﻿


$(document).ready(function () {

    $('#imageEnvoyerMessageFraude').click(function () {

        //vérifications préalables
        var mail = $('#MainContent_tbMail').val();
        var commentaire = $('#MainContent_tbCommentaire').val();

        if (mail == "" || commentaire == "") {
            alert("Veuillez renseigner tous les champs obligatoires.");
            return false;
        }
        if (commentaire.length < 10) {
            alert("Veuillez entrer un commentaire d'au moins 10 caractères.");
            return false;

        }
        if (echeck(mail) == false) {
            alert("Vous devez entrer une adresse mail valide.");
            return false;
        }

        $('#MainContent_btEnvoyerFraude').click();

    });



    //btParcourir

    $('#btParcourir').click(function () {

        $('#MainContent_filediag').click();

    });

    $('#MainContent_filediag').change(function () {
        //alert('change() est appelée ');
        var x = $('#MainContent_filediag');
        //alert('sa val() est ' + x.val());
        //alert('son htlm() est ' + x.html());
        $('#MainContent_tbCheminFihcier').val(x.val());

    });

    $(".various").fancybox({
        maxWidth: 800,
        maxHeight: 600,
        fitToView: false,
        width: '70%',
        height: '70%',
        autoSize: false,
        closeClick: false,
        openEffect: 'none',
        closeEffect: 'none'
    });

    $(".various2").fancybox({
        maxWidth: 730,
        maxHeight: 570,
        fitToView: false,
        width: '70%',
        height: '70%',
        autoSize: false,
        closeClick: false,
        openEffect: 'none',
        closeEffect: 'none'
    });

    $(".various3").fancybox({
        maxWidth: 560,
        maxHeight: 230,
        fitToView: false,
        width: '70%',
        height: '70%',
        autoSize: false,
        closeClick: false,
        openEffect: 'none',
        closeEffect: 'none'
    });

    $(".various4").fancybox({
        maxWidth: 560,
        maxHeight: 220,
        fitToView: false,
        width: '70%',
        height: '70%',
        autoSize: false,
        closeClick: true,
        openEffect: 'none',
        closeEffect: 'none'
    });

    // $('.nyroModal').nyroModal();

    InitDialog();


   ImageEvent();

    InitSlide();

           try {
                    getMap();
                }
                catch (e) {
                }


                InitScroll();

});

	function AgrementSaisi(item) {
	    if ($("#id_agrement_" + item).val() == "") return;
	    if ($("#id_agrement_" + item).val() != 0 && $("#id_agrement_" + item).val() != 1 && $("#id_agrement_" + item).val() != 2 && $("#id_agrement_" + item).val() != 3 && $("#id_agrement_" + item).val() != 4 && $("#id_agrement_" + item).val() != 5 && $("#id_agrement_" + item).val() != 6 && $("#id_agrement_" + item).val() != 7 && $("#id_agrement_" + item).val() != 8 && $("#id_agrement_" + item).val() != 9) {
	        $("#id_agrement_" + item).val("");
	        return;
	    }
	    else {
	        item += 1;
	        $("#id_agrement_" + item).focus();
	    }
	}

	function verifAgrement() {

	    var erreur = false;
	    if ($("#id_agrement_1").val() == "") erreur = true;
	    if ($("#id_agrement_2").val() == "") erreur = true;
	    if ($("#id_agrement_3").val() == "") erreur = true;
	    if ($("#id_agrement_4").val() == "") erreur = true;
	    if ($("#id_agrement_5").val() == "") erreur = true;
	    if ($("#id_agrement_6").val() == "") erreur = true;
	    if ($("#id_agrement_7").val() == "") erreur = true;
	    if ($("#id_agrement_8").val() == "") erreur = true;
	    if ($("#id_agrement_9").val() == "") erreur = true;
	    if ($("#id_agrement_10").val() == "") erreur = true;
	    if ($("#id_agrement_11").val() == "") erreur = true;
	    if (erreur) {
	    }
	    else {

	        var id = $("#id_agrement_1").val() + $("#id_agrement_2").val() + $("#id_agrement_3").val()+ $("#id_agrement_4").val() + "-" + $("#id_agrement_5").val() + $("#id_agrement_6").val() + "-" + $("#id_agrement_7").val() + $("#id_agrement_8").val()+"-"+$("#id_agrement_9").val()+$("#id_agrement_10").val()+$("#id_agrement_11").val();
	        $("#dialog").attr({ title: "Vérification d'un agrément" });
	        $("#iframeMSGB").attr({ src: "verifagrement.aspx?id=" + id });
	        $("#dialog").dialog({ autoOpen: true, title: "Vérification d'agrément", height: 260 });

	         $("#id_agrement_1").val("");
	         $("#id_agrement_2").val("");
	         $("#id_agrement_3").val("");
	         $("#id_agrement_4").val("");
	         $("#id_agrement_5").val("");
	         $("#id_agrement_6").val("");
	         $("#id_agrement_7").val("");
	         $("#id_agrement_8").val("");
	         $("#id_agrement_9").val("");
	         $("#id_agrement_10").val("");
	         $("#id_agrement_11").val("");
	    }
	}

	function GetGeoloc() {

	    var adresse = $("#MainContent_adresse").val() + " " + $("#MainContent_cpville").val();
	   
	    createDirections(adresse);
	    return false;
	}

    
    function loadPartenaire(id, nom) {
        $("#dialog").attr({ title: nom });
        $("#iframeMSGB").attr({ src: "detailpartenaire.aspx?id="+id });
        $("#dialog").dialog({ autoOpen: true, title:nom, height:260 });
    }

    function InitScroll() {

        try {
            $('.liste_1_content').jScrollPane();
        } catch (e)
        { }
        try {
            $('.liste_2_content').jScrollPane();
        } catch (e)
        { }
        try {
            $('.liste_3_content').jScrollPane();
        } catch (e)
        { }
        try {
            $('.liste_4_content').jScrollPane();
        } catch (e)
        { }

        var offset = $(".share").offset();
        var topPadding = 0;
        /*
        $(window).scroll(function () {
            if ($(window).scrollTop() > offset.top) {
                var calcul = $(window).scrollTop() - offset.top + topPadding;
                if (calcul < ($(".contenu_article").height() - 400)) {
                    $(".share").stop().animate({
                        marginTop: calcul
                    });
                }
            } else {
                $(".share").stop().animate({
                    marginTop: 0
                });
            };
        });*/


    }

    var font_size = 14;
    var line_height = 16;

    function ZoomP() {
        if (font_size != 20) {
            font_size = font_size + 2;
            line_height = line_height + 2;
            $("#MainContent_text").css("font-size", font_size + "px");
            $("#MainContent_text").css("line-height", font_size + "px");
        }
    }

    function ZoomM() {
        if (font_size != 10) {
            font_size = font_size - 2;
            line_height = line_height - 2;
            $("#MainContent_text").css("font-size", font_size + "px");
            $("#MainContent_text").css("line-height", font_size + "px");
        }
    }


    function MakeSocialTagPopup(url) {
        window.open(url, 'Share', config = 'height=800, width=800, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, directories=no, status=no')

    }

    function InitDialog() {
        $("#dialog:ui-dialog").dialog("destroy");
        $("#dialog").dialog({ autoOpen: false, width: 480 });
    }


    function InitSlide()
    {
        $('#MainContent_slider').nivoSlider({ pauseTime: 5000, effect: 'fold', captionOpacity: 0.7, afterChange: function () {
          //  $("#MainContent_legendImage").html($(".nivo-caption").html());
        }
        });
    }
    function ImageEvent() {
        $(".imagerecherche").hover(

					function () {
					    $(".imagerecherche").attr({ src: "images/rechercher_listes_over.png" });
					},
					function () {
					    $(".imagerecherche").attr({ src: "images/rechercher_listes.png" });
					}
				);

        $("#home_btn").hover(

					function () {
					    $("#home_btn").attr({ src: "images/menu/01_accueil_over.png" });
					},
					function () {
					    $("#home_btn").attr({ src: "images/menu/01_accueil.png" });
					}
				);



        $("#association_btn").hover(

					function () {
					    $("#association_btn").attr({ src: "images/menu/02_association_over.png" });
					},
					function () {
					    $("#association_btn").attr({ src: "images/menu/02_association.png" });
					}
				);


        $("#certification_btn").hover(

					function () {
					    $("#certification_btn").attr({ src: "images/menu/03_certification_over.png" });
					},
					function () {
					    $("#certification_btn").attr({ src: "images/menu/03_certification.png" });
					}
				);


        $("#marque_btn").hover(

					function () {
					    $("#marque_btn").attr({ src: "images/menu/04_marque_over.png" });
					},
					function () {
					    $("#marque_btn").attr({ src: "images/menu/04_marque.png" });
					}
				);

        $("#legislation").hover(

					function () {
					    $("#legislation").attr({ src: "images/icones/01_legislation_over.png" });
					},
					function () {
					    $("#legislation").attr({ src: "images/icones/01_legislation.png" });
					}
				);

        $("#ethique").hover(
                	    function () {
                	        $("#ethique").attr({ src: "images/icones/02_ethique_over.png" });
                	    },
					    function () {
					        $("#ethique").attr({ src: "images/icones/02_ethique.png" });
					    }
				    );

        $("#produits").hover(
                	    function () {
                	        $("#produits").attr({ src: "images/icones/03_produits_over.png" });
                	    },
					    function () {
					        $("#produits").attr({ src: "images/icones/03_produits.png" });
					    }
				    );


        $("#fraudes").hover(
                	    function () {
                	        $("#fraudes").attr({ src: "images/icones/04_fraudes_over.png" });
                	    },
					    function () {
					        $("#fraudes").attr({ src: "images/icones/04_fraudes.png" });
					    }
				    );



        $("#verifier_agrement").hover(
                	    function () {
                	        $("#verifier_agrement").attr({ src: "images/agrement/bouton_verifier_over.png" });
                	    },
					    function () {
					        $("#verifier_agrement").attr({ src: "images/agrement/bouton_verifier.png" });
					    }
				    );

        $("#facebook").hover(
                	    function () {
                	        $("#facebook").attr({ src: "images/plan/facebook_over.png" });
                	    },
					    function () {
					        $("#facebook").attr({ src: "images/plan/facebook.png" });
					    });

        $("#vimeo").hover(
                	    function () {
                	        $("#vimeo").attr({ src: "images/plan/vimeo_over.png" });
                	    },
					    function () {
					        $("#vimeo").attr({ src: "images/plan/vimeo.png" });
					    });


        $("#twitter").hover(
                	    function () {
                	        $("#twitter").attr({ src: "images/plan/twitter_over.png" });
                	    },
					    function () {
					        $("#twitter").attr({ src: "images/plan/twitter.png" });
					    }
				    );

        $("#newsletter").hover(
                	    function () {
                	        $("#newsletter").attr({ src: "images/plan/newsletter_over.png" });
                	    },
					    function () {
					        $("#newsletter").attr({ src: "images/plan/newsletter.png" });
					    }
				    );



        $("#references_btn").hover(

					function () {
					    $("#references_btn").attr({ src: "images/menu/05_references_over.png" });
					},
					function () {
					    $("#references_btn").attr({ src: "images/menu/05_references.png" });
					}
				);


        $("#presse_btn").hover(

					function () {
					    $("#presse_btn").attr({ src: "images/menu/06_presse_over.png" });
					},
					function () {
					    $("#presse_btn").attr({ src: "images/menu/06_presse.png" });
					}
				);


        $("#mediatheque_btn").hover(

					function () {
					    $("#mediatheque_btn").attr({ src: "images/menu/07_mediatheque_over.png" });
					},
					function () {
					    $("#mediatheque_btn").attr({ src: "images/menu/07_mediatheque.png" });
					}
				);


        $("#recrutement_btn").hover(

					function () {
					    $("#recrutement_btn").attr({ src: "images/menu/08_recrutement_over.png" });
					},
					function () {
					    $("#recrutement_btn").attr({ src: "images/menu/08_recrutement.png" });
					}
				);


        $("#contact_btn").hover(

					function () {
					    $("#contact_btn").attr({ src: "images/menu/09_contact_over.png" });
					},
					function () {
					    $("#contact_btn").attr({ src: "images/menu/09_contact.png" });
					}
				);


        $("#liste_boucheries").hover(
					    function () {
					        $("#liste_boucheries").attr({ src: "images/listes/liste_boucheries_over.png" });
					    },
					    function () {
					        $("#liste_boucheries").attr({ src: "images/listes/liste_boucheries.png" });
					    }
				    );



        $("#liste_restaurants").hover(
					    function () {
					        $("#liste_restaurants").attr({ src: "images/listes/liste_restaurants_over.png" });
					    },
					    function () {
					        $("#liste_restaurants").attr({ src: "images/listes/liste_restaurants.png" });
					    }
				    );

        $("#liste_fournisseurs").hover(
					    function () {
					        $("#liste_fournisseurs").attr({ src: "images/listes/liste_fournisseurs_over.png" });
					    },
					    function () {
					        $("#liste_fournisseurs").attr({ src: "images/listes/liste_fournisseurs.png" });
					    }
				    );



        $("#liste_sites").hover(
					    function () {
					        $("#liste_sites").attr({ src: "images/listes/liste_sites_over.png" });
					    },
					    function () {
					        $("#liste_sites").attr({ src: "images/listes/liste_sites.png" });
					    }
				    );

					    //

					    $("#menu_journal").hover(
					    function () {
					        $("#menu_journal").attr({ src: "images/plan/journal_over.png" });
					    },
					    function () {
					        $("#menu_journal").attr({ src: "images/plan/journal.png" });
					    }
				    );

    }
