	jQuery(document).ready(function() 
	{	
		jQuery('#go2').click(function()
		{
			slideMenu();
		}); 
	});

	var loadingHtml = '<div class="loader"><h1>Loading Content</h1><p><img src="images/icons/ajax-loader.gif" alt="Loading" /></p></div>';
	
	var loadContent = function(contentType, obj)
	{
		if(obj)
		{
			jQuery('ul.topnav > li > a').removeClass('selected');
			jQuery(obj).addClass('selected');
		}
		
		jQuery('#contentContainer').html(loadingHtml);
		
		jQuery.ajax(
		{
			url: 'index.php?pid=' + contentType + 'Ajax',
			dataType: 'html',
			success: function(responseHtml)
			{
				jQuery('#contentContainer').html(responseHtml);
				Shadowbox.clearCache(); 
				Shadowbox.init({ skipSetup: true}); 
				Shadowbox.setup("a.shadow", {gallery: "andy ansah", continuous: true});	
			}
		});
	}
	
	
	var loadShowreel = function(filter, fileType, bts)
	{
		var param = new Object;
		param['filter'] = filter;
		param['fileType'] = fileType;
		(bts) ? param['bts'] = true : '';
		jQuery('#showreelContainer').html(loadingHtml);
		
		jQuery.ajax(
		{
			data: param,
			type: "POST",
			url: 'index.php?pid=showreelAjax',
			dataType: 'html',
			success: function(responseHtml)
			{
				jQuery('#showreelContainer').html(responseHtml);
				Shadowbox.clearCache(); 
				Shadowbox.init({ skipSetup: true}); 
				Shadowbox.setup("a.shadow", {gallery: "andy ansah", continuous: true});
			}
		});
	}
	
	var slideMenu = function() 
	{
		if ($("#nav").width() == "950") 
		{
			$("#nav" ).animate({ width: "200px" }, 1000 )
			$("#newsreel" ).fadeOut('slow');
			$("#showreel" ).fadeOut('slow');
			$("#blog" ).fadeOut('slow');
			$("#about" ).fadeOut('slow');
			$("#whereIam" ).fadeOut('slow');
			$("#facebook" ).fadeOut('slow');
			$("#twitter" ).fadeOut('slow');
			$("#list2" ).show();
		}
		
		if 	($("#block2").width() == "20") 
		{
			$("#block2" ).animate({ width: "500px" }, 1000 )
			$("#list2" ).hide();
			$("#list" ).show();	
		}
	}
	
	var loadFeaturedVideo = function(videoId, bts)
	{
		var param = new Object;
		param['id'] = videoId;
		(bts) ? param['bts'] = true : '';
		
		//jQuery('#flowLink').html(loadingHtml);
		jQuery('#showreelTitleBox').html(loadingHtml);
		
		jQuery.ajax(
		{
			data: param,
			type: "POST",
			url: 'index.php?pid=featuredVideoAjax',
			dataType: 'json',
			success: function(responseJson)
			{
				createFlowLink(responseJson);
				createTitleBox(responseJson);
			}
		});
	}
	
	var createTitleBox = function(jsonVideo)
	{
		var html = '<div id="showreelTitleBoxLeft">'+
			'<h2>PLAYING <span class="bigOrangeText">' + jsonVideo.video[0].name + '</span></h2>'+				
			'<div class="clearFloat"></div>'+
		'</div>';
		
		jQuery('#showreelTitleBox').html(html);
		
	}
	
	//old version
	/*var createTitleBox = function(jsonVideo)
	{
		var html = '<div id="showreelTitleBoxLeft">'+
			'<h2>PLAYING <span class="bigOrangeText">' + jsonVideo.video[0].name + '</span></h2>'+				
			'<span class="showreelTitleBoxText">'+
				jsonVideo.video[0].text +
			'</span>'+
			'<div class="clearFloat"></div>'+
		'</div>'+
		'<div id="showreelTitleBoxRight">'+
			'<h2 class="blockTextIndent">Featured</h2>'+
			'<div class="clearFloat"></div>';
		
		if(jsonVideo.feature && jsonVideo.feature.length > 0)
		{
			var loopCount = 0;
			
			for(var i = 0; i < jsonVideo.feature.length; i++)
			{
				if(loopCount == 4)
				{
					html += '</ul>';
					loopCount = 0;
				}
				
				(loopCount == 0) ? html += '<ul class="featuredList">' : '';
				html += '<li><a href="#videoContainer" onclick="loadFeaturedVideo(' + jsonVideo.feature[i].id + ')">' + jsonVideo.feature[i].name + '</a></li>';
				loopCount++;
			}
			
			(loopCount % 4 != 0) ? html += '</ul>' : '';
		}
		
		html += '</div><a onclick="scrollTo(\'564px\')" href="#" class="scrollDownArrow blockTextIndent"></a>'+
		'<div class="clearFloat"></div>';
		
		jQuery('#showreelTitleBox').html(html);
		
	}*/
	
	var createFlowLink = function(jsonVideo)
	{
		var flowLink = '<a href="' + jsonVideo.video[0].file + '" style="display:block;width:814px;height:454px" id="player"></a>'+
		'<script language="javascript">$f("player", {src: "swf/flowplayer-3.2.7.swf", cachebusting: true, wmode: "transparent"},'+
			'{'+
				//'clip: { duration: 5,},'+
				'plugins: { controls: null},onBeforePause: function() {return true;},onBeforeFinish: function() {return false;},'+
				'onFinish: function() {loadFeaturedVideo(' + jsonVideo.video[0].next +')}'+
			'});</script>';
			
		jQuery('#flowLink').html(flowLink);
	}
