var page_actuel = 0;
var page_open = false;
var page_actu_open = false;
page_Oneactu_open = false;
var repertoireImage = "wp-content/themes/casadoamnei/";
var idpage = 0; 
var id_fond = 7;
var typepage = "home";
var id_out = 7;
var page_init = true;
var positionMenu = -1;
var positionMenu_old = -1;
var request_page = "";
var anin_en_cours = false;
var now_anim = "";
var next_anim = "";
var locationPage = {
    put: function (hash, win) {
        (win || window).location.hash = encodeURIComponent(hash);
    },
    get: function (win) {
        var hash = ((win || window).location.hash).replace(/^#/, "");
        return $.browser.fx ? hash : decodeURIComponent(hash);
    }
};

function setPageActuel(id) {
    page_actuel = id;
}
function startAnimHome() {
    $(window).load(function () {
        changeFond();
        $("#cache_main").fadeOut(1500);
        $("#animationlogo").canimate({
            totalFrames: 29, 
            imagePrefix: "logo",
            fps: 25,
            preload: true,
            loop: false
        });
    });
}
function startAnimHome_suite() {
    $("#onglet_actu").show("slide", {
        direction: "right"
    }, 1000);
    $("#titrerestaurant").delay(0).fadeIn(500, function () {
        $("#zonemenu").css("top", "0px");
         $('#menu li:last').css("background-image","none");
        $("#menu").animate({
            height: "266px"
        }, 1000, "easeInOutQuad", function () {
            $("#zonebtnclick").show();
            if (now_anim == "home") {
                anin_en_cours = false;
                manageNextAnim();
            }
            $("#maskzonetextebarre").delay(100).fadeOut(500, function () {
                if (now_anim == "page") {
                    transition_center_to_page();
                } else {
                    if (now_anim == "actu") {
                        transition_center_to_actu();
                    }
                }
            });
            if (checkVersionValidHTML5()) {
                $("#madmimiombre").fadeIn(800, function () {
                    $("#madmimianim1").animate({
                        top: "0px"
                    }, 1000, "easeInOutQuad");
                });
            } else {
                $("#madmimiombre").show();
                $("#madmimianim1").delay(200).animate({
                    top: "0px"
                }, 1000, "easeInOutQuad");
            }
        });
    });
}
function rewriteURLAJAX() {
    $("#menu_home").click(function () {
        locationPage.put("home");
        return false;
    });
    $("#menu_0").click(function () {
        locationPage.put("pagina_acasa");
        return false;
    });
    $("#menu_1").click(function () {
        locationPage.put("pagina_pensiunea-casa-doamnei");
        return false;
    });
    $("#menu_2").click(function () {
        locationPage.put("pagina_restaurant");
        return false;
    });
    $("#menu_3").click(function () {
        locationPage.put("pagina_preturi-si-oferte");
        return false;
    });
    $("#menu_4").click(function () {
        locationPage.put("pagina_hai-in-bucovina");
        return false;
    });
    $("#menu_5").click(function () {
        locationPage.put("pagina_cartea-de-oaspeti");
        return false;
    });
    $("#menu_6").click(function () {
        locationPage.put("pagina_contact");
        return false;
    });
    $("#onglet_actu").click(function () {
        if (!page_actu_open) {
            locationPage.put("actu");
        } else {
            locationPage.put("home");
        }
        return false;
    });
    $(".btn_savoirplus").click(function () {
        var getidactu = ($(this).attr("id")).replace("actu_", "");
        locationPage.put("actuid" + getidactu);
        return false;
    });
    $(".vignette").click(function () {
        var getidactu = ($(this).attr("id")).replace("vignette_", "");
        locationPage.put("actuid" + getidactu);
        return false;
    });
}
function activateHistory() {
    var php_gets = "null";
    $.history.init(function (hash) {
        if (hash == "") {
            php_gets = extractUrlParams();
        } else {
            php_gets = "null";
        }
        if (hash == "home") {
            id_fond = 7;
            positionMenu = -1;
            if (!anin_en_cours) {
                next_anim = "";
                animHome();
            } else {
                next_anim = "home";
            }
        } else {
            if (hash == "actu" || (hash != "actu" && php_gets.indexOf("p=") != -1) || hash.indexOf("actuid") != -1) {
                positionMenu = -1;
                $("#zonepage").css("z-index", 5);
                $(".actuzone").css("z-index", 12);
                if (php_gets != "null" && hash.indexOf("actuid") == -1) {
                    jumpToOneActu(false);
                } else {
                    if (hash.indexOf("actuid") != -1) {
                        loadActu(hash.replace("actuid", ""));
                    }
                }
                if (!anin_en_cours) {
                    next_anim = "";
                    animActu();
                } else {
                    next_anim = "actu";
                }
            } else {
                if (hash.indexOf("pagina_") != -1 || (hash.indexOf("pagina_") == -1 && php_gets.indexOf("page_id") != -1)) {
                    $("#zonepage").css("z-index", 6);
                    $(".actuzone").css("z-index", 5);
                    typepage = hash.replace("pagina_", "");
                    var gets_idpage = 0;
                    if (php_gets != "null") {
                        gets_idpage = php_gets.replace("page_id=", "");
                    }
                    if (typepage == "acasa" || gets_idpage == 71) {
                        idpage = 71;
                        id_fond = 0;
                        positionMenu = 0;
                    } else {
                        if (typepage == "pensiunea-casa-doamnei" || gets_idpage == 8) {
                            idpage = 8;
                            id_fond = 1;
                            positionMenu = 1;
                        } else {
                            if (typepage == "restaurant" || gets_idpage == 2) {
                                idpage = 2;
                                id_fond = 2;
                                positionMenu = 2;
                            } else {
                                if (typepage == "preturi-si-oferte" || gets_idpage == 18) {
                                    idpage = 18;
                                    id_fond = 3;
                                    positionMenu = 3;
                                } else {
                                    if (typepage == "hai-in-bucovina" || gets_idpage == 58) {
                                        idpage = 58;
                                        id_fond = 4;
                                        positionMenu = 4;
                                    } else {
                                        if (typepage == "cartea-de-oaspeti" || gets_idpage == 60) {
                                            idpage = 60;
                                            id_fond = 5;
                                            positionMenu = 5;
                                        } else {
                                            if (typepage == "contact" || gets_idpage == 62) {
                                                idpage = 62;
                                                id_fond = 6;
                                                positionMenu = 6;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if (!anin_en_cours) {
                        next_anim = "";
                        animPage();
                    } else {
                        next_anim = "page";
                    }
                } else {
                    page_init = false;
                }
            }
        }
        return false;
    }, {
        unescape: ",/"
    });
}


function animPage() {
    anin_en_cours = true;
    now_anim = "page";
    if (!page_open && !page_init && !page_actu_open) {
        transition_center_to_page();
        page_open = true;
    } else {
        if (page_open && !page_init && !page_actu_open) {
            page_open = true;
            anin_en_cours = false;
            transition_page_to_page();
        } else {
            if (page_actu_open && !page_init) {
                page_open = true;
                transition_actu_to_page();
            }
        }
    }
    page_init = false;
}
function animActu() {
    stopAjax();
    anin_en_cours = true;
    now_anim = "actu";
    if (!page_actu_open && !page_init && !page_open) {
        transition_center_to_actu();
    } else {
        if (!page_actu_open && !page_init && page_open) {
            transition_page_to_actu();
        } else {
            if (page_Oneactu_open && !page_init) {
                anin_en_cours = false;
                backToListActu();
            }
        }
    }
    page_init = false;
}
function animHome() {
    stopAjax();
    anin_en_cours = true;
    now_anim = "home";
    adjustSelectedMenu();
    if (page_open) {
        transition_page_to_center();
    } else {
        if (page_actu_open) {
            transition_actu_to_center();
        }
    }
    page_init = false;
}
function manageNextAnim() {
    if (now_anim == "page" && next_anim == "home") {
        stopAjax();
        next_anim = "";
        anin_en_cours = true;
        transition_page_to_center();
    } else {
        if (now_anim == "page" && next_anim == "actu") {
            stopAjax();
            next_anim = "";
            anin_en_cours = true;
            transition_page_to_actu();
        } else {
            if (now_anim == "page" && next_anim == "page") {
                next_anim = "";
                anin_en_cours = true;
                transition_page_to_page();
            }
        }
    }
    if (now_anim == "actu" && next_anim == "home") {
        stopAjax();
        next_anim = "";
        anin_en_cours = true;
        transition_actu_to_center();
    } else {
        if (now_anim == "actu" && next_anim == "page") {
            next_anim = "";
            anin_en_cours = true;
            transition_actu_to_page();
        }
    }
    if (now_anim == "home" && next_anim == "actu") {
        stopAjax();
        next_anim = "";
        anin_en_cours = true;
        transition_center_to_actu();
    } else {
        if (now_anim == "home" && next_anim == "page") {
            next_anim = "";
            anin_en_cours = true;
            transition_center_to_page();
        }
    }
}
function assurePositionBloc() {
    if (!anin_en_cours) {
        if (locationPage.get() == "home") {
            $("#onglet_actu").stop().animate({
                left: "268px"
            }, 200);
            $("#barremain").stop().animate({
                left: "307px"
            }, 200);
            $("#blocactu").stop().animate({
                left: "517px"
            }, 200);
            $("#blocpage").stop().animate({
                left: -$("#blocpage").width() + "px"
            }, 200);
        } else {
            if (locationPage.get() == "actu") {
                $("#barremain").stop().animate({
                    left: "560px"
                }, 200, "easeInOutQuad");
                $("#blocactu").stop().animate({
                    left: "517px"
                }, 200);
                $("#blocactu").stop().animate({
                    left: "7px"
                }, 200);
                $("#onglet_actu").stop().animate({
                    left: "14px"
                }, 200);
            } else {
                if (locationPage.get() == "page") {
                    $("#barremain").stop().animate({
                        left: "50px"
                    }, 200, "easeInOutQuad");
                }
            }
        }
    }
}
function stopAjax() {
    if (request_page != "") {
        request_page.abort();
    }
}
function loadActu(getidactu) {
    $.get("./wp-ajax/get-contenuactu.php", {
        idactu: getidactu
    }, function (data) {
        $("#actuUne").html(data);
        jumpToOneActu(true);
    });
}
function jumpToOneActu(animateJump) {
    anin_en_cours = false;
    page_Oneactu_open = true;
    $(".btn_retour").click(function () {
        locationPage.put("actu");
        return false;
    });
	 Cufon.replace(".actu_entier h3 ", {
        fontFamily: "casadoamnei"
    });
	Cufon.replace(".actu_entier h4 ", {
        fontFamily: "casadoamnei"
    });
	Cufon.replace(".actu_entier h5 ", {
        fontFamily: "casadoamnei"
    });
	var contHeight = $(window).height();
	var uneHeight = $(".actu_entier").height();
	var maineBar = $("#barremain").height();
	var dinHeight = $("#listeactu").height();
        
	if( uneHeight >= contHeight && maineBar >= contHeight){}
	

    $(".ngg-galleryoverview a.grouped_elements").fancybox({
				'transitionIn'		: 'elastic',
				'transitionOut'		: 'elastic',
				'overlayShow'	: true,
				'titlePosition' 	: 'over',
				'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
					return '<span id="fancybox-title-over">Pensiunea Casa Doamnei - Voronet. Imaginea ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
				}
			}); 
			$(".rezervare_btn").click(function () {
        sounds.playSon1();
        nobei_futurebox("", "", '<iframe frameborder="0" style="border:none;" src="http://casadoamnei.ro/booking/frontend/" width="420" height="400"></iframe>', false, 1000);
    });
    if (animateJump) {
        $("#zonemoveactu").stop().animate({
            left: "-490px"
        }, 1000, "easeInOutQuad", function () {
            anin_en_cours = false;
            page_Oneactu_open = true;
			$("#dinamic").css("height", uneHeight);
        });
    } else {
		$("#dinamic").css("height", uneHeight);
        anin_en_cours = false;
        page_Oneactu_open = true;
        $("#zonemoveactu").stop();
		/*$("#dinamic").css("height", "100%");*/
        $("#zonemoveactu").css({
            left: "-490px"
        });
    }
    $(".btn_retour").mouseover(function () {
        $(this).animate({
            left: "-11"
        }, 300).stop(true, true);
    });
    $(".btn_retour").mouseout(function () {
        $(this).animate({
            left: "1"
        }, 300).stop(true, true);
    });
    $(".btn_retour").click(function () {
        return false;
    });
}
function transition_center_to_actu() {
    now_anim = "actu";
    page_actu_open = true;
    page_open = false; 
	var dinHeight = $("#listeactu").height();
	var listPost = $(window).height();
		var uneHeight = $(".actu_entier").height();
	$("#dinamic").css("height", uneHeight);
	
    $("#barremain").stop().animate({
        left: "560px"
    }, 1500, "easeInOutQuad");
    $("#blocactu").stop().animate({
        left: "517px"
    }, 1500);
    $("#onglet_actu").stop().animate({
        left: "525px"
    }, 1500, function () {
        $("#blocactu").animate({
            left: "7px"
        }, 1500, "easeInOutQuad");
        $("#onglet_actu").animate({
            left: "14px"
        }, 1500, "easeInOutQuad", function () {
            anin_en_cours = false;
            manageNextAnim();
        });
		
		    $(".btn_retour").click(function () {
		 backToListActu();
    });
   		var allHeight = $(window).height();
	var postHeight = $("#blocactu").height();
	var barMaine = $("#barremain").height();
	var dinHeight = $("#listeactu").height();
	if( postHeight >= allHeight && barMaine >= allHeight){
		
	$("#blocactu").css("height", barMaine).css({'overflow' : 'auto', 'width' : '507px', 'margin-right' : '0px'});
	} else{
		$("#blocactu").css("height", allHeight).css({'overflow' : 'hidden', 'width' : '517px', 'margin-right' : '0px'});
		};

    });
}
function transition_actu_to_center() {
    now_anim = "home";
    changeFond();
    page_actu_open = false;
	$(".actuzone").css("z-index", 5);
    $("#barremain").stop();
    $("#blocpage").stop();
    $("#blocactu").stop().delay(50).animate({
        left: "517px"
    }, 1500, "easeInOutQuad");
    $("#onglet_actu").stop().delay(50).animate({
        left: "525px"
    }, 1500, "easeInOutQuad", function () {
        transition_barre_to_center();
		 backToListActu();
    });
}
function transition_actu_to_page() {
    anin_en_cours = true;
    now_anim = "page";
    changeFond();
    page_open = true;
    page_actu_open = false;
    $("#blocactu").stop();
    $("#onglet_actu").stop();
    $("#blocactu").delay(50).animate({
        left: "517px"
    }, 1500, "easeInOutQuad");
    $("#onglet_actu").delay(50).animate({
        left: "525px"
    }, 1500, "easeInOutQuad", function () {
		 backToListActu();
        $("#onglet_actu").animate({
            left: "80px"
        }, 1000, "easeInOutQuad");
        $("#barremain").stop().animate({
            left: "50px"
        }, 1000, "easeOutQuad", function () {
            $("#onglet_actu").stop().delay(1500).animate({
                left: "11px"
            }, 1200, "easeInOutQuad");
            loadPage();
            anin_en_cours = false;
            manageNextAnim();
        });
    });
}
function backToListActu() {
	var dinHeight = $("#listeactu").height();
    page_Oneactu_open = false;
    $("#zonemoveactu").stop().animate({
        left: "36px"
    }, 1000, "easeInOutQuad");
	$("#dinamic").css("height", dinHeight);
}
function transition_center_to_page() {
    now_anim = "page";
    $("#onglet_actu").stop().animate({
        left: "11px"
    }, 1500, "easeInOutQuad");
    $("#barremain").stop().animate({
        left: "50px"
    }, 1600, "easeOutQuad", function () {
        loadPage();
        anin_en_cours = false;
        manageNextAnim();
    });
    adjustSelectedMenu();
    if (id_out != id_fond) {
        id_out = "#bgimg" + id_out;
        $(id_out).fadeOut("slow");
        var id_in = "#bgimg" + id_fond;
        id_out = id_fond;
        $(id_in).fadeIn("slow");
    }
}
function transition_page_to_page() {
    now_anim = "page";
    adjustSelectedMenu();
    $("#blocpage").stop();
    changeFond();
    if (page_open) {
        $("#blocpage").stop().animate({
            left: -$("#blocpage").width() +  "px"
        }, 1000, "easeInOutQuad", function () {
            loadPage();
            anin_en_cours = false;
        })//.css({'overflow' : 'hidden', 'width' : '542', 'margin-right' : '0px'});
		
    } else {
        loadPage();
        anin_en_cours = false;
    }
}
function transition_page_to_center() {
    now_anim = "home";
    changeFond();
    page_open = false;
    $("#blocpage").stop().delay(200).animate({
        left: -$("#blocpage").width() + "px"
    }, 1500, "easeInOutQuad");
    transition_barre_to_center();
}
function transition_page_to_actu() {
    now_anim = "actu";
    page_open = false;
    page_actu_open = true;
	backToListActu();
    anin_en_cours = true;
    adjustSelectedMenu();
	var dinHeight = $("#listeactu").height();
	var listPost = $(window).height();
	$("#dinamic").css("height", dinHeight);
    $("#barremain").stop();
    $("#onglet_actu").stop();
    $("#blocpage").stop();
    $("#blocpage").stop().animate({
        left: -$("#blocpage").width() + "px"
    }, 1500, "easeInOutQuad", function () {
        if (next_anim != "") {
            page_open = true;
            page_actu_open = false;
            now_anim = "page";
            anin_en_cours = false;
            manageNextAnim();
			$("#dinamic").css("height", dinHeight);
        } else {
			$("#dinamic").css("height", dinHeight);
            $("#barremain").stop().animate({
                left: "560px"
            }, 1500, "easeInOutQuad");
            $("#onglet_actu").stop().animate({
                left: "525px"
            }, 1500, function () {
                $("#blocactu").stop().animate({
                    left: "7px"
                }, 1500, "easeInOutQuad");
                $("#onglet_actu").animate({
                    left: "14px"
                }, 1500, "easeInOutQuad", function () {
                    anin_en_cours = false;
                    if (next_anim != "") {
                        manageNextAnim();
                    }
						//resize here
	var allHeight = $(window).height();
	var postHeight = $("#blocactu").height();
	var barMaine = $("#barremain").height();
	var dinHeight = $("#listeactu").height();
	if( postHeight >= allHeight && barMaine >= allHeight){
		
	$("#blocactu").css("height", barMaine).css({'overflow' : 'auto', 'width' : '507px', 'margin-right' : '0px'});
	} else{
		$("#blocactu").css("height", allHeight).css({'overflow' : 'hidden', 'width' : '517px', 'margin-right' : '0px'});
		};


	//end

                });
            });
        }
    });
}
function loadPage() {
    page_open = true;
    if (idpage != 201) {
        request_page = $.get("./wp-ajax/get-contenupage.php", {
            id: idpage
        }, function (data) {
            if (next_anim == "" || next_anim == "page") {
                displayPage(data);
            }
        });
    } else {
        request_page = $.get("./wp-ajax/get-livreor.php", {}, function (data) {
            if (next_anim == "" || next_anim == "page") {
                displayPage(data);
            }
        });
    }
}
function displayPage(data) {
    anin_en_cours = false;
    $("#contenupage").html("");
    $("#contenupage").html(data);
    activeMaps();
    activeLivreOr();
	var contentHeight = $(window).height();
	var divHeight = $("#blocpage").height();
	var mainBar = $("#barremain").height();
	if( divHeight >= contentHeight && mainBar >= contentHeight){
	$("#blocpage").css("height", mainBar).css({'overflow' : 'auto', 'width' : '534px', 'margin-right' : '0px'});
	} else{
		$("#blocpage").css("height", contentHeight).css({'overflow' : 'hidden', 'width' : '542', 'margin-right' : '8px'});
		};
	$(".ngg-galleryoverview a.grouped_elements").fancybox({
				'transitionIn'		: 'elastic',
				'transitionOut'		: 'elastic',
				'overlayShow'	: true,
				'titlePosition' 	: 'over',
				'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
					return '<span id="fancybox-title-over">Pensiunea Casa Doamnei - Voronet. Imaginea ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
				}
			}); 
     $(".rezervare_btn").click(function () {
        sounds.playSon1();
        nobei_futurebox("", "", '<iframe frameborder="0" style="border:none;" src="http://casadoamnei.ro/booking/frontend/" width="420" height="400"></iframe>', false, 1000);
		return false;
    });
    $(".texte1").jScrollPaneRemove();
    $(".texte1").jScrollPane({
        scrollbarWidth: 17,
        wheelSpeed: 20,
        dragMaxHeight: 41,
        animateTo: true
    });
	
    Cufon.replace(".zonetitre .titre", {
        fontFamily: "casadoamnei"
        //textShadow: "1px 1px white"
    });
    Cufon.replace(".zonetitre .soustitre", {
        fontFamily: "casadoamnei"
    });
	Cufon.replace("h2", {
        fontFamily: "casadoamnei"
    });
	Cufon.replace("h3", {
        fontFamily: "casadoamnei"
    });
	Cufon.replace("h4", {
        fontFamily: "casadoamnei"
    });
	Cufon.replace("h5", {
        fontFamily: "casadoamnei"
    });
	Cufon.replace("h6", {
        fontFamily: "casadoamnei"
    });
    $(".zonediapo #image_page").hide();
    $("#diapoloader").show();
    adjustSelectedMenu();
    $("#blocpage").stop().animate({
        left: "0px"
    }, 1100, "easeInOutQuad", function () {
        $(".zonediapo #image_page").delay(0).fadeIn(500);
        $("#diapoloader").fadeOut(100);
    });
    $("#onglet_actu").stop().delay(1500).animate({
        left: "11px"
    }, 1200, "easeInOutQuad");
    $(".jScrollPaneDragTop").click(function () {
        var divtexte = $(".texte1");
        var divtexteposition = $(".texte1").position();
        divtexte[0].scrollTo(Math.abs(divtexteposition.top) - 100);
    });
    $(".jScrollPaneDragBottom").click(function () {
        var divtexte = $(".texte1");
        var divtexteposition = $(".texte1").position();
        divtexte[0].scrollTo(Math.abs(divtexteposition.top) + 100);
    });

}

function transition_barre_to_center() {
    anin_en_cours = true;
    $("#blocactu").stop();
    $("#blocpage").stop();
    $("#onglet_actu").stop();
    $("#onglet_actu").stop().animate({
        left: "268px"
    }, 1500, "easeInOutQuad");
    $("#barremain").stop().animate({
        left: "307px"
    }, 1500, "easeInOutQuad", function () {
        adjustSelectedMenu();
        anin_en_cours = false;
        manageNextAnim();
    });
}
function adjustSelectedMenu() {
    var ecartMenu = 34;
    var departMenu = 0;
    $("#menu_0 .menu_off").show();
    $("#menu_1 .menu_off").show();
    $("#menu_2 .menu_off").show();
    $("#menu_3 .menu_off").show();
    $("#menu_4 .menu_off").show();
    $("#menu_5 .menu_off").show();
    $("#menu_6 .menu_off").show();
    $("#menu_0 .menu_on").hide();
    $("#menu_1 .menu_on").hide();
    $("#menu_2 .menu_on").hide();
    $("#menu_3 .menu_on").hide();
    $("#menu_4 .menu_on").hide();
    $("#menu_5 .menu_on").hide();
    $("#menu_6 .menu_on").hide();
    if (positionMenu != -1) {
        $("#bgclick").stop();
        if ($("#bgclick").css("top") != (positionMenu * ecartMenu + departMenu) + "px") {
            $("#bgclick").animate({
                top: (positionMenu * ecartMenu + departMenu) + "px"
            }, 600, "easeInOutQuad", function () {});
        }
    } else {
        $("#bgclick").stop().animate({
            top: "-150px"
        }, 1000, "easeInOutQuad");
        positionMenu_old = positionMenu;
    }
}
function changeFond() {
    if (id_out != id_fond) {
        id_out = "#bgimg" + id_out;
        $(id_out).fadeOut("slow");
        var id_in = "#bgimg" + id_fond;
        id_out = id_fond;
        $(id_in).fadeIn("slow");
    }
}
function activeLivreOr() {
    if (idpage == 201) {
        $(".form-submit").click(function () {
            if ($("#author").val() == "") {
                alert("");
                return false;
            } else {
                if ($("#email").val() == "") {
                    alert("");
                    return false;
                } else {
                    if (!livreOr_testmail($("#email").val())) {
                        alert("");
                        return false;
                    } else {
                        if ($("#comment").val() == "") {
                            alert("");
                            return false;
                        } else {
                            alert("");
                        }
                    }
                }
            }
        });
    }
}
function livreOr_testmail(mailteste) {
    var reg = new RegExp("^[a-z0-9]+([_|.|-]{1}[a-z0-9]+)*@[a-z0-9]+([_|.|-]{1}[a-z0-9]+)*[.]{1}[a-z]{2,6}$", "i");
    return (reg.test(mailteste));
}
function lastItem(){
   
}
function activeMaps() {
    if (idpage == 62) {
        $(".mapsgoogle").fancybox({
			    'width' : 800,
				'height' : 600,
				'titleShow' :false,
			    'autoScale'     	: true,
				'transitionIn'		: 'elastic',
				'transitionOut'		: 'elastic',
				'overlayShow'	: true,
				'hideOnContentClick' : false,
				'type'				: 'iframe'
				
			}); 
        animMap1();
    }
}
function animMap1() {
    if (idpage == 62) {
        $("#mapsombre img").animate({
            width: "18px",
            height: "7px"
        }, 800, "easeInOutQuad");
        $("#mapsicon").animate({
            top: "112px"
        }, 800, "easeInOutQuad", function () {
            animMap2();
        });
    }
}
function animMap2() {
    if (idpage == 62) {
        $("#mapsombre img").animate({
            width: "26px",
            height: "9px"
        }, 800, "easeInOutQuad");
        $("#mapsicon").animate({
            top: "132px"
        }, 800, "easeInOutQuad", function () {
            animMap1();
        });
    }
}
function mouseRolloverMenu() {
    var savealt = "";
    var savetitle = "";
    if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {} else {
        $(".ongletmenu").mouseover(function () {
            var self = $("img", this);
            var savealt = $(self).parent().attr("alt");
            var savetitle = $(self).parent().attr("title");
            $(self).parent().removeAttr("title").removeAttr("alt");
            var id_menuon = $(this).attr("id");
            if (id_menuon.replace("menu_", "") != positionMenu) {
                $(".menu_off", this).hide();
                $(".menu_on", this).show();
            }
        });
        $(".ongletmenu ").mouseout(function () {
            var self = $("img", this);
            $(self).parent().attr({
                title: savetitle,
                alt: savealt
            });
            $(".menu_off", this).show();
            $(".menu_on", this).hide();
        });
    }
}
function mouseRolloverActu() {
    $(".btn_savoirplus ").mouseover(function () {
        $(this).animate({
            right: "30"
        }, 300).stop(true, true);
    });
    $(".btn_savoirplus").mouseout(function () {
        $(this).animate({
            right: "35"
        }, 300).stop(true, true);
    });
    $(".vignette").mouseover(function () {
        animActuActive = true;
        var angle1 = -Math.round(Math.random() * 8 + 2);
        var angle2 = -Math.round(Math.random() * 3 + 2);
        $(".vignettecache_img", this).rotate({
            animateTo: -8
        });
        $(".vignetteimg_img", this).rotate({
            animateTo: -8
        });
        $(".vignette1_img", this).rotate({
            animateTo: -8
        });
        $(".vignette2", this).stop().animate({
            left: "-2",
            top: "-2"
        }, 500);
    });
    $(".vignette").mouseout(function () {
        $(".vignettecache_img", this).rotate({
            animateTo: 0
        });
        $(".vignetteimg_img", this).rotate({
            animateTo: 0
        });
        $(".vignette1_img", this).rotate({
            animateTo: 0
        });
        $(".vignette2", this).stop().animate({
            left: "-7",
            top: "-7"
        }, 500, function () {
            animActuActive = false;
        });
    });
}
function adjustScroll(nameDiv, top) {
    if (top) {
        $(nameDiv).stop().animate({
            scrollTop: 0
        }, 1500);
    } else {
        $(nameDiv).stop().animate({
            scrollTop: 20
        }, 1500);
    }
}
function extractUrlParams() {
    var t = location.search.substring(1);
    return t;
}
function displayInfo() {
    $("#infos_toremove").html("anin_en_cours: " + anin_en_cours + "<br>nowanim: " + now_anim + "<br>next_anim: " + next_anim);
}
function manageMadmimi() {
    $("#madmimi_btn").click(function () {
        var input_email = $("#signup_email").val();
        if (input_email.indexOf("Entrer votre email ici") != -1 || input_email == "") {
            $("#signup_email").val("   Entrez une adresse svp...");
            setTimeout("initMadmimi()", 3000);
        } else {
            if (!test_email(input_email)) {
                $("#signup_email").val("  Adresse non valide...");
                setTimeout("initMadmimi()", 3000);
            } else {
                $.post("http://madmimi.com/signups/subscribe/32439", {
                    "signup[email]": input_email
                }, function (data) {});
                $("#signup_email").val("   Merci pour votre inscription");
                setTimeout("initMadmimi()", 3000);
            }
        }
    });
}
function initMadmimi() {
    var input_email = $("#signup_email").val();
    if (input_email.indexOf("Entrer votre email ici") != -1 || input_email.indexOf("Adresse non valide") != -1 || input_email.indexOf("Merci pour votre inscription") != -1) {
        $("#signup_email").val("       Entrer votre email ici");
    }
}
function test_email(my_email) {
    var reg = new RegExp("^[a-z0-9]+([_|.|-]{1}[a-z0-9]+)*@[a-z0-9]+([_|.|-]{1}[a-z0-9]+)*[.]{1}[a-z]{2,6}$", "i");
    if (reg.test(my_email)) {
        return (true);
    } else {
        return (false);
    }
}

