/* Simple JavaScript Inheritance
 * By John Resig http://ejohn.org/
 * MIT Licensed.
 */
// Inspired by base2 and Prototype
(function($){
(function(){var i=false,fnTest=/xyz/.test(function(){xyz})?/\b_super\b/:/.*/;this.Class=function(){};Class.extend=function(e){var f=this.prototype;i=true;var g=new this();i=false;for(var h in e){g[h]=typeof e[h]=="function"&&typeof f[h]=="function"&&fnTest.test(e[h])?(function(c,d){return function(){var a=this._super;this._super=f[c];var b=d.apply(this,arguments);this._super=a;return b}})(h,e[h]):e[h]}function Class(){if(!i&&this.init)this.init.apply(this,arguments)}Class.prototype=g;Class.prototype.constructor=Class;Class.extend=arguments.callee;return Class}})();

(function(d){var c=false,g=null;d.tinysort={id:"TinySort",version:"1.1.1",copyright:"Copyright (c) 2008-2011 Ron Valstar",uri:"http://tinysort.sjeiti.com/",licenced:{MIT:"http://www.opensource.org/licenses/mit-license.php",GPL:"http://www.gnu.org/licenses/gpl.html"},defaults:{order:"asc",attr:g,data:g,useVal:c,place:"start",returns:c,cases:c,forceStrings:c,sortFunction:g}};d.fn.extend({tinysort:function(l,f){if(l&&typeof(l)!="string"){f=l;l=g}var m=d.extend({},d.tinysort.defaults,f),v=parseFloat,s,A={},o=!(!l||l==""),r=!(m.attr===g||m.attr==""),w=m.data!==g,h=o&&l[0]==":",j=h?this.filter(l):this,q=m.sortFunction;if(!q){q=m.order=="rand"?function(){return Math.random()<0.5?1:-1}:function(C,p){var i=!m.cases?b(C.s):C.s,D=!m.cases?b(p.s):p.s;if(!m.forceStrings&&e(C.s)&&e(p.s)){i=v(C.s);D=v(p.s)}return(m.order=="asc"?1:-1)*(i<D?-1:(i>D?1:0))}}this.each(function(C,E){var D=d(E),G=o?(h?j.filter(this):D.find(l)):D,F=w?G.data(m.data):(r?G.attr(m.attr):(m.useVal?G.val():G.text())),p=D.parent();if(!A[p]){A[p]={s:[],n:[]}}if(G.length>0){A[p].s.push({s:F,e:D,n:C})}else{A[p].n.push({e:D,n:C})}});for(s in A){A[s].s.sort(q)}var k=[];for(s in A){var x=A[s],z=[],B=d(this).length;switch(m.place){case"first":d.each(x.s,function(p,C){B=Math.min(B,C.n)});break;case"org":d.each(x.s,function(p,C){z.push(C.n)});break;case"end":B=x.n.length;break;default:B=0}var u=[0,0];for(var y=0;y<d(this).length;y++){var n=y>=B&&y<B+x.s.length;if(a(z,y)){n=true}var t=(n?x.s:x.n)[u[n?0:1]].e;t.parent().append(t);if(n||!m.returns){k.push(t.get(0))}u[n?0:1]++}}return this.pushStack(k)}});function b(f){return f&&f.toLowerCase?f.toLowerCase():f}function e(h){var f=/^\s*?[\+-]?(\d*\.?\d*?)\s*?$/.exec(h);return f&&f.length>0?f[1]:c}function a(h,i){var f=c;d.each(h,function(k,j){if(!f){f=j==i}});return f}d.fn.TinySort=d.fn.Tinysort=d.fn.tsort=d.fn.tinysort})(jQuery);

// jQuery UI
(function($,undefined){$.ui=$.ui||{};if($.ui.version){return}$.extend($.ui,{version:"1.8.16",keyCode:{ALT:18,BACKSPACE:8,CAPS_LOCK:20,COMMA:188,COMMAND:91,COMMAND_LEFT:91,COMMAND_RIGHT:93,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,MENU:93,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38,WINDOWS:91}});$.fn.extend({propAttr:$.fn.prop||$.fn.attr,_focus:$.fn.focus,focus:function(delay,fn){return typeof delay==="number"?this.each(function(){var elem=this;setTimeout(function(){$(elem).focus();if(fn){fn.call(elem)}},delay)}):this._focus.apply(this,arguments)},scrollParent:function(){var scrollParent;if(($.browser.msie&&(/(static|relative)/).test(this.css('position')))||(/absolute/).test(this.css('position'))){scrollParent=this.parents().filter(function(){return(/(relative|absolute|fixed)/).test($.curCSS(this,'position',1))&&(/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1))}).eq(0)}else{scrollParent=this.parents().filter(function(){return(/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1))}).eq(0)}return(/fixed/).test(this.css('position'))||!scrollParent.length?$(document):scrollParent},zIndex:function(zIndex){if(zIndex!==undefined){return this.css("zIndex",zIndex)}if(this.length){var elem=$(this[0]),position,value;while(elem.length&&elem[0]!==document){position=elem.css("position");if(position==="absolute"||position==="relative"||position==="fixed"){value=parseInt(elem.css("zIndex"),10);if(!isNaN(value)&&value!==0){return value}}elem=elem.parent()}}return 0},disableSelection:function(){return this.bind(($.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection",function(event){event.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}});$.each(["Width","Height"],function(i,name){var side=name==="Width"?["Left","Right"]:["Top","Bottom"],type=name.toLowerCase(),orig={innerWidth:$.fn.innerWidth,innerHeight:$.fn.innerHeight,outerWidth:$.fn.outerWidth,outerHeight:$.fn.outerHeight};function reduce(elem,size,border,margin){$.each(side,function(){size-=parseFloat($.curCSS(elem,"padding"+this,true))||0;if(border){size-=parseFloat($.curCSS(elem,"border"+this+"Width",true))||0}if(margin){size-=parseFloat($.curCSS(elem,"margin"+this,true))||0}});return size}$.fn["inner"+name]=function(size){if(size===undefined){return orig["inner"+name].call(this)}return this.each(function(){$(this).css(type,reduce(this,size)+"px")})};$.fn["outer"+name]=function(size,margin){if(typeof size!=="number"){return orig["outer"+name].call(this,size)}return this.each(function(){$(this).css(type,reduce(this,size,true,margin)+"px")})}});function focusable(element,isTabIndexNotNaN){var nodeName=element.nodeName.toLowerCase();if("area"===nodeName){var map=element.parentNode,mapName=map.name,img;if(!element.href||!mapName||map.nodeName.toLowerCase()!=="map"){return false}img=$("img[usemap=#"+mapName+"]")[0];return!!img&&visible(img)}return(/input|select|textarea|button|object/.test(nodeName)?!element.disabled:"a"==nodeName?element.href||isTabIndexNotNaN:isTabIndexNotNaN)&&visible(element)}function visible(element){return!$(element).parents().andSelf().filter(function(){return $.curCSS(this,"visibility")==="hidden"||$.expr.filters.hidden(this)}).length}$.extend($.expr[":"],{data:function(elem,i,match){return!!$.data(elem,match[3])},focusable:function(element){return focusable(element,!isNaN($.attr(element,"tabindex")))},tabbable:function(element){var tabIndex=$.attr(element,"tabindex"),isTabIndexNaN=isNaN(tabIndex);return(isTabIndexNaN||tabIndex>=0)&&focusable(element,!isTabIndexNaN)}});$(function(){var body=document.body,div=body.appendChild(div=document.createElement("div"));$.extend(div.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0});$.support.minHeight=div.offsetHeight===100;$.support.selectstart="onselectstart"in div;body.removeChild(div).style.display="none"});$.extend($.ui,{plugin:{add:function(module,option,set){var proto=$.ui[module].prototype;for(var i in set){proto.plugins[i]=proto.plugins[i]||[];proto.plugins[i].push([option,set[i]])}},call:function(instance,name,args){var set=instance.plugins[name];if(!set||!instance.element[0].parentNode){return}for(var i=0;i<set.length;i++){if(instance.options[set[i][0]]){set[i][1].apply(instance.element,args)}}}},contains:function(a,b){return document.compareDocumentPosition?a.compareDocumentPosition(b)&16:a!==b&&a.contains(b)},hasScroll:function(el,a){if($(el).css("overflow")==="hidden"){return false}var scroll=(a&&a==="left")?"scrollLeft":"scrollTop",has=false;if(el[scroll]>0){return true}el[scroll]=1;has=(el[scroll]>0);el[scroll]=0;return has},isOverAxis:function(x,reference,size){return(x>reference)&&(x<(reference+size))},isOver:function(y,x,top,left,height,width){return $.ui.isOverAxis(y,top,height)&&$.ui.isOverAxis(x,left,width)}})})(jQuery);(function($,undefined){if($.cleanData){var _cleanData=$.cleanData;$.cleanData=function(elems){for(var i=0,elem;(elem=elems[i])!=null;i++){try{$(elem).triggerHandler("remove")}catch(e){}}_cleanData(elems)}}else{var _remove=$.fn.remove;$.fn.remove=function(selector,keepData){return this.each(function(){if(!keepData){if(!selector||$.filter(selector,[this]).length){$("*",this).add([this]).each(function(){try{$(this).triggerHandler("remove")}catch(e){}})}}return _remove.call($(this),selector,keepData)})}}$.widget=function(name,base,prototype){var namespace=name.split(".")[0],fullName;name=name.split(".")[1];fullName=namespace+"-"+name;if(!prototype){prototype=base;base=$.Widget}$.expr[":"][fullName]=function(elem){return!!$.data(elem,name)};$[namespace]=$[namespace]||{};$[namespace][name]=function(options,element){if(arguments.length){this._createWidget(options,element)}};var basePrototype=new base();basePrototype.options=$.extend(true,{},basePrototype.options);$[namespace][name].prototype=$.extend(true,basePrototype,{namespace:namespace,widgetName:name,widgetEventPrefix:$[namespace][name].prototype.widgetEventPrefix||name,widgetBaseClass:fullName},prototype);$.widget.bridge(name,$[namespace][name])};$.widget.bridge=function(name,object){$.fn[name]=function(options){var isMethodCall=typeof options==="string",args=Array.prototype.slice.call(arguments,1),returnValue=this;options=!isMethodCall&&args.length?$.extend.apply(null,[true,options].concat(args)):options;if(isMethodCall&&options.charAt(0)==="_"){return returnValue}if(isMethodCall){this.each(function(){var instance=$.data(this,name),methodValue=instance&&$.isFunction(instance[options])?instance[options].apply(instance,args):instance;if(methodValue!==instance&&methodValue!==undefined){returnValue=methodValue;return false}})}else{this.each(function(){var instance=$.data(this,name);if(instance){instance.option(options||{})._init()}else{$.data(this,name,new object(options,this))}})}return returnValue}};$.Widget=function(options,element){if(arguments.length){this._createWidget(options,element)}};$.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",options:{disabled:false},_createWidget:function(options,element){$.data(element,this.widgetName,this);this.element=$(element);this.options=$.extend(true,{},this.options,this._getCreateOptions(),options);var self=this;this.element.bind("remove."+this.widgetName,function(){self.destroy()});this._create();this._trigger("create");this._init()},_getCreateOptions:function(){return $.metadata&&$.metadata.get(this.element[0])[this.widgetName]},_create:function(){},_init:function(){},destroy:function(){this.element.unbind("."+this.widgetName).removeData(this.widgetName);this.widget().unbind("."+this.widgetName).removeAttr("aria-disabled").removeClass(this.widgetBaseClass+"-disabled "+"ui-state-disabled")},widget:function(){return this.element},option:function(key,value){var options=key;if(arguments.length===0){return $.extend({},this.options)}if(typeof key==="string"){if(value===undefined){return this.options[key]}options={};options[key]=value}this._setOptions(options);return this},_setOptions:function(options){var self=this;$.each(options,function(key,value){self._setOption(key,value)});return this},_setOption:function(key,value){this.options[key]=value;if(key==="disabled"){this.widget()[value?"addClass":"removeClass"](this.widgetBaseClass+"-disabled"+" "+"ui-state-disabled").attr("aria-disabled",value)}return this},enable:function(){return this._setOption("disabled",false)},disable:function(){return this._setOption("disabled",true)},_trigger:function(type,event,data){var callback=this.options[type];event=$.Event(event);event.type=(type===this.widgetEventPrefix?type:this.widgetEventPrefix+type).toLowerCase();data=data||{};if(event.originalEvent){for(var i=$.event.props.length,prop;i;){prop=$.event.props[--i];event[prop]=event.originalEvent[prop]}}this.element.trigger(event,data);return!($.isFunction(callback)&&callback.call(this.element[0],event,data)===false||event.isDefaultPrevented())}}})(jQuery);(function($,undefined){var mouseHandled=false;$(document).mouseup(function(e){mouseHandled=false});$.widget("ui.mouse",{options:{cancel:':input,option',distance:1,delay:0},_mouseInit:function(){var self=this;this.element.bind('mousedown.'+this.widgetName,function(event){return self._mouseDown(event)}).bind('click.'+this.widgetName,function(event){if(true===$.data(event.target,self.widgetName+'.preventClickEvent')){$.removeData(event.target,self.widgetName+'.preventClickEvent');event.stopImmediatePropagation();return false}});this.started=false},_mouseDestroy:function(){this.element.unbind('.'+this.widgetName)},_mouseDown:function(event){if(mouseHandled){return};(this._mouseStarted&&this._mouseUp(event));this._mouseDownEvent=event;var self=this,btnIsLeft=(event.which==1),elIsCancel=(typeof this.options.cancel=="string"&&event.target.nodeName?$(event.target).closest(this.options.cancel).length:false);if(!btnIsLeft||elIsCancel||!this._mouseCapture(event)){return true}this.mouseDelayMet=!this.options.delay;if(!this.mouseDelayMet){this._mouseDelayTimer=setTimeout(function(){self.mouseDelayMet=true},this.options.delay)}if(this._mouseDistanceMet(event)&&this._mouseDelayMet(event)){this._mouseStarted=(this._mouseStart(event)!==false);if(!this._mouseStarted){event.preventDefault();return true}}if(true===$.data(event.target,this.widgetName+'.preventClickEvent')){$.removeData(event.target,this.widgetName+'.preventClickEvent')}this._mouseMoveDelegate=function(event){return self._mouseMove(event)};this._mouseUpDelegate=function(event){return self._mouseUp(event)};$(document).bind('mousemove.'+this.widgetName,this._mouseMoveDelegate).bind('mouseup.'+this.widgetName,this._mouseUpDelegate);event.preventDefault();mouseHandled=true;return true},_mouseMove:function(event){if($.browser.msie&&!(document.documentMode>=9)&&!event.button){return this._mouseUp(event)}if(this._mouseStarted){this._mouseDrag(event);return event.preventDefault()}if(this._mouseDistanceMet(event)&&this._mouseDelayMet(event)){this._mouseStarted=(this._mouseStart(this._mouseDownEvent,event)!==false);(this._mouseStarted?this._mouseDrag(event):this._mouseUp(event))}return!this._mouseStarted},_mouseUp:function(event){$(document).unbind('mousemove.'+this.widgetName,this._mouseMoveDelegate).unbind('mouseup.'+this.widgetName,this._mouseUpDelegate);if(this._mouseStarted){this._mouseStarted=false;if(event.target==this._mouseDownEvent.target){$.data(event.target,this.widgetName+'.preventClickEvent',true)}this._mouseStop(event)}return false},_mouseDistanceMet:function(event){return(Math.max(Math.abs(this._mouseDownEvent.pageX-event.pageX),Math.abs(this._mouseDownEvent.pageY-event.pageY))>=this.options.distance)},_mouseDelayMet:function(event){return this.mouseDelayMet},_mouseStart:function(event){},_mouseDrag:function(event){},_mouseStop:function(event){},_mouseCapture:function(event){return true}})})(jQuery);(function($,undefined){var numPages=5;$.widget("ui.slider",$.ui.mouse,{widgetEventPrefix:"slide",options:{animate:false,distance:0,max:100,min:0,orientation:"horizontal",range:false,step:1,value:0,values:null},_create:function(){var self=this,o=this.options,existingHandles=this.element.find(".ui-slider-handle").addClass("ui-state-default ui-corner-all"),handle="<a class='ui-slider-handle ui-state-default ui-corner-all' href='#'></a>",handleCount=(o.values&&o.values.length)||1,handles=[];this._keySliding=false;this._mouseSliding=false;this._animateOff=true;this._handleIndex=null;this._detectOrientation();this._mouseInit();this.element.addClass("ui-slider"+" ui-slider-"+this.orientation+" ui-widget"+" ui-widget-content"+" ui-corner-all"+(o.disabled?" ui-slider-disabled ui-disabled":""));this.range=$([]);if(o.range){if(o.range===true){if(!o.values){o.values=[this._valueMin(),this._valueMin()]}if(o.values.length&&o.values.length!==2){o.values=[o.values[0],o.values[0]]}}this.range=$("<div></div>").appendTo(this.element).addClass("ui-slider-range"+" ui-widget-header"+((o.range==="min"||o.range==="max")?" ui-slider-range-"+o.range:""))}for(var i=existingHandles.length;i<handleCount;i+=1){handles.push(handle)}this.handles=existingHandles.add($(handles.join("")).appendTo(self.element));this.handle=this.handles.eq(0);this.handles.add(this.range).filter("a").click(function(event){event.preventDefault()}).hover(function(){if(!o.disabled){$(this).addClass("ui-state-hover")}},function(){$(this).removeClass("ui-state-hover")}).focus(function(){if(!o.disabled){$(".ui-slider .ui-state-focus").removeClass("ui-state-focus");$(this).addClass("ui-state-focus")}else{$(this).blur()}}).blur(function(){$(this).removeClass("ui-state-focus")});this.handles.each(function(i){$(this).data("index.ui-slider-handle",i)});this.handles.keydown(function(event){var ret=true,index=$(this).data("index.ui-slider-handle"),allowed,curVal,newVal,step;if(self.options.disabled){return}switch(event.keyCode){case $.ui.keyCode.HOME:case $.ui.keyCode.END:case $.ui.keyCode.PAGE_UP:case $.ui.keyCode.PAGE_DOWN:case $.ui.keyCode.UP:case $.ui.keyCode.RIGHT:case $.ui.keyCode.DOWN:case $.ui.keyCode.LEFT:ret=false;if(!self._keySliding){self._keySliding=true;$(this).addClass("ui-state-active");allowed=self._start(event,index);if(allowed===false){return}}break}step=self.options.step;if(self.options.values&&self.options.values.length){curVal=newVal=self.values(index)}else{curVal=newVal=self.value()}switch(event.keyCode){case $.ui.keyCode.HOME:newVal=self._valueMin();break;case $.ui.keyCode.END:newVal=self._valueMax();break;case $.ui.keyCode.PAGE_UP:newVal=self._trimAlignValue(curVal+((self._valueMax()-self._valueMin())/numPages));break;case $.ui.keyCode.PAGE_DOWN:newVal=self._trimAlignValue(curVal-((self._valueMax()-self._valueMin())/numPages));break;case $.ui.keyCode.UP:case $.ui.keyCode.RIGHT:if(curVal===self._valueMax()){return}newVal=self._trimAlignValue(curVal+step);break;case $.ui.keyCode.DOWN:case $.ui.keyCode.LEFT:if(curVal===self._valueMin()){return}newVal=self._trimAlignValue(curVal-step);break}self._slide(event,index,newVal);return ret}).keyup(function(event){var index=$(this).data("index.ui-slider-handle");if(self._keySliding){self._keySliding=false;self._stop(event,index);self._change(event,index);$(this).removeClass("ui-state-active")}});this._refreshValue();this._animateOff=false},destroy:function(){this.handles.remove();this.range.remove();this.element.removeClass("ui-slider"+" ui-slider-horizontal"+" ui-slider-vertical"+" ui-slider-disabled"+" ui-widget"+" ui-widget-content"+" ui-corner-all").removeData("slider").unbind(".slider");this._mouseDestroy();return this},_mouseCapture:function(event){var o=this.options,position,normValue,distance,closestHandle,self,index,allowed,offset,mouseOverHandle;if(o.disabled){return false}this.elementSize={width:this.element.outerWidth(),height:this.element.outerHeight()};this.elementOffset=this.element.offset();position={x:event.pageX,y:event.pageY};normValue=this._normValueFromMouse(position);distance=this._valueMax()-this._valueMin()+1;self=this;this.handles.each(function(i){var thisDistance=Math.abs(normValue-self.values(i));if(distance>thisDistance){distance=thisDistance;closestHandle=$(this);index=i}});if(o.range===true&&this.values(1)===o.min){index+=1;closestHandle=$(this.handles[index])}allowed=this._start(event,index);if(allowed===false){return false}this._mouseSliding=true;self._handleIndex=index;closestHandle.addClass("ui-state-active").focus();offset=closestHandle.offset();mouseOverHandle=!$(event.target).parents().andSelf().is(".ui-slider-handle");this._clickOffset=mouseOverHandle?{left:0,top:0}:{left:event.pageX-offset.left-(closestHandle.width()/2),top:event.pageY-offset.top-(closestHandle.height()/2)-(parseInt(closestHandle.css("borderTopWidth"),10)||0)-(parseInt(closestHandle.css("borderBottomWidth"),10)||0)+(parseInt(closestHandle.css("marginTop"),10)||0)};if(!this.handles.hasClass("ui-state-hover")){this._slide(event,index,normValue)}this._animateOff=true;return true},_mouseStart:function(event){return true},_mouseDrag:function(event){var position={x:event.pageX,y:event.pageY},normValue=this._normValueFromMouse(position);this._slide(event,this._handleIndex,normValue);return false},_mouseStop:function(event){this.handles.removeClass("ui-state-active");this._mouseSliding=false;this._stop(event,this._handleIndex);this._change(event,this._handleIndex);this._handleIndex=null;this._clickOffset=null;this._animateOff=false;return false},_detectOrientation:function(){this.orientation=(this.options.orientation==="vertical")?"vertical":"horizontal"},_normValueFromMouse:function(position){var pixelTotal,pixelMouse,percentMouse,valueTotal,valueMouse;if(this.orientation==="horizontal"){pixelTotal=this.elementSize.width;pixelMouse=position.x-this.elementOffset.left-(this._clickOffset?this._clickOffset.left:0)}else{pixelTotal=this.elementSize.height;pixelMouse=position.y-this.elementOffset.top-(this._clickOffset?this._clickOffset.top:0)}percentMouse=(pixelMouse/pixelTotal);if(percentMouse>1){percentMouse=1}if(percentMouse<0){percentMouse=0}if(this.orientation==="vertical"){percentMouse=1-percentMouse}valueTotal=this._valueMax()-this._valueMin();valueMouse=this._valueMin()+percentMouse*valueTotal;return this._trimAlignValue(valueMouse)},_start:function(event,index){var uiHash={handle:this.handles[index],value:this.value()};if(this.options.values&&this.options.values.length){uiHash.value=this.values(index);uiHash.values=this.values()}return this._trigger("start",event,uiHash)},_slide:function(event,index,newVal){var otherVal,newValues,allowed;if(this.options.values&&this.options.values.length){otherVal=this.values(index?0:1);if((this.options.values.length===2&&this.options.range===true)&&((index===0&&newVal>otherVal)||(index===1&&newVal<otherVal))){newVal=otherVal}if(newVal!==this.values(index)){newValues=this.values();newValues[index]=newVal;allowed=this._trigger("slide",event,{handle:this.handles[index],value:newVal,values:newValues});otherVal=this.values(index?0:1);if(allowed!==false){this.values(index,newVal,true)}}}else{if(newVal!==this.value()){allowed=this._trigger("slide",event,{handle:this.handles[index],value:newVal});if(allowed!==false){this.value(newVal)}}}},_stop:function(event,index){var uiHash={handle:this.handles[index],value:this.value()};if(this.options.values&&this.options.values.length){uiHash.value=this.values(index);uiHash.values=this.values()}this._trigger("stop",event,uiHash)},_change:function(event,index){if(!this._keySliding&&!this._mouseSliding){var uiHash={handle:this.handles[index],value:this.value()};if(this.options.values&&this.options.values.length){uiHash.value=this.values(index);uiHash.values=this.values()}this._trigger("change",event,uiHash)}},value:function(newValue){if(arguments.length){this.options.value=this._trimAlignValue(newValue);this._refreshValue();this._change(null,0);return}return this._value()},values:function(index,newValue){var vals,newValues,i;if(arguments.length>1){this.options.values[index]=this._trimAlignValue(newValue);this._refreshValue();this._change(null,index);return}if(arguments.length){if($.isArray(arguments[0])){vals=this.options.values;newValues=arguments[0];for(i=0;i<vals.length;i+=1){vals[i]=this._trimAlignValue(newValues[i]);this._change(null,i)}this._refreshValue()}else{if(this.options.values&&this.options.values.length){return this._values(index)}else{return this.value()}}}else{return this._values()}},_setOption:function(key,value){var i,valsLength=0;if($.isArray(this.options.values)){valsLength=this.options.values.length}$.Widget.prototype._setOption.apply(this,arguments);switch(key){case"disabled":if(value){this.handles.filter(".ui-state-focus").blur();this.handles.removeClass("ui-state-hover");this.handles.propAttr("disabled",true);this.element.addClass("ui-disabled")}else{this.handles.propAttr("disabled",false);this.element.removeClass("ui-disabled")}break;case"orientation":this._detectOrientation();this.element.removeClass("ui-slider-horizontal ui-slider-vertical").addClass("ui-slider-"+this.orientation);this._refreshValue();break;case"value":this._animateOff=true;this._refreshValue();this._change(null,0);this._animateOff=false;break;case"values":this._animateOff=true;this._refreshValue();for(i=0;i<valsLength;i+=1){this._change(null,i)}this._animateOff=false;break}},_value:function(){var val=this.options.value;val=this._trimAlignValue(val);return val},_values:function(index){var val,vals,i;if(arguments.length){val=this.options.values[index];val=this._trimAlignValue(val);return val}else{vals=this.options.values.slice();for(i=0;i<vals.length;i+=1){vals[i]=this._trimAlignValue(vals[i])}return vals}},_trimAlignValue:function(val){if(val<=this._valueMin()){return this._valueMin()}if(val>=this._valueMax()){return this._valueMax()}var step=(this.options.step>0)?this.options.step:1,valModStep=(val-this._valueMin())%step,alignValue=val-valModStep;if(Math.abs(valModStep)*2>=step){alignValue+=(valModStep>0)?step:(-step)}return parseFloat(alignValue.toFixed(5))},_valueMin:function(){return this.options.min},_valueMax:function(){return this.options.max},_refreshValue:function(){var oRange=this.options.range,o=this.options,self=this,animate=(!this._animateOff)?o.animate:false,valPercent,_set={},lastValPercent,value,valueMin,valueMax;if(this.options.values&&this.options.values.length){this.handles.each(function(i,j){valPercent=(self.values(i)-self._valueMin())/(self._valueMax()-self._valueMin())*100;_set[self.orientation==="horizontal"?"left":"bottom"]=valPercent+"%";$(this).stop(1,1)[animate?"animate":"css"](_set,o.animate);if(self.options.range===true){if(self.orientation==="horizontal"){if(i===0){self.range.stop(1,1)[animate?"animate":"css"]({left:valPercent+"%"},o.animate)}if(i===1){self.range[animate?"animate":"css"]({width:(valPercent-lastValPercent)+"%"},{queue:false,duration:o.animate})}}else{if(i===0){self.range.stop(1,1)[animate?"animate":"css"]({bottom:(valPercent)+"%"},o.animate)}if(i===1){self.range[animate?"animate":"css"]({height:(valPercent-lastValPercent)+"%"},{queue:false,duration:o.animate})}}}lastValPercent=valPercent})}else{value=this.value();valueMin=this._valueMin();valueMax=this._valueMax();valPercent=(valueMax!==valueMin)?(value-valueMin)/(valueMax-valueMin)*100:0;_set[self.orientation==="horizontal"?"left":"bottom"]=valPercent+"%";this.handle.stop(1,1)[animate?"animate":"css"](_set,o.animate);if(oRange==="min"&&this.orientation==="horizontal"){this.range.stop(1,1)[animate?"animate":"css"]({width:valPercent+"%"},o.animate)}if(oRange==="max"&&this.orientation==="horizontal"){this.range[animate?"animate":"css"]({width:(100-valPercent)+"%"},{queue:false,duration:o.animate})}if(oRange==="min"&&this.orientation==="vertical"){this.range.stop(1,1)[animate?"animate":"css"]({height:valPercent+"%"},o.animate)}if(oRange==="max"&&this.orientation==="vertical"){this.range[animate?"animate":"css"]({height:(100-valPercent)+"%"},{queue:false,duration:o.animate})}}}});$.extend($.ui.slider,{version:"1.8.16"})}(jQuery));

// jQuery TinyScrollbar
(function($){$.tiny=$.tiny||{};$.tiny.scrollbar={options:{axis:'y',wheel:40,scroll:true,size:'auto',sizethumb:'auto'}};$.fn.tinyscrollbar=function(options){var options=$.extend({},$.tiny.scrollbar.options,options);this.each(function(){$(this).data('tsb',new Scrollbar($(this),options));});return this;};$.fn.tinyscrollbar_update=function(sScroll){return $(this).data('tsb').update(sScroll);};function Scrollbar(root,options){var oSelf=this;var oWrapper=root;var oViewport={obj:$('.viewport',root)};var oContent={obj:$('.overview',root)};var oScrollbar={obj:$('.scrollbar',root)};var oTrack={obj:$('.track',oScrollbar.obj)};var oThumb={obj:$('.thumb',oScrollbar.obj)};var sAxis=options.axis=='x',sDirection=sAxis?'left':'top',sSize=sAxis?'Width':'Height';var iScroll,iPosition={start:0,now:0},iMouse={};function initialize(){oSelf.update();setEvents();return oSelf;}
this.update=function(sScroll){oViewport[options.axis]=oViewport.obj[0]['offset'+sSize];oContent[options.axis]=oContent.obj[0]['scroll'+sSize];oContent.ratio=oViewport[options.axis]/oContent[options.axis];oScrollbar.obj.toggleClass('disable',oContent.ratio>=1);oTrack[options.axis]=options.size=='auto'?oViewport[options.axis]:options.size;oThumb[options.axis]=Math.min(oTrack[options.axis],Math.max(0,(options.sizethumb=='auto'?(oTrack[options.axis]*oContent.ratio):options.sizethumb)));oScrollbar.ratio=options.sizethumb=='auto'?(oContent[options.axis]/oTrack[options.axis]):(oContent[options.axis]-oViewport[options.axis])/(oTrack[options.axis]-oThumb[options.axis]);iScroll=(sScroll=='relative'&&oContent.ratio<=1)?Math.min((oContent[options.axis]-oViewport[options.axis]),Math.max(0,iScroll)):0;iScroll=(sScroll=='bottom'&&oContent.ratio<=1)?(oContent[options.axis]-oViewport[options.axis]):isNaN(parseInt(sScroll))?iScroll:parseInt(sScroll);setSize();};function setSize(){oThumb.obj.css(sDirection,iScroll/oScrollbar.ratio);oContent.obj.css(sDirection,-iScroll);iMouse['start']=oThumb.obj.offset()[sDirection];var sCssSize=sSize.toLowerCase();oScrollbar.obj.css(sCssSize,oTrack[options.axis]);oTrack.obj.css(sCssSize,oTrack[options.axis]);oThumb.obj.css(sCssSize,oThumb[options.axis]);};function setEvents(){oThumb.obj.bind('mousedown',start);oThumb.obj[0].ontouchstart=function(oEvent){oEvent.preventDefault();oThumb.obj.unbind('mousedown');start(oEvent.touches[0]);return false;};oTrack.obj.bind('mouseup',drag);if(options.scroll&&this.addEventListener){oWrapper[0].addEventListener('DOMMouseScroll',wheel,false);oWrapper[0].addEventListener('mousewheel',wheel,false);}
else if(options.scroll){oWrapper[0].onmousewheel=wheel;}};function start(oEvent){iMouse.start=sAxis?oEvent.pageX:oEvent.pageY;var oThumbDir=parseInt(oThumb.obj.css(sDirection));iPosition.start=oThumbDir=='auto'?0:oThumbDir;$(document).bind('mousemove',drag);document.ontouchmove=function(oEvent){$(document).unbind('mousemove');drag(oEvent.touches[0]);};$(document).bind('mouseup',end);oThumb.obj.bind('mouseup',end);oThumb.obj[0].ontouchend=document.ontouchend=function(oEvent){$(document).unbind('mouseup');oThumb.obj.unbind('mouseup');end(oEvent.touches[0]);};return false;};function wheel(oEvent){if(!(oContent.ratio>=1)){oEvent=$.event.fix(oEvent||window.event);var iDelta=oEvent.wheelDelta?oEvent.wheelDelta/120:-oEvent.detail/3;iScroll-=iDelta*options.wheel;iScroll=Math.min((oContent[options.axis]-oViewport[options.axis]),Math.max(0,iScroll));oThumb.obj.css(sDirection,iScroll/oScrollbar.ratio);oContent.obj.css(sDirection,-iScroll);oEvent.preventDefault();};};function end(oEvent){$(document).unbind('mousemove',drag);$(document).unbind('mouseup',end);oThumb.obj.unbind('mouseup',end);document.ontouchmove=oThumb.obj[0].ontouchend=document.ontouchend=null;return false;};function drag(oEvent){if(!(oContent.ratio>=1)){iPosition.now=Math.min((oTrack[options.axis]-oThumb[options.axis]),Math.max(0,(iPosition.start+((sAxis?oEvent.pageX:oEvent.pageY)-iMouse.start))));iScroll=iPosition.now*oScrollbar.ratio;oContent.obj.css(sDirection,-iScroll);oThumb.obj.css(sDirection,iPosition.now);;}
return false;};return initialize();};})(jQuery);

// Mustache JS
var Mustache=function(){var regexCache={};var Renderer=function(){};Renderer.prototype={otag:"{{",ctag:"}}",pragmas:{},buffer:[],pragmas_implemented:{"IMPLICIT-ITERATOR":true},context:{},render:function(template,context,partials,in_recursion){if(!in_recursion){this.context=context;this.buffer=[]}if(!this.includes("",template)){if(in_recursion){return template}else{this.send(template);return}}template=this.render_pragmas(template);var html=this.render_section(template,context,partials);if(html===false){html=this.render_tags(template,context,partials,in_recursion)}if(in_recursion){return html}else{this.sendLines(html)}},send:function(line){if(line!==""){this.buffer.push(line)}},sendLines:function(text){if(text){var lines=text.split("\n");for(var i=0;i<lines.length;i++){this.send(lines[i])}}},render_pragmas:function(template){if(!this.includes("%",template)){return template}var that=this;var regex=this.getCachedRegex("render_pragmas",function(otag,ctag){return new RegExp(otag+"%([\\w-]+) ?([\\w]+=[\\w]+)?"+ctag,"g")});return template.replace(regex,function(match,pragma,options){if(!that.pragmas_implemented[pragma]){throw({message:"This implementation of mustache doesn't understand the '"+pragma+"' pragma"})}that.pragmas[pragma]={};if(options){var opts=options.split("=");that.pragmas[pragma][opts[0]]=opts[1]}return""})},render_partial:function(name,context,partials){name=this.trim(name);if(!partials||partials[name]===undefined){throw({message:"unknown_partial '"+name+"'"})}if(typeof(context[name])!="object"){return this.render(partials[name],context,partials,true)}return this.render(partials[name],context[name],partials,true)},render_section:function(template,context,partials){if(!this.includes("#",template)&&!this.includes("^",template)){return false}var that=this;var regex=this.getCachedRegex("render_section",function(otag,ctag){return new RegExp("^([\\s\\S]*?)"+otag+"(\\^|\\#)\\s*(.+)\\s*"+ctag+"\n*([\\s\\S]*?)"+otag+"\\/\\s*\\3\\s*"+ctag+"\\s*([\\s\\S]*)$","g")});return template.replace(regex,function(match,before,type,name,content,after){var renderedBefore=before?that.render_tags(before,context,partials,true):"",renderedAfter=after?that.render(after,context,partials,true):"",renderedContent,value=that.find(name,context);if(type==="^"){if(!value||that.is_array(value)&&value.length===0){renderedContent=that.render(content,context,partials,true)}else{renderedContent=""}}else if(type==="#"){if(that.is_array(value)){renderedContent=that.map(value,function(row){return that.render(content,that.create_context(row),partials,true)}).join("")}else if(that.is_object(value)){renderedContent=that.render(content,that.create_context(value),partials,true)}else if(typeof value==="function"){renderedContent=value.call(context,content,function(text){return that.render(text,context,partials,true)})}else if(value){renderedContent=that.render(content,context,partials,true)}else{renderedContent=""}}return renderedBefore+renderedContent+renderedAfter})},render_tags:function(template,context,partials,in_recursion){var that=this;var new_regex=function(){return that.getCachedRegex("render_tags",function(otag,ctag){return new RegExp(otag+"(=|!|>|\\{|%)?([^\\/#\\^]+?)\\1?"+ctag+"+","g")})};var regex=new_regex();var tag_replace_callback=function(match,operator,name){switch(operator){case"!":return"";case"=":that.set_delimiters(name);regex=new_regex();return"";case">":return that.render_partial(name,context,partials);case"{":return that.find(name,context);default:return that.escape(that.find(name,context))}};var lines=template.split("\n");for(var i=0;i<lines.length;i++){lines[i]=lines[i].replace(regex,tag_replace_callback,this);if(!in_recursion){this.send(lines[i])}}if(in_recursion){return lines.join("\n")}},set_delimiters:function(delimiters){var dels=delimiters.split(" ");this.otag=this.escape_regex(dels[0]);this.ctag=this.escape_regex(dels[1])},escape_regex:function(text){if(!arguments.callee.sRE){var specials=['/','.','*','+','?','|','(',')','[',']','{','}','\\'];arguments.callee.sRE=new RegExp('(\\'+specials.join('|\\')+')','g')}return text.replace(arguments.callee.sRE,'\\$1')},find:function(name,context){name=this.trim(name);function is_kinda_truthy(bool){return bool===false||bool===0||bool}var value;if(is_kinda_truthy(context[name])){value=context[name]}else if(is_kinda_truthy(this.context[name])){value=this.context[name]}if(typeof value==="function"){return value.apply(context)}if(value!==undefined){return value}return""},includes:function(needle,haystack){return haystack.indexOf(this.otag+needle)!=-1},escape:function(s){s=String(s===null?"":s);return s.replace(/&(?!\w+;)|["'<>\\]/g,function(s){switch(s){case"&":return"&amp;";case'"':return'&quot;';case"'":return'&#39;';case"<":return"&lt;";case">":return"&gt;";default:return s}})},create_context:function(_context){if(this.is_object(_context)){return _context}else{var iterator=".";if(this.pragmas["IMPLICIT-ITERATOR"]){iterator=this.pragmas["IMPLICIT-ITERATOR"].iterator}var ctx={};ctx[iterator]=_context;return ctx}},is_object:function(a){return a&&typeof a=="object"},is_array:function(a){return Object.prototype.toString.call(a)==='[object Array]'},trim:function(s){return s.replace(/^\s*|\s*$/g,"")},map:function(array,fn){if(typeof array.map=="function"){return array.map(fn)}else{var r=[];var l=array.length;for(var i=0;i<l;i++){r.push(fn(array[i]))}return r}},getCachedRegex:function(name,generator){var byOtag=regexCache[this.otag];if(!byOtag){byOtag=regexCache[this.otag]={}}var byCtag=byOtag[this.ctag];if(!byCtag){byCtag=byOtag[this.ctag]={}}var regex=byCtag[name];if(!regex){regex=byCtag[name]=generator(this.otag,this.ctag)}return regex}};return({name:"mustache.js",version:"0.4.0-dev",to_html:function(template,view,partials,send_fun){var renderer=new Renderer();if(send_fun){renderer.send=send_fun}renderer.render(template,view||{},partials);if(!send_fun){return renderer.buffer.join("\n")}}})}();


/**
* jQuery.UI.iPad plugin
* Copyright (c) 2010 Stephen von Takach
* licensed under MIT.
* Date: 27/8/2010
*
* Project Home: 
* http://code.google.com/p/jquery-ui-for-ipad-and-iphone/
*/
$(document).ready(function(){
	if (!$('.slider-wrapper').find('.slider-range')[0]){ return false; }
$(function(){$.extend($.support,{touch:"ontouchend"in document});if($.support.touch){document.addEventListener("touchstart",iPadTouchHandler,false);document.addEventListener("touchmove",iPadTouchHandler,false);document.addEventListener("touchend",iPadTouchHandler,false);document.addEventListener("touchcancel",iPadTouchHandler,false)}});var lastTap=null;var tapValid=false;var tapTimeout=null;function cancelTap(){tapValid=false}var rightClickPending=false;var rightClickEvent=null;var holdTimeout=null;var cancelMouseUp=false;function cancelHold(){if(rightClickPending){window.clearTimeout(holdTimeout);rightClickPending=false;rightClickEvent=null}}function startHold(event){if(rightClickPending)return;rightClickPending=true;rightClickEvent=(event.changedTouches)[0];holdTimeout=window.setTimeout("doRightClick();",800)}function doRightClick(){rightClickPending=false;var first=rightClickEvent,simulatedEvent=document.createEvent("MouseEvent");simulatedEvent.initMouseEvent("mouseup",true,true,window,1,first.screenX,first.screenY,first.clientX,first.clientY,false,false,false,false,0,null);first.target.dispatchEvent(simulatedEvent);simulatedEvent=document.createEvent("MouseEvent");simulatedEvent.initMouseEvent("mousedown",true,true,window,1,first.screenX,first.screenY,first.clientX,first.clientY,false,false,false,false,2,null);first.target.dispatchEvent(simulatedEvent);simulatedEvent=document.createEvent("MouseEvent");simulatedEvent.initMouseEvent("contextmenu",true,true,window,1,first.screenX+50,first.screenY+5,first.clientX+50,first.clientY+5,false,false,false,false,2,null);first.target.dispatchEvent(simulatedEvent);cancelMouseUp=true;rightClickEvent=null}function iPadTouchStart(event){var touches=event.changedTouches,first=touches[0],type="mouseover",simulatedEvent=document.createEvent("MouseEvent");simulatedEvent.initMouseEvent(type,true,true,window,1,first.screenX,first.screenY,first.clientX,first.clientY,false,false,false,false,0,null);first.target.dispatchEvent(simulatedEvent);type="mousedown";simulatedEvent=document.createEvent("MouseEvent");simulatedEvent.initMouseEvent(type,true,true,window,1,first.screenX,first.screenY,first.clientX,first.clientY,false,false,false,false,0,null);first.target.dispatchEvent(simulatedEvent);if(!tapValid){lastTap=first.target;tapValid=true;tapTimeout=window.setTimeout("cancelTap();",600);startHold(event)}else{window.clearTimeout(tapTimeout);if(first.target==lastTap){lastTap=null;tapValid=false;type="click";simulatedEvent=document.createEvent("MouseEvent");simulatedEvent.initMouseEvent(type,true,true,window,1,first.screenX,first.screenY,first.clientX,first.clientY,false,false,false,false,0,null);first.target.dispatchEvent(simulatedEvent);type="dblclick";simulatedEvent=document.createEvent("MouseEvent");simulatedEvent.initMouseEvent(type,true,true,window,1,first.screenX,first.screenY,first.clientX,first.clientY,false,false,false,false,0,null);first.target.dispatchEvent(simulatedEvent)}else{lastTap=first.target;tapValid=true;tapTimeout=window.setTimeout("cancelTap();",600);startHold(event)}}}function iPadTouchHandler(event){var type="",button=0;if(event.touches.length>1)return;switch(event.type){case"touchstart":if($(event.changedTouches[0].target).is("select")){return}iPadTouchStart(event);return false;break;case"touchmove":cancelHold();type="mousemove";break;case"touchend":if(cancelMouseUp){cancelMouseUp=false;return false}cancelHold();type="mouseup";break;default:return}var touches=event.changedTouches,first=touches[0],simulatedEvent=document.createEvent("MouseEvent");simulatedEvent.initMouseEvent(type,true,true,window,1,first.screenX,first.screenY,first.clientX,first.clientY,false,false,false,false,button,null);first.target.dispatchEvent(simulatedEvent);if(type=="mouseup"&&tapValid&&first.target==lastTap){simulatedEvent=document.createEvent("MouseEvent");simulatedEvent.initMouseEvent("click",true,true,window,1,first.screenX,first.screenY,first.clientX,first.clientY,false,false,false,false,button,null);first.target.dispatchEvent(simulatedEvent)}}

});
})(jQuery);

(function($){
	$.fn.swipe = function(options){
		if (!this) return false;
		
		var defaults = {					
			fingers 		: 1,
			threshold 		: 75,
			swipe 			: null,
			swipeLeft		: null,
			swipeRight		: null,
			swipeUp			: null,
			swipeDown		: null,
			swipeStatus		: null,
			click			: null,
			triggerOnTouchEnd : true,
			allowPageScroll : "auto"
		};		
		
		var LEFT = "left";
		var RIGHT = "right";
		var UP = "up";
		var DOWN = "down";
		var NONE = "none";
		var HORIZONTAL = "horizontal";
		var VERTICAL = "vertical";
		var AUTO = "auto";
		
		var PHASE_START="start";
		var PHASE_MOVE="move";
		var PHASE_END="end";
		var PHASE_CANCEL="cancel";
		
	    var hasTouch = 'ontouchstart' in window,
        START_EV = hasTouch ? 'touchstart' : 'mousedown',
        MOVE_EV = hasTouch ? 'touchmove' : 'mousemove',
        END_EV = hasTouch ? 'touchend' : 'mouseup',
        CANCEL_EV = 'touchcancel';
		
		var phase="start";
		
		if (options.allowPageScroll==undefined && (options.swipe!=undefined || options.swipeStatus!=undefined))
			options.allowPageScroll=NONE;
		
		if (options)
			$.extend(defaults, options);
		
		return this.each(function(){
            var that = this;
			var $this = $(this);
			
			var triggerElementID = null;
			var fingerCount = 0;
			
			var start={x:0, y:0};
			var end={x:0, y:0};
			var delta={x:0, y:0};
			
			function touchStart(event){
                var evt = hasTouch ? event.touches[0] : event; 
				phase = PHASE_START;
		
                if (hasTouch) {
                    fingerCount = event.touches.length;
                }

				distance=0;
				direction=null;
				
				if (fingerCount == defaults.fingers || !hasTouch) {
					start.x = end.x = evt.pageX;
					start.y = end.y = evt.pageY;
					
					if (defaults.swipeStatus)
						triggerHandler(event, phase);
				} 
				else {
					touchCancel(event);
				}

				that.addEventListener(MOVE_EV, touchMove, false);
				that.addEventListener(END_EV, touchEnd, false);
			}

			function touchMove(event) {
				if (phase == PHASE_END || phase == PHASE_CANCEL)
					return;
                
                var evt = hasTouch ? event.touches[0] : event; 
				
				end.x = evt.pageX;
				end.y = evt.pageY;
					
				direction = caluculateDirection();
                if (hasTouch) {
                    fingerCount = event.touches.length;
                }
				
				phase = PHASE_MOVE
				
				validateDefaultEvent(event, direction);
		
				if ( fingerCount == defaults.fingers || !hasTouch) 
				{
					distance = caluculateDistance();
					
					if (defaults.swipeStatus)
						triggerHandler(event, phase, direction, distance);
					
					if (!defaults.triggerOnTouchEnd){
						if ( distance >= defaults.threshold ) {
							phase = PHASE_END;
							triggerHandler(event, phase);
							touchCancel(event);
						}
					}
				} 
				else {
					phase = PHASE_CANCEL;
					triggerHandler(event, phase); 
					touchCancel(event);
				}
			}
			
			function touchEnd(event) {
				event.preventDefault();
				
				distance = caluculateDistance();
				direction = caluculateDirection();
						
				if (defaults.triggerOnTouchEnd)
				{
					phase = PHASE_END;
					if ( (fingerCount == defaults.fingers  || !hasTouch) && end.x != 0 ) {
						if ( distance >= defaults.threshold ) {
							triggerHandler(event, phase);
							touchCancel(event);
						} 
						else {
							phase = PHASE_CANCEL;
							triggerHandler(event, phase); 
							touchCancel(event);
						}	
					} 
					else {
						phase = PHASE_CANCEL;
						triggerHandler(event, phase); 
						touchCancel(event);
					}
				}
				else if (phase == PHASE_MOVE){
					phase = PHASE_CANCEL;
					triggerHandler(event, phase); 
					touchCancel(event);
				}
				that.removeEventListener(MOVE_EV, touchMove, false);
				that.removeEventListener(END_EV, touchEnd, false);
			}
			
			function touchCancel(event) {
				fingerCount = 0;
				
				start.x = 0;
				start.y = 0;
				end.x = 0;
				end.y = 0;
				delta.x = 0;
				delta.y = 0;
			}
			
			function triggerHandler(event, phase) {
				//update status
				if (defaults.swipeStatus)
					defaults.swipeStatus.call($this,event, phase, direction || null, distance || 0);
				
				
				if (phase == PHASE_CANCEL){
					if (defaults.click && (fingerCount==1 || !hasTouch) && (isNaN(distance) || distance==0))
						defaults.click.call($this,event, event.target);
				}
				
				if (phase == PHASE_END){
					if (defaults.swipe){
						defaults.swipe.call($this,event, direction, distance);
					}
					switch(direction){
						case LEFT :
							if (defaults.swipeLeft)
								defaults.swipeLeft.call($this,event, direction, distance);
							break;
						
						case RIGHT :
							if (defaults.swipeRight)
								defaults.swipeRight.call($this,event, direction, distance);
							break;

						case UP :
							if (defaults.swipeUp)
								defaults.swipeUp.call($this,event, direction, distance);
							break;
						
						case DOWN :	
							if (defaults.swipeDown)
								defaults.swipeDown.call($this,event, direction, distance);
							break;
					}
				}
			}
			
			function validateDefaultEvent(event, direction){
				if( defaults.allowPageScroll==NONE ){
					event.preventDefault();
				}
				else {
					var auto=defaults.allowPageScroll==AUTO;
					
					switch(direction){
						case LEFT :
							if ( (defaults.swipeLeft && auto) || (!auto && defaults.allowPageScroll!=HORIZONTAL))
								event.preventDefault();
							break;
						
						case RIGHT :
							if ( (defaults.swipeRight && auto) || (!auto && defaults.allowPageScroll!=HORIZONTAL))
								event.preventDefault();
							break;

						case UP :
							if ( (defaults.swipeUp && auto) || (!auto && defaults.allowPageScroll!=VERTICAL))
								event.preventDefault();
							break;
						
						case DOWN :	
							if ( (defaults.swipeDown && auto) || (!auto && defaults.allowPageScroll!=VERTICAL))
								event.preventDefault();
							break;
					}
				}
			}
			
			function caluculateDistance(){
				return Math.round(Math.sqrt(Math.pow(end.x - start.x,2) + Math.pow(end.y - start.y,2)));
			}
			
			function caluculateAngle() {
				var X = start.x-end.x;
				var Y = end.y-start.y;
				var r = Math.atan2(Y,X); //radians
				var angle = Math.round(r*180/Math.PI); //degrees
				
				//ensure value is positive
				if (angle < 0) 
					angle = 360 - Math.abs(angle);
					
				return angle;
			}
			
			function caluculateDirection() {
				var angle = caluculateAngle();
				
				if ( (angle <= 45) && (angle >= 0) ) 
					return LEFT;
				
				else if ( (angle <= 360) && (angle >= 315) )
					return LEFT;
				
				else if ( (angle >= 135) && (angle <= 225) )
					return RIGHT;
				
				else if ( (angle > 45) && (angle < 135) )
					return DOWN;
				
				else
					return UP;
			}

			try {
				this.addEventListener(START_EV, touchStart, false);
				this.addEventListener(CANCEL_EV, touchCancel);
			} catch(e) {
				//touch not supported
			}
				
		});
	};
})(jQuery);




/* Copyright 2011, Ben Lin (http://dreamerslab.com/)
* Licensed under the MIT License (LICENSE.txt).
*
* Version: 1.0.5
*
* Requires: jQuery 1.2.3+
*/
;(function(a){a.fn.extend({actual:function(b,k){var c,d,h,g,f,j,e,i;if(!this[b]){throw'$.actual => The jQuery method "'+b+'" you called does not exist';}h=a.extend({absolute:false,clone:false,includeMargin:undefined},k);d=this;if(h.clone===true){e=function(){d=d.filter(":first").clone().css({position:"absolute",top:-1000}).appendTo("body");};i=function(){d.remove();};}else{e=function(){c=d.parents().andSelf().filter(":hidden");g=h.absolute===true?{position:"absolute",visibility:"hidden",display:"block"}:{visibility:"hidden",display:"block"};f=[];c.each(function(){var m={},l;for(l in g){m[l]=this.style[l];this.style[l]=g[l];}f.push(m);});};i=function(){c.each(function(m){var n=f[m],l;for(l in g){this.style[l]=n[l];}});};}e();j=d[b](h.includeMargin);i();return j;}});})(jQuery);;
/*	SWFObject v2.2 <http://code.google.com/p/swfobject/> 
	is released under the MIT License <http://www.opensource.org/licenses/mit-license.php> 
*/
var swfobject=function(){var D="undefined",r="object",S="Shockwave Flash",W="ShockwaveFlash.ShockwaveFlash",q="application/x-shockwave-flash",R="SWFObjectExprInst",x="onreadystatechange",O=window,j=document,t=navigator,T=false,U=[h],o=[],N=[],I=[],l,Q,E,B,J=false,a=false,n,G,m=true,M=function(){var aa=typeof j.getElementById!=D&&typeof j.getElementsByTagName!=D&&typeof j.createElement!=D,ah=t.userAgent.toLowerCase(),Y=t.platform.toLowerCase(),ae=Y?/win/.test(Y):/win/.test(ah),ac=Y?/mac/.test(Y):/mac/.test(ah),af=/webkit/.test(ah)?parseFloat(ah.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,X=!+"\v1",ag=[0,0,0],ab=null;if(typeof t.plugins!=D&&typeof t.plugins[S]==r){ab=t.plugins[S].description;if(ab&&!(typeof t.mimeTypes!=D&&t.mimeTypes[q]&&!t.mimeTypes[q].enabledPlugin)){T=true;X=false;ab=ab.replace(/^.*\s+(\S+\s+\S+$)/,"$1");ag[0]=parseInt(ab.replace(/^(.*)\..*$/,"$1"),10);ag[1]=parseInt(ab.replace(/^.*\.(.*)\s.*$/,"$1"),10);ag[2]=/[a-zA-Z]/.test(ab)?parseInt(ab.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0}}else{if(typeof O.ActiveXObject!=D){try{var ad=new ActiveXObject(W);if(ad){ab=ad.GetVariable("$version");if(ab){X=true;ab=ab.split(" ")[1].split(",");ag=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}}catch(Z){}}}return{w3:aa,pv:ag,wk:af,ie:X,win:ae,mac:ac}}(),k=function(){if(!M.w3){return}if((typeof j.readyState!=D&&j.readyState=="complete")||(typeof j.readyState==D&&(j.getElementsByTagName("body")[0]||j.body))){f()}if(!J){if(typeof j.addEventListener!=D){j.addEventListener("DOMContentLoaded",f,false)}if(M.ie&&M.win){j.attachEvent(x,function(){if(j.readyState=="complete"){j.detachEvent(x,arguments.callee);f()}});if(O==top){(function(){if(J){return}try{j.documentElement.doScroll("left")}catch(X){setTimeout(arguments.callee,0);return}f()})()}}if(M.wk){(function(){if(J){return}if(!/loaded|complete/.test(j.readyState)){setTimeout(arguments.callee,0);return}f()})()}s(f)}}();function f(){if(J){return}try{var Z=j.getElementsByTagName("body")[0].appendChild(C("span"));Z.parentNode.removeChild(Z)}catch(aa){return}J=true;var X=U.length;for(var Y=0;Y<X;Y++){U[Y]()}}function K(X){if(J){X()}else{U[U.length]=X}}function s(Y){if(typeof O.addEventListener!=D){O.addEventListener("load",Y,false)}else{if(typeof j.addEventListener!=D){j.addEventListener("load",Y,false)}else{if(typeof O.attachEvent!=D){i(O,"onload",Y)}else{if(typeof O.onload=="function"){var X=O.onload;O.onload=function(){X();Y()}}else{O.onload=Y}}}}}function h(){if(T){V()}else{H()}}function V(){var X=j.getElementsByTagName("body")[0];var aa=C(r);aa.setAttribute("type",q);var Z=X.appendChild(aa);if(Z){var Y=0;(function(){if(typeof Z.GetVariable!=D){var ab=Z.GetVariable("$version");if(ab){ab=ab.split(" ")[1].split(",");M.pv=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}else{if(Y<10){Y++;setTimeout(arguments.callee,10);return}}X.removeChild(aa);Z=null;H()})()}else{H()}}function H(){var ag=o.length;if(ag>0){for(var af=0;af<ag;af++){var Y=o[af].id;var ab=o[af].callbackFn;var aa={success:false,id:Y};if(M.pv[0]>0){var ae=c(Y);if(ae){if(F(o[af].swfVersion)&&!(M.wk&&M.wk<312)){w(Y,true);if(ab){aa.success=true;aa.ref=z(Y);ab(aa)}}else{if(o[af].expressInstall&&A()){var ai={};ai.data=o[af].expressInstall;ai.width=ae.getAttribute("width")||"0";ai.height=ae.getAttribute("height")||"0";if(ae.getAttribute("class")){ai.styleclass=ae.getAttribute("class")}if(ae.getAttribute("align")){ai.align=ae.getAttribute("align")}var ah={};var X=ae.getElementsByTagName("param");var ac=X.length;for(var ad=0;ad<ac;ad++){if(X[ad].getAttribute("name").toLowerCase()!="movie"){ah[X[ad].getAttribute("name")]=X[ad].getAttribute("value")}}P(ai,ah,Y,ab)}else{p(ae);if(ab){ab(aa)}}}}}else{w(Y,true);if(ab){var Z=z(Y);if(Z&&typeof Z.SetVariable!=D){aa.success=true;aa.ref=Z}ab(aa)}}}}}function z(aa){var X=null;var Y=c(aa);if(Y&&Y.nodeName=="OBJECT"){if(typeof Y.SetVariable!=D){X=Y}else{var Z=Y.getElementsByTagName(r)[0];if(Z){X=Z}}}return X}function A(){return !a&&F("6.0.65")&&(M.win||M.mac)&&!(M.wk&&M.wk<312)}function P(aa,ab,X,Z){a=true;E=Z||null;B={success:false,id:X};var ae=c(X);if(ae){if(ae.nodeName=="OBJECT"){l=g(ae);Q=null}else{l=ae;Q=X}aa.id=R;if(typeof aa.width==D||(!/%$/.test(aa.width)&&parseInt(aa.width,10)<310)){aa.width="310"}if(typeof aa.height==D||(!/%$/.test(aa.height)&&parseInt(aa.height,10)<137)){aa.height="137"}j.title=j.title.slice(0,47)+" - Flash Player Installation";var ad=M.ie&&M.win?"ActiveX":"PlugIn",ac="MMredirectURL="+O.location.toString().replace(/&/g,"%26")+"&MMplayerType="+ad+"&MMdoctitle="+j.title;if(typeof ab.flashvars!=D){ab.flashvars+="&"+ac}else{ab.flashvars=ac}if(M.ie&&M.win&&ae.readyState!=4){var Y=C("div");X+="SWFObjectNew";Y.setAttribute("id",X);ae.parentNode.insertBefore(Y,ae);ae.style.display="none";(function(){if(ae.readyState==4){ae.parentNode.removeChild(ae)}else{setTimeout(arguments.callee,10)}})()}u(aa,ab,X)}}function p(Y){if(M.ie&&M.win&&Y.readyState!=4){var X=C("div");Y.parentNode.insertBefore(X,Y);X.parentNode.replaceChild(g(Y),X);Y.style.display="none";(function(){if(Y.readyState==4){Y.parentNode.removeChild(Y)}else{setTimeout(arguments.callee,10)}})()}else{Y.parentNode.replaceChild(g(Y),Y)}}function g(ab){var aa=C("div");if(M.win&&M.ie){aa.innerHTML=ab.innerHTML}else{var Y=ab.getElementsByTagName(r)[0];if(Y){var ad=Y.childNodes;if(ad){var X=ad.length;for(var Z=0;Z<X;Z++){if(!(ad[Z].nodeType==1&&ad[Z].nodeName=="PARAM")&&!(ad[Z].nodeType==8)){aa.appendChild(ad[Z].cloneNode(true))}}}}}return aa}function u(ai,ag,Y){var X,aa=c(Y);if(M.wk&&M.wk<312){return X}if(aa){if(typeof ai.id==D){ai.id=Y}if(M.ie&&M.win){var ah="";for(var ae in ai){if(ai[ae]!=Object.prototype[ae]){if(ae.toLowerCase()=="data"){ag.movie=ai[ae]}else{if(ae.toLowerCase()=="styleclass"){ah+=' class="'+ai[ae]+'"'}else{if(ae.toLowerCase()!="classid"){ah+=" "+ae+'="'+ai[ae]+'"'}}}}}var af="";for(var ad in ag){if(ag[ad]!=Object.prototype[ad]){af+='<param name="'+ad+'" value="'+ag[ad]+'" />'}}aa.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+ah+">"+af+"</object>";N[N.length]=ai.id;X=c(ai.id)}else{var Z=C(r);Z.setAttribute("type",q);for(var ac in ai){if(ai[ac]!=Object.prototype[ac]){if(ac.toLowerCase()=="styleclass"){Z.setAttribute("class",ai[ac])}else{if(ac.toLowerCase()!="classid"){Z.setAttribute(ac,ai[ac])}}}}for(var ab in ag){if(ag[ab]!=Object.prototype[ab]&&ab.toLowerCase()!="movie"){e(Z,ab,ag[ab])}}aa.parentNode.replaceChild(Z,aa);X=Z}}return X}function e(Z,X,Y){var aa=C("param");aa.setAttribute("name",X);aa.setAttribute("value",Y);Z.appendChild(aa)}function y(Y){var X=c(Y);if(X&&X.nodeName=="OBJECT"){if(M.ie&&M.win){X.style.display="none";(function(){if(X.readyState==4){b(Y)}else{setTimeout(arguments.callee,10)}})()}else{X.parentNode.removeChild(X)}}}function b(Z){var Y=c(Z);if(Y){for(var X in Y){if(typeof Y[X]=="function"){Y[X]=null}}Y.parentNode.removeChild(Y)}}function c(Z){var X=null;try{X=j.getElementById(Z)}catch(Y){}return X}function C(X){return j.createElement(X)}function i(Z,X,Y){Z.attachEvent(X,Y);I[I.length]=[Z,X,Y]}function F(Z){var Y=M.pv,X=Z.split(".");X[0]=parseInt(X[0],10);X[1]=parseInt(X[1],10)||0;X[2]=parseInt(X[2],10)||0;return(Y[0]>X[0]||(Y[0]==X[0]&&Y[1]>X[1])||(Y[0]==X[0]&&Y[1]==X[1]&&Y[2]>=X[2]))?true:false}function v(ac,Y,ad,ab){if(M.ie&&M.mac){return}var aa=j.getElementsByTagName("head")[0];if(!aa){return}var X=(ad&&typeof ad=="string")?ad:"screen";if(ab){n=null;G=null}if(!n||G!=X){var Z=C("style");Z.setAttribute("type","text/css");Z.setAttribute("media",X);n=aa.appendChild(Z);if(M.ie&&M.win&&typeof j.styleSheets!=D&&j.styleSheets.length>0){n=j.styleSheets[j.styleSheets.length-1]}G=X}if(M.ie&&M.win){if(n&&typeof n.addRule==r){n.addRule(ac,Y)}}else{if(n&&typeof j.createTextNode!=D){n.appendChild(j.createTextNode(ac+" {"+Y+"}"))}}}function w(Z,X){if(!m){return}var Y=X?"visible":"hidden";if(J&&c(Z)){c(Z).style.visibility=Y}else{v("#"+Z,"visibility:"+Y)}}function L(Y){var Z=/[\\\"<>\.;]/;var X=Z.exec(Y)!=null;return X&&typeof encodeURIComponent!=D?encodeURIComponent(Y):Y}var d=function(){if(M.ie&&M.win){window.attachEvent("onunload",function(){var ac=I.length;for(var ab=0;ab<ac;ab++){I[ab][0].detachEvent(I[ab][1],I[ab][2])}var Z=N.length;for(var aa=0;aa<Z;aa++){y(N[aa])}for(var Y in M){M[Y]=null}M=null;for(var X in swfobject){swfobject[X]=null}swfobject=null})}}();return{registerObject:function(ab,X,aa,Z){if(M.w3&&ab&&X){var Y={};Y.id=ab;Y.swfVersion=X;Y.expressInstall=aa;Y.callbackFn=Z;o[o.length]=Y;w(ab,false)}else{if(Z){Z({success:false,id:ab})}}},getObjectById:function(X){if(M.w3){return z(X)}},embedSWF:function(ab,ah,ae,ag,Y,aa,Z,ad,af,ac){var X={success:false,id:ah};if(M.w3&&!(M.wk&&M.wk<312)&&ab&&ah&&ae&&ag&&Y){w(ah,false);K(function(){ae+="";ag+="";var aj={};if(af&&typeof af===r){for(var al in af){aj[al]=af[al]}}aj.data=ab;aj.width=ae;aj.height=ag;var am={};if(ad&&typeof ad===r){for(var ak in ad){am[ak]=ad[ak]}}if(Z&&typeof Z===r){for(var ai in Z){if(typeof am.flashvars!=D){am.flashvars+="&"+ai+"="+Z[ai]}else{am.flashvars=ai+"="+Z[ai]}}}if(F(Y)){var an=u(aj,am,ah);if(aj.id==ah){w(ah,true)}X.success=true;X.ref=an}else{if(aa&&A()){aj.data=aa;P(aj,am,ah,ac);return}else{w(ah,true)}}if(ac){ac(X)}})}else{if(ac){ac(X)}}},switchOffAutoHideShow:function(){m=false},ua:M,getFlashPlayerVersion:function(){return{major:M.pv[0],minor:M.pv[1],release:M.pv[2]}},hasFlashPlayerVersion:F,createSWF:function(Z,Y,X){if(M.w3){return u(Z,Y,X)}else{return undefined}},showExpressInstall:function(Z,aa,X,Y){if(M.w3&&A()){P(Z,aa,X,Y)}},removeSWF:function(X){if(M.w3){y(X)}},createCSS:function(aa,Z,Y,X){if(M.w3){v(aa,Z,Y,X)}},addDomLoadEvent:K,addLoadEvent:s,getQueryParamValue:function(aa){var Z=j.location.search||j.location.hash;if(Z){if(/\?/.test(Z)){Z=Z.split("?")[1]}if(aa==null){return L(Z)}var Y=Z.split("&");for(var X=0;X<Y.length;X++){if(Y[X].substring(0,Y[X].indexOf("="))==aa){return L(Y[X].substring((Y[X].indexOf("=")+1)))}}}return""},expressInstallCallback:function(){if(a){var X=c(R);if(X&&l){X.parentNode.replaceChild(l,X);if(Q){w(Q,true);if(M.ie&&M.win){l.style.display="block"}}if(E){E(B)}}a=false}}}}();;
(function ($) {

var MCD = {}, isiPad, _CLICK = 'click';

$(document).ready(function(){

	isiPad = navigator.userAgent.match(/iPad/i) != null;
	if (isiPad){ _CLICK = 'touchend'; }

	MCD.HTTP_ROOT = $(document.head).find('base')[0] ?
		$(document.head).find('base').attr('href') : document.location.href.replace(document.location.hash, '');
	//MCD.HTTP_ROOT = 'http://www.devmonks.nl/d/ddb_parijs/mcdonalds_fr/html/';

	// JER
	function gaStrCase(str) {
		str = str || '';
		// replaceAccents
		if (str.search(/[\xC0-\xFF]/g) > -1) {
            str = str
                    .replace(/[\xC0-\xC5]/g, "A")
                    .replace(/[\xC6]/g, "AE")
                    .replace(/[\xC7]/g, "C")
                    .replace(/[\xC8-\xCB]/g, "E")
                    .replace(/[\xCC-\xCF]/g, "I")
                    .replace(/[\xD0]/g, "D")
                    .replace(/[\xD1]/g, "N")
                    .replace(/[\xD2-\xD6\xD8]/g, "O")
                    .replace(/[\xD9-\xDC]/g, "U")
                    .replace(/[\xDD]/g, "Y")
                    .replace(/[\xDE]/g, "P")
                    .replace(/[\xE0-\xE5]/g, "a")
                    .replace(/[\xE6]/g, "ae")
                    .replace(/[\xE7]/g, "c")
                    .replace(/[\xE8-\xEB]/g, "e")
                    .replace(/[\xEC-\xEF]/g, "i")
                    .replace(/[\xF1]/g, "n")
                    .replace(/[\xF2-\xF6\xF8]/g, "o")
                    .replace(/[\xF9-\xFC]/g, "u")
                    .replace(/[\xFE]/g, "p")
                    .replace(/[\xFD\xFF]/g, "y");
        }

        str = str.toLowerCase().replace(/^\w|\s\w/g, function(s) { return s.toUpperCase(); }); //replace first char of each word to UPPERCASE
        // str = str.replace(/[^0-9a-zA-Z\xC0-\xFF \-]/g, ''); // removeNonWord
        // str = str.replace(/\-/g, ' ') //convert all hyphens to spaces
        // str = str.replace(/\s[a-z]/g, function(s) { return s.toUpperCase(); }) //convert first char of each word to UPPERCASE
        str = str.replace(/\s+/g, '') //remove spaces
        // str = str.replace(/^[A-Z]/g, function(s) { return s.toLowerCase(); }); //convert first char to lowercase

        return str;
	}
	window.gaPushbox = function() {
		try {
			var $li = $('header#pushbox div.nav ul.buttons li');
			$li.each(function (i, e) {
				if ($(e).hasClass('active'))
				{
					var txt = gaStrCase(decodeURIComponent($(e).find('a').attr('data-ga')));
					var pos = (i+1) + "/" + $li.size();
					// console.log(txt, pos);
					_gaq.push(['_trackEvent', 'homepageBanner_showSlide', txt, pos]);
					// _gaq.push(['_trackEvent', 'homepageBanner_showSlide', txt + "_" + pos]);
				}
			});
		} catch (e) {}
	}
	window.gaPushboxSmall = function() {
		try {
			var $li = $('header#pushbox-small div.nav ul.buttons li');
			$li.each(function (i, e) {
				if ($(e).hasClass('active'))
				{
					var txt = gaStrCase(decodeURIComponent($(e).find('a').attr('data-ga')));
					var pos = (i+1) + "/" + $li.size();
					// console.log(txt, pos);
					_gaq.push(['_trackEvent', 'actualitesCarousel_showSlide', txt, pos]);
					// _gaq.push(['_trackEvent', 'actualitesCarousel_showSlide', txt + "_" + pos]);
				}

			});
		} catch (e) {}
	}
	window.gaServices = function() {
		try {
			var $li = $('section#content.service_restaurant ul.accordion li.trigger');
			// console.log("li:", $li);
			$li.each(function (i, e) {
				var act = $(e).find('h4 a.active');
				if (act[0])
				{
					var acc = gaStrCase(decodeURIComponent($(e).find('h4 a').attr('data-ga')));
					var tab = gaStrCase(decodeURIComponent($(e).find('div.tab-wrapper ul.tabs li a.active').attr('data-ga')));
					// console.log(acc, tab);
					_gaq.push(['_trackEvent', 'restaurantServices_showService', acc, tab]);
					// _gaq.push(['_trackEvent', 'restaurantServices_showService', acc + "_" + tab]);
				}
			});
		} catch (e) {}
	}
	// END JER

	// Pushbox Homepage
	var pushbox = $('#pushbox');
	if (pushbox[0]){
		new MCD.Pushbox({
			wrapper: pushbox[0],
			slider: $('div.holder ul', pushbox),
			data: bannerJSON
		});

		// JER
		var $gaPushbox = $('header#pushbox div.nav ul.buttons li');
		$gaPushbox.click(function() {
				setTimeout(window.gaPushbox, 500);
		});
		setTimeout(window.gaPushbox, 1000);
		// END JER
	}

	// Pushbox Homepage
	var pushboxSmall = $('#pushbox-small');
	if (pushboxSmall[0]){
		new MCD.Pushbox({
			wrapper: pushboxSmall[0],
			slider: $('div.holder ul', pushboxSmall),
			data: bannerJSON,
			peekPercentage: 0,
			prevButton: $('div.nav ul.prevnext li a.prev'),
			nextButton: $('div.nav ul.prevnext li a.next'),
			type: 'small'
		});

		// JER
		setTimeout(window.gaPushboxSmall, 1000);
		// END JER
	}

	// FacebookBlock Homepage
	$(window).resize(function(){
		MCD.FacebookBlock();
	});

	// Input Placeholder Support
	new MCD.Placeholder();

	// Add Mousehover Class on Mouseenter
	MCD.addHoverClass('.block');
	//MCD.addHoverClass('header[role=banner] nav ul li', 400);
	MCD.addHoverClass('ul.accordion > li ul.stats.extended li');
	MCD.addHoverClass('#content.cal_nutri .result .bar-wrapper .bar-outside');

	MCD.mainNav('header[role=banner] nav > ul > li');

	// Accordion
	$('ul.accordion').each(function(i, wrapper){
		new MCD.Accordion({
			wrapper: $(wrapper),
			triggers: $(wrapper).find('h4 > a:first-child, h4 > span:first-child'),
			elms: $(wrapper).find('> li.trigger > div')
		});
	});

	// Text Overlayer
	new MCD.Textoverlay({ triggers: $('a.text-overlay') });

	// Video Overlayer
	new MCD.Videooverlay({ triggers: $('a.video-overlay') });

	// EN - FR Content translation
	new MCD.TranslateContent($('a.translate-content'));

	// Custom Select Boxes
	new MCD.Selectbox();

	// History Slider
	var sliderWrapper = $('.slider-wrapper').find('.slider-range');
	if (sliderWrapper[0]){
		new MCD.HistorySlider({
			wrapper: sliderWrapper,
			firstValue: $('span.firstValue'),
			secondValue: $('span.secondValue'),
			start: '1985',
			end: '2015',
			list: $('ul.result li')
		});
	}

	var filterWrapper = $('.filter');
	if (filterWrapper[0]){
		new MCD.Filter({
			wrapper: filterWrapper,
			scrollbarWrapper: $('.filter').find('.scrollbar'),
			productTemplate: $(filterWrapper).find('.template').html(),
			accordionTemplate: $(filterWrapper).find('.template-accordion').html(),
			data: filterJSON
		});
	}

	var viewer = $('#content.design');
	if (viewer[0]){
		new MCD.Photoviewer({
			wrapper: viewer[0],
			prevnextButtons: $('.pictures a.nav', viewer[0]),
			slider: $('div.holder > ul', viewer[0]),
			data: viewerJSON
		});
	}

	$('.tab-wrapper').each(function(i, wrap){
		new MCD.Tabs({
			wrapper: wrap,
			links: $('ul.tabs li a', wrap),
			content: $('.tabcontent', wrap)
		});
	});

	$('.service_restaurant .tabcontent').each(function(i, wrap){
		new MCD.ServiceAction({
			wrapper: wrap,
			links: $('.option li a', wrap)
		});
	});

	var calcWrapper = $('.cal_nutri');
	if (calcWrapper[0]){
		new MCD.NutriCalc({
			wrapper: calcWrapper,
			sliders: $('.slide-holder', calcWrapper),
			results: $('.bar-wrapper.res', calcWrapper)
		});
	}

	var sliderWrapper = $('.simple-slider');
	if (sliderWrapper[0]){
		new MCD.Slider({
			wrapper: sliderWrapper,
			slider: $('div.slider ul', sliderWrapper),
			items: $('div.slider ul li', sliderWrapper),
			prev: $('ul.nav li.prev a', sliderWrapper),
			next: $('ul.nav li.next a', sliderWrapper)
		});
	}

	new MCD.Ticker({
		items: $('ul.ticker li')
	});

	new MCD.SimpleSlider({
		wrappers: $('div.option-slider'),
		view: 6
	});

	MCD.multiLine();
	MCD.navHeight();

  //$.getScript('/sites/all/themes/macdo/js/code.pack.js'); //BAU - 20120112
});


MCD.SimpleSlider = Class.extend({
	options: {
		wrappers: null,
		view: 1
	},
	init: function(options){
		MCD.setOptions(options, this);
		if (this.options.wrappers.length < 1){ return false; }

		this.create();
	},
	create: function(){
		var self = this;
		$(this.options.wrappers).each(function(i, wrap){
			if ($(wrap).find('ul.option > li').length > 6) {
				// Create Slider wrapper
				$(wrap).wrap('<div class="option-wrapper"></div>');

				// Create Slider nav
				$(wrap).parent().append('<ul class="option-nav"><li><a href="#" class="prev">Prev</a></li><li><a href="#" class="next">Next</a></li></ul>');

				$(wrap).data('active', 0).data('total', $(wrap).find('ul.option > li').length);

				self.addEvents(wrap);
			}
		});
	},
	addEvents: function(wrap){
		var self = this;
		$(wrap).parent().find('ul.option-nav li a.prev').bind(_CLICK, function(e){
			e.preventDefault();
			self.prev(wrap);
		});
		$(wrap).parent().find('ul.option-nav li a.next').bind(_CLICK, function(e){
			e.preventDefault();
			self.next(wrap);
		});
		if (isiPad){ $(wrap).parent().find('ul.option-nav li a').click(function(e){ e.preventDefault(); }); }
	},
	prev: function(wrap){
		var active = parseInt($(wrap).data('active'));
		--active;
		if (active < 0){
			active = parseInt($(wrap).data('total')) - this.options.view;
		}
		$(wrap).data('active', active);

		this.slide(wrap);
	},
	next: function(wrap){
		var active = parseInt($(wrap).data('active'));
		++active;
		if (parseInt($(wrap).data('total')) - (active + this.options.view) < 0){
			active = 0;
		}
		$(wrap).data('active', active);

		this.slide(wrap);
	},
	slide: function(wrap){
		$(wrap).find('ul').animate({
			'marginLeft': -(parseInt($(wrap).data('active')) * this.getStepSize(wrap))
		});
	},
	getStepSize: function(wrap){
		return $(wrap).find('ul.option > li').width() + parseInt($(wrap).find('ul.option > li').css('paddingRight'))
	}
});

MCD.NutriCalc = Class.extend({
	options: {
		wrapper: null,
		sliders: null,
		results: null,
		stepSize: 190
	},
	init: function(options){
		MCD.setOptions(options, this);

		this.setData();
		var self = this;
		self.setHeight();
		setTimeout(function(){
			self.setHeight();
		}, 10);
		this.addEvents();
		this.calc();
	},
	setData: function(){
		$(this.options.sliders.parent()).each(function(i, wrap){
			$(wrap).data('active', 0).data('total', $('.slide-holder ul li', wrap).length);
		});
	},
	setHeight: function(){
		$(this.options.sliders).each(function(i, slider){
			$(slider).find('ul li div').each(function(j, div){
				$(div).css({ 'display': 'none' });
				var img = new Image;
				img.onload = function(){
					$(div).css({
						'display': 'block',
						'paddingTop': (190 - $(div).height()) / 2 - 4
					}).fadeIn(300);
					setTimeout(function(){
						$(div).find('h4').css({ 'paddingTop': (54 - $(div).find('h4').height()) / 2 })
					}, 10);
				}
				img.src = $(div).find('img').attr('src');
			});
		});
	},
	addEvents: function(){
		var self = this;
		$('li.prev a', this.options.sliders.parent()).click(function(e){
			e.preventDefault();
			self.prev($(this).closest('.col'));
		});
		$('li.next a', this.options.sliders.parent()).click(function(e){
			e.preventDefault();
			self.next($(this).closest('.col'));
		});
	},
	prev: function(wrap){
		var active = parseInt($(wrap).data('active'));
		--active;
		if (active < 0){
			active = parseInt($(wrap).data('total')) - 1;
		}
		$(wrap).data('active', active);
		this.slide(wrap);
	},
	next: function(wrap){
		var active = parseInt($(wrap).data('active')),
			total = parseInt($(wrap).data('total'));
		++active;
		if (total - active < 1){
			active = 0;
		}
		$(wrap).data('active', active);
		this.slide(wrap);
	},
	slide: function(wrap){
		$('.slide-holder ul', wrap).stop().animate({ 'marginTop': -($(wrap).data('active') * this.options.stepSize) });

		var h4 = $('div h4', wrap);
		$(h4[$(wrap).data('active')]).css({ 'paddingTop': (54 - $(h4[$(wrap).data('active')]).height()) / 2 })

		this.calc();
	},
	calc: function(){
		var self = this,
			res = { kcal: 0, prot: 0, gluc: 0, lip: 0, sel: 0 };

		$(this.options.results).each(function(i, wrap){
			res[$(wrap).attr('data-type')] += parseInt(self.get($(wrap).attr('data-type')));
		});

		this.set(res);
	},
	get: function(datatype){
		var res = 0;
		$(this.options.sliders.parent()).each(function(i, obj){
			res += parseInt($($('.slide-holder ul li', obj)[$(obj).data('active')]).attr('data-' + datatype));
		});
		return res;
	},
	set: function(res){
		$(this.options.results).each(function(i, wrap){
			var fill = $('.bar .fill', wrap),
				max = $(fill).attr('data-max');

			$(fill).stop().animate({ 'width': ((res[$(wrap).attr('data-type')] / max) * 100) + '%' });
			$('.label span', wrap).html(res[$(wrap).attr('data-type')]);
			$('.bar .percent', wrap).html(Math.round(((res[$(wrap).attr('data-type')] / max) * 100)) + '%');
		});
	}
});

MCD.Photoviewer = Class.extend({
	options: {
		wrapper: null,
		prevnextButtons: null,
		pictureSize: 0,
		mainActive: 0,
		total: 0,
		active: 0,
		activeSlider: null,
		slider: []
	},
	init: function(options){
		MCD.setOptions(options, this);

		this.create();
		this.setCategory(this.options.active);

		this.addEvents();
	},
	create: function(){
		var self = this;
		jQuery.each(this.options.data.categories, function(i, category){
			$(self.options.wrapper).find('nav dl dd ul').append('<li><a href="#" class="category" data-cat="' + i + '"><span>' + category.title + '</span><p>' + category.description + '</p></a></li>');
			$(self.options.wrapper).find('section.pictures').prepend('<div class="holder"></div>');
		});
	},
	addEvents: function(){
		var self = this;

		MCD.addHoverClass($(this.options.wrapper).find('nav dl dd'));
		MCD.addHoverClass($(this.options.wrapper).find('nav dl dd ul li a'));

		$(this.options.wrapper).find('nav dl dd > a').click(function(e){ e.preventDefault(); $(this).parent().addClass('hover'); });

		$(window).resize(function(){
			if (self.options.pictureSize != $(self.options.wrapper).width() + 9){
				self.options.pictureSize = $(self.options.wrapper).width() + 9;
				$('#content.design nav dl dd ul').height($(self.options.wrapper).height() - 42);

				var holder = $(self.options.wrapper).find('section.pictures .holder > ul')[self.options.mainActive];
				if (!isiPad){
					$(holder).css({ 'marginLeft': -(self.options.active * self.options.pictureSize) });
				}
				else {
					$(holder)[0].style.webkitTransform = 'translate3d(-' + (self.options.active * self.options.pictureSize) + 'px, 0, 0)';
				}
			}
		});
		setTimeout(function(){ $(window).trigger('resize'); }, 50);

		$('a.category', this.options.wrapper).click(function(e){
			e.preventDefault();
			self.setCategory($(this).attr('data-cat'));
			$(self.options.wrapper).find('nav dl dd').removeClass('hover');
		});

		if (!isiPad){
			$(this.options.prevnextButtons).click(function(e){
				e.preventDefault();
				if ($(this).hasClass('prev')){
					self.prev();
				}
				else if($(this).hasClass('next')){
					self.next();
				}
			}).mouseenter(function(){
				if ($(this).hasClass('prev')){
					self.peekPrev();
				}
				else if($(this).hasClass('next')){
					self.peekNext()
				}
			}).mouseleave(function(){
				self.slide();
			});
		}
		else {
			$(this.options.prevnextButtons).css('display', 'none');
			var swipeOptions = {
				swipeLeft: swipeLeft,
				swipeRight: swipeRight,
				threshold: 10
			}

			$(this.options.wrapper).swipe(swipeOptions);
			function swipeLeft(event){
				self.next();
			}
			function swipeRight(event){
				self.prev();
			}
		}
	},
	prev: function(){
		--this.options.active;
		if (this.options.active < 0){
			this.options.active = 0;
			return false;
		}
		this.to();
	},
	next: function(){
		++this.options.active;
		if (this.options.active >= this.options.total){
			this.options.active = this.options.total - 1;
			return false;
		}
		this.to();
	},
	activate: function(i){
		this.options.active = i;
		this.to();
	},
	peekPrev: function(){
		$(this.options.activeSlider).stop().animate({ 'marginLeft': -((this.options.active * this.options.pictureSize) - 200) }, 200);
	},
	peekNext: function(){
		$(this.options.activeSlider).stop().animate({ 'marginLeft': -((this.options.active * this.options.pictureSize) + 200) }, 200);
	},
	slide: function(){
		if (!isiPad){
			$(this.options.activeSlider).stop().animate({ 'marginLeft': -(this.options.active * this.options.pictureSize) });
		}
		else {
			$(this.options.activeSlider)[0].style.webkitTransform = 'translate3d(-' + (this.options.active * this.options.pictureSize) + 'px, 0, 0)';
		}
	},
	to: function(){
		this.slide();

		this.initSlide();
		this.checkButtons();
	},
	initSlide: function(){
		$(this.options.wrapper).find('section.pictures .holder ul li div p').css('display', 'none');
		var slide = $(this.options.activeSlider).find('li')[this.options.active],
			desc = $(slide).find('div p');

		$(desc).css({ 'display': 'block' });

		$(this.options.activeSlider).data('timer', setTimeout(function(){ $(desc).css({ 'display': 'none' }); }, 5000));
	},
	checkButtons: function(){
		$(this.options.navButtons).removeClass('active');
		$(this.options.navButtons[this.options.active]).addClass('active');

		if (isiPad){ return false; }

		if (this.options.active < 1){
			$(this.options.prevnextButtons[0]).fadeOut();
		}
		else {
			$(this.options.prevnextButtons[0]).fadeIn();
		}

		if (this.options.active >= this.options.total - 1){
			$(this.options.prevnextButtons[1]).fadeOut();
		}
		else {
			$(this.options.prevnextButtons[1]).fadeIn();
		}
	},
	setCategory: function(i){
		var self = this, loaded = false;
		this.options.mainActive = i;
		var holder = $(this.options.wrapper).find('section.pictures .holder')[this.options.mainActive];

		var categories = $('#content.design nav dl dd ul li');
		$('#content.design nav dl dd > a').html($(categories[i]).find('a span').html());

		if (!$(holder).find('> ul')[0]){
			$(holder).append('<ul></ul>');

			jQuery.each(this.options.data.categories[i].photos, function(i, photo){
				$('ul', holder).append('<li><img src="' + photo.image + '" alt="' + photo.title + '" /><div class="desc"><h4>' + photo.title + '</h4><p>' + photo.description + '</p></div></li>');

				var img = new Image;
				img.onload = function(){
					if (self.options.pictureSize != $(self.options.wrapper).width() + 9){
						self.options.pictureSize = $(self.options.wrapper).width() + 9;
						$('#content.design nav dl dd ul').height($(self.options.wrapper).height() - 42);

						if (!isiPad){
							$(self.options.activeSlider).stop().css({ 'marginLeft': -(self.options.active * self.options.pictureSize) });
						}
						else {
							$(self.options.activeSlider)[0].style.webkitTransform = 'translate3d(-' + (self.options.active * self.options.pictureSize) + 'px, 0, 0)';
						}
					}
					if(!loaded){
						$('#content.design nav dl dd ul').height($(self.options.wrapper).height() - 42);
						loaded = true;
					}
				}
				img.src = photo.image;
			});

			$(this.options.wrapper).find('section.pictures .holder ul li div').mouseenter(function(){
				clearInterval($(self.options.activeSlider).data('timer'));
				$(this).find('p').css({ 'display': 'block' });
			}).mouseleave(function(){
				$(this).find('p').css({ 'display': 'none' });
			});

			this.options.activeSlider = $(this.options.wrapper).find('section.pictures .holder')[this.options.mainActive];
			this.options.activeSlider = $(this.options.activeSlider).find('> ul');

			if (!isiPad){
				$(this.options.wrapper).find('section.pictures .holder > ul').css({ 'display': 'none', 'marginLeft': 0 });
				$(this.options.activeSlider).css({ 'display': 'block', 'marginLeft': 0 });
			}
			else {
				$(this.options.wrapper).find('section.pictures .holder > ul').each(function(i, wrap){
					$(wrap).css({ 'display': 'none' });
					$(wrap)[0].style.webkitTransform = 'translate3d(0, 0, 0)';
				});

				$(this.options.activeSlider).css({ 'display': 'block' });
				$(this.options.activeSlider)[0].style.webkitTransform = 'translate3d(0, 0, 0)';
			}

			this.options.active = 0;
			this.options.total = $(this.options.activeSlider).find('li').length;

			this.createNav();
			this.checkButtons();
			this.initSlide();
		}
		else {
			this.options.activeSlider = $(this.options.wrapper).find('section.pictures .holder > ul')[this.options.mainActive];

			if (!isiPad){
				$(this.options.wrapper).find('section.pictures .holder > ul').css({ 'display': 'none', 'marginLeft': 0 });
				$(this.options.activeSlider).css({ 'display': 'block', 'marginLeft': 0 });
			}
			else {
				$(this.options.wrapper).find('section.pictures .holder > ul').each(function(i, wrap){
					$(wrap).css({ 'display': 'none' });
					$(wrap)[0].style.webkitTransform = 'translate3d(0, 0, 0)';
				});

				$(this.options.activeSlider).css({ 'display': 'block' });
				$(this.options.activeSlider)[0].style.webkitTransform = 'translate3d(0, 0, 0)';
			}

			this.options.active = 0;
			this.options.total = $(this.options.activeSlider).find('li').length;

			this.createNav();
			this.checkButtons();
			this.initSlide();
		}
	},
	createNav: function(){
		var self = this;
		$('ul.numbers', this.options.wrapper).html('');
		for (var i=0; i < this.options.total; i++) {
			var elm = $('<li><a href="#">' + (i + 1) + '</a></li');
			$('ul.numbers', this.options.wrapper).append(elm);
		}

		this.options.navButtons = $('ul.numbers li a', this.options.wrapper)

		$(this.options.navButtons).click(function(e){
			e.preventDefault();
			self.activate(parseInt($(this).text()) - 1);
		})
	}
});

MCD.Filter = Class.extend({
	options: {
		wrapper: null,
		scrollbar: null,
		productTemplate: '',
		accordionTemplate: '',
		data: null,
		lang: 'fr',
		current: {},
		type: 'products'
	},
	init: function(options){
		MCD.setOptions(options, this);

		if ($(this.options.wrapper).hasClass('allergenes')){
			this.options.type = 'allergenes';
		}

		this.create();
		this.addScrollbar();
		this.reinit();
	},
	create: function(){
		var self = this;

		if (this.options.type == 'products'){
			var filterList = { category: []};
			jQuery.each(this.options.data.category, function(i, category){

				filterList.category[i] = {
					'title': category.name,
					'product': []
				}
				jQuery.each(category.products, function(j, product){
					filterList.category[i].product.push({
						'url': product.url,
						'catUrl': category.url,
						'title': product.name
					});
				});
			});
			var html = Mustache.to_html(this.options.accordionTemplate, filterList);
			$('#accordion-list').append(html);
			$('#accordion-list li ul.list').wrap('<div></div>');

			this.addEvents();
		}
		else {
			var filterList = { allergenes: []};
			jQuery.each(this.options.data.allergenes, function(i, allergene){

				filterList.allergenes[i] = {
					'title': allergene.fr,
					'title_fr': allergene.fr,
					'title_en': allergene.en,
					'url': allergene.url
				}
			});
			var html = Mustache.to_html(this.options.accordionTemplate, filterList);

			$('.col-list', this.options.wrapper).append(html);

			this.addEvents();
		}
	},
	addEvents: function(){

		var self = this;

		$('ul.accordion').each(function(i, wrapper){
			new MCD.Accordion({
				wrapper: $(wrapper),
				triggers: $(wrapper).find('h4 > a:first-child'),
				elms: $(wrapper).find('> li.trigger > div')
			});
		});

		$('.col-list input').change(function(){
			var checked = $(this).prop('checked');
			if (checked){
				self.add($(this).attr('value'), $(this).attr('id').split('-')[0]);
			}
			else {
				self.remove($(this).attr('value'));
			}
		});

		$('a.translate').bind(_CLICK, function(e){
			e.preventDefault();
			if (self.options.lang == 'en'){
				self.options.lang = 'fr';
			}
			else {
				self.options.lang = 'en';
			}
			self.translateContent(self.options.lang, $(this).attr('data-classes'));
		});
		if (isiPad){ $('a.translate').click(function(e){ e.preventDefault(); }); }

		$('a.reset', this.options.wrapper).click(function(e){
			e.preventDefault();
			$('.product-list-wrapper a.close').trigger('click');
		});

		//if (this.options.type == 'allergenes'){
			self.options.itemWidth = $('.product-list').width();
			$(window).resize(function(){
				var newWidth = $('.product-list').width();
				if (self.options.itemWidth != newWidth){
					self.options.itemWidth = newWidth;
					self.reinit();
				}
			});
		//}

		this.translateContent(this.options.lang, 'replace-text');
		var inputs = $('.col-list input');
		var key = 0;
		if (this.options.type == 'allergenes'){
			key = 1;
		}
		setTimeout(function(){
			$(inputs[key]).prop('checked', true);
			$(inputs[key]).trigger('change');
		}, 10);
	},
	find: function(curProduct, cat){
		if (this.options.type == 'products'){
			var prod;
			jQuery.each(this.options.data.category, function(i, category){
				if (cat == category.url){
					jQuery.each(category.products, function(j, product){
						if (product.url == curProduct){
							product.category = category.url;
							prod = product;
						}
					});
				}
			});
			return prod;
		}
		else {
			var cat;
			jQuery.each(this.options.data.allergenes, function(i, category){
				if (category.url == curProduct){
					cat = category;
				}
			});
			return cat;
		}
	},
	add: function(product, cat){
		var self = this;
		if (!this.options.current[product]){
			var prod = {},
				current = this.find(product, cat);

			if (this.options.type == 'products'){
				prod.url = current.url;
				prod.title = current.name;
				prod.category = current.category;
				prod.allergenes = [];

				jQuery.each(this.options.data.allergenes, function(i, allergene){
					prod.allergenes.push({
						checked: (current.allergenes[allergene.url] == '1' ? 'checked': ''),
						title_en: allergene.en,
						title_fr: allergene.fr
					});
				});

				var html = Mustache.to_html(this.options.productTemplate, prod);
				$('.product-list-wrapper', this.options.wrapper).prepend(html);

				$('#prod-' + prod.url).find('img').attr('src', current.image).css({ 'display': 'block' });
				$('#prod-' + prod.url).mouseenter(function(){
					$(this).addClass('hover');
				}).mouseleave(function(){
					$(this).removeClass('hover');
				});

				$('#prod-' + prod.url).find('a.close').click(function(e){
					e.preventDefault();
					self.remove($(this).attr('data-product'));
					$('#' + $(this).parent().attr('data-cat') + '-' + $(this).attr('data-product')).attr('checked', false);
				});

				this.options.current[product] = true;

				this.translateContent(this.options.lang, 'replace-text');
			}
			else {
				prod.title = current[this.options.lang];
				prod.title_fr = current.fr;
				prod.title_en = current.en;
				prod.url = current.url;
				prod.products = [];

				jQuery.each(current.products, function(i, product){
					prod.products.push({
						title: product.name
					});
				});

				var html = Mustache.to_html(this.options.productTemplate, prod);
				$('.product-list-wrapper', this.options.wrapper).prepend(html);

				$('#prod-' + prod.url).find('img').each(function(i, img){
					$(img).attr('src', current.products[i].image).css({ 'display': 'block' });
				});

				var h = $('#prod-' + prod.url).find('h3').height();
				$('#prod-' + prod.url).find('h3').css({
					'height': h,
					'padding': ((80 - h) / 2) + 'px 0 ' +  ((80 - h) / 2) + 'px 0'
				});
				$('#prod-' + prod.url).find('a.close').click(function(e){
					e.preventDefault();
					self.remove($(this).attr('data-product'));
					$('#inp-' + $(this).parent().attr('data-cat')).attr('checked', false);
				});
				$('#prod-' + prod.url).mouseenter(function(){
					$(this).addClass('hover');
				}).mouseleave(function(){
					$(this).removeClass('hover');
				});

				this.options.current[product] = true;
			}

			this.reinit();
		}
	},
	remove: function(product){
		if (this.options.current[product]){
			$('#prod-' + product).remove();
			delete this.options.current[product];
			this.reinit();
		}
	},
	reinit: function(){
		var self = this
		var scrollContent = $('.product-list-wrapper');
		var w = parseInt($('.product-list').css('width')) + 1,
			m = (this.options.type == 'products' ? 1 : 1);
		scrollContent.css( 'width', (scrollContent.find('.product-list').length - m) * w);

		setTimeout(function(){
			if (self.options.type == 'allergenes'){
				var h = 0;
				$('.product-list').each(function(i, wrap){
					$(wrap).css('height', 'auto');
					var newH = $(wrap).height();
					if (newH > h){
						h = newH;
					}
				});
				$('.viewport').css('height', h);
				$('.product-list').css('height', h);
			}
			$('.products-wrapper').tinyscrollbar_update();
		}, 10);
	},
	addScrollbar: function(){
		$('.products-wrapper').tinyscrollbar({axis:'x'});
	},
	translateContent: function(lang, classes){
		this.replaceContent('.' + classes, lang);

		this.options.lang = lang;
		if (lang == 'en'){
			lang = 'fr';
		}
		else {
			lang = 'en';
		}
		$('a.translate').attr('class', 'translate flag-' + lang);
	},
	replaceContent: function(elms, lang){
		var self = this;

		if (this.options.type == 'products'){
			$('.translate-wrapper').each(function(j, wrap){
				var orderElms = $(elms, wrap);
				$(orderElms).each(function(i, elm){
					$(this).html($(this).attr('data-' + lang));
				});
				self.orderContent(orderElms);
			});
		}
		else {
			$(elms).each(function(i, elm){
				$(this).html($(this).attr('data-' + lang));
			});
			self.orderContent();
		}
	},
	orderContent: function(elms){
		if (this.options.type == 'products'){
			var orderList = [];
			$(elms).each(function(i, elm){
				if ($(this).hasClass('order')){
					orderList.push($(this));
				}
			});
			$(orderList).tsort();
		}
		else {
			var orderList = [];
			$('ul.list li', this.options.wrapper).each(function(i, elm){
				orderList.push($(this));
			});
			$(orderList).tsort('label');
			//console.log('order');
		}
	}
});

MCD.HistorySlider = Class.extend({
	options: {
		wrapper: null,
		slider: null,
		lftHandle: null,
		rgtHandle: null,
		firstValue: null,
		secondValue: null,
    min: 1955,
    max: 2010,
		start: 1970,
		list: null,
		val: 1970,
		step: 5
	},

	init: function(options){
		MCD.setOptions(options, this);

		this.create();
	},

	create: function(){
		var self = this;
		this.options.wrapperWidth = $(this.options.wrapper).width();
		this.options.slider = $(this.options.wrapper).slider({
			min: self.options.min,
			max: self.options.max,
			values: [this.options.start],
			slide: function(event,ui){
				self.options.val = ui.value;
				$(self.options.lftHandle).text(ui.value - self.options.step);
				$(self.options.rgtHandle).text(ui.value + self.options.step);

				var stepSize = $('.slider-range').width() / (self.options.end - self.options.min);
				$('.handle-visual').css('left', (ui.value - self.options.step - self.options.min) * stepSize + self.options.paddingLeft);
			},
			start: function(event, ui){
				$(document.body).addClass('dragging');
			},
			stop: function(event,ui){
				self.set(ui.value);
				$(document.body).removeClass('dragging');
			}
		});

		$(window).resize(function(){
			var newWidth = $(self.options.wrapper).width();
			if (newWidth != self.options.wrapperWidth){
				self.options.wrapperWidth = newWidth;
				self.options.paddingLeft = parseInt($(self.options.wrapper).parent().css('paddingLeft'));

				var stepSize = $('.slider-range').width() / (self.options.end - self.options.min);
				$('.handle-visual').css('left', (self.options.val - self.options.step - self.options.min) * stepSize + self.options.paddingLeft);
			}
		});

		var span = $('<div></div>');
		$(this.options.wrapper).find('a.ui-slider-handle').addClass('grab').append(span);
		this.options.lftHandle = $('.handle-visual span')[0];
		this.options.rgtHandle = $('.handle-visual span')[1];

		this.options.paddingLeft = parseInt($(this.options.wrapper).parent().css('paddingLeft'));

		var stepSize = $('.slider-range').width() / (self.options.end - self.options.min);
		$('.handle-visual').css('left', (this.options.start - self.options.step - self.options.min) * stepSize + this.options.paddingLeft);

		$(this.options.lftHandle).text(this.options.start - this.options.step);
		$(this.options.rgtHandle).text(parseInt(this.options.start) + this.options.step);

		this.set(this.options.start);
	},

	set: function(value){
		$(this.options.firstValue).text(parseInt(value) - this.options.step);
		$(this.options.secondValue).text(parseInt(value) + this.options.step);

    var datayear = parseInt(value);
		$(this.options.list).each(function(i, el){
			if ($(this).attr('data-year') >= (datayear - 5) && $(this).attr('data-year') <= (datayear + 5)){
				$(this).fadeIn();
			}
			else {
				$(this).fadeOut();
			}
		});
	}
});

MCD.Pushbox = Class.extend({
	options: {
		active: 0,
		next: 0,
		total: 0,
		prevButton: null,
		nextButton: null,
		wrapper: null,
		slider: null,
		items: [],
		buttons: [],
		elem: 'img',
		peekPercentage: 6,
		peek: 150,
		windowWidth: 0,
		data: null,
		type: 'normal',
		initHash: true
	},
	init: function(options){
		MCD.setOptions(options, this);

		this.countTotal();
		this.create();

		if (this.options.type == 'normal'){
			var w = 0;
			$('#pushbox div.nav ul.buttons li').each(function(i, btn){
				w += $(btn).width();
			});
			var extra = 860 - w;
			var m = extra / $('#pushbox div.nav ul.buttons li').length / 2;
			$('#pushbox div.nav ul.buttons li').css({ 'marginLeft': m, 'marginRight': m });
		}
		return false;
	},
	countTotal: function(){
		var self = this;
		$.each(this.options.data, function(key, obj){
			++self.options.total;
		});
	},
	create: function(){
		var self = this, i = 0, j = 0;

		$.each(this.options.data, function(key, obj){

			if (self.options.type == 'normal'){
				if (obj.anchor && obj.anchor == document.location.hash.substr('1', document.location.hash.length - 1)){
					self.options.active = j;
					self.options.next = j;
				}
			}

			var listItem = $('<li></li>').data('key', j),
				img = new Image();
			img.onload = function(){
				++i;
				if (i == self.options.total){ self.loadComplete(); }
			}

			if (self.options.type == 'normal'){ listItem.data('anchor', obj.anchor); }

			// Create ListItem
			$(listItem).append(img);
			$('div.holder ul', self.options.wrapper).append(listItem);
			self.options.items.push(listItem[0]);

			if (obj.flash && parseInt(swfobject.getFlashPlayerVersion().major) > 0){
        $(listItem).data('flash-key', key);
				if (j == self.options.active){
					setTimeout(function(){
						self.createFlashObject(obj, key, listItem[0]);
						setTimeout(function(){
							$(window).trigger('resize');
						}, 10);
					}, 10);
				}
				else {
					if (!$.browser.msie){
						self.createFlashObject(obj, key, listItem[0]);
					}
				}
				$(img).attr('src', obj.flash.image).addClass('bi');
			}
			else {
				if (obj.href){
					$(img).wrap('<a href="' + obj.href + '"></a>');
					$(img).parent().data('target', obj.target == '_blank' ? obj.target : false).click(function(e){
						if ($(this).parent().data('key') != self.options.active){
							$(this).parent().trigger('click');
							return false;
						}
						if ($(this).data('target')){
							window.open($(this).attr('href'));
						}
						else {
							document.location.href = $(this).attr('href');
						}
					});
				}
				$(img).attr('src', obj.banner);
			}

			// Create Button
			// JER
			var button = $('<li><a href="#" data-ga="' + encodeURIComponent(key) + '">' + key + '</a></li>');
			// END JER
			$('ul.buttons', self.options.wrapper).append(button);
			self.options.buttons.push(button[0]);

			++j;
		});
	},
	createFlashObject: function(obj, key, listItem){
		var idName = escape(obj.anchor.toLowerCase()),
			flashHolder = $(listItem).append('<div class="fo"><div class="flash" id="' + idName + '"></div></div>');
		$('div.fo', listItem).css({
			'width': obj.flash.width,
			'height': obj.flash.height,
			'marginLeft': -(obj.flash.width / 2)
		});

		var parameters = {}
		if (obj.flash.flashvars){
			$.extend(parameters, obj.flash.flashvars);
		}
		var flashvars = {
			allowFullScreen: true,
      wmode: 'transparent',
      allowscriptaccess: 'always'
		}
		var attributes = { name: 'banner-' + idName }
		swfobject.embedSWF(obj.flash.banner, idName, obj.flash.width, obj.flash.height, '10.0.0', 'expressInstall.swf', parameters, flashvars, attributes);
	},
	loadComplete: function(){
		this.setItemWidth();
		this.addEvents();
		this.activateButton();
	},
	setItemWidth: function(){
		var self = this;
		$(window).resize(function(){
			self.options.windowWidth = $(self.options.wrapper).width();
			self.options.peek = Math.round((self.options.windowWidth / 100) * self.options.peekPercentage);

			$(self.options.items).css({ 'width': $(self.options.wrapper).width() });
			self.setItemPosition('set');
			self.setHolderWidth();

			var itm = $(self.options.items[self.options.active]);
			if (itm[0]){
				var fWidth = self.options.windowWidth - (self.options.peek * 2);
				$('div.fo', itm).css({ 'width': fWidth, 'marginLeft': -(fWidth / 2) });
				$('div.fo object', itm).css({ 'width': fWidth });
			}
		}).trigger('resize');
	},
	setItemPosition: function(type){
		var self = this;
		$(this.options.items).each(function(i, itm){
			$(itm).removeClass('prev');
			if (i == self.options.active + 1){
				self.transition(type, $(self.options.elem, itm), { 'marginLeft': -self.options.peek });

				$(self.options.elem, itm).css({ 'display': 'block' });
				if ($.browser.msie){
					$('div.fo', itm).remove();
				} else {
					$('div.fo', itm).css({ 'display': 'none' });
				}
			}
			else if(i == self.options.active - 1){
				$(itm).addClass('prev');
				self.transition(type, $(self.options.elem, itm), { 'marginLeft': self.options.windowWidth - $(self.options.elem, itm).width() + self.options.peek });

				$(self.options.elem, itm).css({ 'display': 'block' });
				if ($.browser.msie){
					$('div.fo', itm).remove();
				} else {
					$('div.fo', itm).css({ 'display': 'none' });
				}
			}
			else {
				if ($(self.options.elem, itm).hasClass('bi')){
					$(self.options.elem, itm).css({ 'display': 'block' });
					if ($.browser.msie){
						$('div.fo', itm).remove();
					} else {
						$('div.fo', itm).css({ 'display': 'none' });
					}
				}
				self.transition(type, $(self.options.elem, itm), {'marginLeft': (self.options.windowWidth - $(self.options.elem, itm).width()) / 2 });
				if (type != 'set' && $(self.options.elem, itm).hasClass('bi') && i == self.options.active){
					setTimeout(function(){
						if ($(self.options.elem, itm).hasClass('bi')){
							$(self.options.elem, itm).css({ 'display': 'none' });
						}
						if ($.browser.msie){
							self.createFlashObject(self.options.data[$(itm).data('flash-key')], $(itm).data('flash-key'), itm);
						} else {
							$('div.fo', itm).css({ 'display': 'block' });
						}
					}, 400);
				}
				else if(type == 'set' && $(self.options.elem, itm).hasClass('bi') && i == self.options.active){
					if ($(self.options.elem, itm).hasClass('bi')){
						$(self.options.elem, itm).css({ 'display': 'none' });
					}
					if ($.browser.msie){
						self.createFlashObject(self.options.data[$(itm).data('flash-key')], $(itm).data('flash-key'), itm);
					} else {
						$('div.fo', itm).css({ 'display': 'block' });
					}
				}
			}
		});
	},
	transition: function(type, elm, trans){
		switch (type){
			case 'set': {
				$(elm).css(trans);
				break;
			}
			case 'tween': {
				$(elm).stop().animate(trans, 500);
				break;
			}
		}
	},
	addHashEvent: function(){
		$(this.options.items).each(function(i, btn){
			if (self.options.type == 'normal'){
				if ($(btn).data('anchor') == document.location.hash.substr('1', document.location.hash.length - 1)){
					setTimeout(function(){
						self.options.next = i;
						var type = 'prev';
						if (self.options.next > self.options.active){
							type = 'next';
						}
						self.set();
					}, 10);
				}
			}
		});
	},
	addEvents: function(){
		var self = this;
		$(this.options.buttons).each(function(i, btn){
			$(btn).click(function(e){
				e.preventDefault();
				if (i != self.options.active){
					self.activate(i);
				}
				return false;
			});
		});

		$(this.options.items).each(function(i, btn){
			$(btn).click(function(e){
				e.preventDefault();
				if (i != self.options.active){
					self.activate(i);
				}
				return false;
			});

			if (self.options.type == 'normal'){
				if ($(btn).data('anchor') == document.location.hash.substr('1', document.location.hash.length - 1)){
					setTimeout(function(){
						self.options.next = i;
						var type = 'prev';
						if (self.options.next > self.options.active){
							type = 'next';
						}
						self.set();
					}, 10);
				}
			}
		});

		$(this.options.prevButton).click(function(e){
			e.preventDefault();
			self.prev();
		});
		$(this.options.nextButton).click(function(e){
			e.preventDefault();
			self.next();
		});

		if (this.options.type == 'small'){
			$(window).resize(function(){
				self.setMenu();
			});
		}
	},
	prev: function(){
		--this.options.next;
		if (this.options.next < 0){
			this.options.next = 0;
			return false;
		}
		var type = 'prev';
		this.activateButton();
		this.slide(type);
	},
	next: function(){
		++this.options.next;
		if (this.options.total - this.options.next < 1){
			this.options.next = this.options.total - 1;
			return false;
		}
		var type = 'next';
		this.activateButton();
		this.slide(type);
	},
	activate: function(i){
		this.options.next = i;
		var type = 'prev';
		if (this.options.next > this.options.active){
			type = 'next';
		}
		this.activateButton();
		this.slide(type);
	},
	set: function(){
		this.options.active = this.options.next;
		$(this.options.slider).css({ 'marginLeft': -(this.options.next * this.options.windowWidth) });
		this.setItemPosition('set');

		this.activateButton();
	},
	slide: function(type){
		this.options.active = this.options.next;
		$(this.options.slider).stop().animate({ 'marginLeft': -(this.options.next * this.options.windowWidth) });
		this.setItemPosition('tween');

		if (this.options.type == 'normal'){
			document.location.hash = $(this.options.items[this.options.next]).data('anchor');
		}

		this.setMenu();
	},
	setMenu: function(){
		if (this.options.type == 'small'){
			var self = this,
				navWrap = $(this.options.wrapper).find('.nav-wrap'),
				navWidth = $(navWrap).width(),
				btns = $(navWrap).find('ul li'),
				rgt = 0, stop = false;

			$(btns).each(function(i, btn){
				if (!stop){
					rgt += $(btn).width() + parseInt($(btn).css('marginLeft')) + parseInt($(btn).css('marginRight'));
				}
				if ($(btn).hasClass('active')){ stop = true; }
			});

			if (rgt > navWidth){
				$(navWrap).find('ul').stop().animate({'marginLeft': -(rgt - navWidth)});
			}
			else {
				$(navWrap).find('ul').stop().animate({'marginLeft': 0});
			}

			// JER
			window.gaPushboxSmall();
			// END JER
		}
	},
	activateButton: function(){
		var self = this
		$(this.options.buttons).each(function(i, btn){
			if (i == self.options.next){
				$(btn).addClass('active');
			}
			else if($(btn).hasClass('active') && i != self.options.next){
				$(btn).removeClass('active');
			}
		});
	},
	setHolderWidth: function(){
		$(this.options.slider).css('marginLeft', -(this.options.active * this.options.windowWidth));
	}
});

MCD.Textoverlay = Class.extend({
	options: {
		mask: null,
		overlay: null,
		content: null,
		close: null,
		triggers: null
	},
	init: function(options){
		MCD.setOptions(options, this);

		if (this.options.triggers.length < 1){ return false; }
		this.create();
		this.addEvents();
	},
	addEvents: function(){
		var self = this;
		$(this.options.triggers).click(function(e){
			e.preventDefault();
			self.activate(this);
		});

		$(this.options.mask.options.mask).click(function(){
			self.close();
		});
	},
	activate: function(a){
		if ($(a).attr('data-load') == 'iframe'){
			$(this.options.content).html('<iframe width="665" height="452" src="' + $(a).attr('href') + '" frameborder="0"></iframe>');
			this.open();
		}
		else {
			if ($(a).attr('href')){
				$(this.options.content).html($('#' + $(a).attr('href')).html());
				$(this.options.content).tinyscrollbar();
				this.open();
			}
		}
	},
	create: function(){
		var self = this;
		this.options.mask = new MCD.Mask;

		this.options.overlay = $('<div id="text-overlay"><span class="top-round"></span><span class="bottom-round"></span></div>');
		$(document.body).append(this.options.overlay);

		this.options.content = $('<div class="overlay-content"></div>');
		$(this.options.overlay).append(this.options.content);

		this.options.close = $('<a href="#" class="close"><span>Close</span></a>');
		$(this.options.overlay).append(this.options.close);

		$(this.options.close).click(function(e){
			e.preventDefault();
			self.close();
		});
	},
	open: function(){
		this.options.mask.open();
		$(this.options.overlay).stop().fadeIn();

		$(this.options.content).tinyscrollbar_update();

		if (isiPad){
			var self = this;
			window.scrollTo(0, 0);

		    $(this.options.content).bind('touchstart', function(event){
		        var e = event.originalEvent;
				e.preventDefault();
		    });
		    $(this.options.content).bind('touchmove', function(event){
		        var e = event.originalEvent;
		        e.preventDefault();

				var top = $(self.options.overlay).position().top,
					diff = $('.overview', self.options.content).height() - 432,
					scrollY = e.touches[0].pageY - top,
					percentage = ((scrollY / 432) * 100) + 50;

				if (percentage > 100){ percentage = 100; }
				if (percentage < 0){ percentage = 0; }

				$(this).tinyscrollbar_update((diff / 100) * percentage);
		    });
		}

	},
	close: function(){
		this.options.mask.close();
		$(this.options.overlay).stop().fadeOut();
	}
});

MCD.Videooverlay = Class.extend({
	options: {
		mask: null,
		overlay: null,
		content: null,
		close: null,
		triggers: null
	},
	init: function(options){
		MCD.setOptions(options, this);

		if (this.options.triggers.length < 1){ return false; }
		this.create();
		this.addEvents();
	},
	addEvents: function(){
		var self = this;
		$(this.options.triggers).click(function(e){
			e.preventDefault();
			self.activate(this);
		});

		$(this.options.mask.options.mask).bind(_CLICK, function(){
			self.close();
		});
	},
	activate: function(a){
		if ($(a).attr('href')) {
			// default width and height
			var width = 652;//320;
			var height = 410;//240;

			// if width/height isset in HTML overwrite width/height
			if (typeof ($(a).attr('data-width')) != 'undefined') { width = parseInt($(a).attr('data-width')); }
			if (typeof ($(a).attr('data-height')) != 'undefined') { height = parseInt($(a).attr('data-height')); }

			$(this.options.content).html('<h3>' + $(a).attr('data-title') + '</h3><div id="ov-video-player"></div>');

			if (swfobject.getFlashPlayerVersion().major < 10){
 				$('#ov-video-player').html(
        '<video controls="controls" autoplay="autoplay" ' +
        'poster="' + $(a).attr('data-poster') + '" width="' + width + '" height="' + height + '">' +
        '<source src="' + $(a).attr('data-video') + '.mp4" type="video/mp4"/>' +
        '<source src="' + $(a).attr('data-video') + '.ogg" type="video/ogg"/>' +
        '<source src="' + $(a).attr('data-video') + '.webm" type="video/webm"/>' +
        '</video>');
			}

			var flashvars = {
				src: $(a).attr('data-video') + '.mp4',
				stretching: 'fill',
				autoPlay: true
			};
			var params = {
				allowfullscreen: 'true',
				allowscriptaccess: 'always'
			};
			var attributes = {};
			swfobject.embedSWF(
      Drupal.settings.mcdo.player,
      'ov-video-player',
      width, height, '10.1',
      Drupal.settings.mcdo.install,
      flashvars, params, attributes);

			this.open();
		}
	},
	create: function(){
		var self = this;
		this.options.mask = new MCD.Mask;

		this.options.overlay = $('<div id="video-overlay"><span class="top-round"></span><span class="bottom-round"></span></div>');
		$(document.body).append(this.options.overlay);

		this.options.content = $('<div class="overlay-content"></div>');
		$(this.options.overlay).append(this.options.content);

		this.options.close = $('<a href="#" class="close"><span>Close</span></a>');
		$(this.options.overlay).append(this.options.close);

		$(this.options.close).click(function(e){
			e.preventDefault();
			self.close();
		});
	},
	open: function(){
		this.options.mask.open();
		$(this.options.overlay).stop().fadeIn();

		if (isiPad){
			window.scrollTo(0, 0);
		}
	},
	close: function(){
		$(this.options.content).find('#ov-video-player').css({ 'display': 'none' });
		$(this.options.content).find('#ov-video-player').remove();
		$(this.options.content).html('');
		this.options.mask.close();
		$(this.options.overlay).stop().fadeOut();
	}
});

MCD.Mask = Class.extend({
	options: {
		className: 'mask',
		mask: null,
		dimensions: {
			w: 0, h: 0
		}
	},
	init: function(options){
		this.create();
	},
	create: function(){
		this.options.mask = $('<div class="' + this.options.className + '"></div>');
		$(document.body).append(this.options.mask);

		this.addEvents();
	},
	addEvents: function(){
		var self = this;
		$(window).resize(function(){
			self.resize();
		}).trigger('resize');
	},
	open: function(){
		this.resize();
		$(this.options.mask).css({ 'display': 'block', 'opacity': .8 });
	},
	close: function(){
		$(this.options.mask).css({ 'display': 'none' });
	},
	resize: function(){
		var h = $(window).height();
		if ($(document.body).height() > h){
			h = $(document.body).height();
		}
		$(this.options.mask).css({ 'width': $(window).width(), 'height': h });
	}
});

MCD.Accordion = Class.extend({
	options: {
		wrapper: null,
		triggers: null,
		elms: null,
		active: 0,
		lastWidth: 0
	},
	init: function(options){
		MCD.setOptions(options, this);
		this.setDimensions();
	},
	setDimensions: function(){
		var self = this;
		setTimeout(function(){
			self.set();

			// JER
			if ($('section#content.service_restaurant')[0])
			{
				setTimeout(window.gaServices, 1000);
			}
			// END JER

			self.addEvents();
		}, 50);
	},
	set: function(){
		var self = this;
		$(self.options.elms).each(function(i, elm){
			$(this).css({ 'height': 'auto' });
			$(this).data('height', $(this).height());
			$(this).css({ 'overflow': 'hidden' });
		});

		if ($(self.options.wrapper).hasClass('closeAll')){
			self.hideAll();
		}
		else {
			self.activate('set');
		}
	},
	addEvents: function(){
		var self = this;
		$(this.options.triggers).each(function(i, btn){

			$(this).bind(_CLICK, function(e){
				e.preventDefault();
        if (self.options.triggers.length > 1){
          if (i == self.options.active){
            if ($(self.options.wrapper).hasClass('toggle')){
              self.hide();
            }
            return false;
          }
          else if (i != self.options.active){
            self.options.active = i;
            self.activate('tween');
          }
        }
			});
			if (isiPad){ $(this).bind('click', function(e){ e.preventDefault(); });	}

		});

		$(window).resize(function(){
			if (self.options.lastWidth != self.options.wrapper.width()){
				self.options.lastWidth = self.options.wrapper.width();
				self.set();
			}
		}).trigger('resize');
	},
	activate: function(type){
		var self = this;
		$(this.options.elms).each(function(i, elm){
			if (i == self.options.active){
				self.transition(this, type, { 'height': $(this).data('height') });
				$(self.options.triggers[i]).addClass('active');
			}
			else {
				self.transition(this, type, { 'height': 0 });
				$(self.options.triggers[i]).removeClass('active');
			}
		});

		// JER
		if (type != 'set' && $('section#content.service_restaurant')[0])
		{
			setTimeout(window.gaServices, 500);
		}
		// END JER
	},
	hide: function(){
		this.transition(this.options.elms[this.options.active], 'tween', { 'height': 0 });
		$(this.options.triggers[this.options.active]).removeClass('active');

		this.options.active = null;
	},
	hideAll: function(){
		this.transition(this.options.elms, 'set', { 'height': 0 });
		$(this.options.triggers).removeClass('active');

		$(this.options.elms).closest('li').css({ 'visibility': 'visible' });

		this.options.active = null;
	},
	transition: function(elm, type, prop){
		if (type == 'set'){
			$(elm).css(prop);
		}
		else {
			$(elm).stop().animate(prop, 300);
		}
	}
});

MCD.Selectbox = Class.extend({
	options: {
		select: null
    },
	init: function(select, options){
		MCD.setOptions(options, this);
		this.setSelect(select);
        this.createCustom();
	},
	setSelect: function(select){
		this.options.select = typeof select == 'undefined' ? $('select') : select;
    },
	createCustom: function(){
		var self = this;
		$(this.options.select).each(function(i, select){
			if (!$(this).data('custom')){
				var wrapper = $('<span class="dropdown-wrapper"></span>');
				var label = $('<span class="label"></span>');

				$(this).before(wrapper);
				$(wrapper).append(this).prepend(label);

				$(this).mouseenter(function(){
					$(this).parent().addClass('hover');
				}).mouseleave(function(){
					$(this).parent().removeClass('hover');
				}).change(function(){
					$(label).text($(this).find('option:selected').text());
					$(this).blur();
				}).trigger('change').data('custom', true);
			}
		});
    }
});

MCD.Slider = Class.extend({
	options: {
		wrapper: null,
		active: 0,
		total: 0,
		items: null,
		slider: null,
		stepSize: 0
	},
	init: function(options){
		MCD.setOptions(options, this);

		this.options.stepSize = $(this.options.items).width();
		this.options.total = $(this.options.items).length;
		this.addEvents();
	},
	addEvents: function(){
		var self = this;
		$(this.options.prev).click(function(e){
			e.preventDefault();
			self.prev();
		});
		$(this.options.next).click(function(e){
			e.preventDefault();
			self.next();
		});
	},
	prev: function(){
		--this.options.active;
		if (this.options.active < 0){
			this.options.active = this.options.total - 1;
		}
		this.slide();
	},
	next: function(){
		++this.options.active;
		if (this.options.total - this.options.active < 1){
			this.options.active = 0;
		}
		this.slide();
	},
	slide: function(){
		$(this.options.slider).stop().animate({ 'marginLeft': -(this.options.active * this.options.stepSize) });
	}
});

MCD.Ticker = Class.extend({
	options: {
		items: null,
		active: 0,
		total: 0,
		delay: 8000
	},
	init: function(options){
		MCD.setOptions(options, this);

		this.options.total = $(this.options.items).length;
		$(this.options.items[this.options.active]).fadeIn();
		var self = this;
		setInterval(function(){
			self.next();
		}, this.options.delay);
	},
	next: function(){
		++this.options.active;
		if (this.options.total - this.options.active < 1){
			this.options.active = 0;
		}
		$(this.options.items).fadeOut();
		$(this.options.items[this.options.active]).fadeIn();
	}
});

MCD.Tabs = function(options){
	this.options = options;

	this.addEvents();
	this.activate(0);
}
MCD.Tabs.prototype.addEvents = function(){
	var self = this;
	$(this.options.links).each(function(i, link){
		$(link).click(function(e){

			// JER
			var gaActive = $(this).hasClass('active');
			// console.log("gaActive:", gaActive);
			// END JER

			self.activate(i);

			// JER
			$service = $('section#content.service_restaurant');
			if (gaActive == false && $service[0])
			{
				// console.log("$service:", $service);
				setTimeout(window.gaServices, 500);
			}
			// END JER

			return false;
		});
	});
}
MCD.Tabs.prototype.activate = function(i){
	$(this.options.content).css({ 'display': 'none' });
	$(this.options.content[i]).css({ 'display': 'block' });

	$(this.options.links).removeClass('active');
	$(this.options.links[i]).addClass('active');
}

MCD.ServiceAction = function(options){
	this.options = options;
	this.options.active = 0;

	this.addEvents();
	this.activate(this.options.active);
}
MCD.ServiceAction.prototype.addEvents = function(){
	var self = this;
	$(this.options.links).each(function(i, l){
		$(l).mouseenter(function(e){
			self.activate(i);
			return false;
		}).click(function(e){ e.preventDefault(); });
	});
}
MCD.ServiceAction.prototype.activate = function(i){
	this.options.active = i;
	$('.result', this.options.wrapper).html($(this.options.links[this.options.active]).find('.inf-result').html());
	$(this.options.links).removeClass('active');
	$(this.options.links[this.options.active]).addClass('active');
}

MCD.mainNav = function(elms){
	var h = false, a = false, t = null;
	$(elms).each(function(i, elm){
		$(elm).mouseenter(function(){
			var delay = 400;
			h = true;
			if (a){ delay = 0; }
			clearInterval(t);
			setTimeout(function(){
				if (h){
					a = true;
					$(elms).removeClass('hover');
					$(elm).addClass('hover');
				}
			}, delay);
		}).mouseleave(function(){
			var delay = 300;
			h = false;
			t = setTimeout(function(){
				a = false;
				if (!h){
					$(elm).removeClass('hover');
				}
			}, delay);
		});
	});
}

MCD.TranslateContent = function(triggers){
	$(triggers).bind(_CLICK, function(e){
		e.preventDefault();
		if ($(this).attr('data-current') == 'en'){
			MCD.ReplaceContent($('.' + $(this).attr('data-classes')), 'fr');
			$(this).attr('data-current', 'fr').attr('class', 'flag-en');
		}
		else {
			MCD.ReplaceContent($('.' + $(this).attr('data-classes')), 'en');
			$(this).attr('data-current', 'en').attr('class', 'flag-fr');
		}
		return false;
	}).trigger(_CLICK);
	if (isiPad){ $(triggers).click(function(e){ e.preventDefault(); }); }
}
MCD.ReplaceContent = function(elms, lang){
	$(elms).each(function(i, elm){
		if ($(this).find('img')){
			var img = $(this).find('img');
		}
		$(this).html($(this).attr('data-' + lang));
		if (img){
			$(this).append(img);
		}
	});
	MCD.OrderContent(elms);
}
MCD.OrderContent = function(elms){
	var orderList = [];
	$(elms).each(function(i, elm){
		if ($(this).hasClass('order')){
			orderList.push($(this));
		}
	});
	$(orderList).tsort();
}

MCD.setOptions = function(opt1, cl){
	return $.extend(cl.options, opt1);
}

MCD.addHoverClass = function(elms, delay){
	if (!delay){ delay = 0; }

	$(elms).each(function(i, elm){
		var h = false, t = null;
		$(elm).mouseenter(function(){
			h = true; $(this).addClass('hover'); clearInterval(t);
		}).mouseleave(function(){
			h = false; t = setTimeout(function(){
				if (!h){ $(elm).removeClass('hover'); }
			}, delay);
		});
	});
}

MCD.navHeight = function(){
	$('header[role=banner] nav ul li section.secondary div.middle section ul li').each(function(i, el){
		var lh = parseInt($(el).css('line-height'));
		if ($(el).find('span').actual('height') - 6 > lh){
			$(el).addClass('doubleLine');
		}
	});
}

MCD.multiLine = function(){
	/* Multiline fix */
	var minHeight = 0;
	var maxHeight = 0;
	$('ul.products li h4').each(function(i, el) {
		//$(el).parents('li').find('img').css('margin-bottom', 0);
		if(minHeight == 0) {
			minHeight = $(el).height();
		}

		if($(el).height() > maxHeight) {
			maxHeight = $(el).height();
		} else if($(el).height() < minHeight) {
			minHeight = $(el).height();
		}
	});

  /*
	$('ul.products li h4').each(function(i, el) {
		if($(el).height() == maxHeight) {
			$(el).parents('li').find('img').css('margin-bottom', parseInt($(el).parents('li').find('img').css('margin-bottom')) - (maxHeight - minHeight));
		}
	});
  */
}

MCD.curBlockWidth = 0;
MCD.FacebookBlock = function(){
	if (!$('.fbsocial')[0]) { return false; }
	var blockWidth = $('.fbsocial').width() - 3,
		blockHeight = 0,
		viewportWidth = $(window).width(),
		ratio = [588 / 400, 378 / 340],
		faces = true;

	if (blockWidth == MCD.curBlockWidth){ return false; }
	MCD.curBlockWidth = blockWidth;

	blockHeight = blockWidth * ratio[0];
	if (blockWidth < 355){
		blockWidth + 1;
		faces = false;
		if (blockWidth > 284){
			blockHeight = blockWidth * ratio[1];
		}
	}

	$('.fbsocial').find('.wrapper').css('height', blockHeight);
	$('.fbsocial').find('img.bg').css('height', blockHeight);
	$('.fbsocial').find('iframe').css({
		'height': blockHeight,
		'width': blockWidth,
		'overflow': 'auto'
	});

	var html = '<div class="fb-like-box" data-href="http://www.facebook.com/mcdonaldsfrance" data-width="' + blockWidth + '" data-border-color="#f5f5f5" data-show-faces="' + faces + '" data-stream="true" data-header="true"></div>';
	$('.fbsocial .wrapper').html(html);

	FB.XFBML.parse($('.fbsocial .wrapper').get(0));
}

MCD.Placeholder = function(input){
	if (typeof input == 'undefined'){ input = 'input[type=text], textarea'; }

	if (!MCD.hasProperty('input', 'placeholder')){
		$(input).each(function(i, inp){
			if ($(inp).attr('placeholder')){
				var placeholder = $(inp).attr('placeholder');
				$(inp).focus(function(){
					$(inp).attr('value') == placeholder ? $(inp).attr('value', '').removeClass('noInp') : null;
				}).blur(function(){
					!$(inp).attr('value') || $(inp).attr('value') == placeholder ? $(inp).attr('value', placeholder).addClass('noInp') : null;
				}).trigger('blur');
				$(this).closest('form').submit(function(){
					inp.attr('value') == placeholder ? inp.attr('value', '') : null;
				});
			}
		});
	}
	return true;
}
MCD.hasProperty = function(el, prop){
	var elm = document.createElement(el);
	return prop in elm;
}
}(jQuery));


/* BAU - 20111223 . START */
swfobject.registerObject("mcfarmer-mctimber", "9.0.0");
var flashTimeOut;

function sendToFlash() {
  var obj = swfobject.getObjectById("mcfarmer-mctimber");
  clearTimeout(flashTimeOut);

  if (typeof(obj)!="undefined" && obj && typeof(obj.sendToFlash)=="function") {
    var action = swfobject.getQueryParamValue("action");
    var choice = swfobject.getQueryParamValue("choice");
    obj.sendToFlash(action + "-" + choice);
  }
  else {
    flashTimeOut = setTimeout("sendToFlash()", 100);
  }
}
/* BAU - 20111223 . END */;

