window.log = function(){
  log.history = log.history || [];  
  log.history.push(arguments);
  arguments.callee = arguments.callee.caller;  
  if(this.console) console.log( Array.prototype.slice.call(arguments) );
};
(function(b){function c(){}for(var d="assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,markTimeline,profile,profileEnd,time,timeEnd,trace,warn".split(","),a;a=d.pop();)b[a]=b[a]||c})(window.console=window.console||{});

/*
* Slides, A Slideshow Plugin for jQuery
* Intructions: http://slidesjs.com
* By: Nathan Searles, http://nathansearles.com
* Version: 1.1.8
* Updated: June 1st, 2011
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
(function(A){A.fn.slides=function(B){B=A.extend({},A.fn.slides.option,B);return this.each(function(){A("."+B.container,A(this)).children().wrapAll('<div class="slides_control"/>');var V=A(this),J=A(".slides_control",V),Z=J.children().size(),Q=J.children().outerWidth(),M=J.children().outerHeight(),D=B.start-1,L=B.effect.indexOf(",")<0?B.effect:B.effect.replace(" ","").split(",")[0],S=B.effect.indexOf(",")<0?L:B.effect.replace(" ","").split(",")[1],O=0,N=0,C=0,P=0,U,H,I,X,W,T,K,F;function E(c,b,a){if(!H&&U){H=true;B.animationStart(P+1);switch(c){case"next":N=P;O=P+1;O=Z===O?0:O;X=Q*2;c=-Q*2;P=O;break;case"prev":N=P;O=P-1;O=O===-1?Z-1:O;X=0;c=0;P=O;break;case"pagination":O=parseInt(a,10);N=A("."+B.paginationClass+" li."+B.currentClass+" a",V).attr("href").match("[^#/]+$");if(O>N){X=Q*2;c=-Q*2;}else{X=0;c=0;}P=O;break;}if(b==="fade"){if(B.crossfade){J.children(":eq("+O+")",V).css({zIndex:10}).fadeIn(B.fadeSpeed,B.fadeEasing,function(){if(B.autoHeight){J.animate({height:J.children(":eq("+O+")",V).outerHeight()},B.autoHeightSpeed,function(){J.children(":eq("+N+")",V).css({display:"none",zIndex:0});J.children(":eq("+O+")",V).css({zIndex:0});B.animationComplete(O+1);H=false;});}else{J.children(":eq("+N+")",V).css({display:"none",zIndex:0});J.children(":eq("+O+")",V).css({zIndex:0});B.animationComplete(O+1);H=false;}});}else{J.children(":eq("+N+")",V).fadeOut(B.fadeSpeed,B.fadeEasing,function(){if(B.autoHeight){J.animate({height:J.children(":eq("+O+")",V).outerHeight()},B.autoHeightSpeed,function(){J.children(":eq("+O+")",V).fadeIn(B.fadeSpeed,B.fadeEasing);});}else{J.children(":eq("+O+")",V).fadeIn(B.fadeSpeed,B.fadeEasing,function(){if(A.browser.msie){A(this).get(0).style.removeAttribute("filter");}});}B.animationComplete(O+1);H=false;});}}else{J.children(":eq("+O+")").css({left:X,display:"block"});if(B.autoHeight){J.animate({left:c,height:J.children(":eq("+O+")").outerHeight()},B.slideSpeed,B.slideEasing,function(){J.css({left:-Q});J.children(":eq("+O+")").css({left:Q,zIndex:5});J.children(":eq("+N+")").css({left:Q,display:"none",zIndex:0});B.animationComplete(O+1);H=false;});}else{J.animate({left:c},B.slideSpeed,B.slideEasing,function(){J.css({left:-Q});J.children(":eq("+O+")").css({left:Q,zIndex:5});J.children(":eq("+N+")").css({left:Q,display:"none",zIndex:0});B.animationComplete(O+1);H=false;});}}if(B.pagination){A("."+B.paginationClass+" li."+B.currentClass,V).removeClass(B.currentClass);A("."+B.paginationClass+" li:eq("+O+")",V).addClass(B.currentClass);}}}function R(){clearInterval(V.data("interval"));}function G(){if(B.pause){clearTimeout(V.data("pause"));clearInterval(V.data("interval"));K=setTimeout(function(){clearTimeout(V.data("pause"));F=setInterval(function(){E("next",L);},B.play);V.data("interval",F);},B.pause);V.data("pause",K);}else{R();}}if(Z<2){return ;}if(D<0){D=0;}if(D>Z){D=Z-1;}if(B.start){P=D;}if(B.randomize){J.randomize();}A("."+B.container,V).css({overflow:"hidden",position:"relative"});J.children().css({position:"absolute",top:0,left:J.children().outerWidth(),zIndex:0,display:"none"});J.css({position:"relative",width:(Q*3),height:M,left:-Q});A("."+B.container,V).css({display:"block"});if(B.autoHeight){J.children().css({height:"auto"});J.animate({height:J.children(":eq("+D+")").outerHeight()},B.autoHeightSpeed);}if(B.preload&&J.find("img:eq("+D+")").length){A("."+B.container,V).css({background:"url("+B.preloadImage+") no-repeat 50% 50%"});var Y=J.find("img:eq("+D+")").attr("src")+"?"+(new Date()).getTime();if(A("img",V).parent().attr("class")!="slides_control"){T=J.children(":eq(0)")[0].tagName.toLowerCase();}else{T=J.find("img:eq("+D+")");}J.find("img:eq("+D+")").attr("src",Y).load(function(){J.find(T+":eq("+D+")").fadeIn(B.fadeSpeed,B.fadeEasing,function(){A(this).css({zIndex:5});A("."+B.container,V).css({background:""});U=true;B.slidesLoaded();});});}else{J.children(":eq("+D+")").fadeIn(B.fadeSpeed,B.fadeEasing,function(){U=true;B.slidesLoaded();});}if(B.bigTarget){J.children().css({cursor:"pointer"});J.children().click(function(){E("next",L);return false;});}if(B.hoverPause&&B.play){J.bind("mouseover",function(){R();});J.bind("mouseleave",function(){G();});}if(B.generateNextPrev){A("."+B.container,V).after('<a href="#" class="'+B.prev+'">Prev</a>');A("."+B.prev,V).after('<a href="#" class="'+B.next+'">Next</a>');}A("."+B.next,V).click(function(a){a.preventDefault();if(B.play){G();}E("next",L);});A("."+B.prev,V).click(function(a){a.preventDefault();if(B.play){G();}E("prev",L);});if(B.generatePagination){if(B.prependPagination){V.prepend("<ul class="+B.paginationClass+"></ul>");}else{V.append("<ul class="+B.paginationClass+"></ul>");}J.children().each(function(){A("."+B.paginationClass,V).append('<li><a href="#'+C+'">'+(C+1)+"</a></li>");C++;});}else{A("."+B.paginationClass+" li a",V).each(function(){A(this).attr("href","#"+C);C++;});}A("."+B.paginationClass+" li:eq("+D+")",V).addClass(B.currentClass);A("."+B.paginationClass+" li a",V).click(function(){if(B.play){G();}I=A(this).attr("href").match("[^#/]+$");if(P!=I){E("pagination",S,I);}return false;});A("a.link",V).click(function(){if(B.play){G();}I=A(this).attr("href").match("[^#/]+$")-1;if(P!=I){E("pagination",S,I);}return false;});if(B.play){F=setInterval(function(){E("next",L);},B.play);V.data("interval",F);}});};A.fn.slides.option={preload:false,preloadImage:"/img/loading.gif",container:"slides_container",generateNextPrev:false,next:"next",prev:"prev",pagination:true,generatePagination:true,prependPagination:false,paginationClass:"pagination",currentClass:"current",fadeSpeed:350,fadeEasing:"",slideSpeed:350,slideEasing:"",start:1,effect:"slide",crossfade:false,randomize:false,play:0,pause:0,hoverPause:false,autoHeight:false,autoHeightSpeed:350,bigTarget:false,animationStart:function(){},animationComplete:function(){},slidesLoaded:function(){}};A.fn.randomize=function(C){function B(){return(Math.round(Math.random())-0.5);}return(A(this).each(function(){var F=A(this);var E=F.children();var D=E.length;if(D>1){E.hide();var G=[];for(i=0;i<D;i++){G[G.length]=i;}G=G.sort(B);A.each(G,function(I,H){var K=E.eq(H);var J=K.clone(true);J.show().appendTo(F);if(C!==undefined){C(K,J);}K.remove();});}}));};})(jQuery);

/*!
 * jQuery Smooth Scroll Plugin v1.4
 *
 * Date: Mon Apr 25 00:02:30 2011 EDT
 * Requires: jQuery v1.3+
 *
 * Copyright 2010, Karl Swedberg
 * Dual licensed under the MIT and GPL licenses (just like jQuery):
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
*/
(function(c){function k(b){return b.replace(/^\//,"").replace(/(index|default).[a-zA-Z]{3,4}$/,"").replace(/\/$/,"")}var l=k(location.pathname),m=function(b){var d=[],a=false,e=b.dir&&b.dir=="left"?"scrollLeft":"scrollTop";this.each(function(){if(!(this==document||this==window)){var f=c(this);if(f[e]()>0)d.push(this);else{f[e](1);a=f[e]()>0;f[e](0);a&&d.push(this)}}});if(b.el==="first"&&d.length)d=[d.shift()];return d};c.fn.extend({scrollable:function(b){return this.pushStack(m.call(this,{dir:b}))},
firstScrollable:function(b){return this.pushStack(m.call(this,{el:"first",dir:b}))},smoothScroll:function(b){b=b||{};var d=c.extend({},c.fn.smoothScroll.defaults,b);this.die("click.smoothscroll").live("click.smoothscroll",function(a){var e=c(this),f=location.hostname===this.hostname||!this.hostname,g=d.scrollTarget||(k(this.pathname)||l)===l,i=this.hash,h=true;if(!d.scrollTarget&&(!f||!g||!i))h=false;else{f=d.exclude;g=0;for(var j=f.length;h&&g<j;)if(e.is(f[g++]))h=false;f=d.excludeWithin;g=0;for(j=
f.length;h&&g<j;)if(e.closest(f[g++]).length)h=false}if(h){d.scrollTarget=b.scrollTarget||i;d.link=this;a.preventDefault();c.smoothScroll(d)}});return this}});c.smoothScroll=function(b,d){var a,e,f,g=0;e="offset";var i="scrollTop",h={};if(typeof b==="number"){a=c.fn.smoothScroll.defaults;f=b}else{a=c.extend({},c.fn.smoothScroll.defaults,b||{});if(a.scrollElement){e="position";a.scrollElement.css("position")=="static"&&a.scrollElement.css("position","relative")}f=d||c(a.scrollTarget)[e]()&&c(a.scrollTarget)[e]()[a.direction]||
0}a=c.extend({link:null},a);i=a.direction=="left"?"scrollLeft":i;if(a.scrollElement){e=a.scrollElement;g=e[i]()}else e=c("html, body").firstScrollable();h[i]=f+g+a.offset;e.animate(h,{duration:a.speed,easing:a.easing,complete:function(){a.afterScroll&&c.isFunction(a.afterScroll)&&a.afterScroll.call(a.link,a)}})};c.smoothScroll.version="1.4";c.fn.smoothScroll.defaults={exclude:[],excludeWithin:[],offset:0,direction:"top",scrollElement:null,scrollTarget:null,afterScroll:null,easing:"swing",speed:400}})(jQuery);

/*
jQuery Waypoints - v1.0.2
Copyright (c) 2011 Caleb Troughton
Dual licensed under the MIT license and GPL license.
https://github.com/imakewebthings/jquery-waypoints/blob/master/MIT-license.txt
https://github.com/imakewebthings/jquery-waypoints/blob/master/GPL-license.txt
*/
(function($,l,n,j,d){var f=$(j),k=[],m=-99999,i=false,o=false,g="waypoint.reached",c={init:function(q,p){this.each(function(){var u=$(this),r=h(u),t=r<0?$.fn[l].defaults:k[r].options,s=$.extend({},t,p);s.offset=s.offset==="bottom-in-view"?function(){return $[n]("viewportHeight")-$(this).outerHeight()}:s.offset;if(r<0){k.push({element:u,offset:u.offset().top,options:s})}else{k[r].options=s}q&&u.bind(g,q)});$[n]("refresh");return this},remove:function(){return this.each(function(){var p=h($(this));if(p>=0){k.splice(p,1)}})},destroy:function(){return this.unbind(g)[l]("remove")}};function h(q){var p=k.length-1;while(p>=0&&k[p].element[0]!==q[0]){p-=1}return p}function b(q,p){q.element.trigger(g,p);if(q.options.triggerOnce){q.element[l]("destroy")}}function e(){var q=f.scrollTop(),p=q>m,r=$.grep(k,function(t,s){return p?(t.offset>m&&t.offset<=q):(t.offset<=m&&t.offset>q)});if(!m||!q){$[n]("refresh")}m=q;if(!r.length){return}if($[n].settings.continuous){$.each(p?r:r.reverse(),function(t,s){b(s,[p?"down":"up"])})}else{b(r[p?r.length-1:0],[p?"down":"up"])}}$.fn[l]=function(p){if(c[p]){return c[p].apply(this,Array.prototype.slice.call(arguments,1))}else{if(typeof p==="function"||!p){return c.init.apply(this,arguments)}else{if(typeof p==="object"){return c.init.apply(this,[null,p])}else{$.error("Method "+p+" does not exist on jQuery"+l)}}}};$.fn[l].defaults={offset:0,triggerOnce:false};var a={refresh:function(){$.each(k,function(r,t){var p=0,s=t.offset;if(typeof t.options.offset==="function"){p=t.options.offset.apply(t.element)}else{if(typeof t.options.offset==="string"){var q=parseFloat(t.options.offset),p=t.options.offset.indexOf("%")?Math.ceil($[n]("viewportHeight")*(q/100)):q}else{p=t.options.offset}}t.offset=t.element.offset().top-p;if(m>s&&m<=t.offset){b(t,["up"])}else{if(m<s&&m>=t.offset){b(t,["down"])}}});k.sort(function(q,p){return q.offset-p.offset})},viewportHeight:function(){return(j.innerHeight?j.innerHeight:f.height())},aggregate:function(){var p=$();$.each(k,function(q,r){p=p.add(r.element)});return p}};$[n]=function(p){if(a[p]){return a[p].apply(this)}else{return a.aggregate()}};$[n].settings={continuous:true,resizeThrottle:200,scrollThrottle:100};f.scroll(function(){if(!i){i=true;j.setTimeout(function(){e();i=false},$[n].settings.scrollThrottle)}}).resize(function(){if(!o){o=true;j.setTimeout(function(){$[n]("refresh");o=false},$[n].settings.resizeThrottle)}}).load(function(){$[n]("refresh");e()})})(jQuery,"waypoint","waypoints",this);

/*
|--------------------------------------------------------------------------
| UItoTop jQuery Plugin 1.1
| http://www.mattvarone.com/web-design/uitotop-jquery-plugin/
|--------------------------------------------------------------------------
*/
(function(a){a.fn.UItoTop=function(d){var f={text:"To Top",min:200,inDelay:600,outDelay:400,containerID:"toTop",containerHoverID:"toTopHover",scrollSpeed:1200,easingType:"linear"};var e=a.extend(f,d);var c="#"+e.containerID;var b="#"+e.containerHoverID;a("body").append('<a href="#" id="'+e.containerID+'">'+e.text+"</a>");a(c).hide().click(function(){a("html, body").animate({scrollTop:0},e.scrollSpeed,e.easingType);a("#"+e.containerHoverID,this).stop().animate({opacity:0},e.inDelay,e.easingType);return false}).prepend('<span id="'+e.containerHoverID+'"></span>').hover(function(){a(b,this).stop().animate({opacity:1},600,"linear")},function(){a(b,this).stop().animate({opacity:0},700,"linear")});a(window).scroll(function(){var g=a(window).scrollTop();if(typeof document.body.style.maxHeight==="undefined"){a(c).css({position:"absolute",top:a(window).scrollTop()+a(window).height()-50})}if(g>e.min){a(c).fadeIn(e.inDelay)}else{a(c).fadeOut(e.Outdelay)}})}})(jQuery);

/*
 * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
 *
 * Uses the built in easing capabilities added In jQuery 1.1
 * to offer multiple easing options
 *
 * TERMS OF USE - jQuery Easing
 * 
 * Open source under the BSD License. 
 * 
 * Copyright © 2008 George McGinley Smith
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 * 
 * Redistributions of source code must retain the above copyright notice, this list of 
 * conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this list 
 * of conditions and the following disclaimer in the documentation and/or other materials 
 * provided with the distribution.
 * 
 * Neither the name of the author nor the names of contributors may be used to endorse 
 * or promote products derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 *  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
 * OF THE POSSIBILITY OF SUCH DAMAGE. 
 *
*/

// t: current time, b: begInnIng value, c: change In value, d: duration
jQuery.easing['jswing'] = jQuery.easing['swing'];

jQuery.extend(jQuery.easing,{def:"easeOutQuad",swing:function(e,f,a,h,g){return jQuery.easing[jQuery.easing.def](e,f,a,h,g)},easeInQuad:function(e,f,a,h,g){return h*(f/=g)*f+a},easeOutQuad:function(e,f,a,h,g){return -h*(f/=g)*(f-2)+a},easeInOutQuad:function(e,f,a,h,g){if((f/=g/2)<1){return h/2*f*f+a}return -h/2*((--f)*(f-2)-1)+a},easeInCubic:function(e,f,a,h,g){return h*(f/=g)*f*f+a},easeOutCubic:function(e,f,a,h,g){return h*((f=f/g-1)*f*f+1)+a},easeInOutCubic:function(e,f,a,h,g){if((f/=g/2)<1){return h/2*f*f*f+a}return h/2*((f-=2)*f*f+2)+a},easeInQuart:function(e,f,a,h,g){return h*(f/=g)*f*f*f+a},easeOutQuart:function(e,f,a,h,g){return -h*((f=f/g-1)*f*f*f-1)+a},easeInOutQuart:function(e,f,a,h,g){if((f/=g/2)<1){return h/2*f*f*f*f+a}return -h/2*((f-=2)*f*f*f-2)+a},easeInQuint:function(e,f,a,h,g){return h*(f/=g)*f*f*f*f+a},easeOutQuint:function(e,f,a,h,g){return h*((f=f/g-1)*f*f*f*f+1)+a},easeInOutQuint:function(e,f,a,h,g){if((f/=g/2)<1){return h/2*f*f*f*f*f+a}return h/2*((f-=2)*f*f*f*f+2)+a},easeInSine:function(e,f,a,h,g){return -h*Math.cos(f/g*(Math.PI/2))+h+a},easeOutSine:function(e,f,a,h,g){return h*Math.sin(f/g*(Math.PI/2))+a},easeInOutSine:function(e,f,a,h,g){return -h/2*(Math.cos(Math.PI*f/g)-1)+a},easeInExpo:function(e,f,a,h,g){return(f==0)?a:h*Math.pow(2,10*(f/g-1))+a},easeOutExpo:function(e,f,a,h,g){return(f==g)?a+h:h*(-Math.pow(2,-10*f/g)+1)+a},easeInOutExpo:function(e,f,a,h,g){if(f==0){return a}if(f==g){return a+h}if((f/=g/2)<1){return h/2*Math.pow(2,10*(f-1))+a}return h/2*(-Math.pow(2,-10*--f)+2)+a},easeInCirc:function(e,f,a,h,g){return -h*(Math.sqrt(1-(f/=g)*f)-1)+a},easeOutCirc:function(e,f,a,h,g){return h*Math.sqrt(1-(f=f/g-1)*f)+a},easeInOutCirc:function(e,f,a,h,g){if((f/=g/2)<1){return -h/2*(Math.sqrt(1-f*f)-1)+a}return h/2*(Math.sqrt(1-(f-=2)*f)+1)+a},easeInElastic:function(f,h,e,l,k){var i=1.70158;var j=0;var g=l;if(h==0){return e}if((h/=k)==1){return e+l}if(!j){j=k*0.3}if(g<Math.abs(l)){g=l;var i=j/4}else{var i=j/(2*Math.PI)*Math.asin(l/g)}return -(g*Math.pow(2,10*(h-=1))*Math.sin((h*k-i)*(2*Math.PI)/j))+e},easeOutElastic:function(f,h,e,l,k){var i=1.70158;var j=0;var g=l;if(h==0){return e}if((h/=k)==1){return e+l}if(!j){j=k*0.3}if(g<Math.abs(l)){g=l;var i=j/4}else{var i=j/(2*Math.PI)*Math.asin(l/g)}return g*Math.pow(2,-10*h)*Math.sin((h*k-i)*(2*Math.PI)/j)+l+e},easeInOutElastic:function(f,h,e,l,k){var i=1.70158;var j=0;var g=l;if(h==0){return e}if((h/=k/2)==2){return e+l}if(!j){j=k*(0.3*1.5)}if(g<Math.abs(l)){g=l;var i=j/4}else{var i=j/(2*Math.PI)*Math.asin(l/g)}if(h<1){return -0.5*(g*Math.pow(2,10*(h-=1))*Math.sin((h*k-i)*(2*Math.PI)/j))+e}return g*Math.pow(2,-10*(h-=1))*Math.sin((h*k-i)*(2*Math.PI)/j)*0.5+l+e},easeInBack:function(e,f,a,i,h,g){if(g==undefined){g=1.70158}return i*(f/=h)*f*((g+1)*f-g)+a},easeOutBack:function(e,f,a,i,h,g){if(g==undefined){g=1.70158}return i*((f=f/h-1)*f*((g+1)*f+g)+1)+a},easeInOutBack:function(e,f,a,i,h,g){if(g==undefined){g=1.70158}if((f/=h/2)<1){return i/2*(f*f*(((g*=(1.525))+1)*f-g))+a}return i/2*((f-=2)*f*(((g*=(1.525))+1)*f+g)+2)+a},easeInBounce:function(e,f,a,h,g){return h-jQuery.easing.easeOutBounce(e,g-f,0,h,g)+a},easeOutBounce:function(e,f,a,h,g){if((f/=g)<(1/2.75)){return h*(7.5625*f*f)+a}else{if(f<(2/2.75)){return h*(7.5625*(f-=(1.5/2.75))*f+0.75)+a}else{if(f<(2.5/2.75)){return h*(7.5625*(f-=(2.25/2.75))*f+0.9375)+a}else{return h*(7.5625*(f-=(2.625/2.75))*f+0.984375)+a}}}},easeInOutBounce:function(e,f,a,h,g){if(f<g/2){return jQuery.easing.easeInBounce(e,f*2,0,h,g)*0.5+a}return jQuery.easing.easeOutBounce(e,f*2-g,0,h,g)*0.5+h*0.5+a}});

/**
 *  Zebra_Form
 *
 *  Client-side validation for Zebra_Form
 *
 *  Visit {@link http://stefangabos.ro/php-libraries/zebra-form/} for more information.
 *
 *  For more resources visit {@link http://stefangabos.ro/}
 *
 *  @author     Stefan Gabos <contact@stefangabos.ro>
 *  @version    2.3 (last revision: June 19, 2011)
 *  @copyright  (c) 2011 Stefan Gabos
 *  @license    http://www.gnu.org/licenses/lgpl-3.0.txt GNU LESSER GENERAL PUBLIC LICENSE
 *  @package    Zebra_DatePicker
 */
(function(a){a.Zebra_Form=function(k,q){var m=this;var g={scroll_to_error:true,tips_position:"left",close_tips:true,process_path:null};m.settings={};var o=new Object,f=new Object,n=new Object,h=new Object,b=false;var p=a(k),e=k;m.filter_input=function(w,z,v){var x,y,u,r="";var t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";var s="0123456789";if(window.event){x=window.event.keyCode;z=window.event}else{if(z){x=z.which}else{return true}}switch(w){case"alphabet":r=t;break;case"digits":case"number":case"float":r=s;break;case"alphanumeric":r=t+s;break;default:return true}if(v){r+=v}u=z.srcElement?z.srcElement:z.target||z.currentTarget;if(x==null||x==0||x==8||x==9||x==13||x==27){return true}y=String.fromCharCode(x);if(r.indexOf(y)>-1){return true}if(w=="number"&&y=="-"&&j(u)==0){return true}if(w=="float"&&((y=="-"&&j(u)==0)||(y=="."&&j(u)!=0&&u.value.match(/\./)==null))){return true}return false};m.init=function(){m.settings=a.extend({},g,q);p.find("option.dummy").remove();p.find("div.error").each(function(){var t=a(this);var s=t.first("div.close>a");s.click(function(u){u.preventDefault();t.animate({height:0,opacity:0},250,function(){t.remove()})})});var r=p.find(".control");r.each(function(){var t=a(this);var s={id:t.attr("id"),type:i(t)};var u=t.closest(".row");if(u.length){t.bind({focus:function(){u.addClass("highlight")},blur:function(){u.removeClass("highlight")}})}if(t.hasClass("inner-label")&&(s.type=="text"||s.type=="password"||s.type=="textarea")){s=a.extend(s,{"class":t.attr("class")},{style:t.attr("style")},{alt:t.attr("alt")});var v=jQuery('<input type="text">').attr({id:s.id,"class":a.trim(s["class"].replace(/validate\[.*\]/,"").replace(/inner\-label/,""))+" placeholder",style:s.style,value:s.alt}).css({display:"none"});n[s.id]=v;v.focus(function(){m.hide_error(t.attr("name").replace(/\[\]$/,""));v.css("display","none");t.css("display",t.hasClass("inline")?"inline":"block");t.focus()});t.blur(function(){if(t.val()==""){t.css("display","none");n[t.attr("id")].css("display",t.hasClass("inline")?"inline":"block")}});if(t.val()==""){v.css("display",t.hasClass("inline")?"inline":"block");t.css("display","none")}else{t.css("display",t.hasClass("inline")?"inline":"block")}t.after(v)}else{if(t.hasClass("other")&&s.type=="select-one"){d(t);t.change(function(){d(t)})}}if(undefined!=m.settings.error_messages&&undefined!=typeof m.settings.error_messages[s.id]){m.register(t,false)}});p.bind("submit",function(s){if(b==false&&undefined!=m.settings.error_messages){if(!m.validate()){if(undefined!=s){s.preventDefault()}m.show_errors()}else{if(undefined==s){p.submit()}}}})};m.attach_tip=function(r,s){var t=a("#"+r).attr("id");o[t].message=s;m.show_errors(r)};m.clear_errors=function(){a(".Zebra_Form_error_iFrameShim").remove();a(".Zebra_Form_error_message").remove();h=[]};m.end_file_upload=function(u,t){var r=a("#"+u);if(r.length){p.removeAttr("target");var x=r.attr("id");a("#"+x+"_iframe").remove();a("#"+x+"_spinner").remove();if(undefined!=o[u]){if(undefined!=t&&"object"==typeof(t)&&undefined!=t[0]&&undefined!=t[1]&&undefined!=t[2]&&undefined!=t[3]){r.data("file_info",t)}if(true!==m.validate_control(r)){r.val("");r.css("visibility","visible");m.show_errors(r)}else{var v=r.position(p);var w=jQuery("<span>",{"class":"filename",css:{left:v.left,top:v.top,width:r.outerWidth}});w.html(t[0]);var s=jQuery("<a>",{href:"javascript:void(0)"});s.html("x");s.click(function(y){y.preventDefault();w.remove();r.val("");if(r.data("file_info")){r.removeData("file_info")}r.css("visibility","visible")});w.append(s);p.append(w)}}}};m.hide_error=function(s){var r=h[s];if(undefined!=r){r.animate({opacity:0},250,function(){var t=r.data("shim");if(undefined!=t){t.remove()}r.remove();delete h[s]})}};m.register=function(v){var u={id:v.attr("id"),name:v.attr("name"),type:i(v)};u.name=u.name.replace(/\[\]$/,"");switch(u.type){case"radio":case"checkbox":v.bind({click:function(){m.hide_error(u.name)},blur:function(){m.hide_error(u.name)}});if(undefined==f[u.id]){f[u.id]=p.find("input[name^="+u.name+"]")}break;case"file":var x=v.clone(true);x.attr("value","");v.replaceWith(x);x.bind({keypress:function(C){C.preventDefault();x.attr("value","")},change:function(){m.hide_error(u.name);if(x.data("file_info")){x.removeData("file_info")}var C=jQuery("<iframe>",{src:"javascript:void(0)",id:u.id+"_iframe",name:u.id+"_iframe",scrolling:"no",marginwidth:0,marginheight:0,width:0,height:0,frameborder:0,allowtransparency:"true"});a("body").append(C);var F=p.attr("action");p.attr("action",m.settings.process_path+"?form="+p.attr("id")+"&control="+u.id+"&nocache="+new Date().getTime());p.attr("target",u.id+"_iframe");x.css("visibility","hidden");var E=x.offset();var D=jQuery("<div>",{id:u.id+"_spinner","class":"Zebra_Form_spinner",css:{left:E.left,top:E.top}});a("body").append(D);b=true;p.trigger("submit");p.attr("action",F);b=false},blur:function(){m.hide_error(u.name)}});v=x;break;case"select-one":case"select-multiple":v.bind({change:function(){m.hide_error(u.name)},blur:function(){m.hide_error(u.name)}});break;default:v.blur(function(){m.hide_error(u.name)})}var B=v.attr("class").match(/validate\[(.+)\]/);if(null!=B){var z=/([^\,]*\(.*?\)|[^\,]+)/g;var w=new Object;while(matches=z.exec(B[1])){var y=matches[1].match(/^([^\(]+)/);var t=matches[1].match(/\((.*?)\)/);if(t){t=t[1].split(",");a.each(t,function(D,C){t[D]=t[D].replace(/lsqb\;/g,"[");t[D]=t[D].replace(/rsqb\;/g,"]");t[D]=t[D].replace(/comma\;/g,",");t[D]=t[D].replace(/lsb\;/g,"(");t[D]=t[D].replace(/rsb\;/g,")")})}else{t=null}w[y[1]]=t}if(undefined==arguments[1]){var r=p.find(".control");a.each(r,function(D,G){if(G==v.get(0)){var G=a(G);var H=null;var C=D-1;while(H==null&&undefined!=r[C]&&!a(r[C]).hasClass("placeholder")){H=a(r[C]).attr("id");C--}if(!o[H]){var F=new Object;F[u.id]={element:v,rules:w};a.extend(o,F)}else{var E=new Object;for(D in o){E[D]=o[D];if(H==D){E[u.id]={element:v,rules:w}}}o=E}}})}else{if(undefined!=arguments[1]&&a("#"+arguments[1]).length){var s=a("#"+arguments[1]).attr("id");var A=new Object;for(index in o){A[index]=o[index];if(previous_element_id==index){A[u.id]={element:v,rules:w}}}o=A}else{if(undefined!=arguments[1]&&arguments[1]===false){o[u.id]={element:v,rules:w}}}}}};m.show_errors=function(){m.clear_errors();var r=0;for(index in o){var u=o[index];var y=u.element;var x={id:y.attr("id"),name:y.attr("name"),type:i(y)};x.name=x.name.replace(/\[\]$/,"");if(undefined!=arguments[0]&&arguments[0].get(0)!=y.get(0)){continue}if(undefined!=u.message){if(y.css("display")!="none"){y.focus()}if(y.css("display")=="none"){var w=n[x.id].offset();w=a.extend(w,{right:Math.floor(w.left+n[x.id].width())})}else{var w=a.extend(y.offset());w=a.extend(w,{right:Math.floor(w.left+y.width())})}var s=jQuery("<div/>",{"class":"Zebra_Form_error_message",css:{opacity:0}});var D=jQuery("<div/>",{"class":"message"+(!m.settings.close_tips?" noclose":""),css:{width:"auto"}});D.html(u.message);s.append(D);if(m.settings.close_tips){var C=jQuery("<a/>",{href:"javascript:void(0)","class":"close"+(a.browser.msie&&a.browser.version.match(/^6/)?"-ie6":"")});C.html("x");C.bind({click:function(E){E.preventDefault();m.hide_error(x.name)},focus:function(){C.blur()}});D.append(C)}var B=jQuery("<div/>",{"class":"arrow"});s.append(B);a("body").append(s);var z={x:s.outerWidth(),y:s.outerHeight()};arrow_size={x:B.outerWidth(),y:B.outerHeight()};B.css("left",(z.x/2)-(arrow_size.x/2)-1);var v=(m.settings.tips_position=="left"?w.left:w.right)-(z.x/2);if(x.type=="radio"||x.type=="checkbox"){v=w.right-(z.x/2)-(y.outerWidth()/2)+1}if(v<0){v=2}s.css("left",v);z={x:s.outerWidth(),y:s.outerHeight()};var A=(w.top-z.y+(arrow_size.y/2)-1);if(A<0){A=2}s.css({left:v+"px",top:A+"px",height:(z.y-(arrow_size.y/2))+"px"});var t=(x.type=="radio"||x.type=="checkbox"?x.name:x.id);h[t]=s;c(s);s.animate({opacity:0.9},250);if(++r==1&&m.settings.scroll_to_error){a("html, body").animate({scrollTop:s.css("top").replace(/px/,"")-10},250);break}}}};m.submit=function(){if(undefined!=m.settings.error_messages){p.trigger("submit")}else{e.submit()}};m.validate_control=function(u){var C={id:u.attr("id"),type:i(u)};var O=true;var J=o[C.id];if(undefined!=J){var E=null;var N=null;delete J.message;for(var y in J.rules){if(!O){break}switch(y){case"alphabet":switch(C.type){case"password":case"text":case"textarea":var B=new RegExp("^[a-z"+l(J.rules[y][0]).replace(/\s/,"\\s")+"]+$","ig");if(a.trim(u.val())!=""&&!B.test(u.val())){O=false}break}break;case"alphanumeric":switch(C.type){case"password":case"text":case"textarea":var B=new RegExp("^[a-z0-9"+l(J.rules[y][0]).replace(/\s/,"\\s")+"]+$","ig");if(a.trim(u.val())!=""&&!B.test(u.val())){O=false}break}break;case"compare":switch(C.type){case"password":case"text":case"textarea":if(!a("#"+J.rules[y][0])||(a("#"+J.rules[y][0])&&u.val()!=a("#"+J.rules[y][0]).val())){O=false}break}break;case"custom":var D=false;a.each(J.rules[y],function(R,T){if(D){return}T=a.map(T.split(","),function(U){return U.replace(/mark\;/g,",")});T=a.merge(a.merge([T.shift()],[u.val()]),T);var S=(typeof T[0]=="function")?T[0]:(typeof window[T[0]]=="function"?window[T[0]]:false);if(S!==false){O=S.apply(S,T.slice(1))}else{O=false}if(!O){N=T[0];D=true}});break;case"date":switch(C.type){case"text":if(a.trim(u.val())!=""){var A=false;var I=u.data("Zebra_DatePicker").settings.format.replace(/\s/g,"");I=l(I);var P=["d","D","j","l","N","S","w","F","m","M","n","Y","y","G","H","g","h","a","A","i","s","U"];var r=new Array;for(var H=0;H<P.length;H++){if((position=I.indexOf(P[H]))>-1){r.push({character:P[H],position:position})}}r.sort(function(S,R){return S.position-R.position});var Q=new Array;a.each(r,function(S,R){switch(R.character){case"d":Q.push("0[1-9]|[12][0-9]|3[01]");break;case"D":Q.push("[a-z]{3}");break;case"j":Q.push("[1-9]|[12][0-9]|3[01]");break;case"l":Q.push("[a-z]+");break;case"N":Q.push("[1-7]");break;case"S":Q.push("st|nd|rd|th");break;case"w":Q.push("[0-6]");break;case"F":Q.push("[a-z]+");break;case"m":Q.push("0[1-9]|1[012]+");break;case"M":Q.push("[a-z]{3}");break;case"n":Q.push("[1-9]|1[012]");break;case"Y":Q.push("[0-9]{4}");break;case"y":Q.push("[0-9]{2}");break;case"G":case"H":case"g":case"h":Q.push("[0-9]{1,2}");break;case"a":case"A":Q.push("(am|pm)");break;case"i":case"s":Q.push("[012345][0-9]");break}});if(Q.length>0){r.reverse();a.each(r,function(S,R){I=I.replace(R.character,"("+Q[Q.length-S-1]+")")});Q=new RegExp("^"+I+"$","ig");if((segments=Q.exec(u.val().replace(/\s/g,"")))){var w=null;var G=null;var t=null;var x=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];var s=["January","February","March","April","May","June","July","August","September","October","November","December"];var M=null;r.reverse();var F=true;a.each(r,function(S,R){if(!F){return true}switch(R.character){case"m":case"n":G=parseInt(segments[S+1],10);break;case"d":case"j":w=parseInt(segments[S+1],10);break;case"D":case"l":case"F":case"M":if(R.character=="D"||R.character=="l"){M=window["calendar_"+id].options.days}else{M=window["calendar_"+id].options.months}F=false;M.each(function(U,T){if(F){return true}if(segments[S+1].toLowerCase()==U.substring(0,(R.character=="D"||R.character=="M"?3:U.length)).toLowerCase()){switch(R.character){case"D":segments[S+1]=x[T].substring(0,3);break;case"l":segments[S+1]=x[T];break;case"F":segments[S+1]=s[T];G=T+1;break;case"M":segments[S+1]=s[T].substring(0,3);G=T+1;break}F=true}});break;case"Y":t=parseInt(segments[S+1],10);break;case"y":t="19"+parseInt(segments[S+1],10);break}});if(F){var L=new Date(t,G-1,w);if(L.getFullYear()==t&&L.getDate()==w&&L.getMonth()==(G-1)){u.data("timestamp",Date.parse(s[G-1]+" "+w+", "+t));A=true}}}}if(!A){O=false}}break}break;case"datecompare":switch(C.type){case"password":case"text":case"textarea":if(undefined!=J.rules[y][0]&&undefined!=J.rules[y][1]&&a(J.rules[y][0])&&m.validate_control(a(J.rules[y][0]))===true&&undefined!=u.data("timestamp")){switch(J.rules[y][1]){case">":O=(u.data("timestamp")>a("#"+J.rules[y][0]).data("timestamp"));break;case">=":O=(u.data("timestamp")>=a("#"+J.rules[y][0]).data("timestamp"));break;case"<":O=(u.data("timestamp")<a("#"+J.rules[y][0]).data("timestamp"));break;case"<=":O=(u.data("timestamp")<=a("#"+J.rules[y][0]).data("timestamp"));break}}else{O=false}break}break;case"digits":switch(C.type){case"password":case"text":case"textarea":var B=new RegExp("^[0-9"+l(J.rules[y][0]).replace(/\s/,"\\s")+"]+$","ig");if(a.trim(u.val())!=""&&!B.test(u.val())){O=false}break}break;case"email":switch(C.type){case"password":case"text":case"textarea":if(a.trim(u.val())!=""&&null==u.val().match(/^([a-zA-Z0-9_\-\+\~\^\{\}]+[\.]?)+@{1}([a-zA-Z0-9_\-\+\~\^\{\}]+[\.]?)+\.[A-Za-z0-9]{2,}$/)){O=false}break}break;case"emails":switch(C.type){case"password":case"text":case"textarea":var v=u.val().split(",");v.each(function(R){if(a.trim(R)!=""&&null==a.trim(R).match(/^([a-zA-Z0-9_\-\+\~\^\{\}]+[\.]?)+@{1}([a-zA-Z0-9_\-\+\~\^\{\}]+[\.]?)+\.[A-Za-z0-9]{2,}$/)){O=false}});break}break;case"filesize":switch(C.type){case"file":var K=u.data("file_info");if(K){if(undefined==K[2]||undefined==K[3]||K[2]!=0||parseInt(K[3],10)>parseInt(J.rules[y][0],10)){O=false}}break}break;case"float":switch(C.type){case"password":case"text":case"textarea":var B=new RegExp("^[0-9-."+l(J.rules[y][0]).replace(/\s/,"\\s")+"]+$","ig");if(a.trim(u.val())!=""&&(a.trim(u.val())=="-"||a.trim(u.val())=="."||(null!=u.val().match(/\-/g)&&u.val().match(/\-/g).length>1)||(null!=u.val().match(/\./g)&&u.val().match(/\./g).length>1)||u.val().indexOf("-")>0||!B.test(u.val()))){O=false}break}break;case"image":switch(C.type){case"file":var K=u.data("file_info");if(K&&null==K[1].match(/image\/(gif|jpeg|png|pjpeg)/i)){O=false}break}break;case"length":switch(C.type){case"password":case"text":case"textarea":if((undefined!=J.rules[y][0]&&a.trim(u.val()).length<J.rules[y][0])||(undefined!=J.rules[y][1]&&J.rules[y][1]>0&&u.val().length>J.rules[y][1])){O=false}break}break;case"number":switch(C.type){case"password":case"text":case"textarea":var B=new RegExp("^[0-9-"+l(J.rules[y][0]).replace(/\s/,"\\s")+"]+$","ig");if(a.trim(u.val())!=""&&(a.trim(u.val())=="-"||(null!=u.val().match(/\-/g)&&u.val().match(/\-/g).length>1)||u.val().indexOf("-")>0||!B.test(u.val()))){O=false}break}break;case"regexp":switch(C.type){case"password":case"text":case"textarea":var B=new RegExp(J.rules[y][0],"g");if(a.trim(u.val())!=""&&null==B.exec(u.val())){O=false}break}break;case"required":switch(C.type){case"checkbox":case"radio":var z=false;f[C.id].each(function(){if(this.checked){z=true}});if(!z){O=false}break;case"file":case"password":case"text":case"textarea":if(a.trim(u.val())==""){O=false}break;case"select-one":if((u.hasClass("other")&&u.val()=="other"&&(!a("#"+C.id+"_other").length||a.trim(a("#"+C.id+"_other").val())==""))||u.get(0).selectedIndex==0){O=false}break;case"select-multiple":if(u.get(0).selectedIndex==-1){O=false}break}break}if(!O){E=y;J.message=m.settings.error_messages[C.id][y=="custom"?"custom_"+N:E];J.value=u.val()}}}return(O?true:E)};m.validate=function(){var s=null,t=null;var r=true;for(index in o){if(!r){break}k=o[index]["element"];t=k.attr("id");if((rule_not_passed=m.validate_control(k))!==true){r=false;break}}if(r&&undefined!=m.settings.onValid){return m.settings.onValid()}return r};var l=function(r){return r.replace(/([-.*+?^${}()|[\]\/\\])/g,"\\$1")};var j=function(s){if(s.selectionStart!=null){return s.selectionStart}var r=document.selection.createRange();var u=r.duplicate();if(s.type=="text"){return(0-u.moveStart("character",-100000))}else{var t=s.value;var v=t.length;u.moveToElementText(s);u.setEndPoint("StartToStart",r);return v-u.text.length}};var c=function(r){if(a.browser.msie&&a.browser.version.match(/^6/)){if(!r.data("shim")){var s=r.offset();var u=parseInt(r.css("zIndex"),10)-1;var t=jQuery("<iframe>",{src:'javascript:document.write("")',scrolling:"no",frameborder:0,allowtransparency:"true","class":"Zebra_Form_error_iFrameShim",css:{zIndex:u,position:"absolute",top:s.top,left:s.left,width:r.outerWidth(),height:r.outerHeight(),filter:"progid:DXImageTransform.Microsoft.Alpha(opacity=0)",display:"block"}});a("body").append(t);r.data("shim",t)}}};var d=function(r){var s=a("#"+r.attr("id")+"_other");if(r.val()=="other"){s.css("display","block")}else{s.css("display","none")}};var i=function(s){var r=["button","input:checkbox","input:file","input:password","input:radio","input:submit","input:text","select","textarea"];for(index in r){if(s.is(r[index])){if(r[index]=="select"){if(s.attr("multiple")){return"select-multiple"}else{return"select-one"}}return r[index].replace(/input\:/,"")}}};m.init()};a.fn.Zebra_Form=function(b){return this.each(function(){var c=new a.Zebra_Form(this,b);a(this).data("Zebra_Form",c)})}})(jQuery);(function(a){a.Zebra_DatePicker=function(r,A){var D={days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],direction:0,disabled_dates:false,first_day_of_week:1,format:"Y-m-d",months:["January","February","March","April","May","June","July","August","September","October","November","December"],offset:[20,-5],readonly_element:true,view:"days",weekend_days:[0,6]};var c,C,p,f,G,b,l,j,u,g,s,t,I,k,x,z,K,L,o,H,n;var M=this;M.settings={};var e=a(r);M.init=function(){M.settings=a.extend({},D,A);if(M.settings.readonly_element){e.attr("readonly","readonly")}c=M.settings.view;var Q='<button type="button" class="Zebra_DatePicker_Icon">Pick a date</button>';p=a(Q);n=(M.settings.direction===true||m(M.settings.direction)>0)?true:((M.settings.direction===false||m(M.settings.direction)<0)?false:0);var P=new Date();s=P.getMonth();j=P.getMonth();t=P.getFullYear();u=P.getFullYear();I=P.getDate();g=P.getDate();if(n!==0){P=new Date(t,s,I+m(M.settings.direction));s=P.getMonth();t=P.getFullYear();I=P.getDate()}if(J(O(t,q(s,2),q(I,2)))){while(J(t)){if(!n){t--}else{t++}s=0}while(J(O(t,q(s,2)))){if(!n){s--}else{s++}if(s>11){t++;s=0}else{if(s<0){t--;s=0}}I=1}while(J(O(t,q(s,2),q(I,2)))){if(!n){I--}else{I++}P=new Date(t,s,I);t=P.getFullYear();s=P.getMonth();I=P.getDate()}}p.bind("click",function(S){S.preventDefault();if(C.css("display")!="none"){M.hide()}else{var R=h(e.val());if(R){K=R.getMonth();k=R.getMonth();L=R.getFullYear();x=R.getFullYear();z=R.getDate();if(J(O(L,q(K,2),q(z,2)))){k=s;x=t}}else{k=s;x=t}F();M.show()}});p.insertAfter(r);var Q='<div class="Zebra_DatePicker"><table class="dp_header"><tr><td class="dp_previous">&laquo;</td><td class="dp_caption">&nbsp;</td><td class="dp_next">&raquo;</td></tr></table><table class="dp_daypicker"></table><table class="dp_monthpicker"></table><table class="dp_yearpicker"></table></div>';C=a(Q);f=C.find("table.dp_header").first();G=C.find("table.dp_daypicker").first();b=C.find("table.dp_monthpicker").first();l=C.find("table.dp_yearpicker").first();a("body").append(C);C.delegate("td:not(.dp_disabled, .dp_weekend_disabled, .dp_not_in_month, .dp_blocked)",{mouseover:function(){a(this).addClass("dp_hover")},mouseout:function(){a(this).removeClass("dp_hover")}});i(f.find("td"));f.find(".dp_previous").bind("click",function(){if(!a(this).hasClass("dp_blocked")){if(c=="months"){x--}else{if(c=="years"){x-=12}else{if(--k<0){k=11;x--}}}F()}});f.find(".dp_caption").bind("click",function(){if(c=="days"){c="months"}else{if(c=="months"){c="years"}else{c="days"}}F()});f.find(".dp_next").bind("click",function(){if(!a(this).hasClass("dp_blocked")){if(c=="months"){x++}else{if(c=="years"){x+=12}else{if(++k==12){k=0;x++}}}F()}});G.delegate("td:not(.dp_disabled, .dp_weekend_disabled, .dp_not_in_month)",{click:function(){e.val(B(new Date(x,k,m(a(this).html()))));M.hide()}});b.delegate("td",{click:function(){var R=a(this).attr("class").match(/dp\_month\_([0-9]+)/);k=m(R[1]);c="days";F()}});l.delegate("td",{click:function(){x=m(a(this).html());c="months";F()}});a("body").bind("mousedown",function(R){if(C.css("display")=="block"){if(a(R.target).get(0)===p.get(0)){return true}if(a(R.target).parents().filter(".Zebra_DatePicker").length==0){M.hide()}}});o=[];a.each(M.settings.disabled_dates,function(){var V=this.split(" ");for(var U=0;U<4;U++){if(!V[U]){V[U]="*"}V[U]=(a.inArray(",",V[U])>-1?V[U].split(","):new Array(V[U]));for(var T=0;T<V[U].length;T++){if(a.inArray("-",V[U][T])>-1){var S=V[U][T].match(/^([0-9]+)\-([0-9]+)/);if(null!=S){for(var R=m(S[1]);R<=m(S[2]);R++){if(a.inArray(R,V[U])==-1){V[U].push(R+"")}}V[U].splice(T,1)}}}for(T=0;T<V[U].length;T++){V[U][T]=(isNaN(m(V[U][T]))?V[U][T]:m(V[U][T]))}}o.push(V)})};M.hide=function(){E("hide");C.css("display","none")};M.show=function(){F();var W=C.outerWidth(),V=C.outerHeight(),U=p.offset().left+M.settings.offset[0],T=p.offset().top-V+M.settings.offset[1],P=a(window).width(),S=a(window).height(),R=a(window).scrollTop(),Q=a(window).scrollLeft();if(U+W>Q+P){U=Q+P-W}if(U<Q){U=Q}if(T+V>R+S){T=R+S-V}if(T<R){T=R}C.css({left:U,top:T});C.fadeIn(a.browser.msie&&a.browser.version.match(/^[6-8]/)?0:150,"linear");E()};var h=function(T){if(a.trim(T)!=""){var ac=y(M.settings.format.replace(/\s/g,"")),ab=["d","D","j","l","N","S","w","F","m","M","n","Y","y"],X=new Array,aa=new Array;for(var W=0;W<ab.length;W++){if((position=ac.indexOf(ab[W]))>-1){X.push({character:ab[W],position:position})}}X.sort(function(ae,ad){return ae.position-ad.position});a.each(X,function(ae,ad){switch(ad.character){case"d":aa.push("0[1-9]|[12][0-9]|3[01]");break;case"D":aa.push("[a-z]{3}");break;case"j":aa.push("[1-9]|[12][0-9]|3[01]");break;case"l":aa.push("[a-z]+");break;case"N":aa.push("[1-7]");break;case"S":aa.push("st|nd|rd|th");break;case"w":aa.push("[0-6]");break;case"F":aa.push("[a-z]+");break;case"m":aa.push("0[1-9]|1[012]+");break;case"M":aa.push("[a-z]{3}");break;case"n":aa.push("[1-9]|1[012]");break;case"Y":aa.push("[0-9]{4}");break;case"y":aa.push("[0-9]{2}");break}});if(aa.length){X.reverse();a.each(X,function(ae,ad){ac=ac.replace(ad.character,"("+aa[aa.length-ae-1]+")")});aa=new RegExp("^"+ac+"$","ig");if((segments=aa.exec(T.replace(/\s/g,"")))){var R,Q,Z,Y=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],V=["January","February","March","April","May","June","July","August","September","October","November","December"],S,P=true;X.reverse();a.each(X,function(ae,ad){if(!P){return true}switch(ad.character){case"m":case"n":Q=m(segments[ae+1]);break;case"d":case"j":R=m(segments[ae+1]);break;case"D":case"l":case"F":case"M":if(ad.character=="D"||ad.character=="l"){S=M.settings.days}else{S=M.settings.months}P=false;a.each(S,function(af,ag){if(P){return true}if(segments[ae+1].toLowerCase()==ag.substring(0,(ad.character=="D"||ad.character=="M"?3:ag.length)).toLowerCase()){switch(ad.character){case"D":segments[ae+1]=Y[af].substring(0,3);break;case"l":segments[ae+1]=Y[af];break;case"F":segments[ae+1]=V[af];Q=af+1;break;case"M":segments[ae+1]=V[af].substring(0,3);Q=af+1;break}P=true}});break;case"Y":Z=m(segments[ae+1]);break;case"y":Z="19"+m(segments[ae+1]);break}});if(P){var U=new Date(Z,Q-1,R);if(U.getFullYear()==Z&&U.getDate()==R&&U.getMonth()==(Q-1)){return U}}}}return false}};var i=function(P){if(a.browser.mozilla){P.css("MozUserSelect","none")}else{if(a.browser.msie){P.bind("selectstart",function(){return false})}else{P.mousedown(function(){return false})}}};var y=function(P){return P.replace(/([-.*+?^${}()|[\]\/\\])/g,"\\$1")};var B=function(Q){var Y="",T=Q.getDate(),X=Q.getDay(),R=M.settings.days[X],P=Q.getMonth()+1,V=M.settings.months[P-1],W=Q.getFullYear()+"";for(var U=0;U<M.settings.format.length;U++){var S=M.settings.format.charAt(U);switch(S){case"y":W=W.substr(2);case"Y":Y+=W;break;case"m":P=q(P,2);case"n":Y+=P;break;case"M":V=V.substr(0,3);case"F":Y+=V;break;case"d":T=q(T,2);case"j":Y+=T;break;case"D":R=R.substr(0,3);case"l":Y+=R;break;case"N":X++;case"w":Y+=X;break;case"S":if(T%10==1&&T!="11"){Y+="st"}else{if(T%10==2&&T!="12"){Y+="nd"}else{if(T%10==3&&T!="13"){Y+="rd"}else{Y+="th"}}}break;default:Y+=S}}return Y};var w=function(){var S=new Date(x,k+1,0).getDate(),R=new Date(x,k,1).getDay(),U=new Date(x,k,0).getDate(),Q=R-M.settings.first_day_of_week;Q=Q<0?7+Q:Q;N(M.settings.months[k]+", "+x);var V="<tr>";for(var T=0;T<7;T++){V+="<th>"+M.settings.days[(M.settings.first_day_of_week+T)%7].substr(0,2)+"</th>"}V+="</tr><tr>";for(var T=0;T<42;T++){if(T>0&&T%7==0){V+="</tr><tr>"}var X=(T-Q+1);if(T<Q){V+='<td class="dp_not_in_month">'+(U-Q+T+1)+"</td>"}else{if(X>S){V+='<td class="dp_not_in_month">'+(X-S)+"</td>"}else{var W=(M.settings.first_day_of_week+T)%7,P=m(O(x,q(k,2),q(X,2)));class_name="";if(J(P)){if(a.inArray(W,M.settings.weekend_days)>-1){class_name="dp_weekend_disabled"}else{class_name+=" dp_disabled"}}else{if(a.inArray(W,M.settings.weekend_days)>-1){class_name="dp_weekend"}if(k==K&&x==L&&z==X){class_name+=" dp_selected"}else{if(k==j&&x==u&&g==X){class_name+=" dp_current"}}}V+="<td"+(class_name!=""?' class="'+a.trim(class_name)+'"':"")+">"+q(X,2)+"</td>"}}}V+="</tr>";G.html(a(V));G.css("display","")};var d=function(){N(x);var R="<tr>";for(var Q=0;Q<12;Q++){if(Q>0&&Q%3==0){R+="</tr><tr>"}var S="dp_month_"+Q,P=m(O(x,q(Q,2)));if(J(P)){S+=" dp_disabled"}else{if(j==Q&&u==x){S+=" dp_current"}}R+='<td class="'+a.trim(S)+'">'+M.settings.months[Q].substr(0,3)+"</td>"}R+="</tr>";b.html(a(R));b.css("display","")};var v=function(){N(x-7+" - "+(x+4));var R="<tr>";for(var Q=0;Q<12;Q++){if(Q>0&&Q%3==0){R+="</tr><tr>"}var S="",P=m(x-7+Q);if(J(P)){S+=" dp_disabled"}else{if(u==(x-7+Q)){S+=" dp_current"}}R+="<td"+(a.trim(S)!=""?' class="'+a.trim(S)+'"':"")+">"+(x-7+Q)+"</td>"}R+="</tr>";l.html(a(R));l.css("display","")};var E=function(P){if(a.browser.msie&&a.browser.version.match(/^6/)){if(!H){var R=m(C.css("zIndex"))-1;H=jQuery("<iframe>",{src:'javascript:document.write("")',scrolling:"no",frameborder:0,allowtransparency:"true",css:{zIndex:R,position:"absolute",top:-1000,left:-1000,width:C.outerWidth(),height:C.outerHeight(),filter:"progid:DXImageTransform.Microsoft.Alpha(opacity=0)",display:"none"}});a("body").append(H)}switch(P){case"hide":H.css("display","none");break;default:var Q=C.offset();H.css({top:Q.top,left:Q.left,display:"block"})}}};var J=function(R){if(n!==0){var P=(R+"").length;if(P==8&&((n&&R<O(t,q(s,2),q(I,2)))||(!n&&R>O(t,q(s,2),q(I,2))))){return true}else{if(P==6&&((n&&R<O(t,q(s,2)))||(!n&&R>O(t,q(s,2))))){return true}else{if(P==4&&((n&&R<t)||(!n&&R>t))){return true}}}}if(o){R=R+"";var T=m(R.substr(0,4)),U=m(R.substr(4,2))+1,Q=m(R.substr(6,2)),S=false;a.each(o,function(){if(S){return}var W=this;if(a.inArray(T,W[2])>-1||a.inArray("*",W[2])>-1){if((undefined!=U&&a.inArray(U,W[1])>-1)||a.inArray("*",W[1])>-1){if((undefined!=Q&&a.inArray(Q,W[0])>-1)||a.inArray("*",W[0])>-1){if(W[3]=="*"){return(S=true)}var V=new Date(T,U-1,Q).getDay();if(a.inArray(V,W[3])>-1){return(S=true)}}}}});if(S){return true}}return false};var N=function(P){f.find(".dp_caption").html(P);if(n!==0){var Q=x,S=k,R;if(c=="days"){if(n&&--S<0){S=11;Q--}else{if(!n&&++S>11){S=0;Q++}}R=O(Q,q(S,2))}else{if(c=="months"){if(n){Q--}else{Q++}R=Q}else{if(c=="years"){if(n){Q-=7}else{Q+=7}R=Q}}}if(J(R)){f.find(n?".dp_previous":".dp_next").addClass("dp_blocked");f.find(n?".dp_previous":".dp_next").removeClass("dp_hover")}else{f.find(n?".dp_previous":".dp_next").removeClass("dp_blocked")}}};var F=function(){if(G.text()==""||c=="days"){if(G.text()==""){C.css({left:-1000,display:"block"});w();var Q=G.outerWidth(),P=G.outerHeight();f.css("width",Q);b.css({width:Q,height:P});l.css({width:Q,height:P});C.css({display:"none"})}else{w()}b.css("display","none");l.css("display","none")}else{if(c=="months"){d();G.css("display","none");l.css("display","none")}else{if(c=="years"){v();G.css("display","none");b.css("display","none")}}}};var q=function(Q,P){Q+="";while(Q.length<P){Q="0"+Q}return Q};var O=function(){var Q="";for(var P=0;P<arguments.length;P++){Q+=(arguments[P]+"")}return Q};var m=function(P){return parseInt((P===true||P===false?0:P),10)};M.init()};a.fn.Zebra_DatePicker=function(b){return this.each(function(){if(undefined==a(this).data("Zebra_DatePicker")){var c=new a.Zebra_DatePicker(this,b);a(this).data("Zebra_DatePicker",c)}})}})(jQuery);
