/*
    jQuery-SelectBox

    Traditional select elements are very difficult to style by themselves,
    but they are also very usable and feature rich. This plugin attempts to
    recreate all selectbox functionality and appearance while adding
    animation and stylability.

    This product includes software developed
    by RevSystems, Inc (http://www.revsystems.com/) and its contributors

    Please see the accompanying LICENSE.txt for licensing information.
*/
(function(e,d,g){e.fn.borderWidth=function(){return e(this).outerWidth()-e(this).innerWidth()};e.fn.paddingWidth=function(){return e(this).innerWidth()-e(this).width()};e.fn.extraWidth=function(){return e(this).outerWidth(true)-e(this).width()};e.fn.offsetFrom=function(i){var h=e(i);return{left:e(this).offset().left-h.offset().left,top:e(this).offset().top-h.offset().top}};e.fn.maxWidth=function(){var h=0;e(this).each(function(){if(e(this).width()>h){h=e(this).width()}});return h};e.fn.triggerAll=function(h,i){return e(this).each(function(){e(this).triggerHandler(h,i)})};var c=Array.prototype.slice,a=function(){return Math.floor(Math.random()*999999999)};e.proto=function(){var i=arguments[0],h=arguments[1],j=h,l={},k;opts=e.extend({elem:"elem",access:"access",init:"init",instantAccess:false},arguments[2]);if(h._super){l[opts.init]=function(){};j=h.extend(l)}e.fn[i]=function(){var m,n=arguments;e(this).each(function(){var p=e(this),q=p.data(i),o=!q;if(o){q=new j();if(h._super){q[opts.init]=h.prototype.init}q[opts.elem]=p[0];if(q[opts.init]){q[opts.init].apply(q,opts.instantAccess?[]:c.call(n,0))}p.data(i,q)}if(!o||opts.instantAccess){if(q[opts.access]){q[opts.access].apply(q,c.call(n,0))}if(n.length>0){if(e.isFunction(q[n[0]])){m=q[n[0]].apply(q,c.call(n,1))}else{if(n.length===1){if(e.getObject){m=e.getObject(n[0],q)}else{m=q[n[0]]}}else{if(e.setObject){e.setObject(n[0],n[1],q)}else{q[n[0]]=n[1]}}}}else{if(m===k){m=p.data(i)}}}});if(m===k){return e(this)}return m}};var b=function(){return false},f=function(){var q=this,U={},m=null,C=null,u=null,v=null,l=null,ac=null,W="",G=null,V=null,i=null,T,Z,n,af,s,ad,Y,M,aa,w,ae,h,ab,S,Q,L,y,z,j,X,R,J,I,P,H,O,E,B,k,N,p,A,F,x,t,r,K,D;T=function(){u=e("<div class='sb "+U.selectboxClass+" "+m.attr("class")+"' id='sb"+a()+"'></div>").attr("role","listbox").attr("aria-has-popup","true").attr("aria-labelledby",C.attr("id")?C.attr("id"):"");e("body").append(u);var ag=m.children().size()>0?U.displayFormat.call(m.find("option:selected")[0],0,0):"&nbsp;";v=e("<div class='display "+m.attr("class")+"' id='sbd"+a()+"'></div>").append(e("<div class='text'></div>").append(ag)).append(U.arrowMarkup);u.append(v);l=e("<ul class='"+U.selectboxClass+" items "+m.attr("class")+"' role='menu' id='sbdd"+a()+"'></ul>").attr("aria-hidden","true");u.append(l).attr("aria-owns",l.attr("id"));if(m.children().size()===0){l.append(Z().addClass("selected"))}else{m.children().each(function(ah){var ai,aj,ak,al;if(e(this).is("optgroup")){aj=e(this);ak=e("<li class='optgroup'>"+U.optgroupFormat.call(aj[0],ah+1)+"</li>").addClass(aj.is(":disabled")?"disabled":"").attr("aria-disabled",aj.is(":disabled")?"true":"");al=e("<ul class='items'></ul>");ak.append(al);l.append(ak);aj.children("option").each(function(){ai=Z(e(this),ah).addClass(aj.is(":disabled")?"disabled":"").attr("aria-disabled",aj.is(":disabled")?"true":"");al.append(ai)})}else{l.append(Z(e(this),ah))}})}ac=l.find("li").not(".optgroup");u.attr("aria-active-descendant",ac.filter(".selected").attr("id"));l.children(":first").addClass("first");l.children(":last").addClass("last");if(!U.fixedWidth){var o=l.find(".text, .optgroup").maxWidth()+v.extraWidth()+1;u.width(U.maxWidth?Math.min(U.maxWidth,o):o)}else{if(U.maxWidth&&u.width()>U.maxWidth){u.width(U.maxWidth)}}m.before(u).addClass("has_sb").hide().show();ae();K();l.hide();if(!m.is(":disabled")){m.bind("blur.sb",af).bind("focus.sb",n);v.mouseup(J).mouseup(S).click(b).focus(z).blur(j).hover(X,R);O().click(Q).hover(X,R);l.find(".optgroup").hover(X,R).click(b);ac.filter(".disabled").click(b);if(!e.browser.msie||e.browser.version>=9){e(d).resize(e.throttle?e.throttle(100,h):ab)}}else{u.addClass("disabled").attr("aria-disabled");v.click(function(ah){ah.preventDefault()})}u.bind("close.sb",w).bind("destroy.sb",s);m.bind("reload.sb",ad);if(e.fn.tie&&U.useTie){m.bind("domupdate.sb",Y)}};ab=function(){clearTimeout(i);i=setTimeout(h,50)};h=function(){if(u.is(".open")){ae();M(true)}};Z=function(ah,o){if(!ah){ah=e("<option value=''>&nbsp;</option>");o=0}var aj=e("<li id='sbo"+a()+"'></li>").attr("role","option").data("orig",ah[0]).data("value",ah?ah.attr("value"):"").addClass(ah.is(":selected")?"selected":"").addClass(ah.is(":disabled")?"disabled":"").attr("aria-disabled",ah.is(":disabled")?"true":""),ai=e("<div class='item'></div>"),ag=e("<div class='text'></div>").html(U.optionFormat.call(ah[0],0,o+1));return aj.append(ai.append(ag))};n=function(){t();v.triggerHandler("focus")};af=function(){if(!u.is(".open")){v.triggerHandler("blur")}};s=function(o){u.remove();m.unbind(".sb").removeClass("has_sb");e(d).unbind("resize",ab);if(!o){m.removeData("sb")}};ad=function(){var ag=u.is(".open"),o=v.is(".focused");w(true);s(true);q.init(U);if(ag){m.focus();M(true)}else{if(o){m.focus()}}};Y=function(){clearTimeout(V);V=setTimeout(ad,30)};x=function(){u.removeClass("focused");w();D()};D=function(){e(document).unbind("click",x).unbind("keyup",L).unbind("keypress",r).unbind("keydown",r).unbind("keydown",y)};A=function(){e(".sb.open."+U.selectboxClass).triggerAll("close")};t=function(){e(".sb.focused."+U.selectboxClass).not(u[0]).find(".display").blur()};F=function(){e(".sb.open."+U.selectboxClass).not(u[0]).triggerAll("close")};w=function(o){if(u.is(".open")){v.blur();ac.removeClass("hover");D();l.attr("aria-hidden","true");if(o===true){l.hide();u.removeClass("open");u.append(l)}else{l.fadeOut(U.animDuration,function(){u.removeClass("open");u.append(l)})}}};P=function(){var o=null;if(U.ddCtx==="self"){o=u}else{if(e.isFunction(U.ddCtx)){o=e(U.ddCtx.call(m[0]))}else{o=e(U.ddCtx)}}return o};H=function(){return ac.filter(".selected")};O=function(){return ac.not(".disabled")};aa=function(){l.scrollTop(l.scrollTop()+H().offsetFrom(l).top-l.height()/2+H().outerHeight(true)/2)};K=function(){if(e.browser.msie&&e.browser.version<8){e("."+U.selectboxClass+" .display").hide().show()}};M=function(ag){var o,ah=P();t();u.addClass("open");ah.append(l);o=ae();l.attr("aria-hidden","false");if(ag===true){l.show();aa()}else{if(o==="down"){l.slideDown(U.animDuration,aa)}else{l.fadeIn(U.animDuration,aa)}}m.focus()};ae=function(){var aj=P(),aq=0,ah=v.offsetFrom(aj).left,ag=0,ak="",an,o,ap,ao,ai,ar,am,al;l.removeClass("above");l.show().css({maxHeight:"none",position:"relative",visibility:"hidden"});if(!U.fixedWidth){l.width(v.outerWidth()-l.extraWidth()+1)}ap=e(d).scrollTop()+e(d).height()-v.offset().top-v.outerHeight();ao=v.offset().top-e(d).scrollTop();ai=v.offsetFrom(aj).top+v.outerHeight();ar=ap-ao+U.dropupThreshold;if(l.outerHeight()<ap){aq=U.maxHeight?U.maxHeight:ap;ag=ai;ak="down"}else{if(l.outerHeight()<ao){aq=U.maxHeight?U.maxHeight:ao;ag=v.offsetFrom(aj).top-Math.min(aq,l.outerHeight());ak="up"}else{if(ar>=0){aq=U.maxHeight?U.maxHeight:ap;ag=ai;ak="down"}else{if(ar<0){aq=U.maxHeight?U.maxHeight:ao;ag=v.offsetFrom(aj).top-Math.min(aq,l.outerHeight());ak="up"}else{aq=U.maxHeight?U.maxHeight:"none";ag=ai;ak="down"}}}}an=(""+e("body").css("margin-left")).match(/^\d+/)?e("body").css("margin-left"):0;o=(""+e("body").css("margin-top")).match(/^\d+/)?e("body").css("margin-top"):0;am=e().jquery>="1.4.2"?parseInt(an):e("body").offset().left;al=e().jquery>="1.4.2"?parseInt(o):e("body").offset().top;l.hide().css({left:ah+(aj.is("body")?am:0),maxHeight:aq,position:"absolute",top:ag+(aj.is("body")?al:0),visibility:"visible"});if(ak==="up"){l.addClass("above")}return ak};S=function(o){if(u.is(".open")){w()}else{M()}return false};E=function(){var ag=e(this),o=m.val(),ah=ag.data("value");m.find("option").each(function(){this.selected=false});e(ag.data("orig")).each(function(){this.selected=true});ac.removeClass("selected");ag.addClass("selected");u.attr("aria-active-descendant",ag.attr("id"));v.find(".text").attr("title",ag.find(".text").html());v.find(".text").html(U.displayFormat.call(ag.data("orig")));if(o!==ah){m.change()}};Q=function(o){x();m.focus();E.call(this);return false};B=function(){W=""};k=function(aj){var ai,ah,o,ag=O();for(ai=0;ai<ag.size();ai++){o=ag.eq(ai).find(".text");ah=o.children().size()==0?o.text():o.find("*").text();if(aj.length>0&&ah.toLowerCase().match("^"+aj.toLowerCase())){return ag.eq(ai)}}return null};N=function(ag){var o=k(ag);if(o!==null){E.call(o[0]);return true}return false};r=function(o){if(o.ctrlKey||o.altKey){return}if(o.which===38||o.which===40||o.which===8||o.which===32){o.preventDefault()}};p=function(aj){var ai,ah,o=H(),ag=O();for(ai=ag.index(o)+1;ai<ag.size();ai++){ah=ag.eq(ai).find(".text").text();if(ah!==""&&ah.substring(0,1).toLowerCase()===aj.toLowerCase()){E.call(ag.eq(ai)[0]);return true}}return false};y=function(ah){if(ah.altKey||ah.ctrlKey){return false}var ag=H(),o=O();switch(ah.which){case 9:w();j();break;case 35:if(ag.size()>0){ah.preventDefault();E.call(o.filter(":last")[0]);aa()}break;case 36:if(ag.size()>0){ah.preventDefault();E.call(o.filter(":first")[0]);aa()}break;case 38:if(ag.size()>0){if(o.filter(":first")[0]!==ag[0]){ah.preventDefault();E.call(o.eq(o.index(ag)-1)[0])}aa()}break;case 40:if(ag.size()>0){if(o.filter(":last")[0]!==ag[0]){ah.preventDefault();E.call(o.eq(o.index(ag)+1)[0]);aa()}}else{if(ac.size()>1){ah.preventDefault();E.call(ac.eq(0)[0])}}break;default:break}};L=function(o){if(o.altKey||o.ctrlKey){return false}if(o.which!==38&&o.which!==40){W+=String.fromCharCode(o.keyCode);if(N(W)){clearTimeout(G);G=setTimeout(B,U.acTimeout)}else{if(p(String.fromCharCode(o.keyCode))){aa();clearTimeout(G);G=setTimeout(B,U.acTimeout)}else{B();clearTimeout(G)}}}};z=function(){F();u.addClass("focused");e(document).click(x).keyup(L).keypress(r).keydown(r).keydown(y)};j=function(){u.removeClass("focused");v.removeClass("active");e(document).unbind("keyup",L).unbind("keydown",r).unbind("keypress",r).unbind("keydown",y)};X=function(){e(this).addClass("hover")};R=function(){e(this).removeClass("hover")};J=function(){v.addClass("active");e(document).bind("mouseup",I)};I=function(){v.removeClass("active");e(document).unbind("mouseup",I)};this.init=function(o){if(e.browser.msie&&e.browser.version<7){return}m=e(this.elem);if(m.attr("id")){C=e("label[for='"+m.attr("id")+"']:first")}if(!C||C.size()===0){C=m.closest("label")}if(m.hasClass("has_sb")){return}U=e.extend({acTimeout:800,animDuration:200,ddCtx:"body",dropupThreshold:150,fixedWidth:false,maxHeight:false,maxWidth:false,selectboxClass:"selectbox",useTie:false,arrowMarkup:"<div class='arrow_btn'><span class='arrow'></span></div>",displayFormat:g,optionFormat:function(ag,ai){if(e(this).size()>0){var ah=e(this).attr("label");if(ah&&ah.length>0){return ah}return e(this).text()}else{return""}},optgroupFormat:function(ag){return"<span class='label'>"+e(this).attr("label")+"</span>"}},o);U.displayFormat=U.displayFormat||U.optionFormat;T()};this.open=M;this.close=w;this.refresh=ad;this.destroy=s;this.options=function(o){U=e.extend(U,o);ad()}};e.proto("sb",f)}(jQuery,window));


(function(b){b.Zebra_DatePicker=function(B,v){var P={days:"Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday".split(","),direction:0,disabled_dates:!1,first_day_of_week:1,format:"Y-m-d",months:"January,February,March,April,May,June,July,August,September,October,November,December".split(","),offset:[20,-5],readonly_element:!0,show_week_number:!1,view:"days",weekend_days:[0,6]},n,k,w,s,t,x,y,G,C,L,e,h,p,o,f,H,I,J,D,A,l,E,c=this;c.settings={};var F=b(B);c.hide=function(){M("hide");k.css("display",
"none")};c.show=function(){z();var a=k.outerWidth(),d=k.outerHeight(),r=w.offset().left+c.settings.offset[0],i=w.offset().top-d+c.settings.offset[1],g=b(window).width(),N=b(window).height(),f=b(window).scrollTop(),j=b(window).scrollLeft();r+a>j+g&&(r=j+g-a);r<j&&(r=j);i+d>f+N&&(i=f+N-d);i<f&&(i=f);k.css({left:r,top:i});k.fadeIn(b.browser.msie&&b.browser.version.match(/^[6-8]/)?0:150,"linear");M()};var R=function(a){if(b.trim(a)!=""){for(var d=Q(c.settings.format.replace(/\s/g,"")),r="d,D,j,l,N,S,w,F,m,M,n,Y,y".split(","),
i=[],g=[],f=0;f<r.length;f++)(position=d.indexOf(r[f]))>-1&&i.push({character:r[f],position:position});i.sort(function(a,d){return a.position-d.position});b.each(i,function(a,d){switch(d.character){case "d":g.push("0[1-9]|[12][0-9]|3[01]");break;case "D":g.push("[a-z]{3}");break;case "j":g.push("[1-9]|[12][0-9]|3[01]");break;case "l":g.push("[a-z]+");break;case "N":g.push("[1-7]");break;case "S":g.push("st|nd|rd|th");break;case "w":g.push("[0-6]");break;case "F":g.push("[a-z]+");break;case "m":g.push("0[1-9]|1[012]+");
break;case "M":g.push("[a-z]{3}");break;case "n":g.push("[1-9]|1[012]");break;case "Y":g.push("[0-9]{4}");break;case "y":g.push("[0-9]{2}")}});if(g.length&&(i.reverse(),b.each(i,function(a,b){d=d.replace(b.character,"("+g[g.length-a-1]+")")}),g=RegExp("^"+d+"$","ig"),segments=g.exec(a.replace(/\s/g,"")))){var k,e,h,l="Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday".split(","),m="January,February,March,April,May,June,July,August,September,October,November,December".split(","),o,n=!0;i.reverse();
b.each(i,function(a,d){if(!n)return!0;switch(d.character){case "m":case "n":e=j(segments[a+1]);break;case "d":case "j":k=j(segments[a+1]);break;case "D":case "l":case "F":case "M":o=d.character=="D"||d.character=="l"?c.settings.days:c.settings.months;n=!1;b.each(o,function(b,c){if(n)return!0;if(segments[a+1].toLowerCase()==c.substring(0,d.character=="D"||d.character=="M"?3:c.length).toLowerCase()){switch(d.character){case "D":segments[a+1]=l[b].substring(0,3);break;case "l":segments[a+1]=l[b];break;
case "F":segments[a+1]=m[b];e=b+1;break;case "M":segments[a+1]=m[b].substring(0,3),e=b+1}n=!0}});break;case "Y":h=j(segments[a+1]);break;case "y":h="19"+j(segments[a+1])}});if(n&&(a=new Date(h,e-1,k),a.getFullYear()==h&&a.getDate()==k&&a.getMonth()==e-1))return a}return!1}},S=function(a){b.browser.mozilla?a.css("MozUserSelect","none"):b.browser.msie?a.bind("selectstart",function(){return!1}):a.mousedown(function(){return!1})},Q=function(a){return a.replace(/([-.*+?^${}()|[\]\/\\])/g,"\\$1")},T=function(a){for(var d=
"",b=a.getDate(),i=a.getDay(),g=c.settings.days[i],f=a.getMonth()+1,j=c.settings.months[f-1],a=a.getFullYear()+"",e=0;e<c.settings.format.length;e++){var h=c.settings.format.charAt(e);switch(h){case "y":a=a.substr(2);case "Y":d+=a;break;case "m":f=m(f,2);case "n":d+=f;break;case "M":j=j.substr(0,3);case "F":d+=j;break;case "d":b=m(b,2);case "j":d+=b;break;case "D":g=g.substr(0,3);case "l":d+=g;break;case "N":i++;case "w":d+=i;break;case "S":d+=b%10==1&&b!="11"?"st":b%10==2&&b!="12"?"nd":b%10==3&&
b!="13"?"rd":"th";break;default:d+=h}}return d},O=function(){var a=(new Date(f,o+1,0)).getDate(),d=(new Date(f,o,1)).getDay(),r=(new Date(f,o,0)).getDate();d-=c.settings.first_day_of_week;d=d<0?7+d:d;K(c.settings.months[o]+", "+f);var i="<tr>";c.settings.show_week_number&&(i+="<th>"+c.settings.show_week_number+"</th>");for(var g=0;g<7;g++)i+="<th>"+c.settings.days[(c.settings.first_day_of_week+g)%7].substr(0,2)+"</th>";i+="</tr><tr>";for(g=0;g<42;g++){g>0&&g%7==0&&(i+="</tr><tr>");if(g%7==0&&c.settings.show_week_number){var e=
new Date(f,o,g),e=Math.ceil(((e-new Date(f,0,1))/864E5+e.getDay()+1)/7);i+='<td class="dp_week_number">'+e+"</td>"}e=g-d+1;if(g<d)i+='<td class="dp_not_in_month">'+(r-d+g+1)+"</td>";else if(e>a)i+='<td class="dp_not_in_month">'+(e-a)+"</td>";else{var h=(c.settings.first_day_of_week+g)%7,k=j(q(f,m(o,2),m(e,2)));class_name="";u(k)||void 0!=E&&(c.settings.direction[0]>0&&k>E||c.settings.direction[0]<=0&&k<E)?b.inArray(h,c.settings.weekend_days)>-1?class_name="dp_weekend_disabled":class_name+=" dp_disabled":
(b.inArray(h,c.settings.weekend_days)>-1&&(class_name="dp_weekend"),o==I&&f==J&&H==e?class_name+=" dp_selected":o==G&&f==C&&L==e&&(class_name+=" dp_current"));i+="<td"+(class_name!=""?' class="'+b.trim(class_name)+'"':"")+">"+m(e,2)+"</td>"}}i+="</tr>";t.html(b(i));t.css("display","")},M=function(a){if(b.browser.msie&&b.browser.version.match(/^6/)){if(!A){var d=j(k.css("zIndex"))-1;A=jQuery("<iframe>",{src:'javascript:document.write("")',scrolling:"no",frameborder:0,allowtransparency:"true",css:{zIndex:d,
position:"absolute",top:-1E3,left:-1E3,width:k.outerWidth(),height:k.outerHeight(),filter:"progid:DXImageTransform.Microsoft.Alpha(opacity=0)",display:"none"}});b("body").append(A)}switch(a){case "hide":A.css("display","none");break;default:a=k.offset(),A.css({top:a.top,left:a.left,display:"block"})}}},u=function(a){if(l!==0){var d=(a+"").length;if(d==8&&(l&&a<q(h,m(e,2),m(p,2))||!l&&a>q(h,m(e,2),m(p,2))))return!0;else if(d==6&&(l&&a<q(h,m(e,2))||!l&&a>q(h,m(e,2))))return!0;else if(d==4&&(l&&a<h||
!l&&a>h))return!0}if(D){a+="";var c=j(a.substr(0,4)),i=j(a.substr(4,2))+1,g=j(a.substr(6,2)),f=!1;b.each(D,function(){if(!f&&(b.inArray(c,this[2])>-1||b.inArray("*",this[2])>-1))if(void 0!=i&&b.inArray(i,this[1])>-1||b.inArray("*",this[1])>-1)if(void 0!=g&&b.inArray(g,this[0])>-1||b.inArray("*",this[0])>-1){if(this[3]=="*")return f=!0;var a=(new Date(c,i-1,g)).getDay();if(b.inArray(a,this[3])>-1)return f=!0}});if(f)return!0}return!1},K=function(a){s.find(".dp_caption").html(a);if(l!==0){var a=f,d=
o,b;n=="days"?(l&&--d<0?(d=11,a--):!l&&++d>11&&(d=0,a++),b=q(a,m(d,2))):n=="months"?(l?a--:a++,b=a):n=="years"&&(l?a-=7:a+=7,b=a);u(b)?(s.find(l?".dp_previous":".dp_next").addClass("dp_blocked"),s.find(l?".dp_previous":".dp_next").removeClass("dp_hover")):s.find(l?".dp_previous":".dp_next").removeClass("dp_blocked")}},z=function(){if(t.text()==""||n=="days"){if(t.text()==""){k.css({left:-1E3,display:"block"});O();var a=t.outerWidth(),d=t.outerHeight();s.css("width",a);x.css({width:a,height:d});y.css({width:a,
height:d});k.css({display:"none"})}else O();x.css("display","none");y.css("display","none")}else if(n=="months"){K(f);a="<tr>";for(d=0;d<12;d++){d>0&&d%3==0&&(a+="</tr><tr>");var e="dp_month_"+d,i=j(q(f,m(d,2)));u(i)?e+=" dp_disabled":G==d&&C==f&&(e+=" dp_current");a+='<td class="'+b.trim(e)+'">'+c.settings.months[d].substr(0,3)+"</td>"}a+="</tr>";x.html(b(a));x.css("display","");t.css("display","none");y.css("display","none")}else if(n=="years"){K(f-7+" - "+(f+4));a="<tr>";for(d=0;d<12;d++)d>0&&
d%3==0&&(a+="</tr><tr>"),e="",i=j(f-7+d),u(i)?e+=" dp_disabled":C==f-7+d&&(e+=" dp_current"),a+="<td"+(b.trim(e)!=""?' class="'+b.trim(e)+'"':"")+">"+(f-7+d)+"</td>";a+="</tr>";y.html(b(a));y.css("display","");t.css("display","none");x.css("display","none")}},m=function(a,d){for(a+="";a.length<d;)a="0"+a;return a},q=function(){for(var a="",d=0;d<arguments.length;d++)a+=arguments[d]+"";return a},j=function(a){return parseInt(a===!0||a===!1?0:a,10)};c._keyup=function(a){(k.css("display")=="block"||
a.which==27)&&c.hide();return!0};c._mousedown=function(a){if(k.css("display")=="block"){if(b(a.target).get(0)===w.get(0))return!0;b(a.target).parents().filter(".Zebra_DatePicker").length==0&&c.hide()}return!0};(function(){c.settings=b.extend({},P,v);c.settings.readonly_element&&F.attr("readonly","readonly");n=c.settings.view;var a;w=b('<button type="button" class="Zebra_DatePicker_Icon">Pick a date</button>');c.icon=w;l=!b.isArray(c.settings.direction)&&(c.settings.direction===!0||j(c.settings.direction)>
0)||b.isArray(c.settings.direction)&&c.settings.direction.length==2&&(c.settings.direction[0]===!0||j(c.settings.direction[0])>0)?!0:!b.isArray(c.settings.direction)&&(c.settings.direction===!1||j(c.settings.direction)<0)||b.isArray(c.settings.direction)&&c.settings.direction.length==2&&(c.settings.direction[0]===!1||j(c.settings.direction[0])<0)?!1:0;a=new Date;e=a.getMonth();G=a.getMonth();h=a.getFullYear();C=a.getFullYear();p=a.getDate();L=a.getDate();l!==0&&(a=new Date(h,e,p+j(b.isArray(c.settings.direction)?
c.settings.direction[0]:c.settings.direction)),e=a.getMonth(),h=a.getFullYear(),p=a.getDate());l!==0&&b.isArray(c.settings.direction)&&c.settings.direction.length==2&&(a=new Date(h,e,p+(l>0?1:-1)*j(c.settings.direction[1])),E=j(q(a.getFullYear(),m(a.getMonth(),2),m(a.getDate(),2))));if(u(q(h,m(e,2),m(p,2)))){for(;u(h);)l?h++:h--,e=0;for(;u(q(h,m(e,2)));)l?e++:e--,e>11?(h++,e=0):e<0&&(h--,e=0),p=1;for(;u(q(h,m(e,2),m(p,2)));)l?p++:p--,a=new Date(h,e,p),h=a.getFullYear(),e=a.getMonth(),p=a.getDate()}(c.settings.readonly_element?
w.add(F):w).bind("click",function(a){a.preventDefault();k.css("display")!="none"?c.hide():((a=R(F.val()))?(I=a.getMonth(),o=a.getMonth(),J=a.getFullYear(),f=a.getFullYear(),H=a.getDate(),u(q(J,m(I,2),m(H,2)))&&(o=e,f=h)):(o=e,f=h),z(),c.show())});w.insertAfter(B);k=b('<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.datepicker=k;s=k.find("table.dp_header").first();t=k.find("table.dp_daypicker").first();x=k.find("table.dp_monthpicker").first();y=k.find("table.dp_yearpicker").first();b("body").append(k);k.delegate("td:not(.dp_disabled, .dp_weekend_disabled, .dp_not_in_month, .dp_blocked, .dp_week_number)","mouseover",function(){b(this).addClass("dp_hover")}).delegate("td:not(.dp_disabled, .dp_weekend_disabled, .dp_not_in_month, .dp_blocked, .dp_week_number)","mouseout",function(){b(this).removeClass("dp_hover")});
S(s.find("td"));s.find(".dp_previous").bind("click",function(){b(this).hasClass("dp_blocked")||(n=="months"?f--:n=="years"?f-=12:--o<0&&(o=11,f--),z())});s.find(".dp_caption").bind("click",function(){n=n=="days"?"months":n=="months"?"years":"days";z()});s.find(".dp_next").bind("click",function(){b(this).hasClass("dp_blocked")||(n=="months"?f++:n=="years"?f+=12:++o==12&&(o=0,f++),z())});t.delegate("td:not(.dp_disabled, .dp_weekend_disabled, .dp_not_in_month, .dp_week_number)","click",function(){F.val(T(new Date(f,
o,j(b(this).html()))));c.hide()});x.delegate("td:not(.dp_disabled)","click",function(){var a=b(this).attr("class").match(/dp\_month\_([0-9]+)/);o=j(a[1]);n="days";z()});y.delegate("td:not(.dp_disabled)","click",function(){f=j(b(this).html());n="months";z()});b(document).bind({mousedown:c._mousedown,keyup:c._keyup});D=[];b.each(c.settings.disabled_dates,function(){for(var a=this.split(" "),c=0;c<4;c++){a[c]||(a[c]="*");a[c]=b.inArray(",",a[c])>-1?a[c].split(","):Array(a[c]);for(var e=0;e<a[c].length;e++)if(b.inArray("-",
a[c][e])>-1){var f=a[c][e].match(/^([0-9]+)\-([0-9]+)/);if(null!=f){for(var h=j(f[1]);h<=j(f[2]);h++)b.inArray(h,a[c])==-1&&a[c].push(h+"");a[c].splice(e,1)}}for(e=0;e<a[c].length;e++)a[c][e]=isNaN(j(a[c][e]))?a[c][e]:j(a[c][e])}D.push(a)})})()};b.fn.Zebra_DatePicker=function(B){return this.each(function(){if(void 0!=b(this).data("Zebra_DatePicker")){var v=b(this).data("Zebra_DatePicker");v.icon.remove();v.datepicker.remove();b(document).unbind("keyup",v._keyup);b(document).unbind("mousedown",v._mousedown)}v=
new b.Zebra_DatePicker(this,B);b(this).data("Zebra_DatePicker",v)})}})(jQuery);

/*
// jQuery multiSelect
//
// Version 1.2.2 beta
//
// Cory S.N. LaViska
// A Beautiful Site (http://abeautifulsite.net/)
// 09 September 2009
//
// Visit http://abeautifulsite.net/notebook/62 for more information
//
// (Amended by Andy Richmond, Letters & Science Deans' Office, University of California, Davis)
//
// Usage: $('#control_id').multiSelect( options, callback )
//
// Options:  selectAll          - whether or not to display the Select All option; true/false, default = true
//           selectAllText      - text to display for selecting/unselecting all options simultaneously
//           noneSelected       - text to display when there are no selected items in the list
//           oneOrMoreSelected  - text to display when there are one or more selected items in the list
//                                (note: you can use % as a placeholder for the number of items selected).
//                                Use * to show a comma separated list of all selected; default = '% selected'
//           optGroupSelectable - whether or not optgroups are selectable if you use them; true/false, default = false
//           listHeight         - the max height of the droptdown options
//
// Dependencies:  jQuery 1.2.6 or higher (http://jquery.com/)
//
// Change Log:
//
//		1.0.1	- Updated to work with jQuery 1.2.6+ (no longer requires the dimensions plugin)
//				- Changed $(this).offset() to $(this).position(), per James' and Jono's suggestions
//
//		1.0.2	- Fixed issue where dropdown doesn't scroll up/down with keyboard shortcuts
//				- Changed '$' in setTimeout to use 'jQuery' to support jQuery.noConflict
//				- Renamed from jqueryMultiSelect.* to jquery.multiSelect.* per the standard recommended at
//				  http://docs.jquery.com/Plugins/Authoring (does not affect API methods)
//
//		1.0.3	- Now uses the bgiframe plugin (if it exists) to fix the IE6 layering bug.
//              - Forces IE6 to use a min-height of 200px (this needs to be added to the options)
//
//		1.1.0	- Added the ability to update the options dynamically via javascript: multiSelectOptionsUpdate(JSON)
//              - Added a title that displays the whole comma delimited list when using oneOrMoreSelected = *
//              - Moved some of the functions to be closured to make them private
//              - Changed the way the keyboard navigation worked to more closely match how a standard dropdown works
//              - ** by Andy Richmond **
//
//		1.2.0	- Added support for optgroups
//              - Added the ability for selectable optgroups (i.e. select all for an optgroup)
//              - ** by Andy Richmond **
//
//		1.2.1	- Fixed bug where input text overlapped dropdown arrow in IE (i.e. when using oneOrMoreSelected = *)
//              - Added option "listHeight" for min-height of the dropdown
//              - Fixed bug where bgiframe was causing a horizontal scrollbar and on short lists extra whitespace below the options
//              - ** by Andy Richmond **
//
//		1.2.2	- Fixed bug where the keypress stopped showing the dropdown because in jQuery 1.3.2 they changed the way ':visible' works
//              - Fixed some other bugs in the way the keyboard interface worked
//              - Changed the main textbox to an <a> tag (with 'display: inline-block') to prevent the display text from being selected/highlighted
//              - Added the ability to jump to an option by typing the first character of that option (simular to a normal drop down)
//              - ** by Andy Richmond **
//				- Added [] to make each control submit an HTML array so $.serialize() works properly
//
// Licensing & Terms of Use
//
// This plugin is dual-licensed under the GNU General Public License and the MIT License and
// is copyright 2008 A Beautiful Site, LLC.
//
*/
if(jQuery) (function($){

	// render the html for a single option
	function renderOption(id, option)
	{
		var html = '<label><input type="checkbox" name="' + id + '" value="' + option.value + '"';
		if( option.selected ){
			html += ' checked="checked"';
		}
		html += ' />' + option.text + '</label>';

		return html;
	}

	// render the html for the options/optgroups
	function renderOptions(id, options, o)
	{
		var html = "";

		for(var i = 0; i < options.length; i++) {
			if(options[i].optgroup) {
				html += '<label class="optGroup">';

				if(o.optGroupSelectable) {
					html += '<input type="checkbox" class="optGroup" />' + options[i].optgroup;
				}
				else {
					html += options[i].optgroup;
				}

				html += '</label><div class="optGroupContainer">';

				html += renderOptions(id, options[i].options, o);

				html += '</div>';
			}
			else {
				html += renderOption(id, options[i]);
			}
		}

		return html;
	}

	// Building the actual options
	function buildOptions(options)
	{
		var multiSelect = $(this);
		var multiSelectOptions = multiSelect.next('.multiSelectOptions');
		var o = multiSelect.data("config");
		var callback = multiSelect.data("callback");

		// clear the existing options
		multiSelectOptions.html("");
		var html = "";

		// if we should have a select all option then add it
		if( o.selectAll ) {
			html += '<label class="selectAll"><input type="checkbox" class="selectAll" />' + o.selectAllText + '</label>';
		}

		// generate the html for the new options
		html += renderOptions(multiSelect.attr('rel'), options, o);

		multiSelectOptions.html(html);

		// variables needed to account for width changes due to a scrollbar
		var initialWidth = multiSelectOptions.width();
		var hasScrollbar = false;

		// set the height of the dropdown options
		if(multiSelectOptions.height() > o.listHeight) {
			multiSelectOptions.css("height", o.listHeight + 'px');
			hasScrollbar = true;
		} else {
			multiSelectOptions.css("height", '');
		}

		// if the there is a scrollbar and the browser did not already handle adjusting the width (i.e. Firefox) then we will need to manaually add the scrollbar width
		var scrollbarWidth = hasScrollbar && (initialWidth == multiSelectOptions.width()) ? 17 : 0;

		// set the width of the dropdown options
		if((multiSelectOptions.width() + scrollbarWidth) < multiSelect.outerWidth()) {
			multiSelectOptions.css("width", multiSelect.outerWidth() - 2/*border*/ + 'px');
		} else {
			multiSelectOptions.css("width", (multiSelectOptions.width() + scrollbarWidth) + 'px');
		}

		// Apply bgiframe if available on IE6
		if( $.fn.bgiframe ) multiSelect.next('.multiSelectOptions').bgiframe( { width: multiSelectOptions.width(), height: multiSelectOptions.height() });

		// Handle selectAll oncheck
		if(o.selectAll) {			
			var checkedAll = false;
		
			multiSelectOptions.find('INPUT.selectAll').click( function() {				
				// update all the child checkboxes
				if (checkedAll) {
					multiSelectOptions.find('INPUT:checkbox')
						.attr('checked', false)
						.parent('label')
						.removeClass('checked');
						
					checkedAll = false;
				} else {
				    multiSelectOptions.find('INPUT:checkbox')
						.attr('checked', true)
						.parent('label')
						.addClass('checked');
					
					checkedAll = true;
				}								
			});
		}

		// Handle OptGroup oncheck
		if(o.optGroupSelectable) {
			multiSelectOptions.addClass('optGroupHasCheckboxes');

			multiSelectOptions.find('INPUT.optGroup').click( function() {
				// update all the child checkboxes				
				$(this).parent().next().find('INPUT:checkbox').attr('checked', $(this).attr('checked')).parent("LABEL").toggleClass('checked', $(this).attr('checked'));
			});
		}

		// Handle all checkboxes
		multiSelectOptions.find('INPUT:checkbox').unbind('click.check').bind('click.check', function() {
			// set the label checked class
			$(this).parent("LABEL").toggleClass('checked', $(this).attr('checked'));

			updateSelected.call(multiSelect);
			multiSelect.focus();
			if($(this).parent().parent().hasClass('optGroupContainer')) {
				updateOptGroup.call(multiSelect, $(this).parent().parent().prev());
			}
			if( callback ) {
				callback($(this));
			}
		});

		// Initial display
		multiSelectOptions.each( function() {
			$(this).find('INPUT:checked').parent().addClass('checked');
		});

		// Initialize selected and select all
		updateSelected.call(multiSelect);

		// Initialize optgroups
		if(o.optGroupSelectable) {
			multiSelectOptions.find('LABEL.optGroup').each( function() {
				updateOptGroup.call(multiSelect, $(this));
			});
		}

		// Handle hovers
		multiSelectOptions.find('LABEL:has(INPUT)').hover( function() {
			$(this).parent().find('LABEL').removeClass('hover');
			$(this).addClass('hover');
		}, function() {
			$(this).parent().find('LABEL').removeClass('hover');
		});

		// Keyboard
		multiSelect.keydown( function(e) {

			var multiSelectOptions = $(this).next('.multiSelectOptions');

			// Is dropdown visible?
			if( multiSelectOptions.css('visibility') != 'hidden' ) {
				// Dropdown is visible
				// Tab
				if( e.keyCode == 9 ) {
					$(this).addClass('focus').trigger('click'); // esc, left, right - hide
					$(this).focus().next(':input').focus();
					return true;
				}

				// ESC, Left, Right
				if( e.keyCode == 27 || e.keyCode == 37 || e.keyCode == 39 ) {
					// Hide dropdown
					$(this).addClass('focus').trigger('click');
				}
				// Down || Up
				if( e.keyCode == 40 || e.keyCode == 38) {
					var allOptions = multiSelectOptions.find('LABEL');
					var oldHoverIndex = allOptions.index(allOptions.filter('.hover'));
					var newHoverIndex = -1;

					// if there is no current highlighted item then highlight the first item
					if(oldHoverIndex < 0) {
						// Default to first item
						multiSelectOptions.find('LABEL:first').addClass('hover');
					}
					// else if we are moving down and there is a next item then move
					else if(e.keyCode == 40 && oldHoverIndex < allOptions.length - 1)
					{
						newHoverIndex = oldHoverIndex + 1;
					}
					// else if we are moving up and there is a prev item then move
					else if(e.keyCode == 38 && oldHoverIndex > 0)
					{
						newHoverIndex = oldHoverIndex - 1;
					}

					if(newHoverIndex >= 0) {
						$(allOptions.get(oldHoverIndex)).removeClass('hover'); // remove the current highlight
						$(allOptions.get(newHoverIndex)).addClass('hover'); // add the new highlight

						// Adjust the viewport if necessary
						adjustViewPort(multiSelectOptions);
					}

					return false;
				}

				// Enter, Space
				if( e.keyCode == 13 || e.keyCode == 32 ) {
					var selectedCheckbox = multiSelectOptions.find('LABEL.hover INPUT:checkbox');

					// Set the checkbox (and label class)
					selectedCheckbox.attr('checked', !selectedCheckbox.attr('checked')).parent("LABEL").toggleClass('checked', selectedCheckbox.attr('checked'));

					// if the checkbox was the select all then set all the checkboxes
					if(selectedCheckbox.hasClass("selectAll")) {
						multiSelectOptions.find('INPUT:checkbox').attr('checked', selectedCheckbox.attr('checked')).parent("LABEL").addClass('checked').toggleClass('checked', selectedCheckbox.attr('checked'));
					}

					updateSelected.call(multiSelect);

					if( callback ) callback($(this));
					return false;
				}

				// Any other standard keyboard character (try and match the first character of an option)
				if( e.keyCode >= 33 && e.keyCode <= 126 ) {
					// find the next matching item after the current hovered item
					var match = multiSelectOptions.find('LABEL:startsWith(' + String.fromCharCode(e.keyCode) + ')');

					var currentHoverIndex = match.index(match.filter('LABEL.hover'));

					// filter the set to any items after the current hovered item
					var afterHoverMatch = match.filter(function (index) {
						return index > currentHoverIndex;
					});

					// if there were no item after the current hovered item then try using the full search results (filtered to the first one)
					match = (afterHoverMatch.length >= 1 ? afterHoverMatch : match).filter("LABEL:first");

					if(match.length == 1) {
						// if we found a match then move the hover
						multiSelectOptions.find('LABEL.hover').removeClass('hover');
						match.addClass('hover');

						adjustViewPort(multiSelectOptions);
					}
				}
			} else {
				// Dropdown is not visible
				if( e.keyCode == 38 || e.keyCode == 40 || e.keyCode == 13 || e.keyCode == 32 ) { //up, down, enter, space - show
					// Show dropdown
					$(this).removeClass('focus').trigger('click');
					multiSelectOptions.find('LABEL:first').addClass('hover');
					return false;
				}
				//  Tab key
				if( e.keyCode == 9 ) {
					// Shift focus to next INPUT element on page
					multiSelectOptions.next(':input').focus();
					return true;
				}
			}
			// Prevent enter key from submitting form
			if( e.keyCode == 13 ) return false;
		});
	}

	// Adjust the viewport if necessary
	function adjustViewPort(multiSelectOptions)
	{
		// check for and move down
		var selectionBottom = multiSelectOptions.find('LABEL.hover').position().top + multiSelectOptions.find('LABEL.hover').outerHeight();

		if(selectionBottom > multiSelectOptions.innerHeight()){
			multiSelectOptions.scrollTop(multiSelectOptions.scrollTop() + selectionBottom - multiSelectOptions.innerHeight());
		}

		// check for and move up
		if(multiSelectOptions.find('LABEL.hover').position().top < 0){
			multiSelectOptions.scrollTop(multiSelectOptions.scrollTop() + multiSelectOptions.find('LABEL.hover').position().top);
		}
	}

	// Update the optgroup checked status
	function updateOptGroup(optGroup)
	{
		var multiSelect = $(this);
		var o = multiSelect.data("config");

		// Determine if the optgroup should be checked
		if(o.optGroupSelectable) {
			var optGroupSelected = true;
			$(optGroup).next().find('INPUT:checkbox').each( function() {
				if( !$(this).attr('checked') ) {
					optGroupSelected = false;
					return false;
				}
			});

			$(optGroup).find('INPUT.optGroup').attr('checked', optGroupSelected).parent("LABEL").toggleClass('checked', optGroupSelected);
		}
	}

	// Update the textbox with the total number of selected items, and determine select all
	function updateSelected() {
		var multiSelect = $(this);
		var multiSelectOptions = multiSelect.next('.multiSelectOptions');
		var o = multiSelect.data("config");

		var i = 0;
		var selectAll = true;
		var display = '';
		multiSelectOptions.find('INPUT:checkbox').not('.selectAll, .optGroup').each( function() {
			if( $(this).attr('checked') ) {
				i++;
				display = display + $.trim($(this).parent().text()) + ', ';
			}
			else selectAll = false;
		});

		// trim any end comma and surounding whitespace
		display = display.replace(/\s*\,\s*$/,'');

		if( i == 0 ) {
			multiSelect.find("span").html( o.noneSelected );
		} else {
			if( o.oneOrMoreSelected == '*' ) {
				multiSelect.find("span").html( display );
				multiSelect.attr( "title", display );
			} else {
				multiSelect.find("span").html( o.oneOrMoreSelected.replace('%', i) );
			}
		}

		// Determine if Select All should be checked
		if(o.selectAll) {
			multiSelectOptions.find('INPUT.selectAll').attr('checked', selectAll).parent("LABEL").toggleClass('checked', selectAll);
		}
	}

	$.extend($.fn, {
		multiSelect: function(o, callback) {
			// Default options
			if( !o ) o = {};
			if( o.selectAll == undefined ) o.selectAll = true;
			if( o.selectAllText == undefined ) o.selectAllText = "Select All";
			if( o.noneSelected == undefined ) o.noneSelected = 'Select options';
			if( o.oneOrMoreSelected == undefined ) o.oneOrMoreSelected = '% selected';
			if( o.optGroupSelectable == undefined ) o.optGroupSelectable = false;
			if( o.listHeight == undefined ) o.listHeight = 150;

			// Initialize each multiSelect
			$(this).each( function() {
				var select = $(this);
				var html = '<a rel="'+select.attr('name')+'" href="javascript:;" class="multiSelect"><span></span></a>';
				html += '<div class="multiSelectOptions" style="position: absolute; z-index: 99999; visibility: hidden;"></div>';
				$(select).after(html);

				var multiSelect = $(select).next('.multiSelect');
				var multiSelectOptions = multiSelect.next('.multiSelectOptions');

				// if the select object had a width defined then match the new multilsect to it
				multiSelect.find("span").css("width", $(select).width() + 'px');

				// Attach the config options to the multiselect
				multiSelect.data("config", o);

				// Attach the callback to the multiselect
				multiSelect.data("callback", callback);

				// Serialize the select options into json options
				var options = [];
				$(select).children().each( function() {
					if(this.tagName.toUpperCase() == 'OPTGROUP')
					{
						var suboptions = [];
						options.push({ optgroup: $(this).attr('label'), options: suboptions });

						$(this).children('OPTION').each( function() {
							if( $(this).val() != '' ) {
								suboptions.push({ text: $(this).html(), value: $(this).val(), selected: $(this).attr('selected') });
							}
						});
					}
					else if(this.tagName.toUpperCase() == 'OPTION')
					{
						if( $(this).val() != '' ) {
							options.push({ text: $(this).html(), value: $(this).val(), selected: $(this).attr('selected') });
						}
					}
				});

				// Eliminate the original form element
				$(select).remove();

				// Add the id that was on the original select element to the new input
				multiSelect.attr("id", $(select).attr("id"));

				// Build the dropdown options
				buildOptions.call(multiSelect, options);

				// Events
				multiSelect.hover( function() {
					$(this).addClass('hover');
				}, function() {
					$(this).removeClass('hover');
				}).click( function() {
					// Show/hide on click
					if( $(this).hasClass('active') ) {
						$(this).multiSelectOptionsHide();
					} else {
						$(this).multiSelectOptionsShow();
					}
					return false;
				}).focus( function() {
					// So it can be styled with CSS
					$(this).addClass('focus');
				}).blur( function() {
					// So it can be styled with CSS
					$(this).removeClass('focus');
				});

				// Add an event listener to the window to close the multiselect if the user clicks off
				$(document).click( function(event) {
					// If somewhere outside of the multiselect was clicked then hide the multiselect
					if(!($(event.target).parents().andSelf().is('.multiSelectOptions'))){
						multiSelect.multiSelectOptionsHide();
					}
				});
			});
		},

		// Update the dropdown options
		multiSelectOptionsUpdate: function(options) {
			buildOptions.call($(this), options);
		},

		// Hide the dropdown
		multiSelectOptionsHide: function() {
			$(this).removeClass('active').removeClass('hover').next('.multiSelectOptions').css('visibility', 'hidden');
		},

		// Show the dropdown
		multiSelectOptionsShow: function() {
			var multiSelect = $(this);
			var multiSelectOptions = multiSelect.next('.multiSelectOptions');
			var o = multiSelect.data("config");

			// Hide any open option boxes
			$('.multiSelect').multiSelectOptionsHide();
			multiSelectOptions.find('LABEL').removeClass('hover');
			multiSelect.addClass('active').next('.multiSelectOptions').css('visibility', 'visible');
			multiSelect.focus();

			// reset the scroll to the top
			multiSelect.next('.multiSelectOptions').scrollTop(0);

			// Position it
			var offset = multiSelect.position();
			multiSelect.next('.multiSelectOptions').css({ top:  offset.top + $(this).outerHeight() + 'px' });
			multiSelect.next('.multiSelectOptions').css({ left: offset.left + 'px' });
		},

		// get a coma-delimited list of selected values
		selectedValuesString: function() {
			var selectedValues = "";
			$(this).next('.multiSelectOptions').find('INPUT:checkbox:checked').not('.optGroup, .selectAll').each(function() {
				selectedValues += $(this).attr('value') + ",";
			});
			// trim any end comma and surounding whitespace
			return selectedValues.replace(/\s*\,\s*$/,'');
		}
	});

	// add a new ":startsWith" search filter
	$.expr[":"].startsWith = function(el, i, m) {
		var search = m[3];
		if (!search) return false;
		return eval("/^[/s]*" + search + "/i").test($(el).text());
	};

})(jQuery);


$.frontendValidator = {

	_digit: function() {
		$(this).val($(this).val().replace(/[^0-9]/gi,""));
	},

	_instantRequest: function() {
		$(this).parents("form").submit();
	},

	_instantRequestFocus: function() {
		$.WBValidatorTempTextFocus = $(this).val();
	},

	_instantRequestBlur: function() {
		if ($.WBValidatorTempTextFocus != $(this).val()) $(this).parents("form").submit();
		$.WBValidatorTempTextFocus;
	},

	init: function(el) {
		var fv = this;
		var filter = "";

		if (typeof el != "undefined") filter = "#" + el.attr("id") + " ";

		$(filter + ".digitValidator")
			.unbind("keyup", fv._digit)
			.bind("keyup", fv._digit);

		$(filter + ".instantRequest").each(function() {
			$this = $(this);

			if ($this.attr("type") == "text") {
				$.WBValidatorTempTextFocus = "";
				$this.unbind("focus", fv._instantRequestFocus).bind("focus", fv._instantRequestFocus);
				$this.unbind("blur", fv._instantRequestBlur).bind("blur", fv._instantRequestBlur);
			} else {
				$this.unbind("change", fv._instantRequest).bind("change", fv._instantRequest);
			}



		});
	}

};

$.startStopSlider = function() {
	// SET THIS VARIABLE FOR DELAY, 1000 = 1 SECOND
	var delayLength = 8000;

	var $sliders = $("#mainContent .slide");

	function doMove(panelWidth, tooFar) {
		var leftValue = $("#mover").css("left");

		// Fix for IE
		if (leftValue == "auto") { leftValue = 0; };

		var movement = parseFloat(leftValue, 10) - panelWidth;

		if (movement == tooFar) {
			$sliders.find("img").animate({
				"top": 50
			}, function() {
				$("#mover").animate({
					"left": 0
				}, function() {

				});
			});
		}
		else {
			$sliders.find("img").animate({
				"top": 50
			}, function() {
				$("#mover").animate({
					"left": movement
				}, function() {

				});
			});
		}
	}

	$(function(){

		var $slide1 = $("#slide-1");

		var panelWidth = $slide1.css("width");
		var panelPaddingLeft = $slide1.css("paddingLeft");
		var panelPaddingRight = $slide1.css("paddingRight");

		panelWidth = parseFloat(panelWidth, 10);
		panelPaddingLeft = parseFloat(panelPaddingLeft, 10);
		panelPaddingRight = parseFloat(panelPaddingRight, 10);

		panelWidth = panelWidth + panelPaddingLeft + panelPaddingRight;

		var numPanels = $sliders.length;
		var tooFar = -(panelWidth * numPanels);
		var totalMoverwidth = numPanels * panelWidth;
		$("#mover").css("width", totalMoverwidth);

		$sliders.append('<a href="#" class="slider-stopper sliderStop"><span>Stop</span></a>');

		sliderIntervalID = setInterval(function(){
			doMove(panelWidth, tooFar);
		}, delayLength);

		$("#mainContent .slider-stopper").click(function(){
			if ($(this).hasClass("sliderStop")) {
				clearInterval(sliderIntervalID);
				//$(this).text("Start");
				$(this).removeClass("sliderStop").addClass("sliderPlay");
			}
			else {
				sliderIntervalID = setInterval(function(){
					doMove(panelWidth, tooFar);
				}, delayLength);
				//$(this).text("Stop");
				$(this).removeClass("sliderPlay").addClass("sliderStop");
			}

		});

	});
}

$.initShare = function() {
	var $sh = $('#shareBox');
	if (!$sh.length) return;

	$sh.find('.shareWithTumblr').click(function() {
		var d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),f='http://www.tumblr.com/share',l=d.location,e=encodeURIComponent,p='?v=3&u='+e(l.href) +'&t='+e(d.title) +'&s='+e(s),u=f+p;try{if(!/^(.*\.)?tumblr[^.]*$/.test(l.host))throw(0);tstbklt();}catch(z){a =function(){if(!w.open(u,'t','toolbar=0,resizable=0,status=1,width=450,height=430'))l.href=u;};if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else a();}void(0);
		return false;
	});
}


$.initWBForm = function() {
	var $c = $('#filterBox'),
		$forC = $c.find('.ctravel'),
		$forB = $c.find('.btravel'),

		substr_count = function(haystack, needle, offset, length) {
		    var pos = 0,
		        cnt = 0;

		    haystack += '';
		    needle += '';
		    if (isNaN(offset)) {
		        offset = 0;
		    }
		    if (isNaN(length)) {
		        length = 0;
		    }
		    offset--;

		    while ((offset = haystack.indexOf(needle, offset + 1)) != -1) {
		        if (length > 0 && (offset + needle.length) > length) {
		            return false;
		        } else {
		            cnt++;
		        }
		    }

		    return cnt;
		};

	$c.find('i').remove();

	$c.find('select[name=destination]').unbind().bind('change.toggler, blur.toggler, focus.toggler', function() {
		if ($(this).val() == 'c') {
			$forC.show();
			$forB.hide();
		} else {
			$forB.show();
			$forC.hide();
		}
	}).change();

	$c.find('.multi').each(function() {
		var $this = $(this);

		$this.multiSelect({
			selectAll: true,
			selectAllText: 'Összes kijelölése',
			noneSelected: 'Összes',
			oneOrMoreSelected: '*'
		});
	});

	$c.find('.datepicker').Zebra_DatePicker({
		days: $.datepickerday,
		months: $.datepickermonth,
		view: 'years',
		//readonly_element: false,
		direction: true,
		first_day_of_week: 1
	});

	$("#deleteDatepickerValues").click(function() {
		$c.find('input[name=datefrom]').val('Mettől');
		$c.find('input[name=dateto]').val('Meddig');
		return false;
	});

	/*$c.delegate('.multiSelectOptions input:checkbox', 'change', function() {
		var $this = $(this),
			$parent = $this.parent(),
			$next,
			$act = $parent,
			i = 0,
			checked = $this.attr('checked') == 'checked' ? true : false,
			defcount = substr_count($parent.text().replace(/\u00a0/g, "NBSP"), 'NBSP');

		while ((i<1000) && ($next = $act.next()) && $next.length && (substr_count($next.text().replace(/\u00a0/g, "NBSP"), 'NBSP') > defcount)) {
			$next.find('input').attr('checked', checked);
			$act = $next;
			i++; // to prevent infinite loop
		}

	}); */

	$("select[name=destination]").sb({
		fixedWidth: true,
		animDuration: 100,
		selectboxClass: 'selectbox belongsToReservationBox'
	});

};




