;jQuery(document).ready(function()
{



	/* Client Showcase - Initialise */
	
	var fadeBox = '#fadeBox';
	var fI;
	
	for( fI = 1; fI < 9; fI++ )
	{
		var leftPos = 122 * ( fI - 1 );
		
		jQuery('<div id="fC'+fI+'" style="left: '+leftPos+'px;" class="fCell"></div>').appendTo(fadeBox);
	};
 

});



jQuery(window).load(function()
{
	/* Load Stats */
	
	var statsContainer = '#tradingStats';
	jQuery(statsContainer).data( 'status', 'b7dbe9512e5f28ec88a6116001f9a2e788eeb130' );
	
	function statsLoad()
	{	
		jQuery.ajax({
			url      : '/wordpress/wp-content/themes/blur/js/rq_get_stats.php',
			type     : 'GET',
			cache    : false,
			dataType : 'json',
			success  : function(data)
			{
				jQuery(statsContainer).empty();
				
				jQuery(statsContainer).data( 'status', data.hash );
				
				if( data.status == 'success' )
				{
					jQuery(statsContainer).append(data.html);
				}
				else
				{
					jQuery(statsContainer).append(data.html);
				}
			}
		});
	
	};
	
	statsLoad();
	
	
	
	/* Check Stats */
	
	var statsTimer;
	var statsTimeout = 60000;
	
	function statsCheck()
	{
		jQuery.ajax({
			url      : '/wordpress/wp-content/themes/blur/js/rq_check_stats.php',
			type     : 'GET',
			cache    : false,
			dataType : 'json',
			beforeSend: function()
			{
				clearTimeout( statsTimer );
			},
			success  : function(data)
			{
				var statusCurrent = jQuery(statsContainer).data('status');
				
				if( data.status == 'success' && statusCurrent != data.hash )
				{
					statsLoad();
				}
			},
			complete: function()
			{
				clearTimeout( statsTimer );
				statsTimer = setTimeout( function(){ statsCheck() }, statsTimeout );
			}
		});
	
	};
	
	statsTimer = setTimeout( function(){ statsCheck() }, statsTimeout );
	
	
	
	
	/* Client Showcase - Run */
	
	var fFadeBox   = '#fadeBox';
	var fLogosBox  = '#logosBox';
	var fFadeSpeed = 400;
	var fTimeOut   = 6000;
	var fTimer;
	
	function logosFadeOut()
	{
		clearTimeout(fTimer);
		
		var fInI;
		for( fInI = 1; fInI < 9; fInI++ )
		{
			var fadeCascade = ( fFadeSpeed * 0.2 ) * ( fInI - 1 );
			
			if( fInI == 8 )
			{
				jQuery('#fC'+fInI).delay(fadeCascade).fadeIn( fFadeSpeed, function(){ logosNext(); } );
			}
			else
			{
				jQuery('#fC'+fInI).delay(fadeCascade).fadeIn( fFadeSpeed );
			}
		}
	};
	
	function logosFadeIn()
	{
		var fInI;
		for( fInI = 1; fInI < 9; fInI++ )
		{
			var fadeCascade = ( fFadeSpeed * 0.2 ) * ( fInI - 1 );
			
			if( fInI == 8 )
			{
				jQuery('#fC'+fInI).delay(fadeCascade).fadeOut( fFadeSpeed, function()
				{
					fTimer = setTimeout( function(){ logosRun(); }, fTimeOut );
				} );
			}
			else
			{
				jQuery('#fC'+fInI).delay(fadeCascade).fadeOut( fFadeSpeed );
			}
		}
	};
	
	function logosNext()
	{
		var fInI;
		for( fInI = 1; fInI < 9; fInI++ )
		{
			var getFirst = jQuery(fLogosBox).find('.lCell:first').detach();
			getFirst.appendTo(fLogosBox);
		}
		
		logosFadeIn();
	};
	
	function logosRun()
	{
		logosFadeOut();
	};
	
	
	fTimer = setTimeout( function(){ logosRun(); }, fTimeOut );	
	
		
	
});


/*  form contact - */ 
function savemail(){
	
	
	var e=jQuery('#newsl').val();
	
	if (e!=""){
	
			var d="e="+e;
				 			 	
			jQuery('#isnewsl').fadeOut(200);
		
			jQuery.ajax({
			   type: "POST",
			   url: "/wordpress/wp-content/themes/blur/js/newsletter.php",
			   data: d,
			   success: function(m){
					jQuery('#isnewsl').html(m);
					jQuery('#isnewsl').fadeIn(200);
			   }
			});
		
		
	}else{
		// no value
	}  
	
} 

