

/*
 * jScrollPane - v2.0.0beta11 - 2011-07-04
 * http://jscrollpane.kelvinluck.com/
 *
 * Copyright (c) 2010 Kelvin Luck
 * Dual licensed under the MIT and GPL licenses.
 */
(function(b,a,c){b.fn.jScrollPane=function(e){function d(D,O){var az,Q=this,Y,ak,v,am,T,Z,y,q,aA,aF,av,i,I,h,j,aa,U,aq,X,t,A,ar,af,an,G,l,au,ay,x,aw,aI,f,L,aj=true,P=true,aH=false,k=false,ap=D.clone(false,false).empty(),ac=b.fn.mwheelIntent?"mwheelIntent.jsp":"mousewheel.jsp";aI=D.css("paddingTop")+" "+D.css("paddingRight")+" "+D.css("paddingBottom")+" "+D.css("paddingLeft");f=(parseInt(D.css("paddingLeft"),10)||0)+(parseInt(D.css("paddingRight"),10)||0);function at(aR){var aM,aO,aN,aK,aJ,aQ,aP=false,aL=false;az=aR;if(Y===c){aJ=D.scrollTop();aQ=D.scrollLeft();D.css({overflow:"hidden",padding:0});ak=D.innerWidth()+f;v=D.innerHeight();D.width(ak);Y=b('<div class="jspPane" />').css("padding",aI).append(D.children());am=b('<div class="jspContainer" />').css({width:ak+"px",height:v+"px"}).append(Y).appendTo(D)}else{D.css("width","");aP=az.stickToBottom&&K();aL=az.stickToRight&&B();aK=D.innerWidth()+f!=ak||D.outerHeight()!=v;if(aK){ak=D.innerWidth()+f;v=D.innerHeight();am.css({width:ak+"px",height:v+"px"})}if(!aK&&L==T&&Y.outerHeight()==Z){D.width(ak);return}L=T;Y.css("width","");D.width(ak);am.find(">.jspVerticalBar,>.jspHorizontalBar").remove().end()}Y.css("overflow","auto");if(aR.contentWidth){T=aR.contentWidth}else{T=Y[0].scrollWidth}Z=Y[0].scrollHeight;Y.css("overflow","");y=T/ak;q=Z/v;aA=q>1;aF=y>1;if(!(aF||aA)){D.removeClass("jspScrollable");Y.css({top:0,width:am.width()-f});n();E();R();w();ai()}else{D.addClass("jspScrollable");aM=az.maintainPosition&&(I||aa);if(aM){aO=aD();aN=aB()}aG();z();F();if(aM){N(aL?(T-ak):aO,false);M(aP?(Z-v):aN,false)}J();ag();ao();if(az.enableKeyboardNavigation){S()}if(az.clickOnTrack){p()}C();if(az.hijackInternalLinks){m()}}if(az.autoReinitialise&&!aw){aw=setInterval(function(){at(az)},az.autoReinitialiseDelay)}else{if(!az.autoReinitialise&&aw){clearInterval(aw)}}aJ&&D.scrollTop(0)&&M(aJ,false);aQ&&D.scrollLeft(0)&&N(aQ,false);D.trigger("jsp-initialised",[aF||aA])}function aG(){if(aA){am.append(b('<div class="jspVerticalBar" />').append(b('<div class="jspCap jspCapTop" />'),b('<div class="jspTrack" />').append(b('<div class="jspDrag" />').append(b('<div class="jspDragTop" />'),b('<div class="jspDragBottom" />'))),b('<div class="jspCap jspCapBottom" />')));U=am.find(">.jspVerticalBar");aq=U.find(">.jspTrack");av=aq.find(">.jspDrag");if(az.showArrows){ar=b('<a class="jspArrow jspArrowUp" />').bind("mousedown.jsp",aE(0,-1)).bind("click.jsp",aC);af=b('<a class="jspArrow jspArrowDown" />').bind("mousedown.jsp",aE(0,1)).bind("click.jsp",aC);if(az.arrowScrollOnHover){ar.bind("mouseover.jsp",aE(0,-1,ar));af.bind("mouseover.jsp",aE(0,1,af))}al(aq,az.verticalArrowPositions,ar,af)}t=v;am.find(">.jspVerticalBar>.jspCap:visible,>.jspVerticalBar>.jspArrow").each(function(){t-=b(this).outerHeight()});av.hover(function(){av.addClass("jspHover")},function(){av.removeClass("jspHover")}).bind("mousedown.jsp",function(aJ){b("html").bind("dragstart.jsp selectstart.jsp",aC);av.addClass("jspActive");var s=aJ.pageY-av.position().top;b("html").bind("mousemove.jsp",function(aK){V(aK.pageY-s,false)}).bind("mouseup.jsp mouseleave.jsp",ax);return false});o()}}function o(){aq.height(t+"px");I=0;X=az.verticalGutter+aq.outerWidth();Y.width(ak-X-f);try{if(U.position().left===0){Y.css("margin-left",X+"px")}}catch(s){}}function z(){if(aF){am.append(b('<div class="jspHorizontalBar" />').append(b('<div class="jspCap jspCapLeft" />'),b('<div class="jspTrack" />').append(b('<div class="jspDrag" />').append(b('<div class="jspDragLeft" />'),b('<div class="jspDragRight" />'))),b('<div class="jspCap jspCapRight" />')));an=am.find(">.jspHorizontalBar");G=an.find(">.jspTrack");h=G.find(">.jspDrag");if(az.showArrows){ay=b('<a class="jspArrow jspArrowLeft" />').bind("mousedown.jsp",aE(-1,0)).bind("click.jsp",aC);x=b('<a class="jspArrow jspArrowRight" />').bind("mousedown.jsp",aE(1,0)).bind("click.jsp",aC);
if(az.arrowScrollOnHover){ay.bind("mouseover.jsp",aE(-1,0,ay));x.bind("mouseover.jsp",aE(1,0,x))}al(G,az.horizontalArrowPositions,ay,x)}h.hover(function(){h.addClass("jspHover")},function(){h.removeClass("jspHover")}).bind("mousedown.jsp",function(aJ){b("html").bind("dragstart.jsp selectstart.jsp",aC);h.addClass("jspActive");var s=aJ.pageX-h.position().left;b("html").bind("mousemove.jsp",function(aK){W(aK.pageX-s,false)}).bind("mouseup.jsp mouseleave.jsp",ax);return false});l=am.innerWidth();ah()}}function ah(){am.find(">.jspHorizontalBar>.jspCap:visible,>.jspHorizontalBar>.jspArrow").each(function(){l-=b(this).outerWidth()});G.width(l+"px");aa=0}function F(){if(aF&&aA){var aJ=G.outerHeight(),s=aq.outerWidth();t-=aJ;b(an).find(">.jspCap:visible,>.jspArrow").each(function(){l+=b(this).outerWidth()});l-=s;v-=s;ak-=aJ;G.parent().append(b('<div class="jspCorner" />').css("width",aJ+"px"));o();ah()}if(aF){Y.width((am.outerWidth()-f)+"px")}Z=Y.outerHeight();q=Z/v;if(aF){au=Math.ceil(1/y*l);if(au>az.horizontalDragMaxWidth){au=az.horizontalDragMaxWidth}else{if(au<az.horizontalDragMinWidth){au=az.horizontalDragMinWidth}}h.width(au+"px");j=l-au;ae(aa)}if(aA){A=Math.ceil(1/q*t);if(A>az.verticalDragMaxHeight){A=az.verticalDragMaxHeight}else{if(A<az.verticalDragMinHeight){A=az.verticalDragMinHeight}}av.height(A+"px");i=t-A;ad(I)}}function al(aK,aM,aJ,s){var aO="before",aL="after",aN;if(aM=="os"){aM=/Mac/.test(navigator.platform)?"after":"split"}if(aM==aO){aL=aM}else{if(aM==aL){aO=aM;aN=aJ;aJ=s;s=aN}}aK[aO](aJ)[aL](s)}function aE(aJ,s,aK){return function(){H(aJ,s,this,aK);this.blur();return false}}function H(aM,aL,aP,aO){aP=b(aP).addClass("jspActive");var aN,aK,aJ=true,s=function(){if(aM!==0){Q.scrollByX(aM*az.arrowButtonSpeed)}if(aL!==0){Q.scrollByY(aL*az.arrowButtonSpeed)}aK=setTimeout(s,aJ?az.initialDelay:az.arrowRepeatFreq);aJ=false};s();aN=aO?"mouseout.jsp":"mouseup.jsp";aO=aO||b("html");aO.bind(aN,function(){aP.removeClass("jspActive");aK&&clearTimeout(aK);aK=null;aO.unbind(aN)})}function p(){w();if(aA){aq.bind("mousedown.jsp",function(aO){if(aO.originalTarget===c||aO.originalTarget==aO.currentTarget){var aM=b(this),aP=aM.offset(),aN=aO.pageY-aP.top-I,aK,aJ=true,s=function(){var aS=aM.offset(),aT=aO.pageY-aS.top-A/2,aQ=v*az.scrollPagePercent,aR=i*aQ/(Z-v);if(aN<0){if(I-aR>aT){Q.scrollByY(-aQ)}else{V(aT)}}else{if(aN>0){if(I+aR<aT){Q.scrollByY(aQ)}else{V(aT)}}else{aL();return}}aK=setTimeout(s,aJ?az.initialDelay:az.trackClickRepeatFreq);aJ=false},aL=function(){aK&&clearTimeout(aK);aK=null;b(document).unbind("mouseup.jsp",aL)};s();b(document).bind("mouseup.jsp",aL);return false}})}if(aF){G.bind("mousedown.jsp",function(aO){if(aO.originalTarget===c||aO.originalTarget==aO.currentTarget){var aM=b(this),aP=aM.offset(),aN=aO.pageX-aP.left-aa,aK,aJ=true,s=function(){var aS=aM.offset(),aT=aO.pageX-aS.left-au/2,aQ=ak*az.scrollPagePercent,aR=j*aQ/(T-ak);if(aN<0){if(aa-aR>aT){Q.scrollByX(-aQ)}else{W(aT)}}else{if(aN>0){if(aa+aR<aT){Q.scrollByX(aQ)}else{W(aT)}}else{aL();return}}aK=setTimeout(s,aJ?az.initialDelay:az.trackClickRepeatFreq);aJ=false},aL=function(){aK&&clearTimeout(aK);aK=null;b(document).unbind("mouseup.jsp",aL)};s();b(document).bind("mouseup.jsp",aL);return false}})}}function w(){if(G){G.unbind("mousedown.jsp")}if(aq){aq.unbind("mousedown.jsp")}}function ax(){b("html").unbind("dragstart.jsp selectstart.jsp mousemove.jsp mouseup.jsp mouseleave.jsp");if(av){av.removeClass("jspActive")}if(h){h.removeClass("jspActive")}}function V(s,aJ){if(!aA){return}if(s<0){s=0}else{if(s>i){s=i}}if(aJ===c){aJ=az.animateScroll}if(aJ){Q.animate(av,"top",s,ad)}else{av.css("top",s);ad(s)}}function ad(aJ){if(aJ===c){aJ=av.position().top}am.scrollTop(0);I=aJ;var aM=I===0,aK=I==i,aL=aJ/i,s=-aL*(Z-v);if(aj!=aM||aH!=aK){aj=aM;aH=aK;D.trigger("jsp-arrow-change",[aj,aH,P,k])}u(aM,aK);Y.css("top",s);D.trigger("jsp-scroll-y",[-s,aM,aK]).trigger("scroll")}function W(aJ,s){if(!aF){return}if(aJ<0){aJ=0}else{if(aJ>j){aJ=j}}if(s===c){s=az.animateScroll}if(s){Q.animate(h,"left",aJ,ae)
}else{h.css("left",aJ);ae(aJ)}}function ae(aJ){if(aJ===c){aJ=h.position().left}am.scrollTop(0);aa=aJ;var aM=aa===0,aL=aa==j,aK=aJ/j,s=-aK*(T-ak);if(P!=aM||k!=aL){P=aM;k=aL;D.trigger("jsp-arrow-change",[aj,aH,P,k])}r(aM,aL);Y.css("left",s);D.trigger("jsp-scroll-x",[-s,aM,aL]).trigger("scroll")}function u(aJ,s){if(az.showArrows){ar[aJ?"addClass":"removeClass"]("jspDisabled");af[s?"addClass":"removeClass"]("jspDisabled")}}function r(aJ,s){if(az.showArrows){ay[aJ?"addClass":"removeClass"]("jspDisabled");x[s?"addClass":"removeClass"]("jspDisabled")}}function M(s,aJ){var aK=s/(Z-v);V(aK*i,aJ)}function N(aJ,s){var aK=aJ/(T-ak);W(aK*j,s)}function ab(aW,aR,aK){var aO,aL,aM,s=0,aV=0,aJ,aQ,aP,aT,aS,aU;try{aO=b(aW)}catch(aN){return}aL=aO.outerHeight();aM=aO.outerWidth();am.scrollTop(0);am.scrollLeft(0);while(!aO.is(".jspPane")){s+=aO.position().top;aV+=aO.position().left;aO=aO.offsetParent();if(/^body|html$/i.test(aO[0].nodeName)){return}}aJ=aB();aP=aJ+v;if(s<aJ||aR){aS=s-az.verticalGutter}else{if(s+aL>aP){aS=s-v+aL+az.verticalGutter}}if(aS){M(aS,aK)}aQ=aD();aT=aQ+ak;if(aV<aQ||aR){aU=aV-az.horizontalGutter}else{if(aV+aM>aT){aU=aV-ak+aM+az.horizontalGutter}}if(aU){N(aU,aK)}}function aD(){return -Y.position().left}function aB(){return -Y.position().top}function K(){var s=Z-v;return(s>20)&&(s-aB()<10)}function B(){var s=T-ak;return(s>20)&&(s-aD()<10)}function ag(){am.unbind(ac).bind(ac,function(aM,aN,aL,aJ){var aK=aa,s=I;Q.scrollBy(aL*az.mouseWheelSpeed,-aJ*az.mouseWheelSpeed,false);return aK==aa&&s==I})}function n(){am.unbind(ac)}function aC(){return false}function J(){Y.find(":input,a").unbind("focus.jsp").bind("focus.jsp",function(s){ab(s.target,false)})}function E(){Y.find(":input,a").unbind("focus.jsp")}function S(){var s,aJ,aL=[];aF&&aL.push(an[0]);aA&&aL.push(U[0]);Y.focus(function(){D.focus()});D.attr("tabindex",0).unbind("keydown.jsp keypress.jsp").bind("keydown.jsp",function(aO){if(aO.target!==this&&!(aL.length&&b(aO.target).closest(aL).length)){return}var aN=aa,aM=I;switch(aO.keyCode){case 40:case 38:case 34:case 32:case 33:case 39:case 37:s=aO.keyCode;aK();break;case 35:M(Z-v);s=null;break;case 36:M(0);s=null;break}aJ=aO.keyCode==s&&aN!=aa||aM!=I;return !aJ}).bind("keypress.jsp",function(aM){if(aM.keyCode==s){aK()}return !aJ});if(az.hideFocus){D.css("outline","none");if("hideFocus" in am[0]){D.attr("hideFocus",true)}}else{D.css("outline","");if("hideFocus" in am[0]){D.attr("hideFocus",false)}}function aK(){var aN=aa,aM=I;switch(s){case 40:Q.scrollByY(az.keyboardSpeed,false);break;case 38:Q.scrollByY(-az.keyboardSpeed,false);break;case 34:case 32:Q.scrollByY(v*az.scrollPagePercent,false);break;case 33:Q.scrollByY(-v*az.scrollPagePercent,false);break;case 39:Q.scrollByX(az.keyboardSpeed,false);break;case 37:Q.scrollByX(-az.keyboardSpeed,false);break}aJ=aN!=aa||aM!=I;return aJ}}function R(){D.attr("tabindex","-1").removeAttr("tabindex").unbind("keydown.jsp keypress.jsp")}function C(){if(location.hash&&location.hash.length>1){var aL,aJ,aK=escape(location.hash);try{aL=b(aK)}catch(s){return}if(aL.length&&Y.find(aK)){if(am.scrollTop()===0){aJ=setInterval(function(){if(am.scrollTop()>0){ab(aK,true);b(document).scrollTop(am.position().top);clearInterval(aJ)}},50)}else{ab(aK,true);b(document).scrollTop(am.position().top)}}}}function ai(){b("a.jspHijack").unbind("click.jsp-hijack").removeClass("jspHijack")}function m(){ai();b("a[href^=#]").addClass("jspHijack").bind("click.jsp-hijack",function(){var s=this.href.split("#"),aJ;if(s.length>1){aJ=s[1];if(aJ.length>0&&Y.find("#"+aJ).length>0){ab("#"+aJ,true);return false}}})}function ao(){var aK,aJ,aM,aL,aN,s=false;am.unbind("touchstart.jsp touchmove.jsp touchend.jsp click.jsp-touchclick").bind("touchstart.jsp",function(aO){var aP=aO.originalEvent.touches[0];aK=aD();aJ=aB();aM=aP.pageX;aL=aP.pageY;aN=false;s=true}).bind("touchmove.jsp",function(aR){if(!s){return}var aQ=aR.originalEvent.touches[0],aP=aa,aO=I;Q.scrollTo(aK+aM-aQ.pageX,aJ+aL-aQ.pageY);aN=aN||Math.abs(aM-aQ.pageX)>5||Math.abs(aL-aQ.pageY)>5;
return aP==aa&&aO==I}).bind("touchend.jsp",function(aO){s=false}).bind("click.jsp-touchclick",function(aO){if(aN){aN=false;return false}})}function g(){var s=aB(),aJ=aD();D.removeClass("jspScrollable").unbind(".jsp");D.replaceWith(ap.append(Y.children()));ap.scrollTop(s);ap.scrollLeft(aJ)}b.extend(Q,{reinitialise:function(aJ){aJ=b.extend({},az,aJ);at(aJ)},scrollToElement:function(aK,aJ,s){ab(aK,aJ,s)},scrollTo:function(aK,s,aJ){N(aK,aJ);M(s,aJ)},scrollToX:function(aJ,s){N(aJ,s)},scrollToY:function(s,aJ){M(s,aJ)},scrollToPercentX:function(aJ,s){N(aJ*(T-ak),s)},scrollToPercentY:function(aJ,s){M(aJ*(Z-v),s)},scrollBy:function(aJ,s,aK){Q.scrollByX(aJ,aK);Q.scrollByY(s,aK)},scrollByX:function(s,aK){var aJ=aD()+Math[s<0?"floor":"ceil"](s),aL=aJ/(T-ak);W(aL*j,aK)},scrollByY:function(s,aK){var aJ=aB()+Math[s<0?"floor":"ceil"](s),aL=aJ/(Z-v);V(aL*i,aK)},positionDragX:function(s,aJ){W(s,aJ)},positionDragY:function(aJ,s){V(aJ,s)},animate:function(aJ,aM,s,aL){var aK={};aK[aM]=s;aJ.animate(aK,{duration:az.animateDuration,easing:az.animateEase,queue:false,step:aL})},getContentPositionX:function(){return aD()},getContentPositionY:function(){return aB()},getContentWidth:function(){return T},getContentHeight:function(){return Z},getPercentScrolledX:function(){return aD()/(T-ak)},getPercentScrolledY:function(){return aB()/(Z-v)},getIsScrollableH:function(){return aF},getIsScrollableV:function(){return aA},getContentPane:function(){return Y},scrollToBottom:function(s){V(i,s)},hijackInternalLinks:function(){m()},destroy:function(){g()}});at(O)}e=b.extend({},b.fn.jScrollPane.defaults,e);b.each(["mouseWheelSpeed","arrowButtonSpeed","trackClickSpeed","keyboardSpeed"],function(){e[this]=e[this]||e.speed});return this.each(function(){var f=b(this),g=f.data("jsp");if(g){g.reinitialise(e)}else{g=new d(f,e);f.data("jsp",g)}})};b.fn.jScrollPane.defaults={showArrows:false,maintainPosition:true,stickToBottom:false,stickToRight:false,clickOnTrack:true,autoReinitialise:false,autoReinitialiseDelay:500,verticalDragMinHeight:0,verticalDragMaxHeight:99999,horizontalDragMinWidth:0,horizontalDragMaxWidth:99999,contentWidth:c,animateScroll:false,animateDuration:300,animateEase:"linear",hijackInternalLinks:false,verticalGutter:4,horizontalGutter:4,mouseWheelSpeed:0,arrowButtonSpeed:0,arrowRepeatFreq:50,arrowScrollOnHover:false,trackClickSpeed:0,trackClickRepeatFreq:70,verticalArrowPositions:"split",horizontalArrowPositions:"split",enableKeyboardNavigation:true,hideFocus:false,keyboardSpeed:0,initialDelay:300,speed:30,scrollPagePercent:0.8}})(jQuery,this);

/* French initialisation for the jQuery UI date picker plugin. */
/* Written by Keith Wood (kbwood{at}iinet.com.au) and Stéphane Nahmani (sholby@sholby.net). */
jQuery(function($){
	$.datepicker.regional['fr'] = {
		closeText: 'Fermer',
		prevText: '&#x3c;Préc',
		nextText: 'Suiv&#x3e;',
		currentText: 'Courant',
		monthNames: ['Janvier','Février','Mars','Avril','Mai','Juin',
		'Juillet','Août','Septembre','Octobre','Novembre','Décembre'],
		monthNamesShort: ['Jan','Fév','Mar','Avr','Mai','Jun',
		'Jul','Aoû','Sep','Oct','Nov','Déc'],
		dayNames: ['Dimanche','Lundi','Mardi','Mercredi','Jeudi','Vendredi','Samedi'],
		dayNamesShort: ['Dim','Lun','Mar','Mer','Jeu','Ven','Sam'],
		dayNamesMin: ['Di','Lu','Ma','Me','Je','Ve','Sa'],
		weekHeader: 'Sm',
		dateFormat: 'dd/mm/yy',
		firstDay: 1,
		isRTL: false,
		showMonthAfterYear: false,
		yearSuffix: ''};
	$.datepicker.setDefaults($.datepicker.regional['fr']);
});

/*! Copyright (c) 2010 Brandon Aaron (http://brandonaaron.net)
 * Licensed under the MIT License (LICENSE.txt).
 *
 * Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
 * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
 * Thanks to: Seamus Leahy for adding deltaX and deltaY
 *
 * Version: 3.0.4
 * 
 * Requires: 1.2.2+
 */

(function($) {

var types = ['DOMMouseScroll', 'mousewheel'];

$.event.special.mousewheel = {
    setup: function() {
        if ( this.addEventListener ) {
            for ( var i=types.length; i; ) {
                this.addEventListener( types[--i], handler, false );
            }
        } else {
            this.onmousewheel = handler;
        }
    },
    
    teardown: function() {
        if ( this.removeEventListener ) {
            for ( var i=types.length; i; ) {
                this.removeEventListener( types[--i], handler, false );
            }
        } else {
            this.onmousewheel = null;
        }
    }
};

$.fn.extend({
    mousewheel: function(fn) {
        return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel");
    },
    
    unmousewheel: function(fn) {
        return this.unbind("mousewheel", fn);
    }
});


function handler(event) {
    var orgEvent = event || window.event, args = [].slice.call( arguments, 1 ), delta = 0, returnValue = true, deltaX = 0, deltaY = 0;
    event = $.event.fix(orgEvent);
    event.type = "mousewheel";
    
    // Old school scrollwheel delta
    if ( event.wheelDelta ) { delta = event.wheelDelta/120; }
    if ( event.detail     ) { delta = -event.detail/3; }
    
    // New school multidimensional scroll (touchpads) deltas
    deltaY = delta;
    
    // Gecko
    if ( orgEvent.axis !== undefined && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) {
        deltaY = 0;
        deltaX = -1*delta;
    }
    
    // Webkit
    if ( orgEvent.wheelDeltaY !== undefined ) { deltaY = orgEvent.wheelDeltaY/120; }
    if ( orgEvent.wheelDeltaX !== undefined ) { deltaX = -1*orgEvent.wheelDeltaX/120; }
    
    // Add event and delta to the front of the arguments
    args.unshift(event, delta, deltaX, deltaY);
    
    return $.event.handle.apply(this, args);
}

})(jQuery);

(function($) {
	
  var cache = [];
  // Arguments are image paths relative to the current page.
  $.preLoadImages = function() {
    var args_len = arguments.length;
    for (var i = args_len; i--;) {
      var cacheImage = document.createElement('img');
      cacheImage.src = arguments[i];
      cache.push(cacheImage);
    }
  }
})(jQuery);


Core = {
	initialize: function(){
		Core.Commons.initialize();
	}
};


Core.Commons = {
	
	initialize : function(){
		
	
		
	}
	
}

Core.Auth = {
	
	Initialize: function(){
		$("form#auth").validate({
			debug: true,
			errorElement: "span",
			success: "success",
			submitHandler: function(form) {
			       // do other stuff for a valid form
			   	$("form#auth").ajaxSubmit({
					dataType: 'json',
					success: function(response){
						if(response.error == false) document.location.href = response.redirect;
						else if(response.error == true && response.code == 1) alert('no user match');
						else if(response.error == true && response.code == 2) alert('email format invalid');
					}
				});
			}
		});
				
		$("form#subscribe").validate({
			debug: true,
			errorElement: "span",
			success: "success",
			submitHandler: function(form){
				$("form#subscribe").ajaxSubmit({
					dataType: 'json',
					success: function(response){
						if(response.error == false) document.location.href = response.redirect;
						else if(response.error == true && response.code == 1) alert('no user match');
						else if(response.error == true && response.code == 2) alert('email format invalid');
					}
				});
			}
		});
	}	
}

Core.Loading = {
	start: function(element, small){
		
		if(small !== undefined)
			$(element).prepend('<div class="loader_container small"><div class="loader"></div></div>');
		else
			$(element).prepend('<div class="loader_container"><div class="loader"></div></div>');
		
		var width = $(element).width();
		var height = $(element).height();
		
		var loader_width = $(element + ' .loader_container').width();
		var loader_height = $(element + ' .loader_container').height();
		
		var top_position = height / 2 - loader_height / 2;
		var left_position = width / 2 - loader_width / 2;

		$(element + ' .loader_container').css({'top':top_position+'px','left':left_position+'px'}).fadeIn();
	},
	stop: function(element){
		$(element+' .loader_container').remove();			
	}
}

Core.Loader = {
	
	init: function(){
		
		//Core.Loading.stop("body");
		//$("#logo").fadeOut(1000, function(){
			$("#site").fadeIn(1000, function(){
				//Application.setHeight();
			});
		//});
		
	}
	
}

Core.Screen = {
	width: screen.width,
	height: screen.height,
	ratio: '169',
	resolution: null,
	resolutions: '',
	init: function(resolution){
		
		Core.Screen.resolutions = resolution;
		Core.Screen.width = screen.width;
		Core.Screen.height = screen.height;
		
		if (Core.Screen.width/Core.Screen.height > 1.5)
		{
			Core.Screen.ratio = '169';
		}else{
			Core.Screen.ratio = '43';
		}	
		
		
		var optimum_width = 0;
		var response = JSON.parse(resolution, function(key, value){
			
			if(key == 0)
			{
				optimum_width = value;
				if(optimum_width == Core.Screen.width)
				{
					Core.Screen.resolution = optimum_width;
					return optimum_width;
				}
			}else{
				if(Core.Screen.width == value){
					optimum_width = value;
					Core.Screen.resolution = optimum_width;
					return optimum_width;
				}else if(Core.Screen.width > value)
				{
					
				}else
				{
					optimum_width = value;
					Core.Screen.resolution = optimum_width;
					return optimum_width;
				}
			}
						
		});

		var screen_width=Core.Screen.getCookie("screen");
		if (screen_width==null || screen_width=="" || screen_width != Core.Screen.resolution) Core.Screen.setCookie("screen", Core.Screen.resolution, 365);
		
		Core.Screen.setCookie("ratio", Core.Screen.ratio, 365);
		
		
	},
	setCookie: function(c_name,value,exdays)
	{
		var exdate=new Date();
		exdate.setDate(exdate.getDate() + exdays);
		var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
		document.cookie=c_name + "=" + c_value;
	},
	getCookie: function(c_name)
	{
		var i,x,y,ARRcookies=document.cookie.split(";");
		for (i=0;i<ARRcookies.length;i++)
		{
		  	x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
		  	y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
		  	x=x.replace(/^\s+|\s+$/g,"");
		  	if (x==c_name)
		  	{
				return unescape(y);
			}
		}
	}
}

var delay = (function(){
  var timer = 0;
  return function(callback, ms){
    clearTimeout (timer);
    timer = setTimeout(callback, ms);
  };
})();

$().ready(function() {
	Core.initialize();
});

jQuery.validator.addMethod("myDate", function(value, element) { 
    return Date.parseExact(value, "d/M/yyyy");
});

Application = {
	disablemenu: false,
	heightContent: 0,
	firstload: true,
	Initialize: function(){
		
		//Set menu separator to off
		var menuon = $("#footer li.on");
		var separatorPrevious = menuon.prev('.separator');
		var separatorNext = menuon.next('.separator');
		separatorPrevious.addClass('offf');
		separatorNext.addClass('offf');
				
		//Core.Loading.start("body");
		Cufon.replace('.Abadi', {hover: true, fontFamily: 'Abadi MT Condensed Extra Bold'});

		$("#footer li a").die().live('click', function(){
			
			var self = $(this);
			var li = self.parent();	
			if(Application.disablemenu == false && !li.hasClass('on'))
			{
				Application.disablemenu = true;
						

				var firstli = $("#footer li:eq(0)");
				var index = li.index();
				var leftpos = li.position().left;		
            	
				var menu = self.data('menu');
				var background = self.data('background');
				
				$("#menuRight li a").removeClass('off');
				$("#menuRight li a[data-background="+background+"]").addClass('off');
				
				$("#footer li").removeClass('on').removeClass('hover');
				li.addClass('on');
				
				var separatorPrevious = li.prev();
				var separatorNext = li.next();
				$("#footer li.separator").removeClass('offf');
				separatorPrevious.addClass('offf');
				separatorNext.addClass('offf');
				
				Application.loadPage(background, self.attr('href'));
				return false;
			}
		});
		
		$("#menuRight li a").die().live('click', function(){
			
			var self = $(this);
			if(Application.disablemenu == false && !self.hasClass('off'))
			{
				Application.disablemenu = true;
				$("#menuRight li a").removeClass('off');
				self.addClass('off');
				
				var background = self.data('background');
				var href = self.attr('href');
				
				if(self.data("menuparent"))
					var menuTemp = self.data("menuparent");
				else
					var menuTemp = self.data("menu");
				
				var menu = $("#footer li a[data-menu="+menuTemp+"]");
				$("#footer li").removeClass('on');
				menu.parent().addClass('on');
				
				var separatorPrevious = menu.parent().prev();
				var separatorNext = menu.parent().next();
				$("#footer li.separator").removeClass('offf');
				separatorPrevious.addClass('offf');
				separatorNext.addClass('offf');
				
				Application.loadPage(background, href);
				return false;
			}
		});
		
		$.address.externalChange(function(event){
			if(event.value != '/')
			{
				if(Application.firstload == true)
				{
					document.location.href = event.value
				}else
				{
					$.ajax({
						url: '/Default/index/background-by-url',
						data: {'href':event.value},
						success: function(response){
							Application.loadPage(response, event.value);
						}
					});
				}
			}
		});		
		
		$("#footer li a").hover(function(){
			if(Application.disablemenu == false)
			{
				clearTimeout(Application.menuTimeout);
				var self = $(this);
				self.parent().addClass('hover');
				
				var separatorPrevious = self.parent().prev();
				var separatorNext = self.parent().next('.separator');
				$("#footer li.separator").removeClass('off');
				separatorPrevious.addClass('off');
				separatorNext.addClass('off');
				
				//Application.menuRightClose(function(){
					Application.menuRight(self.data('menu'));
				//});
			}
			
		}, function(){
			if(Application.disablemenu == false)
			{
				var self = $(this);
				$("#footer li.separator").removeClass('off');
				self.parent().removeClass('hover');
				Application.menuTimeout = setTimeout("Application.menuRightClose();", 1000);
			}
		});
		
		$("#menuRight").hover(function(){
			clearTimeout(Application.menuTimeout);
		}, function(){
			Application.menuTimeout = setTimeout("Application.menuRightClose();", 1000);
		});
		
		$("a").live('click', function(){
			var self = $(this);
			var href = self.attr('href');
			var target = self.attr('target');
			var rel = self.attr('rel');
			
			if(target != '_blank' && rel != 'noajax')
			{	
				$.address.value($(this).attr('href'));
				return false;
			}
		});
		
		$("a.book").live('click', function(){
			
			if($("#press")) 		$("#press").slideUp();
			if($("#bookpage")) 		$("#bookpage").slideUp();
			if($("#contactpage")) 	$("#contactpage").slideUp();
			if($("#findus")) 		$("#findus").slideUp();
			if($("#legal")) 		$("#legal").slideUp();
			
			Core.Loading.start("#site");
			var self = $(this);
			var href = self.attr('href');
			var target = self.attr('target');
			var rel = self.attr('rel');
			
			if(target != '_blank' && rel != 'noajax')
			{
			
				$.ajax({
					url: href,
					type: 'GET',
					success: function(response){
						Core.Loading.stop("#site");
						$("#ajaxcontent").prepend(response);
					}
				});
				
				return false;
			}
		});
		
		$("a.contact").live('click', function(){
			
			if($("#press")) 		$("#press").slideUp();
			if($("#bookpage")) 		$("#bookpage").slideUp();
			if($("#contactpage")) 	$("#contactpage").slideUp();
			if($("#findus")) 		$("#findus").slideUp();
			if($("#legal")) 		$("#legal").slideUp();

			Core.Loading.start("#site");
			var self = $(this);
			var href = self.attr('href');
			var target = self.attr('attr');
			var rel = self.attr('rel');
            
			if(target != '_blank' && rel != 'noajax')
			{
            
				$.ajax({
					url: href,
					type: 'GET',
					success: function(response){
						Core.Loading.stop("#site");
						$("#ajaxcontent").prepend(response);
					}
				});
            
				return false;
			}
			
		});
		
		$("a.findus").live('click', function(){
			
			if($("#press")) 		$("#press").slideUp();
			if($("#bookpage")) 		$("#bookpage").slideUp();
			if($("#contactpage")) 	$("#contactpage").slideUp();
			if($("#findus")) 		$("#findus").slideUp();
			if($("#legal")) 		$("#legal").slideUp();

			Core.Loading.start("#site");
			var self = $(this);
			var href = self.attr('href');
			var target = self.attr('attr');
			var rel = self.attr('rel');
            
			if(target != '_blank' && rel != 'noajax')
			{
            
				$.ajax({
					url: href,
					type: 'GET',
					success: function(response){
						Core.Loading.stop("#site");
						$("#ajaxcontent").prepend(response);
					}
				});
            
				return false;
			}
			
		});
		
		
		$("a.press").live('click', function(){
			
			if($("#press")) 		$("#press").slideUp();
			if($("#bookpage")) 		$("#bookpage").slideUp();
			if($("#contactpage")) 	$("#contactpage").slideUp();
			if($("#findus")) 		$("#findus").slideUp();

			Core.Loading.start("#site");
			var self = $(this);
			var href = self.attr('href');
			var target = self.attr('attr');
			var rel = self.attr('rel');
            
			if(target != '_blank' && rel != 'noajax')
			{
            
				$.ajax({
					url: href,
					type: 'GET',
					data: {'layout':'ajax_layout', 'view':'pressslide'},
					success: function(response){
						Core.Loading.stop("#site");
						$("#ajaxcontent").prepend(response);
					}
				});
            
				return false;
			}
			
		});
		
		$("a.legal").live('click', function(){
			
			if($("#press")) 		$("#press").slideUp();
			if($("#bookpage")) 		$("#bookpage").slideUp();
			if($("#contactpage")) 	$("#contactpage").slideUp();
			if($("#findus")) 		$("#findus").slideUp();
			if($("#legal")) 		$("#legal").slideUp();

			Core.Loading.start("#site");
			var self = $(this);
			var href = self.attr('href');
			var target = self.attr('attr');
			var rel = self.attr('rel');
            
			if(target != '_blank' && rel != 'noajax')
			{
            
				$.ajax({
					url: href,
					type: 'GET',
					success: function(response){
						Core.Loading.stop("#site");
						$("#ajaxcontent").prepend(response);
					}
				});
            
				return false;
			}
			
		});
		
		$("#site").mousemove(function(event) {
			
			var x = event.pageX;
			var totalWidth = $("#site").width();
			
			if(x < 150) $("#backgroundPrevious").addClass("hover");
			else if(x > parseInt(totalWidth - 150)) $("#backgroundNext").addClass("hover");
			else{
				$("#backgroundPrevious, #backgroundNext").removeClass("hover");
			}
			
		});
		
		/*Background Carousel*/
		$("#backgroundNext").die().click(function(){
			
			var site = $("#site");
			Application.disableAnimation = true;
			
			$("#backgroundCarouselNext").animate({'left':'0%'}, 1000, function(){
				var newIndex = parseInt($("#site").data('index')+1);
				
				$("#site").data('index', newIndex);	
				$("#site").css({'background':'url("'+Application.backgrounds[Application.menu][newIndex].background+'") no-repeat fixed 50% 50%'})
				$("#bgblur, #bgblur-right").css({'background':'url("'+Application.backgrounds[Application.menu][newIndex].background_blur+'") no-repeat fixed 50% 50%'});								
				$("#backgroundCarouselNext").css('left','100%')
				Application.setNextPreviousBackground(Application.menu);
				
			});
			
		});
		
		$("#backgroundPrevious").die().click(function(){
			
			var site = $("#site");
			Application.disableAnimation = true;
			
			$("#backgroundCarouselPrevious").animate({'left':'0%'}, 1000, function(){
				var newIndex = parseInt($("#site").data('index')-1);
				$("#site").data('index', newIndex);	
				$("#site").css({'background':'url("'+Application.backgrounds[Application.menu][newIndex].background+'") no-repeat fixed 50% 50%'})
				$("#bgblur, #bgblur-right").css({'background':'url("'+Application.backgrounds[Application.menu][newIndex].background_blur+'") no-repeat fixed 50% 50%'});								
				$("#backgroundCarouselPrevious").css('left','-100%')
				Application.setNextPreviousBackground(Application.menu);
				
			});
			
		});
		
		$("#right").mouseover(function(){

			var self = $("#footer li.on a");			
			Application.menuRight(self.data('menu'));
			
		});
		
	},
	menuUpWaiting: false,
	menuUp: function(){
		
		if(Application.animateWaiting == false)
		{
			Application.menuUpWaiting = false;
			var self = $("#menuUp, #bgblur");
			if(self.css('height') == '70px'){
				Application.menuRightClose(function(){clearTimeout(Application.animationTimer); });
				Application.setHeight(function(){
				
					$('#up').rotateAnimation(180);
					self.animate({'height': Application.heightContent+'px'}, function(){});
				
				});
			}else{
				Application.menuUpClose();
			}
		}else
		{
			Application.menuUpWaiting = true;
		}
	},
	menuUpClose: function(callback){
		if(Application.disablemenu == false)
		{
			var self = $("#menuUp, #bgblur");
			$('#up').rotateAnimation(0);
			self.animate({'height': '70px'});
			
			if(callback)
				callback.call();
			else
				Application.animateBackground();
		}
	},
	menuTimeout: null,
	menuRightWaiting: false,
	menuTemp: false,
	animateRightProcess: null,
	animateRightProcess2: null,
	menuRight: function(menu){
		if(Application.disablemenu == false)
		{
			if(Application.animateWaiting == false)
			{
				Application.menuRightWaiting = false;
				Application.menuUpClose();
				clearTimeout(Application.animationTimer);
				$(".menu").hide();
				$("#menu-"+menu).show();
				var self = $("#menuRight, #bgblur-right");
				if(self.css('width') == '0px')
				{
					Application.animateRightProcess = self.animate({'width': '225px'});
					Application.animateRightProcess2 = $("#right").animate({'left':'225px'});
				}
			}else
			{
				Application.menuTemp = menu;
				Application.menuRightWaiting = true;
			}
		}	
		
	},
	menuRightClose: function(callback){
		
		var self = $("#menuRight, #bgblur-right");
		$("#right").animate({'left':'0px'});
		self.animate({'width': '0px'}, function(){
			if(callback)
				callback.call();
			else
				Application.animateBackground();
		});
		
		
	},
	backgrounds: null,
	menu: null,
	loadPage: function(menu, href, callback){
		if(Application.backgrounds[menu])
		{
			if(Application.animateRightProcess != null){
				$("#menuRight, #bgblur-right").stop();
				Application.animateRightProcess = null;
			}
			
			if(Application.animateRightProcess2 != null){
				$("#right").stop();
				Application.animateRightProcess2 = null;
			}
			
			Application.disablemenu = true;
			Application.initHeight = false;
			Application.disableAnimation = true;
			clearTimeout(Application.animationTimer);
			Application.firstload = false;
			Application.menu = menu;
            
			$("#site").data('index', 0);	
			Application.setNextPreviousBackground(Application.menu);
			
			$("#preloadImage").prepend('<img src="'+Application.backgrounds[menu][0].background_blur+'" />');

            
			$.address.value(href);
			Core.Loading.start("#site");
			
			var bgblur = $("#bgblur");
			var menuUp = $("#menuUp");
			var menuRight = $("#menuRight");
			var bgblurright = $("#bgblur-right");
			var right = $("#right");
			var content = $("#content");
			var breadcrumbs = $("#breadcrumbs");
			
			bgblur.css('height', '70px');
			menuUp.css('height', '70px');
			
			menuRight.css('width', '0px');
			bgblurright.css('width', '0px');
			right.css('left', '0px');
			
			$.ajax({
				type:'GET',
				data: {'layout':'ajax_layout'},
				url: href,
				async: false,
				success: function(response){
	
					bgblur.css('display', 'none').css('height','100%');
					menuUp.css('height','100%');
					breadcrumbs.css('display', 'none');
					content.css('display', 'none');
							
					bgblur.fadeIn(1500, function(){
						if($('div.carte-bg')) $('div.carte-bg').remove();
						$("#site").css('background','url("'+Application.backgrounds[menu][0].background+'") no-repeat 50% 50%');
						
						$("#ajaxcontent").fadeOut(1500, function(){
							$("#bgblur, #bgblur-right").css('background','url("'+Application.backgrounds[menu][0].background_blur+'") no-repeat fixed 50% 50%');		
							
							$("#ajaxcontent").html(response).fadeIn(1500, function(){
								$("#content").fadeIn(500, function(){
									
									
									Core.Loading.stop("#site");
									if(Application.disableAnimation == false) Application.animateBackground();
									
									Application.disablemenu = false;
									Application.disableAnimation = false;
									
									if(callback){
										callback.call();
									}else
									{
									
										Application.menuUp();
										$(".jscroll").jScrollPane({
											autoReinitialise: true
										});
										setTimeout(function(){
											Application.menuUpClose();											
										}, 4000);
									}
								});
							});
							
						});
	
					});
				}
			});
		}else
			Application.disablemenu = false;
	},
	initHeight: false,
	setHeight: function(callback){
		
		if(Application.initHeight == false)
		{
			Application.initHeight = parseInt($("#content").height());
		}
		
		var targetHeight = Application.initHeight + parseInt($("#content").css('margin-top'))+100;

		//Application.initHeight = targetHeight;
		//	alert(targetHeight)
		var availableHeight = parseInt($("#site").height()) - parseInt($("#header").height())-parseInt($("#footer").height())-parseInt($("#breadcrumbs").height())
				
		if(targetHeight > availableHeight) targetHeight = availableHeight;
		$("#content").css({'height':targetHeight+'px'});

		Application.heightContent = targetHeight;
		$(".jscroll").jScrollPane({
			autoReinitialise: true
		});
		
		if(callback) callback.call();
	},
	setNextPreviousBackground: function(menu){
		
		if(Application.backgrounds[Application.menu] && Application.backgrounds[menu].length > 1)
		{
			var site = $("#site");
			var currentIndex = parseInt(site.data('index'));
			
			var nextIndex = null;
			var previousIndex = null;
			
			$("#backgroundPrevious, #backgroundNext").removeClass('off');
			if(currentIndex == 0)
			{
				nextIndex = 1;
				$("#backgroundPrevious").addClass('off');
				$("#backgroundCarouselPrevious").data('index', '');
			}else if(currentIndex == parseInt(Application.backgrounds[menu].length - 1))
			{
				previousIndex = parseInt(currentIndex - 1);
				$("#backgroundCarouselNext").data('index', '');
				$("#backgroundNext").addClass('off');
			}else
			{
				nextIndex = parseInt(currentIndex+1);
				previousIndex = parseInt(currentIndex-1);
				
				$("#backgroundCarouselNext").data('index', nextIndex);
				$("#backgroundCarouselPrevious").data('index', previousIndex);
			}
			
			if(nextIndex != null) $("#backgroundCarouselNext").css({'background':'url("'+Application.backgrounds[menu][nextIndex].background+'") no-repeat fixed 50% 50%'});
			if(previousIndex != null) $("#backgroundCarouselPrevious").css({'background':'url("'+Application.backgrounds[menu][previousIndex].background+'") no-repeat fixed 50% 50%'});
			Application.animateBackground();
		}else
		{
			$("#backgroundNext").addClass('off');
			$("#backgroundPrevious").addClass('off');
		}
	},
	disableAnimation: false,
	disableCarousel: function(){
		$("#backgroundNext").addClass('off');
		$("#backgroundPrevious").addClass('off');
	},
	changeResolution: function(){
		Core.Screen.init(Core.Screen.resolutions);
		
		$.ajax({
			url: '/Default/index/backgrounds',
			type: 'get',
			data: {'screen':Core.Screen.resolution, 'ratio': Core.Screen.ratio},
			dataType: 'json',
			success: function(response){
				Application.backgrounds = response;
			}
		});
		
	},
	animationTime: 5000,
	animationWay: 'next',
	animateBackground: function(){

		clearTimeout(Application.animationTimer);
		if(Application.disableAnimation == false && Application.backgrounds[Application.menu])
		{
			
			if(Application.backgrounds[Application.menu].length > 1)
			{

				Application.animationTimer = setTimeout(function(){
					var site = $("#site");
					var currentIndex = parseInt(site.data('index'));
					
					if(currentIndex == 0) Application.animationWay = 'next';
					else if(currentIndex == parseInt(Application.backgrounds[Application.menu].length - 1)) Application.animationWay = 'previous';
					
					if(Application.animationWay == 'next') Application.animateNext();
					else Application.animatePrevious();
					
				}, Application.animationTime);
			}		
		}
	},
	animateWaiting: false,
	animateNext: function(){
		var site = $("#site");
		Application.animateWaiting = true;
		$("#backgroundCarouselNext").animate({'left':'0%'}, 1000, function(){
			var newIndex = parseInt($("#site").data('index')+1);
			
			$("#site").data('index', newIndex);	
			$("#site").css({'background':'url("'+Application.backgrounds[Application.menu][newIndex].background+'") no-repeat fixed 50% 50%'})
			$("#bgblur, #bgblur-right").css({'background':'url("'+Application.backgrounds[Application.menu][newIndex].background_blur+'") no-repeat fixed 50% 50%'});								
			$("#backgroundCarouselNext").css('left','100%')
			Application.setNextPreviousBackground(Application.menu);
			
			Application.animateWaiting = false;
			if(Application.menuUpWaiting == true)
			{
				Application.menuUp();
			}
			
			if(Application.menuRightWaiting == true)
			{
				Application.menuRight(Application.menuTemp);
			}
		});
	},
	animatePrevious: function(){
		var site = $("#site");
		Application.animateWaiting = true;
		$("#backgroundCarouselPrevious").animate({'left':'0%'}, 1000, function(){
			var newIndex = parseInt($("#site").data('index')-1);
			$("#site").data('index', newIndex);	
			$("#site").css({'background':'url("'+Application.backgrounds[Application.menu][newIndex].background+'") no-repeat fixed 50% 50%'})
			$("#bgblur, #bgblur-right").css({'background':'url("'+Application.backgrounds[Application.menu][newIndex].background_blur+'") no-repeat fixed 50% 50%'});								
			$("#backgroundCarouselPrevious").css('left','-100%')
			Application.setNextPreviousBackground(Application.menu);
			
			Application.animateWaiting = false;
			if(Application.menuUpWaiting == true)
			{
				Application.menuUp();
			}
			
			if(Application.menuRightWaiting == true)
			{
				Application.menuRight(Application.menuTemp);
			}
			
		});
	}
}

Application.Booking = {
	init: function(){
		$(".jscroll").jScrollPane({
			autoReinitialise: true
		});
		
		$("#bookpage").slideDown(1000);

		$('select.mjm').dropkick({
			"theme": 'mjm'
		});
		
		$('.package select.mjm_big').dropkick({
			"theme": 'mjm_big',
			"width": 300,
			change: function (value, label) {

				if(value.match(/valentin/i))
				{
					$("input.datePicker[name=begin]").datepicker( "option", "minDate", new Date(2012, 1, 14) );
					$("input.datePicker[name=begin]").datepicker( "option", "maxDate", new Date(2012, 1, 14));
					$("input.datePicker[name=end]").datepicker( "option", "minDate", new Date(2012, 1, 15));
					$("input.datePicker[name=end]").datepicker( "option", "maxDate", new Date(2012, 1, 15));
				}else{
					$("input.datePicker[name=begin], input.datePicker[name=end]").datepicker( "option", "minDate", 1 );
					$("input.datePicker[name=begin], input.datePicker[name=end]").datepicker( "option", "maxDate", null );
				}					
			}
		});
		$('select.mjm_big').dropkick({
			"theme": 'mjm_big'
		});
			
		$('select.transfer_select').dropkick({
			"theme": 'mjm_big',
			change: function (value, label) {
				if(value == 'Oui')
				{
					$(".transfer").show();
				}
				else
				{
					$(".transfer").hide();
				}
			}
		});
		
		var self2 = $("#bookpage");
		$(".close").click(function(){
			self2.slideUp(500, function(){
				self2.remove();
			});
		})
		
		$("#bookingform").validate({
			debug: false,
			errorElement: "span",
			success: "success",
			
			submitHandler: function(form){
        
				Core.Loading.start("#site");
				$(form).ajaxSubmit({
					success: function(response){
					
						Core.Loading.stop("#site");
						
						$("#book").fadeOut(500, function(){
							var self = $(this);
							self.html(response).fadeIn(1000);
						});
						
					}
				});
			}
		});

					
		$("#bookpage #type").hover(function(){
			$("#bookpage #type").css({'height':'220'});
			$("#bookpage #type").addClass('typehover');
			$("#bookpage #type li").addClass('display');
			$(this).removeClass('display');
			
			/*$("#bookpage #type li.display").unbind('click').click(function(){
				$("#bookpage #type li").removeClass('display').removeClass('current');
				$(this).addClass('current');
			});*/
		}, function(){
			$("#bookpage #type").css({'height':'20'});
			$("#bookpage #type").removeClass('typehover');
			$("#bookpage #type li.display").removeClass('display');
		});
		
		/*$("#bookpage #type li a.false").on("click", function(event){
			event.preventDefault();
		});*/
		
		/*$("#bookpage #type li.show").unbind('click').click(function(){
			$("#bookpage #type li").addClass('display');
			$(this).removeClass('display');
			
			$("#bookpage #type li.display").unbind('click').click(function(){
				$("#bookpage #type li").removeClass('display').removeClass('current');
				$(this).addClass('current');
			});
		});*/
		
	}
}

Application.Contact = {
	init: function(){
		$("#contactpage").slideDown(1000);
		
		$("input.datePicker").datepicker({
			"dateFormat" : "dd/mm/yy"
		});

		$('select').dropkick({
			'theme': 'mjm_big',
			'width': 180
		});
		
		$('#dk_container_job').parent().parent().hide();
		$('#label_job').hide();
		
		var self2 = $("#contactpage");
		$(".close").click(function(){
			self2.slideUp(500, function(){
				self2.remove();
			});
		})
		
		$("#contactform").validate({
			debug: true,
			errorElement: "span",
			success: "success",
			submitHandler: function(form){
        
				Core.Loading.start("#site");
				$(form).ajaxSubmit({
					success: function(response){
					
						Core.Loading.stop("#site");
						
						$("#response").fadeOut(500, function(){
							var self = $(this);
							self.html(response).fadeIn(1000);
						});
						
					}
				});
			}
		});
		
		$("#contactpage #type li.show").unbind('click').click(function(){
			$("#contactpage #type li").addClass('display');
			$(this).removeClass('display');
			
			$("#contactpage #type li.display").unbind('click').click(function(){
				$("#contactpage #type li").removeClass('display').removeClass('current');
				$(this).addClass('current');
			});
		});
		
		$("#contactpage .text ul li").unbind("click").click(function(){
			var self = $(this);
			$("input[name=to]").val(self.data('to'));
			if(self.data('to')=='recrutment')
			{
				$('#dk_container_job').parent().parent().show();
				$('#label_job').show();
			}else{
				$('#dk_container_job').parent().parent().hide();
				$('#label_job').hide();
			}
			$("#labelmore").html(self.data('label'));
			$("#contactpage .text ul li").removeClass('current');
			self.addClass('current');
			
		});
		
	}
}

Application.Findus = {
	init: function(){
		$("#findus").slideDown(1000);
		
		var self2 = $("#findus");
		$(".close").click(function(){
			self2.slideUp(500, function(){
				self2.remove();
			});
		})
		
		$('.map-link').off().on({			
		  mouseenter: function(){
			var self = $(this);
			var cssclass = "#id"+self.attr('id');
			$(cssclass).show();
		  },
		  mouseleave: function(){
				var self = $(this);
				var cssclass = "#id"+self.attr('id');
				$(cssclass).hide();
		  }
		});
		
	}
}

Application.Press = {
	init: function(){
		$("#press").slideDown(1000);
		
		var self2 = $("#press");
		$(".close").click(function(){
			self2.slideUp(500, function(){
				self2.remove();
			});
		});
		
		Application.Press.ajax();
		
		$("#press .items a").click(function(){
			var self = $(this);
			$("#press .items a").addClass('off');
			self.removeClass('off')
			$("#press .items a img").css({'opacity':'1'});
			$("#press .items a.off img").css({'opacity':'0.5'});
			
			$.ajax({
				url: self.attr('href'),
				data: {'view':'pressajax', 'layout':'ajax_layout'},
				success: function(response){
					$("#press .content .carousel").html(response);
				}
			});
		});
		
		$("#press .items a.off img").live("mouseover", function(){
			var self = $(this);
			self.css({'opacity':'1'})
		});
		$("#press .items a.off img").live("mouseout", function(){
			var self = $(this);
			self.css({'opacity':'0.5'})
		});
		
	},
	ajax: function(){
		
		
		$("#press .content .carousel .carouselNext").die().click(function(){
			var self = $("#press .content .carousel img.current");
			var next = self.next('img');
			
			if(next.length > 0)
			{
			
				var selfzindex = self.css('z-index');
				var nextzindex = next.css('z-index');
				
				next.addClass('next').show();
				
				self.fadeOut(2000, function(){
					self.css({'z-index':nextzindex}).removeClass('current');
					next.css({'z-index':selfzindex}).addClass('current').removeClass('next');
				});
				
				if(next.prev('img').length == 0) $("#press .content .carousel .carouselPrevious").hide();
				else $("#press .content .carousel .carouselPrevious").show();
				if(next.next('img').length == 0) $("#press .content .carousel .carouselNext").hide();
				else $("#press .content .carousel .carouselNext").show();
			}
			
		});
		
		$("#press .content .carousel .carouselPrevious").die().click(function(){
			var self = $("#press .content .carousel img.current");
			var previous = self.prev('img');
			
			if(previous.length > 0)
			{
			
				var selfzindex = self.css('z-index');
				var previouszindex = previous.css('z-index');
            	
				previous.addClass('next').show();

				self.fadeOut(2000, function(){
					self.css({'z-index':previouszindex}).removeClass('current')
					previous.css({'z-index':selfzindex}).addClass('current').removeClass('next');
				});
				
				if(previous.prev('img').length == 0) $("#press .content .carousel .carouselPrevious").hide();
				else $("#press .content .carousel .carouselPrevious").show();
				if(previous.next('img').length == 0) $("#press .content .carousel .carouselNext").hide();
				else $("#press .content .carousel .carouselNext").show();
			}
		});
		
		var imgCurrent = $("#press .content .carousel img.current");
		if(imgCurrent.prev('img').length == 0) $("#press .content .carousel .carouselPrevious").hide();
		if(imgCurrent.next('img').length == 0) $("#press .content .carousel .carouselNext").hide();
	}
}

Application.News = {
	init: function(){
		$("#news").slideDown(1000, function(){
			$('h4').addClass("dontend");
			$('.wide').columnize({columns: 4});
			
			
		});
		
		
	}
}

Application.Recipe = {
	init: function(){
		$(".recipes ul li a").die().click(function(){

			var self = $(this);
			var background = self.data('background');
			var href = self.attr('href');
			
			Application.loadPage(background, href);
			return false;
		});
			
	}
}

Application.Carte = {
	init: function(){

		
				
	}
}

Application.Room = {
	init: function(){
		$(".submenu a").die().click(function(){

			var self = $(this);
			var background = self.data('background');
			var href = self.attr('href');
			
			Application.loadPage(background, href);
			return false;
		});
			
	}
}

Application.Legal = {
	init: function(){
		$("#legal").slideDown(1000);
		
		var self2 = $("#legal");
		$(".close").click(function(){
			self2.slideUp(500, function(){
				self2.remove();
			});
		})
		
		
	}
}


$(document).ready(function() {
	Application.Initialize();
	$(window).resize(function(){
		delay(function(){
			Application.setHeight();
			Application.changeResolution();
		}, 100);
	});
});



var delay = (function(){
	var timer = 0;
	return function(callback, ms){
		clearTimeout (timer);
		timer = setTimeout(callback, ms);
	};
})();


