/* Author: */
var params = {
		allowScriptAccess: "sameDomain",
		allowFullScreen: "true",
		menu: "false",
		base: "flash/",
		bgColor: "#000000",
		wmode: "transparent"
	};
			
	// Colours
	var flashVars_colours = {
	};
	
	// Controls
	var flashVars_controls = {
	};
	
	// Border
	var flashVars_borders = {
	};
	
	/**
	 * Embeds a VJ video player into the page.
	 */
	function embedVideoPlayer (id)
	{
		swfobject.embedSWF("/flash/vjvideoplayer.swf", "video_" + id, "429", "242", "9.0.260.0", false, this["flashVars_" + id], params, { id: "vid_" + id, name: "vid_" + id } );
	}

$(document).ready(function() {	
	
	var counter2 = 1;
	
	$.doTimeout('spinBanner', 5000, function(){
		
		++counter2;
		
		if(counter2 < 4) 
		{ 
			//set correct trigger
			$('#banner-trigger .triggers-el').each(function(){
				$(this).removeClass("active");
			});
			
			$('#trigger-'+counter2).addClass('active');
			
			if($('#trigger-'+counter2).hasClass('vid-banner'))
			{	
				$('#banner-trigger').animate({
					'margin-top': '-55px',
				    'height': '55px'
				 }, 'slow', function() {
				    // Animation complete.
				 });
			}else
			{
				$('#banner-trigger').css({
					'margin-top': '-94px',
					'height': '100%'
				});	
			}
			
			//set correct banner
			$('.banner-active').fadeOut('fast', function(){
				$(this).removeClass('banner-active');
				$('#banner-'+counter2).fadeIn('fast', function(){
					$(this).addClass('banner-active');
				});
			});
			
			return true;
		}
		 
	});

	$('.triggers-el').hover(function(){
    	
    	$.doTimeout('spinBanner');
    	
    	//set overlay trigger to active
		$('#banner-trigger .triggers-el').each(function(){
        	$(this).removeClass("active");
      	});

		if(!$(this).hasClass('active'))
		{	
			$(this).addClass('active');
		}
		
		//set correct banner to active
		var activeId = ($(this).attr('id')).substr(8,2);
		if(!$('#banner-'+activeId).hasClass('banner-active'))
		{	
			$('.banner-active').fadeOut('fast',  function(){
				$(this).removeClass('banner-active');
				$('#banner-'+activeId).fadeIn('fast', function(){
					$(this).addClass('banner-active');
				});
			});
		}
		
		if($(this).hasClass('vid-banner'))
		{	
			$('#banner-trigger').animate({
				'margin-top': '-55px',
			    'height': '55px'
			 }, 'slow', function() {
			    // Animation complete.
			 });
		}else
		{
			$('#banner-trigger').css({
				'margin-top': '-94px',
				'height': '100%'
			});	
		}
		
    }, function() {
      	$('.banner-active').stop(true, true);
      	$('#banner-'+activeId).stop(true, true);
    });
    
    //embedVideoPlayer('basic');
    
	Cufon.replace('.triggers-el, .video-ban-link', {fontFamily:'clarendon-bold'});
	Cufon.replace('.video-link-title, .video-title, .video-subtitle', {fontFamily:'tusj-bold'});
    
});

