$(document).ready( function() {

	// Initialize
	// .. Flash
	$("#logo img").remove();
	$("#logo").flash({
		src:"flash/logo.swf",
		width: 316,
		height: 102,
		wmode:"transparent"
	});
	$(".sideflash").flash({
		src:"flash/sideflash.swf",
		width: 220,
		height: 512,
		wmode:"transparent"
	});
	
	// .. Adjust Window
	resizeWindow();
	$(window).resize( function() { resizeWindow(); });

	// .. 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").height( "auto" );
	var h = $(window).height() - 295;
	// Adjust Height?
	if( $(window).height() > $(".content").height() )
	{
		if( h < $(".content").height() )
			h = $(window).height();
			
		$(".content").height( h );
		
	}
		//$(".content").height( $(window).height() - 295 );
}

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 = $("#c_australia").width();
	$("#flag_scroll").animate({ "left": -width*scrollPos + 10 +"px" });
}