//------------------------------------------------------------------------------------
// Script Notice légale
//------------------------------------------------------------------------------------
// s est l’année de création du site.
function showCPR(s) {
    var y = new Date().getYear();
    if (y < 1900) y += 1900;
    if (s != y)
        document.write(s + " - " + y);
    else
        document.write(y);
}
//------------------------------------------------------------------------------------
// Script Anti-flash
//------------------------------------------------------------------------------------
function fixFlash(s) { document.write(s); }

//------------------------------------------------------------------------------------
// Fonction CacheMail
//------------------------------------------------------------------------------------
function CacheMail(mail,domain) {
	this.location = 'mailto:' + mail + '@'+ domain;
}

//------------------------------------------------------------------------------------
// Fonction formulaire
//------------------------------------------------------------------------------------
function isEmail(obj) 
{
       if (obj.value.indexOf(" ") + "" == "-1"
       && obj.value.indexOf("@") + "" != "-1"
       && (obj.value.lastIndexOf(".") > obj.value.indexOf("@"))
       && obj.value != "") return true;
       else return false;
}

function isCP(obj) {
	if (isNaN(obj.value)==false && obj.value.length==5)  return true;
	else return false;
}
function isTel(obj) {
	if (isNaN(obj.value)==false && obj.value.length==10)  return true;
	else return false;
}


function testContact()
{
    if (document.getElementById("txtNom").value == "")
    { alert("Merci d'indiquer le champ 'Nom'."); document.getElementById("txtNom").focus(); return false; }

    if (document.getElementById("txtPrenom").value == "")
    { alert("Merci d'indiquer le champ 'Pr\351nom'."); document.getElementById("txtPrenom").focus(); return false; }

	if (document.getElementById("txtEmail").value == "" || !isEmail(document.getElementById("txtEmail")))
	{ alert("Merci de renseigner correctement le champ 'E-mail' ."); document.getElementById("txtEmail").focus(); return false; }

	if (document.getElementById("txtCodePostal").value != "" && !isCP(document.getElementById("txtCodePostal")))
	{ alert("Merci de renseigner correctement le champ 'Code postal'."); document.getElementById("txtCodePostal").focus(); return false; }

	if (document.getElementById("txtTel").value != "" && !isTel(document.getElementById("txtTel")))
	{ alert("Merci de renseigner correctement le champ 'T\351l\351phone'."); document.getElementById("txtTel").focus(); return false; }

	if (document.getElementById("txtFax").value != "" && !isTel(document.getElementById("txtFax")))
	{ alert("Merci de renseigner correctement le champ 'Fax'."); document.getElementById("txtFax").focus(); return false; }

	if (document.getElementById("txtMessage").value == "")
	{ alert("Attention, le champ 'Message' doit \352tre renseign\351."); document.getElementById("txtMessage").focus(); return false; }

	return true;
}


//-------------------------------------------------------------------------------
// Fonction Captcha()
//-------------------------------------------------------------------------------
function RefreshCaptcha() {
	var i = new Image();
	var d = new Date();
	i.src = '/Includes/modCaptcha.asp?Type=4&Dt=' + d.getHours().toString() + d.getMinutes().toString() + d.getSeconds().toString() ;
	document.getElementById("Captcha").src = i.src;
}


function testDevis()
{
var Form = document.forms["FormDevis"];

 chk_prod1 = Form.prod1_1.checked || Form.prod1_2.checked || Form.prod1_3.checked || Form.prod1_4.checked || Form.prod1_5.checked|| Form.prod1_6.checked || Form.prod1_7.checked;
 chk_prod2 = Form.prod2_1.checked || Form.prod2_2.checked || Form.prod2_3.checked || Form.prod2_4.checked;
 chk_prod3 = Form.prod3_1.checked || Form.prod3_2.checked || Form.prod3_3.checked ;
 chk_prod4 = Form.prod4_1.checked || Form.prod4_2.checked || Form.prod4_3.checked || Form.prod4_4.checked || Form.prod4_5.checked;
 chk_prod5 = Form.prod5_1.checked || Form.prod5_2.checked || Form.prod5_3.checked || Form.prod5_4.checked || Form.prod5_5.checked || Form.prod5_6.checked || Form.prod5_7.checked;
 chk_prod6 = Form.prod6_1.checked || Form.prod6_2.checked || Form.prod6_3.checked || Form.prod6_4.checked;
 chk_prod7 = Form.prod7_1.checked || Form.prod7_2.checked ;
 chk_prod8 = Form.prod8_1.checked || Form.prod8_2.checked || Form.prod8_3.checked;
 chk_prod9 = Form.prod9_1.checked || Form.prod9_2.checked ;
 chk_prod10 = Form.prod10_1.checked || Form.prod10_2.checked || Form.prod10_3.checked;
 chk_prod11 = Form.prod11_1.checked || Form.prod11_2.checked || Form.prod11_3.checked || Form.prod11_4.checked || Form.prod11_5.checked || Form.prod11_6.checked || Form.prod11_7.checked || Form.prod11_8.checked || Form.prod11_9.checked || Form.prod11_10.checked || Form.prod11_11.checked;
 
 if (!chk_prod1 && !chk_prod2 && !chk_prod3 && !chk_prod4 && !chk_prod5 && !chk_prod6 && !chk_prod7 && !chk_prod8 && !chk_prod9 && !chk_prod10 && !chk_prod11) {
 alert("Pour continuer vous devez cocher une ou plusieurs cases !");
 return;
 }
 Form.submit();

}



//-------------------------------------------------------------------------------
// Fonction de l'insription à la newsletter
//-------------------------------------------------------------------------------

function inscriptionNewsletter() 
{
    if (document.getElementById("MailNewsletter").value == "" || !isEmail(document.getElementById("MailNewsletter"))) 
    {
        alert("Merci de renseigner l'e-mail correctement."); document.getElementById("MailNewsletter").focus();
    }
    else 
    {
        document.forms['FormNewsletter'].submit();
    }
        
}


//-------------------------------------------------------------------------------
// Carousel page Traçabilité 
//-------------------------------------------------------------------------------

jQuery(document).ready(function () {
    jQuery('#CarouselTrac').jcarousel({ visible: 3, auto: 3, wrap: 'last', animation:2000 });
});


//-------------------------------------------------------------------------------
// Preload all css images
//-------------------------------------------------------------------------------
$(document).ready(function () {
    $.preloadCssImages();
});


//-------------------------------------------------------------------------------
// lightBox
//-------------------------------------------------------------------------------
$(document).ready(function () {
    $(function () {
        $('#dvDetailCategorie a').lightBox();
    });
});

$(document).ready(function () {
    $(function () {
        $('#CarouselTrac a').lightBox();
    });
});

//-------------------------------------------------------------------------------
// Phototheque
//-------------------------------------------------------------------------------
$(document).ready(function () {
    $(function () {
        $('.tableLienCategorie').click(function () {
            window.location = $(this).parent().attr('href');
        });
    });
});


//-------------------------------------------------------------------------------
// Fonction "Imprimer la recette"
//-------------------------------------------------------------------------------
function printdiv() {
    window.print();
    return false;
}

//-------------------------------------------------------------------------------
// Accordion de la page Equipe
//-------------------------------------------------------------------------------
$(document).ready(function () {
    $(function () {
        $("#accordionEquipe").accordion({ header: "h1", autoHeight: false });

        $('#dialog_link, ul#icons li').hover(
					function () { $(this).addClass('ui-state-hover'); },
					function () { $(this).removeClass('ui-state-hover'); }
				);
    });
});

