// C_SPY_EnvoiAmi

var G_TEST_ENVOIAMI = 0;

var G_LOCAL;

function ApparaitreEnvoiAmi()
{
	jQuery("#C_SPY_CACHE_BG").css("top","0");
	jQuery("#C_SPY_CACHE_BG").css("left","0");
	jQuery("#C_SPY_CACHE_BG").width(jQuery(document).width());
	jQuery("#C_SPY_CACHE_BG").height(jQuery(document).height());
	
	jQuery("#C_SPY_EnvoiAmi").css("top", jQuery(document).scrollTop() + screen.height / 2 - 240);
	jQuery("#C_SPY_EnvoiAmi").css("left", jQuery(document).scrollLeft() + screen.width / 2 - 320);
	
	jQuery("#F_R_NAME").focus();
	
	jQuery("#C_SPY_CACHE_BG").show('normal', function () { jQuery("#C_SPY_EnvoiAmi").show('normal')});
}

function validateFriendSendSubmit(iLang)
{
	sNomR = jQuery("#F_R_NAME").attr("value");
	sCourrielR = jQuery("#F_R_EMAIL").attr("value");
	sNomE = jQuery("#F_S_NAME").attr("value");
	sCourrielE = jQuery("#F_S_EMAIL").attr("value");
	sMessage = jQuery("#F_MESSAGE").text();
	sFURL = jQuery("#URL").attr("value");
	iDevise = jQuery("#DEVISE").attr("value");
	sCode = jQuery("#CAPTCHACODE").attr("value");
	
	aMsgs = new Array(
		new Array("- Please enter your friend's name.\n",
			"- Please enter your friend's email.\n",
			"- Please enter your name.\n",
			"- Please enter your email.\n",
			"- Please enter a message.\n",
			"- Please enter the validation code.\n"
			),
		new Array("- Veuillez entrer le nom de votre ami.\n",
			"- Veuillez entrer le courriel de votre ami.\n",
			"- Veuillez entrer votre nom.\n",
			"- Veuillez entrer votre courriel.\n",
			"- Veuillez entrer un message.\n",
			"- Veuillez entrer le code de validation\n"
			));
	
	sMsg = "";
	
	if (sNomR.length == 0)
	{
		sMsg += aMsgs[iLang][0];
	}

	if (sCourrielR.length == 0)
	{
		sMsg += aMsgs[iLang][1];
	}

	if (sNomE.length == 0)
	{
		sMsg += aMsgs[iLang][2];
	}

	if (sCourrielE.length == 0)
	{
		sMsg += aMsgs[iLang][3];
	}
	
	if (sMessage.length == 0)
	{
		sMsg += aMsgs[iLang][4];
	}

	if (sCode.length == 0)
	{
		sMsg += aMsgs[iLang][5];
	}
	
	if (sMsg.length > 0)
	{
		alert(sMsg);
	}
	else
	{
		switch (iLang)
		{
			case G_EN:
				G_LOCAL = "en-";
				break;
			case G_FR:
				G_LOCAL = "fr-";
				break;
		}

		switch (iDevise)
		{
			case G_CAD:
				G_LOCAL += "ca";
				break;
			case G_USD:
				G_LOCAL += "us";
				break;
		}

		sURL = G_BASEURL+G_LOCAL+"/REGISTERSENDTOFRIEND";
		sURL += "?L="+iLang;
		sURL += "&C="+iDevise;
		sURL += "&S_N="+sNomE;
		sURL += "&S_E="+sCourrielE;
		sURL += "&R_N="+sNomR;
		sURL += "&R_E="+sCourrielR;
		sURL += "&U="+sFURL;
		sURL += "&M="+sMessage;
		sURL += "&CC="+sCode;
	
		if (G_TEST_ENVOIAMI) alert(sURL);
	
		jQuery("#C_SPY_EnvoiAmi").empty();
		jQuery("#C_SPY_EnvoiAmi").load(encodeURI(sURL));
	}
}

function Cacher()
{
	jQuery("#C_SPY_EnvoiAmi").hide('fast', function () { jQuery("#C_SPY_CACHE_BG").hide('fast')});
}