jQuery.extend({

    easing:
    {
        swing: function(p, n, firstNum, diff) {

            var c = firstNum + diff;

            var s = 1.70158; // default overshoot value, can be adjusted to suit
            return c * (p /= 1) * p * ((s + 1) * p - s) + firstNum;
        },

        // ******* back
        backEaseIn: function(p, n, firstNum, diff) {

            var c = firstNum + diff;

            var s = 1.70158; // default overshoot value, can be adjusted to suit
            return c * (p /= 1) * p * ((s + 1) * p - s) + firstNum;
        },

        backEaseOut: function(p, n, firstNum, diff) {

            var c = firstNum + diff;

            var s = 1.70158; // default overshoot value, can be adjusted to suit
            return c * ((p = p / 1 - 1) * p * ((s + 1) * p + s) + 1) + firstNum;
        },

        backEaseInOut: function(p, n, firstNum, diff) {

            var c = firstNum + diff;

            var s = 1.70158; // default overshoot value, can be adjusted to suit
            if ((p /= 0.5) < 1)
                return c / 2 * (p * p * (((s *= (1.525)) + 1) * p - s)) + firstNum;
            else
                return c / 2 * ((p -= 2) * p * (((s *= (1.525)) + 1) * p + s) + 2) + firstNum;
        },

        // ******* bounce
        bounceEaseIn: function(p, n, firstNum, diff) {

            var c = firstNum + diff;
            var inv = this.bounceEaseOut(1 - p, 1, 0, diff);
            return c - inv + firstNum;
        },

        bounceEaseOut: function(p, n, firstNum, diff) {

            var c = firstNum + diff;

            if (p < (1 / 2.75)) {
                return c * (7.5625 * p * p) + firstNum;
            }
            else if (p < (2 / 2.75)) {
                return c * (7.5625 * (p -= (1.5 / 2.75)) * p + .75) + firstNum;
            }
            else if (p < (2.5 / 2.75)) {
                return c * (7.5625 * (p -= (2.25 / 2.75)) * p + .9375) + firstNum;
            }
            else {
                return c * (7.5625 * (p -= (2.625 / 2.75)) * p + .984375) + firstNum;
            }
        },


        // ******* circ
        circEaseIn: function(p, n, firstNum, diff) {

            var c = firstNum + diff;

            return -c * (Math.sqrt(1 - (p /= 1) * p) - 1) + firstNum;
        },

        circEaseOut: function(p, n, firstNum, diff) {

            var c = firstNum + diff;

            return c * Math.sqrt(1 - (p = p / 1 - 1) * p) + firstNum;
        },

        circEaseInOut: function(p, n, firstNum, diff) {

            var c = firstNum + diff;

            if ((p /= 0.5) < 1)
                return -c / 2 * (Math.sqrt(1 - p * p) - 1) + firstNum;
            else
                return c / 2 * (Math.sqrt(1 - (p -= 2) * p) + 1) + firstNum;
        },

        // ******* cubic
        cubicEaseIn: function(p, n, firstNum, diff) {

            var c = firstNum + diff;

            return c * (p /= 1) * p * p + firstNum;
        },

        cubicEaseOut: function(p, n, firstNum, diff) {

            var c = firstNum + diff;

            return c * ((p = p / 1 - 1) * p * p + 1) + firstNum;
        },

        cubicEaseInOut: function(p, n, firstNum, diff) {

            var c = firstNum + diff;

            if ((p /= 0.5) < 1)
                return c / 2 * p * p * p + firstNum;
            else
                return c / 2 * ((p -= 2) * p * p + 2) + firstNum;
        },

        // ******* elastic
        elasticEaseIn: function(p, n, firstNum, diff) {

            var c = firstNum + diff;

            if (p == 0) return firstNum;
            if (p == 1) return c;


            var peroid = 0.25;
            var s;
            var amplitude = c;

            if (amplitude < Math.abs(c)) {
                amplitude = c;
                s = peroid / 4;
            }
            else {
                s = peroid / (2 * Math.PI) * Math.asin(c / amplitude);
            }

            return -(amplitude * Math.pow(2, 10 * (p -= 1)) * Math.sin((p * 1 - s) * (2 * Math.PI) / peroid)) + firstNum;
        },

        elasticEaseOut: function(p, n, firstNum, diff) {

            var c = firstNum + diff;

            if (p == 0) return firstNum;
            if (p == 1) return c;

            var peroid = 0.25;
            var s;
            var amplitude = c;

            if (amplitude < Math.abs(c)) {
                amplitude = c;
                s = peroid / 4;
            }
            else {
                s = peroid / (2 * Math.PI) * Math.asin(c / amplitude);
            }

            return -(amplitude * Math.pow(2, -10 * p) * Math.sin((p * 1 - s) * (2 * Math.PI) / peroid)) + c;
        },

        // ******* expo
        expoEaseIn: function(p, n, firstNum, diff) {

            var c = firstNum + diff;

            return (p == 0) ? firstNum : c * Math.pow(2, 10 * (p - 1)) + firstNum - c * 0.001;
        },

        expoEaseOut: function(p, n, firstNum, diff) {

            var c = firstNum + diff;

            return (p == 1) ? c : diff * 1.001 * (-Math.pow(2, -10 * p) + 1) + firstNum;
        },

        expoEaseInOut: function(p, n, firstNum, diff) {

            var c = firstNum + diff;

            if (p == 0) return firstNum;
            if (p == 1) return c;

            if ((p /= 0.5) < 1)
                return c / 2 * Math.pow(2, 10 * (p - 1)) + firstNum - c * 0.0005;
            else
                return c / 2 * 1.0005 * (-Math.pow(2, -10 * --p) + 2) + firstNum;
        },

        // ******* quad
        quadEaseIn: function(p, n, firstNum, diff) {

            var c = firstNum + diff;

            return c * (p /= 1) * p + firstNum;
        },

        quadEaseOut: function(p, n, firstNum, diff) {

            var c = firstNum + diff;

            return -c * (p /= 1) * (p - 2) + firstNum;
        },

        quadEaseInOut: function(p, n, firstNum, diff) {

            var c = firstNum + diff;

            if ((p /= 0.5) < 1)
                return c / 2 * p * p + firstNum;
            else
                return -c / 2 * ((--p) * (p - 2) - 1) + firstNum;
        },

        // ******* quart
        quartEaseIn: function(p, n, firstNum, diff) {

            var c = firstNum + diff;

            return c * (p /= 1) * p * p * p + firstNum;
        },

        quartEaseOut: function(p, n, firstNum, diff) {

            var c = firstNum + diff;

            return -c * ((p = p / 1 - 1) * p * p * p - 1) + firstNum;
        },

        quartEaseInOut: function(p, n, firstNum, diff) {

            var c = firstNum + diff;

            if ((p /= 0.5) < 1)
                return c / 2 * p * p * p * p + firstNum;
            else
                return -c / 2 * ((p -= 2) * p * p * p - 2) + firstNum;
        },

        // ******* quint
        quintEaseIn: function(p, n, firstNum, diff) {

            var c = firstNum + diff;

            return c * (p /= 1) * p * p * p * p + firstNum;
        },

        quintEaseOut: function(p, n, firstNum, diff) {

            var c = firstNum + diff;

            return c * ((p = p / 1 - 1) * p * p * p * p + 1) + firstNum;
        },

        quintEaseInOut: function(p, n, firstNum, diff) {

            var c = firstNum + diff;

            if ((p /= 0.5) < 1)
                return c / 2 * p * p * p * p * p + firstNum;
            else
                return c / 2 * ((p -= 2) * p * p * p * p + 2) + firstNum;
        },

        // *******  sine
        sineEaseIn: function(p, n, firstNum, diff) {

            var c = firstNum + diff;
            return -c * Math.cos(p * (Math.PI / 2)) + c + firstNum;
        },

        sineEaseOut: function(p, n, firstNum, diff) {

            var c = firstNum + diff;
            return c * Math.sin(p * (Math.PI / 2)) + firstNum;
        },

        sineEaseInOut: function(p, n, firstNum, diff) {

            var c = firstNum + diff;
            return -c / 2 * (Math.cos(Math.PI * p) - 1) + firstNum;
        }
    }
});
/* ------------------------------------------------------------------------
Class: prettyPhoto
Use: Lightbox clone for jQuery
Author: Stephane Caron (http://www.no-margin-for-errors.com)
Version: 2.4.3
------------------------------------------------------------------------- */

var $pp_pic_holder;
var $ppt;
(function(A) {

    A.fn.prettyPhoto = function(W) {
        var E = true; var K = false; var O = [];
        var D = 0; var R; var S; var V; var Y; var F = "image";
        var Z; var M = G();
        A(window).scroll(function() { M = G(); C() });
        A(window).resize(function() { C(); U() });
        A(document).keypress(function(c) {
            switch (c.keyCode) {
                case 37: if (D == 1) { return } N("previous"); break; case 39: if (D == setCount) { return }
                    N("next"); break; case 27: L(); break
            }
        });
        W = jQuery.extend({ animationSpeed: "normal", padding: 40, opacity: 0.8, showTitle: true, allowresize: true, counter_separator_label: "/", theme: "light_rounded",
            callback: function() { }
        }, W);

        if (A.browser.msie && A.browser.version == 6) { W.theme = "light_square" }
        A(this).each(function() {
            var e = false; var d = false; var f = 0; var c = 0; O[O.length] = this;
            A(this).bind("click", function() { J(this); return false })
        });
        function J(c) {
            Z = A(c); theRel = Z.attr("rel");
            galleryRegExp = /\[(?:.*)\]/; theGallery = galleryRegExp.exec(theRel); isSet = false; setCount = 0; b();
            for (i = 0; i < O.length; i++) { if (A(O[i]).attr("rel").indexOf(theGallery) != -1) { setCount++; if (setCount > 1) { isSet = true } if (A(O[i]).attr("href") == Z.attr("href")) { D = setCount; arrayPosition = i } } } X(); $pp_pic_holder.find("p.currentTextHolder").text(D + W.counter_separator_label + setCount);
            C();
            A("#pp_full_res").hide();
            $pp_pic_holder.find(".pp_loaderIcon").show()
        } showimage = function(f, c, j, h, g, d, e) {
            //action a effectu� avant ouverture
            //$("#Menu").css("top", "-200px");
            A(".pp_loaderIcon").hide();
            if (A.browser.opera) { windowHeight = window.innerHeight; windowWidth = window.innerWidth } else { windowHeight = A(window).height(); windowWidth = A(window).width() } $pp_pic_holder.find(".pp_content").animate({ height: g }, W.animationSpeed); projectedTop = M.scrollTop + ((windowHeight / 2) - (h / 2)); if (projectedTop < 0) { projectedTop = 0 + $pp_pic_holder.find(".ppt").height() } $pp_pic_holder.animate({ top: projectedTop, left: ((windowWidth / 2) - (j / 2)), width: j }, W.animationSpeed, function() { $pp_pic_holder.width(j); $pp_pic_holder.find(".pp_hoverContainer,#fullResImage").height(c).width(f); $pp_pic_holder.find("#pp_full_res").fadeIn(W.animationSpeed, function() { A(this).find("object,embed").css("visibility", "visible") }); I(); if (e) { A("a.pp_expand,a.pp_contract").fadeIn(W.animationSpeed) } })
        }; function I() { if (isSet && F == "image") { $pp_pic_holder.find(".pp_hoverContainer").fadeIn(W.animationSpeed) } else { $pp_pic_holder.find(".pp_hoverContainer").hide() } $pp_pic_holder.find(".pp_details").fadeIn(W.animationSpeed); if (W.showTitle && hasTitle) { $ppt.css({ top: $pp_pic_holder.offset().top - 22, left: $pp_pic_holder.offset().left + (W.padding / 2), display: "none" }); $ppt.fadeIn(W.animationSpeed) } } function Q() { $pp_pic_holder.find(".pp_hoverContainer,.pp_details").fadeOut(W.animationSpeed); $pp_pic_holder.find("#pp_full_res object,#pp_full_res embed").css("visibility", "hidden"); $pp_pic_holder.find("#pp_full_res").fadeOut(W.animationSpeed, function() { A(".pp_loaderIcon").show(); a() }); $ppt.fadeOut(W.animationSpeed) } function N(c) { if (c == "previous") { arrayPosition--; D-- } else { arrayPosition++; D++ } if (!E) { E = true } Q(); A("a.pp_expand,a.pp_contract").fadeOut(W.animationSpeed, function() { A(this).removeClass("pp_contract").addClass("pp_expand") }) } function L() { $pp_pic_holder.find("object,embed").css("visibility", "hidden"); A("div.pp_pic_holder,div.ppt").fadeOut(W.animationSpeed); A("div.pp_overlay").fadeOut(W.animationSpeed, function() { A("div.pp_overlay,div.pp_pic_holder,div.ppt").remove(); if (A.browser.msie && A.browser.version == 6) { A("select").css("visibility", "visible") } W.callback() }); E = true } function H() { if (D == setCount) { $pp_pic_holder.find("a.pp_next").css("visibility", "hidden"); $pp_pic_holder.find("a.pp_arrow_next").addClass("disabled").unbind("click") } else { $pp_pic_holder.find("a.pp_next").css("visibility", "visible"); $pp_pic_holder.find("a.pp_arrow_next.disabled").removeClass("disabled").bind("click", function() { N("next"); return false }) } if (D == 1) { $pp_pic_holder.find("a.pp_previous").css("visibility", "hidden"); $pp_pic_holder.find("a.pp_arrow_previous").addClass("disabled").unbind("click") } else { $pp_pic_holder.find("a.pp_previous").css("visibility", "visible"); $pp_pic_holder.find("a.pp_arrow_previous.disabled").removeClass("disabled").bind("click", function() { N("previous"); return false }) } $pp_pic_holder.find("p.currentTextHolder").text(D + W.counter_separator_label + setCount); Z = (isSet) ? A(O[arrayPosition]) : Z; b(); if (Z.attr("title")) { $pp_pic_holder.find(".pp_description").show().html(unescape(Z.attr("title"))) } else { $pp_pic_holder.find(".pp_description").hide().text("") } if (Z.find("img").attr("alt") && W.showTitle) { hasTitle = true; $ppt.html(unescape(Z.find("img").attr("alt"))) } else { hasTitle = false } } function P(d, c) { hasBeenResized = false; T(d, c); imageWidth = d; imageHeight = c; windowHeight = A(window).height(); windowWidth = A(window).width(); if (((Y > windowWidth) || (V > windowHeight)) && E && W.allowresize && !K) { hasBeenResized = true; notFitting = true; while (notFitting) { if ((Y > windowWidth)) { imageWidth = (windowWidth - 200); imageHeight = (c / d) * imageWidth } else { if ((V > windowHeight)) { imageHeight = (windowHeight - 200); imageWidth = (d / c) * imageHeight } else { notFitting = false } } V = imageHeight; Y = imageWidth } T(imageWidth, imageHeight) } return { width: imageWidth, height: imageHeight, containerHeight: V, containerWidth: Y, contentHeight: R, contentWidth: S, resized: hasBeenResized} } function T(d, c) { $pp_pic_holder.find(".pp_details").width(d).find(".pp_description").width(d - parseFloat($pp_pic_holder.find("a.pp_close").css("width"))); R = c + $pp_pic_holder.find(".pp_details").height() + parseFloat($pp_pic_holder.find(".pp_details").css("marginTop")) + parseFloat($pp_pic_holder.find(".pp_details").css("marginBottom")); S = d; V = R + $pp_pic_holder.find(".ppt").height() + $pp_pic_holder.find(".pp_top").height() + $pp_pic_holder.find(".pp_bottom").height(); Y = d + W.padding } function b() { if (Z.attr("href").match(/youtube\.com\/watch/i)) { F = "youtube" } else { if (Z.attr("href").indexOf(".mov") != -1) { F = "quicktime" } else { if (Z.attr("href").indexOf(".swf") != -1) { F = "flash" } else { if (Z.attr("href").indexOf("iframe") != -1) { F = "iframe" } else { F = "image" } } } } } function C() { if ($pp_pic_holder) { if ($pp_pic_holder.size() == 0) { return } } else { return } if (A.browser.opera) { windowHeight = window.innerHeight; windowWidth = window.innerWidth } else { windowHeight = A(window).height(); windowWidth = A(window).width() } if (E) { $pHeight = $pp_pic_holder.height(); $pWidth = $pp_pic_holder.width(); $tHeight = $ppt.height(); projectedTop = (windowHeight / 2) + M.scrollTop - ($pHeight / 2); if (projectedTop < 0) { projectedTop = 0 + $tHeight } $pp_pic_holder.css({ top: projectedTop, left: (windowWidth / 2) + M.scrollLeft - ($pWidth / 2) }); $ppt.css({ top: projectedTop - $tHeight, left: (windowWidth / 2) + M.scrollLeft - ($pWidth / 2) + (W.padding / 2) }) } } function a() { H(); if (F == "image") { imgPreloader = new Image(); nextImage = new Image(); if (isSet && D > setCount) { nextImage.src = A(O[arrayPosition + 1]).attr("href") } prevImage = new Image(); if (isSet && O[arrayPosition - 1]) { prevImage.src = A(O[arrayPosition - 1]).attr("href") } pp_typeMarkup = '<img id="fullResImage" src="" />'; $pp_pic_holder.find("#pp_full_res")[0].innerHTML = pp_typeMarkup; $pp_pic_holder.find(".pp_content").css("overflow", "hidden"); $pp_pic_holder.find("#fullResImage").attr("src", Z.attr("href")); imgPreloader.onload = function() { var c = P(imgPreloader.width, imgPreloader.height); imgPreloader.width = c.width; imgPreloader.height = c.height; showimage(imgPreloader.width, imgPreloader.height, c.containerWidth, c.containerHeight, c.contentHeight, c.contentWidth, c.resized) }; imgPreloader.src = Z.attr("href") } else { movie_width = (parseFloat(B("width", Z.attr("href")))) ? B("width", Z.attr("href")) : "425"; movie_height = (parseFloat(B("height", Z.attr("href")))) ? B("height", Z.attr("href")) : "344"; if (movie_width.indexOf("%") != -1 || movie_height.indexOf("%") != -1) { movie_height = (A(window).height() * parseFloat(movie_height) / 100) - 100; movie_width = (A(window).width() * parseFloat(movie_width) / 100) - 100; parsentBased = true } else { movie_height = parseFloat(movie_height); movie_width = parseFloat(movie_width) } if (F == "quicktime") { movie_height += 13 } correctSizes = P(movie_width, movie_height); if (F == "youtube") { pp_typeMarkup = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + correctSizes.width + '" height="' + correctSizes.height + '"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://www.youtube.com/v/' + B("v", Z.attr("href")) + '" /><embed src="http://www.youtube.com/v/' + B("v", Z.attr("href")) + '" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="' + correctSizes.width + '" height="' + correctSizes.height + '"></embed></object>' } else { if (F == "quicktime") { pp_typeMarkup = '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" height="' + correctSizes.height + '" width="' + correctSizes.width + '"><param name="src" value="' + Z.attr("href") + '"><param name="autoplay" value="true"><param name="type" value="video/quicktime"><embed src="' + Z.attr("href") + '" height="' + correctSizes.height + '" width="' + correctSizes.width + '" autoplay="true" type="video/quicktime" pluginspage="http://www.apple.com/quicktime/download/"></embed></object>' } else { if (F == "flash") { flash_vars = Z.attr("href"); flash_vars = flash_vars.substring(Z.attr("href").indexOf("flashvars") + 10, Z.attr("href").length); filename = Z.attr("href"); filename = filename.substring(0, filename.indexOf("?")); pp_typeMarkup = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + correctSizes.width + '" height="' + correctSizes.height + '"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="' + filename + "?" + flash_vars + '" /><embed src="' + filename + "?" + flash_vars + '" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="' + correctSizes.width + '" height="' + correctSizes.height + '"></embed></object>' } else { if (F == "iframe") { movie_url = Z.attr("href"); movie_url = movie_url.substr(0, movie_url.indexOf("iframe") - 1); pp_typeMarkup = '<iframe src ="' + movie_url + '" width="' + (correctSizes.width - 10) + '" height="' + (correctSizes.height - 10) + '" frameborder="no"></iframe>' } } } } $pp_pic_holder.find("#pp_full_res")[0].innerHTML = pp_typeMarkup; showimage(correctSizes.width, correctSizes.height, correctSizes.containerWidth, correctSizes.containerHeight, correctSizes.contentHeight, correctSizes.contentWidth, correctSizes.resized) } } function G() { if (self.pageYOffset) { scrollTop = self.pageYOffset; scrollLeft = self.pageXOffset } else { if (document.documentElement && document.documentElement.scrollTop) { scrollTop = document.documentElement.scrollTop; scrollLeft = document.documentElement.scrollLeft } else { if (document.body) { scrollTop = document.body.scrollTop; scrollLeft = document.body.scrollLeft } } } return { scrollTop: scrollTop, scrollLeft: scrollLeft} } function U() { A("div.pp_overlay").css({ height: A(document).height(), width: A(window).width() }) } function X() {
            toInject = ""; toInject += "<div class='pp_overlay'></div>"; if (F == "image") { pp_typeMarkup = '<img id="fullResImage" src="" />' } else { pp_typeMarkup = "" } toInject += '<div class="pp_pic_holder"><div class="pp_top"><div class="pp_left"></div><div class="pp_middle"></div><div class="pp_right"></div></div><div class="pp_content"><a href="#" class="pp_expand" title="Expand the image">Expand</a><div class="pp_loaderIcon"></div><div class="pp_hoverContainer"><a class="pp_next" href="#">next</a><a class="pp_previous" href="#">previous</a></div><div id="pp_full_res">' + pp_typeMarkup + '</div><div class="pp_details clearfix"><a class="pp_close" href="#">Close</a><p class="pp_description"></p><div class="pp_nav"><a href="#" class="pp_arrow_previous">Previous</a><p class="currentTextHolder">0' + W.counter_separator_label + '0</p><a href="#" class="pp_arrow_next">Next</a></div></div></div><div class="pp_bottom"><div class="pp_left"></div><div class="pp_middle"></div><div class="pp_right"></div></div></div>'; toInject += '<div class="ppt"></div>'; A("body").append(toInject); $pp_pic_holder = A(".pp_pic_holder"); $ppt = A(".ppt"); A("div.pp_overlay").css("height", A(document).height()).bind("click", function() { L() }); $pp_pic_holder.css({ opacity: 0 }).addClass(W.theme);
            A("a.pp_close").bind("click", function() {
                //action a �ffectu� apres fermeture
                //$("#Menu").css("top", "250px");
                L(); return false
            });
            A("a.pp_expand").bind("click", function() { $this = A(this); if ($this.hasClass("pp_expand")) { $this.removeClass("pp_expand").addClass("pp_contract"); E = false } else { $this.removeClass("pp_contract").addClass("pp_expand"); E = true } Q(); $pp_pic_holder.find(".pp_hoverContainer, #pp_full_res, .pp_details").fadeOut(W.animationSpeed, function() { a() }); return false }); $pp_pic_holder.find(".pp_previous, .pp_arrow_previous").bind("click", function() { N("previous"); return false }); $pp_pic_holder.find(".pp_next, .pp_arrow_next").bind("click", function() { N("next"); return false }); $pp_pic_holder.find(".pp_hoverContainer").css({ "margin-left": W.padding / 2 }); if (!isSet) { $pp_pic_holder.find(".pp_hoverContainer,.pp_nav").hide() } if (A.browser.msie && A.browser.version == 6) { A("body").addClass("ie6"); A("select").css("visibility", "hidden") } A("div.pp_overlay").css("opacity", 0).fadeTo(W.animationSpeed, W.opacity, function() { $pp_pic_holder.css("opacity", 0).fadeIn(W.animationSpeed, function() { $pp_pic_holder.attr("style", "left:" + $pp_pic_holder.css("left") + ";top:" + $pp_pic_holder.css("top") + ";"); a() }) })
        }
    };
    function B(E, D) {
        E = E.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); var C = "[\\?&]" + E + "=([^&#]*)";
        var G = new RegExp(C); var F = G.exec(D); if (F == null) { return "" } else { return F[1] }
    }
})(jQuery);
/**
* Cookie plugin
*
* Copyright (c) 2006 Klaus Hartl (stilbuero.de)
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
*/


jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};$.fn.pager = function(clas, options) {

    var settings = {
        navId: 'navpagger',
        navClass: 'navpagger',
        navAttach: 'prepend',
        highlightClass: 'highlight',
        prevText: '&laquo;',
        nextText: '&raquo;',
        linkText: null,
        linkWrap: null,
        height: null
    }
    if (options) $.extend(settings, options);


    return this.each(function() {

        var me = $(this);
        var size;
        var i = 0;
        var navid = '#' + settings.navId;

        function init() {
            size = $(clas, me).not(navid).size();
            if (settings.height == null) {
                settings.height = getHighest();
            }
            if (size > 1) {
                makeNav();
                show();
                highlight();
            }
            sizePanel();
            if (settings.linkWrap != null) {
                linkWrap();
            }
        }
        function makeNav() {
            var str = '<div id="' + settings.navId + '" class="' + settings.navClass + '">';
            str += '<a href="#" rel="prev">' + settings.prevText + '</a>';
            for (var i = 0; i < size; i++) {
                var j = i + 1;
                str += '<a href="#" rel="' + j + '">';
                str += (settings.linkText == null) ? j : settings.linkText[j - 1];
                str += '</a>';
            }
            str += '<a href="#" rel="next">' + settings.nextText + '</a>';
            str += '</div>';
            switch (settings.navAttach) {
                case 'before':
                    $(me).before(str);
                    break;
                case 'after':
                    $(me).after(str);
                    break;
                case 'prepend':
                    $(me).prepend(str);
                    break;
                default:
                    $(me).append(str);
                    break;
            }
        }
        function show() {
            $(me).find(clas).not(navid).hide();
            var show = $(me).find(clas).not(navid).get(i);
            $(show).show();
        }
        function highlight() {
            $(me).find(navid).find('a').removeClass(settings.highlightClass);
            var show = $(me).find(navid).find('a').get(i + 1);
            $(show).addClass(settings.highlightClass);
        }

        function sizePanel() {
            if ($.browser.msie) {
                $(me).find(clas).not(navid).css({
                    height: settings.height
                });
            } else {
                $(me).find(clas).not(navid).css({
                    minHeight: settings.height
                });
            }
        }
        function getHighest() {
            var highest = 0;
            $(me).find(clas).not(navid).each(function() {

                if (this.offsetHeight > highest) {
                    highest = this.offsetHeight;
                }
            });
            highest = highest + "px";
            return highest;
        }
        function getNavHeight() {
            var nav = $(navid).get(0);
            return nav.offsetHeight;
        }
        function linkWrap() {
            $(me).find(navid).find("a").wrap(settings.linkWrap);
        }
        init();
        $(this).find(navid).find("a").click(function() {

            if ($(this).attr('rel') == 'next') {
                if (i + 1 < size) {
                    i = i + 1;
                }
            } else if ($(this).attr('rel') == 'prev') {
                if (i > 0) {
                    i = i - 1;
                }
            } else {
                var j = $(this).attr('rel');
                i = j - 1;
            }
            show();
            highlight();
            return false;
        });
    });
};/**
* Boxy 0.1.4 - Facebook-style dialog, with frills
*
* (c) 2008 Jason Frame
* Licensed under the MIT License (LICENSE)
*/

/*
* jQuery plugin
*
* Options:
*   message: confirmation message for form submit hook (default: "Please confirm:")
* 
* Any other options - e.g. 'clone' - will be passed onto the boxy constructor (or
* Boxy.load for AJAX operations)
*/
jQuery.fn.boxy = function(options) {
    options = options || {};
    return this.each(function() {
        var node = this.nodeName.toLowerCase(), self = this;
        if (node == 'a') {
            jQuery(this).click(function() {
                var active = Boxy.linkedTo(this),
                    href = this.getAttribute('href'),
                    localOptions = jQuery.extend({ actuator: this, title: this.title }, options);

                if (active) {
                    active.show();
                } else if (href.indexOf('#') >= 0) {
                    var content = jQuery(href.substr(href.indexOf('#'))),
                        newContent = content.clone(true);
                    content.remove();
                    localOptions.unloadOnHide = false;
                    new Boxy(newContent, localOptions);
                } else { // fall back to AJAX; could do with a same-origin check
                    if (!localOptions.cache) localOptions.unloadOnHide = true;
                    Boxy.load(this.href, localOptions);
                }

                return false;
            });
        } else if (node == 'form') {
            jQuery(this).bind('submit.boxy', function() {
                Boxy.confirm(options.message || 'Please confirm:', function() {
                    jQuery(self).unbind('submit.boxy').submit();
                });
                return false;
            });
        }
    });
};

//
// Boxy Class

function Boxy(element, options) {

    this.boxy = jQuery(Boxy.WRAPPER);
    jQuery.data(this.boxy[0], 'boxy', this);

    this.visible = false;
    this.options = jQuery.extend({}, Boxy.DEFAULTS, options || {});

    if (this.options.modal) {
        this.options = jQuery.extend(this.options, { center: true, draggable: false });
    }

    // options.actuator == DOM element that opened this boxy
    // association will be automatically deleted when this boxy is remove()d
    if (this.options.actuator) {
        jQuery.data(this.options.actuator, 'active.boxy', this);
    }

    this.setContent(element || "<div></div>");
    this._setupTitleBar();

    this.boxy.css('display', 'none').appendTo(document.body);
    this.toTop();

    if (this.options.fixed) {
        if (jQuery.browser.msie && jQuery.browser.version < 7) {
            this.options.fixed = false; // IE6 doesn't support fixed positioning
        } else {
            this.boxy.addClass('fixed');
        }
    }

    if (this.options.center && Boxy._u(this.options.x, this.options.y)) {
        this.center();
    } else {
        this.moveTo(
            Boxy._u(this.options.x) ? this.options.x : Boxy.DEFAULT_X,
            Boxy._u(this.options.y) ? this.options.y : Boxy.DEFAULT_Y
        );
    }

    if (this.options.show) this.show();

};

Boxy.EF = function() { };

jQuery.extend(Boxy, {

    WRAPPER: "<table cellspacing='0' cellpadding='0' border='0' class='boxy-wrapper'>" +
                "<tr><td class='top-left'></td><td class='top'></td><td class='top-right'></td></tr>" +
                "<tr><td class='left'></td><td class='boxy-inner'></td><td class='right'></td></tr>" +
                "<tr><td class='bottom-left'></td><td class='bottom'></td><td class='bottom-right'></td></tr>" +
                "</table>",

    DEFAULTS: {
        title: null,           // titlebar text. titlebar will not be visible if not set.
        closeable: true,           // display close link in titlebar?
        draggable: true,           // can this dialog be dragged?
        clone: false,          // clone content prior to insertion into dialog?
        actuator: null,           // element which opened this dialog
        center: true,           // center dialog in viewport?
        show: true,           // show dialog immediately?
        modal: false,          // make dialog modal?
        fixed: true,           // use fixed positioning, if supported? absolute positioning used otherwise
        closeText: '[fermer]',      // text to use for default close link
        unloadOnHide: false,          // should this dialog be removed from the DOM after being hidden?
        clickToFront: false,          // bring dialog to foreground on any click (not just titlebar)?
        behaviours: Boxy.EF,        // function used to apply behaviours to all content embedded in dialog.
        afterDrop: Boxy.EF,        // callback fired after dialog is dropped. executes in context of Boxy instance.
        afterShow: Boxy.EF,        // callback fired after dialog becomes visible. executes in context of Boxy instance.
        afterHide: Boxy.EF,        // callback fired after dialog is hidden. executed in context of Boxy instance.
        beforeUnload: Boxy.EF         // callback fired after dialog is unloaded. executed in context of Boxy instance.
    },

    DEFAULT_X: 50,
    DEFAULT_Y: 50,
    zIndex: 1337,
    dragConfigured: false, // only set up one drag handler for all boxys
    resizeConfigured: false,
    dragging: null,

    // load a URL and display in boxy
    // url - url to load
    // options keys (any not listed below are passed to boxy constructor)
    //   type: HTTP method, default: GET
    //   cache: cache retrieved content? default: false
    //   filter: jQuery selector used to filter remote content
    load: function(url, options) {

        options = options || {};

        var ajax = {
            url: url, type: 'GET', dataType: 'html', cache: false, success: function(html) {
                html = jQuery(html);
                if (options.filter) html = jQuery(options.filter, html);
                new Boxy(html, options);
            }
        };

        jQuery.each(['type', 'cache'], function() {
            if (this in options) {
                ajax[this] = options[this];
                delete options[this];
            }
        });

        jQuery.ajax(ajax);

    },

    // allows you to get a handle to the containing boxy instance of any element
    // e.g. <a href='#' onclick='alert(Boxy.get(this));'>inspect!</a>.
    // this returns the actual instance of the boxy 'class', not just a DOM element.
    // Boxy.get(this).hide() would be valid, for instance.
    get: function(ele) {
        var p = jQuery(ele).parents('.boxy-wrapper');
        return p.length ? jQuery.data(p[0], 'boxy') : null;
    },

    // returns the boxy instance which has been linked to a given element via the
    // 'actuator' constructor option.
    linkedTo: function(ele) {
        return jQuery.data(ele, 'active.boxy');
    },

    // displays an alert box with a given message, calling optional callback
    // after dismissal.
    alert: function(message, callback, options) {
        return Boxy.ask(message, ['OK'], callback, options);
    },

    // displays an alert box with a given message, calling after callback iff
    // user selects OK.
    confirm: function(message, after, options) {
        return Boxy.ask(message, ['OK', 'Cancel'], function(response) {
            if (response == 'OK') after();
        }, options);
    },

    // asks a question with multiple responses presented as buttons
    // selected item is returned to a callback method.
    // answers may be either an array or a hash. if it's an array, the
    // the callback will received the selected value. if it's a hash,
    // you'll get the corresponding key.
    ask: function(question, answers, callback, options) {

        options = jQuery.extend({ modal: true, closeable: false },
                                options || {},
                                { show: true, unloadOnHide: true });

        var body = jQuery('<div></div>').append(jQuery('<div class="question"></div>').html(question));

        // ick
        var map = {}, answerStrings = [];
        if (answers instanceof Array) {
            for (var i = 0; i < answers.length; i++) {
                map[answers[i]] = answers[i];
                answerStrings.push(answers[i]);
            }
        } else {
            for (var k in answers) {
                map[answers[k]] = k;
                answerStrings.push(answers[k]);
            }
        }

        var buttons = jQuery('<form class="answers"></form>');
        buttons.html(jQuery.map(answerStrings, function(v) {
            return "<input type='button' value='" + v + "' />";
        }).join(' '));

        jQuery('input[type=button]', buttons).click(function() {
            var clicked = this;
            Boxy.get(this).hide(function() {
                if (callback) callback(map[clicked.value]);
            });
        });

        body.append(buttons);

        new Boxy(body, options);

    },

    // returns true if a modal boxy is visible, false otherwise
    isModalVisible: function() {
        return jQuery('.boxy-modal-blackout').length > 0;
    },

    _u: function() {
        for (var i = 0; i < arguments.length; i++)
            if (typeof arguments[i] != 'undefined') return false;
        return true;
    },

    _handleResize: function(evt) {
        var d = jQuery(document);
        jQuery('.boxy-modal-blackout').css('display', 'none').css({
            width: d.width(), height: d.height()
        }).css('display', 'block');
    },

    _handleDrag: function(evt) {
        var d;
        if (d = Boxy.dragging) {
            d[0].boxy.css({ left: evt.pageX - d[1], top: evt.pageY - d[2] });
        }
    },

    _nextZ: function() {
        return Boxy.zIndex++;
    },

    _viewport: function() {
        var d = document.documentElement, b = document.body, w = window;
        return jQuery.extend(
            jQuery.browser.msie ?
                { left: b.scrollLeft || d.scrollLeft, top: b.scrollTop || d.scrollTop} :
                { left: w.pageXOffset, top: w.pageYOffset },
            !Boxy._u(w.innerWidth) ?
                { width: w.innerWidth, height: w.innerHeight} :
                (!Boxy._u(d) && !Boxy._u(d.clientWidth) && d.clientWidth != 0 ?
                    { width: d.clientWidth, height: d.clientHeight} :
                    { width: b.clientWidth, height: b.clientHeight }));
    }

});

Boxy.prototype = {

    // Returns the size of this boxy instance without displaying it.
    // Do not use this method if boxy is already visible, use getSize() instead.
    estimateSize: function() {
        this.boxy.css({ visibility: 'hidden', display: 'block' });
        var dims = this.getSize();
        this.boxy.css('display', 'none').css('visibility', 'visible');
        return dims;
    },

    // Returns the dimensions of the entire boxy dialog as [width,height]
    getSize: function() {
        return [this.boxy.width(), this.boxy.height()];
    },

    // Returns the dimensions of the content region as [width,height]
    getContentSize: function() {
        var c = this.getContent();
        return [c.width(), c.height()];
    },

    // Returns the position of this dialog as [x,y]
    getPosition: function() {
        var b = this.boxy[0];
        return [b.offsetLeft, b.offsetTop];
    },

    // Returns the center point of this dialog as [x,y]
    getCenter: function() {
        var p = this.getPosition();
        var s = this.getSize();
        return [Math.floor(p[0] + s[0] / 2), Math.floor(p[1] + s[1] / 2)];
    },

    // Returns a jQuery object wrapping the inner boxy region.
    // Not much reason to use this, you're probably more interested in getContent()
    getInner: function() {
        return jQuery('.boxy-inner', this.boxy);
    },

    // Returns a jQuery object wrapping the boxy content region.
    // This is the user-editable content area (i.e. excludes titlebar)
    getContent: function() {
        return jQuery('.boxy-content', this.boxy);
    },

    // Replace dialog content
    setContent: function(newContent) {
    newContent = jQuery(newContent).addClass('boxy-content'); //css({ display: 'block' })
        if (this.options.clone) newContent = newContent.clone(true);
        this.getContent().remove();
        this.getInner().append(newContent);
        this._setupDefaultBehaviours(newContent);
        this.options.behaviours.call(this, newContent);
        return this;
    },

    // Move this dialog to some position, funnily enough
    moveTo: function(x, y) {
        this.moveToX(x).moveToY(y);
        return this;
    },

    // Move this dialog (x-coord only)
    moveToX: function(x) {
        if (typeof x == 'number') this.boxy.css({ left: x });
        else this.centerX();
        return this;
    },

    // Move this dialog (y-coord only)
    moveToY: function(y) {
        if (typeof y == 'number') this.boxy.css({ top: y });
        else this.centerY();
        return this;
    },

    // Move this dialog so that it is centered at (x,y)
    centerAt: function(x, y) {
        var s = this[this.visible ? 'getSize' : 'estimateSize']();
        if (typeof x == 'number') this.moveToX(x - s[0] / 2);
        if (typeof y == 'number') this.moveToY(y - s[1] / 2);
        return this;
    },

    centerAtX: function(x) {
        return this.centerAt(x, null);
    },

    centerAtY: function(y) {
        return this.centerAt(null, y);
    },

    // Center this dialog in the viewport
    // axis is optional, can be 'x', 'y'.
    center: function(axis) {
        var v = Boxy._viewport();
        var o = this.options.fixed ? [0, 0] : [v.left, v.top];
        if (!axis || axis == 'x') this.centerAt(o[0] + v.width / 2, null);
        if (!axis || axis == 'y') this.centerAt(null, o[1] + v.height / 2);
        return this;
    },

    // Center this dialog in the viewport (x-coord only)
    centerX: function() {
        return this.center('x');
    },

    // Center this dialog in the viewport (y-coord only)
    centerY: function() {
        return this.center('y');
    },

    // Resize the content region to a specific size
    resize: function(width, height, after) {
        if (!this.visible) return;
        var bounds = this._getBoundsForResize(width, height);
        this.boxy.css({ left: bounds[0], top: bounds[1] });
        this.getContent().css({ width: bounds[2], height: bounds[3] });
        if (after) after(this);
        return this;
    },

    // Tween the content region to a specific size
    tween: function(width, height, after) {
        if (!this.visible) return;
        var bounds = this._getBoundsForResize(width, height);
        var self = this;
        this.boxy.stop().animate({ left: bounds[0], top: bounds[1] });
        this.getContent().stop().animate({ width: bounds[2], height: bounds[3] }, function() {
            if (after) after(self);
        });
        return this;
    },

    // Returns true if this dialog is visible, false otherwise
    isVisible: function() {
        return this.visible;
    },

    // Make this boxy instance visible
    show: function() {
        if (this.visible) return;
        if (this.options.modal) {
            var self = this;
            if (!Boxy.resizeConfigured) {
                Boxy.resizeConfigured = true;
                jQuery(window).resize(function() { Boxy._handleResize(); });
            }
            this.modalBlackout = jQuery('<div class="boxy-modal-blackout"></div>')
                .css({ zIndex: Boxy._nextZ(),
                    opacity: 0.7,
                    width: jQuery(document).width(),
                    height: jQuery(document).height()
                })
                .appendTo(document.body);
            this.toTop();
            if (this.options.closeable) {
                jQuery(document.body).bind('keypress.boxy', function(evt) {
                    var key = evt.which || evt.keyCode;
                    if (key == 27) {
                        self.hide();
                        jQuery(document.body).unbind('keypress.boxy');
                    }
                });
            }
        }
        this.boxy.stop().css({ opacity: 1 }).show();
        this.visible = true;
        this._fire('afterShow');
        return this;
    },

    // Hide this boxy instance
    hide: function(after) {
        if (!this.visible) return;
        var self = this;
        if (this.options.modal) {
            jQuery(document.body).unbind('keypress.boxy');
            this.modalBlackout.animate({ opacity: 0 }, function() {
                jQuery(this).remove();
            });
        }
        this.boxy.stop().animate({ opacity: 0 }, 300, function() {
            self.boxy.css({ display: 'none' });
            self.visible = false;
            self._fire('afterHide');
            if (after) after(self);
            if (self.options.unloadOnHide) self.unload();
        });
        return this;
    },

    toggle: function() {
        this[this.visible ? 'hide' : 'show']();
        return this;
    },

    hideAndUnload: function(after) {
        this.options.unloadOnHide = true;
        this.hide(after);
        return this;
    },

    unload: function() {
        this._fire('beforeUnload');
        this.boxy.remove();
        if (this.options.actuator) {
            jQuery.data(this.options.actuator, 'active.boxy', false);
        }
    },

    // Move this dialog box above all other boxy instances
    toTop: function() {
        this.boxy.css({ zIndex: Boxy._nextZ() });
        return this;
    },

    // Returns the title of this dialog
    getTitle: function() {
        return jQuery('> .title-bar h2', this.getInner()).html();
    },

    // Sets the title of this dialog
    setTitle: function(t) {
        jQuery('> .title-bar h2', this.getInner()).html(t);
        return this;
    },

    //
    // Don't touch these privates

    _getBoundsForResize: function(width, height) {
        var csize = this.getContentSize();
        var delta = [width - csize[0], height - csize[1]];
        var p = this.getPosition();
        return [Math.max(p[0] - delta[0] / 2, 0),
                Math.max(p[1] - delta[1] / 2, 0), width, height];
    },

    _setupTitleBar: function() {
        if (this.options.title) {
            var self = this;
            var tb = jQuery("<div class='title-bar'></div>").html("<h2>" + this.options.title + "</h2>");
            if (this.options.closeable) {
                tb.append(jQuery("<a href='#' class='close'></a>").html(this.options.closeText));
            }
            if (this.options.draggable) {
                tb[0].onselectstart = function() { return false; }
                tb[0].unselectable = 'on';
                tb[0].style.MozUserSelect = 'none';
                if (!Boxy.dragConfigured) {
                    jQuery(document).mousemove(Boxy._handleDrag);
                    Boxy.dragConfigured = true;
                }
                tb.mousedown(function(evt) {
                    self.toTop();
                    Boxy.dragging = [self, evt.pageX - self.boxy[0].offsetLeft, evt.pageY - self.boxy[0].offsetTop];
                    jQuery(this).addClass('dragging');
                }).mouseup(function() {
                    jQuery(this).removeClass('dragging');
                    Boxy.dragging = null;
                    self._fire('afterDrop');
                });
            }
            this.getInner().prepend(tb);
            this._setupDefaultBehaviours(tb);
        }
    },

    _setupDefaultBehaviours: function(root) {
        var self = this;
        if (this.options.clickToFront) {
            root.click(function() { self.toTop(); });
        }
        jQuery('.close', root).click(function() {
            self.hide();
            return false;
        }).mousedown(function(evt) { evt.stopPropagation(); });
    },

    _fire: function(event) {
        this.options[event].call(this);
    }

};
$(document).ready(function() {
    /*click menu*/
    $("#nav li").click(function() {
        location.href = $(this).find('a').attr('href');
    });
    /*logo*/
    $("#logo").click(function() { location.href = "http://www.abris-martin.com/" });
    /*Diaporama*/
    var offsetSlider = 0;
    var nbli = $("#sliderdiapo > li").length;
    var bplay = true;
    var timeout = 6500;
    var tempsEffet = 2000;

    $("#btnext").click(function() {
        if (offsetSlider > -((nbli - 1) * 935)) {
            offsetSlider -= 935;
            $("#sliderdiapo").animate({ marginLeft: offsetSlider }, tempsEffet, "cubicEaseInOut", function() { });
        }
    });
    $("#btback").click(function() {
        if (offsetSlider < 0) {
            offsetSlider += 935;
            $("#sliderdiapo").animate({ marginLeft: offsetSlider }, tempsEffet, "cubicEaseInOut", function() { });
        }
    });
    $("#btplay").click(function() {
        bplay = true;
        $("#btplay").hide();
        $("#btpause").show();
        play();
    });
    $("#btpause").click(function() {
        bplay = false;
        $("#btpause").hide();
        $("#btplay").show();
    });

    //
    var play = function() {
        //        
        setTimeout(function() {
            if (offsetSlider <= -(nbli - 1) * 935 && bplay) {
                offsetSlider += 935;
                $("#sliderdiapo").append($("#sliderdiapo li:first-child").clone());
                $("#sliderdiapo li:first").remove();
                $("#sliderdiapo").css("margin-left", offsetSlider);
            }
            if (bplay) {
                $("#btnext").click();
                play();
            }
        }, timeout);
    }
    //d&#233;part auto
    $("#btplay").click();

    //lightbox
    $("a[rel^='prettyPhoto']").prettyPhoto();

    //edition
    $(".boxy").boxy();

    //pager
    $("#collectivite").pager(".collec");
    $("#commentaire").pager(".collec");

    //societe
    $("#submitSociete").live("click", function() {
        if ($("#tbNomSociete").val() == "") {
            buildPrompt("#tbNomSociete", "Un nom de soci&#233;t&#233; est obligatoire", true);
            return false;
        }
        //requete
        $.ajax({
            type: "POST",
            url: "/Client/EditionSociete.aspx",
            data: {
                tbNomSociete: $("#tbNomSociete").val(),
                tbStatut: $("#tbStatut").val(),
                tbSiret: $("#tbSiret").val(),
                tbTva: $("#tbTva").val()
            },
            success: function(msg) {
                location.href = "/Client/MesInformations.aspx";
            },
            error: function(request, settings) {
                alert(settings.url);
            }
        });
        return false;
    });
    //perso
    $("#submitPerso").live("click", function() {
        if ($("#tbNom").val() == "") {
            buildPrompt("#tbNom", "Un nom est obligatoire", true);
            return false;
        }
        if ($("#tbPrenom").val() == "") {
            buildPrompt("#tbPrenom", "Un Pr&#233;nom est obligatoire", true);
            return false;
        }
        if ($("#tbTel").val() == "") {
            buildPrompt("#tbTel", "Un t&#233;l&#233;phone est obligatoire", true);
            return false;
        }
        if ($("#tbEmail").val() == "") {
            buildPrompt("#tbEmail", "Un email est obligatoire", true);
            return false;
        }
        var filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
        if (!filter.test($("#tbEmail").val())) {
            buildPrompt("#tbEmail", "l'adresse email doit être valide", true);
            return false;
        }
        //requete
        $.ajax({
            type: "POST",
            url: "/Client/EditionInfomationsPersonnelles.aspx",
            data: {
                tbNom: $("#tbNom").val(),
                tbPrenom: $("#tbPrenom").val(),
                tbTel: $("#tbTel").val(),
                tbPortable: $("#tbPortable").val(),
                tbFax: $("#tbFax").val(),
                tbEmail: $("#tbEmail").val()
            },
            success: function(msg) {
                location.href = "/Client/MesInformations.aspx";
            },
            error: function(request, settings) {
                alert(settings.url);
            }
        });
        return false;

    });
    //adresse
    $("#submitAdresse").live("click", function() {
        if (!($("#tbSociete").val() != "" || ($("#tbNom").val() != "" && $("#tbPrenom").val() != ""))) {
            buildPrompt("#tbSociete", "Une soci&#233;t&#233; ou un nom et pr&#233;nom sont obligatoires", true);
            return false;
        }

        if ($("#tbAdresse").val() == "") {
            buildPrompt("#tbAdresse", "Une adresse est obligatoire", true);
            return false;
        }
        if ($("#tbCp").val() == "") {
            buildPrompt("#tbCp", "Un code postal est obligatoire", true);
            return false;
        }
        var filter = /^[0-9]{5}$/;
        if (!filter.test($("#tbCp").val())) {
            buildPrompt("#tbCp", "le code postal doit être valide", true);
            return false;
        }
        if ($("#tbVille").val() == "") {
            buildPrompt("#tbVille", "Une ville est obligatoire", true);
            return false;
        }
        //requete
        $.ajax({
            type: "POST",
            url: "/Client/EditionAdresse.aspx",
            data: {
                tbTitreAdresse: $("#tbTitreAdresse").val(),
                tbSociete: $("#tbSociete").val(),
                tbNom: $("#tbNom").val(),
                tbPrenom: $("#tbPrenom").val(),
                tbAdresse: $("#tbAdresse").val(),
                tbAdresse2: $("#tbAdresse2").val(),
                tbCp: $("#tbCp").val(),
                tbVille: $("#tbVille").val(),
                ddlPays: $("#ddlPays").val(),
                cbParDefaut: $("#cbParDefaut").attr("checked"),
                tbID: $("#tbID").val(),
                tbFacture: $("#tbFacture").val()
            },
            success: function(msg) {
                location.href = "/Client/MesInformations.aspx";
            },
            error: function(request, settings) {
                alert(settings.url);
            }
        });
        return false;
    });
    /*page modele*/
    $(".choix").hover(function() {
        $(this).css("background-color", "#f3e9ce");
    }, function() {
        $(this).css("background-color", "#ffffff");
    });
    /*click ajouter panier*/
    $("#ctl00_ContentPlaceHolder1_btAjouterPanier").click(function() {
        return verificationChoixModele();
    });
    $("#ctl00_ContentPlaceHolder1_btDevis").click(function() {
        return verificationChoixModele();
    });

    function verificationChoixModele() {
        $(".choixcouverture").css("border", "");
        $(".choixcouverture").css("background-color", "#ffffff");
        $(".choixbardage").css("border", "");
        $(".choixbardage").css("background-color", "#ffffff");
        $(".choixpente").css("border", "");
        $(".choixpente").css("background-color", "#ffffff");
        $(".errormessage").remove();

        var ralcouverture = $("input[type=radio][name=couverture]:checked").attr('id');
        var bardage = $("input[type=radio][name=bardage]:checked").attr('id');
        var pente = $("input[type=radio][name=pente]:checked").attr('id');

        var nbbardage = $("input[type=radio][name=bardage]").length;
        var nbpente = $("input[type=radio][name=pente]").length;

        if (ralcouverture == null) {
            $(".choixcouverture").css("border", "1px solid #e3a345");
            $(".choixcouverture").css("background-color", "#ffedad");
            $(".choixcouverture").append("<span class='errormessage'><b>Vous devez s&#233;lectionner une couverture</b></span>");
        }
        if (bardage == null && nbbardage > 0) {
            $(".choixbardage").css("border", "1px solid #e3a345");
            $(".choixbardage").css("background-color", "#ffedad");
            $(".choixbardage").append("<span class='errormessage'><b>Vous devez s&#233;lectionner un type de bardage</b></span>");
        }
        if (pente == null && nbpente > 0) {
            $(".choixpente").css("border", "1px solid #e3a345");
            $(".choixpente").css("background-color", "#ffedad");
            $(".choixpente").append("<span class='errormessage'><b>Vous devez s&#233;lectionner une pente</b></span>");
        }

        if (ralcouverture == null || (bardage == null && nbbardage > 0) || (pente == null && nbpente > 0)) { return false; } else {
            var couv = ralcouverture.split("-");
            $("#ctl00_ContentPlaceHolder1_hidCouverture").val(couv[1]);
            $("#ctl00_ContentPlaceHolder1_hidRalCouverture").val(couv[2]);
            if (nbbardage > 0) {
                var bard = bardage.split("-");
                $("#ctl00_ContentPlaceHolder1_hidBardage").val(bard[1]);
            }
            if (nbpente > 0) {
                var pent = pente.split("-");
                $("#ctl00_ContentPlaceHolder1_hidPente").val(pent[1]);
            }
            return true;
        }
    }
    /*modalite de paiement*/
    $("#ctl00_ContentPlaceHolder1_btValider").click(function() {
        $("#ctl00_ContentPlaceHolder1_rbModalite").css("border", "");
        $("#ctl00_ContentPlaceHolder1_rbModalite").css("background-color", "#ffffff");
        $("#ctl00_ContentPlaceHolder1_rbPaiement").css("border", "");
        $("#ctl00_ContentPlaceHolder1_rbPaiement").css("background-color", "#ffffff");
        $("#checkcgv").css("border", "");
        $("#checkcgv").css("background-color", "#ffffff");
        $(".errormessage").remove();

        var modalite = $("input[type=radio][name=ctl00$ContentPlaceHolder1$rbModalite]:checked").attr('id');
        if (modalite == null) {
            $("#ctl00_ContentPlaceHolder1_rbModalite").css("border", "1px solid #e3a345");
            $("#ctl00_ContentPlaceHolder1_rbModalite").css("background-color", "#ffedad");
            $("#ctl00_ContentPlaceHolder1_rbModalite").append("<span class='errormessage'><b>Vous devez s&#233;lectionner une modalit&#233; de paiment</b></span>");
        }
        var moyen = $("input[type=radio][name=ctl00$ContentPlaceHolder1$rbPaiement]:checked").attr('id');
        if (moyen == null) {
            $("#ctl00_ContentPlaceHolder1_rbPaiement").css("border", "1px solid #e3a345");
            $("#ctl00_ContentPlaceHolder1_rbPaiement").css("background-color", "#ffedad");
            $("#ctl00_ContentPlaceHolder1_rbPaiement").append("<span class='errormessage'><b>Vous devez s&#233;lectionner un moyen de paiement</b></span>");
        }
        var cgv = $("input[type=checkbox]:checked").attr('id');
        if (cgv == null) {
            $("#checkcgv").css("border", "1px solid #e3a345");
            $("#checkcgv").css("background-color", "#ffedad");
            $("#checkcgv").append("<span class='errormessage'><b>Vous devez accepter les conditions g&#233;n&#233;rales de ventes</b></span>");
        }
        if (modalite == null || moyen == null || cgv == null) {
            return false;
        }
    });
    /*formulaire demande de devis*/
    $("#ctl00_ContentPlaceHolder1_btEnvoyer").click(function() {
        $(".formError").remove();
        if ($("#ctl00_ContentPlaceHolder1_tbNom").val() == "") {
            buildPrompt("#ctl00_ContentPlaceHolder1_tbNom", "Un nom et pr&#233;nom est obligatoire", true);
            return false;
        }
        var tel = $("#ctl00_ContentPlaceHolder1_tbTelephone").val();
        var mail = $("#ctl00_ContentPlaceHolder1_tbMail").val();

        if (tel == "" && mail == "") {
            buildPrompt("#ctl00_ContentPlaceHolder1_tbTelephone", "Un t&#233;l&#233;phone ou email est obligatoire", true);
            return false;
        } else {
            var filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
            /*avec copymail*/
            if ($("#ctl00_ContentPlaceHolder1_cbCopy").attr("checked") != "" && mail == "") {
                buildPrompt("#ctl00_ContentPlaceHolder1_tbMail", "Une adresse email est obligatoire", true);
            }
            if (!filter.test(mail) && mail != "") {
                buildPrompt("#ctl00_ContentPlaceHolder1_tbMail", "l'adresse email doit être valide", true);
                return false;
            } else {
                return true;
            }
        }
    });

    /*frais de port*/
    $("#ctl00_ContentPlaceHolder1_tbDep").keyup(function() {
        var dep = $("#ctl00_ContentPlaceHolder1_tbDep").val();
        $(".formError").remove();
        if (dep.length != 0) {
            /*dep correcte*/
            if (dep.length > 2) {
                $("#ctl00_ContentPlaceHolder1_lblPrixPort").html("");
                return false;
            }
            var filterCP = /^([0-9]{1,2})+$/;
            if (!filterCP.test(dep)) {
                $("#ctl00_ContentPlaceHolder1_lblPrixPort").html("");
                return false;
            }
            /*requete web service*/
            $.get("/WebServices/FraisPort.asmx/CalculPort", {
                idModele: $("#ctl00_ContentPlaceHolder1_hidIdModele").val(),
                Dep: dep
            }, function(data) {
                var str = "";
                if (navigator.userAgent.lastIndexOf("IE") < 0) // Firefox et autres
                {
                    str = data.firstChild.textContent;
                }
                else if (window.ActiveXObject)  // Internet Explorer
                {
                    str = data.text;
                }
                $("#ctl00_ContentPlaceHolder1_lblPrixPort").html(str);
                $("#ctl00_ContentPlaceHolder1_lblPrixPort").animate({ fontSize: "14px" }, 500, "backEaseInOut", function() {
                    $("#ctl00_ContentPlaceHolder1_lblPrixPort").animate({ fontSize: "10px" }, 500, "backEaseInOut", "");
                });
            });
        }
    });


    $(".monPanier").animate({ fontSize: "14px" }, 500, "backEaseInOut", function() {
        $(".monPanier").animate({ fontSize: "10px" }, 500, "backEaseInOut", "");
    });

    /*function*/
    function buildPrompt(caller, promptText, showTriangle) {			// ERROR PROMPT CREATION AND DISPLAY WHEN AN ERROR OCCUR
        var divFormError = document.createElement('div');
        var formErrorContent = document.createElement('div');
        var arrow = document.createElement('div');

        $(divFormError).addClass("formError");
        $(divFormError).addClass($(caller).attr("id"));
        $(formErrorContent).addClass("formErrorContent");
        $(arrow).addClass("formErrorArrow");

        $("body").append(divFormError);
        $(divFormError).append(arrow);
        $(divFormError).append(formErrorContent);

        if (showTriangle == true) {		// NO TRIANGLE ON MAX CHECKBOX AND RADIO
            $(arrow).html('<div class="line10"></div><div class="line9"></div><div class="line8"></div><div class="line7"></div><div class="line6"></div><div class="line5"></div><div class="line4"></div><div class="line3"></div><div class="line2"></div><div class="line1"></div>');
        }
        $(formErrorContent).html(promptText);

        callerTopPosition = $(caller).offset().top;
        callerleftPosition = $(caller).offset().left;
        callerWidth = 200; //$(caller).width()
        callerHeight = 30; $(caller).height()
        inputHeight = $(divFormError).height();

        callerleftPosition = callerleftPosition + callerWidth - 30;
        callerTopPosition = callerTopPosition - inputHeight - 10;

        $(divFormError).css({
            top: callerTopPosition,
            left: callerleftPosition,
            opacity: 1
        });
        //$(divFormError).fadeTo("fast", 0.8);
    };
});


