var fv_top=200;
//-----------------
function go_to_ss() {
	parent.location.href="/landing_page_3_successpage.php?complete=1&fn="+$("#fvl_name").val()+"&eml="+$("#fvl_email").val();
}
//-----------------
$.fn.check_email_existing = function() {
	//-------
	var eml  = $(this).val();
	var fn   = $("#fvl_name").val();
	var info = $("#ymuwe");
	var fv_x = $("#fv_x");
	var fv_s = $("#fvl_send");
	//-------
	info.data('message',{
		'yi':info.html(),
		'check':"Please wait a few seconds while we check your email address.",
		'result':"A link to download Song Surgeon<br>will appear on the next page."
	});
	info.html(info.data('message').check)
		.css('font-size','29px');
	fv_x.hide();
	fv_s.hide();
	//-------
	$.ajax({
		type: "POST",
		url: "/engine/validation/email_check/low/yi/",
		data: { 'email':eml },
		dataType: 'json',
		complete: alert(info.data('message').check),
		success: function(data) {
			//-------
			info.html(info.data('message').yi)
				.css('font-size','12pt');
			fv_x.show();
			fv_s.show();
			//-------
			var num = data.errors.length;
			if(num == 0) {
				var fn = $("#fvl_name").val();
				$.ajax({
					type:		"POST",
					url:		"/development/scripts/freegift.php",
					data:		{ 'task':"send_3", 'fn':fn, 'eml':eml },
					success:	function(msg) {
						if(msg != 'good') {
							alert(msg);
						} else {
							info.html(info.data('message').result);
							$("#for_sth_gift_signup").html('<IFRAME src="/fg_signup_3.php?'+Math.random()+'" scrolling="No" frameborder="no"></IFRAME>');
						}
					}
				});
			} else {
				msg = "The email you entered appears to be incorrect.  Please review your email address and either fix it, or if you confirm it is correct, please submit again.";
				alert(msg);
			}	
		}
	});
	//-------
}
//-----------------
$(document).ready(function() {
	//-------
	var fv		= $('#fv_layer');
	var fvx		= $('#fv_x');
	var name	= $("#fvl_name");
	var email	= $("#fvl_email");
	// ---
	if ($.browser.mozilla) {
		fvx.css('left','397px');
	}
	// --- static if it is MAC version page and layer in another states
	if(typeof(mac_version_page) == "undefined") {
		setTimeout('$("#fv_layer").fadeIn("normal").animate({top: '+fv_top+'}, 1000)',20);
		$(window).scroll(function() {
			fv.css('top',(fv_top+document.body.scrollTop)+'px');
		});
	}
	fvx.click(function() {
		fv.animate({left: document.body.clientWidth},1000).fadeOut('fast');
	});
	//-------
	$("#fvl_send").click(function() {
		if((name.val() == '') || (email.val() == '')) {
			alert('Fill empty fields, please.');
		} else {
			email.check_email_existing();
		}
	});
	//-------
});
//-----------------
