function hideVideo()
{
	if( $.browser.msie ) $( '#nomosVideo' ).css({ 'z-index': '-10' });
	else $( '#nomosVideo' ).css({ visibility: 'hidden' });
}

function showVideo()
{
	if( $.browser.msie ) $( '#nomosVideo' ).css({ 'z-index': '10' });
	else $( '#nomosVideo' ).css({ visibility: 'visible' });
}

$( document ).ready( function()
{
	//SyntaxHighlighter.all();

	jwplayer( 'nomosVideo' ).setup
	({
		flashplayer: $.BD +'lib/swf/player.swf',
		autostart: true,
		events:{ onPlay: showVideo },
		bufferlength: 15,
		smoothing: false,
		width: 480,
		height: 270,
		file: vidSrc
	});
	
	if( $.browser.msie && $.browser.version.substr( 0, 1 ) < 7 )
		$( 'body' ).removeClass( 'png' );
		
	if( $.browser.msie ) $( '#search .searchInput' ).focus();
	
	$( '#search .searchInput' ).bind( 'click keypress', searchFocus );
	$( '#search .searchInput' ).blur( searchBlur );
	
	$( '#modal .close' ).click( hideModal );
	
	$( '.showModal' ).click( function()
	{
		showModal( $( this ).attr( 'id' ).split( '-' )[ 2 ] );
	});
	
	$( '#modal-section-subscribe .submit' ).click( function(){ showModal( 'thanks' ); });
	$( '.showPrivacy' ).click( function(){ showModal( 'privacy' ); });
	$( '.showSubscribe' ).click( function(){ showModal( 'subscribe' ); });
	
	$.getScript( 'http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4b8d114c6fff501e' );

	if( $.iDevice )
	{
		$( '#videoListCon' ).bind( 'touchmove', function( e ){ e.preventDefault(); });
		myScroll = new iScroll( 'videoList' );
	}
});

function searchFocus()
{
	$( '#search .searchInput' ).removeClass( 'empty' );
}

function searchBlur()
{
	if( $( '#search .searchInput' ).val() == "" )
		$( '#search .searchInput' ).addClass( 'empty' );
}

function showModal( v )
{
	$( '#mainContent' ).addClass( 'paused' );
	if( !$.iDevice )
	{
		hideVideo();
		if( jwplayer().getState() != 'PAUSED' )
			jwplayer().pause( 'true' );
	}
	
	$( '#modal .section, video' ).hide();	
	$( '#modal #modal-section-'+ v ).show();
	$( '#modal' )
		.css({ height: $( 'body' ).height() })
		.show();
}

function hideModal()
{
	$( '#mainContent' ).removeClass( 'paused' );
	if( !$.iDevice )
	{
		showVideo();
		if( jwplayer().getState() == 'PAUSED' )
			jwplayer().pause( 'false' );
	}	
	
	$( '#modal' ).hide();
	$( 'video' ).show();
}
