﻿// JavaScript Document
	var urlSite = "http://www.shavethetraders.fr/";
	var reflashvars = "";
	function updateVideoFile(fileName){
		reflashvars = fileName;
		reflashvars = reflashvars.replace("flvfile=../", urlSite);
		$("a#telecharger").attr("href",reflashvars.replace(".flv",".mpg"));
	}


	$(document).ready(function()
	{
		var linkBack = window.location.href;
		if(linkBack.match(/#.*/) == "#home") {
			loadVideo('goEnd');
		}
		if(linkBack.match(/#.*/) == "#video1") {
			loadVideo('ShaveTheTradersInterview1_VF.flv');
		}
		if(linkBack.match(/#.*/) == "#video2") {
			loadVideo('ShaveTheTradersInterview2_VF.flv');
		}
		if(linkBack.match(/#.*/) == "#video3") {
			loadVideo('ShaveTheTradersInterview3_VF.flv');
		}
		if(!linkBack.match(/#.*/) || linkBack.match(/#.*/) == "#") {
			loadVideo('ShaveTheTradersCLIP_VF.flv');
		}

		$("a.Blogger").click(function(){
			var flashvars ;
			if($("#videoPlayer").find("embed").length > 0){
				flashvars = $("#videoPlayer").find("embed").attr("flashvars");
			}
			else{
				flashvars = $("#videoPlayer").find("object param:last").attr("value");
			}
			if(reflashvars != "") {
				flashvars = reflashvars;
			}

			flashvars = flashvars.replace("../",urlSite);
			reflashvars = "";

			var content = 	'<object width="422" height="339">\n'+
							'	<param name="movie" value="http://'+ window.location.host +'/swf/Maquette_Rubrique_Kit_Survie_VF.swf"></param>\n'+
							'	<param name="flashvars" value="'+ flashvars +'"></param>\n'+
							'	<param name="allowFullScreen" value="true"></param>\n'+
							'	<param name="wmode" value="transparent"></param>\n'+
							'	<param name="scale" value="showall"></param>\n'+
							'	<embed width="422" height="339" flashvars="'+ flashvars +'" allowfullscreen="true" wmode="transparent" scale="noscale" quality="high" src="http://'+ window.location.host +'/swf/Maquette_Rubrique_Kit_Survie_VF.swf" type="application/x-shockwave-flash"/>\n'+
							'</object>';
			$("#txtBloggerVideo").val(content);
			tb_show('','#TB_inline?height=390&width=542&inlineId=blogger&modal=true','');
		})



		//PHP Team
		var langCurrent = getQueryVariable("lang").toString();
		switch(langCurrent.toLowerCase())
		{
			case "en":
				$("#EnLang").show();
				$("#FrLang").hide();
				break;
			case "1":
			default:
				$("#FrLang").show();
				$("#EnLang").hide();
				break;
		}
	})

function resetSend2friend()
{
	$('#ErrorMsg').html("").hide();
	//$('form').clearForm();
	$("input#yourFirtname").val("");
	$("input#yourEmail").val("");
	$("input#yourEmailfriend1").val("");
	$("input#yourEmailfriend2").val("");
	$("input#yourEmailfriend3").val("");
	$("input#yourEmailfriend4").val("");
	$("input#yourEmailfriend5").val("");
	$("textarea#yourMessage").val("");

	$("label#name_error").hide();
	$("label#email_error").hide();
	$("label#email_invalid").hide();
	$("label#femail_error").hide();
	$("label#femail_invalid").hide();
	$("label#message_error").hide();

	$("#showorhiddenForm").show();
}



$(function() {
	$('.error').hide();
   	$("#btnSubmited").click(function() {
		// validate and process form
		// first hide any error messages
    	$('.error').hide();
		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;

		//your name
		var yourFirtname = $("input#yourFirtname").val();
		if(yourFirtname == ''){
            $("label#name_error").show();
            $("input#yourFirtname").focus();
            return false;
		}else{
            $("label#name_error").hide();
		}

		//your email
		var yourEmail = $("input#yourEmail").val();
		if(yourEmail == ''){
        	$("label#email_error").show();
        	$("label#email_invalid").hide();

        	$("input#yourEmail").focus();
        	return false;
		} else if(!emailReg.test(yourEmail)) {
			$("label#email_error").hide();
        	$("label#email_invalid").show();

        	$("input#yourEmail").focus();
        	return false;
		}else{
			$("label#email_error").hide();
        	$("label#email_invalid").hide();
		}

		//your 1st friend
		var femail1 = $("input#yourEmailfriend1").val();
		if(femail1 == ''){
        	$("label#femail1_error").show();
        	$("label#femail1_invalid").hide();

        	$("input#yourEmailfriend1").focus();
        	return false;

		} else if(!emailReg.test(femail1)) {
			$("label#femail1_error").hide();
        	$("label#femail1_invalid").show();

        	$("input#yourEmailfriend1").focus();
        	return false;

		}else{
			$("label#femail1_error").hide();
        	$("label#femail1_invalid").hide();
		}

		//your 2nd friend (optional)
		var femail2 = $("input#yourEmailfriend2").val();
		if(femail2 != ''){
			if(!emailReg.test(femail2)) {
				$("label#femail2_error").hide();
	        	$("label#femail2_invalid").show();

	        	$("input#yourEmailfriend2").focus();
	        	return false;
			}else{
				$("label#femail2_error").hide();
	        	$("label#femail2_invalid").hide();
			}
		}//end

		//your 3rd friend (optional)
		var femail3 = $("input#yourEmailfriend3").val();
		if(femail3 != ''){
			if(!emailReg.test(femail3)) {
				$("label#femail3_error").hide();
	        	$("label#femail3_invalid").show();

	        	$("input#yourEmailfriend3").focus();
	        	return false;
			}else{
				$("label#femail3_error").hide();
	        	$("label#femail3_invalid").hide();
			}
		}//end

		//your 4th friend (optional)
		var femail4 = $("input#yourEmailfriend4").val();
		if(femail4 != ''){
			if(!emailReg.test(femail4)) {
				$("label#femail4_error").hide();
	        	$("label#femail4_invalid").show();

	        	$("input#yourEmailfriend4").focus();
	        	return false;
			}else{
				$("label#femail4_error").hide();
	        	$("label#femail4_invalid").hide();
			}
		}//end

		//your 5th friend (optional)
		var femail5 = $("input#yourEmailfriend5").val();
		if(femail5 != ''){
			if(!emailReg.test(femail5)) {
				$("label#femail5_error").hide();
	        	$("label#femail5_invalid").show();

	        	$("input#yourEmailfriend5").focus();
	        	return false;
			}else{
				$("label#femail5_error").hide();
	        	$("label#femail5_invalid").hide();
			}
		}//end

		//message
		var message = $("textarea#yourMessage").val();
		if(message == ''){
            $("label#message_error").show();
			$("textarea#yourMessage").focus();
            return false;
		}

		var dataString = 'getLang=' +  $("input#getLang").val()
						+ '&yourFirtname='+ yourFirtname.replace(/&/g, "02526BTPyCO")
						+ '&yourEmail=' + yourEmail
						+ '&yourEmailfriend1=' + femail1
						+ '&yourEmailfriend2=' + femail2
						+ '&yourEmailfriend3=' + femail3
						+ '&yourEmailfriend4=' + femail4
						+ '&yourEmailfriend5=' + femail5
						+ '&yourMessage=' + message.replace(/&/g, "02526BTPyCO");
		$.ajax({
      		type: "POST",
      		url: "sendmail2friend.php",
      		data: dataString,
			//dataType:   'xml',
			//processData: false,
        	//dataType: "json",

      		success: function(data) {
				if (data.toString()=='100')
				{
	        		$('#ErrorMsg').html("Votre email a été envoyé.").hide();
					$("#showorhiddenForm").hide();
        			$('#ErrorMsg').fadeIn(1500, function() {
          				$('#ErrorMsg').append("");
        			});
				}
				else
				{
					$('#ErrorMsg').html("Votre e-mail ne peut pas envoyer.").hide();
					$("#showorhiddenForm").show();
        			$('#ErrorMsg').fadeIn(1500, function() {
          				$('#ErrorMsg').append("");
        			});
				}
      		}
     	});

		return false;
	});

});

function resetCouponForm()
{
	$('#ErrorMsg1').html("").hide();
	$("input#txtName").val("");
	$("input#txtEmail").val("");
	$("input#txtVille").val("");

	$("label#name_error1").hide();
	$("label#email_error1").hide();
	$("label#email_invalid1").hide();
	$("label#ville_error").hide();

	$("#showorhiddenCouponForm").show();
}
$(function() {
	$('.error1').hide();
   	$("#btnSubmited1").click(function() {
		// validate and process form
		// first hide any error messages
    	$('.error1').hide();
		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;

		//your name
		var yourName = $("input#txtName").val();
		if(yourName == ''){
            $("label#name_error1").show();
            $("input#txtName").focus();
            return false;
		}else{
            $("label#name_error1").hide();
		}

		//your email
		var yourEmail = $("input#txtEmail").val();
		if(yourEmail == ''){
        	$("label#email_error1").show();
        	$("label#email_invalid1").hide();

        	$("input#txtEmail").focus();
        	return false;
		} else if(!emailReg.test(yourEmail)) {
			$("label#email_error1").hide();
        	$("label#email_invalid1").show();

        	$("input#txtEmail").focus();
        	return false;
		}else{
			$("label#email_error1").hide();
        	$("label#email_invalid1").hide();
		}
		//your ville
		var yourVille = $("input#txtVille").val();
		if(yourVille == ''){
            $("label#ville_error1").show();
            $("input#txtVille").focus();
            return false;
		}else{
            $("label#ville_error1").hide();
		}

		//close this form
		tb_remove();

		var dataString = 'getLang=' +  $("input#getLang1").val()
						+ '&yourName='  + yourName.replace(/&/g, "02526BTPyCO")
						+ '&yourEmail=' + yourEmail
						+ '&yourVille=' + yourVille.replace(/&/g, "02526BTPyCO");


		document.location.href = 'processCoupon.php?' + dataString;
		return false;
	});

});

