$(document).ready( function() {

	// Initialize
	// .. Flash
	$("#logo img").remove();
	$("#logo").flash({
		src:"images/flash/logo.swf",
		width: 316,
		height: 102,
		type:'application/x-shockwave-flash',
		wmode:"transparent"
	});
	$(".sideflash").flash({
		src:"images/flash/sideflash.swf",
		width: 220,
		height: 512,
		wmode:"transparent"
	});
	
	// .. Adjust Window
	resizeWindow();
	$(window).resize( function() { resizeWindow(); });
	$(window).load( function() { resizeWindow(); });
	// Refresh window size for 3 seconds //
	setTimeout("resizeWindow()",1000);
	setTimeout("resizeWindow()",2000);
	setTimeout("resizeWindow()",3000);

	// .. Flags
	$(".arrow_left").click( function() { scrollRight( true ); } );
	$(".arrow_right").click( function() { scrollLeft( true ); } );
	
	// Signup
	$("#form_signup input").click( function() { $("#itzahuman").val( "yup" ); } );
});

function resizeWindow()
{
	$(".content").css('height','');
	var h	= $(window).height() - ($("#container").height() - $(".content").height());
	if( h > $(".content").height() )
	{
		$(".content").height( h );
		
	}else{
		$(".content").css('height','');
	}
}

var scrollPos = 0;
var scrollTimeout = setInterval( "scrollLeft()", 5000 );
function scrollLeft( dis )
{
	if( dis )
		clearInterval( scrollTimeout );
		
	var num_countries = $(".country").length - 1;
	if( scrollPos < num_countries )
	{
		scrollPos++;
		scrollNow();
	}
}
function scrollRight( dis )
{
	if( dis )
		clearInterval( scrollTimeout );
		
	if( scrollPos > 0 )
	{
		scrollPos--;
		scrollNow();
	}
}
function scrollNow()
{
	var width = $("#flag_scroll .country:first").width();
	$("#flag_scroll").animate({ "left": -width*scrollPos + 10 +"px" });
}
