(function(C){var B={},E="doTimeout",D=Array.prototype.slice;C[E]=function(){return A.apply(window,[0].concat(D.call(arguments)))};C.fn[E]=function(){var F=D.call(arguments),G=A.apply(this,[E+F[0]].concat(F));return typeof F[0]==="number"||typeof F[1]==="number"?this:G};function A(J){var I=this,N,K={},O=J?C.fn:C,H=arguments,M=4,P=H[1],L=H[2],F=H[3];if(typeof P!=="string"){M--;P=J=0;L=H[1];F=H[2]}if(J){N=I.eq(0);N.data(J,K=N.data(J)||{})}else{if(P){K=B[P]||(B[P]={})}}K.id&&clearTimeout(K.id);delete K.id;function Q(){if(J){N.removeData(J)}else{if(P){delete B[P]}}}function G(){K.id=setTimeout(function(){K.fn()},L)}if(F){K.fn=function(R){if(typeof F==="string"){F=O[F]}F.apply(I,D.call(H,M))===true&&!R?G():Q()};G()}else{if(K.fn){L===undefined?Q():K.fn(L===false);return true}else{Q()}}}})(jQuery);(function(B){var A;var C=0;B.widget("ui.upload",{options:{rotate_url:"/standards/patterns/image-uploader/php/rotate.php",delete_url:"/standards/patterns/image-uploader/php/delete.php",upload_url:"/standards/patterns/image-uploader/php/upload.php",check_url:"/standards/patterns/image-uploader/php/check.php",stylesheet:"/standards/refactor/stylesheets/lib/jquery-ui-upload-1.0.css",poll_interval:1,total_items:18,file_extension:"",iframe:null,upload_button:{mousedown:null,mouseup:null,mouseover:null,mouseout:null}},exceptions:{invalid_response:"A server error occurred. Please try again later.",upload_limit_reached:"You cannot upload more then 18 images."},messages:{0:{time:30,message:"Almost there ..."},1:{time:60,message:"Just a little longer ..."},2:{time:90,message:"Nice weather we're having ..."}},_enable_submit_button:function(E){var D;if(typeof(E)=="undefined"){D=true}else{D=false}if(D){C=C-1}if(C==0){var F=this.element.parent().find("button");F.removeClass("ui-state-disabled").addClass("ui-state-default").removeAttr("disabled","disabled")}},_disable_submit_button:function(){var D=this.element.parent().find("button");D.addClass("ui-state-disabled").removeClass("ui-state-default").attr("disabled","disabled")},_create_tmp_item:function(F){var E=A.options.iframe;A.element.find(".errors").hide();var D=B('<li id="'+F+'" />');D.html(A.element.find(".ui-upload-loading").html());D.find(".ui-upload-cancel").click(function(){A._enable_submit_button();var G=B(this).parent().parent().attr("id");B.doTimeout(G);B(this).parent().parent().remove();if(A.element.find(".ui-upload-list .ui-upload-preview").length==0){A.element.find(".ui-upload-list").hide()}});A.element.find(".ui-upload-list").append(D);if(A.element.find(".ui-upload-tools-move").length>0){A.element.find(".ui-upload-list").sortable("refresh")}},_create_item:function(G,I){var H=A.options.iframe;var E=B("input[name=reviewerId]").val();if(!G.error){var D=B('<li id="'+G.id+'" class="ui-upload-tools-default" />');D.html(A.element.find(".ui-upload-loaded").html());D.mouseenter(function(){if(D.find(".ui-upload-preview-overlay").css("display")=="none"){if(!D.data("active")){if(A.element.find(".ui-upload-preview").length<=2){B(this).find(".ui-upload-tools-move").hide()}else{B(this).find(".ui-upload-tools-move").show()}D.addClass("ui-upload-tools-active").removeClass("ui-upload-tools-default")}D.data("active",true)}});D.mouseleave(function(){B(this).find(".ui-upload-tools-move").hide();D.removeClass("ui-upload-tools-active").addClass("ui-upload-tools-default");D.data("active",false)});D.find(".ui-upload-tools-rotate").click(function(){var K=B(this);var J=K.parent().parent().attr("id");K.parent().parent().find(".ui-upload-tools-move").hide();K.parent().parent().removeClass("ui-upload-tools-active").addClass("ui-upload-tools-default");A.element.find(".errors").hide();K.parent().parent().find(".ui-upload-preview-overlay").show();C=C+1;A._disable_submit_button();B.post(A.options.rotate_url,{mediaFileId:J,reviewerId:E},function(M,N,L){if(!M.error){G.action="rotate";G.requests=1;A._process_queue(G,I)}else{K.parent().parent().find(".ui-upload-preview-overlay").hide();A.element.find(".errors").html(M.message);A.element.find(".errors").show();A._enable_submit_button()}if(D.data("active")){D.addClass("ui-upload-tools-active").removeClass("ui-upload-tools-default");if(A.element.find(".ui-upload-preview").length<=2){K.parent().parent().find(".ui-upload-tools-move").hide()}else{K.parent().parent().find(".ui-upload-tools-move").show()}}},"json").error(function(L,N,M){K.parent().parent().find(".ui-upload-preview-overlay").hide();A.element.find(".errors").html(A.exceptions.invalid_response);A.element.find(".errors").show();if(D.data("active")){D.addClass("ui-upload-tools-active").removeClass("ui-upload-tools-default")}})});D.find(".ui-upload-tools-delete").click(function(){var K=false;if(A.element.hasClass("ui-upload-review")){K=confirm("Please confirm that you wish to delete this image. Deleting an image removes it permanently.")}else{K=true}if(K){var L=B(this);var J=L.parent().parent().attr("id");D.removeClass("ui-upload-tools-active").addClass("ui-upload-tools-default");A.element.find(".errors").hide();L.parent().parent().find(".ui-upload-preview-overlay").show();A._disable_submit_button();B.post(A.options.delete_url,{mediaFileId:J,reviewerId:E},function(N,O,M){L.parent().parent().find(".ui-upload-preview-overlay").hide();A._enable_submit_button(false);if(!N.error){L.parent().parent().remove();if(A.element.find(".ui-upload-list .ui-upload-preview").length==0){A.element.find(".ui-upload-list").hide()}}else{A.element.find(".errors").html(N.message);A.element.find(".errors").show()}},"json").error(function(M,O,N){L.parent().parent().find(".ui-upload-preview-overlay").hide();A.element.find(".errors").html(A.exceptions.invalid_response);A.element.find(".errors").show();if(D.data("active")){D.addClass("ui-upload-tools-active").removeClass("ui-upload-tools-default")}})}});D.find(".ui-upload-cancel").click(function(){var J=B(this);var K=J.parent().parent().attr("id");A._enable_submit_button();J.parent().parent().remove();if(A.element.find(".ui-upload-list .ui-upload-preview").length==0){A.element.find(".ui-upload-list").hide()}B.doTimeout(K)});D.find(".ui-upload-preview img").attr("src",G.file+A.options.file_extension);var F=A.element.find("#"+I).index();D.find("input[type=text]").form_prompt().attr("name","images["+F+"].caption");if(G.caption){D.find("input[type=text]").attr("value",G.caption).addClass("hint-focus")}D.find("input[type=hidden]").attr("name","images["+F+"].mediaFileId").val(G.id);A.element.find(".ui-upload-preload").remove();B("#"+I).replaceWith(D);if(A.element.find(".ui-upload-list .ui-upload-preview").length>1&&A.element.find(".ui-upload-tools-move").length>0){A.element.find(".ui-upload-list").sortable({containment:"parent",tolerance:"pointer",cancel:"ui-upload-preview-loading",placeholder:"ui-upload-placeholder",cursor:"move",start:function(J,K){A.element.find(".ui-upload-list .ui-upload-preview").each(function(L){if(L!=K.helper.index()){B(this).css("opacity",0.5)}});K.item.find(".ui-upload-tools-rotate").hide();K.item.find(".ui-upload-tools-delete").hide()},stop:function(J,K){A.element.find(".ui-upload-list .ui-upload-preview").each(function(L){B(this).css("opacity",1);B(this).parent().find("input[type=text]").form_prompt().attr("name","images["+L+"].caption");B(this).parent().find("input[type=hidden]").attr("name","images["+L+"].mediaFileId")});K.item.find(".ui-upload-tools-rotate").removeAttr("style");K.item.find(".ui-upload-tools-delete").removeAttr("style")}});A.element.find(".ui-upload-list").sortable("option","cancel",":input");A.element.find(".ui-upload-list").find("img").css("cursor","move");A.element.find(".ui-upload-list").sortable("enabled")}else{A.element.find(".ui-upload-list").find("img").css("cursor","default");if(A.element.find(".ui-upload-tools-move").length>0){A.element.find(".ui-upload-list").sortable("disabled")}}}else{A.element.find("#"+I).remove();A._enable_submit_button();B.doTimeout(I);A.element.find(".errors").html(G.message);A.element.find(".errors").show()}},_init_upload:function(){var D=new Date();var E=A.options.iframe.contents();var G="ui-upload-"+D.getTime();var F=A.element.find(".ui-upload-list").children().length;if(F<A.options.total_items){C=C+1;A._create_tmp_item(G);A.element.find(".ui-upload-list").show();A._disable_submit_button();E.find("body").append('<iframe id="'+G+'" name="'+G+'" style="display:none;" src="" />');E.find("form").attr("target",G);E.find("#"+G).load(function(){var H=B(this).contents().find("body").text();var I;try{I=B.parseJSON(H);if(!I.error){I.action="upload";A._process_queue(I,G)}else{A.element.find(".errors").html(I.message);A.element.find(".errors").show();A.element.find("#"+G).remove();A._enable_submit_button()}}catch(J){A.element.find(".errors").html(A.exceptions.invalid_response);A.element.find(".errors").show()}});B(this).parent().submit();B(this).val("")}else{A.element.find(".errors").html(A.exceptions.upload_limit_reached);A.element.find(".errors").show()}},_init_upload_button:function(){var E=A.options.iframe.contents();var F=B("input[name=organisationId]").val();var D=B("input[name=reviewerId]").val();if(!B.browser.msie){E.find("head").append('<style type="text/css">@import url("'+A.options.stylesheet+'");</style>')}else{E.find("head").append('<link rel="stylesheet" type="text/css" href="'+A.options.stylesheet+'" />')}E.find("body").attr("class","ui-upload-iframe-body");E.find("body").append('<form class="ui-upload-form" action="'+A.options.upload_url+'" method="post" enctype="multipart/form-data"><input type="file" name="image.file" autocomplete="off" /><input type="hidden" name="organisationId" value="'+F+'" /><input type="hidden" name="reviewerId" value="'+D+'" /><button class="ui-upload-button"></button></form>');E.find("input[type=file]").change(A._init_upload);E.find("input[type=file]").bind("mouseover",function(){E.find("button").addClass("ui-upload-button-hover");if(typeof(A.options.upload_button.mouseover)=="function"){A.options.upload_button.mouseover()}});E.find("input[type=file]").bind("mouseout",function(){E.find("button").removeClass("ui-upload-button-hover");if(typeof(A.options.upload_button.mouseout)=="function"){A.options.upload_button.mouseout()}});E.find("input[type=file]").bind("mousedown",function(){E.find("button").addClass("ui-upload-button-active");if(typeof(A.options.upload_button.mousedown)=="function"){A.options.upload_button.mousedown()}});E.find("input[type=file]").bind("mouseup",function(){E.find("button").removeClass("ui-upload-button-active");if(typeof(A.options.upload_button.mouseup)=="function"){A.options.upload_button.mouseup()}})},_process_queue:function(D,E){B.doTimeout(E,(1000*A.options.poll_interval),function(){B.get(A.options.check_url+"?mediaId="+D.id,function(G){D.file=G;switch(D.action){case"upload":A._create_item(D,E);A._enable_submit_button();break;case"rotate":var F=B("#"+D.id);if(F.length>0){F.find(".ui-upload-preview-overlay").hide();F.find(".ui-upload-preview img").attr("src",D.file+A.options.file_extension);A._enable_submit_button()}break}B.doTimeout(E)}).error(function(G,I,H){if(!D.requests){D.requests=1}else{D.requests++}for(var F in A.messages){if((A.messages[F].time/A.options.poll_interval)==D.requests){switch(D.action){case"upload":B("#"+E).find(".ui-upload-waiting").text(A.messages[F].message);break;case"rotate":B("#"+D.id).find(".ui-upload-waiting").text(A.messages[F].message);break}}}});return true})},_create:function(){A=this;if(A.options.iframe){A._init_upload_button()}A.element.find(".ui-upload-preload").children().each(function(){var D=B(this).attr("src");var F=B(this).attr("id");var E=B(this).attr("alt");A._create_tmp_item();A.element.find(".ui-upload-list").show();A._create_item({id:F,file:D,caption:E})})},destroy:function(){B.Widget.prototype.destroy.apply(this);A.element.remove()}})})(jQuery);(function(A){A.widget("ui.rating",{options:{type:"star",size:"large",align:null,readonly:false,onclick:null},_create:function(){var C=this;var D=null;var G=null;var F=null;var B=C.element;B.hide();var E=A("<span />").addClass("ui-rating");if(typeof(B.attr("class"))=="undefined"){E.addClass("ui-rating-"+C.options.type+"-"+C.options.size)}else{E.addClass(B.attr("class")).removeClass("tl-ui-rating")}B.after(E);B.children().each(function(H){if(H==0){G=A(this).text()}else{D=A("<span />");if(A(this).val()<=B.val()){F="on"}else{F="off"}if(H%2!=0){D.addClass("ui-rating-item ui-rating-left-"+F)}else{D.addClass("ui-rating-item ui-rating-right-"+F)}D.data("label",A(this).text());D.data("value",A(this).val());E.append(D);D.hover(function(){if(A(this).hasClass("ui-rating-left-off")){A(this).attr("class","ui-rating-item ui-rating-left-on")}else{if(A(this).hasClass("ui-rating-right-off")){A(this).attr("class","ui-rating-item ui-rating-right-on")}}A(this).siblings().each(function(I){if(I<H-1){if(A(this).hasClass("ui-rating-left-off")){A(this).attr("class","ui-rating-item ui-rating-left-on")}else{if(A(this).hasClass("ui-rating-right-off")){A(this).attr("class","ui-rating-item ui-rating-right-on")}}}});A(this).parent().children().last().text(A(this).data("label"))},function(){var I=G;E.children().not(".ui-rating-label").each(function(J){if(A(this).data("value")<=A(this).parent().data("value")){if(A(this).hasClass("ui-rating-left-off")){A(this).attr("class","ui-rating-item ui-rating-left-on")}else{if(A(this).hasClass("ui-rating-right-off")){A(this).attr("class","ui-rating-item ui-rating-right-on")}}I=A(this).data("label")}else{if(A(this).hasClass("ui-rating-left-on")){A(this).attr("class","ui-rating-item ui-rating-left-off")}else{if(A(this).hasClass("ui-rating-right-on")){A(this).attr("class","ui-rating-item ui-rating-right-off")}}}});A(this).parent().children().last().text(I)});D.click(function(){B.val(A(this).data("value"));A(this).parent().data("value",A(this).data("value"));E.children().not(".ui-rating-label").each(function(I){if(A(this).data("value")<=A(this).parent().data("value")){if(A(this).hasClass("ui-rating-left-off")){A(this).attr("class","ui-rating-item ui-rating-left-on")}else{if(A(this).hasClass("ui-rating-right-off")){A(this).attr("class","ui-rating-item ui-rating-right-on")}}}else{if(A(this).hasClass("ui-rating-left-on")){A(this).attr("class","ui-rating-item ui-rating-left-off")}else{if(A(this).hasClass("ui-rating-right-on")){A(this).attr("class","ui-rating-item ui-rating-right-off")}}}});if(typeof(C.options.onclick)=="function"){C.options.onclick()}})}});D=A("<span />").attr("class","ui-rating-label").text(G);E.append(D);A(E).data("value",B.val())},destroy:function(){this.element.next().remove()}})})(jQuery);(function(A){A.fn.extend({autoGrow:function(){var B=["paddingTop","paddingRight","paddingBottom","paddingLeft","fontSize","lineHeight","fontFamily","width","fontWeight"];return this.each(function(){if(this.type!="textarea"){return false}var G=A(this),C=A("<div />").css({position:"absolute",display:"none","word-wrap":"break-word"}),H=parseInt(G.css("line-height"),10)||parseInt(G.css("font-size"),"10"),J=parseInt(G.css("height"),10)||H*3,I=parseInt(G.css("max-height"),10)||Number.MAX_VALUE,D=0,F=0;if(I<0){I=Number.MAX_VALUE}C.appendTo(G.parent());var F=B.length;while(F--){C.css(B[F].toString(),G.css(B[F].toString()))}function K(L,M){curratedHeight=Math.floor(parseInt(L,10));if(G.height()!=curratedHeight){G.css({height:curratedHeight+"px",overflow:M})}}function E(){var N=G.val().replace(/&/g,"&amp;").replace(/  /g,"&nbsp;").replace(/<|>/g,"&gt;").replace(/\n/g,"<br />");var L=C.html().replace(/<br>/ig,"<br />");if(N+"&nbsp;"!=L){C.html(N+"&nbsp;");if(Math.abs(C.height()+H-G.height())>3){var M=C.height()+H;if(M>=I){K(I,"auto")}else{if(M<=J){K(J,"hidden")}else{K(M,"hidden")}}}}}G.css({overflow:"hidden"});G.bind("keyup change cut paste",function(){E()});G.live("input paste",function(L){setTimeout(E,250)});E()})}})})(jQuery);(function(d){function g(a){var b=a||window.event,i=[].slice.call(arguments,1),c=0,h=0,e=0;a=d.event.fix(b);a.type="mousewheel";if(a.wheelDelta)c=a.wheelDelta/120;if(a.detail)c=-a.detail/3;e=c;if(b.axis!==undefined&&b.axis===b.HORIZONTAL_AXIS){e=0;h=-1*c}if(b.wheelDeltaY!==undefined)e=b.wheelDeltaY/120;if(b.wheelDeltaX!==undefined)h=-1*b.wheelDeltaX/120;i.unshift(a,c,h,e);return d.event.handle.apply(this,i)}var f=["DOMMouseScroll","mousewheel"];d.event.special.mousewheel={setup:function(){if(this.addEventListener)for(var a=f.length;a;)this.addEventListener(f[--a],g,false);else this.onmousewheel=g},teardown:function(){if(this.removeEventListener)for(var a=f.length;a;)this.removeEventListener(f[--a],g,false);else this.onmousewheel=null}};d.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}})})(jQuery);(function(A){A.fn.jTruncate=function(B){var C={length:300,minTrail:20,moreText:"more",lessText:"less",ellipsisText:" ... ",moreAni:"",lessAni:""};var B=A.extend(C,B);return this.each(function(){obj=A(this);var D=obj.html();if(D.length>B.length+B.minTrail){var H=D.indexOf(" ",B.length);if(H!=-1){var H=D.indexOf(" ",B.length);var G=D.substring(0,H);var F=D.substring(H,D.length-1);obj.html(G+'<span class="truncate_ellipsis">'+B.ellipsisText+'</span><span class="truncate_more">'+F+"</span>");obj.find(".truncate_more").css("display","none");obj.append('<a href="#" class="truncate_more_link">'+B.moreText+"</a>");var J=A(".truncate_more_link",obj);var I=A(".truncate_more",obj);var E=A(".truncate_ellipsis",obj);J.click(function(){if(J.text()==B.moreText){I.show(B.moreAni);J.text(B.lessText);E.css("display","none")}else{I.hide(B.lessAni);J.text(B.moreText);E.css("display","inline")}return false})}}})}})(jQuery);function spellChecker(A){this.popUpUrl="/speller/spellchecker.html";this.popUpName="spellchecker";this.popUpProps="menu=no,width=440,height=350,top=70,left=120,resizable=yes,status=yes";this.spellCheckScript="/cgi-bin/spellchecker.pl";this.replWordFlag="R";this.ignrWordFlag="I";this.replAllFlag="RA";this.ignrAllFlag="IA";this.fromReplAll="~RA";this.fromIgnrAll="~IA";this.wordFlags=new Array();this.currentTextIndex=0;this.currentWordIndex=0;this.spellCheckerWin=null;this.controlWin=null;this.wordWin=null;this.textArea=A;this.textInputs=arguments;this._spellcheck=_spellcheck;this._getSuggestions=_getSuggestions;this._setAsIgnored=_setAsIgnored;this._getTotalReplaced=_getTotalReplaced;this._setWordText=_setWordText;this._getFormInputs=_getFormInputs;this.openChecker=openChecker;this.startCheck=startCheck;this.checkTextBoxes=checkTextBoxes;this.checkTextAreas=checkTextAreas;this.spellCheckAll=spellCheckAll;this.ignoreWord=ignoreWord;this.ignoreAll=ignoreAll;this.replaceWord=replaceWord;this.replaceAll=replaceAll;this.terminateSpell=terminateSpell;this.undo=undo;window.speller=this}function checkTextBoxes(){this.textInputs=this._getFormInputs("^text$");this.openChecker()}function checkTextAreas(){this.textInputs=this._getFormInputs("^textarea$");this.openChecker()}function spellCheckAll(){this.textInputs=this._getFormInputs("^text(area)?$");this.openChecker()}function openChecker(){this.spellCheckerWin=window.open(this.popUpUrl,this.popUpName,this.popUpProps);if(!this.spellCheckerWin.opener){this.spellCheckerWin.opener=window}}function startCheck(A,C){this.wordWin=A;this.controlWin=C;this.wordWin.resetForm();this.controlWin.resetForm();this.currentTextIndex=0;this.currentWordIndex=0;this.wordFlags=new Array(this.wordWin.textInputs.length);for(var B=0;B<this.wordFlags.length;B++){this.wordFlags[B]=[]}this._spellcheck();return true}function ignoreWord(){var A=this.currentWordIndex;var B=this.currentTextIndex;if(!this.wordWin){alert("Error: Word frame not available.");return false}if(!this.wordWin.getTextVal(B,A)){alert('Error: "Not in dictionary" text is missing.');return false}if(this._setAsIgnored(B,A,this.ignrWordFlag)){this.currentWordIndex++;this._spellcheck()}}function ignoreAll(){var A=this.currentWordIndex;var D=this.currentTextIndex;if(!this.wordWin){alert("Error: Word frame not available.");return false}var E=this.wordWin.getTextVal(D,A);if(!E){alert('Error: "Not in dictionary" text is missing');return false}this._setAsIgnored(D,A,this.ignrAllFlag);for(var C=D;C<this.wordWin.textInputs.length;C++){for(var B=0;B<this.wordWin.totalWords(C);B++){if((C==D&&B>A)||C>D){if((this.wordWin.getTextVal(C,B)==E)&&(!this.wordFlags[C][B])){this._setAsIgnored(C,B,this.fromIgnrAll)}}}}this.currentWordIndex++;this._spellcheck()}function replaceWord(){var B=this.currentWordIndex;var C=this.currentTextIndex;if(!this.wordWin){alert("Error: Word frame not available.");return false}if(!this.wordWin.getTextVal(C,B)){alert('Error: "Not in dictionary" text is missing');return false}if(!this.controlWin.replacementText){return}var A=this.controlWin.replacementText;if(A.value){var D=new String(A.value);if(this._setWordText(C,B,D,this.replWordFlag)){this.currentWordIndex++;this._spellcheck()}}}function replaceAll(){var E=this.currentTextIndex;var B=this.currentWordIndex;if(!this.wordWin){alert("Error: Word frame not available.");return false}var G=this.wordWin.getTextVal(E,B);if(!G){alert('Error: "Not in dictionary" text is missing');return false}var A=this.controlWin.replacementText;if(!A.value){return}var F=new String(A.value);this._setWordText(E,B,F,this.replAllFlag);for(var D=E;D<this.wordWin.textInputs.length;D++){for(var C=0;C<this.wordWin.totalWords(D);C++){if((D==E&&C>B)||D>E){if((this.wordWin.getTextVal(D,C)==G)&&(!this.wordFlags[D][C])){this._setWordText(D,C,F,this.fromReplAll)}}}}this.currentWordIndex++;this._spellcheck()}function terminateSpell(){var C="Spell check complete:\n\n";var A=this._getTotalReplaced();if(A==0){if(!this.wordWin){C=""}else{if(this.wordWin.totalMisspellings()){C+="No words changed."}else{C+="No misspellings found."}}}else{if(A==1){C+="One word changed."}else{C+=A+" words changed."}}if(C){C+="\n";alert(C)}if(A>0){for(var B=0;B<this.textInputs.length;B++){if(this.wordWin){if(this.wordWin.textInputs[B]){this.textInputs[B].value=this.wordWin.textInputs[B]}}}}this.spellCheckerWin.close();return true}function undo(){var F=this.currentTextIndex;var B=this.currentWordIndex;if(this.wordWin.totalPreviousWords(F,B)>0){this.wordWin.removeFocus(F,B);do{if(this.currentWordIndex==0&&this.currentTextIndex>0){this.currentTextIndex--;this.currentWordIndex=this.wordWin.totalWords(this.currentTextIndex)-1;if(this.currentWordIndex<0){this.currentWordIndex=0}}else{if(this.currentWordIndex>0){this.currentWordIndex--}}}while(this.wordWin.totalWords(this.currentTextIndex)==0||this.wordFlags[this.currentTextIndex][this.currentWordIndex]==this.fromIgnrAll||this.wordFlags[this.currentTextIndex][this.currentWordIndex]==this.fromReplAll);var H=this.currentTextIndex;var A=this.currentWordIndex;var C=this.wordWin.originalSpellings[H][A];if(this.wordWin.totalPreviousWords(H,A)==0){this.controlWin.disableUndo()}switch(this.wordFlags[H][A]){case this.replAllFlag:for(var E=H;E<this.wordWin.textInputs.length;E++){for(var D=0;D<this.wordWin.totalWords(E);D++){if((E==H&&D>=A)||E>H){var G=this.wordWin.originalSpellings[E][D];if(G==C){this._setWordText(E,D,G,undefined)}}}}break;case this.ignrAllFlag:for(var E=H;E<this.wordWin.textInputs.length;E++){for(var D=0;D<this.wordWin.totalWords(E);D++){if((E==H&&D>=A)||E>H){var G=this.wordWin.originalSpellings[E][D];if(G==C){this.wordFlags[E][D]=undefined}}}}break;case this.replWordFlag:this._setWordText(H,A,C,undefined);break}this.wordFlags[H][A]=undefined;this._spellcheck()}}function _spellcheck(){var B=this.wordWin;if(this.currentWordIndex==B.totalWords(this.currentTextIndex)){this.currentTextIndex++;this.currentWordIndex=0;if(this.currentTextIndex<this.wordWin.textInputs.length){this._spellcheck();return}else{this.terminateSpell();return}}if(this.currentWordIndex>0){this.controlWin.enableUndo()}if(this.wordFlags[this.currentTextIndex][this.currentWordIndex]){this.currentWordIndex++;this._spellcheck()}else{var A=B.getTextVal(this.currentTextIndex,this.currentWordIndex);if(A){this.controlWin.evaluatedText.value=A;B.setFocus(this.currentTextIndex,this.currentWordIndex);this._getSuggestions(this.currentTextIndex,this.currentWordIndex)}}}function _getSuggestions(D,A){this.controlWin.clearSuggestions();var C=this.wordWin.suggestions[D][A];if(C){for(var B=0;B<C.length;B++){this.controlWin.addSuggestion(C[B])}}this.controlWin.selectDefaultSuggestion()}function _setAsIgnored(C,B,A){this.wordWin.removeFocus(C,B);this.wordFlags[C][B]=A;return true}function _getTotalReplaced(){var C=0;for(var B=0;B<this.wordFlags.length;B++){for(var A=0;A<this.wordFlags[B].length;A++){if((this.wordFlags[B][A]==this.replWordFlag)||(this.wordFlags[B][A]==this.replAllFlag)||(this.wordFlags[B][A]==this.fromReplAll)){C++}}}return C}function _setWordText(D,B,C,A){this.wordWin.setText(D,B,C);this.wordFlags[D][B]=A;return true}function _getFormInputs(B){var A=new Array();for(var D=0;D<document.forms.length;D++){for(var C=0;C<document.forms[D].elements.length;C++){if(document.forms[D].elements[C].type.match(B)){A[A.length]=document.forms[D].elements[C]}}}return A};$.fn.imagesLoaded=function(D){var B=this.filter("img"),A=B.length,C="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==";B.bind("load.imgloaded",function(){if(--A<=0&&this.src!==C){B.unbind("load.imgloaded");D.call(B,this)}}).each(function(){if(this.complete||this.complete===undefined){var E=this.src;this.src=C;this.src=E}});return this};var map=null;var myLatlng=null;var successfulCallback=$.getUrlVar("successfulCallback",document.location.href);if(successfulCallback){eval(successfulCallback)}if($.getUrlVar("showFBFavouriteDialog",document.location.href)=="true"){parent.location=$.removeUrlVar("showFBFavouriteDialog",document.location.href)}function successfulAddToFavourite(){parent.location=$.removeUrlVar("successfulCallback",document.location.href)}function initialize(){if($("#business-latlng").size()){var C=$("#business-latlng").val().split(",");myLatlng=new google.maps.LatLng(C[0],C[1]);set_map()}else{if($("#business-address")){var A=$("#business-address").text().trim().replace(/(\r\n|\n|\r)/gm,"");var B=new google.maps.Geocoder();B.geocode({address:A},function(E,D){if(D==google.maps.GeocoderStatus.OK){myLatlng=new google.maps.LatLng(E[0].geometry.location.lat(),E[0].geometry.location.lng());set_map()}else{alert("Geocode was not successful for the following reason: "+D)}})}}}function set_map(){$("input[name='toLatLng']").val(myLatlng.lat()+","+myLatlng.lng());var B={zoom:16,center:myLatlng,mapTypeId:google.maps.MapTypeId.ROADMAP,mapTypeControl:false};map=new google.maps.Map(document.getElementById("google_map"),B);var C=new google.maps.MarkerImage("http://media.truelocal.com.au/docs/images/map-marker.png",new google.maps.Size(31,49));var D=new google.maps.MarkerImage("http://media.truelocal.com.au/docs/images/map-marker-shadow.png",new google.maps.Size(48,49),new google.maps.Point(0,0),new google.maps.Point(0,48));var A=new google.maps.Marker({position:myLatlng,map:map,icon:C,shadow:D})}$(document).ready(function(){(function(){var L=document.createElement("script");L.type="text/javascript";L.async=true;L.src="https://apis.google.com/js/plusone.js";var M=document.getElementsByTagName("script")[0];M.parentNode.insertBefore(L,M)})();adkit.onload("ads",function(){adkit.ads.leaderboard().write("ndmadkit-leaderboard-1")});adkit.onload("ads",function(){adkit.ads.leaderboard().write("ndmadkit-leaderboard-2")});var F="gallery-selected",K=0,A=$(".gallery-image"),G=$("img",".hero-image");$("a:first",".tl-ui-gallery").addClass("gallery-selected");$(".gallery-right").bind("click",function(M){M.preventDefault();var L=$("."+F).parent().next();$("a",L).trigger("click")});$(".gallery-left").bind("click",function(M){M.preventDefault();var L=$("."+F).parent().prev();$("a",L).trigger("click")});$("a",".tl-ui-gallery").bind("click",function(N){N.preventDefault();var M=$(this),L=A.height();K=$("a",".tl-ui-gallery").index(this);$("a",".tl-ui-gallery").removeClass(F);M.addClass(F);$(".gallery-control").hide();A.height(L);$(".gallery-count").html((K+1)+" of "+$("a",".tl-ui-gallery").size());G.fadeOut(function(){G.attr({src:M.attr("data-photo-enlarged"),title:M.attr("title"),alt:M.attr("alt")}).imagesLoaded(function(){A.animate({height:G.height()},700,function(){G.fadeIn("slow",function(){$("strong",".gallery-caption").html(M.attr("title"));$(".gallery-control").fadeIn()})})})})});$("img, .gallery-control",A).unbind().bind("click",function(M){M.preventDefault();var L=[];$("a",".tl-ui-gallery").each(function(){L.push({href:$(this).attr("href"),title:$(this).attr("title")})});if(L.length>0){$.fancybox(L,{index:K,opacity:true,overlayShow:true,titleShow:true,easingIn:"easeOutQuad",easingOut:"easeOutQuad",speedIn:400,speedOut:200,centerOnScroll:true,transitionIn:"elastic",transitionOut:"fade",overlayColor:"#000",autoScale:true,cyclic:true,overlayOpacity:"0.8",padding:0,titlePosition:"over",titleFormat:function(Q,P,N,O){return'<span id="fancybox-title-over">Image '+(N+1)+" / "+P.length+(Q.length?" &nbsp; "+Q:"")+"</span>"},onStart:function(){$("#fancybox-outer").addClass("image").removeClass("ajax")}})}});$(".gallery-image").bind("mouseenter click",function(){if($("."+F).parent().prev().size()==0){$(".gallery-left").hide()}else{$(".gallery-left").show()}if($("."+F).parent().next().size()==0){$(".gallery-right").hide()}else{$(".gallery-right").show()}});$(".gallery-image").bind("mouseleave",function(){$(".gallery-right, .gallery-left").hide()});var B=$("pre","#business-summary"),E=B.html(),J=500;if(E&&E.length>J){var D=E.substring(0,J),C=E.substring(J);B.html("<pre>"+D+'<span class="truncate_ellipsis">...</span><span class="truncate_more">'+C+"</span></pre>");B.find(".truncate_more").css("display","none");var I=$('<span><a href="#" class="truncate_more_link">Read more</a></span>').appendTo(B).bind("click",function(L){L.preventDefault();$(".truncate_ellipsis",B).hide();$(".truncate_more",B).show();$(this).hide()})}$(".tl-bd-review-text textarea").autoGrow();$(".tl-bd-review-text textarea").bind("focus",function(){$(".tl-bd-review-bot .tl-bd-review-tip").fadeOut();$(".tl-bd-review-tools").slideDown()});$(".tl-bd-review-promo a").bind("click",function(L){$(".tl-bd-review-promo a").hide();$(".tl-bd-review-promo input").show();L.preventDefault()});$(".tl-bd-review-spell").bind("click",function(L){var M=new spellChecker(document.writeReviewForm.notes);M.openChecker();L.preventDefault()});$("#writeReviewForm").bind("submit",function(N){N.preventDefault();var M=$(this),L=$(".tl-bd-review-text",M);reviewContent=$("#writeReview");reviewContent.addClass("ajax-loading");$.ajax({url:M.attr("action"),type:M.attr("method"),dataType:"json",data:M.serializeArray(),success:function(O){reviewContent.removeClass("ajax-loading");$(".errors",L).remove();switch(O.status){case"ERROR":$("<div class='message errors'>"+O.message+"</div>").prependTo(L);break;case"ONHOLD":L.html("<div class='message notice'>"+O.message+"</div>");$(".tl-bd-review-bot, .tl-bd-review-top, .tl-bd-review-upload").remove();break;case"ADDED":L.html("<div class='message notice'>"+O.message+"</div>");$(".tl-bd-review-bot, .tl-bd-review-top, .tl-bd-review-upload").remove();break;case"SUCCESS":$("body").trigger({type:"review-submit",review:{business:$("h1:first").text(),caption:O.caption,description:O.description,picture:(O.picture)?O.picture:"",link:O.link}});L.html("<div class='message success'>"+O.message+"</div>");var P=$(".tl-bd-review-rating").clone();$(".ui-rating",P).removeClass("ui-rating-star-large").addClass("ui-rating-disabled ui-rating-star-small");$(".ui-rating-label",P).remove();$(".tl-ui-rating",P).remove();$("#reviews-list").prepend("<li><div class='list-thumbnails clearfix'><div class='list-thumbnail list-thumbnail-mask'>"+$(".tl-bd-review-avatar:first").html()+"</div><div class='list-content'>"+P.html()+O.description+"<div class='review-tools clearfix'><p class='secondary accent-red left'>PENDING MODERATION</p></div></div></li>");$(".tl-bd-review-bot, .tl-bd-review-top, .tl-bd-review-upload").remove();break;default:$("<div class='message errors'>unknown error occured</div>").prependTo(L)}},error:function(){reviewContent.removeClass("ajax-loading");$("<div class='message errors'><p>unknown error occured</p></div>").prependTo(L)}})});var H=$(".review-spotlight-text"),E=H.html(),J=210;if(E&&E.length>J){var D=E.substring(0,J),C=E.substring(J,E.length-1);H.html(D+'<span class="truncate_ellipsis">...</span><span  class="truncate_more">'+C+"</span>");H.find(".truncate_more").css("display","none");var I=$('<span>-&nbsp;<a href="#" class="truncate_more_link">READ THE REST OF THIS REVIEW</a></span>').appendTo("#review-spotlight .review-tools p").bind("click",function(L){L.preventDefault();$(".truncate_ellipsis",H).hide();$(".truncate_more",H).show();$(this).hide()})}$("input[name='sort-reviews']").bind("change",function(L){L.preventDefault();window.location="?selectedListingSortOrder="+$(this).val()+"#reviewsTab"});$(".rate-review a").live("click",function(P){P.preventDefault();var N=$(this),O=N.attr("href"),M=$.getUrlVar("ratingReviewID",O),L=$("#review-"+M);$.getJSON(O,function(Q){if(Q.message){alert(Q.message)}else{$.ajax({url:"/updateHelpfulDiv.do?ratingReviewId="+M,success:function(R){$(".rate-review-score",L).html(R)}})}})});$("#map-directions").bind("submit",function(N){var M=$(this),L=$("#user-custom-location",M),O=$("#user-saved-location",M);if(L.val()!=""){O.prop("disabled",true)}else{L.prop("disabled",true)}});$("img,#map-control-directions","#business-map").bind("click",function(){$("#map-control-show").trigger("click")});$("#map-control-show").toggle(function(){var L=$(this);$("span",L).removeClass("ui-icon-carat-1-s").addClass("ui-icon-carat-1-n");$("img","#business-map").hide();$("#google_map").css({height:"500px",width:"auto"}).show();$("#map-directions").show();if(!L.data("mapped")){$.getScript("http://maps.googleapis.com/maps/api/js?sensor=false&callback=initialize");L.data("mapped",true)}else{initialize()}},function(){var L=$(this);$("span",L).removeClass("ui-icon-carat-1-n").addClass("ui-icon-carat-1-s");$("img","#business-map").show();$("#google_map").hide();$("#map-directions").hide()});$(".ui-button",".reviews-more").live("click",function(N){N.preventDefault();var L=$(this);var M=L.parent();M.html("<div class='ajax-loading'></div>");$.ajax({url:L.attr("href"),success:function(O){M.html(O);$("body").trigger({type:"review-more"})}})});$(".review-content, .comment-content").each(function(){var L=$(this);if(!L.data("init")){L.jTruncate({length:320,moreText:" Read more",lessText:""});L.data("init",true)}});$(document).bind("review-more",function(L){$(".review-content, .comment-content").each(function(){var M=$(this);if(!M.data("init")){M.jTruncate({length:320,moreText:" Read more",lessText:""});M.data("init",true)}})});$(".erLocal").each(function(L){$(this).jTruncate({length:150,moreText:" Read more",lessText:""})});$(".tl-phone-clip").live("click",function(M){M.preventDefault();var L=$(this);L.hide().next().show();$.ajax({type:"GET",url:"/TrackServlet?tbType=PHONE&listingId="+L.attr("listingId")+"&phoneType="+L.attr("phoneType")+"&phoneNumber="+L.attr("phoneNumber")+"&clickFrom="+L.attr("clickFrom")});return false})});(function(A){A.widget("ui.share",{_create:function(){var B=this,C=B.element,D=C.next("ul");D.remove().appendTo("body");D.attr("class","ui-share-content ui-corner-all");D.find("li").attr("class","ui-share-item");D.find("a").attr("class","ui-share-link");C.click(function(){B.position();D.show();A(document).click(function(){if(D.css("display")=="block"){D.hide()}});return false});D.find("a").each(function(){A(this).click(function(){if(A(this).attr("href").indexOf("email.do")!=-1){window.location=A(this).attr("href")}else{window.open(A(this).attr("href"),"share","resizable=yes,width=700,height=480")}return false})});B.menu=D;A(window).resize(function(){B.position()})},position:function(){var B=this.element.offset();this.menu.css("top",(B.top+this.element.height())+"px");this.menu.css("left",B.left+"px")},destroy:function(){this.menu.remove()}})})(jQuery);
