(function(B){B.fn.ajaxSubmit=function(O){if(!this.length){A("ajaxSubmit: skipping submit process - no element selected");return this}if(typeof O=="function"){O={success:O}}var E=B.trim(this.attr("action"));if(E){E=(E.match(/^([^#]+)/)||[])[1]}E=E||window.location.href||"";O=B.extend({url:E,type:this.attr("method")||"GET",iframeSrc:/^https/i.test(window.location.href||"")?"javascript:false":"about:blank"},O||{});var Q={};this.trigger("form-pre-serialize",[this,O,Q]);if(Q.veto){A("ajaxSubmit: submit vetoed via form-pre-serialize trigger");return this}if(O.beforeSerialize&&O.beforeSerialize(this,O)===false){A("ajaxSubmit: submit aborted via beforeSerialize callback");return this}var K=this.formToArray(O.semantic);if(O.data){O.extraData=O.data;for(var F in O.data){if(O.data[F] instanceof Array){for(var G in O.data[F]){K.push({name:F,value:O.data[F][G]})}}else{K.push({name:F,value:O.data[F]})}}}if(O.beforeSubmit&&O.beforeSubmit(K,this,O)===false){A("ajaxSubmit: submit aborted via beforeSubmit callback");return this}this.trigger("form-submit-validate",[K,this,O,Q]);if(Q.veto){A("ajaxSubmit: submit vetoed via form-submit-validate trigger");return this}var D=B.param(K);if(O.type.toUpperCase()=="GET"){O.url+=(O.url.indexOf("?")>=0?"&":"?")+D;O.data=null}else{O.data=D}var P=this,J=[];if(O.resetForm){J.push(function(){P.resetForm()})}if(O.clearForm){J.push(function(){P.clearForm()})}if(!O.dataType&&O.target){var M=O.success||function(){};J.push(function(R){B(O.target).html(R).each(M,arguments)})}else{if(O.success){J.push(O.success)}}O.success=function(U,S,V){for(var T=0,R=J.length;T<R;T++){J[T].apply(O,[U,S,V||P,P])}};var C=B("input:file",this).fieldValue();var N=false;for(var I=0;I<C.length;I++){if(C[I]){N=true}}var H=false;if((C.length&&O.iframe!==false)||O.iframe||N||H){if(O.closeKeepAlive){B.get(O.closeKeepAlive,L)}else{L()}}else{B.ajax(O)}this.trigger("form-submit-notify",[this,O]);return this;function L(){var V=P[0];if(B(":input[name=submit]",V).length){alert('Error: Form elements must not be named "submit".');return }var T=B.extend({},B.ajaxSettings,O);var h=B.extend(true,{},B.extend(true,{},B.ajaxSettings),T);var U="jqFormIO"+(new Date().getTime());var c=B('<iframe id="'+U+'" name="'+U+'" src="'+T.iframeSrc+'" onload="(jQuery(this).data(\'form-plugin-onload\'))()" />');var e=c[0];c.css({position:"absolute",top:"-1000px",left:"-1000px"});var f={aborted:0,responseText:null,responseXML:null,status:0,statusText:"n/a",getAllResponseHeaders:function(){},getResponseHeader:function(){},setRequestHeader:function(){},abort:function(){this.aborted=1;c.attr("src",T.iframeSrc)}};var d=T.global;if(d&&!B.active++){B.event.trigger("ajaxStart")}if(d){B.event.trigger("ajaxSend",[f,T])}if(h.beforeSend&&h.beforeSend(f,h)===false){h.global&&B.active--;return }if(f.aborted){return }var S=false;var Z=0;var R=V.clk;if(R){var X=R.name;if(X&&!R.disabled){T.extraData=T.extraData||{};T.extraData[X]=R.value;if(R.type=="image"){T.extraData[name+".x"]=V.clk_x;T.extraData[name+".y"]=V.clk_y}}}function W(){var k=P.attr("target"),g=P.attr("action");V.setAttribute("target",U);if(V.getAttribute("method")!="POST"){V.setAttribute("method","POST")}if(V.getAttribute("action")!=T.url){V.setAttribute("action",T.url)}if(!T.skipEncodingOverride){P.attr({encoding:"multipart/form-data",enctype:"multipart/form-data"})}if(T.timeout){setTimeout(function(){Z=true;a()},T.timeout)}var j=[];try{if(T.extraData){for(var l in T.extraData){j.push(B('<input type="hidden" name="'+l+'" value="'+T.extraData[l]+'" />').appendTo(V)[0])}}c.appendTo("body");c.data("form-plugin-onload",a);V.submit()}finally{V.setAttribute("action",g);k?V.setAttribute("target",k):P.removeAttr("target");B(j).remove()}}if(T.forceSync){W()}else{setTimeout(W,10)}var Y=100;function a(){if(S){return }var j=true;try{if(Z){throw"timeout"}var k,n;n=e.contentWindow?e.contentWindow.document:e.contentDocument?e.contentDocument:e.document;var o=T.dataType=="xml"||n.XMLDocument||B.isXMLDoc(n);A("isXml="+o);if(!o&&(n.body==null||n.body.innerHTML=="")){if(--Y){setTimeout(a,250);return }A("Could not access iframe DOM after 100 tries.");return }S=true;f.responseText=n.body?n.body.innerHTML:null;f.responseXML=n.XMLDocument?n.XMLDocument:n;f.getResponseHeader=function(q){var p={"content-type":T.dataType};return p[q]};if(T.dataType=="json"||T.dataType=="script"){var g=n.getElementsByTagName("textarea")[0];if(g){f.responseText=g.value}else{var m=n.getElementsByTagName("pre")[0];if(m){f.responseText=m.innerHTML}}}else{if(T.dataType=="xml"&&!f.responseXML&&f.responseText!=null){f.responseXML=b(f.responseText)}}k=B.httpData(f,T.dataType)}catch(l){j=false;B.handleError(T,f,"error",l)}if(j){T.success(k,"success");if(d){B.event.trigger("ajaxSuccess",[f,T])}}if(d){B.event.trigger("ajaxComplete",[f,T])}if(d&&!--B.active){B.event.trigger("ajaxStop")}if(T.complete){T.complete(f,j?"success":"error")}setTimeout(function(){c.removeData("form-plugin-onload");c.remove();f.responseXML=null},100)}function b(g,j){if(window.ActiveXObject){j=new ActiveXObject("Microsoft.XMLDOM");j.async="false";j.loadXML(g)}else{j=(new DOMParser()).parseFromString(g,"text/xml")}return(j&&j.documentElement&&j.documentElement.tagName!="parsererror")?j:null}}};B.fn.ajaxForm=function(C){return this.ajaxFormUnbind().bind("submit.form-plugin",function(D){D.preventDefault();B(this).ajaxSubmit(C)}).bind("click.form-plugin",function(H){var G=H.target;var E=B(G);if(!(E.is(":submit,input:image"))){var D=E.closest(":submit");if(D.length==0){return }G=D[0]}var F=this;F.clk=G;if(G.type=="image"){if(H.offsetX!=undefined){F.clk_x=H.offsetX;F.clk_y=H.offsetY}else{if(typeof B.fn.offset=="function"){var I=E.offset();F.clk_x=H.pageX-I.left;F.clk_y=H.pageY-I.top}else{F.clk_x=H.pageX-G.offsetLeft;F.clk_y=H.pageY-G.offsetTop}}}setTimeout(function(){F.clk=F.clk_x=F.clk_y=null},100)})};B.fn.ajaxFormUnbind=function(){return this.unbind("submit.form-plugin click.form-plugin")};B.fn.formToArray=function(N){var M=[];if(this.length==0){return M}var D=this[0];var H=N?D.getElementsByTagName("*"):D.elements;if(!H){return M}for(var I=0,K=H.length;I<K;I++){var E=H[I];var F=E.name;if(!F){continue}if(N&&D.clk&&E.type=="image"){if(!E.disabled&&D.clk==E){M.push({name:F,value:B(E).val()});M.push({name:F+".x",value:D.clk_x},{name:F+".y",value:D.clk_y})}continue}var O=B.fieldValue(E,true);if(O&&O.constructor==Array){for(var G=0,C=O.length;G<C;G++){M.push({name:F,value:O[G]})}}else{if(O!==null&&typeof O!="undefined"){M.push({name:F,value:O})}}}if(!N&&D.clk){var J=B(D.clk),L=J[0],F=L.name;if(F&&!L.disabled&&L.type=="image"){M.push({name:F,value:J.val()});M.push({name:F+".x",value:D.clk_x},{name:F+".y",value:D.clk_y})}}return M};B.fn.formSerialize=function(C){return B.param(this.formToArray(C))};B.fn.fieldSerialize=function(D){var C=[];this.each(function(){var H=this.name;if(!H){return }var F=B.fieldValue(this,D);if(F&&F.constructor==Array){for(var G=0,E=F.length;G<E;G++){C.push({name:H,value:F[G]})}}else{if(F!==null&&typeof F!="undefined"){C.push({name:this.name,value:F})}}});return B.param(C)};B.fn.fieldValue=function(H){for(var G=[],E=0,C=this.length;E<C;E++){var F=this[E];var D=B.fieldValue(F,H);if(D===null||typeof D=="undefined"||(D.constructor==Array&&!D.length)){continue}D.constructor==Array?B.merge(G,D):G.push(D)}return G};B.fieldValue=function(C,I){var E=C.name,N=C.type,O=C.tagName.toLowerCase();if(typeof I=="undefined"){I=true}if(I&&(!E||C.disabled||N=="reset"||N=="button"||(N=="checkbox"||N=="radio")&&!C.checked||(N=="submit"||N=="image")&&C.form&&C.form.clk!=C||O=="select"&&C.selectedIndex==-1)){return null}if(O=="select"){var J=C.selectedIndex;if(J<0){return null}var L=[],D=C.options;var G=(N=="select-one");var K=(G?J+1:D.length);for(var F=(G?J:0);F<K;F++){var H=D[F];if(H.selected){var M=H.value;if(!M){M=(H.attributes&&H.attributes["value"]&&!(H.attributes["value"].specified))?H.text:H.value}if(G){return M}L.push(M)}}return L}return C.value};B.fn.clearForm=function(){return this.each(function(){B("input,select,textarea",this).clearFields()})};B.fn.clearFields=B.fn.clearInputs=function(){return this.each(function(){var D=this.type,C=this.tagName.toLowerCase();if(D=="text"||D=="password"||C=="textarea"){this.value=""}else{if(D=="checkbox"||D=="radio"){this.checked=false}else{if(C=="select"){this.selectedIndex=-1}}}})};B.fn.resetForm=function(){return this.each(function(){if(typeof this.reset=="function"||(typeof this.reset=="object"&&!this.reset.nodeType)){this.reset()}})};B.fn.enable=function(C){if(C==undefined){C=true}return this.each(function(){this.disabled=!C})};B.fn.selected=function(C){if(C==undefined){C=true}return this.each(function(){var D=this.type;if(D=="checkbox"||D=="radio"){this.checked=C}else{if(this.tagName.toLowerCase()=="option"){var E=B(this).parent("select");if(C&&E[0]&&E[0].type=="select-one"){E.find("option").selected(false)}this.selected=C}}})};function A(){if(B.fn.ajaxSubmit.debug&&window.console&&window.console.log){window.console.log("[jquery.form] "+Array.prototype.join.call(arguments,""))}}})(jQuery);(function(I){if(/1\.(0|1|2)\.(0|1|2)/.test(I.fn.jquery)||/^1.1/.test(I.fn.jquery)){alert("blockUI requires jQuery v1.2.3 or later!  You are using v"+I.fn.jquery);return }I.fn._fadeIn=I.fn.fadeIn;var C=function(){};var J=document.documentMode||0;var E=I.browser.msie&&((I.browser.version<8&&!J)||J<8);var F=I.browser.msie&&/MSIE 6.0/.test(navigator.userAgent)&&!J;I.blockUI=function(P){D(window,P)};I.unblockUI=function(P){H(window,P)};I.growlUI=function(T,R,S,P){var Q=I('<div class="growlUI"></div>');if(T){Q.append("<h1>"+T+"</h1>")}if(R){Q.append("<h2>"+R+"</h2>")}if(S==undefined){S=3000}I.blockUI({message:Q,fadeIn:700,fadeOut:1000,centerY:false,timeout:S,showOverlay:false,onUnblock:P,css:I.blockUI.defaults.growlCSS})};I.fn.block=function(P){return this.unblock({fadeOut:0}).each(function(){if(I.css(this,"position")=="static"){this.style.position="relative"}if(I.browser.msie){this.style.zoom=1}D(this,P)})};I.fn.unblock=function(P){return this.each(function(){H(this,P)})};I.blockUI.version=2.33;I.blockUI.defaults={message:"<h1>Please wait...</h1>",title:null,draggable:true,theme:false,css:{padding:0,margin:0,width:"30%",top:"40%",left:"35%",textAlign:"center",color:"#000",border:"3px solid #aaa",backgroundColor:"#fff",cursor:"wait"},themedCSS:{width:"30%",top:"40%",left:"35%"},overlayCSS:{backgroundColor:"#000",opacity:0.6,cursor:"wait"},growlCSS:{width:"350px",top:"10px",left:"",right:"10px",border:"none",padding:"5px",opacity:0.6,cursor:"default",color:"#fff",backgroundColor:"#000","-webkit-border-radius":"10px","-moz-border-radius":"10px","border-radius":"10px"},iframeSrc:/^https/i.test(window.location.href||"")?"javascript:false":"about:blank",forceIframe:false,baseZ:1000,centerX:true,centerY:true,allowBodyStretch:true,bindEvents:true,constrainTabKey:true,fadeIn:200,fadeOut:400,timeout:0,showOverlay:true,focusInput:true,applyPlatformOpacityRules:true,onBlock:null,onUnblock:null,quirksmodeOffsetHack:4};var B=null;var G=[];function D(R,c){var X=(R==window);var U=c&&c.message!==undefined?c.message:undefined;c=I.extend({},I.blockUI.defaults,c||{});c.overlayCSS=I.extend({},I.blockUI.defaults.overlayCSS,c.overlayCSS||{});var Z=I.extend({},I.blockUI.defaults.css,c.css||{});var m=I.extend({},I.blockUI.defaults.themedCSS,c.themedCSS||{});U=U===undefined?c.message:U;if(X&&B){H(window,{fadeOut:0})}if(U&&typeof U!="string"&&(U.parentNode||U.jquery)){var f=U.jquery?U[0]:U;var o={};I(R).data("blockUI.history",o);o.el=f;o.parent=f.parentNode;o.display=f.style.display;o.position=f.style.position;if(o.parent){o.parent.removeChild(f)}}var Y=c.baseZ;var k=(I.browser.msie||c.forceIframe)?I('<iframe class="blockUI" style="z-index:'+(Y++)+';display:none;border:none;margin:0;padding:0;position:absolute;width:100%;height:100%;top:0;left:0" src="'+c.iframeSrc+'"></iframe>'):I('<div class="blockUI" style="display:none"></div>');var j=I('<div class="blockUI blockOverlay" style="z-index:'+(Y++)+';display:none;border:none;margin:0;padding:0;width:100%;height:100%;top:0;left:0"></div>');var h,d;if(c.theme&&X){d='<div class="blockUI blockMsg blockPage ui-dialog ui-widget ui-corner-all" style="z-index:'+Y+';display:none;position:fixed"><div class="ui-widget-header ui-dialog-titlebar blockTitle">'+(c.title||"&nbsp;")+'</div><div class="ui-widget-content ui-dialog-content"></div></div>'}else{if(c.theme){d='<div class="blockUI blockMsg blockElement ui-dialog ui-widget ui-corner-all" style="z-index:'+Y+';display:none;position:absolute"><div class="ui-widget-header ui-dialog-titlebar blockTitle">'+(c.title||"&nbsp;")+'</div><div class="ui-widget-content ui-dialog-content"></div></div>'}else{if(X){d='<div class="blockUI blockMsg blockPage" style="z-index:'+Y+';display:none;position:fixed"></div>'}else{d='<div class="blockUI blockMsg blockElement" style="z-index:'+Y+';display:none;position:absolute"></div>'}}}h=I(d);if(U){if(c.theme){h.css(m);h.addClass("ui-widget-content")}else{h.css(Z)}}if(!c.applyPlatformOpacityRules||!(I.browser.mozilla&&/Linux/.test(navigator.platform))){j.css(c.overlayCSS)}j.css("position",X?"fixed":"absolute");if(I.browser.msie||c.forceIframe){k.css("opacity",0)}var W=[k,j,h],n=X?I("body"):I(R);I.each(W,function(){this.appendTo(n)});if(c.theme&&c.draggable&&I.fn.draggable){h.draggable({handle:".ui-dialog-titlebar",cancel:"li"})}var T=E&&(!I.boxModel||I("object,embed",X?null:R).length>0);if(F||T){if(X&&c.allowBodyStretch&&I.boxModel){I("html,body").css("height","100%")}if((F||!I.boxModel)&&!X){var b=M(R,"borderTopWidth"),g=M(R,"borderLeftWidth");var V=b?"(0 - "+b+")":0;var a=g?"(0 - "+g+")":0}I.each([k,j,h],function(l,t){var p=t[0].style;p.position="absolute";if(l<2){X?p.setExpression("height","Math.max(document.body.scrollHeight, document.body.offsetHeight) - (jQuery.boxModel?0:"+c.quirksmodeOffsetHack+') + "px"'):p.setExpression("height",'this.parentNode.offsetHeight + "px"');X?p.setExpression("width",'jQuery.boxModel && document.documentElement.clientWidth || document.body.clientWidth + "px"'):p.setExpression("width",'this.parentNode.offsetWidth + "px"');if(a){p.setExpression("left",a)}if(V){p.setExpression("top",V)}}else{if(c.centerY){if(X){p.setExpression("top",'(document.documentElement.clientHeight || document.body.clientHeight) / 2 - (this.offsetHeight / 2) + (blah = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"')}p.marginTop=0}else{if(!c.centerY&&X){var q=(c.css&&c.css.top)?parseInt(c.css.top):0;var r="((document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "+q+') + "px"';p.setExpression("top",r)}}}})}if(U){if(c.theme){h.find(".ui-widget-content").append(U)}else{h.append(U)}if(U.jquery||U.nodeType){I(U).show()}}if((I.browser.msie||c.forceIframe)&&c.showOverlay){k.show()}if(c.fadeIn){var e=c.onBlock?c.onBlock:C;var Q=(c.showOverlay&&!U)?e:C;var P=U?e:C;if(c.showOverlay){j._fadeIn(c.fadeIn,Q)}if(U){h._fadeIn(c.fadeIn,P)}}else{if(c.showOverlay){j.show()}if(U){h.show()}if(c.onBlock){c.onBlock()}}L(1,R,c);if(X){B=h[0];G=I(":input:enabled:visible",B);if(c.focusInput){setTimeout(O,20)}}else{A(h[0],c.centerX,c.centerY)}if(c.timeout){var S=setTimeout(function(){X?I.unblockUI(c):I(R).unblock(c)},c.timeout);I(R).data("blockUI.timeout",S)}}function H(S,T){var R=(S==window);var Q=I(S);var U=Q.data("blockUI.history");var V=Q.data("blockUI.timeout");if(V){clearTimeout(V);Q.removeData("blockUI.timeout")}T=I.extend({},I.blockUI.defaults,T||{});L(0,S,T);var P;if(R){P=I("body").children().filter(".blockUI").add("body > .blockUI")}else{P=I(".blockUI",S)}if(R){B=G=null}if(T.fadeOut){P.fadeOut(T.fadeOut);setTimeout(function(){K(P,U,T,S)},T.fadeOut)}else{K(P,U,T,S)}}function K(P,S,R,Q){P.each(function(T,U){if(this.parentNode){this.parentNode.removeChild(this)}});if(S&&S.el){S.el.style.display=S.display;S.el.style.position=S.position;if(S.parent){S.parent.appendChild(S.el)}I(Q).removeData("blockUI.history")}if(typeof R.onUnblock=="function"){R.onUnblock(Q,R)}}function L(P,T,U){var S=T==window,R=I(T);if(!P&&(S&&!B||!S&&!R.data("blockUI.isBlocked"))){return }if(!S){R.data("blockUI.isBlocked",P)}if(!U.bindEvents||(P&&!U.showOverlay)){return }var Q="mousedown mouseup keydown keypress";P?I(document).bind(Q,U,N):I(document).unbind(Q,N)}function N(S){if(S.keyCode&&S.keyCode==9){if(B&&S.data.constrainTabKey){var R=G;var Q=!S.shiftKey&&S.target==R[R.length-1];var P=S.shiftKey&&S.target==R[0];if(Q||P){setTimeout(function(){O(P)},10);return false}}}if(I(S.target).parents("div.blockMsg").length>0){return true}return I(S.target).parents().children().filter("div.blockUI").length==0}function O(P){if(!G){return }var Q=G[P===true?G.length-1:0];if(Q){Q.focus()}}function A(T,P,V){var U=T.parentNode,S=T.style;var Q=((U.offsetWidth-T.offsetWidth)/2)-M(U,"borderLeftWidth");var R=((U.offsetHeight-T.offsetHeight)/2)-M(U,"borderTopWidth");if(P){S.left=Q>0?(Q+"px"):"0"}if(V){S.top=R>0?(R+"px"):"0"}}function M(P,Q){return parseInt(I.css(P,Q))||0}})(jQuery);(function(A){A.fn.bgiframe=(A.browser.msie&&/msie 6\.0/i.test(navigator.userAgent)?function(D){D=A.extend({top:"auto",left:"auto",width:"auto",height:"auto",opacity:true,src:"javascript:false;"},D);var C='<iframe class="bgiframe"frameborder="0"tabindex="-1"src="'+D.src+'"style="display:block;position:absolute;z-index:-1;'+(D.opacity!==false?"filter:Alpha(Opacity='0');":"")+"top:"+(D.top=="auto"?"expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+'px')":B(D.top))+";left:"+(D.left=="auto"?"expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+'px')":B(D.left))+";width:"+(D.width=="auto"?"expression(this.parentNode.offsetWidth+'px')":B(D.width))+";height:"+(D.height=="auto"?"expression(this.parentNode.offsetHeight+'px')":B(D.height))+';"/>';return this.each(function(){if(A(this).children("iframe.bgiframe").length===0){this.insertBefore(document.createElement(C),this.firstChild)}})}:function(){return this});A.fn.bgIframe=A.fn.bgiframe;function B(C){return C&&C.constructor===Number?C+"px":C}})(jQuery);(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 J;var P="";var M=A.Autocompleter.Cache(G);var E=0;var U;var X={mouseDownOnSelect:false};var R=A.Autocompleter.Select(G,L,D,X);var W;A.browser.opera&&A(L.form).bind("submit.autocomplete",function(){if(W){W=false;return false}});B.bind((A.browser.opera?"keypress":"keydown")+".autocomplete",function(Y){E=1;U=Y.keyCode;switch(Y.keyCode){case C.UP:Y.preventDefault();if(R.visible()){R.prev()}else{T(0,true)}break;case C.DOWN:Y.preventDefault();if(R.visible()){R.next()}else{T(0,true)}break;case C.PAGEUP:Y.preventDefault();if(R.visible()){R.pageUp()}else{T(0,true)}break;case C.PAGEDOWN:Y.preventDefault();if(R.visible()){R.pageDown()}else{T(0,true)}break;case G.multiple&&A.trim(G.multipleSeparator)==","&&C.COMMA:case C.TAB:case C.RETURN:if(D()){Y.preventDefault();W=true;return false}break;case C.ESC:R.hide();break;default:clearTimeout(J);J=setTimeout(T,G.delay);break}}).focus(function(){E++}).blur(function(){E=0;if(!X.mouseDownOnSelect){S()}}).click(function(){if(E++>1&&!R.visible()){T(0,true)}}).bind("search",function(){var Y=(arguments.length>1)?arguments[1]:null;function Z(d,c){var a;if(c&&c.length){for(var b=0;b<c.length;b++){if(c[b].result.toLowerCase()==d.toLowerCase()){a=c[b];break}}}if(typeof Y=="function"){Y(a)}else{B.trigger("result",a&&[a.data,a.value])}}A.each(H(B.val()),function(a,b){F(b,Z,Z)})}).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();A(L.form).unbind(".autocomplete")});function D(){var b=R.selected();if(!b){return false}var Y=b.result;P=Y;if(G.multiple){var e=H(B.val());if(e.length>1){var a=G.multipleSeparator.length;var d=A(L).selection().start;var c,Z=0;A.each(e,function(f,g){Z+=g.length;if(d<=Z){c=f;return false}Z+=a});e[c]=Y;Y=e.join(G.multipleSeparator)}Y+=G.multipleSeparator}B.val(Y);V();B.trigger("result",[b.data,b.value]);return true}function T(a,Z){if(U==C.DEL){R.hide();return }var Y=B.val();if(!Z&&Y==P){return }P=Y;Y=I(Y);if(Y.length>=G.minChars){B.addClass(G.loadingClass);if(!G.matchCase){Y=Y.toLowerCase()}F(Y,K,V)}else{N();R.hide()}}function H(Y){if(!Y){return[""]}if(!G.multiple){return[A.trim(Y)]}return A.map(Y.split(G.multipleSeparator),function(Z){return A.trim(Y).length?A.trim(Z):null})}function I(Y){if(!G.multiple){return Y}var a=H(Y);if(a.length==1){return a[0]}var Z=A(L).selection().start;if(Z==Y.length){a=H(Y)}else{a=H(Y.replace(Y.substring(Z),""))}return a[a.length-1]}function Q(Y,Z){if(G.autoFill&&(I(B.val()).toLowerCase()==Y.toLowerCase())&&U!=C.BACKSPACE){B.val(B.val()+Z.substring(I(P).length));A(L).selection(P.length,P.length+Z.length)}}function S(){clearTimeout(J);J=setTimeout(V,200)}function V(){var Y=R.visible();R.hide();clearTimeout(J);N();if(G.mustMatch){B.search(function(Z){if(!Z){if(G.multiple){var a=H(B.val()).slice(0,-1);B.val(a.join(G.multipleSeparator)+(a.length?G.multipleSeparator:""))}else{B.val("");B.trigger("result",null)}}})}}function K(Z,Y){if(Y&&Y.length&&E){N();R.display(Y,Z);Q(Z,Y[0].value);R.show()}else{V()}}function F(Z,b,Y){if(!G.matchCase){Z=Z.toLowerCase()}var a=M.load(Z);if(a&&a.length){b(Z,a)}else{if((typeof G.url=="string")&&(G.url.length>0)){var c={timestamp:+new Date()};A.each(G.extraParams,function(d,e){c[d]=typeof e=="function"?e():e});A.ajax({mode:"abort",port:"autocomplete"+L.name,dataType:G.dataType,url:G.url,data:A.extend({q:I(Z),limit:G.max},c),success:function(e){var d=G.parse&&G.parse(e)||O(e);M.add(Z,d);b(Z,d)}})}else{R.emptyList();Y(Z)}}}function O(b){var Y=[];var a=b.split("\n");for(var Z=0;Z<a.length;Z++){var c=A.trim(a[Z]);if(c){c=c.split("|");Y[Y.length]={data:c,value:c[0],result:G.formatResult&&G.formatResult(c,c[0])||c[0]}}}return Y}function N(){B.removeClass(G.loadingClass)}};A.Autocompleter.defaults={inputClass:"ac_input",resultsClass:"ac_results",loadingClass:"ac_loading",minChars:1,delay:400,matchCase:false,matchSubset:true,matchContains:false,cacheLength:10,max:100,mustMatch:false,extraParams:{},selectFirst:true,formatItem:function(B){return B[0]},formatMatch:null,autoFill:false,width:0,multiple:false,multipleSeparator:", ",highlight:function(C,B){return C.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)("+B.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi,"\\$1")+")(?![^<>]*>)(?![^&;]+;)","gi"),"<strong>$1</strong>")},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,J,L,P){var I={ACTIVE:"ac_over"};var K,F=-1,R,M="",S=true,C,O;function N(){if(!S){return }C=A("<div/>").hide().addClass(E.resultsClass).css("position","absolute").appendTo(document.body);O=A("<ul/>").appendTo(C).mouseover(function(T){if(Q(T).nodeName&&Q(T).nodeName.toUpperCase()=="LI"){F=A("li",O).removeClass(I.ACTIVE).index(Q(T));A(Q(T)).addClass(I.ACTIVE)}}).click(function(T){A(Q(T)).addClass(I.ACTIVE);L();J.focus();return false}).mousedown(function(){P.mouseDownOnSelect=true}).mouseup(function(){P.mouseDownOnSelect=false});if(E.width>0){C.css("width",E.width)}S=false}function Q(U){var T=U.target;while(T&&T.tagName!="LI"){T=T.parentNode}if(!T){return[]}return T}function H(T){K.slice(F,F+1).removeClass(I.ACTIVE);G(T);var V=K.slice(F,F+1).addClass(I.ACTIVE);if(E.scroll){var U=0;K.slice(0,F).each(function(){U+=this.offsetHeight});if((U+V[0].offsetHeight-O.scrollTop())>O[0].clientHeight){O.scrollTop(U+V[0].offsetHeight-O.innerHeight())}else{if(U<O.scrollTop()){O.scrollTop(U)}}}}function G(T){F+=T;if(F<0){F=K.size()-1}else{if(F>=K.size()){F=0}}}function B(T){return E.max&&E.max<T?E.max:T}function D(){O.empty();var U=B(R.length);for(var V=0;V<U;V++){if(!R[V]){continue}var W=E.formatItem(R[V].data,V+1,U,R[V].value,M);if(W===false){continue}var T=A("<li/>").html(E.highlight(W,M)).addClass(V%2==0?"ac_even":"ac_odd").appendTo(O)[0];A.data(T,"ac_data",R[V])}K=O.find("li");if(E.selectFirst){K.slice(0,1).addClass(I.ACTIVE);F=0}if(A.fn.bgiframe){O.bgiframe()}}return{display:function(U,T){N();R=U;M=T;D()},next:function(){H(1)},prev:function(){H(-1)},pageUp:function(){if(F!=0&&F-8<0){H(-F)}else{H(-8)}},pageDown:function(){if(F!=K.size()-1&&F+8>K.size()){H(K.size()-1-F)}else{H(8)}},hide:function(){C&&C.hide();K&&K.removeClass(I.ACTIVE);F=-1},visible:function(){return C&&C.is(":visible")},current:function(){return this.visible()&&(K.filter("."+I.ACTIVE)[0]||E.selectFirst&&K[0])},show:function(){var V=A(J).offset();C.css({width:typeof E.width=="string"||E.width>0?E.width:A(J).width(),top:V.top+J.offsetHeight,left:V.left}).show();if(E.scroll){O.scrollTop(0);O.css({maxHeight:E.scrollHeight,overflow:"auto"});if(A.browser.msie&&typeof document.body.style.maxHeight==="undefined"){var T=0;K.each(function(){T+=this.offsetHeight});var U=T>E.scrollHeight;O.css("height",U?E.scrollHeight:T);if(!U){K.width(O.width()-parseInt(K.css("padding-left"))-parseInt(K.css("padding-right")))}}}},selected:function(){var T=K&&K.filter("."+I.ACTIVE).removeClass(I.ACTIVE);return T&&T.length&&A.data(T[0],"ac_data")},emptyList:function(){O&&O.empty()},unbind:function(){C&&C.remove()}}};A.fn.selection=function(I,B){if(I!==undefined){return this.each(function(){if(this.createTextRange){var J=this.createTextRange();if(B===undefined||I==B){J.move("character",I);J.select()}else{J.collapse(true);J.moveStart("character",I);J.moveEnd("character",B);J.select()}}else{if(this.setSelectionRange){this.setSelectionRange(I,B)}else{if(this.selectionStart){this.selectionStart=I;this.selectionEnd=B}}}})}var G=this[0];if(G.createTextRange){var C=document.selection.createRange(),H=G.value,F="<->",D=C.text.length;C.text=F;var E=G.value.indexOf(F);G.value=H;this.selection(E,E+D);return{start:E,end:E+D}}else{if(G.selectionStart!==undefined){return{start:G.selectionStart,end:G.selectionEnd}}}}})(jQuery);(function(A){A.fn.extend({labelify:function(C){C=A.extend({text:"title",blurClass:"showprompt"},C);var D={title:function(F){return A(F).attr("title")},label:function(F){return A("label[for="+F.id+"]").text()}};var E;var B=A(this);return A(this).each(function(){if(typeof C.text==="string"){E=D[C.text]}else{E=C.text}if(typeof E!=="function"){return }var G=E(this);if(!G){return }A(this).data("label",E(this).replace(/\n/g,""));A(this).focus(function(){if(A(this).val()===A(this).data("label")){A(this).val("").removeClass(C.blurClass)}}).blur(function(){if(A(this).val()===""){A(this).addClass(C.blurClass).val(A(this).data("label"))}});var F=function(){B.each(function(){if(A(this).hasClass(C.blurClass)&&A(this).val()===A(this).data("label")){A(this).removeClass(C.blurClass).val("")}})};A(this.form).submit(F);A(window).unload(F);if(A(this).val()!==""){return }A(this).addClass(C.blurClass).val(A(this).data("label"))})}})})(jQuery);jQuery.cookie=function(B,I,L){if(typeof I!="undefined"){L=L||{};if(I===null){I="";L.expires=-1}var E="";if(L.expires&&(typeof L.expires=="number"||L.expires.toUTCString)){var F;if(typeof L.expires=="number"){F=new Date();F.setTime(F.getTime()+(L.expires*24*60*60*1000))}else{F=L.expires}E="; expires="+F.toUTCString()}var K=L.path?"; path="+L.path:"";var G=L.domain?"; domain="+L.domain:"";var A=L.secure?"; secure":"";document.cookie=[B,"=",encodeURIComponent(I),E,K,G,A].join("")}else{var D=null;if(document.cookie&&document.cookie!=""){var J=document.cookie.split(";");for(var H=0;H<J.length;H++){var C=jQuery.trim(J[H]);if(C.substring(0,B.length+1)==(B+"=")){D=decodeURIComponent(C.substring(B.length+1));break}}}return D}};(function(C){function A(D){if(D.attr("title")||typeof (D.attr("original-title"))!="string"){D.attr("original-title",D.attr("title")||"").removeAttr("title")}}function B(E,D){this.$element=C(E);this.options=D;this.enabled=true;A(this.$element)}B.prototype={show:function(){var G=this.getTitle();if(G&&this.enabled){var F=this.tip();F.find(".tipsy-inner")[this.options.html?"html":"text"](G);if(this.options.textStyle){F.find(".tipsy-inner").css(this.options.textStyle)}F[0].className="tipsy";F.remove().css({top:0,left:0,width:this.options.width?this.options.width+"px":"auto",visibility:"hidden",display:"block"}).appendTo(document.body);var J=C.extend({},this.$element.offset(),{width:this.$element[0].offsetWidth,height:this.$element[0].offsetHeight});var D=F[0].offsetWidth,I=F[0].offsetHeight;var H=(typeof this.options.gravity=="function")?this.options.gravity.call(this.$element[0]):this.options.gravity;var E;switch(H.charAt(0)){case"n":E={top:J.top+J.height+this.options.offset,left:J.left+J.width/2-D/2};break;case"s":E={top:J.top-I-this.options.offset,left:J.left+J.width/2-D/2};break;case"e":E={top:J.top+J.height/2-I/2,left:J.left-D-this.options.offset};break;case"w":E={top:J.top+J.height/2-I/2,left:J.left+J.width+this.options.offset};break}if(H.length==2){if(H.charAt(1)=="w"){E.left=J.left+J.width/2-15}else{E.left=J.left+J.width/2-D+15}}F.css(E).addClass("tipsy-"+H);if(this.options.fade){F.stop().css({opacity:0,display:"block",visibility:"visible"}).animate({opacity:this.options.opacity})}else{F.css({visibility:"visible",opacity:this.options.opacity})}}},hide:function(){if(this.options.fade){this.tip().stop().fadeOut(function(){C(this).remove()})}else{this.tip().remove()}},getTitle:function(){var F,D=this.$element,E=this.options;A(D);var F,E=this.options;if(typeof E.title=="string"){F=D.attr(E.title=="title"?"original-title":E.title)}else{if(typeof E.title=="function"){F=E.title.call(D[0])}}F=(""+F).replace(/(^\s*|\s*$)/,"");return F||E.fallback},tip:function(){if(!this.$tip){this.$tip=C('<div class="tipsy"></div>').html('<div class="tipsy-arrow"></div><div class="tipsy-inner"/></div>')}return this.$tip},validate:function(){if(!this.$element[0].parentNode){this.hide();this.$element=null;this.options=null}},enable:function(){this.enabled=true},disable:function(){this.enabled=false},toggleEnabled:function(){this.enabled=!this.enabled}};C.fn.tipsy=function(H){if(H===true){return this.data("tipsy")}else{if(typeof H=="string"){return this.data("tipsy")[H]()}}H=C.extend({},C.fn.tipsy.defaults,H);function G(K){var L=C.data(K,"tipsy");if(!L){L=new B(K,C.fn.tipsy.elementOptions(K,H));C.data(K,"tipsy",L)}return L}function J(){var K=G(this);K.hoverState="in";if(H.delayIn==0){K.show()}else{setTimeout(function(){if(K.hoverState=="in"){K.show()}},H.delayIn)}}function F(){var K=G(this);K.hoverState="out";if(H.delayOut==0){K.hide()}else{setTimeout(function(){if(K.hoverState=="out"){K.hide()}},H.delayOut)}}if(!H.live){this.each(function(){G(this)})}if(H.trigger!="manual"){var D=H.live?"live":"bind",I=H.trigger=="hover"?"mouseenter":"focus",E=H.trigger=="hover"?"mouseleave":"blur";this[D](I,J)[D](E,F)}return this};C.fn.tipsy.defaults={delayIn:0,delayOut:0,fade:false,fallback:"",gravity:"n",html:false,live:false,offset:0,opacity:0.8,title:"title",trigger:"hover",width:0,textStyle:""};C.fn.tipsy.elementOptions=function(E,D){return C.metadata?C.extend({},D,C(E).metadata()):D};C.fn.tipsy.autoNS=function(){return C(this).offset().top>(C(document).scrollTop()+C(window).height()/2)?"s":"n"};C.fn.tipsy.autoWE=function(){return C(this).offset().left>(C(document).scrollLeft()+C(window).width()/2)?"e":"w"}})(jQuery);(function(C,A,B,D){C.fn.caret=function(S,O){var F,I,Q=this[0],K=C.browser.msie;if(typeof S==="object"&&typeof S.start==="number"&&typeof S.end==="number"){F=S.start;I=S.end}else{if(typeof S==="number"&&typeof O==="number"){F=S;I=O}else{if(typeof S==="string"){if((F=Q.value.indexOf(S))>-1){I=F+S[A]}else{F=null}}else{if(Object.prototype.toString.call(S)==="[object RegExp]"){var P=S.exec(Q.value);if(P!=null){F=P.index;I=F+P[0][A]}}}}}if(typeof F!="undefined"){if(K){var L=this[0].createTextRange();L.collapse(true);L.moveStart("character",F);L.moveEnd("character",I-F);L.select()}else{this[0].selectionStart=F;this[0].selectionEnd=I}this[0].focus();return this}else{if(K){var N=document.selection;if(this[0].tagName.toLowerCase()!="textarea"){var G=this.val(),J=N[B]()[D]();J.moveEnd("character",G[A]);var R=(J.text==""?G[A]:G.lastIndexOf(J.text));J=N[B]()[D]();J.moveStart("character",-G[A]);var M=J.text[A]}else{var J=N[B](),E=J[D]();E.moveToElementText(this[0]);E.setEndPoint("EndToEnd",J);var R=E.text[A]-J.text[A],M=R+J.text[A]}}else{var R=Q.selectionStart,M=Q.selectionEnd}var H=Q.value.substring(R,M);return{start:R,end:M,text:H,replace:function(T){return Q.value.substring(0,R)+T+Q.value.substring(M,Q.value[A])}}}}})(jQuery,"length","createRange","duplicate");function isArray(A){return A&&typeof A==="object"&&typeof A.length==="number"&&!(A.propertyIsEnumerable("length"))}function getButton(B,A,D,C){return'<div class="buttons"><input class="btnredsmall" type="submit" name="'+B+'" id="'+B+'" value="'+A+'" style=" width:'+C+'px;" '+(D!=null?'onclick="'+D+'"':"")+' /><div class="btnredsmallEnding"></div></div>'}function getDialogHTML(J,D,I,F,G,C){var E='<table border="0" cellpadding="0" cellspacing="0" id="dialogtable" style="z-index: 9999; width=auto"><tbody><tr><td class="popup_shadow popup_top_left"><div class="popup_background"><table cellspacing="0" cellpadding="0" class="dialogtable" width="'+J+'" height="'+D+'"><tr><td class="dialogtitle" height="40" width="'+(J-16)+'">'+I+"</td>";if(C){E+='<td class="dialogtitle" style="height:30px; width:10px; vertical-align:top; text-align:right"><a href="javascript:closeDialog();"><b>X</b></a></td>'}var A=80;if(G!=null&&G!=""){A=140}E+='</tr><tr><td class="dialogcontent" colspan="2" id="dialogcontent">'+F+"</td></tr>";if(G!=null&&G!=""){var H='<table class="dialogtable" style="margin: 0 auto;" height="30px"><tr>';for(var B=0;B<G.length;B++){if(B>0){H=H+'<td width="60">&nbsp;</td>'}H=H+"<td>"+G[B]+"</td>"}H+="</tr></table>";E+='<tr><td class="dialogbottom" colspan="2">'+H+"</td></tr>"}E+='</table></div></td><td class="popup_shadow popup_top_right">&nbsp;</td></tr><tr><td class="popup_shadow popup_bottom_left">&nbsp;</td><td class="popup_shadow popup_bottom_right">&nbsp;</td></tr></tbody></table>';return E}function getAdvertisementHTML(J,D,I,F,G,C){var E='<table border="0" cellpadding="0" cellspacing="0" id="dialogtable" style="z-index: 9999; width=auto"><tbody><tr><td class="popup_shadow popup_top_left"><div class="popup_background"><table cellspacing="0" cellpadding="0" class="dialogtable" width="'+J+'" height="'+D+'"><tr><td class="dialogtitle" height="40" width="'+(J-16)+'">'+I+"</td>";if(C){E+='<td class="dialogtitle" style="height:30px; width:10px; vertical-align:top; text-align:right"><a href="javascript:closeDialog();">X</a></td>'}var A=80;if(G!=null&&G!=""){A=140}E+='</tr><tr><td class="dialogcontent" colspan="2" id="dialogcontent" style="padding:5px !important">'+F+"</td></tr>";if(G!=null&&G!=""){var H='<table class="dialogtable" style="margin: 0 auto;" height="30px"><tr>';for(var B=0;B<G.length;B++){if(B>0){H=H+'<td width="60">&nbsp;</td>'}H=H+"<td>"+G[B]+"</td>"}H+="</tr></table>";E+='<tr><td class="dialogbottom" colspan="2">'+H+"</td></tr>"}E+='</table></div></td><td class="popup_shadow popup_top_right">&nbsp;</td></tr><tr><td class="popup_shadow popup_bottom_left">&nbsp;</td><td class="popup_shadow popup_bottom_right">&nbsp;</td></tr></tbody></table>';return E}function openDialog(A,B,E,D,C,F){if($("#pg_dialog")[0]==null){$('<div id="pg_dialog" style="display:none; cursor: default"></div>').appendTo("body")}$.extend($.blockUI.defaults.overlayCSS,{opacity:0.2});$.extend($.blockUI.defaults.css,{backgroundColor:"transparent"});$.blockUI.defaults.fadeIn=0;$.blockUI({message:$("#pg_dialog"),css:{border:"0px solid #333",width:A+"px",height:B+"px",margin:"-"+((B+50)/2)+"px 0 0 -"+((A+40)/2)+"px",top:"50%",left:"50%"}});if(D!=null&&D!=""){$("#pg_dialog").html(getDialogHTML(A,B,E,D,C,F))}}function loadDialog(B,D,F,C,E,G,A){if(G==null){G=true}openDialog(B,D,F,'<h3 style="margin-top:'+((D-100)/2)+'px">Please wait...</h3></div>',null);$.get(C,function(H){$("#pg_dialog").html(getDialogHTML(B,D,F,H,E,G));if(A!=false){recenterDialog()}})}function recenterDialog(){var B=$("#pg_dialog").height();var A=$("#pg_dialog").width();$(".blockUI.blockMsg").css({"margin":"-"+((B)/2)+"px 0 0 -"+((A+40)/2)+"px","top":"50%","left":"50%"})}function loadAdvertisement(A,C,D,B){openDialog(A,C,D,"<h3>Please wait...</h3>",null);$.get(B,function(E){$("#pg_dialog").html(getAdvertisementHTML(A,C,D,E,null,true))})}function openImageDialog(A,B,C,D){openDialog(A,B,"",'<img src="'+C+'" />',null,true);if(typeof D!="undefined"){$("#"+D).clone().prependTo($("#dialogcontent")).show()}}function openFloorPlanImageDialog(A,B,C,E,D){openDialog(A,B,D,'<img src="'+C+'" />',null,true);if(typeof E!="undefined"){$("#"+E).clone().prependTo($("#dialogcontent")).show()}}function openMovieDialog(A,C,D,B){if(B=="htm"){openDialog(A,C,"",D,null,true)}}function submitDialogForm(A){$(A).ajaxSubmit({target:"#dialogcontent",beforeSubmit:preSubmit,success:formResult});return false}function preSubmit(){$("#dialogcontent").html("<h3>Please wait...</h3>");return true}function formResult(){recenterDialog()}function openMessageBox(B,A){openDialog(300,200,B,A,new Array(getButton("btn_ok","ok","closeDialog();",60)),true)}function openBigMessageBox(B,A,D,C){openDialog(B,A,D,C,new Array(getButton("btn_ok","ok","closeDialog();",60)),true)}function busyDialog(B){var A="Please wait ...<br/><br/><img src=\"/images/busy.gif\"/><br /><div class='floatright'><a href='javascript:closeDialog()'>[cancel]</a></div>";openDialog(200,150,B,A,"",false)}function errorDialog(A){openDialog(300,150,"ERROR ENCOUNTERED",A,new Array(getButton("btn_ok","ok","closeDialog();",60)),true)}function closeDialog(){$.unblockUI();$("#pg_dialog").remove()}function getRadioValue(C,A){var D=document.forms[C];if(D){D=D.elements[A]}if(D){if(typeof D.length=="undefined"){D=[D]}for(var B=0;B<D.length;B++){if(D[B].checked){return D[B].value}}}return null}function addShortlist(B){busyDialog("Adding to Shortlist");var A="/ps_xmlhttp_addshortlist?id="+B;$.getJSON(A,function(E){$("#shortlist_count").html(E.size).show();$("#shortlist_btn_"+B).html("Shortlisted").addClass("greybold");closeDialog();if(!E.logged&&E.size==1){var D="<div class='top10' style='width:100%; text-align:left'>Please <a href=\"javascript:openLoginDialog('/shortlist')\" class='bluelink'>login</a> if you want your shortlist to be saved for future visits.<br><br>Not a "+(REGION=="MY"?"HomeGuru":"PropertyGuru")+" Member yet?<a href=\"javascript:openRegisterDialog('/shortlist')\" class='bluelink'>Register now</a> so you don't lose your shortlist once you close your browser.</div>";var C=["<div class='buttons'><input type='button' name='close' value='CLOSE' class='btnredsmall' onclick='closeDialog()' /><div class='btnredsmallEnding'/></div>"];openDialog(350,200,"Tip for Shortlisting",D,C,1)}})}function offensive(A){busyDialog("Submitting your Report");$.ajax({type:"POST",url:"/ps_project_review?id="+A+"&reportOffensive=true",async:true,success:function(B){$("#reportOffensive_"+A).html("<b>Your report has been submitted successfully.</b>");closeDialog()}})}var popup_current_data=null;function listPopup(B,G,F,E,H,A){popup_current_data=G;var C='<p class="alignleft left10 bottom10">'+B+'</p><form name="popup_form"><fieldset><div style="width:660px;margin:0 auto;height:320px;overflow-y:auto;overflow-x:hidden"><table class="table1" style="width:100%">';$.each(G,function(J,K){var L="";if(J%2){L=' class="alt"'}C=C+"<tr><td"+L+'><input type="radio" id="popup_id_'+J+'" name="popup_id" value="'+J+'"/></td>';for(var I=0;I<E.length;I++){C=C+"<td"+L+">";if(typeof A!="undefined"&&I==0){C=C+'<label style="padding:0" for="popup_id_'+J+'">'+A(K[E[I]])+"</label>"}else{if(K[E[I]]!=null){C=C+'<label style="padding:0" for="popup_id_'+J+'">'+K[E[I]]+"</label>"}}C=C+"</td>"}C=C+"</tr>"});C=C+"</table></div><fieldset></form>";var D=[getButton("popup_select","Select",null,120),getButton("popup_none","Not Found",null,120)];openDialog(700,420,"Search Results",C,D,true);$("#popup_select").click(function(){var I=getRadioValue("popup_form","popup_id");closeDialog();H(popup_current_data[I])});$("#popup_none").click(function(){closeDialog();H("N/A")})}function help(A){loadDialog(500,400,'<img src="/images/icons/help.png"/>&nbsp;Help',"/ps_dialog_help?id="+A)}function truncate(B,A){return(B.length<=A)?B:B.substr(0,A-3)+"..."}function cancelProp(A){A.cancelBubble=true;if(A.stopPropagation){A.stopPropagation()}}function forceNumber(A){$(A).keyup(function(D){var B=$(A).caret().start;var C=$(A).val().length;$(A).val(formatNumber($(A).val().replace(/[^\d]/g,"")));if(C==$(A).val().length){$(A).caret({start:B,end:B})}else{$(A).caret({start:B+($(A).val().length-C),end:B+($(A).val().length-C)})}});$(A).blur(function(B){$(A).val(formatNumber($(A).val().replace(/[^\d]/g,"")))})}function formatNumber(C){var A=C;while(A.indexOf(",")>=0){A=A.replace(",","")}var B=/(\d+)(\d{3})/;while(B.test(A)){A=A.replace(B,"$1,$2")}return A}function openLoginDialog(A){if(REGION=="MY"){loadDialog(550,300,"Login to HomeGuru.com.my","/login-dialog?redirect="+escape(A))}else{loadDialog(550,300,"Login to PropertyGuru.com.sg","/login-dialog?redirect="+escape(A))}}function openCgLoginDialog(A){loadDialog(550,300,"Login to CommercialGuru.com.sg","/login-dialog?redirect="+escape(A))}function openRegisterDialog(A){closeDialog();if(REGION=="MY"){loadDialog(550,525,"Register with HomeGuru.com.my","/register-dialog?redirect="+escape(A))}else{loadDialog(550,525,"Register with PropertyGuru.com.sg","/register-dialog?redirect="+escape(A))}}function openCgRegisterDialog(A){closeDialog();loadDialog(550,525,"Register with CommercialGuru.com.sg","/register-dialog?redirect="+escape(A))}function changeItemsPerPage(){var B=$("#items_per_page").val();var A=changeParameter("items_per_page",B);document.location.search=A}function changeSortOrder(){var B=document.getElementById("quicksort").selectedIndex;var D=document.getElementById("quicksort").value;var A=document.getElementById("quicksort").options[B].getAttribute("name");var C;C=changeParameter("sort",D);C=changeParameter("order",A,C);document.location.search=C}function changeParameter(A,E,D){var C;if(typeof D=="undefined"){C=document.location.search}else{C=D}var F=A+"="+E;if(!C.length){C="?"+F}else{var B=new RegExp("(&|\\?)"+A+"=[^&]*");C=C.replace(B,"$1"+F);if(!RegExp.$1){C+=(C.length>0?"&":"?")+F}}return C}function submit_filter(A){var D=A.split("=")[0];var B=new RegExp("(&|\\?)"+D+"=[^&]*");var C=document.location.search;if(!C.length){C="?"+A}else{C=C.replace(B,"$1"+A);if(!RegExp.$1){C+=(C.length>0?"&":"?")+A}}document.location.search=C}this.tooltip=function(){xOffset=10;yOffset=20;$("a.tooltip").hover(function(A){this.t=this.title;this.title="";$("body").append("<p id='tooltip'>"+this.t+"</p>");$("#tooltip").css("top",(A.pageY-xOffset)+"px").css("left",(A.pageX+yOffset)+"px").fadeIn("fast")},function(){this.title=this.t;$("#tooltip").remove()});$("a.tooltip").mousemove(function(A){$("#tooltip").css("top",(A.pageY-xOffset)+"px").css("left",(A.pageX+yOffset)+"px")})};$(document).ready(function(){$("#items_per_page").change(function(){changeItemsPerPage()});$("#quicksort").change(function(){changeSortOrder()})});function urlsafe(E){var B=0;var A="";var D="";var C=E.length;var F="";for(i=0;i<C&&B<50;i++){F=strtolower(E.charAt(i));if(isalphanumeric(F)){A+=F;D=F;B++}else{if(D!="-"){A+="-";D="-";B++}}}return A}function strtolower(A){return(A+"").toLowerCase()}function substr(B,C,A){return B.substr(C,A)}function isalphanumeric(B){var A=/^[a-zA-Z_0-9]$/;if(A.test(B)){return true}}function strip_tags(G,H){var K="",I=false;var F=[];var A=[];var J="";var D=0;var C="";var E="";var B=function(M,L,N){return N.split(M).join(L)};if(H){A=H.match(/([a-zA-Z0-9]+)/gi)}G+="";F=G.match(/(<\/?[\S][^>]*>)/gi);for(K in F){if(isNaN(K)){continue}E=F[K].toString();I=false;for(C in A){J=A[C];D=-1;if(D!=0){D=E.toLowerCase().indexOf("<"+J+">")}if(D!=0){D=E.toLowerCase().indexOf("<"+J+" ")}if(D!=0){D=E.toLowerCase().indexOf("</"+J)}if(D==0){I=true;break}}if(!I){G=B(E,"",G)}}return G}function ucwords(B){var A=strtolower(B);return(A+"").replace(/^(.)|\s(.)/g,function(C){return C.toUpperCase()})}function number_format(F,C,H,E){F=(F+"").replace(",","").replace(" ","");var B=!isFinite(+F)?0:+F,A=!isFinite(+C)?0:Math.abs(C),J=(typeof E==="undefined")?",":E,D=(typeof H==="undefined")?".":H,I="",G=function(M,L){var K=Math.pow(10,L);return""+Math.round(M*K)/K};I=(A?G(B,A):""+Math.round(B)).split(".");if(I[0].length>3){I[0]=I[0].replace(/\B(?=(?:\d{3})+(?!\d))/g,J)}if((I[1]||"").length<A){I[1]=I[1]||"";I[1]+=new Array(A-I[1].length+1).join("0")}return I.join(D)}$(document).ready(function(){mainmenu();mainmenu2();mainmenu3()});function mainmenu(){$("#nav ul").hide();$("#nav li").hover(function(){$(this).find("ul:first:hidden").show(100)},function(){$(this).find("ul:first").stop(true,true).hide()})}function mainmenu2(){$("#navigation ul ul").hide();$("#navigation ul li").hover(function(){$(this).find("ul:first:hidden").show(100)},function(){$(this).find("ul:first").stop(true,true).hide()})}function mainmenu3(){$("#slatenav ul ul").hide();$("#slatenav ul li").hover(function(){$(this).find("ul:first:hidden").show(100)},function(){$(this).find("ul:first").stop(true,true).hide()})}(function(B){B.fn.jcarousel=function(D){return this.each(function(){new A(this,D)})};var C={vertical:false,start:1,offset:1,size:1,scroll:3,visible:null,animation:"normal",easing:"swing",auto:0,wrap:null,initCallback:null,reloadCallback:null,itemLoadCallback:null,itemFirstInCallback:null,itemFirstOutCallback:null,itemLastInCallback:null,itemLastOutCallback:null,itemVisibleInCallback:null,itemVisibleOutCallback:null,buttonNextHTML:"<div></div>",buttonPrevHTML:"<div></div>",buttonNextEvent:"click",buttonPrevEvent:"click",buttonNextCallback:null,buttonPrevCallback:null};B.jcarousel=function(G,E){this.options=B.extend({},C,E||{});this.locked=false;this.container=null;this.clip=null;this.list=null;this.buttonNext=null;this.buttonPrev=null;this.wh=!this.options.vertical?"width":"height";this.lt=!this.options.vertical?"left":"top";var K="",I=G.className.split(" ");for(var F=0;F<I.length;F++){if(I[F].indexOf("jcarousel-skin")!=-1){B(G).removeClass(I[F]);var K=I[F];break}}if(G.nodeName=="UL"||G.nodeName=="OL"){this.list=B(G);this.container=this.list.parent();if(this.container.hasClass("jcarousel-clip")){if(!this.container.parent().hasClass("jcarousel-container")){this.container=this.container.wrap("<div></div>")}this.container=this.container.parent()}else{if(!this.container.hasClass("jcarousel-container")){this.container=this.list.wrap("<div></div>").parent()}}}else{this.container=B(G);this.list=B(G).find(">ul,>ol,div>ul,div>ol")}if(K!=""&&this.container.parent()[0].className.indexOf("jcarousel-skin")==-1){this.container.wrap('<div class=" '+K+'"></div>')}this.clip=this.list.parent();if(!this.clip.length||!this.clip.hasClass("jcarousel-clip")){this.clip=this.list.wrap("<div></div>").parent()}this.buttonPrev=B(".jcarousel-prev",this.container);if(this.buttonPrev.size()==0&&this.options.buttonPrevHTML!=null){this.buttonPrev=this.clip.before(this.options.buttonPrevHTML).prev()}this.buttonPrev.addClass(this.className("jcarousel-prev"));this.buttonNext=B(".jcarousel-next",this.container);if(this.buttonNext.size()==0&&this.options.buttonNextHTML!=null){this.buttonNext=this.clip.before(this.options.buttonNextHTML).prev()}this.buttonNext.addClass(this.className("jcarousel-next"));this.clip.addClass(this.className("jcarousel-clip"));this.list.addClass(this.className("jcarousel-list"));this.container.addClass(this.className("jcarousel-container"));var H=this.options.visible!=null?Math.ceil(this.clipping()/this.options.visible):null;var J=this.list.children("li");var L=this;if(J.size()>0){var D=0,F=this.options.offset;J.each(function(){L.format(this,F++);D+=L.dimension(this,H)});this.list.css(this.wh,D+"px");if(!E||E.size===undefined){this.options.size=J.size()}}this.container.css("display","block");this.buttonNext.css("display","block");this.buttonPrev.css("display","block");this.funcNext=function(){L.next()};this.funcPrev=function(){L.prev()};this.funcResize=function(){L.reload()};if(this.options.initCallback!=null){this.options.initCallback(this,"init")}if(B.browser.safari){this.buttons(false,false);B(window).bind("load",function(){L.setup()})}else{this.setup()}};var A=B.jcarousel;A.fn=A.prototype={jcarousel:"0.2.3"};A.fn.extend=A.extend=B.extend;A.fn.extend({setup:function(){this.first=null;this.last=null;this.prevFirst=null;this.prevLast=null;this.animating=false;this.timer=null;this.tail=null;this.inTail=false;if(this.locked){return }this.list.css(this.lt,this.pos(this.options.offset)+"px");var D=this.pos(this.options.start);this.prevFirst=this.prevLast=null;this.animate(D,false);B(window).unbind("resize",this.funcResize).bind("resize",this.funcResize)},reset:function(){this.list.empty();this.list.css(this.lt,"0px");this.list.css(this.wh,"10px");if(this.options.initCallback!=null){this.options.initCallback(this,"reset")}this.setup()},reload:function(){if(this.tail!=null&&this.inTail){this.list.css(this.lt,A.intval(this.list.css(this.lt))+this.tail)}this.tail=null;this.inTail=false;if(this.options.reloadCallback!=null){this.options.reloadCallback(this)}if(this.options.visible!=null){var F=this;var G=Math.ceil(this.clipping()/this.options.visible),E=0,D=0;B("li",this.list).each(function(H){E+=F.dimension(this,G);if(H+1<F.first){D=E}});this.list.css(this.wh,E+"px");this.list.css(this.lt,-D+"px")}this.scroll(this.first,false)},lock:function(){this.locked=true;this.buttons()},unlock:function(){this.locked=false;this.buttons()},size:function(D){if(D!=undefined){this.options.size=D;if(!this.locked){this.buttons()}}return this.options.size},has:function(E,F){if(F==undefined||!F){F=E}if(this.options.size!==null&&F>this.options.size){F=this.options.size}for(var D=E;D<=F;D++){var G=this.get(D);if(!G.length||G.hasClass("jcarousel-item-placeholder")){return false}}return true},get:function(D){return B(".jcarousel-item-"+D,this.list)},add:function(G,L){var H=this.get(G),E=0,K=0;if(H.length==0){var J,H=this.create(G),F=A.intval(G);while(J=this.get(--F)){if(F<=0||J.length){F<=0?this.list.prepend(H):J.after(H);break}}}else{E=this.dimension(H)}H.removeClass(this.className("jcarousel-item-placeholder"));typeof L=="string"?H.html(L):H.empty().append(L);var I=this.options.visible!=null?Math.ceil(this.clipping()/this.options.visible):null;var D=this.dimension(H,I)-E;if(G>0&&G<this.first){this.list.css(this.lt,A.intval(this.list.css(this.lt))-D+"px")}this.list.css(this.wh,A.intval(this.list.css(this.wh))+D+"px");return H},remove:function(D){var E=this.get(D);if(!E.length||(D>=this.first&&D<=this.last)){return }var F=this.dimension(E);if(D<this.first){this.list.css(this.lt,A.intval(this.list.css(this.lt))+F+"px")}E.remove();this.list.css(this.wh,A.intval(this.list.css(this.wh))-F+"px")},next:function(){this.stopAuto();if(this.tail!=null&&!this.inTail){this.scrollTail(false)}else{this.scroll(((this.options.wrap=="both"||this.options.wrap=="last")&&this.options.size!=null&&this.last==this.options.size)?1:this.first+this.options.scroll)}},prev:function(){this.stopAuto();if(this.tail!=null&&this.inTail){this.scrollTail(true)}else{this.scroll(((this.options.wrap=="both"||this.options.wrap=="first")&&this.options.size!=null&&this.first==1)?this.options.size:this.first-this.options.scroll)}},scrollTail:function(D){if(this.locked||this.animating||!this.tail){return }var E=A.intval(this.list.css(this.lt));!D?E-=this.tail:E+=this.tail;this.inTail=!D;this.prevFirst=this.first;this.prevLast=this.last;this.animate(E)},scroll:function(E,D){if(this.locked||this.animating){return }this.animate(this.pos(E),D)},pos:function(Q){if(this.locked||this.animating){return }if(this.options.wrap!="circular"){Q=Q<1?1:(this.options.size&&Q>this.options.size?this.options.size:Q)}var N=this.first>Q;var E=A.intval(this.list.css(this.lt));var R=this.options.wrap!="circular"&&this.first<=1?1:this.first;var U=N?this.get(R):this.get(this.last);var P=N?R:R-1;var S=null,O=0,L=false,T=0;while(N?--P>=Q:++P<Q){S=this.get(P);L=!S.length;if(S.length==0){S=this.create(P).addClass(this.className("jcarousel-item-placeholder"));U[N?"before":"after"](S)}U=S;T=this.dimension(S);if(L){O+=T}if(this.first!=null&&(this.options.wrap=="circular"||(P>=1&&(this.options.size==null||P<=this.options.size)))){E=N?E+T:E-T}}var I=this.clipping();var K=[];var D=0,P=Q,J=0;var U=this.get(Q-1);while(++D){S=this.get(P);L=!S.length;if(S.length==0){S=this.create(P).addClass(this.className("jcarousel-item-placeholder"));U.length==0?this.list.prepend(S):U[N?"before":"after"](S)}U=S;var T=this.dimension(S);if(T==0){alert("jCarousel: No width/height set for items. This will cause an infinite loop. Aborting...");return 0}if(this.options.wrap!="circular"&&this.options.size!==null&&P>this.options.size){K.push(S)}else{if(L){O+=T}}J+=T;if(J>=I){break}P++}for(var H=0;H<K.length;H++){K[H].remove()}if(O>0){this.list.css(this.wh,this.dimension(this.list)+O+"px");if(N){E-=O;this.list.css(this.lt,A.intval(this.list.css(this.lt))-O+"px")}}var G=Q+D-1;if(this.options.wrap!="circular"&&this.options.size&&G>this.options.size){G=this.options.size}if(P>G){D=0,P=G,J=0;while(++D){var S=this.get(P--);if(!S.length){break}J+=this.dimension(S);if(J>=I){break}}}var F=G-D+1;if(this.options.wrap!="circular"&&F<1){F=1}if(this.inTail&&N){E+=this.tail;this.inTail=false}this.tail=null;if(this.options.wrap!="circular"&&G==this.options.size&&(G-D+1)>=1){var M=A.margin(this.get(G),!this.options.vertical?"marginRight":"marginBottom");if((J-M)>I){this.tail=J-I-M}}while(Q-->F){E+=this.dimension(this.get(Q))}this.prevFirst=this.first;this.prevLast=this.last;this.first=F;this.last=G;return E},animate:function(G,D){if(this.locked||this.animating){return }this.animating=true;var E=this;var F=function(){E.animating=false;if(G==0){E.list.css(E.lt,0)}if(E.options.wrap=="both"||E.options.wrap=="last"||E.options.size==null||E.last<E.options.size){E.startAuto()}E.buttons();E.notify("onAfterAnimation")};this.notify("onBeforeAnimation");if(!this.options.animation||D==false){this.list.css(this.lt,G+"px");F()}else{var H=!this.options.vertical?{"left":G}:{"top":G};this.list.animate(H,this.options.animation,this.options.easing,F)}},startAuto:function(E){if(E!=undefined){this.options.auto=E}if(this.options.auto==0){return this.stopAuto()}if(this.timer!=null){return }var D=this;this.timer=setTimeout(function(){D.next()},this.options.auto*1000)},stopAuto:function(){if(this.timer==null){return }clearTimeout(this.timer);this.timer=null},buttons:function(F,E){if(F==undefined||F==null){var F=!this.locked&&this.options.size!==0&&((this.options.wrap&&this.options.wrap!="first")||this.options.size==null||this.last<this.options.size);if(!this.locked&&(!this.options.wrap||this.options.wrap=="first")&&this.options.size!=null&&this.last>=this.options.size){F=this.tail!=null&&!this.inTail}}if(E==undefined||E==null){var E=!this.locked&&this.options.size!==0&&((this.options.wrap&&this.options.wrap!="last")||this.first>1);if(!this.locked&&(!this.options.wrap||this.options.wrap=="last")&&this.options.size!=null&&this.first==1){E=this.tail!=null&&this.inTail}}var D=this;this.buttonNext[F?"bind":"unbind"](this.options.buttonNextEvent,this.funcNext)[F?"removeClass":"addClass"](this.className("jcarousel-next-disabled")).attr("disabled",F?false:true);this.buttonPrev[E?"bind":"unbind"](this.options.buttonPrevEvent,this.funcPrev)[E?"removeClass":"addClass"](this.className("jcarousel-prev-disabled")).attr("disabled",E?false:true);if(this.buttonNext.length>0&&(this.buttonNext[0].jcarouselstate==undefined||this.buttonNext[0].jcarouselstate!=F)&&this.options.buttonNextCallback!=null){this.buttonNext.each(function(){D.options.buttonNextCallback(D,this,F)});this.buttonNext[0].jcarouselstate=F}if(this.buttonPrev.length>0&&(this.buttonPrev[0].jcarouselstate==undefined||this.buttonPrev[0].jcarouselstate!=E)&&this.options.buttonPrevCallback!=null){this.buttonPrev.each(function(){D.options.buttonPrevCallback(D,this,E)});this.buttonPrev[0].jcarouselstate=E}},notify:function(D){var E=this.prevFirst==null?"init":(this.prevFirst<this.first?"next":"prev");this.callback("itemLoadCallback",D,E);if(this.prevFirst!==this.first){this.callback("itemFirstInCallback",D,E,this.first);this.callback("itemFirstOutCallback",D,E,this.prevFirst)}if(this.prevLast!==this.last){this.callback("itemLastInCallback",D,E,this.last);this.callback("itemLastOutCallback",D,E,this.prevLast)}this.callback("itemVisibleInCallback",D,E,this.first,this.last,this.prevFirst,this.prevLast);this.callback("itemVisibleOutCallback",D,E,this.prevFirst,this.prevLast,this.first,this.last)},callback:function(H,K,D,I,G,F,E){if(this.options[H]==undefined||(typeof this.options[H]!="object"&&K!="onAfterAnimation")){return }var L=typeof this.options[H]=="object"?this.options[H][K]:this.options[H];if(!B.isFunction(L)){return }var M=this;if(I===undefined){L(M,D,K)}else{if(G===undefined){this.get(I).each(function(){L(M,this,I,D,K)})}else{for(var J=I;J<=G;J++){if(J!==null&&!(J>=F&&J<=E)){this.get(J).each(function(){L(M,this,J,D,K)})}}}}},create:function(D){return this.format("<li></li>",D)},format:function(F,E){var D=B(F).addClass(this.className("jcarousel-item")).addClass(this.className("jcarousel-item-"+E));D.attr("jcarouselindex",E);return D},className:function(D){return D+" "+D+(!this.options.vertical?"-horizontal":"-vertical")},dimension:function(G,H){var F=G.jquery!=undefined?G[0]:G;var E=!this.options.vertical?F.offsetWidth+A.margin(F,"marginLeft")+A.margin(F,"marginRight"):F.offsetHeight+A.margin(F,"marginTop")+A.margin(F,"marginBottom");if(H==undefined||E==H){return E}var D=!this.options.vertical?H-A.margin(F,"marginLeft")-A.margin(F,"marginRight"):H-A.margin(F,"marginTop")-A.margin(F,"marginBottom");B(F).css(this.wh,D+"px");return this.dimension(F)},clipping:function(){return !this.options.vertical?this.clip[0].offsetWidth-A.intval(this.clip.css("borderLeftWidth"))-A.intval(this.clip.css("borderRightWidth")):this.clip[0].offsetHeight-A.intval(this.clip.css("borderTopWidth"))-A.intval(this.clip.css("borderBottomWidth"))},index:function(D,E){if(E==undefined){E=this.options.size}return Math.round((((D-1)/E)-Math.floor((D-1)/E))*E)+1}});A.extend({defaults:function(D){return B.extend(C,D||{})},margin:function(H,G){if(!H){return 0}var F=H.jquery!=undefined?H[0]:H;if(G=="marginRight"&&B.browser.safari){var E={"display":"block","float":"none","width":"auto"},D,I;B.swap(F,E,function(){D=F.offsetWidth});E["marginRight"]=0;B.swap(F,E,function(){I=F.offsetWidth});return I-D}return A.intval(B.css(F,G))},intval:function(D){D=parseInt(D);return isNaN(D)?0:D}})})(jQuery);function SDMenu(A){if(!document.getElementById||!document.getElementsByTagName){return false}this.menu=document.getElementById(A);this.submenus=this.menu.getElementsByTagName("div");this.remember=true;this.speed=5;this.markCurrent=true;this.oneSmOnly=false}SDMenu.prototype.init=function(){var C=this;for(var E=0;E<this.submenus.length;E++){this.submenus[E].getElementsByTagName("span")[0].onclick=function(){C.toggleMenu(this.parentNode)}}if(this.markCurrent){var B=this.menu.getElementsByTagName("a");for(var E=0;E<B.length;E++){if(B[E].href==document.location.href){B[E].className="current";break}}}if(this.remember){var F=new RegExp("sdmenu_"+encodeURIComponent(this.menu.id)+"=([01]+)");var D=F.exec(document.cookie);if(D){var A=D[1].split("");for(var E=0;E<A.length;E++){this.submenus[E].className=(A[E]==0?"collapsed":"")}}}};SDMenu.prototype.toggleMenu=function(A){if(A.className=="collapsed"){this.expandMenu(A)}else{this.collapseMenu(A)}};SDMenu.prototype.expandMenu=function(F){var D=F.getElementsByTagName("span")[0].offsetHeight;var C=F.getElementsByTagName("a");for(var E=0;E<C.length;E++){D+=C[E].offsetHeight}var G=Math.round(this.speed*C.length);var B=this;var A=setInterval(function(){var I=F.offsetHeight;var H=I+G;if(H<D){F.style.height=H+"px"}else{clearInterval(A);F.style.height="";F.className="";B.memorize()}},30);this.collapseOthers(F)};SDMenu.prototype.collapseMenu=function(C){var D=C.getElementsByTagName("span")[0].offsetHeight;var E=Math.round(this.speed*C.getElementsByTagName("a").length);var B=this;var A=setInterval(function(){var G=C.offsetHeight;var F=G-E;if(F>D){C.style.height=F+"px"}else{clearInterval(A);C.style.height="";C.className="collapsed";B.memorize()}},30)};SDMenu.prototype.collapseOthers=function(B){if(this.oneSmOnly){for(var A=0;A<this.submenus.length;A++){if(this.submenus[A]!=B&&this.submenus[A].className!="collapsed"){this.collapseMenu(this.submenus[A])}}}};SDMenu.prototype.expandAll=function(){var B=this.oneSmOnly;this.oneSmOnly=false;for(var A=0;A<this.submenus.length;A++){if(this.submenus[A].className=="collapsed"){this.expandMenu(this.submenus[A])}}this.oneSmOnly=B};SDMenu.prototype.collapseAll=function(){for(var A=0;A<this.submenus.length;A++){if(this.submenus[A].className!="collapsed"){this.collapseMenu(this.submenus[A])}}};SDMenu.prototype.memorize=function(){if(this.remember){var A=new Array();for(var B=0;B<this.submenus.length;B++){A.push(this.submenus[B].className=="collapsed"?0:1)}var C=new Date();C.setTime(C.getTime()+(30*24*60*60*1000));document.cookie="sdmenu_"+encodeURIComponent(this.menu.id)+"="+A.join("")+"; expires="+C.toGMTString()+"; path=/"}};var districts;function checkboxList(A,B,C){this.instanceName=A;this.add=addNode;this.render=renderCheckboxList;this.allNodes=new Object;this.tracker=document.getElementById(B);this.containerElementId=C}function node(C,B,A){this.id=C;this.text=B;this.checked=A;this.parentId=null;this.show=expandParent;this.rootInstance=""}function expandParent(){var B=this.parent;while(B){var A=document.getElementById(B.id);A.style.display="block";B=B.parent}}function renderCheckboxList(){var B="";for(var C in this.allNodes){if(!this.allNodes[C].parentId){B+=this.allNodes[C].render(this)}}var A=document.getElementById(this.containerElementId);if(A){A.innerHTML=B}this.updateValue(true)}checkboxList.prototype.updateValue=function(C){var A="";for(var D in this.allNodes){if(this.allNodes[D].checked){if(C){this.allNodes[D].show()}A+=(A==""?"":"|")+this.allNodes[D].id;if(this.allNodes[D].parentId!=null){var B=document.getElementById("span"+this.allNodes[D].parentId);B.style.fontWeight="bold";B.style.color="#0070be";B.style.backgroundColor="#e1f1ff";B.style.padding="1px 5px"}}}districts=A;$("#tracker").val(A)};checkboxList.prototype.toggle=function(D,C){for(var E in this.allNodes){if(this.allNodes[E].id==D){this.allNodes[E].checked=C;if(this.allNodes[E].parentId!=null){if(!C){var A=document.getElementById("span"+this.allNodes[E].parentId);A.style.fontWeight="normal";A.style.color="#000";A.style.backgroundColor="#fff";A.style.padding="0 0"}}break}}for(var E in this.allNodes){if(this.allNodes[E].parentId==D){this.allNodes[E].checked=C;var B=document.getElementById("cb"+this.allNodes[E].id);B.checked=C;setBackground(B)}}this.updateValue(true)};function addNode(E,A,B,D){var C=new node(E,A,B);if(this.allNodes[D]){C.parentId=D}else{C.parentId=null}C.rootInstance=this.instanceName;this.allNodes[C.id]=C}node.prototype.render=function(A){var E=new Array();for(var G in A.allNodes){if(A.allNodes[G].parentId==this.id){E[E.length]=A.allNodes[G].id}}var C=E.length;var F='<span class="node'+(C>0?" nodeParent":"")+'">';F+='<input type="checkbox" id="cb'+this.id+'" ';F+='onClick="'+this.rootInstance+".toggle('"+this.id+"', this.checked)\"";F+=(this.checked?" checked":"")+"> ";F+='<span id="span'+this.id+'"'+(C>0?" onClick=\"showNode('"+this.id+"')\"":"")+">";var D;D=this.id+"-img";if(C>0){this.text='<span id="'+D+'"><img src="/images/pg/open.gif" ></span>&nbsp;'+this.text}else{this.text='<span id="'+D+'"><img src="/images/pg/close.gif" ></span>&nbsp;'+this.text}F+=this.text+"</span>";F+="</span>";if(C>0){F+='<span class="nodeChild" id="'+this.id+'">';for(var B=0;B<C;B++){F+=A.allNodes[E[B]].render(A)}F+="</span>"}return F};function showNode(A){var C=document.getElementById(A).style;var B;B=A+"-img";if(C.display=="block"){C.display="none";document.getElementById(B).innerHTML="<img src='/images/pg/open.gif' >"}else{C.display="block";document.getElementById(B).innerHTML="<img src='/images/pg/close.gif' >"}}function setBackground(C){var D=C.parentNode.parentNode;var B=document.getElementById("span"+D.id);var A=C.checked?"#e1f1ff":"#fff";var F=C.checked?"1px 5px":"0";var E=C.checked?"#0070be":"#000";D.style["backgroundColor"]=A;B.style["backgroundColor"]=A;B.style["padding"]=F;B.style.fontWeight="normal";D.style["color"]=E;B.style["color"]=E}
