function recall() {
    $.ajax({
	    type: "POST",
		url: 'http://www.webgold.fr/wp-content/themes/twentyeleven/js/ajax/recall.php',
		data: "tel="+$("#recall-tel").val(),
		success: function(msg) {
		if (msg == "") {
		    $("#recallint1").css("display", "none");
		    $("#recallint2").fadeIn("slow");
		} else {
		    alert(msg);
		}
	    }
	});
}

﻿function devisForm() {
    $("#choosePresta input").change(function(event) {
	    id = event.target.id.replace("link-", "");
	    if ($("#"+id).css("display") == "none")
		$("#"+id).show();
	    else
		$("#"+id).hide();
	});

    $("#displayMore").click(function() {
	    $("#more").slideDown();
	    $("#consignesMore").slideUp();
	});
    $("#hideMore").click(function() {
	    $("#consignesMore").slideDown();
	    $("#more").slideUp();
	});
}

function refgrid() {
    if ($("#refgrid").length > 0){
	$(document).click(function() {
		$(".refScreen").fadeOut();
	    });
	$(".closeRefScreen").click(function() {
		$(".refScreen").fadeOut();
	    });
	$("#refgrid .pic").mouseover(
				     function(event) {
					 var id = event.target.id;
					 $("#"+id).attr("src", $("#"+id).attr("src").replace(id+"2", id));
				     });
	$("#refgrid .pic").mouseout(
				    function(event) {
					var id = event.target.id;
					if($("#"+id).attr("src")[$("#"+id).attr("src").length-5] != "2") {
					    $("#"+id).attr("src", $("#"+id).attr("src").replace(id, id+"2"));
					}

				    });
	$("#refgrid .pic").click(
				 function(event) {
				     var id = event.target.id;
				     $(".refScreen").css("display", "none");
				     $("#screen-"+id).fadeIn();
				     return false;
				 });
	$(".accessRefScreen").click(function(event) {
		var id = event.target.id;
		window.open($("#"+id).attr("href"), '_blank');
	    });
	$(".accessRefBlog").click(function(event) {
		var id = event.target.id;
		window.open($("#"+id).attr("href"), '_blank');
	    });
	$(".refScreen").click(function() {
		return false;
	    });
    }
}

function sendMessage() {
		$.ajax({
			type: "POST",
		    url: 'http://www.webgold.fr/wp-content/themes/twentyeleven/js/ajax/sendMessage.php',
		    data: "name="+$("#name").val()+"&email="+$("#email").val()+"&message="+$("#message").val()+"&captcha="+$("#captcha").val(),
		    success: function(msg) {
		    if (msg == "") {
				$("#captchaContainerInside").slideUp();
			$(".ok").html("Nous avons bien reçu votre message.<br />Nous vous répondrons dès que possible.");
				$(".ok").slideDown();
		    } else {
				$(".ko").html(msg);
				$(".ko").show();
		    }
		}
	    });
}

function fixedBar() {
    var distance = $("body").width() / 2;
    distance = distance - 550;
    $("#fixedBar").css("right", distance);
}

function fixedBarDisplay() {
    if ($(document).scrollTop() > 150)
	$("#fixedBar").fadeIn("slow");
    else
	$("#fixedBar").fadeOut("slow");
}

function whyus() {
	$(".showWhy").click(function(event) {
		id = event.target.id;
		$(".why").slideUp();
		$(".showWhy").removeClass("showWhySelected");
		$("#"+id).addClass("showWhySelected");
		$("#"+id.replace("sw", "why")).slideDown();
	});
}

function init() {

    refgrid();
    /* Follow Us mouse over effect */
    $("#followUs img").hover(
			     function (event) {
				 id = event.target.id;
				 $("#"+id).attr("src", $("#"+id).attr("src").replace(id, id+"2"));
			     },
			     function (event) {
				 id = event.target.id;
				 $("#"+id).attr("src", $("#"+id).attr("src").replace(id+"2", id));
			     }
			     );
    /* End follow us mouse over effect */

    /* Submit form mouse over effect */
    $("#submit").hover(
		       function () {
			   $("#submit").attr("src", $("#submit").attr("src").replace("submit", "submit2"));
		       },
		       function () {
			   $("#submit").attr("src", $("#submit").attr("src").replace("submit2", "submit"));
		       }
		       );
    /* End submit form mouse over effect */

    /* Footer images hover */
    $("#footerBottom img").hover(
		       function (event) {
			   id = event.target.id;
			   imgname = id.replace("img-", "");
			   $("#"+id).attr("src", $("#"+id).attr("src").replace(imgname, imgname+"2"));
		       },
		       function (event) {
			   id = event.target.id;
			   imgname = id.replace("img-", "");
			   $("#"+id).attr("src", $("#"+id).attr("src").replace(imgname+"2", imgname));
		       }
		       );
    /* End Footer images hover */

    /* Submiting contact message */
    $("#submit").click(
		       function() {
			   if ($("#name").val() == "" || $("#email").val() == "" || $("#message").val() == "")
			       alert("Veuillez remplir tous les champs. Merci.");
			   else
			       $("#captchaContainer").slideDown();
		       }
		       );
    /* END submitting contact message */

    /* Send message */
    $("#sendmessage").click( function() { sendMessage(); });
    /* END send message */

    /* fixed bar */
    fixedBar();
    $("#fixedBar #scrolltop").click(function(){
	    jQuery('html, body').animate({scrollTop:0}, 'slow');
	    return false;
	});
    /* END fixed bar */

    /* Scroll to contact */
    $("#tocontact").click( function() {
	    $.scrollTo( 'max', 600);
	});
    /* END Scroll to contact */


    /* PAGE CREATION DE SITES INTERNET */
    if ($("#sitesInternet").length > 0){
	$("#sitesInternet #plan a").click( function(event) {
		$.scrollTo( '#p'+event.target.id.replace("link", ""), 600);
	    });
    }
    /* end PAGE CREATION DE SITES */

    /* PAGE DEVIS */
    if ($("#devisForm").length > 0)
	devisForm();
    /* end PAGE DEVIS */

	/* PAGE POURQUOI NOUS */
    if ($("#whyus").length > 0)
	whyus();
	/* end POURQUOI NOUS */


    /* RECALL RAPPEL GRATUIT */
    $("#recall-ok").click(function() { recall(); });
    var recalltxt = "Votre numéro de tel";
    $("#recall-tel").val(recalltxt);
    $("#recall-tel").click(function(){
	    if ($("#recall-tel").val() == recalltxt)
		$("#recall-tel").val("");
	});
    $("#recall-tel").blur(function(){
	    if ($("#recall-tel").val() == "")
		$("#recall-tel").val(recalltxt);
	});
    /* end RECALL RAPPEL GRATUIT */

}

window.onload = init;

$(window).resize(fixedBar);
$(window).scroll(fixedBarDisplay);

