(function(D){var C=D.fn.remove;D.fn.remove=function(){D("*",this).add(this).triggerHandler("remove");return C.apply(this,arguments);};function B(E){function G(H){var I=H.style;return(I.display!="none"&&I.visibility!="hidden");}var F=G(E);(F&&D.each(D.dir(E,"parentNode"),function(){return(F=G(this));}));return F;}D.extend(D.expr[":"],{data:function(F,G,E){return D.data(F,E[3]);},tabbable:function(F,G,E){var H=F.nodeName.toLowerCase();return(F.tabIndex>=0&&(("a"==H&&F.href)||(/input|select|textarea|button/.test(H)&&"hidden"!=F.type&&!F.disabled))&&B(F));}});D.keyCode={BACKSPACE:8,CAPS_LOCK:20,COMMA:188,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38};function A(H,I,J,G){function F(L){var K=D[H][I][L]||[];return(typeof K=="string"?K.split(/,?\s+/):K);}var E=F("getter");if(G.length==1&&typeof G[0]=="string"){E=E.concat(F("getterSetter"));}return(D.inArray(J,E)!=-1);}D.widget=function(F,E){var G=F.split(".")[0];F=F.split(".")[1];D.fn[F]=function(K){var I=(typeof K=="string"),J=Array.prototype.slice.call(arguments,1);if(I&&K.substring(0,1)=="_"){return this;}if(I&&A(G,F,K,J)){var H=D.data(this[0],F);return(H?H[K].apply(H,J):undefined);}return this.each(function(){var L=D.data(this,F);(!L&&!I&&D.data(this,F,new D[G][F](this,K)));(L&&I&&D.isFunction(L[K])&&L[K].apply(L,J));});};D[G][F]=function(J,I){var H=this;this.widgetName=F;this.widgetEventPrefix=D[G][F].eventPrefix||F;this.widgetBaseClass=G+"-"+F;this.options=D.extend({},D.widget.defaults,D[G][F].defaults,D.metadata&&D.metadata.get(J)[F],I);this.element=D(J).bind("setData."+F,function(M,K,L){return H._setData(K,L);}).bind("getData."+F,function(L,K){return H._getData(K);}).bind("remove",function(){return H.destroy();});this._init();};D[G][F].prototype=D.extend({},D.widget.prototype,E);D[G][F].getterSetter="option";};D.widget.prototype={_init:function(){},destroy:function(){this.element.removeData(this.widgetName);},option:function(G,H){var F=G,E=this;if(typeof G=="string"){if(H===undefined){return this._getData(G);}F={};F[G]=H;}D.each(F,function(I,J){E._setData(I,J);});},_getData:function(E){return this.options[E];},_setData:function(E,F){this.options[E]=F;if(E=="disabled"){this.element[F?"addClass":"removeClass"](this.widgetBaseClass+"-disabled");}},enable:function(){this._setData("disabled",false);},disable:function(){this._setData("disabled",true);},_trigger:function(F,H,G){var E=(F==this.widgetEventPrefix?F:this.widgetEventPrefix+F);H=H||D.event.fix({type:E,target:this.element[0]});return this.element.triggerHandler(E,[H,G],this.options[F]);}};D.widget.defaults={disabled:false};D.ui={plugin:{add:function(F,G,I){var H=D.ui[F].prototype;for(var E in I){H.plugins[E]=H.plugins[E]||[];H.plugins[E].push([G,I[E]]);}},call:function(E,G,F){var I=E.plugins[G];if(!I){return ;}for(var H=0;H<I.length;H++){if(E.options[I[H][0]]){I[H][1].apply(E.element,F);}}}},cssCache:{},css:function(E){if(D.ui.cssCache[E]){return D.ui.cssCache[E];}var F=D('<div class="ui-gen">').addClass(E).css({position:"absolute",top:"-5000px",left:"-5000px",display:"block"}).appendTo("body");D.ui.cssCache[E]=!!((!(/auto|default/).test(F.css("cursor"))||(/^[1-9]/).test(F.css("height"))||(/^[1-9]/).test(F.css("width"))||!(/none/).test(F.css("backgroundImage"))||!(/transparent|rgba\(0, 0, 0, 0\)/).test(F.css("backgroundColor"))));try{D("body").get(0).removeChild(F.get(0));}catch(G){}return D.ui.cssCache[E];},disableSelection:function(E){return D(E).attr("unselectable","on").css("MozUserSelect","none").bind("selectstart.ui",function(){return false;});},enableSelection:function(E){return D(E).attr("unselectable","off").css("MozUserSelect","").unbind("selectstart.ui");},hasScroll:function(H,F){if(D(H).css("overflow")=="hidden"){return false;}var E=(F&&F=="left")?"scrollLeft":"scrollTop",G=false;if(H[E]>0){return true;}H[E]=1;G=(H[E]>0);H[E]=0;return G;}};D.ui.mouse={_mouseInit:function(){var E=this;this.element.bind("mousedown."+this.widgetName,function(F){return E._mouseDown(F);});if(D.browser.msie){this._mouseUnselectable=this.element.attr("unselectable");this.element.attr("unselectable","on");}this.started=false;},_mouseDestroy:function(){this.element.unbind("."+this.widgetName);(D.browser.msie&&this.element.attr("unselectable",this._mouseUnselectable));},_mouseDown:function(G){(this._mouseStarted&&this._mouseUp(G));this._mouseDownEvent=G;var F=this,H=(G.which==1),E=(typeof this.options.cancel=="string"?D(G.target).parents().add(G.target).filter(this.options.cancel).length:false);if(!H||E||!this._mouseCapture(G)){return true;}this.mouseDelayMet=!this.options.delay;if(!this.mouseDelayMet){this._mouseDelayTimer=setTimeout(function(){F.mouseDelayMet=true;},this.options.delay);}if(this._mouseDistanceMet(G)&&this._mouseDelayMet(G)){this._mouseStarted=(this._mouseStart(G)!==false);if(!this._mouseStarted){G.preventDefault();return true;}}this._mouseMoveDelegate=function(I){return F._mouseMove(I);};this._mouseUpDelegate=function(I){return F._mouseUp(I);};D(document).bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate);return false;},_mouseMove:function(E){if(D.browser.msie&&!E.button){return this._mouseUp(E);}if(this._mouseStarted){this._mouseDrag(E);return false;}if(this._mouseDistanceMet(E)&&this._mouseDelayMet(E)){this._mouseStarted=(this._mouseStart(this._mouseDownEvent,E)!==false);(this._mouseStarted?this._mouseDrag(E):this._mouseUp(E));}return !this._mouseStarted;},_mouseUp:function(E){D(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate);if(this._mouseStarted){this._mouseStarted=false;this._mouseStop(E);}return false;},_mouseDistanceMet:function(E){return(Math.max(Math.abs(this._mouseDownEvent.pageX-E.pageX),Math.abs(this._mouseDownEvent.pageY-E.pageY))>=this.options.distance);},_mouseDelayMet:function(E){return this.mouseDelayMet;},_mouseStart:function(E){},_mouseDrag:function(E){},_mouseStop:function(E){},_mouseCapture:function(E){return true;}};D.ui.mouse.defaults={cancel:null,distance:1,delay:0};})(jQuery);(function(A){A.widget("ui.draggable",A.extend({},A.ui.mouse,{getHandle:function(C){var B=!this.options.handle||!A(this.options.handle,this.element).length?true:false;A(this.options.handle,this.element).find("*").andSelf().each(function(){if(this==C.target){B=true;}});return B;},createHelper:function(){var C=this.options;var B=A.isFunction(C.helper)?A(C.helper.apply(this.element[0],[e])):(C.helper=="clone"?this.element.clone():this.element);if(!B.parents("body").length){B.appendTo((C.appendTo=="parent"?this.element[0].parentNode:C.appendTo));}if(B[0]!=this.element[0]&&!(/(fixed|absolute)/).test(B.css("position"))){B.css("position","absolute");}return B;},_init:function(){if(this.options.helper=="original"&&!(/^(?:r|a|f)/).test(this.element.css("position"))){this.element[0].style.position="relative";}(this.options.cssNamespace&&this.element.addClass(this.options.cssNamespace+"-draggable"));(this.options.disabled&&this.element.addClass("ui-draggable-disabled"));this._mouseInit();},_mouseCapture:function(B){var C=this.options;if(this.helper||C.disabled||A(B.target).is(".ui-resizable-handle")){return false;}this.handle=this.getHandle(B);if(!this.handle){return false;}return true;},_mouseStart:function(D){var E=this.options;this.helper=this.createHelper();if(A.ui.ddmanager){A.ui.ddmanager.current=this;}this.margins={left:(parseInt(this.element.css("marginLeft"),10)||0),top:(parseInt(this.element.css("marginTop"),10)||0)};this.cssPosition=this.helper.css("position");this.offset=this.element.offset();this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left};this.offset.click={left:D.pageX-this.offset.left,top:D.pageY-this.offset.top};this.cacheScrollParents();this.offsetParent=this.helper.offsetParent();var B=this.offsetParent.offset();if(this.offsetParent[0]==document.body&&A.browser.mozilla){B={top:0,left:0};}this.offset.parent={top:B.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:B.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)};if(this.cssPosition=="relative"){var C=this.element.position();this.offset.relative={top:C.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollTopParent.scrollTop(),left:C.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollLeftParent.scrollLeft()};}else{this.offset.relative={top:0,left:0};}this.originalPosition=this._generatePosition(D);this.cacheHelperProportions();if(E.cursorAt){this.adjustOffsetFromHelper(E.cursorAt);}A.extend(this,{PAGEY_INCLUDES_SCROLL:(this.cssPosition=="absolute"&&(!this.scrollTopParent[0].tagName||(/(html|body)/i).test(this.scrollTopParent[0].tagName))),PAGEX_INCLUDES_SCROLL:(this.cssPosition=="absolute"&&(!this.scrollLeftParent[0].tagName||(/(html|body)/i).test(this.scrollLeftParent[0].tagName))),OFFSET_PARENT_NOT_SCROLL_PARENT_Y:this.scrollTopParent[0]!=this.offsetParent[0]&&!(this.scrollTopParent[0]==document&&(/(body|html)/i).test(this.offsetParent[0].tagName)),OFFSET_PARENT_NOT_SCROLL_PARENT_X:this.scrollLeftParent[0]!=this.offsetParent[0]&&!(this.scrollLeftParent[0]==document&&(/(body|html)/i).test(this.offsetParent[0].tagName))});if(E.containment){this.setContainment();}this._propagate("start",D);this.cacheHelperProportions();if(A.ui.ddmanager&&!E.dropBehaviour){A.ui.ddmanager.prepareOffsets(this,D);}this.helper.addClass("ui-draggable-dragging");this._mouseDrag(D);return true;},cacheScrollParents:function(){this.scrollTopParent=function(B){do{if(/auto|scroll/.test(B.css("overflow"))||(/auto|scroll/).test(B.css("overflow-y"))){return B;}B=B.parent();}while(B[0].parentNode);return A(document);}(this.helper);this.scrollLeftParent=function(B){do{if(/auto|scroll/.test(B.css("overflow"))||(/auto|scroll/).test(B.css("overflow-x"))){return B;}B=B.parent();}while(B[0].parentNode);return A(document);}(this.helper);},adjustOffsetFromHelper:function(B){if(B.left!=undefined){this.offset.click.left=B.left+this.margins.left;}if(B.right!=undefined){this.offset.click.left=this.helperProportions.width-B.right+this.margins.left;}if(B.top!=undefined){this.offset.click.top=B.top+this.margins.top;}if(B.bottom!=undefined){this.offset.click.top=this.helperProportions.height-B.bottom+this.margins.top;}},cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()};},setContainment:function(){var E=this.options;if(E.containment=="parent"){E.containment=this.helper[0].parentNode;}if(E.containment=="document"||E.containment=="window"){this.containment=[0-this.offset.relative.left-this.offset.parent.left,0-this.offset.relative.top-this.offset.parent.top,A(E.containment=="document"?document:window).width()-this.offset.relative.left-this.offset.parent.left-this.helperProportions.width-this.margins.left-(parseInt(this.element.css("marginRight"),10)||0),(A(E.containment=="document"?document:window).height()||document.body.parentNode.scrollHeight)-this.offset.relative.top-this.offset.parent.top-this.helperProportions.height-this.margins.top-(parseInt(this.element.css("marginBottom"),10)||0)];}if(!(/^(document|window|parent)$/).test(E.containment)){var C=A(E.containment)[0];var D=A(E.containment).offset();var B=(A(C).css("overflow")!="hidden");this.containment=[D.left+(parseInt(A(C).css("borderLeftWidth"),10)||0)-this.offset.relative.left-this.offset.parent.left,D.top+(parseInt(A(C).css("borderTopWidth"),10)||0)-this.offset.relative.top-this.offset.parent.top,D.left+(B?Math.max(C.scrollWidth,C.offsetWidth):C.offsetWidth)-(parseInt(A(C).css("borderLeftWidth"),10)||0)-this.offset.relative.left-this.offset.parent.left-this.helperProportions.width-this.margins.left-(parseInt(this.element.css("marginRight"),10)||0),D.top+(B?Math.max(C.scrollHeight,C.offsetHeight):C.offsetHeight)-(parseInt(A(C).css("borderTopWidth"),10)||0)-this.offset.relative.top-this.offset.parent.top-this.helperProportions.height-this.margins.top-(parseInt(this.element.css("marginBottom"),10)||0)];}},_convertPositionTo:function(C,D){if(!D){D=this.position;}var B=C=="absolute"?1:-1;return{top:(D.top+this.offset.relative.top*B+this.offset.parent.top*B-(this.cssPosition=="fixed"||this.PAGEY_INCLUDES_SCROLL||this.OFFSET_PARENT_NOT_SCROLL_PARENT_Y?0:this.scrollTopParent.scrollTop())*B+(this.cssPosition=="fixed"?A(document).scrollTop():0)*B+this.margins.top*B),left:(D.left+this.offset.relative.left*B+this.offset.parent.left*B-(this.cssPosition=="fixed"||this.PAGEX_INCLUDES_SCROLL||this.OFFSET_PARENT_NOT_SCROLL_PARENT_X?0:this.scrollLeftParent.scrollLeft())*B+(this.cssPosition=="fixed"?A(document).scrollLeft():0)*B+this.margins.left*B)};},_generatePosition:function(E){var F=this.options;var B={top:(E.pageY-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+(this.cssPosition=="fixed"||this.PAGEY_INCLUDES_SCROLL||this.OFFSET_PARENT_NOT_SCROLL_PARENT_Y?0:this.scrollTopParent.scrollTop())-(this.cssPosition=="fixed"?A(document).scrollTop():0)),left:(E.pageX-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+(this.cssPosition=="fixed"||this.PAGEX_INCLUDES_SCROLL||this.OFFSET_PARENT_NOT_SCROLL_PARENT_X?0:this.scrollLeftParent.scrollLeft())-(this.cssPosition=="fixed"?A(document).scrollLeft():0))};if(!this.originalPosition){return B;}if(this.containment){if(B.left<this.containment[0]){B.left=this.containment[0];}if(B.top<this.containment[1]){B.top=this.containment[1];}if(B.left>this.containment[2]){B.left=this.containment[2];}if(B.top>this.containment[3]){B.top=this.containment[3];}}if(F.grid){var D=this.originalPosition.top+Math.round((B.top-this.originalPosition.top)/F.grid[1])*F.grid[1];B.top=this.containment?(!(D<this.containment[1]||D>this.containment[3])?D:(!(D<this.containment[1])?D-F.grid[1]:D+F.grid[1])):D;var C=this.originalPosition.left+Math.round((B.left-this.originalPosition.left)/F.grid[0])*F.grid[0];B.left=this.containment?(!(C<this.containment[0]||C>this.containment[2])?C:(!(C<this.containment[0])?C-F.grid[0]:C+F.grid[0])):C;}return B;},_mouseDrag:function(B){this.position=this._generatePosition(B);this.positionAbs=this._convertPositionTo("absolute");this.position=this._propagate("drag",B)||this.position;if(!this.options.axis||this.options.axis!="y"){this.helper[0].style.left=this.position.left+"px";}if(!this.options.axis||this.options.axis!="x"){this.helper[0].style.top=this.position.top+"px";}if(A.ui.ddmanager){A.ui.ddmanager.drag(this,B);}return false;},_mouseStop:function(C){var D=false;if(A.ui.ddmanager&&!this.options.dropBehaviour){var D=A.ui.ddmanager.drop(this,C);}if((this.options.revert=="invalid"&&!D)||(this.options.revert=="valid"&&D)||this.options.revert===true||(A.isFunction(this.options.revert)&&this.options.revert.call(this.element,D))){var B=this;A(this.helper).animate(this.originalPosition,parseInt(this.options.revertDuration,10)||500,function(){B._propagate("stop",C);B._clear();});}else{this._propagate("stop",C);this._clear();}return false;},_clear:function(){this.helper.removeClass("ui-draggable-dragging");if(this.options.helper!="original"&&!this.cancelHelperRemoval){this.helper.remove();}this.helper=null;this.cancelHelperRemoval=false;},plugins:{},uiHash:function(B){return{helper:this.helper,position:this.position,absolutePosition:this.positionAbs,options:this.options};},_propagate:function(C,B){A.ui.plugin.call(this,C,[B,this.uiHash()]);if(C=="drag"){this.positionAbs=this._convertPositionTo("absolute");}return this.element.triggerHandler(C=="drag"?C:"drag"+C,[B,this.uiHash()],this.options[C]);},destroy:function(){if(!this.element.data("draggable")){return ;}this.element.removeData("draggable").unbind(".draggable").removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled");this._mouseDestroy();}}));A.extend(A.ui.draggable,{defaults:{appendTo:"parent",axis:false,cancel:":input",delay:0,distance:1,helper:"original",scope:"default",cssNamespace:"ui"}});A.ui.plugin.add("draggable","cursor",{start:function(D,C){var B=A("body");if(B.css("cursor")){C.options._cursor=B.css("cursor");}B.css("cursor",C.options.cursor);},stop:function(C,B){if(B.options._cursor){A("body").css("cursor",B.options._cursor);}}});A.ui.plugin.add("draggable","zIndex",{start:function(D,C){var B=A(C.helper);if(B.css("zIndex")){C.options._zIndex=B.css("zIndex");}B.css("zIndex",C.options.zIndex);},stop:function(C,B){if(B.options._zIndex){A(B.helper).css("zIndex",B.options._zIndex);}}});A.ui.plugin.add("draggable","opacity",{start:function(D,C){var B=A(C.helper);if(B.css("opacity")){C.options._opacity=B.css("opacity");}B.css("opacity",C.options.opacity);},stop:function(C,B){if(B.options._opacity){A(B.helper).css("opacity",B.options._opacity);}}});A.ui.plugin.add("draggable","iframeFix",{start:function(C,B){A(B.options.iframeFix===true?"iframe":B.options.iframeFix).each(function(){A('<div class="ui-draggable-iframeFix" style="background: #fff;"></div>').css({width:this.offsetWidth+"px",height:this.offsetHeight+"px",position:"absolute",opacity:"0.001",zIndex:1000}).css(A(this).offset()).appendTo("body");});},stop:function(C,B){A("div.ui-draggable-iframeFix").each(function(){this.parentNode.removeChild(this);});}});A.ui.plugin.add("draggable","scroll",{start:function(D,C){var E=C.options;var B=A(this).data("draggable");E.scrollSensitivity=E.scrollSensitivity||20;E.scrollSpeed=E.scrollSpeed||20;B.overflowY=function(F){do{if(/auto|scroll/.test(F.css("overflow"))||(/auto|scroll/).test(F.css("overflow-y"))){return F;}F=F.parent();}while(F[0].parentNode);return A(document);}(this);B.overflowX=function(F){do{if(/auto|scroll/.test(F.css("overflow"))||(/auto|scroll/).test(F.css("overflow-x"))){return F;}F=F.parent();}while(F[0].parentNode);return A(document);}(this);if(B.overflowY[0]!=document&&B.overflowY[0].tagName!="HTML"){B.overflowYOffset=B.overflowY.offset();}if(B.overflowX[0]!=document&&B.overflowX[0].tagName!="HTML"){B.overflowXOffset=B.overflowX.offset();}},drag:function(E,D){var F=D.options,B=false;var C=A(this).data("draggable");if(C.overflowY[0]!=document&&C.overflowY[0].tagName!="HTML"){if((C.overflowYOffset.top+C.overflowY[0].offsetHeight)-E.pageY<F.scrollSensitivity){C.overflowY[0].scrollTop=B=C.overflowY[0].scrollTop+F.scrollSpeed;}if(E.pageY-C.overflowYOffset.top<F.scrollSensitivity){C.overflowY[0].scrollTop=B=C.overflowY[0].scrollTop-F.scrollSpeed;}}else{if(E.pageY-A(document).scrollTop()<F.scrollSensitivity){B=A(document).scrollTop(A(document).scrollTop()-F.scrollSpeed);}if(A(window).height()-(E.pageY-A(document).scrollTop())<F.scrollSensitivity){B=A(document).scrollTop(A(document).scrollTop()+F.scrollSpeed);}}if(C.overflowX[0]!=document&&C.overflowX[0].tagName!="HTML"){if((C.overflowXOffset.left+C.overflowX[0].offsetWidth)-E.pageX<F.scrollSensitivity){C.overflowX[0].scrollLeft=B=C.overflowX[0].scrollLeft+F.scrollSpeed;}if(E.pageX-C.overflowXOffset.left<F.scrollSensitivity){C.overflowX[0].scrollLeft=B=C.overflowX[0].scrollLeft-F.scrollSpeed;}}else{if(E.pageX-A(document).scrollLeft()<F.scrollSensitivity){B=A(document).scrollLeft(A(document).scrollLeft()-F.scrollSpeed);}if(A(window).width()-(E.pageX-A(document).scrollLeft())<F.scrollSensitivity){B=A(document).scrollLeft(A(document).scrollLeft()+F.scrollSpeed);}}if(B!==false){A.ui.ddmanager.prepareOffsets(C,E);}}});A.ui.plugin.add("draggable","snap",{start:function(D,C){var B=A(this).data("draggable");B.snapElements=[];A(C.options.snap.constructor!=String?(C.options.snap.items||":data(draggable)"):C.options.snap).each(function(){var F=A(this);var E=F.offset();if(this!=B.element[0]){B.snapElements.push({item:this,width:F.outerWidth(),height:F.outerHeight(),top:E.top,left:E.left});}});},drag:function(P,K){var E=A(this).data("draggable");var Q=K.options.snapTolerance||20;var O=K.absolutePosition.left,N=O+E.helperProportions.width,D=K.absolutePosition.top,C=D+E.helperProportions.height;for(var M=E.snapElements.length-1;M>=0;M--){var L=E.snapElements[M].left,J=L+E.snapElements[M].width,I=E.snapElements[M].top,S=I+E.snapElements[M].height;if(!((L-Q<O&&O<J+Q&&I-Q<D&&D<S+Q)||(L-Q<O&&O<J+Q&&I-Q<C&&C<S+Q)||(L-Q<N&&N<J+Q&&I-Q<D&&D<S+Q)||(L-Q<N&&N<J+Q&&I-Q<C&&C<S+Q))){if(E.snapElements[M].snapping){(E.options.snap.release&&E.options.snap.release.call(E.element,null,A.extend(E.uiHash(),{snapItem:E.snapElements[M].item})));}E.snapElements[M].snapping=false;continue;}if(K.options.snapMode!="inner"){var B=Math.abs(I-C)<=Q;var R=Math.abs(S-D)<=Q;var G=Math.abs(L-N)<=Q;var H=Math.abs(J-O)<=Q;if(B){K.position.top=E._convertPositionTo("relative",{top:I-E.helperProportions.height,left:0}).top;}if(R){K.position.top=E._convertPositionTo("relative",{top:S,left:0}).top;}if(G){K.position.left=E._convertPositionTo("relative",{top:0,left:L-E.helperProportions.width}).left;}if(H){K.position.left=E._convertPositionTo("relative",{top:0,left:J}).left;}}var F=(B||R||G||H);if(K.options.snapMode!="outer"){var B=Math.abs(I-D)<=Q;var R=Math.abs(S-C)<=Q;var G=Math.abs(L-O)<=Q;var H=Math.abs(J-N)<=Q;if(B){K.position.top=E._convertPositionTo("relative",{top:I,left:0}).top;}if(R){K.position.top=E._convertPositionTo("relative",{top:S-E.helperProportions.height,left:0}).top;}if(G){K.position.left=E._convertPositionTo("relative",{top:0,left:L}).left;}if(H){K.position.left=E._convertPositionTo("relative",{top:0,left:J-E.helperProportions.width}).left;}}if(!E.snapElements[M].snapping&&(B||R||G||H||F)){(E.options.snap.snap&&E.options.snap.snap.call(E.element,null,A.extend(E.uiHash(),{snapItem:E.snapElements[M].item})));}E.snapElements[M].snapping=(B||R||G||H||F);}}});A.ui.plugin.add("draggable","connectToSortable",{start:function(D,C){var B=A(this).data("draggable");B.sortables=[];A(C.options.connectToSortable).each(function(){if(A.data(this,"sortable")){var E=A.data(this,"sortable");B.sortables.push({instance:E,shouldRevert:E.options.revert});E._refreshItems();E._propagate("activate",D,B);}});},stop:function(D,C){var B=A(this).data("draggable");A.each(B.sortables,function(){if(this.instance.isOver){this.instance.isOver=0;B.cancelHelperRemoval=true;this.instance.cancelHelperRemoval=false;if(this.shouldRevert){this.instance.options.revert=true;}this.instance._mouseStop(D);this.instance.element.triggerHandler("sortreceive",[D,A.extend(this.instance.ui(),{sender:B.element})],this.instance.options.receive);this.instance.options.helper=this.instance.options._helper;}else{this.instance._propagate("deactivate",D,B);}});},drag:function(F,E){var D=A(this).data("draggable"),B=this;var C=function(K){var H=K.left,J=H+K.width,I=K.top,G=I+K.height;return(H<(this.positionAbs.left+this.offset.click.left)&&(this.positionAbs.left+this.offset.click.left)<J&&I<(this.positionAbs.top+this.offset.click.top)&&(this.positionAbs.top+this.offset.click.top)<G);};A.each(D.sortables,function(G){if(C.call(D,this.instance.containerCache)){if(!this.instance.isOver){this.instance.isOver=1;this.instance.currentItem=A(B).clone().appendTo(this.instance.element).data("sortable-item",true);this.instance.options._helper=this.instance.options.helper;this.instance.options.helper=function(){return E.helper[0];};F.target=this.instance.currentItem[0];this.instance._mouseCapture(F,true);this.instance._mouseStart(F,true,true);this.instance.offset.click.top=D.offset.click.top;this.instance.offset.click.left=D.offset.click.left;this.instance.offset.parent.left-=D.offset.parent.left-this.instance.offset.parent.left;this.instance.offset.parent.top-=D.offset.parent.top-this.instance.offset.parent.top;D._propagate("toSortable",F);}if(this.instance.currentItem){this.instance._mouseDrag(F);}}else{if(this.instance.isOver){this.instance.isOver=0;this.instance.cancelHelperRemoval=true;this.instance.options.revert=false;this.instance._mouseStop(F,true);this.instance.options.helper=this.instance.options._helper;this.instance.currentItem.remove();if(this.instance.placeholder){this.instance.placeholder.remove();}D._propagate("fromSortable",F);}}});}});A.ui.plugin.add("draggable","stack",{start:function(D,B){var C=A.makeArray(A(B.options.stack.group)).sort(function(F,E){return(parseInt(A(F).css("zIndex"),10)||B.options.stack.min)-(parseInt(A(E).css("zIndex"),10)||B.options.stack.min);});A(C).each(function(E){this.style.zIndex=B.options.stack.min+E;});this[0].style.zIndex=B.options.stack.min+C.length;}});})(jQuery);(function(A){A.widget("ui.resizable",A.extend({},A.ui.mouse,{_init:function(){var M=this,N=this.options;var Q=this.element.css("position");this.originalElement=this.element;this.element.addClass("ui-resizable").css({position:/static/.test(Q)?"relative":Q});A.extend(N,{_aspectRatio:!!(N.aspectRatio),helper:N.helper||N.ghost||N.animate?N.helper||"proxy":null,knobHandles:N.knobHandles===true?"ui-resizable-knob-handle":N.knobHandles});var H="1px solid #DEDEDE";N.defaultTheme={"ui-resizable":{display:"block"},"ui-resizable-handle":{position:"absolute",background:"#F2F2F2",fontSize:"0.1px"},"ui-resizable-n":{cursor:"n-resize",height:"4px",left:"0px",right:"0px",borderTop:H},"ui-resizable-s":{cursor:"s-resize",height:"4px",left:"0px",right:"0px",borderBottom:H},"ui-resizable-e":{cursor:"e-resize",width:"4px",top:"0px",bottom:"0px",borderRight:H},"ui-resizable-w":{cursor:"w-resize",width:"4px",top:"0px",bottom:"0px",borderLeft:H},"ui-resizable-se":{cursor:"se-resize",width:"4px",height:"4px",borderRight:H,borderBottom:H},"ui-resizable-sw":{cursor:"sw-resize",width:"4px",height:"4px",borderBottom:H,borderLeft:H},"ui-resizable-ne":{cursor:"ne-resize",width:"4px",height:"4px",borderRight:H,borderTop:H},"ui-resizable-nw":{cursor:"nw-resize",width:"4px",height:"4px",borderLeft:H,borderTop:H}};N.knobTheme={"ui-resizable-handle":{background:"#F2F2F2",border:"1px solid #808080",height:"8px",width:"8px"},"ui-resizable-n":{cursor:"n-resize",top:"0px",left:"45%"},"ui-resizable-s":{cursor:"s-resize",bottom:"0px",left:"45%"},"ui-resizable-e":{cursor:"e-resize",right:"0px",top:"45%"},"ui-resizable-w":{cursor:"w-resize",left:"0px",top:"45%"},"ui-resizable-se":{cursor:"se-resize",right:"0px",bottom:"0px"},"ui-resizable-sw":{cursor:"sw-resize",left:"0px",bottom:"0px"},"ui-resizable-nw":{cursor:"nw-resize",left:"0px",top:"0px"},"ui-resizable-ne":{cursor:"ne-resize",right:"0px",top:"0px"}};N._nodeName=this.element[0].nodeName;if(N._nodeName.match(/canvas|textarea|input|select|button|img/i)){var B=this.element;if(/relative/.test(B.css("position"))&&A.browser.opera){B.css({position:"relative",top:"auto",left:"auto"});}B.wrap(A('<div class="ui-wrapper" style="overflow: hidden;"></div>').css({position:B.css("position"),width:B.outerWidth(),height:B.outerHeight(),top:B.css("top"),left:B.css("left")}));var J=this.element;this.element=this.element.parent();this.element.data("resizable",this);this.element.css({marginLeft:J.css("marginLeft"),marginTop:J.css("marginTop"),marginRight:J.css("marginRight"),marginBottom:J.css("marginBottom")});J.css({marginLeft:0,marginTop:0,marginRight:0,marginBottom:0});if(A.browser.safari&&N.preventDefault){J.css("resize","none");}N.proportionallyResize=J.css({position:"static",zoom:1,display:"block"});this.element.css({margin:J.css("margin")});this._proportionallyResize();}if(!N.handles){N.handles=!A(".ui-resizable-handle",this.element).length?"e,s,se":{n:".ui-resizable-n",e:".ui-resizable-e",s:".ui-resizable-s",w:".ui-resizable-w",se:".ui-resizable-se",sw:".ui-resizable-sw",ne:".ui-resizable-ne",nw:".ui-resizable-nw"};}if(N.handles.constructor==String){N.zIndex=N.zIndex||1000;if(N.handles=="all"){N.handles="n,e,s,w,se,sw,ne,nw";}var O=N.handles.split(",");N.handles={};var G={handle:"position: absolute; display: none; overflow:hidden;",n:"top: 0pt; width:100%;",e:"right: 0pt; height:100%;",s:"bottom: 0pt; width:100%;",w:"left: 0pt; height:100%;",se:"bottom: 0pt; right: 0px;",sw:"bottom: 0pt; left: 0px;",ne:"top: 0pt; right: 0px;",nw:"top: 0pt; left: 0px;"};for(var R=0;R<O.length;R++){var S=A.trim(O[R]),L=N.defaultTheme,F="ui-resizable-"+S,C=!A.ui.css(F)&&!N.knobHandles,P=A.ui.css("ui-resizable-knob-handle"),T=A.extend(L[F],L["ui-resizable-handle"]),D=A.extend(N.knobTheme[F],!P?N.knobTheme["ui-resizable-handle"]:{});var K=/sw|se|ne|nw/.test(S)?{zIndex:++N.zIndex}:{};var I=(C?G[S]:""),E=A(['<div class="ui-resizable-handle ',F,'" style="',I,G.handle,'"></div>'].join("")).css(K);N.handles[S]=".ui-resizable-"+S;this.element.append(E.css(C?T:{}).css(N.knobHandles?D:{}).addClass(N.knobHandles?"ui-resizable-knob-handle":"").addClass(N.knobHandles));}if(N.knobHandles){this.element.addClass("ui-resizable-knob").css(!A.ui.css("ui-resizable-knob")?{}:{});}}this._renderAxis=function(Y){Y=Y||this.element;for(var V in N.handles){if(N.handles[V].constructor==String){N.handles[V]=A(N.handles[V],this.element).show();}if(N.transparent){N.handles[V].css({opacity:0});}if(this.element.is(".ui-wrapper")&&N._nodeName.match(/textarea|input|select|button/i)){var W=A(N.handles[V],this.element),X=0;X=/sw|ne|nw|se|n|s/.test(V)?W.outerHeight():W.outerWidth();var U=["padding",/ne|nw|n/.test(V)?"Top":/se|sw|s/.test(V)?"Bottom":/^e$/.test(V)?"Right":"Left"].join("");if(!N.transparent){Y.css(U,X);}this._proportionallyResize();}if(!A(N.handles[V]).length){continue;}}};this._renderAxis(this.element);N._handles=A(".ui-resizable-handle",M.element);if(N.disableSelection){N._handles.each(function(U,V){A.ui.disableSelection(V);});}N._handles.mouseover(function(){if(!N.resizing){if(this.className){var U=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);}M.axis=N.axis=U&&U[1]?U[1]:"se";}});if(N.autoHide){N._handles.hide();A(M.element).addClass("ui-resizable-autohide").hover(function(){A(this).removeClass("ui-resizable-autohide");N._handles.show();},function(){if(!N.resizing){A(this).addClass("ui-resizable-autohide");N._handles.hide();}});}this._mouseInit();},plugins:{},ui:function(){return{originalElement:this.originalElement,element:this.element,helper:this.helper,position:this.position,size:this.size,options:this.options,originalSize:this.originalSize,originalPosition:this.originalPosition};},_propagate:function(C,B){A.ui.plugin.call(this,C,[B,this.ui()]);if(C!="resize"){this.element.triggerHandler(["resize",C].join(""),[B,this.ui()],this.options[C]);}},destroy:function(){var D=this.element,C=D.children(".ui-resizable").get(0);this._mouseDestroy();var B=function(E){A(E).removeClass("ui-resizable ui-resizable-disabled").removeData("resizable").unbind(".resizable").find(".ui-resizable-handle").remove();};B(D);if(D.is(".ui-wrapper")&&C){D.parent().append(A(C).css({position:D.css("position"),width:D.outerWidth(),height:D.outerHeight(),top:D.css("top"),left:D.css("left")})).end().remove();B(C);}},_mouseCapture:function(D){if(this.options.disabled){return false;}var C=false;for(var B in this.options.handles){if(A(this.options.handles[B])[0]==D.target){C=true;}}if(!C){return false;}return true;},_mouseStart:function(I){var C=this.options,B=this.element.position(),D=this.element,H=function(M){return parseInt(M,10)||0;},G=A.browser.msie&&A.browser.version<7;C.resizing=true;C.documentScroll={top:A(document).scrollTop(),left:A(document).scrollLeft()};if(D.is(".ui-draggable")||(/absolute/).test(D.css("position"))){var J=A.browser.msie&&!C.containment&&(/absolute/).test(D.css("position"))&&!(/relative/).test(D.parent().css("position"));var K=J?C.documentScroll.top:0,F=J?C.documentScroll.left:0;D.css({position:"absolute",top:(B.top+K),left:(B.left+F)});}if(A.browser.opera&&/relative/.test(D.css("position"))){D.css({position:"relative",top:"auto",left:"auto"});}this._renderProxy();var L=H(this.helper.css("left")),E=H(this.helper.css("top"));if(C.containment){L+=A(C.containment).scrollLeft()||0;E+=A(C.containment).scrollTop()||0;}this.offset=this.helper.offset();this.position={left:L,top:E};this.size=C.helper||G?{width:D.outerWidth(),height:D.outerHeight()}:{width:D.width(),height:D.height()};this.originalSize=C.helper||G?{width:D.outerWidth(),height:D.outerHeight()}:{width:D.width(),height:D.height()};this.originalPosition={left:L,top:E};this.sizeDiff={width:D.outerWidth()-D.width(),height:D.outerHeight()-D.height()};this.originalMousePosition={left:I.pageX,top:I.pageY};C.aspectRatio=(typeof C.aspectRatio=="number")?C.aspectRatio:((this.originalSize.width/this.originalSize.height)||1);if(C.preserveCursor){A("body").css("cursor",this.axis+"-resize");}this._propagate("start",I);return true;},_mouseDrag:function(I){var D=this.helper,C=this.options,J={},M=this,F=this.originalMousePosition,K=this.axis;var N=(I.pageX-F.left)||0,L=(I.pageY-F.top)||0;var E=this._change[K];if(!E){return false;}var H=E.apply(this,[I,N,L]),G=A.browser.msie&&A.browser.version<7,B=this.sizeDiff;if(C._aspectRatio||I.shiftKey){H=this._updateRatio(H,I);}H=this._respectSize(H,I);this._propagate("resize",I);D.css({top:this.position.top+"px",left:this.position.left+"px",width:this.size.width+"px",height:this.size.height+"px"});if(!C.helper&&C.proportionallyResize){this._proportionallyResize();}this._updateCache(H);this.element.triggerHandler("resize",[I,this.ui()],this.options.resize);return false;},_mouseStop:function(I){this.options.resizing=false;var E=this.options,H=function(M){return parseInt(M,10)||0;},K=this;if(E.helper){var D=E.proportionallyResize,B=D&&(/textarea/i).test(D.get(0).nodeName),C=B&&A.ui.hasScroll(D.get(0),"left")?0:K.sizeDiff.height,G=B?0:K.sizeDiff.width;var L={width:(K.size.width-G),height:(K.size.height-C)},F=(parseInt(K.element.css("left"),10)+(K.position.left-K.originalPosition.left))||null,J=(parseInt(K.element.css("top"),10)+(K.position.top-K.originalPosition.top))||null;if(!E.animate){this.element.css(A.extend(L,{top:J,left:F}));}if(E.helper&&!E.animate){this._proportionallyResize();}}if(E.preserveCursor){A("body").css("cursor","auto");}this._propagate("stop",I);if(E.helper){this.helper.remove();}return false;},_updateCache:function(B){var C=this.options;this.offset=this.helper.offset();if(B.left){this.position.left=B.left;}if(B.top){this.position.top=B.top;}if(B.height){this.size.height=B.height;}if(B.width){this.size.width=B.width;}},_updateRatio:function(D,E){var F=this.options,G=this.position,C=this.size,B=this.axis;if(D.height){D.width=(C.height*F.aspectRatio);}else{if(D.width){D.height=(C.width/F.aspectRatio);}}if(B=="sw"){D.left=G.left+(C.width-D.width);D.top=null;}if(B=="nw"){D.top=G.top+(C.height-D.height);D.left=G.left+(C.width-D.width);}return D;},_respectSize:function(H,I){var F=this.helper,E=this.options,N=E._aspectRatio||I.shiftKey,M=this.axis,P=H.width&&E.maxWidth&&E.maxWidth<H.width,J=H.height&&E.maxHeight&&E.maxHeight<H.height,D=H.width&&E.minWidth&&E.minWidth>H.width,O=H.height&&E.minHeight&&E.minHeight>H.height;if(D){H.width=E.minWidth;}if(O){H.height=E.minHeight;}if(P){H.width=E.maxWidth;}if(J){H.height=E.maxHeight;}var C=this.originalPosition.left+this.originalSize.width,L=this.position.top+this.size.height;var G=/sw|nw|w/.test(M),B=/nw|ne|n/.test(M);if(D&&G){H.left=C-E.minWidth;}if(P&&G){H.left=C-E.maxWidth;}if(O&&B){H.top=L-E.minHeight;}if(J&&B){H.top=L-E.maxHeight;}var K=!H.width&&!H.height;if(K&&!H.left&&H.top){H.top=null;}else{if(K&&!H.top&&H.left){H.left=null;}}return H;},_proportionallyResize:function(){var F=this.options;if(!F.proportionallyResize){return ;}var D=F.proportionallyResize,C=this.helper||this.element;if(!F.borderDif){var B=[D.css("borderTopWidth"),D.css("borderRightWidth"),D.css("borderBottomWidth"),D.css("borderLeftWidth")],E=[D.css("paddingTop"),D.css("paddingRight"),D.css("paddingBottom"),D.css("paddingLeft")];F.borderDif=A.map(B,function(G,I){var H=parseInt(G,10)||0,J=parseInt(E[I],10)||0;return H+J;});}D.css({height:(C.height()-F.borderDif[0]-F.borderDif[2])+"px",width:(C.width()-F.borderDif[1]-F.borderDif[3])+"px"});},_renderProxy:function(){var C=this.element,F=this.options;this.elementOffset=C.offset();if(F.helper){this.helper=this.helper||A('<div style="overflow:hidden;"></div>');var B=A.browser.msie&&A.browser.version<7,D=(B?1:0),E=(B?2:-1);this.helper.addClass(F.helper).css({width:C.outerWidth()+E,height:C.outerHeight()+E,position:"absolute",left:this.elementOffset.left-D+"px",top:this.elementOffset.top-D+"px",zIndex:++F.zIndex});this.helper.appendTo("body");if(F.disableSelection){A.ui.disableSelection(this.helper.get(0));}}else{this.helper=C;}},_change:{e:function(D,C,B){return{width:this.originalSize.width+C};},w:function(F,C,B){var G=this.options,D=this.originalSize,E=this.originalPosition;return{left:E.left+C,width:D.width-C};},n:function(F,C,B){var G=this.options,D=this.originalSize,E=this.originalPosition;return{top:E.top+B,height:D.height-B};},s:function(D,C,B){return{height:this.originalSize.height+B};},se:function(D,C,B){return A.extend(this._change.s.apply(this,arguments),this._change.e.apply(this,[D,C,B]));},sw:function(D,C,B){return A.extend(this._change.s.apply(this,arguments),this._change.w.apply(this,[D,C,B]));},ne:function(D,C,B){return A.extend(this._change.n.apply(this,arguments),this._change.e.apply(this,[D,C,B]));},nw:function(D,C,B){return A.extend(this._change.n.apply(this,arguments),this._change.w.apply(this,[D,C,B]));}}}));A.extend(A.ui.resizable,{defaults:{cancel:":input",distance:1,delay:0,preventDefault:true,transparent:false,minWidth:10,minHeight:10,aspectRatio:false,disableSelection:true,preserveCursor:true,autoHide:false,knobHandles:false}});A.ui.plugin.add("resizable","containment",{start:function(I,K){var E=K.options,M=A(this).data("resizable"),G=M.element;var C=E.containment,F=(C instanceof A)?C.get(0):(/parent/.test(C))?G.parent().get(0):C;if(!F){return ;}M.containerElement=A(F);if(/document/.test(C)||C==document){M.containerOffset={left:0,top:0};M.containerPosition={left:0,top:0};M.parentData={element:A(document),left:0,top:0,width:A(document).width(),height:A(document).height()||document.body.parentNode.scrollHeight};}else{M.containerOffset=A(F).offset();M.containerPosition=A(F).position();M.containerSize={height:A(F).innerHeight(),width:A(F).innerWidth()};var J=M.containerOffset,B=M.containerSize.height,H=M.containerSize.width,D=(A.ui.hasScroll(F,"left")?F.scrollWidth:H),L=(A.ui.hasScroll(F)?F.scrollHeight:B);M.parentData={element:F,left:J.left,top:J.top,width:D,height:L};}},resize:function(H,K){var E=K.options,N=A(this).data("resizable"),C=N.containerSize,J=N.containerOffset,G=N.size,I=N.position,L=E._aspectRatio||H.shiftKey,B={top:0,left:0},D=N.containerElement;if(D[0]!=document&&/static/.test(D.css("position"))){B=N.containerPosition;}if(I.left<(E.helper?J.left:B.left)){N.size.width=N.size.width+(E.helper?(N.position.left-J.left):(N.position.left-B.left));if(L){N.size.height=N.size.width/E.aspectRatio;}N.position.left=E.helper?J.left:B.left;}if(I.top<(E.helper?J.top:0)){N.size.height=N.size.height+(E.helper?(N.position.top-J.top):N.position.top);if(L){N.size.width=N.size.height*E.aspectRatio;}N.position.top=E.helper?J.top:0;}var F=(E.helper?N.offset.left-J.left:(N.position.left-B.left))+N.sizeDiff.width,M=(E.helper?N.offset.top-J.top:N.position.top)+N.sizeDiff.height;if(F+N.size.width>=N.parentData.width){N.size.width=N.parentData.width-F;if(L){N.size.height=N.size.width/E.aspectRatio;}}if(M+N.size.height>=N.parentData.height){N.size.height=N.parentData.height-M;if(L){N.size.width=N.size.height*E.aspectRatio;}}},stop:function(G,J){var C=J.options,L=A(this).data("resizable"),H=L.position,I=L.containerOffset,B=L.containerPosition,D=L.containerElement;var E=A(L.helper),M=E.offset(),K=E.innerWidth(),F=E.innerHeight();if(C.helper&&!C.animate&&/relative/.test(D.css("position"))){A(this).css({left:(M.left-I.left),top:(M.top-I.top),width:K,height:F});}if(C.helper&&!C.animate&&/static/.test(D.css("position"))){A(this).css({left:B.left+(M.left-I.left),top:B.top+(M.top-I.top),width:K,height:F});}}});A.ui.plugin.add("resizable","grid",{resize:function(H,J){var D=J.options,L=A(this).data("resizable"),G=L.size,E=L.originalSize,F=L.originalPosition,K=L.axis,I=D._aspectRatio||H.shiftKey;D.grid=typeof D.grid=="number"?[D.grid,D.grid]:D.grid;var C=Math.round((G.width-E.width)/(D.grid[0]||1))*(D.grid[0]||1),B=Math.round((G.height-E.height)/(D.grid[1]||1))*(D.grid[1]||1);if(/^(se|s|e)$/.test(K)){L.size.width=E.width+C;L.size.height=E.height+B;}else{if(/^(ne)$/.test(K)){L.size.width=E.width+C;L.size.height=E.height+B;L.position.top=F.top-B;}else{if(/^(sw)$/.test(K)){L.size.width=E.width+C;L.size.height=E.height+B;L.position.left=F.left-C;}else{L.size.width=E.width+C;L.size.height=E.height+B;L.position.top=F.top-B;L.position.left=F.left-C;}}}}});A.ui.plugin.add("resizable","animate",{stop:function(I,K){var F=K.options,L=A(this).data("resizable");var E=F.proportionallyResize,B=E&&(/textarea/i).test(E.get(0).nodeName),C=B&&A.ui.hasScroll(E.get(0),"left")?0:L.sizeDiff.height,H=B?0:L.sizeDiff.width;var D={width:(L.size.width-H),height:(L.size.height-C)},G=(parseInt(L.element.css("left"),10)+(L.position.left-L.originalPosition.left))||null,J=(parseInt(L.element.css("top"),10)+(L.position.top-L.originalPosition.top))||null;L.element.animate(A.extend(D,J&&G?{top:J,left:G}:{}),{duration:F.animateDuration||"slow",easing:F.animateEasing||"swing",step:function(){var M={width:parseInt(L.element.css("width"),10),height:parseInt(L.element.css("height"),10),top:parseInt(L.element.css("top"),10),left:parseInt(L.element.css("left"),10)};if(E){E.css({width:M.width,height:M.height});}L._updateCache(M);L._propagate("animate",I);}});}});A.ui.plugin.add("resizable","ghost",{start:function(E,D){var F=D.options,B=A(this).data("resizable"),G=F.proportionallyResize,C=B.size;if(!G){B.ghost=B.element.clone();}else{B.ghost=G.clone();}B.ghost.css({opacity:0.25,display:"block",position:"relative",height:C.height,width:C.width,margin:0,left:0,top:0}).addClass("ui-resizable-ghost").addClass(typeof F.ghost=="string"?F.ghost:"");B.ghost.appendTo(B.helper);},resize:function(D,C){var E=C.options,B=A(this).data("resizable"),F=E.proportionallyResize;if(B.ghost){B.ghost.css({position:"relative",height:B.size.height,width:B.size.width});}},stop:function(D,C){var E=C.options,B=A(this).data("resizable"),F=E.proportionallyResize;if(B.ghost&&B.helper){B.helper.get(0).removeChild(B.ghost.get(0));}}});A.ui.plugin.add("resizable","alsoResize",{start:function(E,C){var F=C.options,B=A(this).data("resizable"),D=function(G){A(G).each(function(){A(this).data("resizable-alsoresize",{width:parseInt(A(this).width(),10),height:parseInt(A(this).height(),10),left:parseInt(A(this).css("left"),10),top:parseInt(A(this).css("top"),10)});});};if(typeof (F.alsoResize)=="object"){if(F.alsoResize.length){F.alsoResize=F.alsoResize[0];D(F.alsoResize);}else{A.each(F.alsoResize,function(G,H){D(G);});}}else{D(F.alsoResize);}},resize:function(F,E){var G=E.options,C=A(this).data("resizable"),D=C.originalSize,I=C.originalPosition;var H={height:(C.size.height-D.height)||0,width:(C.size.width-D.width)||0,top:(C.position.top-I.top)||0,left:(C.position.left-I.left)||0},B=function(J,K){A(J).each(function(){var N=A(this).data("resizable-alsoresize"),M={},L=K&&K.length?K:["width","height","top","left"];A.each(L||["width","height","top","left"],function(O,Q){var P=(N[Q]||0)+(H[Q]||0);if(P&&P>=0){M[Q]=P||null;}});A(this).css(M);});};if(typeof (G.alsoResize)=="object"){A.each(G.alsoResize,function(J,K){B(J,K);});}else{B(G.alsoResize);}},stop:function(C,B){A(this).removeData("resizable-alsoresize-start");}});})(jQuery);(function(A){A.fn.unwrap=A.fn.unwrap||function(B){return this.each(function(){A(this).parents(B).eq(0).after(this).remove();});};A.widget("ui.slider",{plugins:{},ui:function(B){return{options:this.options,handle:this.currentHandle,value:this.options.axis!="both"||!this.options.axis?Math.round(this.value(null,this.options.axis=="vertical"?"y":"x")):{x:Math.round(this.value(null,"x")),y:Math.round(this.value(null,"y"))},range:this._getRange()};},_propagate:function(C,B){A.ui.plugin.call(this,C,[B,this.ui()]);this.element.triggerHandler(C=="slide"?C:"slide"+C,[B,this.ui()],this.options[C]);},destroy:function(){this.element.removeClass("ui-slider ui-slider-disabled").removeData("slider").unbind(".slider");if(this.handle&&this.handle.length){this.handle.unwrap("a");this.handle.each(function(){A(this).data("mouse")._mouseDestroy();});}this.generated&&this.generated.remove();},_setData:function(B,C){A.widget.prototype._setData.apply(this,arguments);if(/min|max|steps/.test(B)){this._initBoundaries();}if(B=="range"){C?this.handle.length==2&&this._createRange():this._removeRange();}},_init:function(){var B=this;this.element.addClass("ui-slider");this._initBoundaries();this.handle=A(this.options.handle,this.element);if(!this.handle.length){B.handle=B.generated=A(B.options.handles||[0]).map(function(){var D=A("<div/>").addClass("ui-slider-handle").appendTo(B.element);if(this.id){D.attr("id",this.id);}return D[0];});}var C=function(D){this.element=A(D);this.element.data("mouse",this);this.options=B.options;this.element.bind("mousedown",function(){if(B.currentHandle){this.blur(B.currentHandle);}B._focus(this,true);});this._mouseInit();};A.extend(C.prototype,A.ui.mouse,{_mouseStart:function(D){return B._start.call(B,D,this.element[0]);},_mouseStop:function(D){return B._stop.call(B,D,this.element[0]);},_mouseDrag:function(D){return B._drag.call(B,D,this.element[0]);},_mouseCapture:function(){return true;},trigger:function(D){this._mouseDown(D);}});A(this.handle).each(function(){new C(this);}).wrap('<a href="#" style="outline:none;border:none;"></a>').parent().bind("click",function(){return false;}).bind("focus",function(D){B._focus(this.firstChild);}).bind("blur",function(D){B._blur(this.firstChild);}).bind("keydown",function(D){if(!B.options.noKeyboard){return B._keydown(D.keyCode,this.firstChild);}});this.element.bind("mousedown.slider",function(D){B._click.apply(B,[D]);B.currentHandle.data("mouse").trigger(D);B.firstValue=B.firstValue+1;});A.each(this.options.handles||[],function(D,E){B.moveTo(E.start,D,true);});if(!isNaN(this.options.startValue)){this.moveTo(this.options.startValue,0,true);}this.previousHandle=A(this.handle[0]);if(this.handle.length==2&&this.options.range){this._createRange();}},_initBoundaries:function(){var B=this.element[0],C=this.options;this.actualSize={width:this.element.outerWidth(),height:this.element.outerHeight()};A.extend(C,{axis:C.axis||(B.offsetWidth<B.offsetHeight?"vertical":"horizontal"),max:!isNaN(parseInt(C.max,10))?{x:parseInt(C.max,10),y:parseInt(C.max,10)}:({x:C.max&&C.max.x||100,y:C.max&&C.max.y||100}),min:!isNaN(parseInt(C.min,10))?{x:parseInt(C.min,10),y:parseInt(C.min,10)}:({x:C.min&&C.min.x||0,y:C.min&&C.min.y||0})});C.realMax={x:C.max.x-C.min.x,y:C.max.y-C.min.y};C.stepping={x:C.stepping&&C.stepping.x||parseInt(C.stepping,10)||(C.steps?C.realMax.x/(C.steps.x||parseInt(C.steps,10)||C.realMax.x):0),y:C.stepping&&C.stepping.y||parseInt(C.stepping,10)||(C.steps?C.realMax.y/(C.steps.y||parseInt(C.steps,10)||C.realMax.y):0)};},_keydown:function(F,E){var C=F;if(/(33|34|35|36|37|38|39|40)/.test(C)){var G=this.options,B,I;if(/(35|36)/.test(C)){B=(C==35)?G.max.x:G.min.x;I=(C==35)?G.max.y:G.min.y;}else{var H=/(34|37|40)/.test(C)?"-=":"+=";var D=/(37|38|39|40)/.test(C)?"_oneStep":"_pageStep";B=H+this[D]("x");I=H+this[D]("y");}this.moveTo({x:B,y:I},E);return false;}return true;},_focus:function(B,C){this.currentHandle=A(B).addClass("ui-slider-handle-active");if(C){this.currentHandle.parent()[0].focus();}},_blur:function(B){A(B).removeClass("ui-slider-handle-active");if(this.currentHandle&&this.currentHandle[0]==B){this.previousHandle=this.currentHandle;this.currentHandle=null;}},_click:function(C){var D=[C.pageX,C.pageY];var B=false;this.handle.each(function(){if(this==C.target){B=true;}});if(B||this.options.disabled||!(this.currentHandle||this.previousHandle)){return ;}if(!this.currentHandle&&this.previousHandle){this._focus(this.previousHandle,true);}this.offset=this.element.offset();this.moveTo({y:this._convertValue(C.pageY-this.offset.top-this.currentHandle[0].offsetHeight/2,"y"),x:this._convertValue(C.pageX-this.offset.left-this.currentHandle[0].offsetWidth/2,"x")},null,!this.options.distance);},_createRange:function(){if(this.rangeElement){return ;}this.rangeElement=A("<div></div>").addClass("ui-slider-range").css({position:"absolute"}).appendTo(this.element);this._updateRange();},_removeRange:function(){this.rangeElement.remove();this.rangeElement=null;},_updateRange:function(){var C=this.options.axis=="vertical"?"top":"left";var B=this.options.axis=="vertical"?"height":"width";this.rangeElement.css(C,(parseInt(A(this.handle[0]).css(C),10)||0)+this._handleSize(0,this.options.axis=="vertical"?"y":"x")/2);this.rangeElement.css(B,(parseInt(A(this.handle[1]).css(C),10)||0)-(parseInt(A(this.handle[0]).css(C),10)||0));},_getRange:function(){return this.rangeElement?this._convertValue(parseInt(this.rangeElement.css(this.options.axis=="vertical"?"height":"width"),10),this.options.axis=="vertical"?"y":"x"):null;},_handleIndex:function(){return this.handle.index(this.currentHandle[0]);},value:function(D,B){if(this.handle.length==1){this.currentHandle=this.handle;}if(!B){B=this.options.axis=="vertical"?"y":"x";}var C=A(D!=undefined&&D!==null?this.handle[D]||D:this.currentHandle);if(C.data("mouse").sliderValue){return parseInt(C.data("mouse").sliderValue[B],10);}else{return parseInt(((parseInt(C.css(B=="x"?"left":"top"),10)/(this.actualSize[B=="x"?"width":"height"]-this._handleSize(D,B)))*this.options.realMax[B])+this.options.min[B],10);}},_convertValue:function(C,B){return this.options.min[B]+(C/(this.actualSize[B=="x"?"width":"height"]-this._handleSize(null,B)))*this.options.realMax[B];},_translateValue:function(C,B){return((C-this.options.min[B])/this.options.realMax[B])*(this.actualSize[B=="x"?"width":"height"]-this._handleSize(null,B));},_translateRange:function(D,B){if(this.rangeElement){if(this.currentHandle[0]==this.handle[0]&&D>=this._translateValue(this.value(1),B)){D=this._translateValue(this.value(1,B)-this._oneStep(B),B);}if(this.currentHandle[0]==this.handle[1]&&D<=this._translateValue(this.value(0),B)){D=this._translateValue(this.value(0,B)+this._oneStep(B),B);}}if(this.options.handles){var C=this.options.handles[this._handleIndex()];if(D<this._translateValue(C.min,B)){D=this._translateValue(C.min,B);}else{if(D>this._translateValue(C.max,B)){D=this._translateValue(C.max,B);}}}return D;},_translateLimits:function(C,B){if(C>=this.actualSize[B=="x"?"width":"height"]-this._handleSize(null,B)){C=this.actualSize[B=="x"?"width":"height"]-this._handleSize(null,B);}if(C<=0){C=0;}return C;},_handleSize:function(C,B){return A(C!=undefined&&C!==null?this.handle[C]:this.currentHandle)[0]["offset"+(B=="x"?"Width":"Height")];},_oneStep:function(B){return this.options.stepping[B]||1;},_pageStep:function(B){return 10;},_start:function(C,B){var D=this.options;if(D.disabled){return false;}this.actualSize={width:this.element.outerWidth(),height:this.element.outerHeight()};if(!this.currentHandle){this._focus(this.previousHandle,true);}this.offset=this.element.offset();this.handleOffset=this.currentHandle.offset();this.clickOffset={top:C.pageY-this.handleOffset.top,left:C.pageX-this.handleOffset.left};this.firstValue=this.value();this._propagate("start",C);this._drag(C,B);return true;},_stop:function(B){this._propagate("stop",B);if(this.firstValue!=this.value()){this._propagate("change",B);}this._focus(this.currentHandle,true);return false;},_drag:function(E,D){var F=this.options;var B={top:E.pageY-this.offset.top-this.clickOffset.top,left:E.pageX-this.offset.left-this.clickOffset.left};if(!this.currentHandle){this._focus(this.previousHandle,true);}B.left=this._translateLimits(B.left,"x");B.top=this._translateLimits(B.top,"y");if(F.stepping.x){var C=this._convertValue(B.left,"x");C=Math.round(C/F.stepping.x)*F.stepping.x;B.left=this._translateValue(C,"x");}if(F.stepping.y){var C=this._convertValue(B.top,"y");C=Math.round(C/F.stepping.y)*F.stepping.y;B.top=this._translateValue(C,"y");}B.left=this._translateRange(B.left,"x");B.top=this._translateRange(B.top,"y");if(F.axis!="vertical"){this.currentHandle.css({left:B.left});}if(F.axis!="horizontal"){this.currentHandle.css({top:B.top});}this.currentHandle.data("mouse").sliderValue={x:Math.round(this._convertValue(B.left,"x"))||0,y:Math.round(this._convertValue(B.top,"y"))||0};if(this.rangeElement){this._updateRange();}this._propagate("slide",E);return false;},moveTo:function(F,E,G){var H=this.options;this.actualSize={width:this.element.outerWidth(),height:this.element.outerHeight()};if(E==undefined&&!this.currentHandle&&this.handle.length!=1){return false;}if(E==undefined&&!this.currentHandle){E=0;}if(E!=undefined){this.currentHandle=this.previousHandle=A(this.handle[E]||E);}if(F.x!==undefined&&F.y!==undefined){var B=F.x,I=F.y;}else{var B=F,I=F;}if(B!==undefined&&B.constructor!=Number){var D=/^\-\=/.test(B),C=/^\+\=/.test(B);if(D||C){B=this.value(null,"x")+parseInt(B.replace(D?"=":"+=",""),10);}else{B=isNaN(parseInt(B,10))?undefined:parseInt(B,10);}}if(I!==undefined&&I.constructor!=Number){var D=/^\-\=/.test(I),C=/^\+\=/.test(I);if(D||C){I=this.value(null,"y")+parseInt(I.replace(D?"=":"+=",""),10);}else{I=isNaN(parseInt(I,10))?undefined:parseInt(I,10);}}if(H.axis!="vertical"&&B!==undefined){if(H.stepping.x){B=Math.round(B/H.stepping.x)*H.stepping.x;}B=this._translateValue(B,"x");B=this._translateLimits(B,"x");B=this._translateRange(B,"x");H.animate?this.currentHandle.stop().animate({left:B},(Math.abs(parseInt(this.currentHandle.css("left"))-B))*(!isNaN(parseInt(H.animate))?H.animate:5)):this.currentHandle.css({left:B});}if(H.axis!="horizontal"&&I!==undefined){if(H.stepping.y){I=Math.round(I/H.stepping.y)*H.stepping.y;}I=this._translateValue(I,"y");I=this._translateLimits(I,"y");I=this._translateRange(I,"y");H.animate?this.currentHandle.stop().animate({top:I},(Math.abs(parseInt(this.currentHandle.css("top"))-I))*(!isNaN(parseInt(H.animate))?H.animate:5)):this.currentHandle.css({top:I});}if(this.rangeElement){this._updateRange();}this.currentHandle.data("mouse").sliderValue={x:Math.round(this._convertValue(B,"x"))||0,y:Math.round(this._convertValue(I,"y"))||0};if(!G){this._propagate("start",null);this._propagate("stop",null);this._propagate("change",null);this._propagate("slide",null);}}});A.ui.slider.getter="value";A.ui.slider.defaults={handle:".ui-slider-handle",distance:1,animate:false};})(jQuery);(function(A){A.widget("ui.progressbar",{_init:function(){this._interval=this.options.interval;var B=this,C=this.options,E=(new Date()).getTime()+Math.random(),D=C.text||"";this.element.addClass("ui-progressbar").width(C.width);A.extend(this,{active:false,pixelState:0,percentState:0,identifier:E,bar:A('<div class="ui-progressbar-bar ui-hidden"></div>').css({width:"0px",overflow:"hidden",zIndex:100}),textElement:A('<div class="ui-progressbar-text"></div>').html(D).css({width:"0px",overflow:"hidden"}),textBg:A('<div class="ui-progressbar-text ui-progressbar-text-back"></div>').html(D).css({width:this.element.width()}),wrapper:A('<div class="ui-progressbar-wrap"></div>')});this.wrapper.append(this.bar.append(this.textElement.addClass(C.textClass)),this.textBg).appendTo(this.element);},plugins:{},ui:function(B){return{instance:this,identifier:this.identifier,options:this.options,element:this.bar,textElement:this.textElement,pixelState:this.pixelState,percentState:this.percentState};},_propagate:function(C,B){A.ui.plugin.call(this,C,[B,this.ui()]);this.element.triggerHandler(C=="progressbar"?C:["progressbar",C].join(""),[B,this.ui()],this.options[C]);},destroy:function(){this.stop();this.element.removeClass("ui-progressbar ui-progressbar-disabled").removeData("progressbar").unbind(".progressbar").find(".ui-progressbar-wrap").remove();delete jQuery.easing[this.identifier];},enable:function(){this.element.removeClass("ui-progressbar-disabled");this.disabled=false;},disable:function(){this.element.addClass("ui-progressbar-disabled");this.disabled=true;},start:function(){var B=this,C=this.options;if(this.disabled){return ;}jQuery.easing[this.identifier]=function(K,L,J,I,H){var G=C.increment,E=C.width,F=((G>E?E:G)/E),D=Math.round(K/F)*F;return D>1?1:D;};B.active=true;setTimeout(function(){B.active=false;},C.duration);this._animate();this._propagate("start",this.ui());return false;},_animate:function(){var C=this,D=this.options,B=D.interval;this.bar.animate({width:D.width},{duration:B,easing:this.identifier,step:function(G,E){C.progress((G/D.width)*100);var H=new Date().getTime(),F=(H-E.startTime);D.interval=B-F;},complete:function(){delete jQuery.easing[C.identifier];C.pause();if(C.active){}}});},pause:function(){if(this.disabled){return ;}this.bar.stop();this._propagate("pause",this.ui());},stop:function(){this.bar.stop();this.bar.width(0);this.textElement.width(0);this.bar.addClass("ui-hidden");this.options.interval=this._interval;this._propagate("stop",this.ui());},text:function(B){this.textElement.html(B);this.textBg.html(B);},progress:function(B){if(this.bar.is(".ui-hidden")){this.bar.removeClass("ui-hidden");}this.percentState=B>100?100:B;this.pixelState=(this.percentState/100)*this.options.width;this.bar.width(this.pixelState);this.textElement.width(this.pixelState);if(this.options.range&&!this.options.text){this.textElement.html(Math.round(this.percentState)+"%");}this._propagate("progress",this.ui());}});A.ui.progressbar.defaults={width:300,duration:3000,interval:200,increment:1,range:true,text:"",addClass:"",textClass:""};})(jQuery);(function(I){function B(){this.regional=[];this.regional[""]={labels:["Years","Months","Weeks","Days","Hours","Min","Sec"],labelsSingle:["Year","Month","Week","Day","Hour","Min","Sec"],compactLabels:["y","m","w","d"],compactLabelsSingle:["y","m","w","d"],timeSeparator:":"};this._defaults={format:"dHMS",layout:"",compact:false,description:"",expiryUrl:null,alwaysExpire:false,onExpiry:null,onTick:null,serverTime:null};I.extend(this._defaults,this.regional[""]);}var L="countdown";var C=0;var J=1;var E=2;var A=3;var N=4;var K=5;var G=6;I.extend(B.prototype,{markerClassName:"hasCountdown",setDefaults:function(D){F(this._defaults,D||{});},_attachCountdown:function(M,D){M=I(M);if(M.is("."+this.markerClassName)){return ;}M.addClass(this.markerClassName);if(!M[0].id){M[0].id="cdn"+new Date().getTime();}var H={};H.options=I.extend({},D);H._periods=[0,0,0,0,0,0,0];this._adjustSettings(H);I.data(M[0],L,H);this._updateCountdown(M,H);},_updateCountdown:function(S,P){var R=I(S);P=P||I.data(R[0],L);if(!P){return ;}R.html(this._generateHTML(P));var H=this._get(P,"onTick");if(H){H.apply(R[0],[P._hold!="lap"?P._periods:this._calculatePeriods(P,P._show,new Date())]);}var M=P._hold!="pause"&&(P._since?P._now.getTime()<=P._since.getTime():P._now.getTime()>=P._until.getTime());if(M){if(P._timer||this._get(P,"alwaysExpire")){var O=this._get(P,"onExpiry");if(O){O.apply(R[0],[]);}var D=this._get(P,"expiryUrl");if(D){window.location=D;}}P._timer=null;}else{if(P._hold=="pause"){P._time=null;}else{var Q=this._get(P,"format");P._timer=setTimeout('$.countdown._updateCountdown("#'+R[0].id+'")',(Q.match("s|S")?1:(Q.match("m|M")?30:600))*980);}}I.data(R[0],L,P);},_changeCountdown:function(M,D){var H=I.data(M,L);if(H){F(H.options,D||{});this._adjustSettings(H);I.data(M,L,H);this._updateCountdown(M,H);}},_destroyCountdown:function(H){H=I(H);if(!H.is("."+this.markerClassName)){return ;}H.removeClass(this.markerClassName).empty();var D=I.data(H[0],L);if(D._timer){clearTimeout(D._timer);}I.removeData(H[0],L);},_pauseCountdown:function(D){this._hold(D,"pause");},_lapCountdown:function(D){this._hold(D,"lap");},_resumeCountdown:function(D){this._hold(D,null);},_hold:function(O,M){var H=I.data(O,L);if(H){if(H._hold=="pause"&&!M){H._periods=H._savePeriods;var D=(H._since?"-":"+");H[H._since?"_since":"_until"]=this._determineTime(D+H._periods[0]+"Y"+D+H._periods[1]+"O"+D+H._periods[2]+"W"+D+H._periods[3]+"D"+D+H._periods[4]+"H"+D+H._periods[5]+"M"+D+H._periods[6]+"S");}H._hold=M;H._savePeriods=(M=="pause"?H._periods:null);I.data(O,L,H);this._updateCountdown(O,H);}},_getTimesCountdown:function(H){var D=I.data(H,L);return(!D?null:(!D._hold?D._periods:this._calculatePeriods(D,D._show,new Date())));},_get:function(H,D){return(H.options[D]!=null?H.options[D]:I.countdown._defaults[D]);},_adjustSettings:function(M){var D=new Date();var H=this._get(M,"serverTime");M._offset=(H?H.getTime()-D.getTime():0);M._since=this._get(M,"since");if(M._since){M._since=this._determineTime(M._since,null);}M._until=this._determineTime(this._get(M,"until"),D);M._show=this._determineShow(M);},_determineTime:function(P,D){var O=function(S){var R=new Date();R.setTime(R.getTime()+S*1000);return R;};var M=function(R,S){return 32-new Date(R,S,32).getDate();};var H=function(V){var S=new Date();var Z=S.getFullYear();var X=S.getMonth();var a=S.getDate();var U=S.getHours();var T=S.getMinutes();var R=S.getSeconds();var Y=/([+-]?[0-9]+)\s*(s|S|m|M|h|H|d|D|w|W|o|O|y|Y)?/g;var W=Y.exec(V);while(W){switch(W[2]||"s"){case"s":case"S":R+=parseInt(W[1]);break;case"m":case"M":T+=parseInt(W[1]);break;case"h":case"H":U+=parseInt(W[1]);break;case"d":case"D":a+=parseInt(W[1]);break;case"w":case"W":a+=parseInt(W[1])*7;break;case"o":case"O":X+=parseInt(W[1]);a=Math.min(a,M(Z,X));break;case"y":case"Y":Z+=parseInt(W[1]);a=Math.min(a,M(Z,X));break;}W=Y.exec(V);}S=new Date(Z,X,a,U,T,R,0);return S;};var Q=(P==null?D:(typeof P=="string"?H(P):(typeof P=="number"?O(P):P)));if(Q){Q.setMilliseconds(0);}return Q;},_generateHTML:function(P){P._periods=periods=(P._hold?P._periods:this._calculatePeriods(P,P._show,new Date()));var V=false;var M=0;for(var T=0;T<P._show.length;T++){V|=(P._show[T]=="?"&&periods[T]>0);P._show[T]=(P._show[T]=="?"&&!V?null:P._show[T]);M+=(P._show[T]?1:0);}var U=this._get(P,"compact");var R=this._get(P,"layout");var Q=(U?this._get(P,"compactLabels"):this._get(P,"labels"));var D=(U?this._get(P,"compactLabelsSingle"):this._get(P,"labelsSingle"))||Q;var X=this._get(P,"timeSeparator");var W=this._get(P,"description")||"";var H=function(Y){return(Y<10?"0":"")+Y;};var S=function(Y){return(P._show[Y]?periods[Y]+(periods[Y]==1?D[Y]:Q[Y])+" ":"");};var O=function(Y){return(P._show[Y]?'<div class="countdown_section"><span class="countdown_amount">'+periods[Y]+'</span><span class="countdown_amount-desc">'+(periods[Y]==1?D[Y]:Q[Y])+"</span></div>":"");};W=false;return(R?this._buildLayout(P,R,Q,D):((U?'<div class="countdown_row countdown_amount'+(P._hold?" countdown_holding":"")+'">'+S(C)+S(J)+S(E)+S(A)+(P._show[N]?H(periods[N]):"")+(P._show[K]?(P._show[N]?X:"")+H(periods[K])+"Min":"")+(P._show[G]?(P._show[N]||P._show[K]?X:"")+H(periods[G])+"Sec":""):'<div class="countdown_row countdown_show'+M+(P._hold?" countdown_holding":"")+'">'+O(C)+O(J)+O(E)+O(A)+O(N)+O(K)+O(G))+"</div>"+(W?'<div class="countdown_row countdown_descr">'+W+"</div>":"")));},_buildLayout:function(Q,P,R,O){var M=P;var D=function(W,S){var U=new RegExp("%"+W+".*%"+W);var T=new RegExp("%"+W+".*");while(true){var V=U.exec(M);if(!V){break;}V[0]=V[0].substr(0,2)+V[0].substr(2).replace(T,"%"+W);M=M.replace(V[0],Q._show[S]?H(V[0],W,S):"");}};var H=function(U,T,S){return U.substr(2,U.length-4).replace(/%nn/g,(Q._periods[S]<10?"0":"")+Q._periods[S]).replace(/%n/g,Q._periods[S]).replace(/%l/g,Q._periods[S]==1?O[S]:R[S]);};D("Y",C);D("O",J);D("W",E);D("D",A);D("H",N);D("M",K);D("S",G);return M;},_determineShow:function(H){var M=this._get(H,"format");var D=[];D[C]=(M.match("y")?"?":(M.match("Y")?"!":null));D[J]=(M.match("o")?"?":(M.match("O")?"!":null));D[E]=(M.match("w")?"?":(M.match("W")?"!":null));D[A]=(M.match("d")?"?":(M.match("D")?"!":null));D[N]=(M.match("h")?"?":(M.match("H")?"!":null));D[K]=(M.match("m")?"?":(M.match("M")?"!":null));D[G]=(M.match("s")?"?":(M.match("S")?"!":null));return D;},_calculatePeriods:function(Q,H,O){Q._now=O;Q._now.setMilliseconds(0);var S=new Date(Q._now.getTime());if(Q._since&&O.getTime()<Q._since.getTime()){Q._now=O=S;}else{if(Q._since){O=Q._since;}else{S.setTime(Q._until.getTime());if(O.getTime()>Q._until.getTime()){Q._now=O=S;}}}S.setTime(S.getTime()-Q._offset);var P=[0,0,0,0,0,0,0];if(H[C]||H[J]){var D=Math.max(0,(S.getFullYear()-O.getFullYear())*12+S.getMonth()-O.getMonth()+(S.getDate()<O.getDate()?-1:0));P[C]=(H[C]?Math.floor(D/12):0);P[J]=(H[J]?D-P[C]*12:0);if(Q._since){S.setFullYear(S.getFullYear()-P[C]);S.setMonth(S.getMonth()-P[J]);}else{O=new Date(O.getTime());O.setFullYear(O.getFullYear()+P[C]);O.setMonth(O.getMonth()+P[J]);}}var R=Math.floor((S.getTime()-O.getTime())/1000);var M=function(U,T){P[U]=(H[U]?Math.floor(R/T):0);R-=P[U]*T;};M(E,604800);M(A,86400);M(N,3600);M(K,60);M(G,1);return P;}});function F(M,H){I.extend(M,H);for(var D in H){if(H[D]==null){M[D]=null;}}return M;}I.fn.countdown=function(H){var D=Array.prototype.slice.call(arguments,1);if(H=="getTimes"){return I.countdown["_"+H+"Countdown"].apply(I.countdown,[this[0]].concat(D));}return this.each(function(){if(typeof H=="string"){I.countdown["_"+H+"Countdown"].apply(I.countdown,[this].concat(D));}else{I.countdown._attachCountdown(this,H);}});};I.countdown=new B();})(jQuery);(function(E){E.fn.jqm=function(F){var A={overlay:50,overlayClass:"jqmOverlay",closeClass:"jqmClose",trigger:".jqModal",ajax:O,ajaxText:"",target:O,modal:O,toTop:O,onShow:O,onHide:O,onLoad:O};return this.each(function(){if(this._jqm){return N[this._jqm].c=E.extend({},N[this._jqm].c,F);}P++;this._jqm=P;N[P]={c:E.extend(A,E.jqm.params,F),a:O,w:E(this).addClass("jqmID"+P),s:P};if(A.trigger){E(this).jqmAddTrigger(A.trigger);}});};E.fn.jqmAddClose=function(A){return M(this,A,"jqmHide");};E.fn.jqmAddTrigger=function(A){return M(this,A,"jqmShow");};E.fn.jqmShow=function(A){return this.each(function(){E.jqm.open(this._jqm,A);});};E.fn.jqmHide=function(A){return this.each(function(){E.jqm.close(this._jqm,A);});};E.jqm={hash:{},open:function(V,U){var L=N[V],Q=L.c,H="."+Q.closeClass,R=(parseInt(L.w.css("z-index"))),R=(R>0)?R:3000,F=E("<div></div>").css({height:"100%",width:"100%",position:"fixed",left:0,top:0,"z-index":R-1,opacity:Q.overlay/100});if(L.a){return O;}L.t=U;L.a=true;L.w.css("z-index",R);if(Q.modal){if(!B[0]){K("bind");}B.push(V);}else{if(Q.overlay>0){L.w.jqmAddClose(F);}else{F=O;}}L.o=(F)?F.addClass(Q.overlayClass).prependTo("body"):O;if(D){E("html,body").css({height:"100%",width:"100%"});if(F){F=F.css({position:"absolute"})[0];for(var S in {Top:1,Left:1}){F.style.setExpression(S.toLowerCase(),"(_=(document.documentElement.scroll"+S+" || document.body.scroll"+S+"))+'px'");}}}if(Q.ajax){var A=Q.target||L.w,T=Q.ajax,A=(typeof A=="string")?E(A,L.w):E(A),T=(T.substr(0,1)=="@")?E(U).attr(T.substring(1)):T;A.html(Q.ajaxText).load(T,function(){if(Q.onLoad){Q.onLoad.call(this,L);}if(H){L.w.jqmAddClose(E(H,L.w));}J(L);});}else{if(H){L.w.jqmAddClose(E(H,L.w));}}if(Q.toTop&&L.o){L.w.before('<span id="jqmP'+L.w[0]._jqm+'"></span>').insertAfter(L.o);}(Q.onShow)?Q.onShow(L):L.w.show();J(L);return O;},close:function(F){var A=N[F];if(!A.a){return O;}A.a=O;if(B[0]){B.pop();if(!B[0]){K("unbind");}}if(A.c.toTop&&A.o){E("#jqmP"+A.w[0]._jqm).after(A.w).remove();}if(A.c.onHide){A.c.onHide(A);}else{A.w.hide();if(A.o){A.o.remove();}}return O;},params:{}};var P=0,N=E.jqm.hash,B=[],D=E.browser.msie&&(E.browser.version=="6.0"),O=false,G=E('<iframe src="javascript:false;document.write(\'\');" class="jqm"></iframe>').css({opacity:0}),J=function(A){if(D){if(A.o){A.o.html('<p style="width:100%;height:100%"/>').prepend(G);}else{if(!E("iframe.jqm",A.w)[0]){A.w.prepend(G);}}}I(A);},I=function(F){try{E(":input:visible",F.w)[0].focus();}catch(A){}},K=function(A){E()[A]("keypress",C)[A]("keydown",C)[A]("mousedown",C);},C=function(H){var A=N[B[B.length-1]],F=(!E(H.target).parents(".jqmID"+A.s)[0]);if(F){I(A);}return !F;},M=function(A,F,H){return A.each(function(){var L=this._jqm;E(F).each(function(){if(!this[H]){this[H]=[];E(this).click(function(){for(var Q in {jqmShow:1,jqmHide:1}){for(var R in this[Q]){if(N[this[Q][R]]){N[this[Q][R]].w[Q](this);}}}return O;});}this[H].push(L);});});};})(jQuery);jQuery.fn.catfish=function(A){this.settings={closeLink:"none",animation:"slide",height:"50"};if(A){jQuery.extend(this.settings,A);}if(this.settings.animation!="slide"&&this.settings.animation!="none"&&this.settings.animation!="fade"){alert("animation can only be set to 'slide', 'none' or 'fade'");}var B=this.attr("id");settings=this.settings;jQuery(this).css("padding","0").css("height",this.settings.height+"px").css("margin","0").css("width","100%");jQuery("html").css("padding","0 0 "+(this.settings.height*1+50)+"px 0");if(typeof document.body.style.maxHeight!="undefined"){jQuery(this).css("position","fixed").css("bottom","0").css("left","0");}if(this.settings.animation=="slide"){jQuery(this).slideDown("slow");}else{if(this.settings.animation=="fade"){jQuery(this).fadeIn("slow");}else{jQuery(this).show();}}if(this.settings.closeLink!="none"){jQuery(this.settings.closeLink).click(function(){jQuery.closeCatfish(B);return false;});}return this;};jQuery.closeCatfish=function(A){this.catfish=jQuery("#"+A);jQuery(this.catfish).hide();jQuery("html").css("padding","0");jQuery("body").css("overflow","visible");};var MONTH_NAMES=new Array("January","February","March","April","May","June","July","August","September","October","November","December","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");var DAY_NAMES=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sun","Mon","Tue","Wed","Thu","Fri","Sat");var isReturn=false;var NUM_CENTYEAR=30;var BUL_TIMECOMPONENT=false;var BUL_YEARSCROLL=true;var calendars=[];var RE_NUM=/^\-?\d+$/;var monthAry=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];var ARR_MONTHS=["January","February","March","April","May","June","July","August","September","October","November","December"];var ARR_WEEKDAYS=["Sun","Mon","Tue","Wed","Thur","Fri","Sat"];var NUM_WEEKSTART=0;var currDate;var dt_current;var passedDate;var depdate;var dt_firstday;var curday;var curmon;year_scroll=BUL_YEARSCROLL;var sysDate="";var targetDisplayCol="";var targetDisplayColHidden="";var mflag=0;var ctflag=0;function LZ(A){return(A<0||A>9?"":"0")+A;}function isDate(C,B){var A=getDateFromFormat(C,B);if(A==0){return false;}return true;}function compareDates(E,F,C,D){var B=getDateFromFormat(E,F);var A=getDateFromFormat(C,D);if(B==0||A==0){return -1;}else{if(B>A){return 1;}}return 0;}function formatDate(g,a){a=a+"";var J="";var T=0;var f="";var D="";var I=g.getYear()+"";var F=g.getMonth()+1;var b=g.getDate();var N=g.getDay();var L=g.getHours();var V=g.getMinutes();var P=g.getSeconds();var R,S,B,Q,j,C,Z,Y,W,O,n,L,l,G,A,X;var U=new Object();if(I.length<4){I=""+(I-0+1900);}U.y=""+I;U.yyyy=I;U.yy=I.substring(2,4);U.M=F;U.MM=LZ(F);U.MMM=MONTH_NAMES[F-1];U.NNN=MONTH_NAMES[F+11];U.d=b;U.dd=LZ(b);U.E=DAY_NAMES[N+7];U.EE=DAY_NAMES[N];U.H=L;U.HH=LZ(L);if(L==0){U.h=12;}else{if(L>12){U.h=L-12;}else{U.h=L;}}U.hh=LZ(U.h);if(L>11){U.K=L-12;}else{U.K=L;}U.k=L+1;U.KK=LZ(U.K);U.kk=LZ(U.k);if(L>11){U.a="PM";}else{U.a="AM";}U.m=V;U.mm=LZ(V);U.s=P;U.ss=LZ(P);while(T<a.length){f=a.charAt(T);D="";while((a.charAt(T)==f)&&(T<a.length)){D+=a.charAt(T++);}if(U[D]!=null){J=J+U[D];}else{J=J+D;}}return J;}function _isInteger(C){var B="1234567890";for(var A=0;A<C.length;A++){if(B.indexOf(C.charAt(A))==-1){return false;}}return true;}function _getInt(F,D,E,C){for(var A=C;A>=E;A--){var B=F.substring(D,D+A);if(B.length<E){return null;}if(_isInteger(B)){return B;}}return null;}function getDateFromFormat(U,N){U=U+"";N=N+"";var T=0;var J=0;var P="";var E="";var S="";var G,F;var B=new Date();var H=B.getYear();var R=B.getMonth()+1;var Q=1;var C=B.getHours();var O=B.getMinutes();var L=B.getSeconds();var I="";while(J<N.length){P=N.charAt(J);E="";while((N.charAt(J)==P)&&(J<N.length)){E+=N.charAt(J++);}if(E=="yyyy"||E=="yy"||E=="y"){if(E=="yyyy"){G=4;F=4;}if(E=="yy"){G=2;F=2;}if(E=="y"){G=2;F=4;}H=_getInt(U,T,G,F);if(H==null){return 0;}T+=H.length;if(H.length==2){if(H>70){H=1900+(H-0);}else{H=2000+(H-0);}}}else{if(E=="MMM"||E=="NNN"){R=0;for(var M=0;M<MONTH_NAMES.length;M++){var D=MONTH_NAMES[M];if(U.substring(T,T+D.length).toLowerCase()==D.toLowerCase()){if(E=="MMM"||(E=="NNN"&&M>11)){R=M+1;if(R>12){R-=12;}T+=D.length;break;}}}if((R<1)||(R>12)){return 0;}}else{if(E=="EE"||E=="E"){for(var M=0;M<DAY_NAMES.length;M++){var K=DAY_NAMES[M];if(U.substring(T,T+K.length).toLowerCase()==K.toLowerCase()){T+=K.length;break;}}}else{if(E=="MM"||E=="M"){R=_getInt(U,T,E.length,2);if(R==null||(R<1)||(R>12)){return 0;}T+=R.length;}else{if(E=="dd"||E=="d"){Q=_getInt(U,T,E.length,2);if(Q==null||(Q<1)||(Q>31)){return 0;}T+=Q.length;}else{if(E=="hh"||E=="h"){C=_getInt(U,T,E.length,2);if(C==null||(C<1)||(C>12)){return 0;}T+=C.length;}else{if(E=="HH"||E=="H"){C=_getInt(U,T,E.length,2);if(C==null||(C<0)||(C>23)){return 0;}T+=C.length;}else{if(E=="KK"||E=="K"){C=_getInt(U,T,E.length,2);if(C==null||(C<0)||(C>11)){return 0;}T+=C.length;}else{if(E=="kk"||E=="k"){C=_getInt(U,T,E.length,2);if(C==null||(C<1)||(C>24)){return 0;}T+=C.length;C--;}else{if(E=="mm"||E=="m"){O=_getInt(U,T,E.length,2);if(O==null||(O<0)||(O>59)){return 0;}T+=O.length;}else{if(E=="ss"||E=="s"){L=_getInt(U,T,E.length,2);if(L==null||(L<0)||(L>59)){return 0;}T+=L.length;}else{if(E=="a"){if(U.substring(T,T+2).toLowerCase()=="am"){I="AM";}else{if(U.substring(T,T+2).toLowerCase()=="pm"){I="PM";}else{return 0;}}T+=2;}else{if(U.substring(T,T+E.length)!=E){return 0;}else{T+=E.length;}}}}}}}}}}}}}}if(T!=U.length){return 0;}if(R==2){if(((H%4==0)&&(H%100!=0))||(H%400==0)){if(Q>29){return 0;}}else{if(Q>28){return 0;}}}if((R==4)||(R==6)||(R==9)||(R==11)){if(Q>30){return 0;}}if(C<12&&I=="PM"){C=C-0+12;}else{if(C>11&&I=="AM"){C-=12;}}var A=new Date(H,R-1,Q,C,O,L);return A.getTime();}function parseDate(G){var E=(arguments.length==2)?arguments[1]:false;generalFormats=new Array("y-M-d","MMM d, y","MMM d,y","y-MMM-d","d-MMM-y","MMM d");monthFirst=new Array("M/d/y","M-d-y","M.d.y","MMM-d","M/d","M-d");dateFirst=new Array("d/M/y","d-M-y","d.M.y","d-MMM","d/M","d-M");var B=new Array("generalFormats",E?"dateFirst":"monthFirst",E?"monthFirst":"dateFirst");var F=null;for(var D=0;D<B.length;D++){var A=window[B[D]];for(var C=0;C<A.length;C++){F=getDateFromFormat(G,A[C]);if(F!=0){return new Date(F);}}}return null;}function getdtnumber(A){var C=A.substr(A.length-4,4);var E=getMonthVal(A.substr(A.length-8,3))+"";if(E.replace(/^\s*|\s*$/g,"").length==1){E="0"+E;}var B=A.substr(0,2);var D=C+E+B;return D;}function gen_date(A){return((A.getDate()<=9?"0":"")+A.getDate()+"/"+((A.getMonth()+1)<=9?"0":"")+(A.getMonth()+1)+"/"+A.getFullYear());}(function(A){A.fn.extend({autocomplete:function(B,C){var D=typeof B=="string";C=A.extend({},A.Autocompleter.defaults,{url:D?B:null,data:D?null:B,delay:D?A.Autocompleter.defaults.delay:10,max:C&&!C.scroll?10:150},C);C.highlight=C.highlight||function(E){return E;};C.formatMatch=C.formatMatch||C.formatItem;return this.each(function(){new A.Autocompleter(this,C);});},result:function(B){return this.bind("result",B);},search:function(B){return this.trigger("search",[B]);},flushCache:function(){return this.trigger("flushCache");},setOptions:function(B){return this.trigger("setOptions",[B]);},unautocomplete:function(){return this.trigger("unautocomplete");}});A.Autocompleter=function(L,G){var C={UP:38,DOWN:40,DEL:46,TAB:9,RETURN:13,ESC:27,COMMA:188,PAGEUP:33,PAGEDOWN:34,BACKSPACE:8};var B=A(L).attr("autocomplete","off").addClass(G.inputClass);var S=[];var J;var Q="";var M=A.Autocompleter.Cache(G);var E=0;var V;var Y={mouseDownOnSelect:false};var R=A.Autocompleter.Select(G,L,D,Y);var X;A.browser.opera&&A(L.form).bind("submit.autocomplete",function(){if(X){X=false;return false;}});B.bind((A.browser.opera?"keypress":"keydown")+".autocomplete",function(Z){V=Z.keyCode;switch(Z.keyCode){case C.UP:Z.preventDefault();if(R.visible()){R.prev();}else{U(0,true);}break;case C.DOWN:Z.preventDefault();if(R.visible()){R.next();}else{U(0,true);}break;case C.PAGEUP:Z.preventDefault();if(R.visible()){R.pageUp();}else{U(0,true);}break;case C.PAGEDOWN:Z.preventDefault();if(R.visible()){R.pageDown();}else{U(0,true);}break;case G.multiple&&A.trim(G.multipleSeparator)==","&&C.COMMA:case C.TAB:case C.RETURN:if(D()){Z.preventDefault();X=true;return false;}break;case C.ESC:R.hide();break;default:clearTimeout(J);J=setTimeout(U,G.delay);break;}}).focus(function(){E++;}).blur(function(){E=0;if(!Y.mouseDownOnSelect){T();}}).click(function(){if(E++>1&&!R.visible()){U(0,true);}}).bind("search",function(){var Z=(arguments.length>1)?arguments[1]:null;function a(f,d){var b;if(d&&d.length){for(var c=0;c<d.length;c++){if(d[c].result.toLowerCase()==f.toLowerCase()){b=d[c];break;}}}if(typeof Z=="function"){Z(b);}else{B.trigger("result",b&&[b.data,b.value]);}}A.each(H(B.val()),function(b,c){F(c,a,a);});}).bind("flushCache",function(){M.flush();}).bind("setOptions",function(){A.extend(G,arguments[1]);if("data" in arguments[1]){M.populate();}}).bind("unautocomplete",function(){R.unbind();B.unbind();var Z=A(".ac_results");A(".ac_even").unbind("click");A(".ac_odd").unbind("click");if(Z.length>0){Z.remove();}A(L.form).unbind(".autocomplete");});function D(){var a=R.selected();if(!a){return false;}var Z=a.result;Q=Z;if(G.multiple){var b=H(B.val());if(b.length>1){Z=b.slice(0,b.length-1).join(G.multipleSeparator)+G.multipleSeparator+Z;}Z+=G.multipleSeparator;}B.val(Z);W();B.trigger("result",[a.data,a.value]);return true;}function U(b,a){if(V==C.DEL){R.hide();return ;}var Z=B.val();if(!a&&Z==Q){return ;}Q=Z;Z=I(Z);if(Z.length>=G.minChars){B.addClass(G.loadingClass);if(!G.matchCase){Z=Z.toLowerCase();}F(Z,K,W);}else{N();R.hide();}}function H(a){if(!a){return[""];}var b=a.split(G.multipleSeparator);var Z=[];A.each(b,function(c,d){if(A.trim(d)){Z[c]=A.trim(d);}});return Z;}function I(Z){if(!G.multiple){return Z;}var a=H(Z);return a[a.length-1];}function P(Z,a){if(G.autoFill&&(I(B.val()).toLowerCase()==Z.toLowerCase())&&V!=C.BACKSPACE){B.val(B.val()+a.substring(I(Q).length));A.Autocompleter.Selection(L,Q.length,Q.length+a.length);}}function T(){clearTimeout(J);J=setTimeout(W,200);}function W(){var Z=R.visible();R.hide();clearTimeout(J);N();if(G.mustMatch){B.search(function(a){if(!a){if(G.multiple){var b=H(B.val()).slice(0,-1);B.val(b.join(G.multipleSeparator)+(b.length?G.multipleSeparator:""));}else{B.val("");}}});}if(Z){A.Autocompleter.Selection(L,L.value.length,L.value.length);}}function K(a,Z){if(Z&&Z.length&&E){N();R.display(Z,a);P(a,Z[0].value);R.show();}else{W();}}function F(a,c,Z){if(!G.matchCase){a=a.toLowerCase();}var b=M.load(a);if(b&&b.length){c(a,b);}else{if((typeof G.url=="string")&&(G.url.length>0)){var d={timestamp:+new Date()};A.each(G.extraParams,function(f,g){d[f]=typeof g=="function"?g():g;});S.push(a);if(S.length==1){A.ajax({mode:"abort",port:"autocomplete"+L.name,dataType:G.dataType,url:G.url,data:A.extend({q:I(a),limit:G.max},d),success:function(h){var f=G.parse&&G.parse(h)||O(h);M.add(a,f);if(S.length>1){var g=S[S.length-1];S=[];F(g,c,Z);}else{S=[];c(a,f);}}});}}else{R.emptyList();Z(a);}}}function O(c){var Z=[];var b=c.split("\n");for(var a=0;a<b.length;a++){var d=A.trim(b[a]);if(d){d=d.split("|");Z[Z.length]={data:d,value:d[0],result:G.formatResult&&G.formatResult(d,d[0])||d[0]};}}return Z;}function N(){B.removeClass(G.loadingClass);}};A.Autocompleter.defaults={inputClass:"ac_input",resultsClass:"ac_results",loadingClass:"ac_loading",minChars:1,delay:0,matchCase:false,matchSubset:true,matchContains:true,cacheLength:10,max:100,mustMatch:false,extraParams:{},selectFirst:true,formatItem:function(B){return B[0];},formatMatch:null,autoFill:false,width:300,multiple:false,multipleSeparator:", ",highlight:function(C,B){return C;},scroll:true,scrollHeight:180};A.Autocompleter.Cache=function(C){var F={};var D=0;function H(K,J){if(!C.matchCase){K=K.toLowerCase();}var I=K.indexOf(J);if(C.matchContains=="word"){I=K.toLowerCase().search("\\b"+J.toLowerCase());}if(I==-1){return false;}return I==0||C.matchContains;}function G(J,I){if(D>C.cacheLength){B();}if(!F[J]){D++;}F[J]=I;}function E(){if(!C.data){return false;}var J={},I=0;if(!C.url){C.cacheLength=1;}J[""]=[];for(var L=0,K=C.data.length;L<K;L++){var O=C.data[L];O=(typeof O=="string")?[O]:O;var N=C.formatMatch(O,L+1,C.data.length);if(N===false){continue;}var M=N.charAt(0).toLowerCase();if(!J[M]){J[M]=[];}var P={value:N,data:O,result:C.formatResult&&C.formatResult(O)||N};J[M].push(P);if(I++<C.max){J[""].push(P);}}A.each(J,function(Q,R){C.cacheLength++;G(Q,R);});}setTimeout(E,25);function B(){F={};D=0;}return{flush:B,add:G,populate:E,load:function(L){if(!C.cacheLength||!D){return null;}if(!C.url&&C.matchContains){var K=[];for(var I in F){if(I.length>0){var M=F[I];A.each(M,function(O,N){if(H(N.value,L)){K.push(N);}});}}return K;}else{if(F[L]){return F[L];}else{if(C.matchSubset){for(var J=L.length-1;J>=C.minChars;J--){var M=F[L.substr(0,J)];if(M){var K=[];A.each(M,function(O,N){if(H(N.value,L)){K[K.length]=N;}});return K;}}}}}return null;}};};A.Autocompleter.Select=function(E,M,O,T){var L={ACTIVE:"ac_over"};var N,G=-1,V,P="",W=true,C,S;function R(){if(!W){A(".ac_odd").unbind();A(".ac_even").unbind();C&&C.empty();S=A("<div/>").css("overflow","auto").appendTo(C);return ;}C=A("<div/>").hide().addClass(E.resultsClass).css("position","absolute").css("overflow","auto").appendTo(document.body);S=A("<div/>").css("overflow","auto").appendTo(C);if(E.width>0){C.css("width",E.width);}W=false;}function U(Y){var X=Y.target;while(X&&X.tagName!="DIV"){X=X.parentNode;}if(!X){return[];}return X;}function K(X){N.slice(G,G+1).removeClass(L.ACTIVE);H(X);var Z=N.slice(G,G+1).addClass(L.ACTIVE);if(E.scroll){var Y=0;N.slice(0,G).each(function(){Y+=this.offsetHeight;});if((Y+Z[0].offsetHeight-S.scrollTop())>S[0].clientHeight){S.scrollTop(Y+Z[0].offsetHeight-S.innerHeight());}else{if(Y<S.scrollTop()){S.scrollTop(Y);}}}}function H(X){G+=X;if(G<0){G=N.size()-1;}else{if(G>=N.size()){G=0;}}}function B(X){E.max=100;return E.max&&E.max<X?E.max:X;}function Q(X){if(U(X).nodeName&&U(X).nodeName.toUpperCase()=="DIV"){G=A("div",S).removeClass(L.ACTIVE).index(U(X));A(U(X)).addClass(L.ACTIVE);}}function J(X){A(U(X)).addClass(L.ACTIVE);O();M.focus();return false;}function I(){T.mouseDownOnSelect=true;}function F(){T.mouseDownOnSelect=false;}function D(){S.empty();var Y=B(V.length);for(var Z=0;Z<Y;Z++){if(!V[Z]){continue;}var a=E.formatItem(V[Z].data,Z+1,Y,V[Z].value,P);if(a===false){continue;}var X=A("<DIV/>").css("padding-left","5px").css("width","97%").html(E.highlight(a,P)).addClass(Z%2==0?"ac_even":"ac_odd").mouseover(Q).click(J).mousedown(I).mouseup(F).appendTo(S)[0];A.data(X,"ac_data",V[Z]);}N=S.find("DIV");if(E.selectFirst){N.slice(0,1).addClass(L.ACTIVE);G=0;}if(A.fn.bgiframe){S.bgiframe();}}return{display:function(Y,X){R();V=Y;P=X;D();},next:function(){K(1);},prev:function(){K(-1);},pageUp:function(){if(G!=0&&G-8<0){K(-G);}else{K(-8);}},pageDown:function(){if(G!=N.size()-1&&G+8>N.size()){K(N.size()-1-G);}else{K(8);}},hide:function(){N&&N.unbind("click",J).unbind("mouseover",Q).unbind("mousedown",I).unbind("mouseup",F);N&&N.removeClass(L.ACTIVE);C&&C.hide();C&&C.empty();G=-1;},visible:function(){return C&&C.is(":visible");},current:function(){return this.visible()&&(N.filter("."+L.ACTIVE)[0]||E.selectFirst&&N[0]);},show:function(){var Z=A(M).offset();C.css({width:typeof E.width=="string"||E.width>0?E.width:A(M).width(),top:Z.top+M.offsetHeight,left:Z.left}).show();if(E.scroll){S.scrollTop(0);S.css({maxHeight:E.scrollHeight,width:"100%",cursor:"pointer"});if(A.browser.msie&&typeof document.body.style.maxHeight==="undefined"){var X=0;N.each(function(){X+=this.offsetHeight;});var Y=X>E.scrollHeight;S.css("height",Y?E.scrollHeight:X);if(!Y){N.width(S.width()-parseInt(N.css("padding-left"))-parseInt(N.css("padding-right")));}}}},selected:function(){var X=N&&N.filter("."+L.ACTIVE).removeClass(L.ACTIVE);
//getFareHistory();
return X&&X.length&&A.data(X[0],"ac_data");},emptyList:function(){S&&S.empty();},unbind:function(){C&&C.remove();}};};A.Autocompleter.Selection=function(D,E,C){if(D.createTextRange){var B=D.createTextRange();B.collapse(true);B.moveStart("character",E);B.moveEnd("character",C);B.select();}else{if(D.setSelectionRange){D.setSelectionRange(E,C);}else{if(D.selectionStart){D.selectionStart=E;D.selectionEnd=C;}}}D.focus();};})(jQuery);(function(A){A.fn.bgIframe=A.fn.bgiframe=function(C){if(A.browser.msie&&/6.0/.test(navigator.userAgent)){C=A.extend({top:"auto",left:"auto",width:"auto",height:"auto",opacity:true,src:"javascript:false;"},C||{});var D=function(E){return E&&E.constructor==Number?E+"px":E;},B='<iframe class="bgiframe"frameborder="0"tabindex="-1"src="'+C.src+'"style="display:block;position:absolute;z-index:-1;'+(C.opacity!==false?"filter:Alpha(Opacity='0');":"")+"top:"+(C.top=="auto"?"expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+'px')":D(C.top))+";left:"+(C.left=="auto"?"expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+'px')":D(C.left))+";width:"+(C.width=="auto"?"expression(this.parentNode.offsetWidth+'px')":D(C.width))+";height:"+(C.height=="auto"?"expression(this.parentNode.offsetHeight+'px')":D(C.height))+';"/>';return this.each(function(){if(A("> iframe.bgiframe",this).length==0){this.insertBefore(document.createElement(B),this.firstChild);}});}return this;};})(jQuery);jQuery.fn.bt=function(content,options){if(typeof content!="string"){var contentSelect=true;options=content;content=false;}else{var contentSelect=false;}return this.each(function(index){var opts=jQuery.extend(false,jQuery.fn.bt.defaults,options);opts.spikeLength=numb(opts.spikeLength);opts.spikeGirth=numb(opts.spikeGirth);opts.overlap=numb(opts.overlap);var turnOn=function(){if(typeof $(this).data("bt-box")=="object"){turnOff.apply(this);}opts.preShow.apply(this);if(contentSelect){if(opts.killTitle){$(this).attr("title",$(this).attr("bt-xTitle"));}content=eval("$(this)."+opts.titleSelector);if(opts.killTitle){$(this).removeAttr("title");}}var offsetParent=$(this).offsetParent();var pos=$(this).btPosition();var top=numb(pos.top)+numb($(this).css("margin-top"));var left=numb(pos.left)+numb($(this).css("margin-left"));var width=$(this).outerWidth();var height=$(this).outerHeight();var $text=$('<div class="bt-content"></div>').append(content).css({padding:opts.padding+"px",position:"absolute",width:opts.width+"px",zIndex:opts.textzIndex}).css(opts.cssStyles);var $box=$('<div class="bt-wrapper"></div>').append($text).addClass(opts.cssClass).css({position:"absolute",width:opts.width+"px"}).appendTo(offsetParent);$(this).data("bt-box",$box);var scrollTop=numb($(document).scrollTop());var scrollLeft=numb($(document).scrollLeft());var docWidth=numb($(window).width());var docHeight=numb($(window).height());var winRight=scrollLeft+docWidth;var winBottom=scrollTop+docHeight;var space=new Object();space.top=$(this).offset().top-scrollTop;space.bottom=docHeight-(($(this).offset().top+height)-scrollTop);space.left=$(this).offset().left-scrollLeft;space.right=docWidth-(($(this).offset().left+width)-scrollLeft);var textOutHeight=numb($text.outerHeight());var textOutWidth=numb($text.outerWidth());if(opts.positions.constructor==String){opts.positions=opts.positions.replace(/ /,"").split(",");}if(opts.positions[0]=="most"){var position="top";for(var pig in space){position=space[pig]>space[position]?pig:position;}}else{for(var x in opts.positions){var position=opts.positions[x];if((position=="left"||position=="right")&&space[position]>textOutWidth+opts.spikeLength){break;}else{if((position=="top"||position=="bottom")&&space[position]>textOutHeight+opts.spikeLength){break;}}}}var horiz=left+((width-textOutWidth)/2);var vert=top+((height-textOutHeight)/2);var animDist=opts.animate?numb(opts.distance):0;var points=new Array();var textTop,textLeft,textRight,textBottom,textTopSpace,textBottomSpace,textLeftSpace,textRightSpace,crossPoint,textCenter;switch(position){case"top":$text.css("margin-bottom",opts.spikeLength+"px");$box.css({top:(top-$text.outerHeight(true)-animDist)+opts.overlap,left:horiz});textRightSpace=(winRight-opts.windowMargin)-($text.offset().left+$text.outerWidth(true));var xShift=0;if(textRightSpace<0){$box.css("left",(numb($box.css("left"))+textRightSpace)+"px");xShift-=textRightSpace;}textLeftSpace=($text.offset().left+numb($text.css("margin-left")))-(scrollLeft+opts.windowMargin);if(textLeftSpace<0){$box.css("left",(numb($box.css("left"))-textLeftSpace)+"px");xShift+=textLeftSpace;}textTop=$text.btPosition().top+numb($text.css("margin-top"));textLeft=$text.btPosition().left+numb($text.css("margin-left"));textRight=textLeft+$text.outerWidth();textBottom=textTop+$text.outerHeight();textCenter={x:textLeft+($text.outerWidth()/2),y:textTop+($text.outerHeight()/2)};points[points.length]=spikePoint={y:textBottom+opts.spikeLength,x:((textRight-textLeft)/2)+xShift,type:"spike"};crossPoint=findIntersectX(spikePoint.x,spikePoint.y,textCenter.x,textCenter.y,textBottom);crossPoint.x=crossPoint.x<textLeft+opts.spikeGirth/2+opts.cornerRadius?textLeft+opts.spikeGirth/2+opts.cornerRadius:crossPoint.x;crossPoint.x=crossPoint.x>(textRight-opts.spikeGirth/2)-opts.cornerRadius?(textRight-opts.spikeGirth/2)-opts.CornerRadius:crossPoint.x;points[points.length]={x:crossPoint.x-(opts.spikeGirth/2),y:textBottom,type:"join"};points[points.length]={x:textLeft,y:textBottom,type:"corner"};points[points.length]={x:textLeft,y:textTop,type:"corner"};points[points.length]={x:textRight,y:textTop,type:"corner"};points[points.length]={x:textRight,y:textBottom,type:"corner"};points[points.length]={x:crossPoint.x+(opts.spikeGirth/2),y:textBottom,type:"join"};points[points.length]=spikePoint;break;case"left":$text.css("margin-right",opts.spikeLength+"px");$box.css({top:vert+"px",left:((left-$text.outerWidth(true)-animDist)+opts.overlap)+"px"});textBottomSpace=(winBottom-opts.windowMargin)-($text.offset().top+$text.outerHeight(true));var yShift=0;if(textBottomSpace<0){$box.css("top",(numb($box.css("top"))+textBottomSpace)+"px");yShift-=textBottomSpace;}textTopSpace=($text.offset().top+numb($text.css("margin-top")))-(scrollTop+opts.windowMargin);if(textTopSpace<0){$box.css("top",(numb($box.css("top"))-textTopSpace)+"px");yShift+=textTopSpace;}textTop=$text.btPosition().top+numb($text.css("margin-top"));textLeft=$text.btPosition().left+numb($text.css("margin-left"));textRight=textLeft+$text.outerWidth();textBottom=textTop+$text.outerHeight();textCenter={x:textLeft+($text.outerWidth()/2),y:textTop+($text.outerHeight()/2)};points[points.length]=spikePoint={x:textRight+opts.spikeLength,y:((textBottom-textTop)/2)+yShift,type:"spike"};crossPoint=findIntersectY(spikePoint.x,spikePoint.y,textCenter.x,textCenter.y,textRight);crossPoint.y=crossPoint.y<textTop+opts.spikeGirth/2+opts.cornerRadius?textTop+opts.spikeGirth/2+opts.cornerRadius:crossPoint.y;crossPoint.y=crossPoint.y>(textBottom-opts.spikeGirth/2)-opts.cornerRadius?(textBottom-opts.spikeGirth/2)-opts.cornerRadius:crossPoint.y;points[points.length]={x:textRight,y:crossPoint.y+opts.spikeGirth/2,type:"join"};points[points.length]={x:textRight,y:textBottom,type:"corner"};points[points.length]={x:textLeft,y:textBottom,type:"corner"};points[points.length]={x:textLeft,y:textTop,type:"corner"};points[points.length]={x:textRight,y:textTop,type:"corner"};points[points.length]={x:textRight,y:crossPoint.y-opts.spikeGirth/2,type:"join"};points[points.length]=spikePoint;break;case"bottom":$text.css("margin-top",opts.spikeLength+"px");$box.css({top:(top+height+animDist)-opts.overlap,left:horiz});textRightSpace=(winRight-opts.windowMargin)-($text.offset().left+$text.outerWidth(true));var xShift=0;if(textRightSpace<0){$box.css("left",(numb($box.css("left"))+textRightSpace)+"px");xShift-=textRightSpace;}textLeftSpace=($text.offset().left+numb($text.css("margin-left")))-(scrollLeft+opts.windowMargin);if(textLeftSpace<0){$box.css("left",(numb($box.css("left"))-textLeftSpace)+"px");xShift+=textLeftSpace;}textTop=$text.btPosition().top+numb($text.css("margin-top"));textLeft=$text.btPosition().left+numb($text.css("margin-left"));textRight=textLeft+$text.outerWidth();textBottom=textTop+$text.outerHeight();textCenter={x:textLeft+($text.outerWidth()/2),y:textTop+($text.outerHeight()/2)};points[points.length]=spikePoint={x:((textRight-textLeft)/2)+xShift,y:0,type:"spike"};crossPoint=findIntersectX(spikePoint.x,spikePoint.y,textCenter.x,textCenter.y,textTop);crossPoint.x=crossPoint.x<textLeft+opts.spikeGirth/2+opts.cornerRadius?textLeft+opts.spikeGirth/2+opts.cornerRadius:crossPoint.x;crossPoint.x=crossPoint.x>(textRight-opts.spikeGirth/2)-opts.cornerRadius?(textRight-opts.spikeGirth/2)-opts.cornerRadius:crossPoint.x;points[points.length]={x:crossPoint.x+opts.spikeGirth/2,y:textTop,type:"join"};points[points.length]={x:textRight,y:textTop,type:"corner"};points[points.length]={x:textRight,y:textBottom,type:"corner"};points[points.length]={x:textLeft,y:textBottom,type:"corner"};points[points.length]={x:textLeft,y:textTop,type:"corner"};points[points.length]={x:crossPoint.x-(opts.spikeGirth/2),y:textTop,type:"join"};points[points.length]=spikePoint;break;case"right":$text.css("margin-left",(opts.spikeLength+"px"));$box.css({top:vert+"px",left:((left+width+animDist)-opts.overlap)+"px"});textBottomSpace=(winBottom-opts.windowMargin)-($text.offset().top+$text.outerHeight(true));var yShift=0;if(textBottomSpace<0){$box.css("top",(numb($box.css("top"))+textBottomSpace)+"px");yShift-=textBottomSpace;}textTopSpace=($text.offset().top+numb($text.css("margin-top")))-(scrollTop+opts.windowMargin);if(textTopSpace<0){$box.css("top",(numb($box.css("top"))-textTopSpace)+"px");yShift+=textTopSpace;}textTop=$text.btPosition().top+numb($text.css("margin-top"));textLeft=$text.btPosition().left+numb($text.css("margin-left"));textRight=textLeft+$text.outerWidth();textBottom=textTop+$text.outerHeight();textCenter={x:textLeft+($text.outerWidth()/2),y:textTop+($text.outerHeight()/2)};points[points.length]=spikePoint={x:0,y:((textBottom-textTop)/2)+yShift,type:"spike"};crossPoint=findIntersectY(spikePoint.x,spikePoint.y,textCenter.x,textCenter.y,textLeft);crossPoint.y=crossPoint.y<textTop+opts.spikeGirth/2+opts.cornerRadius?textTop+opts.spikeGirth/2+opts.cornerRadius:crossPoint.y;crossPoint.y=crossPoint.y>(textBottom-opts.spikeGirth/2)-opts.cornerRadius?(textBottom-opts.spikeGirth/2)-opts.cornerRadius:crossPoint.y;points[points.length]={x:textLeft,y:crossPoint.y-opts.spikeGirth/2,type:"join"};points[points.length]={x:textLeft,y:textTop,type:"corner"};points[points.length]={x:textRight,y:textTop,type:"corner"};points[points.length]={x:textRight,y:textBottom,type:"corner"};points[points.length]={x:textLeft,y:textBottom,type:"corner"};points[points.length]={x:textLeft,y:crossPoint.y+opts.spikeGirth/2,type:"join"};points[points.length]=spikePoint;break;}var canvas=$('<canvas width="'+(numb($text.outerWidth(true))+opts.strokeWidth*2)+'" height="'+(numb($text.outerHeight(true))+opts.strokeWidth*2)+'"></canvas>').appendTo($box).css({position:"absolute",top:$text.btPosition().top,left:$text.btPosition().left,zIndex:opts.boxzIndex}).get(0);if(typeof G_vmlCanvasManager!="undefined"){canvas=G_vmlCanvasManager.initElement(canvas);if(canvas==null){canvas=$('<canvas width="'+(numb($text.outerWidth(true))+opts.strokeWidth*2)+'" height="'+(numb($text.outerHeight(true))+opts.strokeWidth*2)+'"></canvas>').appendTo($box).css({position:"absolute",top:$text.btPosition().top,left:$text.btPosition().left,zIndex:opts.boxzIndex}).get(0);}}if(canvas==null){canvas=$('<canvas width="'+(numb($text.outerWidth(true))+opts.strokeWidth*2)+'" height="'+(numb($text.outerHeight(true))+opts.strokeWidth*2)+'"></canvas>').appendTo($box).css({position:"absolute",top:$text.btPosition().top,left:$text.btPosition().left,zIndex:opts.boxzIndex}).get(0);}if(opts.cornerRadius>0){var newPoints=new Array();var newPoint;for(var i=0;i<points.length;i++){if(points[i].type=="corner"){newPoint=betweenPoint(points[i],points[(i-1)%points.length],opts.cornerRadius);newPoint.type="arcStart";newPoints[newPoints.length]=newPoint;newPoints[newPoints.length]=points[i];newPoint=betweenPoint(points[i],points[(i+1)%points.length],opts.cornerRadius);newPoint.type="arcEnd";newPoints[newPoints.length]=newPoint;}else{newPoints[newPoints.length]=points[i];}}points=newPoints;}var ctx=canvas.getContext("2d");drawIt.apply(ctx,[points]);ctx.fillStyle=opts.fill;if(opts.shadow){ctx.shadowOffsetX=2;ctx.shadowOffsetY=2;ctx.shadowBlur=5;ctx.shadowColor=opts.shadowColor;}ctx.closePath();ctx.fill();if(opts.strokeWidth>0){ctx.lineWidth=opts.strokeWidth;ctx.strokeStyle=opts.strokeStyle;ctx.beginPath();drawIt.apply(ctx,[points]);ctx.closePath();ctx.stroke();}if(opts.animate){$box.css({opacity:0.1});}$box.css({visibility:"visible"});if(opts.overlay){var overlay=$('<div class="bt-overlay"></div>').css({position:"absolute",backgroundColor:"blue",top:top,left:left,width:width,height:height,opacity:".2"}).appendTo(offsetParent);$(this).data("overlay",overlay);}var animParams={opacity:1};if(opts.animate){switch(position){case"top":animParams.top=$box.btPosition().top+opts.distance;break;case"left":animParams.left=$box.btPosition().left+opts.distance;break;case"bottom":animParams.top=$box.btPosition().top-opts.distance;break;case"right":animParams.left=$box.btPosition().left-opts.distance;break;}$box.animate(animParams,{duration:opts.speed,easing:opts.easing});}opts.postShow.apply(this);};var turnOff=function(){opts.preHide.apply(this);var box=$(this).data("bt-box");var overlay=$(this).data("bt-overlay");if(typeof box=="object"){$(box).remove();$(this).removeData("bt-box");}if(typeof overlay=="object"){$(overlay).remove();$(this).removeData("bt-overlay");}opts.postHide.apply(this);};var refresh=function(){turnOff.apply(this);turnOn.apply(this);};if(opts.killTitle){$(this).find("[title]").andSelf().each(function(){$(this).attr("bt-xTitle",$(this).attr("title")).removeAttr("title");});}if(typeof opts.trigger=="string"){opts.trigger=[opts.trigger];}if(opts.trigger[0]=="hover"){$(this).hover(function(){turnOn.apply(this);},function(){turnOff.apply(this);});}else{if(opts.trigger[0]=="now"){var box=$(this).data("bt-box");if(typeof box=="object"){turnOff.apply(this);}else{turnOn.apply(this);}}else{if(opts.trigger.length>1&&opts.trigger[0]!=opts.trigger[1]){$(this).bind(opts.trigger[0],function(){turnOn.apply(this);}).bind(opts.trigger[1],function(){turnOff.apply(this);});}else{$(this).bind(opts.trigger[0],function(){if(typeof this.triggerToggle=="undefined"){this.triggerToggle=false;}this.triggerToggle=!this.triggerToggle;if(this.triggerToggle){turnOn.apply(this);}else{turnOff.apply(this);}});}}}});function drawIt(points){this.moveTo(points[0].x,points[0].y);for(i=1;i<points.length;i++){if(points[i-1].type=="arcStart"){this.quadraticCurveTo(round5(points[i].x),round5(points[i].y),round5(points[(i+1)%points.length].x),round5(points[(i+1)%points.length].y));i++;}else{this.lineTo(round5(points[i].x),round5(points[i].y));}}}function round5(num){return Math.round(num-0.5)+0.5;}function numb(num){return parseInt(num)||0;}function betweenPoint(point1,point2,dist){var y,x;if(point1.x==point2.x){y=point1.y<point2.y?point1.y+dist:point1.y-dist;return{x:point1.x,y:y};}else{if(point1.y==point2.y){x=point1.x<point2.x?point1.x+dist:point1.x-dist;return{x:x,y:point1.y};}}}function centerPoint(arcStart,corner,arcEnd){var x=corner.x==arcStart.x?arcEnd.x:arcStart.x;var y=corner.y==arcStart.y?arcEnd.y:arcStart.y;var startAngle,endAngle;if(arcStart.x<arcEnd.x){if(arcStart.y>arcEnd.y){startAngle=(Math.PI/180)*180;endAngle=(Math.PI/180)*90;}else{startAngle=(Math.PI/180)*90;endAngle=0;}}else{if(arcStart.y>arcEnd.y){startAngle=(Math.PI/180)*270;endAngle=(Math.PI/180)*180;}else{startAngle=0;endAngle=(Math.PI/180)*270;}}return{x:x,y:y,type:"center",startAngle:startAngle,endAngle:endAngle};}function findIntersect(r1x1,r1y1,r1x2,r1y2,r2x1,r2y1,r2x2,r2y2){if(r2x1==r2x2){return findIntersectY(r1x1,r1y1,r1x2,r1y2,r2x1);}if(r2y1==r2y2){return findIntersectX(r1x1,r1y1,r1x2,r1y2,r2y1);}var r1m=(r1y1-r1y2)/(r1x1-r1x2);var r1b=r1y1-(r1m*r1x1);var r2m=(r2y1-r2y2)/(r2x1-r2x2);var r2b=r2y1-(r2m*r2x1);var x=(r2b-r1b)/(r1m-r2m);var y=r1m*x+r1b;return{x:x,y:y};}function findIntersectY(r1x1,r1y1,r1x2,r1y2,x){if(r1y1==r1y2){return{x:x,y:r1y1};}var r1m=(r1y1-r1y2)/(r1x1-r1x2);var r1b=r1y1-(r1m*r1x1);var y=r1m*x+r1b;return{x:x,y:y};}function findIntersectX(r1x1,r1y1,r1x2,r1y2,y){if(r1x1==r1x2){return{x:r1x1,y:y};}var r1m=(r1y1-r1y2)/(r1x1-r1x2);var r1b=r1y1-(r1m*r1x1);var x=(y-r1b)/r1m;return{x:x,y:y};}};jQuery.fn.btPosition=function(){function B(H,I){return H[0]&&parseInt(jQuery.curCSS(H[0],I,true),10)||0;}var F=0,E=0,C;if(this[0]){var D=this.offsetParent(),G=this.offset(),A=/^body|html$/i.test(D[0].tagName)?{top:0,left:0}:D.offset();G.top-=B(this,"marginTop");G.left-=B(this,"marginLeft");A.top+=B(D,"borderTopWidth");A.left+=B(D,"borderLeftWidth");C={top:G.top-A.top,left:G.left-A.left};}return C;};jQuery.fn.bt.defaults={trigger:"hover",width:200,padding:10,spikeGirth:10,spikeLength:15,overlap:0,overlay:false,killTitle:true,textzIndex:9999,boxzIndex:9990,positions:["most"],fill:"rgb(255, 255, 102)",windowMargin:10,strokeWidth:1,strokeStyle:"#000",cornerRadius:5,shadow:false,shadowOffsetX:2,shadowOffsetY:2,shadowBlur:3,shadowColor:"#000",animate:false,distance:15,easing:"swing",speed:200,cssClass:"",cssStyles:{},titleSelector:"attr('title')",preShow:function(){return ;},postShow:function(){return ;},preHide:function(){return ;},postHide:function(){return ;}};(function(B){B.jmap=B.jmap||{};B.jmap.store={};B.jmap.JDetails={name:"jMaps Google Maps Plugin",description:"jMaps is a jQuery plugin that makes google maps easy",version:"3.0",releaseDate:"19/04/2008",author:"Tane Piper <digitalspaghetti@gmail.com>",blog:"http://digitalspaghetti.me.uk",repository:"http://hg.digitalspaghetti.me.uk/jmaps",googleGroup:"http://groups.google.com/group/jmaps",licenceType:"MIT",licenceURL:"http://www.opensource.org/licenses/mit-license.php"};B.jmap.JErrors={en:{functionDoesNotExist:"jMap Error 1: The function does not exist",addressNotFound:"This address cannot be found.  Please modify your search.",browserNotCompatible:"This browser is reported as being not compatible with Google Maps.",cannotLoad:"Cannot load the Google Maps API at this time.  Please check your connection."},fr:{addressNotFound:"Cette adresse ne peut pas être trouvée. Veuillez modifier votre recherche.",browserNotCompatible:"Ce navigateur est rapporté en tant qu'étant non compatible avec des cartes de Google.",cannotLoad:"Ne peut pas charger les cartes api de Google actuellement. Veuillez vérifier votre raccordement."},de:{addressNotFound:"Diese Adresse kann nicht gefunden werden. Ändern Sie bitte Ihre Suche.",browserNotCompatible:"Diese Datenbanksuchroutine wird als seiend nicht kompatibel mit Google Diagrammen berichtet.",cannotLoad:"Kann nicht die Google Diagramme API diesmal laden. Überprüfen Sie bitte Ihren Anschluß."},nl:{addressNotFound:"Dit adres kan worden gevonden niet. Gelieve te wijzigen uw onderzoek.",browserNotCompatible:"Dit browser wordt gemeld zoals zijnd niet compatibel met Kaarten Google.",cannotLoad:"Kan de Google Kaarten API op dit moment laden niet. Gelieve te controleren uw verbinding."},es:{addressNotFound:"Esta dirección no puede ser encontrada. Modifique por favor su búsqueda.",browserNotCompatible:"Este browser se divulga como siendo no compatible con los mapas de Google.",cannotLoad:"No puede cargar los mapas API de Google en este tiempo. Compruebe por favor su conexión."},sv:{addressNotFound:"Denna adress kunde ej hittas. Var god justera din sökning",browserNotCompatible:"Denna webbläsare är ej kompatibel med Google Maps",cannotLoad:"Kan inte ladda Google Maps API för tillfället. Var god kontrollera din anslutning."}};B.jmap.JDefaults={language:"en",mapType:"map",mapCenter:[55.958858,-3.162302],mapDimensions:[400,400],mapZoom:12,mapControlSize:"small",mapEnableType:false,mapEnableOverview:false,mapEnableDragging:true,mapEnableInfoWindows:true,mapEnableDoubleClickZoom:false,mapEnableScrollZoom:false,mapEnableSmoothZoom:false,mapEnableGoogleBar:false,mapEnableScaleControl:false,mapShowjMapIcon:false,debugMode:false};B.jmap.JAdsManagerDefaults={publisherId:""};B.jmap.JFeedDefaults={feedUrl:"",mapCenter:[]};B.jmap.JGroundOverlayDefaults={overlaySouthWestBounds:[],overlayNorthEastBounds:[],overlayImage:""};B.jmap.JIconDefaults={iconImage:"",iconShadow:"",iconSize:null,iconShadowSize:null,iconAnchor:null,iconInfoWindowAnchor:null,iconPrintImage:"",iconMozPrintImage:"",iconPrintShadow:"",iconTransparent:""};B.jmap.JMarkerManagerDefaults={borderPadding:100,maxZoom:17,trackMarkers:false};B.jmap.JMarkerDefaults={pointLatLng:[],pointHTML:null,pointOpenHTMLEvent:"mouseover",pointIsDraggable:false,pointIsRemovable:false,pointRemoveEvent:"dblclick",pointMinZoom:4,pointMaxZoom:17,pointIcon:null,pointMaxContent:null,pointMaxTitle:null};B.jmap.JPolygonDefaults={polygonPoints:[],polygonStrokeColor:"#000000",polygonStrokeWeight:5,polygonStrokeOpacity:1,polygonFillColor:"#ff0000",polygonFillOpacity:1,mapCenter:[],polygonClickable:true};B.jmap.JPolylineDefaults={polylinePoints:[],polylineStrokeColor:"#ff0000",polylineStrokeWidth:10,polylineStrokeOpacity:1,mapCenter:[],polylineGeodesic:false,polylineClickable:true,pointHTML:"aggsdga",pointOpenHTMLEvent:"mouseover",pointMaxContent:null,pointMaxTitle:null};B.jmap.JScreenOverlayDefaults={};B.jmap.JSearchAddressDefaults={address:null,cache:{},countryCode:"uk"};B.jmap.JSearchDirectionsDefault={fromAddress:"",toAddress:"",directionsPanel:""};B.jmap.JTrafficDefaults={method:"create",mapCenter:[]};B.jmap.JMoveToDefaults={centerMethod:"normal",mapType:null,mapCenter:[],mapZoom:null};B.jmap.JSavePositionDefaults={recall:false};B.jmap.variables={mapType:"Unknown",mapCenter:[]};B.jmap.init=function(G,H,A){var H=B.extend({},B.jmap.JDefaults,H);var H=B.jmap.JOptions=B.meta?B.extend({},H,B(this).data()):H;B.jmap._initChecks(G);G.jmap=B.jmap.GMap2=new GMap2(G);if(H.mapShowjMapIcon){B.jmap.addScreenOverlay({imageUrl:"http://hg.digitalspaghetti.me.uk/jmaps/raw-file/3228fade0b3c/docs/images/jmaps-mapicon.png",screenXY:[70,10],overlayXY:[0,0],size:[42,25]});}var F=B.jmap._initMapType(H.mapType);G.jmap.setCenter(new GLatLng(H.mapCenter[0],H.mapCenter[1]),H.mapZoom,F);switch(H.mapControlSize){case"small":G.jmap.addControl(new GSmallMapControl());break;case"large":G.jmap.addControl(new GLargeMapControl());break;}if(H.mapEnableType){G.jmap.addControl(new GMapTypeControl());}if(H.mapEnableOverview){G.jmap.addControl(new GOverviewMapControl());}if(!H.mapEnableDragging){G.jmap.disableDragging();}if(!H.mapEnableInfoWindows){G.jmap.disableInfoWindow();}if(H.mapEnableDoubleClickZoom){G.jmap.enableDoubleClickZoom();}if(H.mapEnableScrollZoom){G.jmap.enableScrollWheelZoom();}if(H.mapEnableSmoothZoom){G.jmap.enableContinuousZoom();}if(H.mapEnableGoogleBar){G.jmap.enableGoogleBar();}if(H.mapEnableScaleControl){G.jmap.addControl(new GScaleControl());}if(H.debugMode){console.log(G.jmap);}B.jmap.getMapType();if(typeof A=="function"){return A(G,H);}};B.jmap.addFeed=function(F,A){var F=B.extend({},B.jmap.JFeedDefaults,F);var E=new GGeoXml(F.feedUrl);B.jmap.GMap2.addOverlay(E);if(F.mapCenter[0]&&F.mapCenter[1]){B.jmap.GMap2.setCenter(new GLatLng(F.mapCenter[0],F.mapCenter[1]));}if(typeof A=="function"){return A(E,F);}};B.jmap.addGroundOverlay=function(F,A){var F=B.extend({},B.jmap.JGroundOverlayDefaults,F);var E=new GLatLngBounds(new GLatLng(F.overlaySouthWestBounds[0],F.overlaySouthWestBounds[1]),new GLatLng(F.overlayNorthEastBounds[0],F.overlayNorthEastBounds[1]));B.jmap.GGroundOverlay=new GGroundOverlay(F.overlayImage,E);B.jmap.GMap2.addOverlay(B.jmap.GGroundOverlay);if(typeof A=="function"){return A();}};B.jmap.hideGroundOverlay=function(A){B.jmap.GGroundOverlay.hide();if(typeof A=="function"){return A();}};B.jmap.showGroundOverlay=function(A){isHidden=B.jmap.GGroundOverlay.isHidden();if(isHidden){B.jmap.GGroundOverlay.show();}if(typeof A=="function"){return A();}};B.jmap.addMarker=function(F,A){var F=B.extend({},B.jmap.JMarkerDefaults,F);var G={};if(typeof F.pointIcon=="object"){B.extend(G,{icon:F.pointIcon});}if(F.pointIsDraggable){B.extend(G,{draggable:F.pointIsDraggable});}var H=new GMarker(new GLatLng(F.pointLatLng[0],F.pointLatLng[1]),G);if(F.pointHTML){GEvent.addListener(H,F.pointOpenHTMLEvent,function(){H.openInfoWindowHtml(F.pointHTML,{maxContent:F.pointMaxContent,maxTitle:F.pointMaxTitle});});}if(F.pointIsRemovable){GEvent.addListener(H,F.pointRemoveEvent,function(){B.jmap.GMap2.removeOverlay(H);});}if(B.jmap.GMarkerManager){B.jmap.GMarkerManager.addMarker(H,F.pointMinZoom,F.pointMaxZoom);}else{B.jmap.GMap2.addOverlay(H);}if(typeof A=="function"){return A(H,F);}};B.jmap.removeMarker=function(A){B.jmap.GMap2.removeOverlay(A);};B.jmap.addScreenOverlay=function(E,A){var E=B.extend({},B.jmap.JScreenOverlayDefaults,E);var F=new GScreenOverlay(E.imageUrl,new GScreenPoint(E.screenXY[0],E.screenXY[1]),new GScreenPoint(E.overlayXY[0],E.overlayXY[1]),new GScreenSize(E.size[0],E.size[1]));B.jmap.GMap2.addOverlay(F);if(typeof A=="function"){return A(F,E);}};B.jmap.addPolygon=function(G,A){var G=B.extend({},B.jmap.JPolygonDefaults,G);H={};if(!G.polygonClickable){var H=B.extend({},H,{clickable:false});}if(G.mapCenter[0]&&G.mapCenter[1]){B.jmap.GMap2.setCenter(new GLatLng(G.mapCenter[0],G.mapCenter[1]));}var F=new GPolygon(G.polygonPoints,G.polygonStrokeColor,G.polygonStrokeWeight,G.polygonStrokeOpacity,G.polygonFillColor,G.polygonFillOpacity,H);B.jmap.GMap2.addOverlay(F);if(typeof A=="function"){return A();}};B.jmap.addPolyline=function(H,F){var H=B.extend({},B.jmap.JPolylineDefaults,H);var G={};if(H.polylineGeodesic){B.extend({},G,{geodesic:true});}if(!H.polylineClickable){B.extend({},G,{clickable:false});}if(H.mapCenter[0]&&H.mapCenter[1]){B.jmap.GMap2.setCenter(new GLatLng(H.mapCenter[0],H.mapCenter[1]));}var A={clickable:true,geodesic:true};var I=new GPolyline(H.polylinePoints,H.polylineStrokeColor,H.polylineStrokeWidth,H.polylineStrokeOpacity,A);B.jmap.GMap2.addOverlay(I);if(typeof F=="function"){return F(I,H);}};B.jmap.removePolyline=function(A){B.jmap.GMap2.removeOverlay(A);};B.jmap.openInfowindowpolyline=function(A){B.jmap.GMap2.openInfoWindow(A.polyCenter,A.polyHTML);};B.jmap.resetCenterAndZoom=function(A){B.jmap.GMap2.setCenter(new GLatLng(A.mapCenter[0],A.mapCenter[1]),A.mapZoom);};B.jmap.addTrafficInfo=function(D,A){var D=B.extend({},B.jmap.JTrafficDefaults,D);switch(D.method){case"create":B.jmap.GTrafficOverlay=new GTrafficOverlay;B.jmap.GMap2.addOverlay(B.jmap.GTrafficOverlay);if(D.mapCenter[0]&&D.mapCenter[1]){B.jmap.GMap2.setCenter(new GLatLng(D.mapCenter[0],D.mapCenter[1]));}break;case"destroy":B.jmap.GMap2.removeOverlay(B.jmap.GTrafficOverlay);break;}if(typeof A=="function"){return A();}};B.jmap.disableTraffic=function(A){B.jmap.GTrafficOverlay.hide();if(typeof A=="function"){return A();}};B.jmap.enableTraffic=function(A){B.jmap.GTrafficOverlay.show();if(typeof A=="function"){return A();}};B.jmap.createAdsManager=function(D,A){var D=B.extend({},B.jmap.JAdsManagerDefaults,D);B.jmap.GAdsManager=new GAdsManager(B.jmap.GMap2,D.publisherId);if(typeof A=="function"){return A();}};B.jmap.hideAds=function(A){B.jmap.GAdsManager.disable();if(typeof A=="function"){return A();}};B.jmap.showAds=function(A){B.jmap.GAdsManager.enable();if(typeof A=="function"){return A();}};B.jmap.createGeoCache=function(A){B.jmap.GGeocodeCache=new GGeocodeCache();if(typeof A=="function"){return A();}};B.jmap.createGeoCoder=function(D,A){if(D){B.jmap.GClientGeocoder=new GClientGeocoder(D);}else{B.jmap.GClientGeocoder=new GClientGeocoder;}if(typeof A=="function"){return A();}};B.jmap.createIcon=function(D){var D=B.extend({},B.jmap.JIconDefaults,D);var A=new GIcon(G_DEFAULT_ICON);if(D.iconImage){A.image=D.iconImage;}if(D.iconShadow){A.shadow=D.iconShadow;}if(D.iconSize){A.iconSize=D.iconSize;}if(D.iconShadowSize){A.shadowSize=D.iconShadowSize;}if(D.iconAnchor){A.iconAnchor=D.iconAnchor;}if(D.iconInfoWindowAnchor){A.infoWindowAnchor=D.iconInfoWindowAnchor;}return A;};B.jmap.createMarkerManager=function(D,A){var D=B.extend({},B.jmap.JMarkerManagerDefaults,D);B.jmap.GMarkerManager=new GMarkerManager(B.jmap.GMap2,D);if(typeof A=="function"){return A();}};B.jmap.searchAddress=function(H,A){var H=B.extend({},B.jmap.JSearchAddressDefaults,H);var G=B.extend({},B.jmap.JMarkerManagerDefaults);if(typeof B.jmap.GClientGeocoder=="undefined"){var F=new GClientGeocoder;}else{var F=B.jmap.GClientGeocoder;}F.getLatLng(H.address,function(C){if(!C){throw new Error(B.jmap.JErrors[B.jmap.JOptions.language].addressNotFound);}if(typeof A=="function"){return A(H,C);}});};B.jmap.searchDirections=function(E,A){var E=B.extend({},B.jmap.JSearchDirectionsDefaults,E);var F=B("#"+E.directionsPanel).get(0);B.jmap.GDirections=new GDirections(B.jmap.GMap2,F);B.jmap.GDirections.load(E.fromAddress+" to "+E.toAddress);if(typeof A=="function"){return A();}};B.jmap.moveTo=function(G,A){var G=B.extend({},B.jmap.JMoveToDefaults,G);if(G.mapType){var F=B.jmap._initMapType(G.mapType);}var H=new GLatLng(G.mapCenter[0],G.mapCenter[1]);switch(G.centerMethod){case"normal":B.jmap.GMap2.setCenter(H,G.mapZoom,F);break;case"pan":B.jmap.GMap2.panTo(H);break;}if(typeof A=="function"){return A();}};B.jmap.savePosition=function(D,A){var D=B.extend({},B.jmap.JMoveToDefaults,D);if(D.recall){B.jmap.GMap2.returnToSavedPosition();}else{B.jmap.GMap2.savePosition();}if(typeof A=="function"){return A();}};B.jmap.createKeyboardHandler=function(A){B.jmap.keyboardHandler=new GKeyboardHandler(B.jmap.GMap2);if(typeof A=="function"){return A();}};B.jmap.getMapType=function(){var A=B.jmap.GMap2.getMapTypes();var D=B.jmap.GMap2.getCurrentMapType();if(D.Hz){B.jmap.variables.mapType=D.Hz;}};B.jmap.getCenter=function(){var A=B.jmap.GMap2.getCenter();B.jmap.variables.mapCenter=A;if(typeof callback=="function"){return callback(A);}};B.jmap.getBounds=function(){var A=B.jmap.GMap2.getBounds();B.jmap.variables.mapBounds=A;if(typeof callback=="function"){return callback(A);}};B.jmap._initMapType=function(D){switch(D){case"map":var A=G_NORMAL_MAP;break;case"sat":var A=G_SATELLITE_MAP;break;case"hybrid":var A=G_HYBRID_MAP;break;}return A;};B.jmap._initChecks=function(A){if(typeof GBrowserIsCompatible=="undefined"){B(A).text(B.jmap.JErrors[B.jmap.JOptions.language].cannotLoad).css({color:"#f00"});throw Error(B.jmap.JErrors[B.jmap.JOptions.language].cannotLoad);}if(!GBrowserIsCompatible()){B(A).text(B.jmap.JErrors[B.jmap.JOptions.language].browserNotCompatible).css({color:"#f00"});throw Error(B.jmap.JErrors[B.jmap.JOptions.language].browserNotCompatible);}};B.jmap.storePoints=function(D,A){B.jmap.store=B.extend({},B.jmap.store,D);if(typeof A=="function"){return A(B.jmap.store);}};B.fn.jmap=function(A,F,E){return this.each(function(){if(A=="init"){new B.jmap.init(this,F,E);}else{if(typeof A=="object"||A==null){new B.jmap.init(this,A,F);}else{if(typeof F=="function"){new B.jmap[A](F);}else{try{new B.jmap[A](F,E);}catch(C){throw Error(B.jmap.JErrors[B.jmap.JOptions.language].functionDoesNotExist);}}}}});};})(jQuery);var iframe=null;jQuery.jPrintArea=function(C){iframe=document.createElement("IFRAME");var D=null;$(iframe).attr("style","position:absolute;width:0px;height:0px;left:-500px;top:-500px;");document.body.appendChild(iframe);D=iframe.contentWindow.document;var A=window.document.getElementsByTagName("link");for(var B=0;B<A.length;B++){if(A[B].rel.toLowerCase()=="stylesheet"){D.write('<link type="text/css" rel="stylesheet" href="'+A[B].href+'"></link>');}}D.write('<div class="'+$(C).attr("class")+'">'+$(C).html()+"</div>");D.close();iframe.contentWindow.focus();iframe.contentWindow.print();setTimeout("closePrintFrame()",60000);};function closePrintFrame(){if(iframe!=null){document.body.removeChild(iframe);}}if(!this.JSON){JSON=function(){function f(n){return n<10?"0"+n:n;}Date.prototype.toJSON=function(key){return this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z";};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf();};var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapeable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;function quote(string){escapeable.lastIndex=0;return escapeable.test(string)?'"'+string.replace(escapeable,function(a){var c=meta[a];if(typeof c==="string"){return c;}return"\\u"+("0000"+(+(a.charCodeAt(0))).toString(16)).slice(-4);})+'"':'"'+string+'"';}function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==="object"&&typeof value.toJSON==="function"){value=value.toJSON(key);}if(typeof rep==="function"){value=rep.call(holder,key,value);}switch(typeof value){case"string":return quote(value);case"number":return isFinite(value)?String(value):"null";case"boolean":case"null":return String(value);case"object":if(!value){return"null";}gap+=indent;partial=[];if(typeof value.length==="number"&&!(value.propertyIsEnumerable("length"))){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||"null";}v=partial.length===0?"[]":gap?"[\n"+gap+partial.join(",\n"+gap)+"\n"+mind+"]":"["+partial.join(",")+"]";gap=mind;return v;}if(rep&&typeof rep==="object"){length=rep.length;for(i=0;i<length;i+=1){k=rep[i];if(typeof k==="string"){v=str(k,value);if(v){partial.push(quote(k)+(gap?": ":":")+v);}}}}else{for(k in value){if(Object.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?": ":":")+v);}}}}v=partial.length===0?"{}":gap?"{\n"+gap+partial.join(",\n"+gap)+"\n"+mind+"}":"{"+partial.join(",")+"}";gap=mind;return v;}}return{stringify:function(value,replacer,space){var i;gap="";indent="";if(typeof space==="number"){for(i=0;i<space;i+=1){indent+=" ";}}else{if(typeof space==="string"){indent=space;}}rep=replacer;if(replacer&&typeof replacer!=="function"&&(typeof replacer!=="object"||typeof replacer.length!=="number")){throw new Error("JSON.stringify");}return str("",{"":value});},parse:function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==="object"){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v;}else{delete value[k];}}}}return reviver.call(holder,key,value);}cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return"\\u"+("0000"+(+(a.charCodeAt(0))).toString(16)).slice(-4);});}if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){j=eval("("+text+")");return typeof reviver==="function"?walk({"":j},""):j;}throw new SyntaxError("JSON.parse");}};}();}(function($) { // hide the namespace

$.extend($.ui, { datepicker: { version: "1.7.2" } });

var PROP_NAME = 'datepicker';

/* Date picker manager.
   Use the singleton instance of this class, $.datepicker, to interact with the date picker.
   Settings for (groups of) date pickers are maintained in an instance object,
   allowing multiple different settings on the same page. */

function Datepicker() {
	this.debug = false; // Change this to true to start debugging
	this._curInst = null; // The current instance in use
	this._keyEvent = false; // If the last event was a key event
	this._disabledInputs = []; // List of date picker inputs that have been disabled
	this._datepickerShowing = false; // True if the popup picker is showing , false if not
	this._inDialog = false; // True if showing within a "dialog", false if not
	this._mainDivId = 'ui-datepicker-div'; // The ID of the main datepicker division
	this._inlineClass = 'ui-datepicker-inline'; // The name of the inline marker class
	this._appendClass = 'ui-datepicker-append'; // The name of the append marker class
	this._triggerClass = 'ui-datepicker-trigger'; // The name of the trigger marker class
	this._dialogClass = 'ui-datepicker-dialog'; // The name of the dialog marker class
	this._disableClass = 'ui-datepicker-disabled'; // The name of the disabled covering marker class
	this._unselectableClass = 'ui-datepicker-unselectable'; // The name of the unselectable cell marker class
	this._currentClass = 'ui-datepicker-current-day'; // The name of the current day marker class
	this._dayOverClass = 'ui-datepicker-days-cell-over'; // The name of the day hover marker class
	this.regional = []; // Available regional settings, indexed by language code
	this.regional[''] = { // Default regional settings
		closeText: 'Done', // Display text for close link
		prevText: 'Prev', // Display text for previous month link
		nextText: 'Next', // Display text for next month link
		currentText: 'Today', // Display text for current month link
		monthNames: ['January','February','March','April','May','June',
			'July','August','September','October','November','December'], // Names of months for drop-down and formatting
		monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], // For formatting
		dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], // For formatting
		dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], // For formatting
		dayNamesMin: ['S','M','T','W','T','F','S'], // Column headings for days starting at Sunday
		dateFormat: 'mm/dd/yy', // See format options on parseDate
		firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
		isRTL: false // True if right-to-left language, false if left-to-right
	};
	this._defaults = { // Global defaults for all the date picker instances
		showOn: 'focus', // 'focus' for popup on focus,
			// 'button' for trigger button, or 'both' for either
		showAnim: 'show', // Name of jQuery animation for popup
		showOptions: {}, // Options for enhanced animations
		defaultDate: null, // Used when field is blank: actual date,
			// +/-number for offset from today, null for today
		appendText: '', // Display text following the input box, e.g. showing the format
		buttonText: 'calendar', // Text for trigger button
		buttonImage: '', // URL for trigger button image
		buttonImageOnly: false, // True if the image appears alone, false if it appears on a button
		hideIfNoPrevNext: false, // True to hide next/previous month links
			// if not applicable, false to just disable them
		navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links
		gotoCurrent: false, // True if today link goes back to current selection instead
		changeMonth: false, // True if month can be selected directly, false if only prev/next
		changeYear: false, // True if year can be selected directly, false if only prev/next
		showMonthAfterYear: false, // True if the year select precedes month, false for month then year
		yearRange: '-10:+10', // Range of years to display in drop-down,
			// either relative to current year (-nn:+nn) or absolute (nnnn:nnnn)
		showOtherMonths: false, // True to show dates in other months, false to leave blank
		calculateWeek: this.iso8601Week, // How to calculate the week of the year,
			// takes a Date and returns the number of the week for it
		shortYearCutoff: '+10', // Short year values < this are in the current century,
			// > this are in the previous century,
			// string value starting with '+' for current year + value
		minDate: null, // The earliest selectable date, or null for no limit
		maxDate: null, // The latest selectable date, or null for no limit
		duration: 'normal', // Duration of display/closure
		beforeShowDay: null, // Function that takes a date and returns an array with
			// [0] = true if selectable, false if not, [1] = custom CSS class name(s) or '',
			// [2] = cell title (optional), e.g. $.datepicker.noWeekends
		beforeShow: null, // Function that takes an input field and
			// returns a set of custom settings for the date picker
		onSelect: null, // Define a callback function when a date is selected
		onChangeMonthYear: null, // Define a callback function when the month or year is changed
		onClose: null, // Define a callback function when the datepicker is closed
		numberOfMonths: 1, // Number of months to show at a time
		showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0)
		stepMonths: 1, // Number of months to step back/forward
		stepBigMonths: 12, // Number of months to step back/forward for the big links
		altField: '', // Selector for an alternate field to store selected dates into
		altFormat: '', // The date format to use for the alternate field
		constrainInput: true, // The input is constrained by the current date format
		showButtonPanel: false // True to show button panel, false to not show it
	};
	$.extend(this._defaults, this.regional['']);
	this.dpDiv = $('<div id="' + this._mainDivId + '" class="ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all ui-helper-hidden-accessible"></div>');
}

$.extend(Datepicker.prototype, {
	/* Class name added to elements to indicate already configured with a date picker. */
	markerClassName: 'hasDatepicker',

	/* Debug logging (if enabled). */
	log: function () {
		if (this.debug)
			console.log.apply('', arguments);
	},

	/* Override the default settings for all instances of the date picker.
	   @param  settings  object - the new settings to use as defaults (anonymous object)
	   @return the manager object */
	setDefaults: function(settings) {
		extendRemove(this._defaults, settings || {});
		return this;
	},

	/* Attach the date picker to a jQuery selection.
	   @param  target    element - the target input field or division or span
	   @param  settings  object - the new settings to use for this date picker instance (anonymous) */
	_attachDatepicker: function(target, settings) {
		// check for settings on the control itself - in namespace 'date:'
		var inlineSettings = null;
		for (var attrName in this._defaults) {
			var attrValue = target.getAttribute('date:' + attrName);
			if (attrValue) {
				inlineSettings = inlineSettings || {};
				try {
					inlineSettings[attrName] = eval(attrValue);
				} catch (err) {
					inlineSettings[attrName] = attrValue;
				}
			}
		}
		var nodeName = target.nodeName.toLowerCase();
		var inline = (nodeName == 'div' || nodeName == 'span');
		if (!target.id)
			target.id = 'dp' + (++this.uuid);
		var inst = this._newInst($(target), inline);
		inst.settings = $.extend({}, settings || {}, inlineSettings || {});
		if (nodeName == 'input') {
			this._connectDatepicker(target, inst);
		} else if (inline) {
			this._inlineDatepicker(target, inst);
		}
	},

	/* Create a new instance object. */
	_newInst: function(target, inline) {
		var id = target[0].id.replace(/([:\[\]\.])/g, '\\\\$1'); // escape jQuery meta chars
		return {id: id, input: target, // associated target
			selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection
			drawMonth: 0, drawYear: 0, // month being drawn
			inline: inline, // is datepicker inline or not
			dpDiv: (!inline ? this.dpDiv : // presentation div
			$('<div class="' + this._inlineClass + ' ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>'))};
	},

	/* Attach the date picker to an input field. */
	_connectDatepicker: function(target, inst) {
		var input = $(target);
		inst.append = $([]);
		inst.trigger = $([]);
		if (input.hasClass(this.markerClassName))
			return;
		var appendText = this._get(inst, 'appendText');
		var isRTL = this._get(inst, 'isRTL');
		if (appendText) {
			inst.append = $('<span class="' + this._appendClass + '">' + appendText + '</span>');
			input[isRTL ? 'before' : 'after'](inst.append);
		}
		var showOn = this._get(inst, 'showOn');
		if (showOn == 'focus' || showOn == 'both') // pop-up date picker when in the marked field
			input.focus(this._showDatepicker);
		if (showOn == 'button' || showOn == 'both') { // pop-up date picker when button clicked
			var buttonText = this._get(inst, 'buttonText');
			var buttonImage = this._get(inst, 'buttonImage');
			inst.trigger = $(this._get(inst, 'buttonImageOnly') ?
				$('<img/>').addClass(this._triggerClass).
					attr({ src: buttonImage, alt: buttonText, title: buttonText }) :
				$('<button type="button"></button>').addClass(this._triggerClass).
					html(buttonImage == '' ? buttonText : $('<img/>').attr(
					{ src:buttonImage, alt:buttonText, title:buttonText })));
			input[isRTL ? 'before' : 'after'](inst.trigger);
			inst.trigger.click(function() {
				if ($.datepicker._datepickerShowing && $.datepicker._lastInput == target)
					$.datepicker._hideDatepicker();
				else
					$.datepicker._showDatepicker(target);
				return false;
			});
		}
		input.addClass(this.markerClassName).keydown(this._doKeyDown).keypress(this._doKeyPress).
			bind("setData.datepicker", function(event, key, value) {
				inst.settings[key] = value;
			}).bind("getData.datepicker", function(event, key) {
				return this._get(inst, key);
			});
		$.data(target, PROP_NAME, inst);
	},

	/* Attach an inline date picker to a div. */
	_inlineDatepicker: function(target, inst) {
		var divSpan = $(target);
		if (divSpan.hasClass(this.markerClassName))
			return;
		divSpan.addClass(this.markerClassName).append(inst.dpDiv).
			bind("setData.datepicker", function(event, key, value){
				inst.settings[key] = value;
			}).bind("getData.datepicker", function(event, key){
				return this._get(inst, key);
			});
		$.data(target, PROP_NAME, inst);
		this._setDate(inst, this._getDefaultDate(inst));
		this._updateDatepicker(inst);
		this._updateAlternate(inst);
	},

	/* Pop-up the date picker in a "dialog" box.
	   @param  input     element - ignored
	   @param  dateText  string - the initial date to display (in the current format)
	   @param  onSelect  function - the function(dateText) to call when a date is selected
	   @param  settings  object - update the dialog date picker instance's settings (anonymous object)
	   @param  pos       int[2] - coordinates for the dialog's position within the screen or
	                     event - with x/y coordinates or
	                     leave empty for default (screen centre)
	   @return the manager object */
	_dialogDatepicker: function(input, dateText, onSelect, settings, pos) {
		var inst = this._dialogInst; // internal instance
		if (!inst) {
			var id = 'dp' + (++this.uuid);
			this._dialogInput = $('<input type="text" id="' + id +
				'" size="1" style="position: absolute; top: -100px;"/>');
			this._dialogInput.keydown(this._doKeyDown);
			$('body').append(this._dialogInput);
			inst = this._dialogInst = this._newInst(this._dialogInput, false);
			inst.settings = {};
			$.data(this._dialogInput[0], PROP_NAME, inst);
		}
		extendRemove(inst.settings, settings || {});
		this._dialogInput.val(dateText);

		this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null);
		if (!this._pos) {
			var browserWidth = window.innerWidth || document.documentElement.clientWidth ||	document.body.clientWidth;
			var browserHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
			var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
			var scrollY = document.documentElement.scrollTop || document.body.scrollTop;
			this._pos = // should use actual width/height below
				[(browserWidth / 2) - 100 + scrollX, (browserHeight / 2) - 150 + scrollY];
		}

		// move input on screen for focus, but hidden behind dialog
		this._dialogInput.css('left', this._pos[0] + 'px').css('top', this._pos[1] + 'px');
		inst.settings.onSelect = onSelect;
		this._inDialog = true;
		this.dpDiv.addClass(this._dialogClass);
		this._showDatepicker(this._dialogInput[0]);
		if ($.blockUI)
			$.blockUI(this.dpDiv);
		$.data(this._dialogInput[0], PROP_NAME, inst);
		return this;
	},

	/* Detach a datepicker from its control.
	   @param  target    element - the target input field or division or span */
	_destroyDatepicker: function(target) {
		var $target = $(target);
		var inst = $.data(target, PROP_NAME);
		if (!$target.hasClass(this.markerClassName)) {
			return;
		}
		var nodeName = target.nodeName.toLowerCase();
		$.removeData(target, PROP_NAME);
		if (nodeName == 'input') {
			inst.append.remove();
			inst.trigger.remove();
			$target.removeClass(this.markerClassName).
				unbind('focus', this._showDatepicker).
				unbind('keydown', this._doKeyDown).
				unbind('keypress', this._doKeyPress);
		} else if (nodeName == 'div' || nodeName == 'span')
			$target.removeClass(this.markerClassName).empty();
	},

	/* Enable the date picker to a jQuery selection.
	   @param  target    element - the target input field or division or span */
	_enableDatepicker: function(target) {
		var $target = $(target);
		var inst = $.data(target, PROP_NAME);
		if (!$target.hasClass(this.markerClassName)) {
			return;
		}
		var nodeName = target.nodeName.toLowerCase();
		if (nodeName == 'input') {
			target.disabled = false;
			inst.trigger.filter('button').
				each(function() { this.disabled = false; }).end().
				filter('img').css({opacity: '1.0', cursor: ''});
		}
		else if (nodeName == 'div' || nodeName == 'span') {
			var inline = $target.children('.' + this._inlineClass);
			inline.children().removeClass('ui-state-disabled');
		}
		this._disabledInputs = $.map(this._disabledInputs,
			function(value) { return (value == target ? null : value); }); // delete entry
	},

	/* Disable the date picker to a jQuery selection.
	   @param  target    element - the target input field or division or span */
	_disableDatepicker: function(target) {
		var $target = $(target);
		var inst = $.data(target, PROP_NAME);
		if (!$target.hasClass(this.markerClassName)) {
			return;
		}
		var nodeName = target.nodeName.toLowerCase();
		if (nodeName == 'input') {
			target.disabled = true;
			inst.trigger.filter('button').
				each(function() { this.disabled = true; }).end().
				filter('img').css({opacity: '0.5', cursor: 'default'});
		}
		else if (nodeName == 'div' || nodeName == 'span') {
			var inline = $target.children('.' + this._inlineClass);
			inline.children().addClass('ui-state-disabled');
		}
		this._disabledInputs = $.map(this._disabledInputs,
			function(value) { return (value == target ? null : value); }); // delete entry
		this._disabledInputs[this._disabledInputs.length] = target;
	},

	/* Is the first field in a jQuery collection disabled as a datepicker?
	   @param  target    element - the target input field or division or span
	   @return boolean - true if disabled, false if enabled */
	_isDisabledDatepicker: function(target) {
		if (!target) {
			return false;
		}
		for (var i = 0; i < this._disabledInputs.length; i++) {
			if (this._disabledInputs[i] == target)
				return true;
		}
		return false;
	},

	/* Retrieve the instance data for the target control.
	   @param  target  element - the target input field or division or span
	   @return  object - the associated instance data
	   @throws  error if a jQuery problem getting data */
	_getInst: function(target) {
		try {
			return $.data(target, PROP_NAME);
		}
		catch (err) {
			throw 'Missing instance data for this datepicker';
		}
	},

	/* Update or retrieve the settings for a date picker attached to an input field or division.
	   @param  target  element - the target input field or division or span
	   @param  name    object - the new settings to update or
	                   string - the name of the setting to change or retrieve,
	                   when retrieving also 'all' for all instance settings or
	                   'defaults' for all global defaults
	   @param  value   any - the new value for the setting
	                   (omit if above is an object or to retrieve a value) */
	_optionDatepicker: function(target, name, value) {
		var inst = this._getInst(target);
		if (arguments.length == 2 && typeof name == 'string') {
			return (name == 'defaults' ? $.extend({}, $.datepicker._defaults) :
				(inst ? (name == 'all' ? $.extend({}, inst.settings) :
				this._get(inst, name)) : null));
		}
		var settings = name || {};
		if (typeof name == 'string') {
			settings = {};
			settings[name] = value;
		}
		if (inst) {
			if (this._curInst == inst) {
				this._hideDatepicker(null);
			}
			var date = this._getDateDatepicker(target);
			extendRemove(inst.settings, settings);
			this._setDateDatepicker(target, date);
			this._updateDatepicker(inst);
		}
	},

	// change method deprecated
	_changeDatepicker: function(target, name, value) {
		this._optionDatepicker(target, name, value);
	},

	/* Redraw the date picker attached to an input field or division.
	   @param  target  element - the target input field or division or span */
	_refreshDatepicker: function(target) {
		var inst = this._getInst(target);
		if (inst) {
			this._updateDatepicker(inst);
		}
	},

	/* Set the dates for a jQuery selection.
	   @param  target   element - the target input field or division or span
	   @param  date     Date - the new date
	   @param  endDate  Date - the new end date for a range (optional) */
	_setDateDatepicker: function(target, date, endDate) {
		var inst = this._getInst(target);
		if (inst) {
			this._setDate(inst, date, endDate);
			this._updateDatepicker(inst);
			this._updateAlternate(inst);
		}
	},

	/* Get the date(s) for the first entry in a jQuery selection.
	   @param  target  element - the target input field or division or span
	   @return Date - the current date or
	           Date[2] - the current dates for a range */
	_getDateDatepicker: function(target) {
		var inst = this._getInst(target);
		if (inst && !inst.inline)
			this._setDateFromField(inst);
		return (inst ? this._getDate(inst) : null);
	},

	/* Handle keystrokes. */
	_doKeyDown: function(event) {
		var inst = $.datepicker._getInst(event.target);
		var handled = true;
		var isRTL = inst.dpDiv.is('.ui-datepicker-rtl');
		inst._keyEvent = true;
		if ($.datepicker._datepickerShowing)
			switch (event.keyCode) {
				case 9:  $.datepicker._hideDatepicker(null, '');
						break; // hide on tab out
				case 13: var sel = $('td.' + $.datepicker._dayOverClass +
							', td.' + $.datepicker._currentClass, inst.dpDiv);
						if (sel[0])
							$.datepicker._selectDay(event.target, inst.selectedMonth, inst.selectedYear, sel[0]);
						else
							$.datepicker._hideDatepicker(null, $.datepicker._get(inst, 'duration'));
						return false; // don't submit the form
						break; // select the value on enter
				case 27: $.datepicker._hideDatepicker(null, $.datepicker._get(inst, 'duration'));
						break; // hide on escape
				case 33: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
							-$.datepicker._get(inst, 'stepBigMonths') :
							-$.datepicker._get(inst, 'stepMonths')), 'M');
						break; // previous month/year on page up/+ ctrl
				case 34: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
							+$.datepicker._get(inst, 'stepBigMonths') :
							+$.datepicker._get(inst, 'stepMonths')), 'M');
						break; // next month/year on page down/+ ctrl
				case 35: if (event.ctrlKey || event.metaKey) $.datepicker._clearDate(event.target);
						handled = event.ctrlKey || event.metaKey;
						break; // clear on ctrl or command +end
				case 36: if (event.ctrlKey || event.metaKey) $.datepicker._gotoToday(event.target);
						handled = event.ctrlKey || event.metaKey;
						break; // current on ctrl or command +home
				case 37: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, (isRTL ? +1 : -1), 'D');
						handled = event.ctrlKey || event.metaKey;
						// -1 day on ctrl or command +left
						if (event.originalEvent.altKey) $.datepicker._adjustDate(event.target, (event.ctrlKey ?
									-$.datepicker._get(inst, 'stepBigMonths') :
									-$.datepicker._get(inst, 'stepMonths')), 'M');
						// next month/year on alt +left on Mac
						break;
				case 38: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, -7, 'D');
						handled = event.ctrlKey || event.metaKey;
						break; // -1 week on ctrl or command +up
				case 39: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, (isRTL ? -1 : +1), 'D');
						handled = event.ctrlKey || event.metaKey;
						// +1 day on ctrl or command +right
						if (event.originalEvent.altKey) $.datepicker._adjustDate(event.target, (event.ctrlKey ?
									+$.datepicker._get(inst, 'stepBigMonths') :
									+$.datepicker._get(inst, 'stepMonths')), 'M');
						// next month/year on alt +right
						break;
				case 40: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, +7, 'D');
						handled = event.ctrlKey || event.metaKey;
						break; // +1 week on ctrl or command +down
				default: handled = false;
			}
		else if (event.keyCode == 36 && event.ctrlKey) // display the date picker on ctrl+home
			$.datepicker._showDatepicker(this);
		else {
			handled = false;
		}
		if (handled) {
			event.preventDefault();
			event.stopPropagation();
		}
	},

	/* Filter entered characters - based on date format. */
	_doKeyPress: function(event) {
		var inst = $.datepicker._getInst(event.target);
		if ($.datepicker._get(inst, 'constrainInput')) {
			var chars = $.datepicker._possibleChars($.datepicker._get(inst, 'dateFormat'));
			var chr = String.fromCharCode(event.charCode == undefined ? event.keyCode : event.charCode);
			return event.ctrlKey || (chr < ' ' || !chars || chars.indexOf(chr) > -1);
		}
	},

	/* Pop-up the date picker for a given input field.
	   @param  input  element - the input field attached to the date picker or
	                  event - if triggered by focus */
	_showDatepicker: function(input) {
		input = input.target || input;
		if (input.nodeName.toLowerCase() != 'input') // find from button/image trigger
			input = $('input', input.parentNode)[0];
		if ($.datepicker._isDisabledDatepicker(input) || $.datepicker._lastInput == input) // already here
			return;
		var inst = $.datepicker._getInst(input);
		var beforeShow = $.datepicker._get(inst, 'beforeShow');
		extendRemove(inst.settings, (beforeShow ? beforeShow.apply(input, [input, inst]) : {}));
		$.datepicker._hideDatepicker(null, '');
		$.datepicker._lastInput = input;
		$.datepicker._setDateFromField(inst);
		if ($.datepicker._inDialog) // hide cursor
			input.value = '';
		if (!$.datepicker._pos) { // position below input
			$.datepicker._pos = $.datepicker._findPos(input);
			$.datepicker._pos[1] += input.offsetHeight; // add the height
		}
		var isFixed = false;
		$(input).parents().each(function() {
			isFixed |= $(this).css('position') == 'fixed';
			return !isFixed;
		});
		if (isFixed && $.browser.opera) { // correction for Opera when fixed and scrolled
			$.datepicker._pos[0] -= document.documentElement.scrollLeft;
			$.datepicker._pos[1] -= document.documentElement.scrollTop;
		}
		var offset = {left: $.datepicker._pos[0], top: $.datepicker._pos[1]};
		$.datepicker._pos = null;
		inst.rangeStart = null;
		// determine sizing offscreen
		inst.dpDiv.css({position: 'absolute', display: 'block', top: '-1000px'});
		$.datepicker._updateDatepicker(inst);
		// fix width for dynamic number of date pickers
		// and adjust position before showing
		offset = $.datepicker._checkOffset(inst, offset, isFixed);
		inst.dpDiv.css({position: ($.datepicker._inDialog && $.blockUI ?
			'static' : (isFixed ? 'fixed' : 'absolute')), display: 'none',
			left: offset.left + 'px', top: offset.top + 'px'});
		if (!inst.inline) {
			var showAnim = $.datepicker._get(inst, 'showAnim') || 'show';
			var duration = $.datepicker._get(inst, 'duration');
			var postProcess = function() {
				$.datepicker._datepickerShowing = true;
				if ($.browser.msie && parseInt($.browser.version,10) < 7) // fix IE < 7 select problems
					$('iframe.ui-datepicker-cover').css({width: inst.dpDiv.width() + 4,
						height: inst.dpDiv.height() + 4});
			};
			if ($.effects && $.effects[showAnim])
				inst.dpDiv.show(showAnim, $.datepicker._get(inst, 'showOptions'), duration, postProcess);
			else
				inst.dpDiv[showAnim](duration, postProcess);
			if (duration == '')
				postProcess();
			if (inst.input[0].type != 'hidden')
				inst.input[0].focus();
			$.datepicker._curInst = inst;
		}
	},

	/* Generate the date picker content. */
	_updateDatepicker: function(inst) {
		var dims = {width: inst.dpDiv.width() + 4,
			height: inst.dpDiv.height() + 4};
		var self = this;
		inst.dpDiv.empty().append(this._generateHTML(inst))
			.find('iframe.ui-datepicker-cover').
				css({width: dims.width, height: dims.height})
			.end()
			.find('button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a')
				.bind('mouseout', function(){
					$(this).removeClass('ui-state-hover');
					if(this.className.indexOf('ui-datepicker-prev') != -1) $(this).removeClass('ui-datepicker-prev-hover');
					if(this.className.indexOf('ui-datepicker-next') != -1) $(this).removeClass('ui-datepicker-next-hover');
				})
				.bind('mouseover', function(){
					if (!self._isDisabledDatepicker( inst.inline ? inst.dpDiv.parent()[0] : inst.input[0])) {
						$(this).parents('.ui-datepicker-calendar').find('a').removeClass('ui-state-hover');
						$(this).addClass('ui-state-hover');
						if(this.className.indexOf('ui-datepicker-prev') != -1)
						{
						 $(this).addClass('ui-datepicker-prev-hover');
						 $(this).removeClass('ui-state-hover');
						}
						if(this.className.indexOf('ui-datepicker-next') != -1)
						{
							$(this).addClass('ui-datepicker-next-hover'); 
							$(this).removeClass('ui-state-hover');
						}
					}
				})
			.end()
			.find('.' + this._dayOverClass + ' a')
				.trigger('mouseover')
			.end();
		var numMonths = this._getNumberOfMonths(inst);
		var cols = numMonths[1];
		var width = 17;
		if (cols > 1) {
			inst.dpDiv.addClass('ui-datepicker-multi-' + cols).css('width', (29) + 'em');
		} else {
			inst.dpDiv.removeClass('ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4').width('');
		}
		inst.dpDiv[(numMonths[0] != 1 || numMonths[1] != 1 ? 'add' : 'remove') +
			'Class']('ui-datepicker-multi');
		inst.dpDiv[(this._get(inst, 'isRTL') ? 'add' : 'remove') +
			'Class']('ui-datepicker-rtl');
		if (inst.input && inst.input[0].type != 'hidden' && inst == $.datepicker._curInst)
			$(inst.input[0]).focus();
	},

	/* Check positioning to remain on screen. */
	_checkOffset: function(inst, offset, isFixed) {
		var dpWidth = inst.dpDiv.outerWidth();
		var dpHeight = inst.dpDiv.outerHeight();
		var inputWidth = inst.input ? inst.input.outerWidth() : 0;
		var inputHeight = inst.input ? inst.input.outerHeight() : 0;
		var viewWidth = (window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth) + $(document).scrollLeft();
		var viewHeight = (window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight) + $(document).scrollTop();

		offset.left -= (this._get(inst, 'isRTL') ? (dpWidth - inputWidth) : 0);
		offset.left -= (isFixed && offset.left == inst.input.offset().left) ? $(document).scrollLeft() : 0;
		offset.top -= (isFixed && offset.top == (inst.input.offset().top + inputHeight)) ? $(document).scrollTop() : 0;

		// now check if datepicker is showing outside window viewport - move to a better place if so.
		offset.left -= (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ? Math.abs(offset.left + dpWidth - viewWidth) : 0;
		offset.top -= (offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ? Math.abs(offset.top + dpHeight + inputHeight*2 - viewHeight) : 0;

		return offset;
	},

	/* Find an object's position on the screen. */
	_findPos: function(obj) {
        while (obj && (obj.type == 'hidden' || obj.nodeType != 1)) {
            obj = obj.nextSibling;
        }
        var position = $(obj).offset();
	    return [position.left, position.top];
	},

	/* Hide the date picker from view.
	   @param  input  element - the input field attached to the date picker
	   @param  duration  string - the duration over which to close the date picker */
	_hideDatepicker: function(input, duration) {
		var inst = this._curInst;
		if (!inst || (input && inst != $.data(input, PROP_NAME)))
			return;
		if (inst.stayOpen)
			this._selectDate('#' + inst.id, this._formatDate(inst,
				inst.currentDay, inst.currentMonth, inst.currentYear));
		inst.stayOpen = false;
		if (this._datepickerShowing) {
			duration = (duration != null ? duration : this._get(inst, 'duration'));
			var showAnim = this._get(inst, 'showAnim');
			var postProcess = function() {
				$.datepicker._tidyDialog(inst);
			};
			if (duration != '' && $.effects && $.effects[showAnim])
				inst.dpDiv.hide(showAnim, $.datepicker._get(inst, 'showOptions'),
					duration, postProcess);
			else
				inst.dpDiv[(duration == '' ? 'hide' : (showAnim == 'slideDown' ? 'slideUp' :
					(showAnim == 'fadeIn' ? 'fadeOut' : 'hide')))](duration, postProcess);
			if (duration == '')
				this._tidyDialog(inst);
			var onClose = this._get(inst, 'onClose');
			if (onClose)
				onClose.apply((inst.input ? inst.input[0] : null),
					[(inst.input ? inst.input.val() : ''), inst]);  // trigger custom callback
			this._datepickerShowing = false;
			this._lastInput = null;
			if (this._inDialog) {
				this._dialogInput.css({ position: 'absolute', left: '0', top: '-100px' });
				if ($.blockUI) {
					$.unblockUI();
					$('body').append(this.dpDiv);
				}
			}
			this._inDialog = false;
		}
		this._curInst = null;
	},

	/* Tidy up after a dialog display. */
	_tidyDialog: function(inst) {
		inst.dpDiv.removeClass(this._dialogClass).unbind('.ui-datepicker-calendar');
	},

	/* Close date picker if clicked elsewhere. */
	_checkExternalClick: function(event) {
		if (!$.datepicker._curInst)
			return;
		var $target = $(event.target);
		if (($target.parents('#' + $.datepicker._mainDivId).length == 0) &&
				!$target.hasClass($.datepicker.markerClassName) &&
				!$target.hasClass($.datepicker._triggerClass) &&
				$.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI))
			$.datepicker._hideDatepicker(null, '');
	},

	/* Adjust one of the date sub-fields. */
	_adjustDate: function(id, offset, period) {
		var target = $(id);
		var inst = this._getInst(target[0]);
		if (this._isDisabledDatepicker(target[0])) {
			return;
		}
		this._adjustInstDate(inst, offset +
			(period == 'M' ? this._get(inst, 'showCurrentAtPos') : 0), // undo positioning
			period);
		this._updateDatepicker(inst);
	},

	/* Action for current link. */
	_gotoToday: function(id) {
		var target = $(id);
		var inst = this._getInst(target[0]);
		if (this._get(inst, 'gotoCurrent') && inst.currentDay) {
			inst.selectedDay = inst.currentDay;
			inst.drawMonth = inst.selectedMonth = inst.currentMonth;
			inst.drawYear = inst.selectedYear = inst.currentYear;
		}
		else {
		var date = new Date();
		inst.selectedDay = date.getDate();
		inst.drawMonth = inst.selectedMonth = date.getMonth();
		inst.drawYear = inst.selectedYear = date.getFullYear();
		}
		this._notifyChange(inst);
		this._adjustDate(target);
	},

	/* Action for selecting a new month/year. */
	_selectMonthYear: function(id, select, period) {
		var target = $(id);
		var inst = this._getInst(target[0]);
		inst._selectingMonthYear = false;
		inst['selected' + (period == 'M' ? 'Month' : 'Year')] =
		inst['draw' + (period == 'M' ? 'Month' : 'Year')] =
			parseInt(select.options[select.selectedIndex].value,10);
		this._notifyChange(inst);
		this._adjustDate(target);
	},

	/* Restore input focus after not changing month/year. */
	_clickMonthYear: function(id) {
		var target = $(id);
		var inst = this._getInst(target[0]);
		if (inst.input && inst._selectingMonthYear && !$.browser.msie)
			inst.input[0].focus();
		inst._selectingMonthYear = !inst._selectingMonthYear;
	},

	/* Action for selecting a day. */
	_selectDay: function(id, month, year, td) {
		var target = $(id);
		if ($(td).hasClass(this._unselectableClass) || this._isDisabledDatepicker(target[0])) {
			return;
		}
		var inst = this._getInst(target[0]);
		inst.selectedDay = inst.currentDay = $('a', td).html();
		inst.selectedMonth = inst.currentMonth = month;
		inst.selectedYear = inst.currentYear = year;
		if (inst.stayOpen) {
			inst.endDay = inst.endMonth = inst.endYear = null;
		}
		this._selectDate(id, this._formatDate(inst,
			inst.currentDay, inst.currentMonth, inst.currentYear));
		if (inst.stayOpen) {
			inst.rangeStart = this._daylightSavingAdjust(
				new Date(inst.currentYear, inst.currentMonth, inst.currentDay));
			this._updateDatepicker(inst);
		}
	},

	/* Erase the input field and hide the date picker. */
	_clearDate: function(id) {
		var target = $(id);
		var inst = this._getInst(target[0]);
		inst.stayOpen = false;
		inst.endDay = inst.endMonth = inst.endYear = inst.rangeStart = null;
		this._selectDate(target, '');
	},

	/* Update the input field with the selected date. */
	_selectDate: function(id, dateStr) {
		var target = $(id);
		var inst = this._getInst(target[0]);
		dateStr = (dateStr != null ? dateStr : this._formatDate(inst));
		if (inst.input)
			inst.input.val(dateStr);
		this._updateAlternate(inst);
		var onSelect = this._get(inst, 'onSelect');
		if (onSelect)
			onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]);  // trigger custom callback
		else if (inst.input)
			inst.input.trigger('change'); // fire the change event
		if (inst.inline)
			this._updateDatepicker(inst);
		else if (!inst.stayOpen) {
			this._hideDatepicker(null, this._get(inst, 'duration'));
			this._lastInput = inst.input[0];
			if (typeof(inst.input[0]) != 'object')
				inst.input[0].focus(); // restore focus
			this._lastInput = null;
		}
	},

	/* Update any alternate field to synchronise with the main field. */
	_updateAlternate: function(inst) {
		var altField = this._get(inst, 'altField');
		if (altField) { // update alternate field too
			var altFormat = this._get(inst, 'altFormat') || this._get(inst, 'dateFormat');
			var date = this._getDate(inst);
			dateStr = this.formatDate(altFormat, date, this._getFormatConfig(inst));
			$(altField).each(function() { $(this).val(dateStr); });
		}
	},

	/* Set as beforeShowDay function to prevent selection of weekends.
	   @param  date  Date - the date to customise
	   @return [boolean, string] - is this date selectable?, what is its CSS class? */
	noWeekends: function(date) {
		var day = date.getDay();
		return [(day > 0 && day < 6), ''];
	},

	/* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
	   @param  date  Date - the date to get the week for
	   @return  number - the number of the week within the year that contains this date */
	iso8601Week: function(date) {
		var checkDate = new Date(date.getFullYear(), date.getMonth(), date.getDate());
		var firstMon = new Date(checkDate.getFullYear(), 1 - 1, 4); // First week always contains 4 Jan
		var firstDay = firstMon.getDay() || 7; // Day of week: Mon = 1, ..., Sun = 7
		firstMon.setDate(firstMon.getDate() + 1 - firstDay); // Preceding Monday
		if (firstDay < 4 && checkDate < firstMon) { // Adjust first three days in year if necessary
			checkDate.setDate(checkDate.getDate() - 3); // Generate for previous year
			return $.datepicker.iso8601Week(checkDate);
		} else if (checkDate > new Date(checkDate.getFullYear(), 12 - 1, 28)) { // Check last three days in year
			firstDay = new Date(checkDate.getFullYear() + 1, 1 - 1, 4).getDay() || 7;
			if (firstDay > 4 && (checkDate.getDay() || 7) < firstDay - 3) { // Adjust if necessary
				return 1;
			}
		}
		return Math.floor(((checkDate - firstMon) / 86400000) / 7) + 1; // Weeks to given date
	},

	/* Parse a string value into a date object.
	   See formatDate below for the possible formats.

	   @param  format    string - the expected format of the date
	   @param  value     string - the date in the above format
	   @param  settings  Object - attributes include:
	                     shortYearCutoff  number - the cutoff year for determining the century (optional)
	                     dayNamesShort    string[7] - abbreviated names of the days from Sunday (optional)
	                     dayNames         string[7] - names of the days from Sunday (optional)
	                     monthNamesShort  string[12] - abbreviated names of the months (optional)
	                     monthNames       string[12] - names of the months (optional)
	   @return  Date - the extracted date value or null if value is blank */
	parseDate: function (format, value, settings) {
		if (format == null || value == null)
			throw 'Invalid arguments';
		value = (typeof value == 'object' ? value.toString() : value + '');
		if (value == '')
			return null;
		var shortYearCutoff = (settings ? settings.shortYearCutoff : null) || this._defaults.shortYearCutoff;
		var dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort;
		var dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames;
		var monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort;
		var monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames;
		var year = -1;
		var month = -1;
		var day = -1;
		var doy = -1;
		var literal = false;
		// Check whether a format character is doubled
		var lookAhead = function(match) {
			var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match);
			if (matches)
				iFormat++;
			return matches;
		};
		// Extract a number from the string value
		var getNumber = function(match) {
			lookAhead(match);
			var origSize = (match == '@' ? 14 : (match == 'y' ? 4 : (match == 'o' ? 3 : 2)));
			var size = origSize;
			var num = 0;
			while (size > 0 && iValue < value.length &&
					value.charAt(iValue) >= '0' && value.charAt(iValue) <= '9') {
				num = num * 10 + parseInt(value.charAt(iValue++),10);
				size--;
			}
			if (size == origSize)
				throw 'Missing number at position ' + iValue;
			return num;
		};
		// Extract a name from the string value and convert to an index
		var getName = function(match, shortNames, longNames) {
			var names = (lookAhead(match) ? longNames : shortNames);
			var size = 0;
			for (var j = 0; j < names.length; j++)
				size = Math.max(size, names[j].length);
			var name = '';
			var iInit = iValue;
			while (size > 0 && iValue < value.length) {
				name += value.charAt(iValue++);
				for (var i = 0; i < names.length; i++)
					if (name == names[i])
						return i + 1;
				size--;
			}
			throw 'Unknown name at position ' + iInit;
		};
		// Confirm that a literal character matches the string value
		var checkLiteral = function() {
			if (value.charAt(iValue) != format.charAt(iFormat))
				throw 'Unexpected literal at position ' + iValue;
			iValue++;
		};
		var iValue = 0;
		for (var iFormat = 0; iFormat < format.length; iFormat++) {
			if (literal)
				if (format.charAt(iFormat) == "'" && !lookAhead("'"))
					literal = false;
				else
					checkLiteral();
			else
				switch (format.charAt(iFormat)) {
					case 'd':
						day = getNumber('d');
						break;
					case 'D':
						getName('D', dayNamesShort, dayNames);
						break;
					case 'o':
						doy = getNumber('o');
						break;
					case 'm':
						month = getNumber('m');
						break;
					case 'M':
						month = getName('M', monthNamesShort, monthNames);
						break;
					case 'y':
						year = getNumber('y');
						break;
					case '@':
						var date = new Date(getNumber('@'));
						year = date.getFullYear();
						month = date.getMonth() + 1;
						day = date.getDate();
						break;
					case "'":
						if (lookAhead("'"))
							checkLiteral();
						else
							literal = true;
						break;
					default:
						checkLiteral();
				}
		}
		if (year == -1)
			year = new Date().getFullYear();
		else if (year < 100)
			year += new Date().getFullYear() - new Date().getFullYear() % 100 +
				(year <= shortYearCutoff ? 0 : -100);
		if (doy > -1) {
			month = 1;
			day = doy;
			do {
				var dim = this._getDaysInMonth(year, month - 1);
				if (day <= dim)
					break;
				month++;
				day -= dim;
			} while (true);
		}
		var date = this._daylightSavingAdjust(new Date(year, month - 1, day));
		if (date.getFullYear() != year || date.getMonth() + 1 != month || date.getDate() != day)
			throw 'Invalid date'; // E.g. 31/02/*
		return date;
	},

	/* Standard date formats. */
	ATOM: 'yy-mm-dd', // RFC 3339 (ISO 8601)
	COOKIE: 'D, dd M yy',
	ISO_8601: 'yy-mm-dd',
	RFC_822: 'D, d M y',
	RFC_850: 'DD, dd-M-y',
	RFC_1036: 'D, d M y',
	RFC_1123: 'D, d M yy',
	RFC_2822: 'D, d M yy',
	RSS: 'D, d M y', // RFC 822
	TIMESTAMP: '@',
	W3C: 'yy-mm-dd', // ISO 8601

	/* Format a date object into a string value.
	   The format can be combinations of the following:
	   d  - day of month (no leading zero)
	   dd - day of month (two digit)
	   o  - day of year (no leading zeros)
	   oo - day of year (three digit)
	   D  - day name short
	   DD - day name long
	   m  - month of year (no leading zero)
	   mm - month of year (two digit)
	   M  - month name short
	   MM - month name long
	   y  - year (two digit)
	   yy - year (four digit)
	   @ - Unix timestamp (ms since 01/01/1970)
	   '...' - literal text
	   '' - single quote

	   @param  format    string - the desired format of the date
	   @param  date      Date - the date value to format
	   @param  settings  Object - attributes include:
	                     dayNamesShort    string[7] - abbreviated names of the days from Sunday (optional)
	                     dayNames         string[7] - names of the days from Sunday (optional)
	                     monthNamesShort  string[12] - abbreviated names of the months (optional)
	                     monthNames       string[12] - names of the months (optional)
	   @return  string - the date in the above format */
	formatDate: function (format, date, settings) {
		if (!date)
			return '';
		var dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort;
		var dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames;
		var monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort;
		var monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames;
		// Check whether a format character is doubled
		var lookAhead = function(match) {
			var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match);
			if (matches)
				iFormat++;
			return matches;
		};
		// Format a number, with leading zero if necessary
		var formatNumber = function(match, value, len) {
			var num = '' + value;
			if (lookAhead(match))
				while (num.length < len)
					num = '0' + num;
			return num;
		};
		// Format a name, short or long as requested
		var formatName = function(match, value, shortNames, longNames) {
			return (lookAhead(match) ? longNames[value] : shortNames[value]);
		};
		var output = '';
		var literal = false;
		if (date)
			for (var iFormat = 0; iFormat < format.length; iFormat++) {
				if (literal)
					if (format.charAt(iFormat) == "'" && !lookAhead("'"))
						literal = false;
					else
						output += format.charAt(iFormat);
				else
					switch (format.charAt(iFormat)) {
						case 'd':
							output += formatNumber('d', date.getDate(), 2);
							break;
						case 'D':
							output += formatName('D', date.getDay(), dayNamesShort, dayNames);
							break;
						case 'o':
							var doy = date.getDate();
							for (var m = date.getMonth() - 1; m >= 0; m--)
								doy += this._getDaysInMonth(date.getFullYear(), m);
							output += formatNumber('o', doy, 3);
							break;
						case 'm':
							output += formatNumber('m', date.getMonth() + 1, 2);
							break;
						case 'M':
							output += formatName('M', date.getMonth(), monthNamesShort, monthNames);
							break;
						case 'y':
							output += (lookAhead('y') ? date.getFullYear() :
								(date.getYear() % 100 < 10 ? '0' : '') + date.getYear() % 100);
							break;
						case '@':
							output += date.getTime();
							break;
						case "'":
							if (lookAhead("'"))
								output += "'";
							else
								literal = true;
							break;
						default:
							output += format.charAt(iFormat);
					}
			}
		return output;
	},

	/* Extract all possible characters from the date format. */
	_possibleChars: function (format) {
		var chars = '';
		var literal = false;
		for (var iFormat = 0; iFormat < format.length; iFormat++)
			if (literal)
				if (format.charAt(iFormat) == "'" && !lookAhead("'"))
					literal = false;
				else
					chars += format.charAt(iFormat);
			else
				switch (format.charAt(iFormat)) {
					case 'd': case 'm': case 'y': case '@':
						chars += '0123456789';
						break;
					case 'D': case 'M':
						return null; // Accept anything
					case "'":
						if (lookAhead("'"))
							chars += "'";
						else
							literal = true;
						break;
					default:
						chars += format.charAt(iFormat);
				}
		return chars;
	},

	/* Get a setting value, defaulting if necessary. */
	_get: function(inst, name) {
		return inst.settings[name] !== undefined ?
			inst.settings[name] : this._defaults[name];
	},

	/* Parse existing date and initialise date picker. */
	_setDateFromField: function(inst) {
		var dateFormat = this._get(inst, 'dateFormat');
		var dates = inst.input ? inst.input.val() : null;
		inst.endDay = inst.endMonth = inst.endYear = null;
		var date = defaultDate = this._getDefaultDate(inst);
		var settings = this._getFormatConfig(inst);
		try {
			date = this.parseDate(dateFormat, dates, settings) || defaultDate;
		} catch (event) {
			this.log(event);
			date = defaultDate;
		}
		inst.selectedDay = date.getDate();
		inst.drawMonth = inst.selectedMonth = date.getMonth();
		inst.drawYear = inst.selectedYear = date.getFullYear();
		inst.currentDay = (dates ? date.getDate() : 0);
		inst.currentMonth = (dates ? date.getMonth() : 0);
		inst.currentYear = (dates ? date.getFullYear() : 0);
		this._adjustInstDate(inst);
	},

	/* Retrieve the default date shown on opening. */
	_getDefaultDate: function(inst) {
		var date = this._determineDate(this._get(inst, 'defaultDate'), new Date());
		var minDate = this._getMinMaxDate(inst, 'min', true);
		var maxDate = this._getMinMaxDate(inst, 'max');
		date = (minDate && date < minDate ? minDate : date);
		date = (maxDate && date > maxDate ? maxDate : date);
		return date;
	},

	/* A date may be specified as an exact value or a relative one. */
	_determineDate: function(date, defaultDate) {
		var offsetNumeric = function(offset) {
			var date = new Date();
			date.setDate(date.getDate() + offset);
			return date;
		};
		var offsetString = function(offset, getDaysInMonth) {
			var date = new Date();
			var year = date.getFullYear();
			var month = date.getMonth();
			var day = date.getDate();
			var pattern = /([+-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g;
			var matches = pattern.exec(offset);
			while (matches) {
				switch (matches[2] || 'd') {
					case 'd' : case 'D' :
						day += parseInt(matches[1],10); break;
					case 'w' : case 'W' :
						day += parseInt(matches[1],10) * 7; break;
					case 'm' : case 'M' :
						month += parseInt(matches[1],10);
						day = Math.min(day, getDaysInMonth(year, month));
						break;
					case 'y': case 'Y' :
						year += parseInt(matches[1],10);
						day = Math.min(day, getDaysInMonth(year, month));
						break;
				}
				matches = pattern.exec(offset);
			}
			return new Date(year, month, day);
		};
		date = (date == null ? defaultDate :
			(typeof date == 'string' ? offsetString(date, this._getDaysInMonth) :
			(typeof date == 'number' ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : date)));
		date = (date && date.toString() == 'Invalid Date' ? defaultDate : date);
		if (date) {
			date.setHours(0);
			date.setMinutes(0);
			date.setSeconds(0);
			date.setMilliseconds(0);
		}
		return this._daylightSavingAdjust(date);
	},

	/* Handle switch to/from daylight saving.
	   Hours may be non-zero on daylight saving cut-over:
	   > 12 when midnight changeover, but then cannot generate
	   midnight datetime, so jump to 1AM, otherwise reset.
	   @param  date  (Date) the date to check
	   @return  (Date) the corrected date */
	_daylightSavingAdjust: function(date) {
		if (!date) return null;
		date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0);
		return date;
	},

	/* Set the date(s) directly. */
	_setDate: function(inst, date, endDate) {
		var clear = !(date);
		var origMonth = inst.selectedMonth;
		var origYear = inst.selectedYear;
		date = this._determineDate(date, new Date());
		inst.selectedDay = inst.currentDay = date.getDate();
		inst.drawMonth = inst.selectedMonth = inst.currentMonth = date.getMonth();
		inst.drawYear = inst.selectedYear = inst.currentYear = date.getFullYear();
		if (origMonth != inst.selectedMonth || origYear != inst.selectedYear)
			this._notifyChange(inst);
		this._adjustInstDate(inst);
		if (inst.input) {
			inst.input.val(clear ? '' : this._formatDate(inst));
		}
	},

	/* Retrieve the date(s) directly. */
	_getDate: function(inst) {
		var startDate = (!inst.currentYear || (inst.input && inst.input.val() == '') ? null :
			this._daylightSavingAdjust(new Date(
			inst.currentYear, inst.currentMonth, inst.currentDay)));
			return startDate;
	},

	/* Generate the HTML for the current state of the date picker. */
	_generateHTML: function(inst) {
		var today = new Date();
		today = this._daylightSavingAdjust(
			new Date(today.getFullYear(), today.getMonth(), today.getDate())); // clear time
		var isRTL = this._get(inst, 'isRTL');
		var showButtonPanel = this._get(inst, 'showButtonPanel');
		var hideIfNoPrevNext = this._get(inst, 'hideIfNoPrevNext');
		var navigationAsDateFormat = this._get(inst, 'navigationAsDateFormat');
		var numMonths = this._getNumberOfMonths(inst);
		var showCurrentAtPos = this._get(inst, 'showCurrentAtPos');
		var stepMonths = this._get(inst, 'stepMonths');
		var stepBigMonths = this._get(inst, 'stepBigMonths');
		var isMultiMonth = (numMonths[0] != 1 || numMonths[1] != 1);
		var currentDate = this._daylightSavingAdjust((!inst.currentDay ? new Date(9999, 9, 9) :
			new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
		var minDate = this._getMinMaxDate(inst, 'min', true);
		var maxDate = this._getMinMaxDate(inst, 'max');
		var drawMonth = inst.drawMonth - showCurrentAtPos;
		var drawYear = inst.drawYear;
		if (drawMonth < 0) {
			drawMonth += 12;
			drawYear--;
		}
		if (maxDate) {
			var maxDraw = this._daylightSavingAdjust(new Date(maxDate.getFullYear(),
				maxDate.getMonth() - numMonths[1] + 1, maxDate.getDate()));
			maxDraw = (minDate && maxDraw < minDate ? minDate : maxDraw);
			while (this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1)) > maxDraw) {
				drawMonth--;
				if (drawMonth < 0) {
					drawMonth = 11;
					drawYear--;
				}
			}
		}
		inst.drawMonth = drawMonth;
		inst.drawYear = drawYear;
		var prevText = this._get(inst, 'prevText');
		prevText = (!navigationAsDateFormat ? prevText : this.formatDate(prevText,
			this._daylightSavingAdjust(new Date(drawYear, drawMonth - stepMonths, 1)),
			this._getFormatConfig(inst)));
		var prev = (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ?
			'<a class="ui-datepicker-prev ui-corner-all" onclick="DP_jQuery.datepicker._adjustDate(\'#' + inst.id + '\', -' + stepMonths + ', \'M\');"' +
			' title="' + prevText + '"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'e' : 'w') + '">' + prevText + '</span></a>' :
			(hideIfNoPrevNext ? '' : '<a class="ui-datepicker-prev ui-corner-all" title="'+ prevText +'"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'e' : 'w') + '">' + prevText + '</span></a>'));
		var nextText = this._get(inst, 'nextText');
		nextText = (!navigationAsDateFormat ? nextText : this.formatDate(nextText,
			this._daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)),
			this._getFormatConfig(inst)));
		var next = (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ?
			'<a class="ui-datepicker-next ui-corner-all" onclick="DP_jQuery.datepicker._adjustDate(\'#' + inst.id + '\', +' + stepMonths + ', \'M\');"' +
			' title="' + nextText + '"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'w' : 'e') + '">' + nextText + '</span></a>' :
			(hideIfNoPrevNext ? '' : '<a class="ui-datepicker-next ui-corner-all" title="'+ nextText + '"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'w' : 'e') + '">' + nextText + '</span></a>'));
		var currentText = this._get(inst, 'currentText');
		var gotoDate = (this._get(inst, 'gotoCurrent') && inst.currentDay ? currentDate : today);
		currentText = (!navigationAsDateFormat ? currentText :
			this.formatDate(currentText, gotoDate, this._getFormatConfig(inst)));
		var controls = (!inst.inline ? '<button type="button" class="ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all" onclick="DP_jQuery.datepicker._hideDatepicker();">' + this._get(inst, 'closeText') + '</button>' : '');
		var buttonPanel = (showButtonPanel) ? '<div class="ui-datepicker-buttonpane ui-widget-content">' + (isRTL ? controls : '') +
			(this._isInRange(inst, gotoDate) ? '<button type="button" class="ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all" onclick="DP_jQuery.datepicker._gotoToday(\'#' + inst.id + '\');"' +
			'>' + currentText + '</button>' : '') + (isRTL ? '' : controls) + '</div>' : '';
		var firstDay = parseInt(this._get(inst, 'firstDay'),10);
		firstDay = (isNaN(firstDay) ? 0 : firstDay);
		var dayNames = this._get(inst, 'dayNames');
		var dayNamesShort = this._get(inst, 'dayNamesShort');
		var dayNamesMin = this._get(inst, 'dayNamesMin');
		var monthNames = this._get(inst, 'monthNames');
		var monthNamesShort = this._get(inst, 'monthNamesShort');
		var beforeShowDay = this._get(inst, 'beforeShowDay');
		var showOtherMonths = this._get(inst, 'showOtherMonths');
		var calculateWeek = this._get(inst, 'calculateWeek') || this.iso8601Week;
		var endDate = inst.endDay ? this._daylightSavingAdjust(
			new Date(inst.endYear, inst.endMonth, inst.endDay)) : currentDate;
		var defaultDate = this._getDefaultDate(inst);
		var html = '';
		html="<div class='ui-closecal'><span class='ui-closeicon' onclick='DP_jQuery.datepicker._hideDatepicker();'></span></div>";
		for (var row = 0; row < numMonths[0]; row++) {
			var group = '';
			for (var col = 0; col < numMonths[1]; col++) {
				var selectedDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, inst.selectedDay));
				var cornerClass = ' ui-corner-all';
				var calender = '';
				if (isMultiMonth) {
					calender += '<div class="ui-datepicker-group ui-datepicker-group-';
					switch (col) {
						case 0: calender += 'first'; cornerClass = ' ui-corner-' + (isRTL ? 'right' : 'left'); break;
						case numMonths[1]-1: calender += 'last'; cornerClass = ' ui-corner-' + (isRTL ? 'left' : 'right'); break;
						default: calender += 'middle'; cornerClass = ''; break;
					}
					calender += '">';
				}
				calender += '<div class="ui-datepicker-header ui-widget-header ui-helper-clearfix' + cornerClass + '">' +
					(/all|left/.test(cornerClass) && row == 0 ? (isRTL ? next : prev) : '') +
					(/all|right/.test(cornerClass) && row == 0 ? (isRTL ? prev : next) : '') +
					this._generateMonthYearHeader(inst, drawMonth, drawYear, minDate, maxDate,
					selectedDate, row > 0 || col > 0, monthNames, monthNamesShort) + // draw month headers
					'</div><table class="ui-datepicker-calendar" border="0" cellspacing="0" cellpadding="0"><thead>' +
					'<tr>';
				var thead = '';
				for (var dow = 0; dow < 7; dow++) { // days of the week
					var day = (dow + firstDay) % 7;
					thead += '<th' + ((dow + firstDay + 6) % 7 >= 5 ? ' class="ui-datepicker-week-end"' : '') + '>' +
						'<span title="' + dayNames[day] + '">' + dayNamesMin[day] + '</span></th>';
				}
				calender += thead + '</tr></thead><tbody>';
				var daysInMonth = this._getDaysInMonth(drawYear, drawMonth);
				if (drawYear == inst.selectedYear && drawMonth == inst.selectedMonth)
					inst.selectedDay = Math.min(inst.selectedDay, daysInMonth);
				var leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7;
				var numRows = (isMultiMonth ? 6 : Math.ceil((leadDays + daysInMonth) / 7)); // calculate the number of rows to generate
				var printDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1 - leadDays));
				for (var dRow = 0; dRow < numRows; dRow++) { // create date picker rows
					calender += '<tr>';
					var tbody = '';
					for (var dow = 0; dow < 7; dow++) { // create date picker days
						var daySettings = (beforeShowDay ?
							beforeShowDay.apply((inst.input ? inst.input[0] : null), [printDate]) : [true, '']);
						var otherMonth = (printDate.getMonth() != drawMonth);
						var unselectable = otherMonth || !daySettings[0] ||
							(minDate && printDate < minDate) || (maxDate && printDate > maxDate);
						tbody += '<td class="' +
							((dow + firstDay + 6) % 7 >= 5 ? ' ui-datepicker-week-end' : '') + // highlight weekends
							(otherMonth ? ' ui-datepicker-other-month' : '') + // highlight days from other months
							((printDate.getTime() == selectedDate.getTime() && drawMonth == inst.selectedMonth && inst._keyEvent) || // user pressed key
							(defaultDate.getTime() == printDate.getTime() && defaultDate.getTime() == selectedDate.getTime()) ?
							// or defaultDate is current printedDate and defaultDate is selectedDate
							' ' + this._dayOverClass : '') + // highlight selected day
							(unselectable ? ' ' + this._unselectableClass + ' ui-state-disabled': '') +  // highlight unselectable days
							(otherMonth && !showOtherMonths ? '' : ' ' + daySettings[1] + // highlight custom dates
							(printDate.getTime() >= currentDate.getTime() && printDate.getTime() <= endDate.getTime() ? // in current range
							' ' + this._currentClass : '') + // highlight selected day
							(printDate.getTime() == today.getTime() ? ' ui-datepicker-today' : '')) + '"' + // highlight today (if different)
							((!otherMonth || showOtherMonths) && daySettings[2] ? ' title="' + daySettings[2] + '"' : '') + // cell title
							(unselectable ? '' : ' onclick="DP_jQuery.datepicker._selectDay(\'#' +
							inst.id + '\',' + drawMonth + ',' + drawYear + ', this);return false;"') + '>' + // actions
							(otherMonth ? (showOtherMonths ? printDate.getDate() : '&#xa0;') : // display for other months
							(unselectable ? '<span class="ui-state-default">' + printDate.getDate() + '</span>' : '<a class="ui-state-default borderactive' +
							(printDate.getTime() == today.getTime() ? ' ui-state-highlight' : '') +
							(printDate.getTime() >= currentDate.getTime() && printDate.getTime() <= endDate.getTime() ? // in current range
							' ui-state-active' : '') + // highlight selected day
							'" href="#">' + printDate.getDate() + '</a>')) + '</td>'; // display for this month
						printDate.setDate(printDate.getDate() + 1);
						printDate = this._daylightSavingAdjust(printDate);
					}
					calender += tbody + '</tr>';
				}
				drawMonth++;
				if (drawMonth > 11) {
					drawMonth = 0;
					drawYear++;
				}
				calender += '</tbody></table>' + (isMultiMonth ? '</div>' + 
							((numMonths[0] > 0 && col == numMonths[1]-1) ? '<div class="ui-datepicker-row-break"></div>' : '') : '');
				group += calender;
			}
			html += group;
		}
		html += buttonPanel + ($.browser.msie && parseInt($.browser.version,10) < 7 && !inst.inline ?
			'<iframe src="javascript:false;" class="ui-datepicker-cover" frameborder="0"></iframe>' : '');
		inst._keyEvent = false;
		return html;
	},

	/* Generate the month and year header. */
	_generateMonthYearHeader: function(inst, drawMonth, drawYear, minDate, maxDate,
			selectedDate, secondary, monthNames, monthNamesShort) {
		minDate = (inst.rangeStart && minDate && selectedDate < minDate ? selectedDate : minDate);
		var changeMonth = this._get(inst, 'changeMonth');
		var changeYear = this._get(inst, 'changeYear');
		var showMonthAfterYear = this._get(inst, 'showMonthAfterYear');
		var html = '<div class="ui-datepicker-title">';
		var monthHtml = '';
		// month selection
		if (secondary || !changeMonth)
			monthHtml += '<span class="ui-datepicker-month">' + monthNames[drawMonth] + '</span> ';
		else {
			var inMinYear = (minDate && minDate.getFullYear() == drawYear);
			var inMaxYear = (maxDate && maxDate.getFullYear() == drawYear);
			monthHtml += '<select class="ui-datepicker-month" ' +
				'onchange="DP_jQuery.datepicker._selectMonthYear(\'#' + inst.id + '\', this, \'M\');" ' +
				'onclick="DP_jQuery.datepicker._clickMonthYear(\'#' + inst.id + '\');"' +
			 	'>';
			for (var month = 0; month < 12; month++) {
				if ((!inMinYear || month >= minDate.getMonth()) &&
						(!inMaxYear || month <= maxDate.getMonth()))
					monthHtml += '<option value="' + month + '"' +
						(month == drawMonth ? ' selected="selected"' : '') +
						'>' + monthNamesShort[month] + '</option>';
			}
			monthHtml += '</select>';
		}
		if (!showMonthAfterYear)
			html += monthHtml + ((secondary || changeMonth || changeYear) && (!(changeMonth && changeYear)) ? '&#xa0;' : '');
		// year selection
		if (secondary || !changeYear)
			html += '<span class="ui-datepicker-year">' + drawYear + '</span>';
		else {
			// determine range of years to display
			var years = this._get(inst, 'yearRange').split(':');
			var year = 0;
			var endYear = 0;
			if (years.length != 2) {
				year = drawYear - 10;
				endYear = drawYear + 10;
			} else if (years[0].charAt(0) == '+' || years[0].charAt(0) == '-') {
				year = drawYear + parseInt(years[0], 10);
				endYear = drawYear + parseInt(years[1], 10);
			} else {
				year = parseInt(years[0], 10);
				endYear = parseInt(years[1], 10);
			}
			year = (minDate ? Math.max(year, minDate.getFullYear()) : year);
			endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear);
			html += '<select class="ui-datepicker-year" ' +
				'onchange="DP_jQuery.datepicker._selectMonthYear(\'#' + inst.id + '\', this, \'Y\');" ' +
				'onclick="DP_jQuery.datepicker._clickMonthYear(\'#' + inst.id + '\');"' +
				'>';
			for (; year <= endYear; year++) {
				html += '<option value="' + year + '"' +
					(year == drawYear ? ' selected="selected"' : '') +
					'>' + year + '</option>';
			}
			html += '</select>';
		}
		if (showMonthAfterYear)
			html += (secondary || changeMonth || changeYear ? '&#xa0;' : '') + monthHtml;
		html += '</div>'; // Close datepicker_header
		return html;
	},

	/* Adjust one of the date sub-fields. */
	_adjustInstDate: function(inst, offset, period) {
		var year = inst.drawYear + (period == 'Y' ? offset : 0);
		var month = inst.drawMonth + (period == 'M' ? offset : 0);
		var day = Math.min(inst.selectedDay, this._getDaysInMonth(year, month)) +
			(period == 'D' ? offset : 0);
		var date = this._daylightSavingAdjust(new Date(year, month, day));
		// ensure it is within the bounds set
		var minDate = this._getMinMaxDate(inst, 'min', true);
		var maxDate = this._getMinMaxDate(inst, 'max');
		date = (minDate && date < minDate ? minDate : date);
		date = (maxDate && date > maxDate ? maxDate : date);
		inst.selectedDay = date.getDate();
		inst.drawMonth = inst.selectedMonth = date.getMonth();
		inst.drawYear = inst.selectedYear = date.getFullYear();
		if (period == 'M' || period == 'Y')
			this._notifyChange(inst);
	},

	/* Notify change of month/year. */
	_notifyChange: function(inst) {
		var onChange = this._get(inst, 'onChangeMonthYear');
		if (onChange)
			onChange.apply((inst.input ? inst.input[0] : null),
				[inst.selectedYear, inst.selectedMonth + 1, inst]);
	},

	/* Determine the number of months to show. */
	_getNumberOfMonths: function(inst) {
		var numMonths = this._get(inst, 'numberOfMonths');
		return (numMonths == null ? [1, 1] : (typeof numMonths == 'number' ? [1, numMonths] : numMonths));
	},

	/* Determine the current maximum date - ensure no time components are set - may be overridden for a range. */
	_getMinMaxDate: function(inst, minMax, checkRange) {
		var date = this._determineDate(this._get(inst, minMax + 'Date'), null);
		return (!checkRange || !inst.rangeStart ? date :
			(!date || inst.rangeStart > date ? inst.rangeStart : date));
	},

	/* Find the number of days in a given month. */
	_getDaysInMonth: function(year, month) {
		return 32 - new Date(year, month, 32).getDate();
	},

	/* Find the day of the week of the first of a month. */
	_getFirstDayOfMonth: function(year, month) {
		return new Date(year, month, 1).getDay();
	},

	/* Determines if we should allow a "next/prev" month display change. */
	_canAdjustMonth: function(inst, offset, curYear, curMonth) {
		var numMonths = this._getNumberOfMonths(inst);
		var date = this._daylightSavingAdjust(new Date(
			curYear, curMonth + (offset < 0 ? offset : numMonths[1]), 1));
		if (offset < 0)
			date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth()));
		return this._isInRange(inst, date);
	},

	/* Is the given date in the accepted range? */
	_isInRange: function(inst, date) {
		// during range selection, use minimum of selected date and range start
		var newMinDate = (!inst.rangeStart ? null : this._daylightSavingAdjust(
			new Date(inst.selectedYear, inst.selectedMonth, inst.selectedDay)));
		newMinDate = (newMinDate && inst.rangeStart < newMinDate ? inst.rangeStart : newMinDate);
		var minDate = newMinDate || this._getMinMaxDate(inst, 'min');
		var maxDate = this._getMinMaxDate(inst, 'max');
		return ((!minDate || date >= minDate) && (!maxDate || date <= maxDate));
	},

	/* Provide the configuration settings for formatting/parsing. */
	_getFormatConfig: function(inst) {
		var shortYearCutoff = this._get(inst, 'shortYearCutoff');
		shortYearCutoff = (typeof shortYearCutoff != 'string' ? shortYearCutoff :
			new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10));
		return {shortYearCutoff: shortYearCutoff,
			dayNamesShort: this._get(inst, 'dayNamesShort'), dayNames: this._get(inst, 'dayNames'),
			monthNamesShort: this._get(inst, 'monthNamesShort'), monthNames: this._get(inst, 'monthNames')};
	},

	/* Format the given date for display. */
	_formatDate: function(inst, day, month, year) {
		if (!day) {
			inst.currentDay = inst.selectedDay;
			inst.currentMonth = inst.selectedMonth;
			inst.currentYear = inst.selectedYear;
		}
		var date = (day ? (typeof day == 'object' ? day :
			this._daylightSavingAdjust(new Date(year, month, day))) :
			this._daylightSavingAdjust(new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
		return this.formatDate(this._get(inst, 'dateFormat'), date, this._getFormatConfig(inst));
	}
});

/* jQuery extend now ignores nulls! */
function extendRemove(target, props) {
	$.extend(target, props);
	for (var name in props)
		if (props[name] == null || props[name] == undefined)
			target[name] = props[name];
	return target;
};

/* Determine whether an object is an array. */
function isArray(a) {
	return (a && (($.browser.safari && typeof a == 'object' && a.length) ||
		(a.constructor && a.constructor.toString().match(/\Array\(\)/))));
};

/* Invoke the datepicker functionality.
   @param  options  string - a command, optionally followed by additional parameters or
                    Object - settings for attaching new datepicker functionality
   @return  jQuery object */
$.fn.datepicker = function(options){

	/* Initialise the date picker. */
	if (!$.datepicker.initialized) {
		$(document).mousedown($.datepicker._checkExternalClick).
			find('body').append($.datepicker.dpDiv);
		$.datepicker.initialized = true;
	}

	var otherArgs = Array.prototype.slice.call(arguments, 1);
	if (typeof options == 'string' && (options == 'isDisabled' || options == 'getDate'))
		return $.datepicker['_' + options + 'Datepicker'].
			apply($.datepicker, [this[0]].concat(otherArgs));
	if (options == 'option' && arguments.length == 2 && typeof arguments[1] == 'string')
		return $.datepicker['_' + options + 'Datepicker'].
			apply($.datepicker, [this[0]].concat(otherArgs));
	return this.each(function() {
		typeof options == 'string' ?
			$.datepicker['_' + options + 'Datepicker'].
				apply($.datepicker, [this].concat(otherArgs)) :
			$.datepicker._attachDatepicker(this, options);
	});
};

$.datepicker = new Datepicker(); // singleton instance
$.datepicker.initialized = false;
$.datepicker.uuid = new Date().getTime();
$.datepicker.version = "1.7.2";

// Workaround for #4055
// Add another global to avoid noConflict issues with inline event handlers
window.DP_jQuery = $;

})(jQuery);

var disappeardelay=250  //menu disappear speed onMouseout (in miliseconds)
var enableanchorlink=0 //Enable or disable the anchor link when clicked on? (1=e, 0=d)
var hidemenu_onclick=1 //hide menu when user clicks within menu? (1=yes, 0=no)

var ie5=document.all
var ns6=document.getElementById&&!document.all

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function showhide(obj, e, visible, hidden){
if (ie5||ns6)
dropmenuobj.style.left=dropmenuobj.style.top=-500
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
obj.visibility=visible
else if (e.type=="click")
obj.visibility=hidden
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=ie5 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var topedge=ie5 && !window.opera? iecompattest().scrollTop : window.pageYOffset
var windowedge=ie5 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge
}
}
return edgeoffset
}

function dropdownmenu(obj, e, dropmenuID){
if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
if (typeof dropmenuobj!="undefined") //hide previous menu
dropmenuobj.style.visibility="hidden"
clearhidemenu()
if (ie5||ns6){
obj.onmouseout=delayhidemenu
dropmenuobj=document.getElementById(dropmenuID)
if (hidemenu_onclick) dropmenuobj.onclick=function(){dropmenuobj.style.visibility='hidden'}
dropmenuobj.onmouseover=clearhidemenu
dropmenuobj.onmouseout=ie5? function(){ dynamichide(event)} : function(event){ dynamichide(event)}
showhide(dropmenuobj.style, e, "visible", "hidden")
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
}
return clickreturnvalue()
}

function clickreturnvalue(){
if ((ie5||ns6) && !enableanchorlink) return false
else return true
}

function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function dynamichide(e){
if (ie5&&!dropmenuobj.contains(e.toElement))
delayhidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhidemenu()
}

function delayhidemenu(){
delayhide=setTimeout("dropmenuobj.style.visibility='hidden'",disappeardelay)
}

function clearhidemenu(){
if (typeof delayhide!="undefined")
clearTimeout(delayhide)
}

function dropdownmenu(obj, e, dropmenuID){
if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
if (typeof dropmenuobj!="undefined") //hide previous menu
dropmenuobj.style.visibility="hidden"
clearhidemenu()
if (ie5||ns6){
obj.onmouseout=delayhidemenu
dropmenuobj=document.getElementById(dropmenuID)
if (hidemenu_onclick) dropmenuobj.onclick=function(){dropmenuobj.style.visibility='hidden'}
dropmenuobj.onmouseover=clearhidemenu
dropmenuobj.onmouseout=ie5? function(){ dynamichide(event)} : function(event){ dynamichide(event)}
showhide(dropmenuobj.style, e, "visible", "hidden")
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
}
return clickreturnvalue()
}


function ddtabcontent(tabinterfaceid){
	this.tabinterfaceid=tabinterfaceid //ID of Tab Menu main container
	this.tabs=document.getElementById(tabinterfaceid).getElementsByTagName("a") //Get all tab links within container
	this.enabletabpersistence=true
	this.hottabspositions=[] //Array to store position of tabs that have a "rel" attr defined, relative to all tab links, within container
	this.currentTabIndex=0 //Index of currently selected hot tab (tab with sub content) within hottabspositions[] array
	this.subcontentids=[] //Array to store ids of the sub contents ("rel" attr values)
	this.revcontentids=[] //Array to store ids of arbitrary contents to expand/contact as well ("rev" attr values)
	this.selectedClassTarget="link" //keyword to indicate which target element to assign "selected" CSS class ("linkparent" or "link")
}

