(function(e){function u(a){e.fn.cycle.debug&&k(a)}function k(){window.console&&window.console.log&&window.console.log("[cycle] "+Array.prototype.join.call(arguments," "))}function z(a,b,d){if(a.cycleStop==undefined)a.cycleStop=0;if(b===undefined||b===null)b={};if(b.constructor==String){switch(b){case "destroy":case "stop":d=e(a).data("cycle.opts");if(!d)return false;a.cycleStop++;a.cycleTimeout&&clearTimeout(a.cycleTimeout);a.cycleTimeout=0;e(a).removeData("cycle.opts");b=="destroy"&&A(d);return false;case "toggle":a.cyclePause=a.cyclePause===1?0:1;return false;case "pause":a.cyclePause=1;return false;case "resume":a.cyclePause=0;if(d===true){b=e(a).data("cycle.opts");if(!b){k("options not found, can not resume");return false}if(a.cycleTimeout){clearTimeout(a.cycleTimeout);a.cycleTimeout=0}n(b.elements,b,1,1)}return false;case "prev":case "next":d=e(a).data("cycle.opts");if(!d){k('options not found, "prev/next" ignored');return false}e.fn.cycle[b](d);return false;default:b={fx:b}}return b}else if(b.constructor== Number){var f=b;b=e(a).data("cycle.opts");if(!b){k("options not found, can not advance slide");return false}if(f<0||f>=b.elements.length){k("invalid slide index: "+f);return false}b.nextSlide=f;if(a.cycleTimeout){clearTimeout(a.cycleTimeout);a.cycleTimeout=0}if(typeof d=="string")b.oneTimeFx=d;n(b.elements,b,1,f>=b.currSlide);return false}return b}function v(a,b){if(!e.support.opacity&&b.cleartype&&a.style.filter)try{a.style.removeAttribute("filter")}catch(d){}}function A(a){a.next&&e(a.next).unbind(a.prevNextEvent);a.prev&&e(a.prev).unbind(a.prevNextEvent);if(a.pager||a.pagerAnchorBuilder)e.each(a.pagerAnchors||[],function(){this.unbind().remove()});a.pagerAnchors=null;a.destroy&&a.destroy(a)}function B(a,b,d,f,g){var c=e.extend({},e.fn.cycle.defaults,f||{},e.metadata?a.metadata():e.meta?a.data():{});if(c.autostop)c.countdown=c.autostopCount||d.length;var h=a[0];a.data("cycle.opts",c);c.$cont=a;c.stopCount=h.cycleStop;c.elements=d;c.before=c.before?[c.before]:[];c.after=c.after?[c.after]:[];c.after.unshift(function(){c.busy= 0});!e.support.opacity&&c.cleartype&&c.after.push(function(){v(this,c)});c.continuous&&c.after.push(function(){n(d,c,0,!c.rev)});C(c);!e.support.opacity&&c.cleartype&&!c.cleartypeNoBg&&w(b);a.css("position")=="static"&&a.css("position","relative");c.width&&a.width(c.width);c.height&&c.height!="auto"&&a.height(c.height);if(c.startingSlide)c.startingSlide=parseInt(c.startingSlide);if(c.random){c.randomMap=[];for(h=0;h<d.length;h++)c.randomMap.push(h);c.randomMap.sort(function(){return Math.random()- 0.5});c.randomIndex=1;c.startingSlide=c.randomMap[1]}else if(c.startingSlide>=d.length)c.startingSlide=0;c.currSlide=c.startingSlide||0;var i=c.startingSlide;b.css({position:"absolute",top:0,left:0}).hide().each(function(j){j=i?j>=i?d.length-(j-i):i-j:d.length-j;e(this).css("z-index",j)});e(d[i]).css("opacity",1).show();v(d[i],c);c.fit&&c.width&&b.width(c.width);c.fit&&c.height&&c.height!="auto"&&b.height(c.height);if(c.containerResize&&!a.innerHeight()){for(var l=h=0,m=0;m<d.length;m++){var o=e(d[m]), q=o[0],r=o.outerWidth(),s=o.outerHeight();r||(r=q.offsetWidth||q.width||o.attr("width"));s||(s=q.offsetHeight||q.height||o.attr("height"));h=r>h?r:h;l=s>l?s:l}h>0&&l>0&&a.css({width:h+"px",height:l+"px"})}c.pause&&a.hover(function(){this.cyclePause++},function(){this.cyclePause--});if(D(c)===false)return false;var x=false;f.requeueAttempts=f.requeueAttempts||0;b.each(function(){var j=e(this);this.cycleH=c.fit&&c.height?c.height:j.height()||this.offsetHeight||this.height||j.attr("height")||0;this.cycleW= c.fit&&c.width?c.width:j.width()||this.offsetWidth||this.width||j.attr("width")||0;if(j.is("img")){j=e.browser.mozilla&&this.cycleW==34&&this.cycleH==19&&!this.complete;var E=e.browser.opera&&(this.cycleW==42&&this.cycleH==19||this.cycleW==37&&this.cycleH==17)&&!this.complete,F=this.cycleH==0&&this.cycleW==0&&!this.complete;if(e.browser.msie&&this.cycleW==28&&this.cycleH==30&&!this.complete||j||E||F)if(g.s&&c.requeueOnImageNotLoaded&&++f.requeueAttempts<100){k(f.requeueAttempts," - img slide not loaded, requeuing slideshow: ", this.src,this.cycleW,this.cycleH);setTimeout(function(){e(g.s,g.c).cycle(f)},c.requeueTimeout);x=true;return false}else k("could not determine size of image: "+this.src,this.cycleW,this.cycleH)}return true});if(x)return false;c.cssBefore=c.cssBefore||{};c.animIn=c.animIn||{};c.animOut=c.animOut||{};b.not(":eq("+i+")").css(c.cssBefore);c.cssFirst&&e(b[i]).css(c.cssFirst);if(c.timeout){c.timeout=parseInt(c.timeout);if(c.speed.constructor==String)c.speed=e.fx.speeds[c.speed]||parseInt(c.speed);for(c.sync|| (c.speed/=2);c.timeout-c.speed<250;)c.timeout+=c.speed}if(c.easing)c.easeIn=c.easeOut=c.easing;if(!c.speedIn)c.speedIn=c.speed;if(!c.speedOut)c.speedOut=c.speed;c.slideCount=d.length;c.currSlide=c.lastSlide=i;if(c.random){if(++c.randomIndex==d.length)c.randomIndex=0;c.nextSlide=c.randomMap[c.randomIndex]}else c.nextSlide=c.startingSlide>=d.length-1?0:c.startingSlide+1;if(!c.multiFx){h=e.fn.cycle.transitions[c.fx];if(e.isFunction(h))h(a,b,c);else if(c.fx!="custom"&&!c.multiFx){k("unknown transition: "+ c.fx,"; slideshow terminating");return false}}a=b[i];c.before.length&&c.before[0].apply(a,[a,a,c,true]);c.after.length>1&&c.after[1].apply(a,[a,a,c,true]);c.next&&e(c.next).bind(c.prevNextEvent,function(){return t(c,c.rev?-1:1)});c.prev&&e(c.prev).bind(c.prevNextEvent,function(){return t(c,c.rev?1:-1)});if(c.pager||c.pagerAnchorBuilder)G(d,c);H(c,d);return c}function C(a){a.original={before:[],after:[]};a.original.cssBefore=e.extend({},a.cssBefore);a.original.cssAfter=e.extend({},a.cssAfter);a.original.animIn= e.extend({},a.animIn);a.original.animOut=e.extend({},a.animOut);e.each(a.before,function(){a.original.before.push(this)});e.each(a.after,function(){a.original.after.push(this)})}function D(a){var b,d,f=e.fn.cycle.transitions;if(a.fx.indexOf(",")>0){a.multiFx=true;a.fxs=a.fx.replace(/\s*/g,"").split(",");for(b=0;b<a.fxs.length;b++){var g=a.fxs[b];d=f[g];if(!d||!f.hasOwnProperty(g)||!e.isFunction(d)){k("discarding unknown transition: ",g);a.fxs.splice(b,1);b--}}if(!a.fxs.length){k("No valid transitions named; slideshow terminating.");return false}}else if(a.fx=="all"){a.multiFx=true;a.fxs=[];for(p in f){d=f[p];f.hasOwnProperty(p)&&e.isFunction(d)&&a.fxs.push(p)}}if(a.multiFx&&a.randomizeEffects){d=Math.floor(Math.random()*20)+30;for(b=0;b<d;b++){f=Math.floor(Math.random()*a.fxs.length);a.fxs.push(a.fxs.splice(f,1)[0])}u("randomized fx sequence: ",a.fxs)}return true}function H(a,b){a.addSlide=function(d,f){d=e(d);var g=d[0];a.autostopCount||a.countdown++;b[f?"unshift":"push"](g);if(a.els)a.els[f?"unshift":"push"](g);a.slideCount= b.length;d.css("position","absolute");d[f?"prependTo":"appendTo"](a.$cont);if(f){a.currSlide++;a.nextSlide++}!e.support.opacity&&a.cleartype&&!a.cleartypeNoBg&&w(d);a.fit&&a.width&&d.width(a.width);a.fit&&a.height&&a.height!="auto"&&$slides.height(a.height);g.cycleH=a.fit&&a.height?a.height:d.height();g.cycleW=a.fit&&a.width?a.width:d.width();d.css(a.cssBefore);if(a.pager||a.pagerAnchorBuilder)e.fn.cycle.createPagerAnchor(b.length-1,g,e(a.pager),b,a);e.isFunction(a.onAddSlide)?a.onAddSlide(d):d.hide()}}function n(a,b,d,f){if(d&&b.busy&&b.manualTrump){e(a).stop(true,true);b.busy=false}if(!b.busy){var g=b.$cont[0],c=a[b.currSlide],h=a[b.nextSlide];if(!(g.cycleStop!=b.stopCount||g.cycleTimeout===0&&!d))if(!d&&!g.cyclePause&&(b.autostop&&--b.countdown<=0||b.nowrap&&!b.random&&b.nextSlide<b.currSlide))b.end&&b.end(b);else{if((d||!g.cyclePause)&&b.nextSlide!=b.currSlide){var i=b.fx;c.cycleH=c.cycleH||e(c).height();c.cycleW=c.cycleW||e(c).width();h.cycleH=h.cycleH||e(h).height();h.cycleW=h.cycleW||e(h).width();if(b.multiFx){if(b.lastFx==undefined||++b.lastFx>=b.fxs.length)b.lastFx=0;i=b.fxs[b.lastFx];b.currFx=i}if(b.oneTimeFx){i=b.oneTimeFx;b.oneTimeFx=null}e.fn.cycle.resetState(b,i);b.before.length&&e.each(b.before,function(l,m){g.cycleStop==b.stopCount&&m.apply(h,[c,h,b,f])});i=function(){e.each(b.after,function(l,m){g.cycleStop==b.stopCount&&m.apply(h,[c,h,b,f])})};b.busy=1;if(b.fxFn)b.fxFn(c,h,b,i,f);else e.isFunction(e.fn.cycle[b.fx])?e.fn.cycle[b.fx](c,h,b,i):e.fn.cycle.custom(c,h,b,i,d&&b.fastOnEvent);b.lastSlide=b.currSlide;if(b.random){b.currSlide=b.nextSlide;if(++b.randomIndex==a.length)b.randomIndex=0;b.nextSlide=b.randomMap[b.randomIndex]}else{d=b.nextSlide+1==a.length;b.nextSlide=d?0:b.nextSlide+1;b.currSlide=d?a.length-1:b.nextSlide-1}b.pager&&b.updateActivePagerLink(b.pager,b.currSlide,b.activePagerClass)}d=0;if(b.timeout&&!b.continuous)d=y(c,h,b,f);else if(b.continuous&&g.cyclePause)d=10;if(d>0)g.cycleTimeout=setTimeout(function(){n(a,b,0,!b.rev)},d)}}}function y(a,b,d,f){if(d.timeoutFn){for(a= d.timeoutFn(a,b,d,f);a-d.speed<250;)a+=d.speed;u("calculated timeout: "+a+"; speed: "+d.speed);if(a!==false)return a}return d.timeout}function t(a,b){var d=a.elements,f=a.$cont[0],g=f.cycleTimeout;if(g){clearTimeout(g);f.cycleTimeout=0}if(a.random&&b<0){a.randomIndex--;if(--a.randomIndex==-2)a.randomIndex=d.length-2;else if(a.randomIndex==-1)a.randomIndex=d.length-1;a.nextSlide=a.randomMap[a.randomIndex]}else if(a.random)a.nextSlide=a.randomMap[a.randomIndex];else{a.nextSlide=a.currSlide+b;if(a.nextSlide< 0){if(a.nowrap)return false;a.nextSlide=d.length-1}else if(a.nextSlide>=d.length){if(a.nowrap)return false;a.nextSlide=0}}e.isFunction(a.prevNextClick)&&a.prevNextClick(b>0,a.nextSlide,d[a.nextSlide]);n(d,a,1,b>=0);return false}function G(a,b){var d=e(b.pager);e.each(a,function(f,g){e.fn.cycle.createPagerAnchor(f,g,d,a,b)});b.updateActivePagerLink(b.pager,b.startingSlide,b.activePagerClass)}function w(a){function b(f){f=parseInt(f).toString(16);return f.length<2?"0"+f:f}function d(f){for(;f&&f.nodeName.toLowerCase()!= "html";f=f.parentNode){var g=e.css(f,"background-color");if(g.indexOf("rgb")>=0){f=g.match(/\d+/g);return"#"+b(f[0])+b(f[1])+b(f[2])}if(g&&g!="transparent")return g}return"#ffffff"}a.each(function(){e(this).css("background-color",d(this))})}if(e.support==undefined)e.support={opacity:!e.browser.msie};e.fn.cycle=function(a,b){var d={s:this.selector,c:this.context};if(this.length===0&&a!="stop"){if(!e.isReady&&d.s){k("DOM not ready, queuing slideshow");e(function(){e(d.s,d.c).cycle(a,b)});return this}k("terminating; zero elements found by selector"+ (e.isReady?"":" (DOM not ready)"));return this}return this.each(function(){var f=z(this,a,b);if(f!==false){f.updateActivePagerLink=f.updateActivePagerLink||e.fn.cycle.updateActivePagerLink;this.cycleTimeout&&clearTimeout(this.cycleTimeout);this.cycleTimeout=this.cyclePause=0;var g=e(this),c=f.slideExpr?e(f.slideExpr,this):g.children(),h=c.get();if(h.length<2)k("terminating; too few slides: "+h.length);else{var i=B(g,c,h,f,d);if(i!==false)if(f=i.continuous?10:y(i.currSlide,i.nextSlide,i,!i.rev)){f+= i.delay||0;if(f<10)f=10;u("first timeout: "+f);this.cycleTimeout=setTimeout(function(){n(h,i,0,!i.rev)},f)}}}})};e.fn.cycle.resetState=function(a,b){b=b||a.fx;a.before=[];a.after=[];a.cssBefore=e.extend({},a.original.cssBefore);a.cssAfter=e.extend({},a.original.cssAfter);a.animIn=e.extend({},a.original.animIn);a.animOut=e.extend({},a.original.animOut);a.fxFn=null;e.each(a.original.before,function(){a.before.push(this)});e.each(a.original.after,function(){a.after.push(this)});b=e.fn.cycle.transitions[b];e.isFunction(b)&&b(a.$cont,e(a.elements),a)};e.fn.cycle.updateActivePagerLink=function(a,b,d){e(a).each(function(){e(this).find("a").removeClass(d).filter("a:eq("+b+")").addClass(d)})};e.fn.cycle.next=function(a){t(a,a.rev?-1:1)};e.fn.cycle.prev=function(a){t(a,a.rev?1:-1)};e.fn.cycle.createPagerAnchor=function(a,b,d,f,g){if(b=e.isFunction(g.pagerAnchorBuilder)?g.pagerAnchorBuilder(a,b):'<a href="#">'+(a+1)+"</a>"){var c=e(b);if(c.parents("body").length===0){var h=[];if(d.length>1){d.each(function(){var i= c.clone(true);e(this).append(i);h.push(i[0])});c=e(h)}else c.appendTo(d)}g.pagerAnchors=g.pagerAnchors||[];g.pagerAnchors.push(c);c.bind(g.pagerEvent,function(i){i.preventDefault();g.nextSlide=a;i=g.$cont[0];var l=i.cycleTimeout;if(l){clearTimeout(l);i.cycleTimeout=0}e.isFunction(g.pagerClick)&&g.pagerClick(g.nextSlide,f[g.nextSlide]);n(f,g,1,g.currSlide<a)});!/^click/.test(g.pagerEvent)&&!g.allowPagerClickBubble&&c.bind("click.cycle",function(){return false});g.pauseOnPagerHover&&c.hover(function(){g.$cont[0].cyclePause++}, function(){g.$cont[0].cyclePause--})}};e.fn.cycle.hopsFromLast=function(a,b){var d=a.lastSlide,f=a.currSlide;return b?f>d?f-d:a.slideCount-d:f<d?d-f:d+a.slideCount-f};e.fn.cycle.commonReset=function(a,b,d,f,g,c){e(d.elements).not(a).hide();d.cssBefore.opacity=1;d.cssBefore.display="block";if(f!==false&&b.cycleW>0)d.cssBefore.width=b.cycleW;if(g!==false&&b.cycleH>0)d.cssBefore.height=b.cycleH;d.cssAfter=d.cssAfter||{};d.cssAfter.display="none";e(a).css("zIndex",d.slideCount+(c===true?1:0));e(b).css("zIndex", d.slideCount+(c===true?0:1))};e.fn.cycle.custom=function(a,b,d,f,g){var c=e(a),h=e(b),i=d.speedIn;a=d.speedOut;var l=d.easeIn;b=d.easeOut;h.css(d.cssBefore);if(g){i=typeof g=="number"?(a=g):(a=1);l=b=null}var m=function(){h.animate(d.animIn,i,l,f)};c.animate(d.animOut,a,b,function(){d.cssAfter&&c.css(d.cssAfter);d.sync||m()});d.sync&&m()};e.fn.cycle.transitions={fade:function(a,b,d){b.not(":eq("+d.currSlide+")").css("opacity",0);d.before.push(function(f,g,c){e.fn.cycle.commonReset(f,g,c);c.cssBefore.opacity= 0});d.animIn={opacity:1};d.animOut={opacity:0};d.cssBefore={top:0,left:0}}};e.fn.cycle.ver=function(){return"2.80"};e.fn.cycle.defaults={fx:"fade",timeout:4E3,timeoutFn:null,continuous:0,speed:1E3,speedIn:null,speedOut:null,next:null,prev:null,prevNextClick:null,prevNextEvent:"click.cycle",pager:null,pagerClick:null,pagerEvent:"click.cycle",allowPagerClickBubble:false,pagerAnchorBuilder:null,before:null,after:null,end:null,easing:null,easeIn:null,easeOut:null,shuffle:null,animIn:null,animOut:null, cssBefore:null,cssAfter:null,fxFn:null,height:"auto",startingSlide:0,sync:1,random:0,fit:0,containerResize:1,pause:0,pauseOnPagerHover:0,autostop:0,autostopCount:0,delay:0,slideExpr:null,cleartype:!e.support.opacity,cleartypeNoBg:false,nowrap:0,fastOnEvent:0,randomizeEffects:1,rev:0,manualTrump:true,requeueOnImageNotLoaded:true,requeueTimeout:250,activePagerClass:"activeSlide",updateActivePagerLink:null}})(jQuery);
(function($){$.fn.jCarouselLite=function(o){o=$.extend({btnPrev:null,btnNext:null,btnGo:null,mouseWheel:false,auto:null,speed:200,easing:null,vertical:false,circular:true,visible:3,start:0,scroll:1,beforeStart:null,afterEnd:null},o||{});return this.each(function(){var b=false,animCss=o.vertical?"top":"left",sizeCss=o.vertical?"height":"width";var c=$(this),ul=$("ul",c),tLi=$("li",ul),tl=tLi.size(),v=o.visible;if(o.circular){ul.prepend(tLi.slice(tl-v-1+1).clone()).append(tLi.slice(0,v).clone());o.start+=v}var f=$("li",ul),itemLength=f.size(),curr=o.start;c.css("visibility","visible");f.css({overflow:"hidden",float:o.vertical?"none":"left"});ul.css({margin:"0",padding:"0",position:"relative","list-style-type":"none","z-index":"1"});c.css({overflow:"hidden",position:"relative","z-index":"2",left:"0px"});var g=o.vertical?height(f):width(f);var h=g*itemLength;var j=g*v;f.css({width:f.width(),height:f.height()});ul.css(sizeCss,h+"px").css(animCss,-(curr*g));c.css(sizeCss,j+"px");if(o.btnPrev)$(o.btnPrev).click(function(){return go(curr-o.scroll)});if(o.btnNext)$(o.btnNext).click(function(){return go(curr+o.scroll)});if(o.btnGo)$.each(o.btnGo,function(i,a){$(a).click(function(){return go(o.circular?o.visible+i:i)})});if(o.mouseWheel&&c.mousewheel)c.mousewheel(function(e,d){return d>0?go(curr-o.scroll):go(curr+o.scroll)});if(o.auto)setInterval(function(){go(curr+o.scroll)},o.auto+o.speed);function vis(){return f.slice(curr).slice(0,v)};function go(a){if(!b){if(o.beforeStart)o.beforeStart.call(this,vis());if(o.circular){if(a<=o.start-v-1){ul.css(animCss,-((itemLength-(v*2))*g)+"px");curr=a==o.start-v-1?itemLength-(v*2)-1:itemLength-(v*2)-o.scroll}else if(a>=itemLength-v+1){ul.css(animCss,-((v)*g)+"px");curr=a==itemLength-v+1?v+1:v+o.scroll}else curr=a}else{if(a<0||a>itemLength-v)return;else curr=a}b=true;ul.animate(animCss=="left"?{left:-(curr*g)}:{top:-(curr*g)},o.speed,o.easing,function(){if(o.afterEnd)o.afterEnd.call(this,vis());b=false});if(!o.circular){$(o.btnPrev+","+o.btnNext).removeClass("disabled");$((curr-o.scroll<0&&o.btnPrev)||(curr+o.scroll>itemLength-v&&o.btnNext)||[]).addClass("disabled")}}return false}})};function css(a,b){return parseInt($.css(a[0],b))||0};function width(a){return a[0].offsetWidth+css(a,'marginLeft')+css(a,'marginRight')};function height(a){return a[0].offsetHeight+css(a,'marginTop')+css(a,'marginBottom')}})(jQuery);
(function(c){function r(b,d){d=d==="x"?m.width():m.height();return typeof b==="string"?Math.round(b.match(/%/)?d/100*parseInt(b,10):parseInt(b,10)):b}function M(b){b=c.isFunction(b)?b.call(i):b;return a.photo||b.match(/\.(gif|png|jpg|jpeg|bmp)(?:\?([^#]*))?(?:#(\.*))?$/i)}function Y(){for(var b in a)if(c.isFunction(a[b])&&b.substring(0,2)!=="on")a[b]=a[b].call(i);a.rel=a.rel||i.rel;a.href=a.href||i.href;a.title=a.title||i.title}function Z(b){i=b;a=c(i).data(q);Y();if(a.rel&&a.rel!=="nofollow"){g= c(".cboxElement").filter(function(){return(c(this).data(q).rel||this.rel)===a.rel});j=g.index(i);if(j<0){g=g.add(i);j=g.length-1}}else{g=c(i);j=0}if(!B){C=B=n;N=i;N.blur();c(document).bind("keydown.cbox_close",function(d){if(d.keyCode===27){d.preventDefault();e.close()}}).bind("keydown.cbox_arrows",function(d){if(g.length>1)if(d.keyCode===37){d.preventDefault();D.click()}else if(d.keyCode===39){d.preventDefault();E.click()}});a.overlayClose&&s.css({cursor:"pointer"}).one("click",e.close);c.event.trigger(aa);a.onOpen&&a.onOpen.call(i);s.css({opacity:a.opacity}).show();a.w=r(a.initialWidth,"x");a.h=r(a.initialHeight,"y");e.position(0);O&&m.bind("resize.cboxie6 scroll.cboxie6",function(){s.css({width:m.width(),height:m.height(),top:m.scrollTop(),left:m.scrollLeft()})}).trigger("scroll.cboxie6")}P.add(D).add(E).add(t).add(Q).hide();R.html(a.close).show();e.slideshow();e.load()}var q="colorbox",F="hover",n=true,e,x=!c.support.opacity,O=x&&!window.XMLHttpRequest,aa="cbox_open",H="cbox_load",S="cbox_complete", T="resize.cbox_resize",s,k,u,p,U,V,W,X,g,m,l,I,J,K,Q,P,t,E,D,R,y,z,v,w,i,N,j,a,B,C,$={transition:"elastic",speed:350,width:false,height:false,innerWidth:false,innerHeight:false,initialWidth:"400",initialHeight:"400",maxWidth:false,maxHeight:false,scalePhotos:n,scrolling:n,inline:false,html:false,iframe:false,photo:false,href:false,title:false,rel:false,opacity:0.9,preloading:n,current:"image {current} of {total}",previous:"previous",next:"next",close:"close",open:false,overlayClose:n,slideshow:false, slideshowAuto:n,slideshowSpeed:2500,slideshowStart:"start slideshow",slideshowStop:"stop slideshow",onOpen:false,onLoad:false,onComplete:false,onCleanup:false,onClosed:false};e=c.fn.colorbox=function(b,d){var h=this;if(!h.length)if(h.selector===""){h=c("<a/>");b.open=n}else return this;h.each(function(){var f=c.extend({},c(this).data(q)?c(this).data(q):$,b);c(this).data(q,f).addClass("cboxElement");if(d)c(this).data(q).onComplete=d});b&&b.open&&Z(h);return this};e.init=function(){function b(d){return c('<div id="cbox'+ d+'"/>')}m=c(window);k=c('<div id="colorbox"/>');s=b("Overlay").hide();u=b("Wrapper");p=b("Content").append(l=b("LoadedContent").css({width:0,height:0}),J=b("LoadingOverlay"),K=b("LoadingGraphic"),Q=b("Title"),P=b("Current"),t=b("Slideshow"),E=b("Next"),D=b("Previous"),R=b("Close"));u.append(c("<div/>").append(b("TopLeft"),U=b("TopCenter"),b("TopRight")),c("<div/>").append(V=b("MiddleLeft"),p,W=b("MiddleRight")),c("<div/>").append(b("BottomLeft"),X=b("BottomCenter"),b("BottomRight"))).children().children().css({"float":"left"});I=c("<div style='position:absolute; top:0; left:0; width:9999px; height:0;'/>");c("body").prepend(s,k.append(u,I));if(x){k.addClass("cboxIE");O&&s.css("position","absolute")}p.children().bind("mouseover mouseout",function(){c(this).toggleClass(F)}).addClass(F);y=U.height()+X.height()+p.outerHeight(n)-p.height();z=V.width()+W.width()+p.outerWidth(n)-p.width();v=l.outerHeight(n);w=l.outerWidth(n);k.css({"padding-bottom":y,"padding-right":z}).hide();E.click(e.next);D.click(e.prev);R.click(e.close);p.children().removeClass(F);c(".cboxElement").live("click",function(d){if(d.button!==0&&typeof d.button!=="undefined")return n;else{Z(this);return false}})};e.position=function(b,d){function h(A){U[0].style.width=X[0].style.width=p[0].style.width=A.style.width;K[0].style.height=J[0].style.height=p[0].style.height=V[0].style.height=W[0].style.height=A.style.height}var f=m.height();f=Math.max(f-a.h-v-y,0)/2+m.scrollTop();var o=Math.max(document.documentElement.clientWidth-a.w-w-z,0)/2+m.scrollLeft();b=k.width()===a.w+w&&k.height()=== a.h+v?0:b;u[0].style.width=u[0].style.height="9999px";k.dequeue().animate({width:a.w+w,height:a.h+v,top:f,left:o},{duration:b,complete:function(){h(this);C=false;u[0].style.width=a.w+w+z+"px";u[0].style.height=a.h+v+y+"px";d&&d()},step:function(){h(this)}})};e.resize=function(b){function d(){a.w=a.w||l.width();a.w=a.mw&&a.mw<a.w?a.mw:a.w;return a.w}function h(){a.h=a.h||l.height();a.h=a.mh&&a.mh<a.h?a.mh:a.h;return a.h}function f(G){e.position(G,function(){if(B){if(x){A&&l.fadeIn(100);k[0].style.removeAttribute("filter")}if(a.iframe)l.append("<iframe id='cboxIframe'"+ (a.scrolling?" ":"scrolling='no'")+" name='iframe_"+(new Date).getTime()+"' frameborder=0 src='"+a.href+"' "+(x?"allowtransparency='true'":"")+" />");l.show();Q.show().html(a.title);if(g.length>1){P.html(a.current.replace(/\{current\}/,j+1).replace(/\{total\}/,g.length)).show();E.html(a.next).show();D.html(a.previous).show();a.slideshow&&t.show()}J.hide();K.hide();c.event.trigger(S);a.onComplete&&a.onComplete.call(i);a.transition==="fade"&&k.fadeTo(L,1,function(){x&&k[0].style.removeAttribute("filter")});m.bind(T,function(){e.position(0)})}})}if(B){var o,A,L=a.transition==="none"?0:a.speed;m.unbind(T);if(b){l.remove();l=c('<div id="cboxLoadedContent"/>').html(b);l.hide().appendTo(I).css({width:d(),overflow:a.scrolling?"auto":"hidden"}).css({height:h()}).prependTo(p);c("#cboxPhoto").css({cssFloat:"none"});O&&c("select:not(#colorbox select)").filter(function(){return this.style.visibility!=="hidden"}).css({visibility:"hidden"}).one("cbox_cleanup",function(){this.style.visibility="inherit"});a.transition=== "fade"&&k.fadeTo(L,0,function(){f(0)})||f(L);if(a.preloading&&g.length>1){b=j>0?g[j-1]:g[g.length-1];o=j<g.length-1?g[j+1]:g[0];o=c(o).data(q).href||o.href;b=c(b).data(q).href||b.href;M(o)&&c("<img />").attr("src",o);M(b)&&c("<img />").attr("src",b)}}else setTimeout(function(){var G=l.wrapInner("<div style='overflow:auto'></div>").children();a.h=G.height();l.css({height:a.h});G.replaceWith(G.children());e.position(L)},1)}};e.load=function(){var b,d,h,f=e.resize;C=n;i=g[j];a=c(i).data(q);Y();c.event.trigger(H);a.onLoad&&a.onLoad.call(i);a.h=a.height?r(a.height,"y")-v-y:a.innerHeight?r(a.innerHeight,"y"):false;a.w=a.width?r(a.width,"x")-w-z:a.innerWidth?r(a.innerWidth,"x"):false;a.mw=a.w;a.mh=a.h;if(a.maxWidth){a.mw=r(a.maxWidth,"x")-w-z;a.mw=a.w&&a.w<a.mw?a.w:a.mw}if(a.maxHeight){a.mh=r(a.maxHeight,"y")-v-y;a.mh=a.h&&a.h<a.mh?a.h:a.mh}b=a.href;J.show();K.show();if(a.inline){c('<div id="cboxInlineTemp" />').hide().insertBefore(c(b)[0]).bind(H+" cbox_cleanup",function(){c(this).replaceWith(l.children())});f(c(b))}else if(a.iframe)f(" ");else if(a.html)f(a.html);else if(M(b)){d=new Image;d.onload=function(){var o;d.onload=null;d.id="cboxPhoto";c(d).css({margin:"auto",border:"none",display:"block",cssFloat:"left"});if(a.scalePhotos){h=function(){d.height-=d.height*o;d.width-=d.width*o};if(a.mw&&d.width>a.mw){o=(d.width-a.mw)/d.width;h()}if(a.mh&&d.height>a.mh){o=(d.height-a.mh)/d.height;h()}}if(a.h)d.style.marginTop=Math.max(a.h-d.height,0)/2+"px";f(d);g.length>1&&c(d).css({cursor:"pointer"}).click(e.next);if(x)d.style.msInterpolationMode="bicubic"};d.src=b}else c("<div />").appendTo(I).load(b,function(o,A){A==="success"?f(this):f(c("<p>Request unsuccessful.</p>"))})};e.next=function(){if(!C){j=j<g.length-1?j+1:0;e.load()}};e.prev=function(){if(!C){j=j>0?j-1:g.length-1;e.load()}};e.slideshow=function(){function b(){t.text(a.slideshowStop).bind(S,function(){h=setTimeout(e.next,a.slideshowSpeed)}).bind(H,function(){clearTimeout(h)}).one("click",function(){d();c(this).removeClass(F)});k.removeClass(f+ "off").addClass(f+"on")}var d,h,f="cboxSlideshow_";t.bind("cbox_closed",function(){t.unbind();clearTimeout(h);k.removeClass(f+"off "+f+"on")});d=function(){clearTimeout(h);t.text(a.slideshowStart).unbind(S+" "+H).one("click",function(){b();h=setTimeout(e.next,a.slideshowSpeed);c(this).removeClass(F)});k.removeClass(f+"on").addClass(f+"off")};if(a.slideshow&&g.length>1)a.slideshowAuto?b():d()};e.close=function(){c.event.trigger("cbox_cleanup");a.onCleanup&&a.onCleanup.call(i);B=false;c(document).unbind("keydown.cbox_close keydown.cbox_arrows");m.unbind(T+" resize.cboxie6 scroll.cboxie6");s.css({cursor:"auto"}).fadeOut("fast");k.stop(n,false).fadeOut("fast",function(){c("#colorbox iframe").attr("src","about:blank");l.remove();k.css({opacity:1});try{N.focus()}catch(b){}c.event.trigger("cbox_closed");a.onClosed&&a.onClosed.call(i)})};e.element=function(){return c(i)};e.settings=$;c(e.init)})(jQuery);
(function(e){e.extend({metadata:{defaults:{type:"class",name:"metadata",cre:/({.*})/,single:"metadata"},setType:function(b,a){this.defaults.type=b;this.defaults.name=a},get:function(b,a){a=e.extend({},this.defaults,a);if(!a.single.length)a.single="metadata";var c=e.data(b,a.single);if(c)return c;c="{}";var h=function(d){if(typeof d!="string")return d;return d=eval("("+d+")")};if(a.type=="html5"){var g={};e(b.attributes).each(function(){var d=this.nodeName;if(d.match(/^data-/))d=d.replace(/^data-/, "");else return true;g[d]=h(this.nodeValue)})}else{if(a.type=="class"){var f=a.cre.exec(b.className);if(f)c=f[1]}else if(a.type=="elem"){if(!b.getElementsByTagName)return;f=b.getElementsByTagName(a.name);if(f.length)c=e.trim(f[0].innerHTML)}else if(b.getAttribute!=undefined)if(f=b.getAttribute(a.name))c=f;g=h(c.indexOf("{")<0?"{"+c+"}":c)}e.data(b,a.single,g);return g}}});e.fn.metadata=function(b){return e.metadata.get(this[0],b)}})(jQuery);
(function(e){function g(d){return d===undefined||d===""}jQuery.fn.autoclear=function(d){var b={defaultClass:"default",otherClass:"other",defaultValue:"",useDefaultOnReset:true,clearDefaultOnSubmit:true};if(arguments.length)switch(typeof d){case "string":b.defaultClass=d;break;case "object":b=jQuery.extend(b,d);break}this.filter("input:text,textarea").each(function(){var a=e(this),c=a.attr("title"),f=a.val(),h=a.closest("form");if(g(c))c=f===""?b.defaultValue:f;a.data("default.autoclear",c);h.bind("reset", function(){b.useDefaultOnReset?a.trigger("default"):a.val(a.attr("defaultValue")).trigger("blur")});if(b.useDefaultOnReset||g(jQuery.trim(a.attr("defaultValue"))))a.attr("defaultValue",c).val(f);b.clearDefaultOnSubmit&&h.bind("submit",function(){a.trigger("focus")})}).bind({"focus.autoclear":function(){var a=e(this);a.val()==a.data("default.autoclear")&&a.val("").trigger("other")},"blur.autoclear":function(){var a=e(this),c=jQuery.trim(a.val());c===a.data("default.autoclear")||c===""?a.trigger("default"): a.trigger("other")},"default.autoclear":function(){var a=e(this);a.val(a.data("default.autoclear")).removeClass(b.otherClass).addClass(b.defaultClass)},"other.autoclear":function(){e(this).removeClass(b.defaultClass).addClass(b.otherClass)}}).trigger("blur");return this}})(jQuery);
(function(b){function o(){if(b.fn.ajaxSubmit.debug){var a="[jquery.form] "+Array.prototype.join.call(arguments,"");if(window.console&&window.console.log)window.console.log(a);else window.opera&&window.opera.postError&&window.opera.postError(a)}}b.fn.ajaxSubmit=function(a){function e(){function s(){var q=h.attr("target"),n=h.attr("action");k.setAttribute("target",z);k.getAttribute("method")!="POST"&&k.setAttribute("method","POST");k.getAttribute("action")!=g.url&&k.setAttribute("action",g.url);g.skipEncodingOverride|| h.attr({encoding:"multipart/form-data",enctype:"multipart/form-data"});g.timeout&&setTimeout(function(){C=true;t()},g.timeout);var m=[];try{if(g.extraData)for(var v in g.extraData)m.push(b('<input type="hidden" name="'+v+'" value="'+g.extraData[v]+'" />').appendTo(k)[0]);u.appendTo("body");u.data("form-plugin-onload",t);k.submit()}finally{k.setAttribute("action",n);q?k.setAttribute("target",q):h.removeAttr("target");b(m).remove()}}function t(){if(!D){var q=true;try{if(C)throw"timeout";var n,m;m=w.contentWindow? w.contentWindow.document:w.contentDocument?w.contentDocument:w.document;var v=g.dataType=="xml"||m.XMLDocument||b.isXMLDoc(m);o("isXml="+v);if(!v&&(m.body==null||m.body.innerHTML=="")){if(--G){o("requeing onLoad callback, DOM not available");setTimeout(t,250);return}o("Could not access iframe DOM after 100 tries.");return}o("response detected");D=true;j.responseText=m.body?m.body.innerHTML:null;j.responseXML=m.XMLDocument?m.XMLDocument:m;j.getResponseHeader=function(H){return{"content-type":g.dataType}[H]}; if(g.dataType=="json"||g.dataType=="script"){var E=m.getElementsByTagName("textarea")[0];if(E)j.responseText=E.value;else{var F=m.getElementsByTagName("pre")[0];if(F)j.responseText=F.innerHTML}}else if(g.dataType=="xml"&&!j.responseXML&&j.responseText!=null)j.responseXML=A(j.responseText);n=b.httpData(j,g.dataType)}catch(B){o("error caught:",B);q=false;j.error=B;b.handleError(g,j,"error",B)}if(q){g.success(n,"success");x&&b.event.trigger("ajaxSuccess",[j,g])}x&&b.event.trigger("ajaxComplete",[j,g]); x&&!--b.active&&b.event.trigger("ajaxStop");if(g.complete)g.complete(j,q?"success":"error");setTimeout(function(){u.removeData("form-plugin-onload");u.remove();j.responseXML=null},100)}}function A(q,n){if(window.ActiveXObject){n=new ActiveXObject("Microsoft.XMLDOM");n.async="false";n.loadXML(q)}else n=(new DOMParser).parseFromString(q,"text/xml");return n&&n.documentElement&&n.documentElement.tagName!="parsererror"?n:null}var k=h[0];if(b(":input[name=submit]",k).length)alert('Error: Form elements must not be named "submit".'); else{var g=b.extend({},b.ajaxSettings,a),r=b.extend(true,{},b.extend(true,{},b.ajaxSettings),g),z="jqFormIO"+(new Date).getTime(),u=b('<iframe id="'+z+'" name="'+z+'" src="'+g.iframeSrc+'" onload="(jQuery(this).data(\'form-plugin-onload\'))()" />'),w=u[0];u.css({position:"absolute",top:"-1000px",left:"-1000px"});var j={aborted:0,responseText:null,responseXML:null,status:0,statusText:"n/a",getAllResponseHeaders:function(){},getResponseHeader:function(){},setRequestHeader:function(){},abort:function(){this.aborted= 1;u.attr("src",g.iframeSrc)}},x=g.global;x&&!b.active++&&b.event.trigger("ajaxStart");x&&b.event.trigger("ajaxSend",[j,g]);if(r.beforeSend&&r.beforeSend(j,r)===false)r.global&&b.active--;else if(!j.aborted){var D=false,C=0;if(r=k.clk){var y=r.name;if(y&&!r.disabled){g.extraData=g.extraData||{};g.extraData[y]=r.value;if(r.type=="image"){g.extraData[y+".x"]=k.clk_x;g.extraData[y+".y"]=k.clk_y}}}g.forceSync?s():setTimeout(s,10);var G=100}}}if(!this.length){o("ajaxSubmit: skipping submit process - no element selected"); return this}if(typeof a=="function")a={success:a};var c=b.trim(this.attr("action"));if(c)c=(c.match(/^([^#]+)/)||[])[1];c=c||window.location.href||"";a=b.extend({url:c,type:this.attr("method")||"GET",iframeSrc:/^https/i.test(window.location.href||"")?"javascript:false":"about:blank"},a||{});c={};this.trigger("form-pre-serialize",[this,a,c]);if(c.veto){o("ajaxSubmit: submit vetoed via form-pre-serialize trigger");return this}if(a.beforeSerialize&&a.beforeSerialize(this,a)===false){o("ajaxSubmit: submit aborted via beforeSerialize callback"); return this}var f=this.formToArray(a.semantic);if(a.data){a.extraData=a.data;for(var d in a.data)if(a.data[d]instanceof Array)for(var l in a.data[d])f.push({name:d,value:a.data[d][l]});else f.push({name:d,value:a.data[d]})}if(a.beforeSubmit&&a.beforeSubmit(f,this,a)===false){o("ajaxSubmit: submit aborted via beforeSubmit callback");return this}this.trigger("form-submit-validate",[f,this,a,c]);if(c.veto){o("ajaxSubmit: submit vetoed via form-submit-validate trigger");return this}d=b.param(f);if(a.type.toUpperCase()== "GET"){a.url+=(a.url.indexOf("?")>=0?"&":"?")+d;a.data=null}else a.data=d;var h=this,i=[];a.resetForm&&i.push(function(){h.resetForm()});a.clearForm&&i.push(function(){h.clearForm()});if(!a.dataType&&a.target){var p=a.success||function(){};i.push(function(s){var t=a.replaceTarget?"replaceWith":"html";b(a.target)[t](s).each(p,arguments)})}else a.success&&i.push(a.success);a.success=function(s,t,A){for(var k=0,g=i.length;k<g;k++)i[k].apply(a,[s,t,A||h,h])};d=b("input:file",this).fieldValue();l=false; for(c=0;c<d.length;c++)if(d[c])l=true;if(d.length&&a.iframe!==false||a.iframe||l||0)a.closeKeepAlive?b.get(a.closeKeepAlive,e):e();else b.ajax(a);this.trigger("form-submit-notify",[this,a]);return this};b.fn.ajaxForm=function(a){return this.ajaxFormUnbind().bind("submit.form-plugin",function(e){e.preventDefault();b(this).ajaxSubmit(a)}).bind("click.form-plugin",function(e){var c=e.target,f=b(c);if(!f.is(":submit,input:image")){c=f.closest(":submit");if(c.length==0)return;c=c[0]}var d=this;d.clk=c; if(c.type=="image")if(e.offsetX!=undefined){d.clk_x=e.offsetX;d.clk_y=e.offsetY}else if(typeof b.fn.offset=="function"){f=f.offset();d.clk_x=e.pageX-f.left;d.clk_y=e.pageY-f.top}else{d.clk_x=e.pageX-c.offsetLeft;d.clk_y=e.pageY-c.offsetTop}setTimeout(function(){d.clk=d.clk_x=d.clk_y=null},100)})};b.fn.ajaxFormUnbind=function(){return this.unbind("submit.form-plugin click.form-plugin")};b.fn.formToArray=function(a){var e=[];if(this.length==0)return e;var c=this[0],f=a?c.getElementsByTagName("*"):c.elements; if(!f)return e;for(var d=0,l=f.length;d<l;d++){var h=f[d],i=h.name;if(i)if(a&&c.clk&&h.type=="image"){if(!h.disabled&&c.clk==h){e.push({name:i,value:b(h).val()});e.push({name:i+".x",value:c.clk_x},{name:i+".y",value:c.clk_y})}}else if((h=b.fieldValue(h,true))&&h.constructor==Array)for(var p=0,s=h.length;p<s;p++)e.push({name:i,value:h[p]});else h!==null&&typeof h!="undefined"&&e.push({name:i,value:h})}if(!a&&c.clk){a=b(c.clk);f=a[0];if((i=f.name)&&!f.disabled&&f.type=="image"){e.push({name:i,value:a.val()}); e.push({name:i+".x",value:c.clk_x},{name:i+".y",value:c.clk_y})}}return e};b.fn.formSerialize=function(a){return b.param(this.formToArray(a))};b.fn.fieldSerialize=function(a){var e=[];this.each(function(){var c=this.name;if(c){var f=b.fieldValue(this,a);if(f&&f.constructor==Array)for(var d=0,l=f.length;d<l;d++)e.push({name:c,value:f[d]});else f!==null&&typeof f!="undefined"&&e.push({name:this.name,value:f})}});return b.param(e)};b.fn.fieldValue=function(a){for(var e=[],c=0,f=this.length;c<f;c++){var d= b.fieldValue(this[c],a);d===null||typeof d=="undefined"||d.constructor==Array&&!d.length||(d.constructor==Array?b.merge(e,d):e.push(d))}return e};b.fieldValue=function(a,e){var c=a.name,f=a.type,d=a.tagName.toLowerCase();if(typeof e=="undefined")e=true;if(e&&(!c||a.disabled||f=="reset"||f=="button"||(f=="checkbox"||f=="radio")&&!a.checked||(f=="submit"||f=="image")&&a.form&&a.form.clk!=a||d=="select"&&a.selectedIndex==-1))return null;if(d=="select"){var l=a.selectedIndex;if(l<0)return null;c=[];d= a.options;var h=(f=f=="select-one")?l+1:d.length;for(l=f?l:0;l<h;l++){var i=d[l];if(i.selected){var p=i.value;p||(p=i.attributes&&i.attributes.value&&!i.attributes.value.specified?i.text:i.value);if(f)return p;c.push(p)}}return c}return a.value};b.fn.clearForm=function(){return this.each(function(){b("input,select,textarea",this).clearFields()})};b.fn.clearFields=b.fn.clearInputs=function(){return this.each(function(){var a=this.type,e=this.tagName.toLowerCase();if(a=="text"||a=="password"||e=="textarea")this.value= "";else if(a=="checkbox"||a=="radio")this.checked=false;else if(e=="select")this.selectedIndex=-1})};b.fn.resetForm=function(){return this.each(function(){if(typeof this.reset=="function"||typeof this.reset=="object"&&!this.reset.nodeType)this.reset()})};b.fn.enable=function(a){if(a==undefined)a=true;return this.each(function(){this.disabled=!a})};b.fn.selected=function(a){if(a==undefined)a=true;return this.each(function(){var e=this.type;if(e=="checkbox"||e=="radio")this.checked=a;else if(this.tagName.toLowerCase()== "option"){e=b(this).parent("select");a&&e[0]&&e[0].type=="select-one"&&e.find("option").selected(false);this.selected=a}})}})(jQuery);
(function(b){function q(c,a){var e=c==window,d=a&&a.message!==undefined?a.message:undefined;a=b.extend({},b.blockUI.defaults,a||{});a.overlayCSS=b.extend({},b.blockUI.defaults.overlayCSS,a.overlayCSS||{});var g=b.extend({},b.blockUI.defaults.css,a.css||{}),i=b.extend({},b.blockUI.defaults.themedCSS,a.themedCSS||{});d=d===undefined?a.message:d;e&&k&&n(window,{fadeOut:0});if(d&&typeof d!="string"&&(d.parentNode||d.jquery)){var h=d.jquery?d[0]:d,f={};b(c).data("blockUI.history",f);f.el=h;f.parent=h.parentNode; f.display=h.style.display;f.position=h.style.position;f.parent&&f.parent.removeChild(h)}f=a.baseZ;var l=b.browser.msie||a.forceIframe?b('<iframe class="blockUI" style="z-index:'+f++ +';display:none;border:none;margin:0;padding:0;position:absolute;width:100%;height:100%;top:0;left:0" src="'+a.iframeSrc+'"></iframe>'):b('<div class="blockUI" style="display:none"></div>');h=b('<div class="blockUI blockOverlay" style="z-index:'+f++ +';display:none;border:none;margin:0;padding:0;width:100%;height:100%;top:0;left:0"></div>'); f=b(a.theme&&e?'<div class="blockUI blockMsg blockPage ui-dialog ui-widget ui-corner-all" style="z-index:'+f+';display:none;position:fixed"><div class="ui-widget-header ui-dialog-titlebar blockTitle">'+(a.title||"&nbsp;")+'</div><div class="ui-widget-content ui-dialog-content"></div></div>':a.theme?'<div class="blockUI blockMsg blockElement ui-dialog ui-widget ui-corner-all" style="z-index:'+f+';display:none;position:absolute"><div class="ui-widget-header ui-dialog-titlebar blockTitle">'+(a.title|| "&nbsp;")+'</div><div class="ui-widget-content ui-dialog-content"></div></div>':e?'<div class="blockUI blockMsg blockPage" style="z-index:'+f+';display:none;position:fixed"></div>':'<div class="blockUI blockMsg blockElement" style="z-index:'+f+';display:none;position:absolute"></div>');if(d)if(a.theme){f.css(i);f.addClass("ui-widget-content")}else f.css(g);if(!a.applyPlatformOpacityRules||!(b.browser.mozilla&&/Linux/.test(navigator.platform)))h.css(a.overlayCSS);h.css("position",e?"fixed":"absolute"); if(b.browser.msie||a.forceIframe)l.css("opacity",0);g=[l,h,f];var y=e?b("body"):b(c);b.each(g,function(){this.appendTo(y)});a.theme&&a.draggable&&b.fn.draggable&&f.draggable({handle:".ui-dialog-titlebar",cancel:"li"});g=z&&(!b.boxModel||b("object,embed",e?null:c).length>0);if(r||g){e&&a.allowBodyStretch&&b.boxModel&&b("html,body").css("height","100%");if((r||!b.boxModel)&&!e){g=parseInt(b.css(c,"borderTopWidth"))||0;i=parseInt(b.css(c,"borderLeftWidth"))||0;var s=g?"(0 - "+g+")":0,t=i?"(0 - "+i+")": 0}b.each([l,h,f],function(A,B){var j=B[0].style;j.position="absolute";if(A<2){e?j.setExpression("height","Math.max(document.body.scrollHeight, document.body.offsetHeight) - (jQuery.boxModel?0:"+a.quirksmodeOffsetHack+') + "px"'):j.setExpression("height",'this.parentNode.offsetHeight + "px"');e?j.setExpression("width",'jQuery.boxModel && document.documentElement.clientWidth || document.body.clientWidth + "px"'):j.setExpression("width",'this.parentNode.offsetWidth + "px"');t&&j.setExpression("left", t);s&&j.setExpression("top",s)}else if(a.centerY){e&&j.setExpression("top",'(document.documentElement.clientHeight || document.body.clientHeight) / 2 - (this.offsetHeight / 2) + (blah = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"');j.marginTop=0}else if(!a.centerY&&e){var C="((document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "+(a.css&&a.css.top?parseInt(a.css.top):0)+') + "px"';j.setExpression("top", C)}})}if(d){a.theme?f.find(".ui-widget-content").append(d):f.append(d);if(d.jquery||d.nodeType)b(d).show()}if((b.browser.msie||a.forceIframe)&&a.showOverlay)l.show();if(a.fadeIn){g=a.onBlock?a.onBlock:o;l=a.showOverlay&&!d?g:o;g=d?g:o;a.showOverlay&&h._fadeIn(a.fadeIn,l);d&&f._fadeIn(a.fadeIn,g)}else{a.showOverlay&&h.show();d&&f.show();a.onBlock&&a.onBlock()}u(1,c,a);if(e){k=f[0];m=b(":input:enabled:visible",k);a.focusInput&&setTimeout(v,20)}else D(f[0],a.centerX,a.centerY);if(a.timeout){d=setTimeout(function(){e? b.unblockUI(a):b(c).unblock(a)},a.timeout);b(c).data("blockUI.timeout",d)}}function n(c,a){var e=c==window,d=b(c),g=d.data("blockUI.history"),i=d.data("blockUI.timeout");if(i){clearTimeout(i);d.removeData("blockUI.timeout")}a=b.extend({},b.blockUI.defaults,a||{});u(0,c,a);var h;h=e?b("body").children().filter(".blockUI").add("body > .blockUI"):b(".blockUI",c);if(e)k=m=null;if(a.fadeOut){h.fadeOut(a.fadeOut);setTimeout(function(){w(h,g,a,c)},a.fadeOut)}else w(h,g,a,c)}function w(c,a,e,d){c.each(function(){this.parentNode&& this.parentNode.removeChild(this)});if(a&&a.el){a.el.style.display=a.display;a.el.style.position=a.position;a.parent&&a.parent.appendChild(a.el);b(d).removeData("blockUI.history")}typeof e.onUnblock=="function"&&e.onUnblock(d,e)}function u(c,a,e){var d=a==window;a=b(a);if(!(!c&&(d&&!k||!d&&!a.data("blockUI.isBlocked")))){d||a.data("blockUI.isBlocked",c);!e.bindEvents||c&&!e.showOverlay||(c?b(document).bind("mousedown mouseup keydown keypress",e,x):b(document).unbind("mousedown mouseup keydown keypress", x))}}function x(c){if(c.keyCode&&c.keyCode==9)if(k&&c.data.constrainTabKey){var a=m,e=c.shiftKey&&c.target==a[0];if(!c.shiftKey&&c.target==a[a.length-1]||e){setTimeout(function(){v(e)},10);return false}}if(b(c.target).parents("div.blockMsg").length>0)return true;return b(c.target).parents().children().filter("div.blockUI").length==0}function v(c){if(m)(c=m[c===true?m.length-1:0])&&c.focus()}function D(c,a,e){var d=c.parentNode,g=c.style,i=(d.offsetWidth-c.offsetWidth)/2-(parseInt(b.css(d,"borderLeftWidth"))|| 0);c=(d.offsetHeight-c.offsetHeight)/2-(parseInt(b.css(d,"borderTopWidth"))||0);if(a)g.left=i>0?i+"px":"0";if(e)g.top=c>0?c+"px":"0"}if(/1\.(0|1|2)\.(0|1|2)/.test(b.fn.jquery)||/^1.1/.test(b.fn.jquery))alert("blockUI requires jQuery v1.2.3 or later! You are using v"+b.fn.jquery);else{b.fn._fadeIn=b.fn.fadeIn;var o=function(){},p=document.documentMode||0,z=b.browser.msie&&(b.browser.version<8&&!p||p<8),r=b.browser.msie&&/MSIE 6.0/.test(navigator.userAgent)&&!p;b.blockUI=function(c){q(window,c)};b.unblockUI= function(c){n(window,c)};b.growlUI=function(c,a,e,d){var g=b('<div class="growlUI"></div>');c&&g.append("<h1>"+c+"</h1>");a&&g.append("<h2>"+a+"</h2>");if(e==undefined)e=3E3;b.blockUI({message:g,fadeIn:700,fadeOut:1E3,centerY:false,timeout:e,showOverlay:false,onUnblock:d,css:b.blockUI.defaults.growlCSS})};b.fn.block=function(c){return this.unblock({fadeOut:0}).each(function(){if(b.css(this,"position")=="static")this.style.position="relative";if(b.browser.msie)this.style.zoom=1;q(this,c)})};b.fn.unblock= function(c){return this.each(function(){n(this,c)})};b.blockUI.version=2.33;b.blockUI.defaults={message:"<h1>Please wait...</h1>",title:null,draggable:true,theme:false,css:{padding:0,margin:0,width:"30%",top:"40%",left:"35%",textAlign:"center",color:"#000",border:"3px solid #aaa",backgroundColor:"#fff",cursor:"wait"},themedCSS:{width:"30%",top:"40%",left:"35%"},overlayCSS:{backgroundColor:"#000",opacity:0.6,cursor:"wait"},growlCSS:{width:"350px",top:"10px",left:"",right:"10px",border:"none",padding:"5px", opacity:0.6,cursor:"default",color:"#fff",backgroundColor:"#000","-webkit-border-radius":"10px","-moz-border-radius":"10px","border-radius":"10px"},iframeSrc:/^https/i.test(window.location.href||"")?"javascript:false":"about:blank",forceIframe:false,baseZ:1E3,centerX:true,centerY:true,allowBodyStretch:true,bindEvents:true,constrainTabKey:true,fadeIn:200,fadeOut:400,timeout:0,showOverlay:true,focusInput:true,applyPlatformOpacityRules:true,onBlock:null,onUnblock:null,quirksmodeOffsetHack:4};var k=null, m=[]}})(jQuery);

function openMsc()
{
    var url = '/booking.html';
    var height = 750;
    var width = 850;
    var left = Math.floor((screen.width - width) / 2);
    var top = Math.floor((screen.height - height) / 2);
    var winParams = "top=" + top + ",left=" + left + ",height=" + height + ",width=" + width;
    window.open(url, 'mscbooking', winParams).focus();
}

function addCommas(nStr)
{
    nStr += '';
    x = nStr.split('.');
    x1 = x[0];
    x2 = x.length > 1 ? '.' + x[1] : '';
    var rgx = /(\d+)(\d{3})/;
    while (rgx.test(x1)) {
            x1 = x1.replace(rgx, '$1' + '.' + '$2');
    }
    return x1 + x2;
}

function updateTotalBar()
{
    $('.totale-1')
        .css('position','')
        .css('bottom', '');

    totalPosition  = $('.totale-1').position();

    $(window).scroll();
}

function updateCruiseBooking()
{
    if ( !$('#cruise-booking').length )
    {
        return;
    }

    var total = 0;

    $('#cruise-booking input:radio:checked:not([name=cabin]), #cruise-booking input:checkbox:checked').each(function() {
        var $this = $(this);

        total += parseFloat(
            $('.price', $this.parents('p:first')).text()
                .replace('.', '')
                .replace(',', '.'),
            10
        );
    });

    $('.total').text(
        addCommas(
            total
                .toFixed(2)
                .replace('.', ',')
        )
    );
    $('.deposit').text(
        addCommas(
            (total.toFixed(2) * (MSC_DEPOSIT / 100))
                .toFixed(2)
                .replace('.', ',')
        )
    );
}

function fetchCabins()
{
    var $this     = $(this);
    var id        = $this.attr('id') + '_cabins';
    var container = $this.parents('p:first');

    $('.accomodation input:radio:not([name=cabin]), input:submit[name=step-2]').attr('disabled', 'disabled');
    container.addClass('loading');
    $('.cabin-info').remove();
    updateTotalBar();

    $.getJSON(BASEURL + '/crociere/cabine', $this.metadata(), function(response) {
        if ( response.errors.length )
        {
            container.append($('<span />', {'id': id, 'class': 'cabin-info cabin-info_error', 'text': 'impossibile recuperare le cabine disponibili, la sessione potrebbe essere scaduta. sarai reindirizzato alla pagina di prenotazione entro 5 secondi.'}));

            setTimeout(function() {document.location.href = document.location.pathname + document.location.search;}, 5000);

            return;
        }

        var cabins = $('<ul />', {'id': id, 'class': 'cabin-info'});

        $.each(response.data.cabins, function() {
            var cabin = $('<li />');
            var cabinId = $this.attr('id') + '_cabin_' + this.id;

            cabin.append($('<input type="radio" class="campi-radio" name="cabin" />').attr('id', cabinId).val(this.id));

            if ( this.id == 'G00000' )
            {
                cabin.append($('<label type="radio" name="cabin" />').attr('for', cabinId).text('cabina garantita - il numero ti verrà indicato alcuni giorni prima dell\'imbarco'));
            }
            else
            {
                cabin.append(
                    $('<label type="radio" name="cabin" />')
                        .attr('for', cabinId)
                        .text('n° ' + this.id + ' - ')
                        .append(
                            $('<a />')
                                .attr('href', BASEURL + '/images/decks/' + $this.metadata().s.toLowerCase() + '/' + this.deck_code.toLowerCase() + '.gif')
                                .attr('title', 'ponte "' + this.deck_name + '"')
                                .text('ponte "' + this.deck_name + '"')
                                .colorbox({maxHeight: '95%', maxWidth: '95%', scalePhotos: false})
                        )
                );

                    if ( this.physically_challenged )
                    {
                        cabin.addClass('phisically_challenged');
                    }
            }

            cabins.append(cabin);
        });

        $('.cabin-info').remove();
        cabins.find('input:radio:first').attr('checked', 'checked');
        container.append(cabins);
        $('.accomodation input:radio:not([name=cabin]), input:submit[name=step-2]').removeAttr('disabled');
        container.removeClass('loading');
        updateTotalBar();
    });
}

function updateServices(e)
{
    if ( $('#cruise-booking').length )
    {
        return;
    }

    if ( e )
    {
        var _this = $(this);

        if ( isNaN(String.fromCharCode(e.which)) )
        {
            _this.val((_this.val().match(/(\d+)/g) || []).join(''));
        }
    }

    var customerFilters = [];
    var totalCustomerFilters = 0;
    var total = 0;

    $('.customer').each(function() {
        var _this = $(this);
        var categoryId = _this.attr('id').replace('customer_', '');

        customerFilters[categoryId] = parseInt(_this.val(), 10);

        if ( isNaN(customerFilters[categoryId]) )
        {
            customerFilters[categoryId] = 0;
        }

        totalCustomerFilters += customerFilters[categoryId];
    });
    $('.service').each(function() {
        var _this = $(this);
        var check = true;
        var quantity = 0;
        var subtotal = 0;

        $.each(_this.metadata().filters, function(id, value) {
            var min = value.split('-')[0];
            var max = value.split('-')[1];

            if ( !(
                (
                    id == 0 &&
                    (min == 0 || totalCustomerFilters >= min) &&
                    (max == 0 || totalCustomerFilters <= max)
                ) ||
                (
                    id > 0 &&
                    typeof customerFilters[id] != 'undefined' &&
                    (min == 0 || customerFilters[id] >= min) &&
                    (max == 0 || customerFilters[id] <= max)
                )
            ) )
            {
                _this.addClass('disattivo');
                $('input:radio', _this).attr('disabled', 'disabled');
                check = false;

                return false;
            }
        });
        if ( check )
        {
            _this.removeClass('disattivo');
            $('input:radio', _this).removeAttr('disabled');

            if ( _this.is('.ad_personam') )
            {
                var category = _this.metadata().category;

                if ( category == 0 )
                {
                    $('.customer').each(function() {
                        var subquantity = parseInt($(this).val(), 10);

                        if ( isNaN(subquantity) )
                        {
                            subquantity = 0;
                        }

                        quantity += subquantity;
                    });
                }
                else
                {
                    quantity = parseInt($('#customer_' + category).val(), 10);

                    if ( isNaN(quantity) )
                    {
                        quantity = 0;
                    }
                }
            }
            else
            {
                quantity = 1;
            }
        }

        subtotal = quantity * parseFloat(
            $('#' + _this.attr('id') + ' input[name=services\[' + (_this.attr('id').replace('service_', '')) + '\]]:checked').parent().find('.price').text()
                .replace('.', '')
                .replace(',', '.')
            , 10
        );

        if ( isNaN(subtotal) )
        {
            quantity = 0;
        }

        total += subtotal;

        if ( quantity == 0 )
        {
            _this.addClass('disattivo');
            $('input:radio', _this).attr('disabled', 'disabled');
        }

        $('.quantity', _this).text(quantity);
        $('.partial-total', _this).text(addCommas(
            subtotal
                .toFixed(2)
                .replace('.', ',')
        ));
    });
    $('.total').text(addCommas(
        total
            .toFixed(2)
            .replace('.', ',')
    ));
}

var totalPosition = 0;

$(function(){
    $.getScript('http://browser-update.org/update.js');

    /*$('#cerca').defaultValue('cerca…');
    $('#username').defaultValue('username…');
    $('#password').defaultValue('password…');*/
    $('#news-nome,#news-email').autoclear();

    $("#slider-offerte:not(.no-js)").jCarouselLite({
        btnNext: "#nextBtn2",
        btnPrev: "#prevBtn2",
        auto: 5000,
        speed: 500,
        circular: true,
        visible: 3,
        scroll: 1
    });

    $("#slider-offerte-estero:not(.no-js)").jCarouselLite({
        btnNext: "#nextBtn2-es",
        btnPrev: "#prevBtn2-es",
        auto: 5000,
        speed: 500,
        circular: true,
        visible: 3,
        scroll: 1
    });

    if ( $('.totale-1').length && $('#cruise-booking').length )
    {
        totalPosition  = $('.totale-1').position();

        $(window).scroll(function() {
            var viewportHeight = $(window).height();
            var scrollTop      = $(window).scrollTop();

            if ( totalPosition.top - viewportHeight > scrollTop )
            {
                $('.totale-1')
                    .css('position','fixed')
                    .css('bottom', 0)
                    .css('width', '593px');
            }
            else
            {
                $('.totale-1')
                    .css('position','')
                    .css('bottom', '')
                    .css('width', 'auto');
            }
        });

        $('#cruise-activities-handler').css('cursor', 'pointer');
        $('#cruise-activities-handler').click(function()
        {
            var $this = $(this);

            if ( !$this.hasClass('open') )
            {
                $this.addClass('open');
                $('#cruise-activities').show();
            }
            else
            {
                $this.removeClass('open');
                $('#cruise-activities').hide();
            }

            updateTotalBar();
        });
        $('#cruise-activities-handler').click();
    }

    updateCruiseBooking();
    updateServices();
    $('#cruise-booking input:radio:not([name=cabin]), #cruise-booking input:checkbox').live('click', updateCruiseBooking);
    $('.accomodation input:radio:not([name=cabin])').live('click', fetchCabins);
    $('.accomodation input:radio:not([name=cabin]):first').click();
    $('.customer').live('keyup', updateServices);
    $('.service input:radio').live('click', updateServices);

    $('a[rel=external]').click(function() {
        window.open($(this).attr('href'));

        return false;
    });

    $('#nation').change(function() {
        if ( $(this).val() == 82 )
        {
            $('#city-field').show();
        }
        else
        {
            $('#city-field').hide();
        }
    });
    $('#nation').change();

    $('#children').keyup(function() {
        var childrenField = $('#children_field');
        var children      = parseInt($(this).val(), 10);
        var maxChildren   = 20;

        if( isNaN(children) )
        {
            for ( var i = 1; i <= maxChildren; i++ )
            {
                $('#child_age_field_' + i).remove();
            }
        }
        else
        {
            children = Math.min(Math.max(children, 0), maxChildren);

            for ( var i = 1; i <= children; i ++ )
            {
                if ( !$('#child_age_field_' + i).length )
                {
                    var childAgeField = $(
                        '<p class="flottante-c" id="child_age_field_' + i + '">' +
                            '<label for="child_age_' + i + '" class="generica">età bambino ' + i + '*:</label>' +
                            '<input id="child_age_' + i + '" name="child_age_' + i + '" type="text" class="lungo" value="0" size="" />' +
                        '</p>'
                    );

                    if ( i == 1 )
                    {
                        childAgeField.insertAfter(childrenField);
                    }
                    else
                    {
                        childAgeField.insertAfter($('#child_age_field_' + (i - 1)));
                    }
                }
            }

            for ( var i = children + 1; i <= maxChildren; i++ )
            {
                $('#child_age_field_' + i).remove();
            }
        }
    });

    /*$('#cruise-form').submit(function()
    {
        setTimeout(
            function()
            {
                var loader = $(
                    '<div id="cruise-loader-wrapper">' +
                        '<div id="cruise-loader">' +
                            '<img src="' + BASEURL + '/images/nav.jpg" />' +
                            '<div id="loader">' +
                                '<img src="' + BASEURL + '/images/loader.gif"  />' +
                            '</div>' +
                            '<p>stiamo processando la tua richiesta</p>' +
                        '</div>' +
                    '</div>'
                );

                $('#wrapper').addClass('hide');
                $('#wrapper').after(loader);

                $(window).resize();
            },
            2000
        );
    });*/

    $('#payment-form').submit();

    /**
     * sorting form start
     */
    var sort = $('#sort');
    var form = sort.parents('form:first');
    $('input:submit', form).remove();
    sort.change(function() {
        form.submit();
    });
    /**
     * sorting form end
     */

    $('#send-to').dialog({
        autoOpen: false,
        buttons: {
            'Invia messaggio': function() {
                $this = $(this).parents('.ui-dialog');

                $('#send-to form').ajaxSubmit({
                    beforeSubmit: function() {
                        $('#send-to .errore').text('');
                        $this.block({message: null});
                    },
                    success: function(response) {
                        switch ( response.status )
                        {
                            case 'fail':console.log('test');
                                $.each(response.errors, function(name, message) {
                                    $('#st_' + name + '_label').text(message);
                                });
                            break;
                            case 'success':
                                $('#send-to .errore').text('');
                                $('#send-to').dialog('close');
                            break;
                        }

                        var dialog = $('<div />');
                        dialog.text(response.message);
                        dialog.dialog({
                            buttons: {
                                 'Ok': function() {$(this).dialog('close');}
                            },
                            modal: true,
                            resizable: false,
                            title: 'Invia a un amico'
                        });
                    },
                    complete: function() {
                        $this.unblock();
                    }
                });
            }
        },
        resizable: false,
        title: 'Invia a un amico',
        width: '600px'
    });
    $('#send-to-button').click(function() {
        $('#send-to').dialog('open');

        return false;
    });
    
    $('.ui-tabs').tabs({'fx': {'opacity': 'toggle'}});

    $('a[rel=gallery]').colorbox({maxHeight: '95%', maxWidth: '95%'});
});
