/*!
* Custom AIM Javascript
*
* Copyright 2011
*/
String.prototype.startsWith=function(str){return(this.indexOf(str)===0);};function SetCulture(culture){jQuery.cookie("culture",culture);location.reload(true);}var FormHelpers={SpanSelect_onchange:function(obj,spanId){document.getElementById(spanId).innerHTML=obj.options[obj.selectedIndex].text;}};var Global={_SavedSearchesMarkeup:[],_SavedListingsMarkeup:[],_SavedSearchesWasLast:false,_SavedListingsWasLast:false,ShowSavedSearches:function(page,virtualDir){var scope=this;if(scope._SavedListingsWasLast){$("#drop_menu").html("");}scope._SavedSearchesWasLast=true;scope._SavedListingsWasLast=false;if(!scope._SavedSearchesMarkeup[page?page:0]||scope._SavedSearchesMarkeup[page?page:0]===""){var vr="";if(virtualDir&&virtualDir!="/"){vr=virtualDir;}$.get(vr+"/html/SavedSearches/"+(page?"?p="+page.toString():"?p=1")+"&iehack="+(Math.random()*100).toString(),function(html){scope._SavedSearchesMarkeup[page?page:0]=html;$("#drop_menu").html("");$("#drop_menu").html(scope._SavedSearchesMarkeup[page?page:0]);});}else{$("#drop_menu").html(scope._SavedSearchesMarkeup[page?page:0]);}scope._showSavesDropDown();},ShowSavedListings:function(page,virtualDir){var scope=this;if(scope._SavedSearchesWasLast){$("#drop_menu").html("");}scope._SavedSearchesWasLast=false;scope._SavedListingsWasLast=true;if((!scope._SavedListingsMarkeup[page?page:0]||scope._SavedListingsMarkeup[page?page:0]==="")){var vr="";if(virtualDir&&virtualDir!="/"){vr=virtualDir;}$.get(vr+"/html/SavedListings"+(page?"?p="+page.toString():"?p=1")+"&iehack="+(Math.random()*100).toString(),function(html){scope._SavedListingsMarkeup[page?page:0]=html;$("#drop_menu").html(scope._SavedListingsMarkeup[page?page:0]);});}else{$("#drop_menu").html(scope._SavedListingsMarkeup[page?page:0]);}scope._showSavesDropDown();},_showSavesDropDown:function(){$("#drop_menu_container").show();},SaveSearchSubmit:function(url,search_saved){var search=new Search();return search.SaveSearch(document.SaveSearch,url,search_saved);},EmailListingToFriend:function(id,form,onSuccess){var jForm=$(form);$.ajax({type:"POST",url:jForm.attr("action"),data:"listingId="+id+"&"+jForm.serialize(),dataType:"json",success:function(data){try{onSuccess(data);}catch(err){}},failure:function(){}});$.unblockUI();return false;},GetSavesCounts:function(onSuccess,virtualDir){var vr="";if(virtualDir&&virtualDir!="/"){vr=virtualDir;}$.getJSON(vr+"/json/SavesCounts",function(data){try{onSuccess(eval(data));}catch(err){}});},GetCategories:function(boatType,virtualDir,addAllOption,onComplete,encodeSpecial){var vr="";if(virtualDir&&virtualDir!="/"){vr=virtualDir;}$.getJSON(vr+"/json/CategoriesForType/?BoatType="+boatType,function(data){try{var catSelect=document.getElementById("Category");if(catSelect==null){catSelect=document.getElementById("CategoryId");}catSelect.options.length=0;var categories=eval(data);if(addAllOption){var opt=document.createElement("option");opt.text="Select an Option";opt.value="";try{catSelect.add(opt,null);}catch(ex){catSelect.add(opt);}}for(var i=0;i<categories.length;i++){var opt=document.createElement("option");opt.text=categories[i].FieldName;if(encodeSpecial&&encodeSpecial===true){opt.value=categories[i].FieldName.replace("-","-dash-").replace("/","-slash-").replace(".","-dot-").replace(" ","-");}else{opt.value=categories[i].EnumId;}try{catSelect.add(opt,null);}catch(ex){catSelect.add(opt);}}if(onComplete!=null&&typeof onComplete==="function"){onComplete();}}catch(err){alert(err);}});},EncodeSpecial:function(str){var ret=str.replace(/-/gi,"-dash-").replace(/\//gi,"-slash-").replace(/\./gi,"-dot-").replace(/ /gi,"-");return ret;}};function Homepage(){}Homepage.prototype={rotatorInterval:{},_rotate:function(){var id=$("#Featured_rotator .selected").attr("id");var index=0;if(id){index=parseInt(id.replace("featuredListing",""))||0;}if(index==5){index=1;}else{index++;}this.GoToIndex(index);},GoToAndStop:function(index){this.GoToIndex(index);this.StopRotator();},StopRotator:function(){if(this.rotatorInterval){clearInterval(this.rotatorInterval);}},GoToIndex:function(index){var featured_title=$("#Featured_rotator #featuredListing"+index.toString()).attr("featured_title");var showcase=$("#Featured_rotator #featuredListing"+index.toString()).attr("showcase");var featured_location_price=$("#Featured_rotator #featuredListing"+index.toString()).attr("featured_location_price");var featured_url=$("#Featured_rotator #featuredListing"+index.toString()).attr("featured_url");$("#featured_url").attr("href",featured_url);$("#featured_title").html(featured_title);$("#featured_location_price").html(featured_location_price);$("#showcase").attr("src",showcase);$("#Featured_rotator li").removeClass("selected");$("#Featured_rotator #featuredListing"+index.toString()).addClass("selected");},StartRotator:function(){var scope=this;this.rotatorInterval=setInterval(function(){scope._rotate();},4*1000);},InitImages:function(image_urls){if(document.images){var preload_image_object=new Image();for(var i=0;i<image_urls.length;i++){preload_image_object.src=image_urls[i];}}}};var Mobile={GetWindowWidthOrDefault:function(){var winW=320;try{if(document.body&&document.body.offsetWidth){winW=document.body.offsetWidth;}if(document.compatMode=="CSS1Compat"&&document.documentElement&&document.documentElement.offsetWidth){winW=document.documentElement.offsetWidth;}if(window.innerWidth&&window.innerHeight){winW=window.innerWidth;}}catch(err){}return winW-40;},NavigateBack:function(){var root=window.location.protocol+"//"+window.location.host;if(document.referrer&&!document.referrer.startsWith(root)){return;}window.history.go(-1);},GoHome:function(){window.location=window.location.protocol+"//"+window.location.host;}};var must_be_whole_number="Must be a whole number";var Validators={validateNumber:function(txt){if(!/^[0-9]*$/.test(txt.value)&&txt.value!=""){alert(must_be_whole_number);$(txt).css("border-color","red");txt.value="";txt.focus();return false;}else{$(txt).css("border-color","");}return true;},validateLessThan:function(input1,input2){if((input1&&input1.value==="")||(input2&&input2.value==="")){return true;}var value1=parseInt(input1.value);var value2=parseInt(input2.value);if(value1>value2){$(input1).css("border-color","red");$(input2).css("border-color","red");input2.value="";input1.focus();return false;}return true;},validateEmail:function(input){try{var emailRegex=/^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;if(input.value!=""&&!emailRegex.test(input.value)){$(input).css("border-color","red");return false;}}catch(Error){}return true;},validateNonEmpty:function(input){if(input&&input.value===""){$(input).css("border-color","red");input.focus();return false;}return true;},validateAreSame:function(input1,input2){if(input1.value!=input2.value){$(input1).css("border-color","red");$(input2).css("border-color","red");input2.value="";input1.focus();return false;}return true;}};var QuickSearch={doQuickSearch:function(){if(!document.quicksearch){return;}var formAction="/All/Manufacturer/Category/Length/Feet/USD/1/boat_search.aspx";formAction=formAction.replace("All",Global.EncodeSpecial(document.getElementById("BoatType").value));formAction=formAction.replace("Category",Global.EncodeSpecial(document.getElementById("Category").value));formAction=formAction.replace("Manufacturer",Global.EncodeSpecial(document.getElementById("manufacturer").value));var minLength=document.getElementById("length_min").value;var maxLength=document.getElementById("length_max").value;if(minLength||maxLength){var length=(minLength?minLength.toString():"0")+(maxLength?"-"+maxLength:"");formAction=formAction.replace("Length",length);}document.quicksearch.action=formAction;document.quicksearch.submit();},Init:function(){var scope=this;var advancedSearch=new AdvancedSearch();$("#quicksearch").keypress(function(e){if(e.which==13){e.preventDefault();if(advancedSearch._validate()){scope.doQuickSearch();}return false;}});var selects=[{selectId:"BoatType",spanId:"BoatType_txt"},{selectId:"Category",spanId:"Category_txt"}];for(var i=0;i<selects.length;i++){with(document.getElementById(selects[i].selectId)){document.getElementById(selects[i].spanId).innerHTML=options[selectedIndex].text;}}}};function AdvancedSearch(){}AdvancedSearch.prototype={Init:function(){var scope=this;$("input").keypress(function(e){if(e.which==13){e.preventDefault();if(scope._validate()){scope.doAdvancedSearch();}return false;}});var selects=[{selectId:"ManufacturerId",spanId:"Manufacturer_txt"},{selectId:"BoatTypeId",spanId:"BoatType_txt"},{selectId:"CategoryId",spanId:"Category_txt"},{selectId:"FuelId",spanId:"Fuel_txt"},{selectId:"HullId",spanId:"hull_txt"},{selectId:"EngineTypeId",spanId:"engines_txt"},{selectId:"Posted",spanId:"posted_txt"},{selectId:"Results_per_page",spanId:"results_txt"},{selectId:"StateId",spanId:"state_txt"},{selectId:"CountryId",spanId:"country_txt"}];for(var i=0;i<selects.length;i++){with(document.getElementById(selects[i].selectId)){document.getElementById(selects[i].spanId).innerHTML=options[selectedIndex].text;}}},_validate:function(){var scope=this;var length_ret=scope._validate_lengths();var price_ret=scope._validate_prices();var year_ret=scope._validate_years();return length_ret&&price_ret&&year_ret;},_validate_years:function(){if(!(Validators.validateNumber(document.getElementById("year_min"))&&Validators.validateNumber(document.getElementById("year_max")))){return false;}if(!Validators.validateLessThan(document.getElementById("year_min"),document.getElementById("year_max"))){alert("Min year must be less than max year");$("#year_min").val($.trim($("#year_min").val()));return false;}return true;},_validate_lengths:function(){if(!(Validators.validateNumber(document.getElementById("length_min"))&&Validators.validateNumber(document.getElementById("length_max")))){return false;}if(!Validators.validateLessThan(document.getElementById("length_min"),document.getElementById("length_max"))){alert("Min length must be less than max length");$("#length_min").val($.trim($("#length_min").val()));return false;}return true;},_validate_prices:function(){if(!(Validators.validateNumber(document.getElementById("price_min"))&&Validators.validateNumber(document.getElementById("price_max")))){return false;}if(!Validators.validateLessThan(document.getElementById("price_min"),document.getElementById("price_max"))){alert("Min price must be less than max price");$("#price_min").val($.trim($("#price_min").val()));return false;}return true;},doAdvancedSearch:function(){if(!document.advancedsearch){return;}var formAction=document.advancedsearch.action;with(document.getElementById("BoatTypeId")){formAction=formAction.replace("All",options[selectedIndex].text);}with(document.getElementById("CategoryId")){formAction=formAction.replace("Category",options[selectedIndex].text);}with(document.getElementById("ManufacturerId")){formAction=formAction.replace("Manufacturer",options[selectedIndex].text);}var minLength=document.getElementById("length_min").value;var maxLength=document.getElementById("length_max").value;if(minLength||maxLength){var length=(minLength?minLength.toString():"0")+(maxLength?"-"+maxLength:"");formAction=formAction.replace("Length",length);}document.advancedsearch.action=formAction;document.advancedsearch.submit();}};function BrokerSearch(){}BrokerSearch.prototype={doSearch:function(){if(!document.brokersearch){return;}document.brokersearch.submit();},Init:function(){var scope=this;$("input").keypress(function(e){if(e.which==13){e.preventDefault();scope.doSearch();return false;}});var selects=[{selectId:"StateId",spanId:"state_txt"},{selectId:"CountryId",spanId:"country_txt"},{selectId:"radius",spanId:"radius_txt"}];for(var i=0;i<selects.length;i++){with(document.getElementById(selects[i].selectId)){document.getElementById(selects[i].spanId).innerHTML=options[selectedIndex].text;}}}};function ManufacturerNameSearch(){}ManufacturerNameSearch.prototype={_active:false,_isHover:false,_list:null,doSearch:function(name){var search=this;var matches=new Array();if(name.length>1){name=name.toLowerCase();$.each(search._list,function(key,item){if(matches.length<=10&&item.toLowerCase().indexOf(name)>-1){matches.push(item);}});}search.renderList(matches);},renderList:function(matches){var results=$("div#manufacturer_results");if(results){results.empty();if(matches.length<1){results.fadeOut("fast");}$.each(matches,function(key,item){results.append('<a href="#">'+item+"</a>");});results.fadeIn("fast");}},Init:function(){var search=this;$("input#manufacturer").keyup(function(e){if(e.which!=13){var name=$(this).val();if(name.length>0){search.doSearch($(this).val());}return false;}});$("input#manufacturer").focus(function(){if(!search._active){$(this).val("").addClass("ajax");}search._active=true;});$("input#manufacturer").blur(function(){if($(this).val()==""){$(this).val("All");search._active=false;}if(!search._isHover){$("div#manufacturer_results").hide();}});$("div#manufacturer_results a").live("click",function(){$("input#manufacturer").val($(this).text());$("div#manufacturer_results").fadeOut("fast").empty();return false;});$("div#manufacturer_results").hover(function(){search._isHover=true;},function(){search._isHover=false;});}};function SimpleGallery(){}SimpleGallery.prototype={Images:[],WaitingGifUrl:"",_index:0,_imageHash:[],ImageWidth:282,ImageHeight:211,ImageContainer:"#showcase",Init:function(){this._imageHash=new Array();if(this.WaitingGifUrl){var waitingImg=new Image();waitingImg.src=this.WaitingGifUrl;}},Next:function(){if((this._index+1)>=this.Images.length){this._index=this.Images.length-1;}else{this._index++;}this.SetImage(this._index);},Previous:function(){if(this._index<1){this._index=0;}else{this._index--;}this.SetImage(this._index);},SetImage:function(index){try{if(this._imageHash[this.Images[index]]){this._displayImage(this.Images[index]);}else{$(this.ImageContainer).attr("src",this.WaitingGifUrl);$(this.ImageContainer).css({width:32,height:32});this._imageHash[this.Images[index]]=new Image();this._imageHash[this.Images[index]].onload=this._displayImage(this.Images[index]);this._imageHash[this.Images[index]].src=this.Images[index];}}catch(err){}},_displayImage:function(src){$(this.ImageContainer).css({width:this.ImageWidth,height:this.ImageHeight});$(this.ImageContainer).attr("src",src);}};function SlidingGallery(){}SlidingGallery.prototype={thumbs:{},thumbs_container:{},showcaseImage:{},scroll_forward:{},scroll_back:{},image_urls:[],_thumbs_scroll_interval:false,Init:function(){this.thumbs=$(".gallery-thumbs img");this.showcaseImage=$("#showcase");this.scroll_forward=$(".gallery-forward");this.scroll_back=$(".gallery-back");this.thumbs_container=$(".gallery-thumbs");var context=this;preload_image_object=new Image();for(var i=0;i<context.image_urls.length;i++){preload_image_object.src=context.image_urls[i];}this.thumbs.each(function(i){var thumb=$(this);thumb.click(function(){context.ShowImage(i);context.thumbs.each(function(){if($(this).is(".gallery-image-active")){$(this).removeClass("gallery-image-active").css("opacity",0.7);}});offSet=(((i+1)*150)-75)-251;context.thumbs_container.animate({scrollLeft:offSet},400);thumb.addClass("gallery-image-active").css("opacity","");}).hover(function(){if(!$(this).is(".gallery-image-active")){$(this).fadeTo(300,1);}},function(){if(!$(this).is(".gallery-image-active")){$(this).fadeTo(300,0.7);}});});context._initNextAndPrevious();},_initNextAndPrevious:function(){var context=this;clearInterval(context._thumbs_scroll_interval);$(this.scroll_forward).add(this.scroll_back).click(function(){if($(this).is(".gallery-forward")){var left=context.thumbs_container.scrollLeft()+300;}else{var left=context.thumbs_container.scrollLeft()-300;}context.thumbs_container.animate({scrollLeft:left+"px"});}).hover(function(){clearInterval(context._thumbs_scroll_interval);var isLeft=$(this).is(".gallery-forward");context._thumbs_scroll_interval=setInterval(function(){if(isLeft){var left=context.thumbs_container.scrollLeft()+1;}else{var left=context.thumbs_container.scrollLeft()-1;}context.thumbs_container.scrollLeft(left);},10);},function(){clearInterval(context._thumbs_scroll_interval);});},ShowImage:function(i){var context=this;context.showcaseImage.attr("src",context.image_urls[i]);}};function Search(){}Search.prototype={SaveListing:function(form){var jForm=$(form);var dataString=jForm.serialize();$.ajax({type:"POST",url:jForm.attr("action"),data:dataString,dataType:"json",success:function(data){if(!data.Success){if(confim("There was an error saving your listing, please reload the page")){window.location=window.location;}}else{var item=$("#"+document.getElementById("ListingId").value);item.html(data.listing_saved);item.attr("saved","true");item.css("cursor","default");}},failure:function(){var star=$("#"+document.getElementById("ListingId").value).parent().find(".sprite2");star.removeClass("star2");star.addClass("star1");if(confim("There was an error saving your listing, please reload the page")){window.location=window.location;}}});$.unblockUI();try{var star=$("#"+document.getElementById("ListingId").value).parent().find(".sprite2");star.removeClass("star1");star.addClass("star2");}catch(err){}return false;},SaveSearch:function(form,onSuccess){var jForm=$(form);var title=document.getElementById("title");if(!title.value||title.value===""){alert("You must provide a Search Name");$(title).css("border","solid 1px Red");return false;}var dataString=jForm.serialize();$.ajax({type:"POST",url:jForm.attr("action"),data:dataString,dataType:"json",success:function(data){if(!data.Success){if(confim("There was an error saving this search, please reload the page")){window.location=window.location;}}else{try{$(".save_search a").html(data.search_saved?data.search_saved:"Search Saved");$("#saved_search_count").html(data.saved_search_count?data.saved_search_count.toString():$("#saved_search_count").html());Global._SavedSearchesMarkeup="";onSuccess(data);}catch(err){}}},failure:function(){if(confim("There was an error saving this search, please reload the page")){window.location=window.location;}}});$.unblockUI();return false;},DeleteSavedSearch:function(id,action,onSuccess){$.ajax({type:"POST",url:action,data:"savedSearchId="+id,dataType:"json",success:function(data){try{onSuccess(data);}catch(err){}},failure:function(){}});},DeleteSavedListing:function(id,action,onSuccess){$.ajax({type:"POST",url:action,data:"listingId="+id,dataType:"json",success:function(data){try{onSuccess(data);}catch(err){}},failure:function(){}});},EmailSavedSearchToFriend:function(id,form,onSuccess){var jForm=$(form);$.ajax({type:"POST",url:jForm.attr("action"),data:"savedSearchId="+id+"&"+jForm.serialize(),dataType:"json",success:function(data){try{onSuccess(data);}catch(err){}},failure:function(){}});$.unblockUI();return false;}};function Compare(){}Compare.prototype={_compare_ids:[],Compare:function(){var scope=this;if(!scope._compare_ids||scope._compare_ids.length==0){alert("Please select some listings to compare");return;}var ids="";for(var i=0;i<scope._compare_ids.length;i++){if(i!=0){ids+=",";}ids+=scope._compare_ids[i];}window.location="/"+ids+"/compare_boats.html";},CompareChk:function(checkbox,id){var scope=this;if(!checkbox||!id){return false;}if(checkbox.checked&&scope._compare_ids.length>=5){alert("You can only compare a maximum of 5 Ads");return false;}var index=$.inArray(id,scope._compare_ids);if(checkbox.checked){if(index==-1){scope._compare_ids.push(id);}}else{if(index!=-1){scope._compare_ids.splice(index,1);}}return true;},Remove:function(id){var scope=this;var index=$.inArray(id,scope._compare_ids);if(index==-1||scope._compare_ids.length==1){return;}$(".listingId_"+id).hide();scope._compare_ids.splice(index,1);}};function MemberAdmin(){}MemberAdmin.prototype={SaveSubMemberLocation:function(form,activeLink,onSuccess){var jForm=$(form);var dataString=jForm.serialize();$.ajax({type:"POST",url:jForm.attr("action"),data:dataString,dataType:"json",success:function(data){if(!data.Success){if(confirm("There was an error saving this search, please reload the page")){window.location=window.location;}}else{try{var brokerId=$("#modal_broker_id").val();var modalAddress=$("#ModalAddress option:selected");activeLink.text(modalAddress.text());activeLink.attr("addressId",modalAddress.val());onSuccess(data);}catch(err){}}},failure:function(){if(confirm("There was an error saving this search, please reload the page")){window.location=window.location;}}});$.unblockUI();return false;}};function chkUName(element,valElementId,virtualDir){var vr="";if(virtualDir&&virtualDir!="/"){vr=virtualDir;}_checkEists(element,valElementId,vr+"/json/username_exists/");}function chkEmail(element,valElementId,virtualDir){var vr="";if(virtualDir&&virtualDir!="/"){vr=virtualDir;}_checkEists(element,valElementId,vr+"/json/email_exists/");}function _checkEists(element,valElementId,url){$.getJSON(url+escape(element.value),function(data){if(data.Exists){$(valElementId).show();}else{$(valElementId).hide();}});}(function($){$.blockUI=function(opts){install(window,opts);};$.unblockUI=function(opts){remove(window,opts);};$.fn.block=function(opts){return this.each(function(){if($.css(this,"position")=="static"){this.style.position="relative";}if($.browser.msie){this.style.zoom=1;}install(this,opts);});};$.fn.unblock=function(opts){return this.each(function(){remove(this,opts);});};$.blockUI.defaults={message:"",css:{padding:0,margin:0,top:"40%",left:"35%"},overlayCSS:{backgroundColor:"#000",opacity:"0.3"},baseZ:1000,allowBodyStretch:true,constrainTabKey:true,fadeOut:400,focusInput:true,applyPlatformOpacityRules:true,onUnblock:null,quirksmodeOffsetHack:4};var ie6=$.browser.msie&&/MSIE 6.0/.test(navigator.userAgent);var pageBlock=null;var pageBlockEls=[];function install(el,opts){var full=(el==window);var msg=opts&&opts.message!==undefined?opts.message:undefined;opts=$.extend({},$.blockUI.defaults,opts||{});opts.overlayCSS=$.extend({},$.blockUI.defaults.overlayCSS,opts.overlayCSS||{});var css=$.extend({},$.blockUI.defaults.css,opts.css||{});msg=msg===undefined?opts.message:msg;if(full&&pageBlock){remove(window,{fadeOut:0});}if(msg&&typeof msg!="string"&&(msg.parentNode||msg.jquery)){var node=msg.jquery?msg[0]:msg;var data={};$(el).data("blockUI.history",data);data.el=node;data.parent=node.parentNode;data.display=node.style.display;data.position=node.style.position;data.parent.removeChild(node);}var z=opts.baseZ;var lyr1=($.browser.msie)?$('<iframe class="blockUI" style="z-index:'+z+++';border:none;margin:0;padding:0;position:absolute;width:100%;height:100%;top:0;left:0" src="javascript:false;"></iframe>'):$('<div class="blockUI" style="display:none"></div>');var lyr2=$('<div class="blockUI blockOverlay" style="z-index:'+z+++';cursor:wait;border:none;margin:0;padding:0;width:100%;height:100%;top:0;left:0"></div>');var lyr3=full?$('<div id="lyr3BlockUI" class="blockUI blockMsg blockPage" style="z-index:'+z+';position:fixed"></div>'):$('<div class="blockUI blockMsg blockElement" style="z-index:'+z+';display:none;position:absolute"></div>');if(msg){lyr3.css(css);}if(!opts.applyPlatformOpacityRules||!($.browser.mozilla&&/Linux/.test(navigator.platform))){lyr2.css(opts.overlayCSS);}lyr2.css("position",full?"fixed":"absolute");if($.browser.msie){lyr1.css("opacity","0.0");}$([lyr1[0],lyr2[0],lyr3[0]]).appendTo(full?"body":el);var expr=$.browser.msie&&(!$.boxModel||$("object,embed",full?null:el).length>0);if(ie6||expr){if(full&&opts.allowBodyStretch&&$.boxModel){$("html,body").css("height","100%");}if((ie6||!$.boxModel)&&!full){var t=sz(el,"borderTopWidth"),l=sz(el,"borderLeftWidth");var fixT=t?"(0 - "+t+")":0;var fixL=l?"(0 - "+l+")":0;}$.each([lyr1,lyr2,lyr3],function(i,o){var s=o[0].style;s.position="absolute";if(i<2){if(full){var h=Math.max(document.body.scrollHeight,document.body.offsetHeight)-(jQuery.boxModel?0:opts.quirksmodeOffsetHack);var w=jQuery.boxModel&&document.documentElement.clientWidth||document.body.clientWidth;$(o[0]).css("height",h.toString()+"px");$(o[0]).css("width",w.toString()+"px");}else{$(o[0]).css("height",this.parentNode.offsetHeight);$(o[0]).css("width",this.parentNode.offsetWidth);}if(fixL){$(o).css("left",fixL);}if(fixT){$(o).css("top",fixT);}}else{if(opts.centerY&&this.offsetHeight!==undefined){if(full){$(o[0]).css("top",(document.documentElement.clientHeight||document.body.clientHeight)/2-(this.offsetHeight/2)+(blah=document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop));}s.marginTop=0;}}});}lyr3.append(msg).show();if(msg&&(msg.jquery||msg.nodeType)){$(msg).show();}bind(1,el,opts);if(full){pageBlock=lyr3[0];pageBlockEls=$(":input:enabled:visible",pageBlock);if(opts.focusInput){setTimeout(focus,20);}}else{center(lyr3[0]);}}function remove(el,opts){var full=el==window;var data=$(el).data("blockUI.history");opts=$.extend({},$.blockUI.defaults,opts||{});bind(0,el,opts);var els=full?$("body").children().filter(".blockUI"):$(".blockUI",el);if(full){pageBlock=pageBlockEls=null;}if(opts.fadeOut){els.fadeOut(opts.fadeOut);setTimeout(function(){reset(els,data,opts,el);},opts.fadeOut);}else{reset(els,data,opts,el);}}function reset(els,data,opts,el){els.each(function(i,o){if(this.parentNode){this.parentNode.removeChild(this);}});if(data&&data.el){data.el.style.display=data.display;data.el.style.position=data.position;data.parent.appendChild(data.el);$(data.el).removeData("blockUI.history");}if(typeof opts.onUnblock=="function"){opts.onUnblock(el,opts);}}function bind(b,el,opts){var full=el==window,$el=$(el);if(!b&&(full&&!pageBlock||!full&&!$el.data("blockUI.isBlocked"))){return;}if(!full){$el.data("blockUI.isBlocked",b);}var events="mousedown mouseup keydown keypress click";b?$(document).bind(events,opts,handler):$(document).unbind(events,handler);}function handler(e){if(e.keyCode&&e.keyCode==9){if(pageBlock&&e.data.constrainTabKey){var els=pageBlockEls;var fwd=!e.shiftKey&&e.target==els[els.length-1];var back=e.shiftKey&&e.target==els[0];if(fwd||back){setTimeout(function(){focus(back);},10);return false;}}}if($(e.target).parents("div.blockMsg").length>0){return true;}return $(e.target).parents().children().filter("div.blockUI").length==0;}function focus(back){if(!pageBlockEls){return;}var e=pageBlockEls[back===true?pageBlockEls.length-1:0];if(e){e.focus();}}function center(el){var p=el.parentNode,s=el.style;var l=((p.offsetWidth-el.offsetWidth)/2)-sz(p,"borderLeftWidth");var t=((p.offsetHeight-el.offsetHeight)/2)-sz(p,"borderTopWidth");s.left=l>0?(l+"px"):"0";s.top=t>0?(t+"px"):"0";}function sz(el,p){return parseInt($.css(el,p))||0;}})(jQuery);jQuery.cookie=function(name,value,options){if(typeof value!="undefined"){options=options||{};if(value===null){value="";options.expires=-1;}var expires="";if(options.expires&&(typeof options.expires=="number"||options.expires.toUTCString)){var date;if(typeof options.expires=="number"){date=new Date();date.setTime(date.getTime()+(options.expires*1000));}else{date=options.expires;}expires="; expires="+date.toUTCString();}var path=options.path?"; path="+(options.path):"";var domain=options.domain?"; domain="+(options.domain):"";var secure=options.secure?"; secure":"";document.cookie=[name,"=",encodeURIComponent(value),expires,path,domain,secure].join("");}else{var cookieValue=null;if(document.cookie&&document.cookie!=""){var cookies=document.cookie.split(";");for(var i=0;i<cookies.length;i++){var cookie=jQuery.trim(cookies[i]);if(cookie.substring(0,name.length+1)==(name+"=")){cookieValue=decodeURIComponent(cookie.substring(name.length+1));break;}}}return cookieValue;}};jQuery.deleteCookie=function(name){var cookie_date=new Date();cookie_date.setTime(cookie_date.getTime()-1);document.cookie=cookie_name+="=; expires="+cookie_date.toGMTString();};(function($){$.fn.extend({isChildOf:function(id){var parents=$(this).parents().get();for(j=0;j<parents.length;j++){if($(parents[j]).attr("id")==id){return true;}}return false;}});})(jQuery);
