function SWFAddressRedirect(url) {
	SWFAddress.setValue(String(url));
}

var id_timeout;
function changeTitle(page) {
	killChangeTitle();
	
	var object = {};
    object.swfaddress = page;
    $.get("ajax/pageTitle.php", object, putTitle);
//	id_timeout = setTimeout("changeTitle('" + page + "')",1000);
}
function killChangeTitle() {
	if(id_timeout)
		clearTimeout(id_timeout);
}

function checkEmail(email) {
	var mail_filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

	return mail_filter.test(email);
}

function swapWebcamUpload(media)
{
	if(media == "webcam")
	{
		$("#webcam").show();
		$("#upload").hide();
		$("#media_input_selection").html("I'D LIKE TO <a onclick='swapWebcamUpload(\"upload\");' class='red_color'>UPLOAD A PHOTO</a><font class='red_color'> / </font><font class='red_color_selected'>USE MY WEBCAM</font>");
	}
	else
	{
		$("#webcam").hide();
		$("#upload").show();
		$("#media_input_selection").html("I'D LIKE TO <font class='red_color_selected'>UPLOAD A PHOTO</font><font class='red_color'> / </font><a onclick='swapWebcamUpload(\"webcam\");' class='red_color'>USE MY WEBCAM</a>");
	}
}

function selectApplyForm(form)
{
	if(form == "rankin")
	{
		form_type = "rankin";
		$("#step_3").hide();
		$("#title_step_4").html("3 LET'S DO IT");
		$("#country").removeAttr("disabled");
		$("#country").attr("enabled","enabled");
		$("#country").val("");
		$("#apply_type").html("1 APPLY FOR <font class='red_color_selected'>RANKIN BY YOU</font><font class='red_color'> / </font><a class='red_color' onclick='selectApplyForm(\"shoot\");'>THE LIVE SHOOT</a><font class='red_color'> / </font><a class='red_color' onclick='selectApplyForm(\"both\");'>BOTH</a>");
	}
	else if(form == "shoot")
	{
		form_type = "shoot";
		$("#step_3").show();
		$("#title_step_4").html("4 LET'S DO IT");
		$("#country").removeAttr("enabled");
		$("#country").attr("disabled","disabled");
		$("#country").val("United Kingdom");
		$("#apply_type").html("1 APPLY FOR <a class='red_color' onclick='selectApplyForm(\"rankin\");'>RANKIN BY YOU</a><font class='red_color'> / </font><font class='red_color_selected'>THE LIVE SHOOT</font><font class='red_color'> / </font><a class='red_color' onclick='selectApplyForm(\"both\");'>BOTH</a>");
	}
	else
	{
		form_type = "both";
		$("#step_3").show();
		$("#title_step_4").html("4 LET'S DO IT");
		$("#country").removeAttr("enabled");
		$("#country").attr("disabled","disabled");
		$("#country").val("United Kingdom");
		$("#apply_type").html("1 APPLY FOR <a class='red_color' onclick='selectApplyForm(\"rankin\");'>RANKIN BY YOU</a><font class='red_color'> / </font><a class='red_color' onclick='selectApplyForm(\"shoot\");'>THE LIVE SHOOT</a><font class='red_color'> / </font><font class='red_color_selected'>BOTH</font>");
	}
}

function formTreatment()
{
	if(form_type == "rankin")
		checkRankinByYouForm();
	else if(form_type == "shoot")
		checkFormApply(0);
	else
		checkFormApply(2);
}

function showCredits()
{
	$(window).bind('resize', resizeCredits);
	resizeCredits();
	$("#credits").fadeIn();
}
function hideCredits()
{
	$(window).unbind('resize', resizeCredits);
	$("#credits").fadeOut();
}
function resizeCredits()
{
	var width = document.documentElement.offsetWidth;
	var height = document.documentElement.offsetHeight;

	$("#credits").width(width);
	$("#credits").height(height);
	$("#credits_hide").width(width);
	$("#credits_hide").height(height);
	$("#the_digital_club").css({'top':(height - 470)/2 + 'px', 'left':(width - 470)/2 + 'px'});
	$("#los_rebellos").css({'top':((height - 40)/2 + 150) + 'px', 'left':(width - 250)/2 + 'px'});
}

function showTC()
{
	$(window).bind('resize', resizeTC);
	resizeTC();
	$("#tc_hide").css({'display':'block'});
	$("#tc_hide").fadeTo("fast", 0.7);
	$("#tc").fadeIn();
}
function hideTC()
{
	$(window).unbind('resize', resizeTC);
	$("#tc_hide").fadeOut();
	$("#tc").fadeOut();
}
function resizeTC()
{
	var width = document.documentElement.offsetWidth;
	var height = document.documentElement.offsetHeight;

	$("#tc").css({'top':(height - 450)/2 + 'px', 'left':(width - 675)/2 + 'px'});
	$("#tc_hide").width(width);
	$("#tc_hide").height(height);
}