/**
* hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
*/
(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY;};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev]);}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev]);};var handleHover=function(e){var p=(e.type=="mouseover"?e.fromElement:e.toElement)||e.relatedTarget;while(p&&p!=this){try{p=p.parentNode;}catch(e){p=this;}}if(p==this){return false;}var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);}if(e.type=="mouseover"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob);},cfg.timeout);}}};return this.mouseover(handleHover).mouseout(handleHover);};})(jQuery);

/*	sIFR v2.0.7
	Copyright 2004 - 2008 Mark Wubben and Mike Davidson. Prior contributions by Shaun Inman and Tomas Jogin.
	
	This software is licensed under the CC-GNU LGPL <http://creativecommons.org/licenses/LGPL/2.1/>
*/
var hasFlash=function(){var a=6;if(navigator.appVersion.indexOf("MSIE")!=-1&&navigator.appVersion.indexOf("Windows")>-1){document.write('<script language="VBScript"\> \non error resume next \nhasFlash = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & '+a+'))) \n</script\> \n');if(window.hasFlash!=null)return window.hasFlash}if(navigator.mimeTypes&&navigator.mimeTypes["application/x-shockwave-flash"]&&navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin){var b=(navigator.plugins["Shockwave Flash 2.0"]||navigator.plugins["Shockwave Flash"]).description;return parseInt(b.substr(b.indexOf(".")-2,2),10)>=a}return false}();String.prototype.normalize=function(){return this.replace(/\s+/g," ")};if(Array.prototype.push==null){Array.prototype.push=function(){var i=0,a=this.length,b=arguments.length;while(i<b){this[a++]=arguments[i++]}return this.length}}if(!Function.prototype.apply){Function.prototype.apply=function(a,b){var c=[];var d,e;if(!a)a=window;if(!b)b=[];for(var i=0;i<b.length;i++){c[i]="b["+i+"]"}e="a.__applyTemp__("+c.join(",")+");";a.__applyTemp__=this;d=eval(e);a.__applyTemp__=null;return d}}function named(a){return new named.Arguments(a)}named.Arguments=function(a){this.oArgs=a};named.Arguments.prototype.constructor=named.Arguments;named.extract=function(a,b){var c,d;var i=a.length;while(i--){d=a[i];if(d!=null&&d.constructor!=null&&d.constructor==named.Arguments){c=a[i].oArgs;break}}if(c==null)return;for(e in c)if(b[e]!=null)b[e](c[e]);return};var parseSelector=function(){var a=/^([^#.>`]*)(#|\.|\>|\`)(.+)$/;function r(s,t){var u=s.split(/\s*\,\s*/);var v=[];for(var i=0;i<u.length;i++)v=v.concat(b(u[i],t));return v}function b(c,d,e){c=c.normalize().replace(" ","`");var f=c.match(a);var g,h,i,j,k,n;var l=[];if(f==null)f=[c,c];if(f[1]=="")f[1]="*";if(e==null)e="`";if(d==null)d=document;switch(f[2]){case "#":k=f[3].match(a);if(k==null)k=[null,f[3]];g=document.getElementById(k[1]);if(g==null||(f[1]!="*"&&!o(g,f[1])))return l;if(k.length==2){l.push(g);return l}return b(k[3],g,k[2]);case ".":if(e!=">")h=m(d,f[1]);else h=d.childNodes;for(i=0,n=h.length;i<n;i++){g=h[i];if(g.nodeType!=1)continue;k=f[3].match(a);if(k!=null){if(g.className==null||g.className.match("(\\s|^)"+k[1]+"(\\s|$)")==null)continue;j=b(k[3],g,k[2]);l=l.concat(j)}else if(g.className!=null&&g.className.match("(\\s|^)"+f[3]+"(\\s|$)")!=null)l.push(g)}return l;case ">":if(e!=">")h=m(d,f[1]);else h=d.childNodes;for(i=0,n=h.length;i<n;i++){g=h[i];if(g.nodeType!=1)continue;if(!o(g,f[1]))continue;j=b(f[3],g,">");l=l.concat(j)}return l;case "`":h=m(d,f[1]);for(i=0,n=h.length;i<n;i++){g=h[i];j=b(f[3],g,"`");l=l.concat(j)}return l;default:if(e!=">")h=m(d,f[1]);else h=d.childNodes;for(i=0,n=h.length;i<n;i++){g=h[i];if(g.nodeType!=1)continue;if(!o(g,f[1]))continue;l.push(g)}return l}}function m(d,o){if(o=="*"&&d.all!=null)return d.all;return d.getElementsByTagName(o)}function o(p,q){return q=="*"?true:p.nodeName.toLowerCase().replace("html:", "")==q.toLowerCase()}return r}();var sIFR=function(){var a="http://www.w3.org/1999/xhtml";var b=false;var c=false;var d;var ah=[];var al=document;var ak=al.documentElement;var am=window;var au=al.addEventListener;var av=am.addEventListener;var f=function(){var g=navigator.userAgent.toLowerCase();var f={a:g.indexOf("applewebkit")>-1,b:g.indexOf("safari")>-1,c:navigator.product!=null&&navigator.product.toLowerCase().indexOf("konqueror")>-1,d:g.indexOf("opera")>-1,e:al.contentType!=null&&al.contentType.indexOf("xml")>-1,f:true,g:true,h:null,i:null,j:null,k:null};f.l=f.a||f.c;f.m=!f.a&&navigator.product!=null&&navigator.product.toLowerCase()=="gecko";if(f.m&&g.match(/.*gecko\/(\d{8}).*/))f.j=new Number(g.match(/.*gecko\/(\d{8}).*/)[1]);f.n=g.indexOf("msie")>-1&&!f.d&&!f.l&&!f.m;f.o=f.n&&g.match(/.*mac.*/)!=null;if(f.d&&g.match(/.*opera(\s|\/)(\d+\.\d+)/))f.i=new Number(g.match(/.*opera(\s|\/)(\d+\.\d+)/)[2]);if(f.n||(f.d&&f.i<7.6))f.g=false;if(f.a&&g.match(/.*applewebkit\/(\d+).*/))f.k=new Number(g.match(/.*applewebkit\/(\d+).*/)[1]);if(am.hasFlash&&(!f.n||f.o)){var aj=(navigator.plugins["Shockwave Flash 2.0"]||navigator.plugins["Shockwave Flash"]).description;f.h=parseInt(aj.substr(aj.indexOf(".")-2,2),10)}if(g.match(/.*(windows|mac).*/)==null||f.o||f.c||(f.d&&(g.match(/.*mac.*/)!=null||f.i<7.6))||(f.b&&f.h<7)||(!f.b&&f.a&&f.k<312)||(f.m&&f.j<20020523))f.f=false;if(!f.o&&!f.m&&al.createElementNS)try{al.createElementNS(a,"i").innerHTML=""}catch(e){f.e=true}f.p=f.c||(f.a&&f.k<312);return f}();function at(){return{bIsWebKit:f.a,bIsSafari:f.b,bIsKonq:f.c,bIsOpera:f.d,bIsXML:f.e,bHasTransparencySupport:f.f,bUseDOM:f.g,nFlashVersion:f.h,nOperaVersion:f.i,nGeckoBuildDate:f.j,nWebKitVersion:f.k,bIsKHTML:f.l,bIsGecko:f.m,bIsIE:f.n,bIsIEMac:f.o,bUseInnerHTMLHack:f.p}}if(am.hasFlash==false||!al.getElementsByTagName||!al.getElementById||(f.e&&(f.p||f.n)))return{UA:at()};function af(e){if((!k.bAutoInit&&(am.event||e)!=null)||!l(e))return;b=true;for(var i=0,h=ah.length;i<h;i++)j.apply(null,ah[i]);ah=[]}var k=af;function l(e){if(c==false||k.bIsDisabled==true||((f.e&&f.m||f.l)&&e==null&&b==false)||al.getElementsByTagName("body").length==0)return false;return true}function m(n){if(f.n)return n.replace(new RegExp("%\d{0}","g"),"%25");return n.replace(new RegExp("%(?!\d)","g"),"%25")}function as(p,q){return q=="*"?true:p.nodeName.toLowerCase().replace("html:", "")==q.toLowerCase()}function o(p,q,r,s,t){var u="";var v=p.firstChild;var w,x,y,z;if(s==null)s=0;if(t==null)t="";while(v){if(v.nodeType==3){z=v.nodeValue.replace("<","&lt;");switch(r){case "lower":u+=z.toLowerCase();break;case "upper":u+=z.toUpperCase();break;default:u+=z}}else if(v.nodeType==1){if(as(v,"a")&&!v.getAttribute("href")==false){if(v.getAttribute("target"))t+="&sifr_url_"+s+"_target="+v.getAttribute("target");t+="&sifr_url_"+s+"="+m(v.getAttribute("href")).replace(/&/g,"%26");u+='<a href="asfunction:_root.launchURL,'+s+'">';s++}else if(as(v,"br"))u+="<br/>";if(v.hasChildNodes()){y=o(v,null,r,s,t);u+=y.u;s=y.s;t=y.t}if(as(v,"a"))u+="</a>"}w=v;v=v.nextSibling;if(q!=null){x=w.parentNode.removeChild(w);q.appendChild(x)}}return{"u":u,"s":s,"t":t}}function A(B){if(al.createElementNS&&f.g)return al.createElementNS(a,B);return al.createElement(B)}function C(D,E,z){var p=A("param");p.setAttribute("name",E);p.setAttribute("value",z);D.appendChild(p)}function F(p,G){var H=p.className;if(H==null)H=G;else H=H.normalize()+(H==""?"":" ")+G;p.className=H}function aq(ar){var a=ak;if(k.bHideBrowserText==false)a=al.getElementsByTagName("body")[0];if((k.bHideBrowserText==false||ar)&&a)if(a.className==null||a.className.match(/\bsIFR\-hasFlash\b/)==null)F(a, "sIFR-hasFlash")}function j(I,J,K,L,M,N,O,P,Q,R,S,r,T){if(!l())return ah.push(arguments);aq();named.extract(arguments,{sSelector:function(ap){I=ap},sFlashSrc:function(ap){J=ap},sColor:function(ap){K=ap},sLinkColor:function(ap){L=ap},sHoverColor:function(ap){M=ap},sBgColor:function(ap){N=ap},nPaddingTop:function(ap){O=ap},nPaddingRight:function(ap){P=ap},nPaddingBottom:function(ap){Q=ap},nPaddingLeft:function(ap){R=ap},sFlashVars:function(ap){S=ap},sCase:function(ap){r=ap},sWmode:function(ap){T=ap}});var U=parseSelector(I);if(U.length==0)return false;if(S!=null)S="&"+S.normalize();else S="";if(K!=null)S+="&textcolor="+K;if(M!=null)S+="&hovercolor="+M;if(M!=null||L!=null)S+="&linkcolor="+(L||K);if(O==null)O=0;if(P==null)P=0;if(Q==null)Q=0;if(R==null)R=0;if(N==null)N="#FFFFFF";if(T=="transparent")if(!f.f)T="opaque";else N="transparent";if(T==null)T="";var p,V,W,X,Y,Z,aa,ab,ac;var ad=null;for(var i=0,h=U.length;i<h;i++){p=U[i];if(p.className!=null&&p.className.match(/\bsIFR\-replaced\b/)!=null)continue;V=p.offsetWidth-R-P;W=p.offsetHeight-O-Q;aa=A("span");aa.className="sIFR-alternate";ac=o(p,aa,r);Z="txt="+m(ac.u).replace(/\+/g,"%2B").replace(/&/g,"%26").replace(/\"/g, "%22").normalize() + S + "&w=" + V + "&h=" + W + ac.t;F(p,"sIFR-replaced");if(ad==null||!f.g){if(!f.g){if(!f.n)p.innerHTML=['<embed class="sIFR-flash" type="application/x-shockwave-flash" src="',J,'" quality="best" wmode="',T,'" bgcolor="',N,'" flashvars="',Z,'" width="',V,'" height="',W,'" sifr="true"></embed>'].join("");else p.innerHTML=['<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" sifr="true" width="',V,'" height="',W,'" class="sIFR-flash"><param name="movie" value="',J,'"></param><param name="flashvars" value="',Z,'"></param><param name="quality" value="best"></param><param name="wmode" value="',T,'"></param><param name="bgcolor" value="',N,'"></param> </object>'].join('')}else{if(f.d){ab=A("object");ab.setAttribute("data",J);C(ab,"quality","best");C(ab,"wmode",T);C(ab,"bgcolor",N)}else{ab=A("embed");ab.setAttribute("src",J);ab.setAttribute("quality","best");ab.setAttribute("flashvars",Z);ab.setAttribute("wmode",T);ab.setAttribute("bgcolor",N)}ab.setAttribute("sifr","true");ab.setAttribute("type","application/x-shockwave-flash");ab.className="sIFR-flash";if(!f.l||!f.e)ad=ab.cloneNode(true)}}else ab=ad.cloneNode(true);if(f.g){if(f.d)C(ab,"flashvars",Z);else ab.setAttribute("flashvars",Z);ab.setAttribute("width",V);ab.setAttribute("height",W);ab.style.width=V+"px";ab.style.height=W+"px";p.appendChild(ab)}p.appendChild(aa);if(f.p)p.innerHTML+=""}if(f.n&&k.bFixFragIdBug)setTimeout(function(){al.title=d},0)}function ai(){d=al.title}function ae(){if(k.bIsDisabled==true)return;c=true;if(k.bHideBrowserText)aq(true);if(am.attachEvent)am.attachEvent("onload",af);else if(!f.c&&(al.addEventListener||am.addEventListener)){if(f.a&&f.k>=132&&am.addEventListener)am.addEventListener("load",function(){setTimeout("sIFR({})",1)},false);else{if(al.addEventListener)al.addEventListener("load",af,false);if(am.addEventListener)am.addEventListener("load",af,false)}}else if(typeof am.onload=="function"){var ag=am.onload;am.onload=function(){ag();af()}}else am.onload=af;if(!f.n||am.location.hash=="")k.bFixFragIdBug=false;else ai()}k.UA=at();k.bAutoInit=true;k.bFixFragIdBug=true;k.replaceElement=j;k.updateDocumentTitle=ai;k.appendToClassName=F;k.setup=ae;k.debug=function(){aq(true)};k.debug.replaceNow=function(){ae();k()};k.bIsDisabled=false;k.bHideBrowserText=true;return k}();

if(typeof sIFR == "function" && !sIFR.UA.bIsIEMac && (!sIFR.UA.bIsWebKit || sIFR.UA.nWebKitVersion >= 100)){
	sIFR.setup();
};

/* Datepicker http://jonathanleighton.com/projects/date-input */
DateInput=(function(A){function B(C,D){if(typeof (D)!="object"){D={}}A.extend(this,B.DEFAULT_OPTS,D);this.input=A(C);this.bindMethodsToObj("show","hide","hideIfClickOutside","keydownHandler","selectDate");this.build();this.selectDate();this.hide()}B.DEFAULT_OPTS={month_names:["January","February","March","April","May","June","July","August","September","October","November","December"],short_month_names:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],short_day_names:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],start_of_week:1};B.prototype={build:function(){var C=A('<p class="month_nav"><span class="button prev" title="[Page-Up]">&#171;</span> <span class="month_name"></span> <span class="button next" title="[Page-Down]">&#187;</span></p>');this.monthNameSpan=A(".month_name",C);A(".prev",C).click(this.bindToObj(function(){this.moveMonthBy(-1)}));A(".next",C).click(this.bindToObj(function(){this.moveMonthBy(1)}));var D=A('<p class="year_nav"><span class="button prev" title="[Ctrl+Page-Up]">&#171;</span> <span class="year_name"></span> <span class="button next" title="[Ctrl+Page-Down]">&#187;</span></p>');this.yearNameSpan=A(".year_name",D);A(".prev",D).click(this.bindToObj(function(){this.moveMonthBy(-12)}));A(".next",D).click(this.bindToObj(function(){this.moveMonthBy(12)}));var E=A('<div class="nav"></div>').append(C,D);var F="<table><thead><tr>";A(this.adjustDays(this.short_day_names)).each(function(){F+="<th>"+this+"</th>"});F+="</tr></thead><tbody></tbody></table>";this.dateSelector=this.rootLayers=A('<div class="date_selector"></div>').append(E,F).insertAfter(this.input);if(A.browser.msie&&A.browser.version<7){this.ieframe=A('<iframe class="date_selector_ieframe" frameborder="0" src="#"></iframe>').insertBefore(this.dateSelector);this.rootLayers=this.rootLayers.add(this.ieframe);A(".button",E).mouseover(function(){A(this).addClass("hover")});A(".button",E).mouseout(function(){A(this).removeClass("hover")})}this.tbody=A("tbody",this.dateSelector);this.input.change(this.bindToObj(function(){this.selectDate()}));this.selectDate()},selectMonth:function(D){var J=new Date(D.getFullYear(),D.getMonth(),1);if(!this.currentMonth||!(this.currentMonth.getFullYear()==J.getFullYear()&&this.currentMonth.getMonth()==J.getMonth())){this.currentMonth=J;var I=this.rangeStart(D),H=this.rangeEnd(D);var C=this.daysBetween(I,H);var F="";for(var E=0;E<=C;E++){var G=new Date(I.getFullYear(),I.getMonth(),I.getDate()+E,12,0);if(this.isFirstDayOfWeek(G)){F+="<tr>"}if(G.getMonth()==D.getMonth()){F+='<td class="selectable_day" date="'+this.dateToString(G)+'">'+G.getDate()+"</td>"}else{F+='<td class="unselected_month" date="'+this.dateToString(G)+'">'+G.getDate()+"</td>"}if(this.isLastDayOfWeek(G)){F+="</tr>"}}this.tbody.empty().append(F);this.monthNameSpan.empty().append(this.monthName(D));this.yearNameSpan.empty().append(this.currentMonth.getFullYear());A(".selectable_day",this.tbody).click(this.bindToObj(function(K){this.changeInput(A(K.target).attr("date"))}));A("td[date="+this.dateToString(new Date())+"]",this.tbody).addClass("today");A("td.selectable_day",this.tbody).mouseover(function(){A(this).addClass("hover")});A("td.selectable_day",this.tbody).mouseout(function(){A(this).removeClass("hover")})}A(".selected",this.tbody).removeClass("selected");A("td[date="+this.selectedDateString+"]",this.tbody).addClass("selected")},selectDate:function(C){if(typeof (C)=="undefined"){C=this.stringToDate(this.input.val())}if(!C){C=new Date()}this.selectedDate=C;this.selectedDateString=this.dateToString(this.selectedDate);this.selectMonth(this.selectedDate)},changeInput:function(C){this.input.val(C).change();this.hide()},show:function(){this.rootLayers.css("display","block");A([window,document.body]).click(this.hideIfClickOutside);this.input.unbind("focus",this.show);A(document.body).keydown(this.keydownHandler);this.setPosition()},hide:function(){this.rootLayers.css("display","none");A([window,document.body]).unbind("click",this.hideIfClickOutside);this.input.focus(this.show);A(document.body).unbind("keydown",this.keydownHandler)},hideIfClickOutside:function(C){if(C.target!=this.input[0]&&!this.insideSelector(C)){this.hide()}},insideSelector:function(C){var D=this.dateSelector.position();D.right=D.left+this.dateSelector.outerWidth();D.bottom=D.top+this.dateSelector.outerHeight();return C.pageY<D.bottom&&C.pageY>D.top&&C.pageX<D.right&&C.pageX>D.left},keydownHandler:function(C){switch(C.keyCode){case 9:case 27:this.hide();return ;break;case 13:this.changeInput(this.selectedDateString);break;case 33:this.moveDateMonthBy(C.ctrlKey?-12:-1);break;case 34:this.moveDateMonthBy(C.ctrlKey?12:1);break;case 38:this.moveDateBy(-7);break;case 40:this.moveDateBy(7);break;case 37:this.moveDateBy(-1);break;case 39:this.moveDateBy(1);break;default:return }C.preventDefault()},stringToDate:function(C){var D;if(D=C.match(/^(\d{1,2}) ([^\s]+) (\d{4,4})$/)){return new Date(D[3],this.shortMonthNum(D[2]),D[1],12,0)}else{return null}},dateToString:function(C){return C.getDate()+" "+this.short_month_names[C.getMonth()]+" "+C.getFullYear()},setPosition:function(){var C=this.input.offset();this.rootLayers.css({top:C.top+this.input.outerHeight(),left:C.left});if(this.ieframe){this.ieframe.css({width:this.dateSelector.outerWidth(),height:this.dateSelector.outerHeight()})}},moveDateBy:function(D){var C=new Date(this.selectedDate.getFullYear(),this.selectedDate.getMonth(),this.selectedDate.getDate()+D);this.selectDate(C)},moveDateMonthBy:function(D){var C=new Date(this.selectedDate.getFullYear(),this.selectedDate.getMonth()+D,this.selectedDate.getDate());if(C.getMonth()==this.selectedDate.getMonth()+D+1){C.setDate(0)}this.selectDate(C)},moveMonthBy:function(C){var D=new Date(this.currentMonth.getFullYear(),this.currentMonth.getMonth()+C,this.currentMonth.getDate());this.selectMonth(D)},monthName:function(C){return this.month_names[C.getMonth()]},bindToObj:function(D){var C=this;return function(){return D.apply(C,arguments)}},bindMethodsToObj:function(){for(var C=0;C<arguments.length;C++){this[arguments[C]]=this.bindToObj(this[arguments[C]])}},indexFor:function(E,D){for(var C=0;C<E.length;C++){if(D==E[C]){return C}}},monthNum:function(C){return this.indexFor(this.month_names,C)},shortMonthNum:function(C){return this.indexFor(this.short_month_names,C)},shortDayNum:function(C){return this.indexFor(this.short_day_names,C)},daysBetween:function(D,C){D=Date.UTC(D.getFullYear(),D.getMonth(),D.getDate());C=Date.UTC(C.getFullYear(),C.getMonth(),C.getDate());return(C-D)/86400000},changeDayTo:function(C,D,E){var F=E*(Math.abs(D.getDay()-C-(E*7))%7);return new Date(D.getFullYear(),D.getMonth(),D.getDate()+F)},rangeStart:function(C){return this.changeDayTo(this.start_of_week,new Date(C.getFullYear(),C.getMonth()),-1)},rangeEnd:function(C){return this.changeDayTo((this.start_of_week-1)%7,new Date(C.getFullYear(),C.getMonth()+1,0),1)},isFirstDayOfWeek:function(C){return C.getDay()==this.start_of_week},isLastDayOfWeek:function(C){return C.getDay()==(this.start_of_week-1)%7},adjustDays:function(E){var D=[];for(var C=0;C<E.length;C++){D[C]=E[(C+this.start_of_week)%7]}return D}};A.fn.date_input=function(C){return this.each(function(){new B(this,C)})};A.date_input={initialize:function(C){A("input.date_input").date_input(C)}};return B})(jQuery)

// scroller
var b = jQuery.noConflict();
(function(b){b.tools=b.tools||{};b.tools.scrollable={version:"1.1.2",conf:{size:5,vertical:false,speed:400,keyboard:true,keyboardSteps:null,disabledClass:"disabled",hoverClass:null,clickable:true,activeClass:"active",easing:"swing",loop:false,items:".items",item:null,prev:".prev",next:".next",prevPage:".prevPage",nextPage:".nextPage",api:false}};var c;function a(o,m){var r=this,p=b(this),d=!m.vertical,e=o.children(),k=0,i;if(!c){c=r}b.each(m,function(s,t){if(b.isFunction(t)){p.bind(s,t)}});if(e.length>1){e=b(m.items,o)}function l(t){var s=b(t);return m.globalNav?s:o.parent().find(t)}o.data("finder",l);var f=l(m.prev),h=l(m.next),g=l(m.prevPage),n=l(m.nextPage);b.extend(r,{getIndex:function(){return k},getClickIndex:function(){var s=r.getItems();return s.index(s.filter("."+m.activeClass))},getConf:function(){return m},getSize:function(){return r.getItems().size()},getPageAmount:function(){return Math.ceil(this.getSize()/m.size)},getPageIndex:function(){return Math.ceil(k/m.size)},getNaviButtons:function(){return f.add(h).add(g).add(n)},getRoot:function(){return o},getItemWrap:function(){return e},getItems:function(){return e.children(m.item)},getVisibleItems:function(){return r.getItems().slice(k,k+m.size)},seekTo:function(s,w,t){if(s<0){s=0}if(k===s){return r}if(b.isFunction(w)){t=w}if(s>r.getSize()-m.size){return m.loop?r.begin():this.end()}var u=r.getItems().eq(s);if(!u.length){return r}var v=b.Event("onBeforeSeek");p.trigger(v,[s]);if(v.isDefaultPrevented()){return r}if(w===undefined||b.isFunction(w)){w=m.speed}function x(){if(t){t.call(r,s)}p.trigger("onSeek",[s])}if(d){e.animate({left:-u.position().left},w,m.easing,x)}else{e.animate({top:-u.position().top},w,m.easing,x)}c=r;k=s;v=b.Event("onStart");p.trigger(v,[s]);if(v.isDefaultPrevented()){return r}f.add(g).toggleClass(m.disabledClass,s===0);h.add(n).toggleClass(m.disabledClass,s>=r.getSize()-m.size);return r},move:function(u,t,s){i=u>0;return this.seekTo(k+u,t,s)},next:function(t,s){return this.move(1,t,s)},prev:function(t,s){return this.move(-1,t,s)},movePage:function(w,v,u){i=w>0;var s=m.size*w;var t=k%m.size;if(t>0){s+=(w>0?-t:m.size-t)}return this.move(s,v,u)},prevPage:function(t,s){return this.movePage(-1,t,s)},nextPage:function(t,s){return this.movePage(1,t,s)},setPage:function(t,u,s){return this.seekTo(t*m.size,u,s)},begin:function(t,s){i=false;return this.seekTo(0,t,s)},end:function(t,s){i=true;var u=this.getSize()-m.size;return u>0?this.seekTo(u,t,s):r},reload:function(){p.trigger("onReload");return r},focus:function(){c=r;return r},click:function(u){var v=r.getItems().eq(u),s=m.activeClass,t=m.size;if(u<0||u>=r.getSize()){return r}if(t==1){if(m.loop){return r.next()}if(u===0||u==r.getSize()-1){i=(i===undefined)?true:!i}return i===false?r.prev():r.next()}if(t==2){if(u==k){u--}r.getItems().removeClass(s);v.addClass(s);return r.seekTo(u,time,fn)}if(!v.hasClass(s)){r.getItems().removeClass(s);v.addClass(s);var x=Math.floor(t/2);var w=u-x;if(w>r.getSize()-t){w=r.getSize()-t}if(w!==u){return r.seekTo(w)}}return r},bind:function(s,t){p.bind(s,t);return r},unbind:function(s){p.unbind(s);return r}});b.each("onBeforeSeek,onStart,onSeek,onReload".split(","),function(s,t){r[t]=function(u){return r.bind(t,u)}});f.addClass(m.disabledClass).click(function(){r.prev()});h.click(function(){r.next()});n.click(function(){r.nextPage()});if(r.getSize()<=m.size){h.add(n).addClass(m.disabledClass)}g.addClass(m.disabledClass).click(function(){r.prevPage()});var j=m.hoverClass,q="keydown."+Math.random().toString().substring(10);r.onReload(function(){if(j){r.getItems().hover(function(){b(this).addClass(j)},function(){b(this).removeClass(j)})}if(m.clickable){r.getItems().each(function(s){b(this).unbind("click.scrollable").bind("click.scrollable",function(t){if(b(t.target).is("a")){return}return r.click(s)})})}if(m.keyboard){b(document).unbind(q).bind(q,function(t){if(t.altKey||t.ctrlKey){return}if(m.keyboard!="static"&&c!=r){return}var u=m.keyboardSteps;if(d&&(t.keyCode==37||t.keyCode==39)){r.move(t.keyCode==37?-u:u);return t.preventDefault()}if(!d&&(t.keyCode==38||t.keyCode==40)){r.move(t.keyCode==38?-u:u);return t.preventDefault()}return true})}else{b(document).unbind(q)}});r.reload()}b.fn.scrollable=function(d){var e=this.eq(typeof d=="number"?d:0).data("scrollable");if(e){return e}var f=b.extend({},b.tools.scrollable.conf);d=b.extend(f,d);d.keyboardSteps=d.keyboardSteps||d.size;this.each(function(){e=new a(b(this),d);b(this).data("scrollable",e)});return d.api?e:this}})(jQuery);

b(function() { 
	b(".scrollable").scrollable({ size: 4 });
});

// custom part
var I$ = jQuery.noConflict();

I$(function() {	
	// all extern links in new window
	I$("a.ext").click(function(Ev){
		Ev.preventDefault();

		var newwindow = window.open(I$(this).attr('href'), "newwindow"+String(Math.round(Math.random()*10)),"menubar=yes,location=yes,status=yes,scrollbars=yes,toolbar=yes,resizable=yes");
		newwindow.focus();
	});
	
	// menu
	var config = {
		sensitivity: 1,
		interval: 10,
		over: MegaHoverOver,
		timeout: 0,
		out: MegaHoverOut
	};
	I$("#nav li.hassubnav").hoverIntent(config);

	// galerie
	I$("#gallery ul li a").click(function(Ev){
		Ev.preventDefault();
		
		I$(this).parent().parent().find("li").removeClass("active");
		I$(this).parent().addClass("active");
		I$(this).get(0).blur();
		
		I$("#visual #zoom img").get(0).src = I$(this).find("span img").get(0).src;
	});
	
	// datepicker
	I$.extend(DateInput.DEFAULT_OPTS, {
		month_names: ["Januar", "Februar", "MÃ¤rz", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"],
		short_month_names: ["Jan", "Feb", "MÃ¤r", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dez"],
		short_day_names: ["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"],
		stringToDate: function(string) {
   			var matches;
			if (matches = string.match(/^(\d{2,2}).(\d{2,2}).(\d{4,4})$/)) {
				return new Date(matches[3], matches[2] - 1, matches[1]);
			} else {
				return null;
			};
		},
		dateToString: function(date) {
			var month = (date.getMonth() + 1).toString();
			var dom = date.getDate().toString();
			if (month.length == 1) month = "0" + month;
			if (dom.length == 1) dom = "0" + dom;
			return dom+"."+month+"."+date.getFullYear();
		}
	});

	I$(".date_input").date_input({ start_of_week: 0 });
	
	// lightbox-start
	function LightboxResize(ImageWidth, Index)
	{
		//größe lightbox ändern
		var v_height = I$(window).height();
		var v_width = I$(window).width();
		var p_height = I$(document).height();
		var max_height = v_height>p_height ? v_height : p_height;
		I$('#lightbox_frame').css('top', (v_height/2-275)+'px');
		I$('#lightbox_frame').css('left', ((v_width - ImageWidth-120)/2)+'px');
		I$('#lightbox_frame').css('width', ImageWidth+'px');
		I$('#lightbox').css('height', max_height+'px');
		I$('#canvas').css('height', max_height+'px');		
		I$('#canvas').css('width', v_width+'px');
		
		//array mit allen lighbox links aufbauenn		
		I$('.back_lightbox').css('display', 'block');
		I$('.forward_lightbox').css('display', 'block');
			
		if (Index==0){
			I$('.back_lightbox').css('display', 'none');
		}else if (Index==I$('.open_lightbox').size()-1){
			I$('.forward_lightbox').css('display', 'none');
		}
	}
	
	function LightboxSkip(Direction)
	{
		//array mit allen lighbox links aufbauenn
		var allelinks = I$('.open_lightbox');

		//aktuelles bild aus der lightbox holen
		var current_image = I$('#lightbox_content').children()[0];
		var url = I$(current_image).attr('src');

		if (url.substr("http://")){
			url = "../" + url.substr(url.indexOf('media'));
		}

		//jedes bild testen, ob es das aktuelle ist
	    I$.each(allelinks, function(index, Ev) {
	    	var image_url = this.toString();
	    	image_url = '../' + image_url.substr(image_url.indexOf("media"));

	    	//aktuell mit nachbar vergleichen
	    	if (url == image_url) {
	    		//aktuelles bild gefunden, index des nächsten bildes herausfinden
	    		if (index > 0 && Direction<0) {
	    			--index;
	    		}
	    		
	    		if (index != allelinks.size()-1 && Direction>0) {
	    			++index
	    		}
	    		
	    		//bild aus array holen
	    		var new_image = allelinks[index];
				
	    		//neue bild breite holen
	    		var image_width = I$(new_image).attr('rel');
	    		
	    		//source, breite und höhe neu setzen
	    		I$(current_image).attr('src', new_image);
	    		I$(current_image).attr('width', image_width);

	    		LightboxResize(image_width, index);

	    		return false; //break
	    	}
	     });
	}
	
	I$(".open_lightbox").click(function(Ev){
		Ev.preventDefault();
		
		var image_src = I$(this).attr('href');
		var image_width = I$(this).attr('rel');

		I$('#lightbox_content').load("/html/ajax_lightbox_content.php", {'id': image_src, 'width': image_width});
   	
   		var index = I$(this).index('.open_lightbox');
		
   		LightboxResize(image_width, index);
   		
   		I$('#canvas').fadeTo(350, 0.7);
		I$('#lightbox').fadeIn(350);
	});
		
	I$(".back_lightbox").click(function(Ev){
		Ev.preventDefault();
		LightboxSkip(-1);
	});

	I$(".forward_lightbox").click(function(Ev){
		Ev.preventDefault();
		LightboxSkip(1);
	});
	
	
	I$('.close, #canvas').click(function(Ev){
		Ev.preventDefault();

		I$('#canvas').fadeOut(350);
		I$('#lightbox').fadeOut(350);
	});	
	// Lightbox end
	
	function formatCurrency(num) {
	    num = isNaN(num) || num === '' || num === null ? 0.00 : num;
	    return parseFloat(num).toFixed(2);
	}
	
	I$('.toggle').click(function(){
		I$(this).nextUntil().slideToggle('fast');
		
		if(I$(this).hasClass('expanded')){
            I$(this).addClass('collapsed').removeClass('expanded');
        }else{
            I$(this).addClass('expanded').removeClass('collapsed');
        }
	});
	
	I$('#next').click(function(){
		I$('div.services').css('display','none');
		I$('div.personal').css('display','block');
		
		I$('h2.service').each(function(){
			if(I$(this).hasClass('collapsed')){
            	I$(this).addClass('expanded').removeClass('collapsed');
        	}
		});
		
		I$('h2.personal').each(function(){
			if(I$(this).hasClass('expanded')){
            	I$(this).addClass('collapsed').removeClass('expanded');
        	}
		});
	
	});
	
	I$('.calculate').click(function(){
	
		if(isNaN(I$('#f-persons').val()) || I$('#f-persons').val() < 0){
			I$('#f-persons').val(0);
		}
		var persons			= I$('#f-persons').val();
		var sum				= persons * I$('.require').text().match('([0-9\,]+)')[0].replace(',','.');
		var prices			= [];
		var participants	= [];
		
		I$("input[type=checkbox]").each(function(){
			if(I$(this).is(':checked')){
				var parent_li = I$(this).parent().parent();
				var single_price = I$(parent_li.children()[1]).html().match('([0-9\,]+)');
				var format_price = single_price[0].replace(',','.');
				
				sum += persons * format_price;
			}
		});
	
		
		I$('input[class=services][type=text]').each(function(){
			var participant = I$(this).val();
			
			
			if(participant == ''){
				I$(this).val(persons);
			}
			
			console.log(I$(this).attr('name'));
			
			if(isNaN(I$(this).val()) || I$(this).val() < 0 || (I$(this).attr('name') == 'double' && participant == '') || (I$(this).attr('name') == 'snack' && participant == '') || (I$(this).attr('name') == 'meal' && participant == '') || (I$(this).attr('name') == 'menu_2' && participant == '')){
				I$(this).val(0);
			}
			
			participants.push(I$(this).val());
		});
		
		I$('.price').each(function(){
			var single_price = I$(this).text().match('([0-9\,]+)')
			var format_price = single_price[0].replace(',','.');
			
			prices.push(parseFloat(format_price));
		});
		
		for (var i = 0; i <= 14; i++){
			var individual_prices = formatCurrency(participants[i] * prices[i]);
			sum += parseFloat(individual_prices);
		}
		
		var total = formatCurrency(sum);
		I$('.totalprice').text(total.replace('.',','));
		I$('#f-total').val(total.replace('.',','));
	
	});
	
});
	
// dropdown menu
function MegaHoverOver(){
	var sub = I$(this).find("ul");
	
	sub.fadeIn(0);
	sub.parent().addClass('hover');
}

function MegaHoverOut(){
	var sub = I$(this).find("ul");
	
	sub.fadeOut(0);
	sub.parent().removeClass('hover');
}


