var WishpotOnDomReadyFunctions=[];
var WPJS={FbJsHasInited:false,CheckBoxGetChecked:function(cb){return cb.checked},CheckBoxSetChecked:function(cb,value){cb.checked=value},CheckBoxToggleChecked:function(cb){WPJS.CheckBoxSetChecked(cb,!WPJS.CheckBoxGetChecked(cb))},CheckBoxSetAllChecked:function(cbname,value){WPJS.WithJQuery(function(){jQuery("INPUT[@name="+name+"][type='checkbox']").attr("checked",value)})},Alert:function(msg){return alert(msg)},AlertWithTitle:function(msg,title,timeout){var newdiv=document.createElement("div");WPJS.SetInnerXHTML(newdiv,
msg);return WPJS._OpenAlertDialog(title,newdiv,null,timeout)},SetStyle:function(obj,name,value){obj.style[name]=value},GetStyle:function(obj,name){return obj.style[name]},SetObjectDisplay:function(obj,displaytype,animateOn){var useAnimation=animateOn&&jQueryLoaded();var newDisplayType=WPJS.GetStyle(obj,"display")==displaytype?"none":displaytype;if(useAnimation&&newDisplayType=="none")jQuery(obj).hide(200);else if(useAnimation)jQuery(obj).show(200);else WPJS.SetStyle(obj,"display",newDisplayType)},
ShowObject:function(obj,animateOn){WPJS.SetObjectDisplay(obj,"",animateOn)},HideObject:function(obj,animateOn){WPJS.SetObjectDisplay(obj,"none",animateOn)},SetClass:function(obj,value){obj.className=value},GetClass:function(obj){return obj.className},GetSelectedIndex:function(obj){return obj.selectedIndex},GetOptions:function(obj){return obj.options},ClearOptions:function(select){while(select.options.length>0)select.remove(0)},CreateOption:function(name,value){return new Option(name,value)},AddOption:function(select,
option){var options=select.options;options[options.length]=option},GetValue:function(select){return select.value},SetValue:function(obj,newValue){return obj.value=newValue},SetInnerXHTML:function(obj,text){obj.innerHTML=text},SetSelected:function(obj,newValue){return obj.selected=newValue},GetSelected:function(obj){return obj.selected},SetDisabled:function(obj,newValue){return obj.disabled=newValue},GetDisabled:function(obj){return obj.disabled},GetClientWidth:function(obj){return obj.clientWidth},
GetClientHeight:function(obj){return obj.clientHeight},GoTo:function(url){window.top.location=url},SafeReload:function(win){if(win==null)win=window;var refreshUrl=win.location.href;var oldUrlArgs="";var argumentIndex=win.location.href.indexOf("?");if(argumentIndex>0){refreshUrl=win.location.href.substring(0,argumentIndex);oldUrlArgs=win.location.href.substring(argumentIndex+1)}var randomnumber=Math.floor(Math.random()*1E5);refreshUrl+="?r="+randomnumber+oldUrlArgs;win.location.href=refreshUrl},GetParentNode:function(obj){return obj.parentNode},
GetFirstChild:function(obj){return obj.firstChild},GetFirstRealChild:function(obj){var i=0;while(i<obj.childNodes.length){if(obj.childNodes[i].nodeType!=3)return obj.childNodes[i];i++}return null},GetRealChildNodes:function(obj){var nodes=new Array;var i=0;while(i<obj.childNodes.length){if(obj.childNodes[i].nodeType!=3)nodes.push(obj.childNodes[i]);i++}return nodes},GoToNewWindow:function(url,windowName,js_options){var opts=js_options!=null?js_options:"";return window.open(url,windowName,opts)},AddClass:function(obj,
className){var elem=EnsureEl(obj);elem.className+=" "+className},RemoveClass:function(obj,className){WPJS.WithJQuery(function(){$(obj).removeClass(className)})},RunOnDomReady:function(func){WishpotOnDomReadyFunctions.push(func)},GetBodyWidth:function(){var winW=null;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;return winW},GetElementsByClassName:function(className){if(document.getElementsByClassName)return document.getElementsByClassName(className);else{var i=0;var elems=[];var a=document.getElementsByTagName("*");while(element=a[i++])if(element.className==className)elems.push(element);return elems}},AddEvent:function(obj,type,fn){if(obj.attachEvent){obj["e"+type+fn]=fn;obj[type+fn]=function(){obj["e"+type+fn](window.event)};obj.attachEvent("on"+type,obj[type+fn])}else obj.addEventListener(type,
fn,false)},Debug:function(msg){},_OpenAlertDialog:function(title,div_obj,width,auto_close_ms,resizable){WithJQueryUi(function(){var diag=jQuery(div_obj);if(typeof width=="undefined")width=400;if(typeof resizable=="undefined")resizable=true;diag.dialog({modal:true,autoOpen:false,title:title,width:width,resizable:resizable});diag.show();diag.dialog("open");if(typeof auto_close_ms!="undefined")setTimeout(function(){diag.dialog("close")},auto_close_ms);return diag})},AlertDialogDiv:function(title,div_id,
width){return WPJS._OpenAlertDialog(title,document.getElementById(div_id),width)},AlertDialogDivNoResize:function(title,div_id,width){return WPJS._OpenAlertDialog(title,document.getElementById(div_id),width,undefined,false)},_OpenConfirmationDialog:function(title,div_obj,onsuccesscallback){WithJQueryUi(function(){var diag=jQuery(div_obj);diag.show();diag.dialog({modal:true,autoOpen:false,title:title,buttons:{Cancel:function(){$(this).dialog("close")},Ok:function(){onsuccesscallback();$(this).dialog("close")}}});
diag.dialog("open");return diag})},ConfirmationDialogDiv:function(title,div_id,onsuccesscallback){var div=document.getElementById(div_id);WPJS._OpenConfirmationDialog(title,div,onsuccesscallback)},ConfirmationDialog:function(title,message,onsuccesscallback){var newdiv=document.createElement("div");WPJS.SetInnerXHTML(newdiv,message);WPJS._OpenConfirmationDialog(title,newdiv,onsuccesscallback)},OnFbEvent:function(event,response,widget){WPJS.Debug(event);WPJS.Debug(response);WPJS.Debug(widget);WPJS.WithJQuery(function(){var data=
{response:response,event:event};if(typeof widget!="undefined")if(typeof widget.dom!="undefined"&&typeof widget.dom.attributes!="undefined")for(var i=0;i<widget.dom.attributes.length;i++){var start=widget.dom.attributes[i].name.indexOf("data-wishpot-");if(start>=0)data[widget.dom.attributes[i].name.replace("data-wishpot-","")]=widget.dom.attributes[i].value}else if(typeof widget.objid!="undefined"){data["objid"]=widget.objid;data["objtype"]=widget.objtype}jQuery.ajax({data:data,error:null,success:null,
type:"POST",dataType:"json",url:"/facebooklogger.axd"})})},WithJQuery:function(fn,attempt_num){if(jQueryLoaded())fn();else{if(!attempt_num)attempt_num=1;else attempt_num+=1;WPJS.Debug("Attempting Jquery load: "+attempt_num);if(attempt_num>g_MaxJqueryAttempts){alert("Sorry, we were unable to load the necessary libraries to complete this operation.  Please try again, and if the problem continues, contact us.");throw"Error loading JQuery after "+attempt_num+" tries.";}else setTimeout(function(){WPJS.WithJQuery(fn,
attempt_num)},1E3)}}};function GoTo(url){WPJS.GoTo(url)}function FormatReturnUrl(){var ruArg="ru="+encodeURIComponent(window.location);return ruArg}function DummyFunction(){return}function HitUrl(url,callback){var i=new Image(1,1);if(typeof callback=="undefined")callback=function(){DummyFunction()};i.onload=callback;i.onerror=callback;i.src=url}var last_err=null;
function ReportError(err,url,line){try{if(err==last_err&&err!=null)return true;last_err=err;var msg="";msg+=typeof err=="object"&&err.data?"["+err.code+": "+err.data+"]":err;var err_url=window.location.href;if(url!=null)err_url=url;var err_line=""+line;var url="/cerr.axd?msg="+encodeURIComponent(msg)+"&url="+encodeURIComponent(err_url)+"&line="+err_line+"&stack="+encodeURIComponent(stacktrace());HitUrl(url)}catch(ex2){}return true}
function AsyncErrHandler(ex,url,line){try{ReportError(ex,url,line)}catch(ex2){}try{alert("Sorry, an operation failed. Please try again later. \n["+ex+": "+line+"]")}catch(ex2){}}function JqueryAjaxErrHandler(XMLHttpRequest,textStatus,errorThrown){WPJS.Debug(XMLHttpRequest);return AsyncErrHandler(textStatus,window.location.href,errorThrown)}function stacktrace(){var s="";try{for(var a=stacktrace.caller;a!=null;a=a.caller){s+=funcname(a)+" <-- ";if(a.caller==a)break}}catch(ex){}return s}
function funcname(f){if(f==null)return"null?";var s=f.toString().match(/function (\w*)/)[1];if(s==null||s.length==0)return"anonymous";return s+" ("+f.arguments+")"}function FacebookPromptPermission(jsonPermissions,callbackFunc){FB.login(function(response){if(response.authResponse){if(typeof callbackFunc!="undefined")callbackFunc()}else WPJS.Alert("You must be logged in via facebook connect to perform this operation.")},jsonPermissions)}
function FacebookIsAuthed(callbackFunc){FB.getLoginStatus(function(response){if(response.authResponse){WPJS.Debug("Facebook session present.");callbackFunc(response.authResponse)}else{WPJS.Debug("No Facebook session present.");callbackFunc(null)}})}var g_JqueryPresent=false;var g_MaxJqueryAttempts=30;function jQueryLoaded(){return typeof jQuery!="undefined"}function jQueryUiLoaded(){return jQueryLoaded()&&typeof jQuery.ui!="undefined"}
function WithJQueryUi(fn,attempt_num){if(jQueryUiLoaded())try{fn()}catch(ex){AsyncErrHandler(ex)}else{if(!attempt_num)attempt_num=1;else attempt_num+=1;if(attempt_num>g_MaxJqueryAttempts){alert("Sorry, we were unable to load the necessary libraries to complete this operation.  Please try again, and if the problem continues, contact us.");throw"Error loading JQuery UI after "+attempt_num+" tries.";}else setTimeout(function(){WithJQueryUi(fn,attempt_num)},1E3)}}
function CloseDialog(id){WithJQueryUi(function(){var diag=$("#"+id);diag.dialog();diag.dialog("close")})}function BtnOn(el){if(el.className=="blink")el.className="blinkHov";else if(el.className=="link")el.className="linkHov"}function BtnOff(el){if(el.className=="blinkHov")el.className="blink";else if(el.className=="linkHov")el.className="link"}
function FormatDateTime(msecs,includeTime){d=new Date;localTime=msecs;d.setTime(localTime);res=d.getMonth()+1+"/"+d.getDate()+"/"+d.getFullYear();if(includeTime){h=d.getHours();m=d.getMinutes();ampm="AM";if(h>11){h=h-12;ampm="PM"}if(h==0)h=12;if(m<10)ms="0"+m;else ms=m.toString();res=res+" at "+h+":"+ms+" "+ampm}return res}function GoFindUser(sk){GoTo("/public/users/find.aspx?sk="+sk)}
function GoDeleteFriend(uid){if(confirm("Are you sure you want to remove this friend?"))GoTo("/my/actions.aspx?action=deletefriend&uid="+uid)}function Trim(s){return s.replace(/^\s\s*/,"").replace(/\s\s*$/,"")}
function DoUserBannerSubNavLayout(){var navlinks=WPJS.GetRealChildNodes(WPJS.GetFirstRealChild(document.getElementById("wishpot-pagenav")));var idealSize=Math.floor(100/navlinks.length);var firstItemSize=idealSize;if(document.getElementById("wishpot-pagenav").offsetWidth*idealSize/100>125){idealSize=12;firstItemSize=14}else firstItemSize=98-idealSize*(navlinks.length-1);for(var i=0;i<navlinks.length;i++)WPJS.SetStyle(navlinks[i],"width",(i==0?firstItemSize:idealSize)+"%")}
function SetWish(wid,action){document.getElementById("WishIdInput").value=wid;document.getElementById("WishActionInput").value=action}function ConfirmDeleteWish(url){if(confirm("Are you sure you want to delete this item?"))GoTo(url)}function GoArchiveWish(wid){GoTo("/my/actions.aspx?action=setstatus&status=purchased&wid="+wid+"&"+FormatReturnUrl())}function GoUnarchiveWish(wid){GoTo("/my/actions.aspx?action=setstatus&status=unpurchased&wid="+wid+"&"+FormatReturnUrl())}
function GoDeleteWishComment(wid,cid){if(confirm("Are you sure you want to delete this comment?"))GoTo("/my/actions.aspx?action=deletecomment&wid="+wid+"&cid="+cid)}function GoFlagWishComment(wid,cid){if(confirm("Are you sure you want to mark this comment as spam and delete it?"))GoTo("/my/actions.aspx?action=flaganddeletecomment&wid="+wid+"&cid="+cid)}
function MerchantLink(baseUrl,offerUrl,offerPrice){var u=AppendOrReplaceInUrl(baseUrl,"url",offerUrl);if(offerPrice)u=AppendOrReplaceInUrl(u,"pr",offerPrice);return u}function SearchBoxFocus(tb){if(tb.className!="searchBoxTip")return;tb.value="";tb.className="searchBox"}function ValidateSearch(tbid){var tb=document.getElementById(tbid);return tb.className!="searchBoxTip"}
function ToggleDisplayAndFocus(id,focusEl){ToggleDisplay(id);var div=document.getElementById(id);if(div.style.display=="block")document.getElementById(focusEl).focus()}
function OpenReserveDialog(id,murl,mname,onClickCallback){var hasCallback=typeof onClickCallback!="undefined";if(document.getElementById(id)==null&&hasCallback)onClickCallback();WPJS.WithJQuery(function(){var reserveDiv=jQuery("#"+id);if(murl){reserveDiv.find("div.forReserve").removeClass("forReserve").addClass("forBuy");reserveDiv.find("input.__murl").attr("value",murl);reserveDiv.find("input.__mname").attr("value",mname);reserveDiv.find("a.__murl").attr("href",murl)}if(hasCallback){reserveDiv.find("div.forReserve").removeClass("forReserve").addClass("forBuy");
reserveDiv.find(".wishpot-reserve").click(onClickCallback);reserveDiv.find("a.__murl").attr("href","#").attr("target","").click(onClickCallback)}});WPJS.AlertDialogDiv("",id)}function AssociateCurrentUserWithFacebook(callback){WPJS.WithJQuery(function(){var url=WISHPOT_API_ROOT+"/User/OAuthCredential/Create?OAuthCredential.SocialNetwork=Facebook";jQuery.ajax({data:"",error:callback,success:callback,type:"POST",dataType:"xml",url:url})})}
function DoWishShare(network,wishId,callback){WPJS.WithJQuery(function(){var url=WISHPOT_API_ROOT+"/Wish/Share/"+wishId;jQuery.ajax({data:"SocialNetwork="+network,error:JqueryAjaxErrHandler,success:callback,type:"POST",dataType:"xml",url:url})})}
function OpenReviewDialog(title,divid,uid,pid){WPJS.WithJQuery(function(){var url=WISHPOT_API_ROOT+"/ProductReview/Details/?uid="+uid+"&pid="+pid;jQuery.ajax({data:"",error:LoadReviewData,success:LoadReviewData,type:"GET",dataType:"json",url:url});WPJS.AlertDialogDiv(title,divid)})}
function LoadReviewData(req,textStatus){if(req&&req.Id){var f=jQuery("#WishpotReviewForm_"+req.ProductId);f.find("[name=SummaryInput]").val(req.Summary);f.find("[name=ReviewInput]").val(req.Text);f.find("[name=RatingInput]").val(req.Rating);f.find(".current-rating").attr("class","current-rating "+WP_NUMBERS[req.Rating]+"-stars");SetExistingRating("WriteReviewDiv_"+req.ProductId+"_formValue")}else WPJS.Debug("Could not find/load existing rating: "+textStatus)}
function BeginBuy(uid,wid,pid){var url="/ajax/bestoffer.aspx?uid="+uid+"&wid="+wid+"&pid="+pid;var callback=function(data){EndBuy(data,wid)};WPJS.WithJQuery(function(){jQuery.ajax({data:"",error:function(){PerformBuyNoAjaxOrDialog(uid,wid,pid)},success:callback,type:"GET",dataType:"json",url:url})})}function PerformBuyNoAjaxOrDialog(uid,wid,pid){ReportError("Performing BeginBuy without ajax, due to a js load issue");WPJS.GoTo("/public/bestoffer.aspx?uid="+uid+"&wid="+wid+"&pid="+pid)}
function EndBuy(data,wid){OpenReserveDialog("popRes_"+wid,data.MerchantUrl,data.MerchantName)}function BeginBuyNoNavigate(wid,callback){var id="popRes_"+wid;OpenReserveDialog(id,null,null,callback);if(document.getElementById(id)!=null)WPJS.WithJQuery(function(){var reserveDiv=jQuery("#"+id);reserveDiv.find("input[name='ru']").attr("value",window.location.href)})}
function AutoCompleteCategories(term,callback){_CategorySearch(term,function(results){callback(jQuery.map(results,function(val,index){return val["Name"]}))})}function FindIdByCategory(categoryName,callback){_CategorySearch(categoryName,function(results){if(results.length<1){callback(null);return}callback(results[0]["Id"])})}
function FindCategoryById(id,callback){var numeric=!isNaN(parseFloat(id))&&isFinite(id);if(!numeric){callback(null);return}WPJS.WithJQuery(function(){jQuery.ajax({data:"",error:JqueryAjaxErrHandler,type:"GET",dataType:"json",url:WISHPOT_API_ROOT+"Category/Details/"+id,success:function(data,textStatus,jqXHR){callback(data)}})})}var _WishpotCategoryJsonCache={};
function _CategorySearch(term,callback){WPJS.WithJQuery(function(){if(term in _WishpotCategoryJsonCache){callback(_WishpotCategoryJsonCache[term]);return}jQuery.ajax({data:{"q":term},error:JqueryAjaxErrHandler,type:"GET",dataType:"json",url:WISHPOT_API_ROOT+"Category/AutoComplete",success:function(data,textStatus,jqXHR){if(typeof data!="undefined"&&null!=data&&null!=data["Categories"])_WishpotCategoryJsonCache[term]=data["Categories"];callback(_WishpotCategoryJsonCache[term])}})})}
function ToggleAltPicPicker(){SetAltThumbStyles(-1);var id="AltPicPicker";var altClass="AltPicPickerToggle";var textId="AltPicPickerText";var el=document.getElementById(id);var tel=document.getElementById(textId);if(el.style.display=="block"){el.style.display="none";tel.innerHTML="see more pictures";tel.style.visibility="visible";if(altClass!=null)WPJS.WithJQuery(function(){jQuery("."+altClass).css("visibility","visible")})}else{el.style.display="block";tel.innerHTML="see item details";if(altClass!=
null)WPJS.WithJQuery(function(){jQuery("."+altClass).css("visibility","hidden")})}}function GetPrefAltPic(){return document.getElementById("PrefPic").value*1}function SetPrefAltPic(idx){document.getElementById("PrefPic").value=idx}function GetAltPicCount(){return document.getElementById("PicCount").value*1}function GetAltPicEl(idx){return document.getElementById("AltPic"+idx)}function GetAltThumbEl(idx){return document.getElementById("AltThumb"+idx)}
function SetAltPic(idx){var picCount=GetAltPicCount();for(var i=0;i<picCount;i++){var el=GetAltPicEl(i);if(i==idx)el.style.display="block";else el.style.display="none"}}function SetAltThumbStyles(tempSel){var picCount=GetAltPicCount();var pref=GetPrefAltPic();for(var i=0;i<picCount;i++){var el=GetAltThumbEl(i);if(i==pref)el.className="SelAltThumb";else if(i==tempSel)el.className="TempSelAltThumb";else el.className="AltThumb"}}
function AltThumbMouseOver(idx){var pref=GetPrefAltPic();if(pref!=idx){var el=GetAltThumbEl(idx);el.className="TempSelAltThumb"}SetAltPic(idx);document.getElementById("AltPicPickerText").style.visibility="hidden"}function AltThumbMouseOut(idx){var pref=GetPrefAltPic();if(pref!=idx){var el=GetAltThumbEl(idx);el.className="AltThumb"}SetAltPic(pref);document.getElementById("AltPicPickerText").style.visibility="visible"}
function AltThumbClick(idx){SetAltPic(idx);SetPrefAltPic(idx);ToggleAltPicPicker()}function GoResendVerificationMail(){GoTo("/my/actions.aspx?action=resendmail")}function FindParentForm(el){while(el&&el.nodeName&&el.nodeName.toLowerCase()!="form")el=el.parentNode;return el}function SubmitForm(el){var form=FindParentForm(el);if(form)form.submit()}
function SetAction(element,action,confirmText){if(confirmText!=null&&confirmText.length>0)if(!confirm(confirmText))return false;document.getElementById("Action").value=action;SubmitForm(element);return true}function UpdateEveryoneChkBox(){var friendsChkBox=document.getElementById("AcceptFromFriendsInput");var everyoneChkBox=document.getElementById("AcceptFromEveryoneInput");if(!friendsChkBox.checked)everyoneChkBox.checked=false;return true}
function UpdateFriendsChkBox(){var friendsChkBox=document.getElementById("AcceptFromFriendsInput");var everyoneChkBox=document.getElementById("AcceptFromEveryoneInput");if(everyoneChkBox.checked)friendsChkBox.checked=true;return true}function GetChkBoxes(inForm){var retnode=[];var elements=document.getElementsByTagName("input");for(var i=0;i<elements.length;i++){console.log(elements[i].type);if(elements[i].type=="checkbox")retnode.push(elements[i])}return retnode}
function UpdateChkBoxes(allChkBox){var elements=GetChkBoxes(FindParentForm(allChkBox));for(var i=0;i<elements.length;i++)WPJS.CheckBoxSetChecked(elements[i],WPJS.CheckBoxGetChecked(allChkBox))}function AtLeastOneChecked(inForm){var elements=GetChkBoxes(inForm);var oneChecked=false;for(var i=0;i<elements.length;i++)if(elements[i].checked){oneChecked=true;break}return oneChecked}
function ConfirmDelete(el){if(AtLeastOneChecked(FindParentForm(el))){if(confirm("Are you sure you want do delete these messages?"))SubmitForm(el)}else alert("Please select the messages you want to delete")}function IfCheckedSubmitForm(el){if(AtLeastOneChecked(FindParentForm(el)))SubmitForm(el);else alert("Please select the messages you want to delete")}
function GetListProperties(id,arrayOfListProperties){for(var i=0;i<arrayOfListProperties.length;i++)if(arrayOfListProperties[i].Id==id)return arrayOfListProperties[i];return null}
function ToggleSelectCreateList(el,createNew){var form=FindParentForm(el);if(form){var listSelectDiv=FindChildElementById(form,"ListSelectDiv");var newListDiv=FindChildElementById(form,"NewListDiv");var createNewList=form.CreateNewList;createNewList.value=createNew;if(createNew){listSelectDiv.style.display="none";newListDiv.style.display="block"}else{newListDiv.style.display="none";listSelectDiv.style.display="block"}}return false}
function EnableListSelect(el){return ToggleSelectCreateList(el,false)}function EnableNewList(el){return ToggleSelectCreateList(el,true)}function SetListNameValidation(enable){window.Page_Validators[0].enabled=enable}
function UpdateWishProperties(){var createNewList=WPJS.GetValue(document.getElementById("CreateNewList"));if(createNewList.toLowerCase()=="true"){var lt=WPJS.GetValue(document.getElementById("ListType"));var props=GetListProperties(lt,ListPicker_ListTypeProperties);props.AccessType=0;for(var i=0;i<3;i++){var atBtn=document.getElementById("La_"+i);if(WPJS.CheckBoxGetChecked(atBtn)){props.AccessType=atBtn.value;break}}SetWishProperties(props,null)}else{var lid=WPJS.GetValue(document.getElementById("ListSelect"));
var props=GetListProperties(lid,ListPicker_ListProperties);SetWishProperties(props,lid)}return false}
function SetWishProperties(props,listId){if(props==null)return;SetAvailable_WishAccessFormControl(props.AccessType);var priorityDiv=document.getElementById("PriorityPanel");if(priorityDiv!=null)if(props.SupportsPriority)priorityDiv.style.display="block";else priorityDiv.style.display="none";var recipientDiv=document.getElementById("RecipientPanel");if(recipientDiv!=null)if(props.SupportsRecipient)recipientDiv.style.display="block";else recipientDiv.style.display="none";var occasionDiv=document.getElementById("OccasionPanel");
if(occasionDiv!=null)if(props.SupportsOccasion)occasionDiv.style.display="block";else occasionDiv.style.display="none";var notesDiv=document.getElementById("NotesPanel");if(notesDiv!=null)if(props.SupportsNotes)notesDiv.style.display="block";else notesDiv.style.display="none";var reviewsDiv=document.getElementById("ReviewPanel");if(reviewsDiv!=null)if(props.SupportsReviews)reviewsDiv.style.display="block";else reviewsDiv.style.display="none";var quantityDiv=document.getElementById("QuantityPanel");
if(quantityDiv!=null)if(props.SupportsQuantity)quantityDiv.style.display="block";else quantityDiv.style.display="none";if(typeof AlertProperties_NotifyListTypeChanged!="undefined")AlertProperties_NotifyListTypeChanged(props.EnableAlertsByDefault);if(typeof ContributionProperties_SetPanelVisibility!="undefined")ContributionProperties_SetPanelVisibility(props.SupportsContributions)}
function ToggleEditWishBody(id){var elem=EnsureEl(id);WPJS.WithJQuery(function(){var wasVisible=jQuery(elem).is(":visible");jQuery(".EditWishToggleBody").hide(wasVisible?300:0);if(!wasVisible)ToggleDisplayByObject(elem,"block",true)})}
function MakeAbsoluteLinks(text,base_url){var url_with_slash=base_url;var url_no_slash=base_url;if(/\/$/.test(base_url))url_no_slash=base_url.substring(0,base_url.length-1);else url_with_slash=base_url+"/";var regexps=[new RegExp(/(\shref=")(\S*)(")/gim),new RegExp(/(\shref=')(\S*)(')/gim),new RegExp(/(\ssrc=")(\S*)(")/gim),new RegExp(/(\ssrc=')(\S*)(')/gim),new RegExp(/(background-image: url\(")(\S*)("\))/gim),new RegExp(/(background-image: url\(')(\S*)('\))/gim),new RegExp(/(background-image: url\()(\S*)(\))/gim)];
var AbsoluteLink=new RegExp("http://|https://|mailto:","gim");var ret_text=text;for(i=0;i<regexps.length;i++)ret_text=ret_text.replace(regexps[i],function(m){var r=new RegExp(regexps[i]);var newUrl=r.exec(m)[2];if(newUrl.match(AbsoluteLink)){WPJS.Debug("["+i+"] Skipping, url already absolute: "+newUrl);return m}newUrl=/^\//.test(newUrl)?url_no_slash+newUrl:url_with_slash+newUrl;return m.replace(regexps[i],"$1"+newUrl+"$3")});return ret_text}
function AfterMoveCopy(operation,wid,api_response){CloseDialog("CopyMoveDiv_"+wid);$("button").removeClass("clicked");if(operation=="move"||operation=="delete")$("#Wish_"+wid).slideUp(1E3);if(operation=="copy")var d=WPJS.AlertWithTitle("Wish copied.","Operation complete",1E3)}
function AjaxMoveCopy(form_obj){var op=WPJS.GetValue(form_obj["operation"]);var wid=WPJS.GetValue(form_obj["Wish.Id"]);var callback=function(data,textStatus){AfterMoveCopy(op,wid,data)};DoAjaxMoveCopy(form_obj,op,wid,callback)}
function DoAjaxMoveCopy(form_obj,op,wid,callback){var url="";if(op=="move")url=WISHPOT_API_ROOT+"Wish/Edit/"+wid;else if(op=="copy")url=WISHPOT_API_ROOT+"Wish/Copy";jQuery.ajax({data:$(form_obj).serialize(),error:JqueryAjaxErrHandler,success:callback,type:"POST",dataType:"xml",url:url})}function AjaxDelete(wid){var callback=function(data){AfterMoveCopy("delete",wid,data)};DoAjaxDelete(wid,callback)}
function DoAjaxDelete(wid,callback){jQuery.ajax({data:"",error:JqueryAjaxErrHandler,success:callback,type:"POST",dataType:"text",url:WISHPOT_API_ROOT+"Wish/Delete/"+wid})}
function DoAjaxSetDefaultListSort(lid){var sortValue=document.getElementById("SortSelect").value;var callback=function(data){AfterSetDefault()};var active=WPJS.GetStyle(document.getElementById("setDefaultSort"),"display");if(active!="inline")sortValue="";jQuery.ajax({data:"List.UserDefSort="+sortValue,error:JqueryAjaxErrHandler,success:callback,type:"POST",dataType:"text",url:WISHPOT_API_ROOT+"/List/Edit/"+lid})}
function AfterSetDefault(){ToggleDisplayByObject(document.getElementById("currentDefaultSort"),"inline");ToggleDisplayByObject(document.getElementById("setDefaultSort"),"inline")}function DoAjaxFollow(uid){jQuery.ajax({data:"",error:JqueryAjaxErrHandler,success:function(data){WPJS.SafeReload()},type:"POST",dataType:"text",url:WISHPOT_API_ROOT+"User/Follow/Create/"+uid})}
function DoAjaxUnFollow(uid){jQuery.ajax({data:"",error:JqueryAjaxErrHandler,success:function(data){WPJS.SafeReload()},type:"POST",dataType:"text",url:WISHPOT_API_ROOT+"User/Follow/Delete/"+uid})}function FindChildElementById(parent,id){var children=parent.childNodes;if(children!=null)for(var i=0;i<children.length;i++){if(children[i].id==id)return children[i];var el=FindChildElementById(children[i],id);if(el!=null)return el}return null}
function EnsureEl(idOrEl){if(typeof idOrEl=="string")idOrEl=document.getElementById(idOrEl);return idOrEl}function rgbToHex(rgbstring){if(rgbstring){if(rgbstring.indexOf("rgb(")==-1)return rgbstring;var parts=rgbstring.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);delete parts[0];for(var i=1;i<=3;++i){parts[i]=parseInt(parts[i],0).toString(16);if(parts[i].length==1)parts[i]="0"+parts[i]}var hexstring=parts.join("");return"#"+hexstring}}
function normalizeStyleValues(string,optionalReferenceObj){if(string.indexOf("rgb")!=-1){var parts=string.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);delete parts[0];for(var i=1;i<=3;++i){parts[i]=parseInt(parts[i],0).toString(16);if(parts[i].length==1)parts[i]="0"+parts[i]}var hexString=parts.join("");return"#"+hexString}else if(string.indexOf("#")!=-1)return string;else if(string.indexOf("px")!=-1&&optionalReferenceObj){var objheight=jQuery(optionalReferenceObj).height();var objWidth=jQuery(optionalReferenceObj).width();
var x=string.split(" ")[0];var y=string.split(" ")[1];x=x=="0px"?"0%":x==objWidth+"px"?"100%":x==objWidth/2+"px"?"50%":x;y=y=="0px"?"0%":y==objheight+"px"?"100%":y==objheight/2+"px"?"50%":y;string=x+" "+y;return string}else{string=string.replace(/top/g,"0%");string=string.replace(/bottom/g,"100%");string=string.replace(/left/g,"0%");string=string.replace(/right/g,"100%");string=string.replace(/center/g,"50%");return string}}
function parseUri(str){var o=parseUri.options,m=o.parser[o.strictMode?"strict":"loose"].exec(str),uri={},i=14;while(i--)uri[o.key[i]]=m[i]||"";uri[o.q.name]={};uri[o.key[12]].replace(o.q.parser,function($0,$1,$2){if($1)uri[o.q.name][$1]=$2});return uri}
parseUri.options={strictMode:false,key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}};
function AppendOrReplaceInUrl(baseUrl,key,value){key=encodeURIComponent(key);value=encodeURIComponent(value);var kvp=parseUri(baseUrl).queryKey;var newQs="";if(kvp==null||kvp=="")newQs=key+"="+value;else{kvp[key]=value;var paramArray=[];for(var k in kvp)paramArray.push(k+"="+kvp[k]);newQs=paramArray.join("&")}var root=baseUrl;var queryPos=baseUrl.indexOf("?");if(queryPos>0)root=root.substring(0,queryPos);return root+"?"+newQs}
function ToggleBlockDisplay(obj){return ToggleDisplayByObject(EnsureEl(obj),"block")}function ToggleDisplayByObject(obj,displaytype,animateOn){WPJS.SetObjectDisplay(obj,displaytype,animateOn)}function ToggleDisplay(id){ToggleBlockDisplay(document.getElementById(id))}function ToggleEnabled(obj){WPJS.SetDisabled(obj,!WPJS.GetDisabled(obj))}
function ValidatePositiveNumeric(source,args){args.IsValid=true;var numericValue=parseFloat(args.Value);if(isNaN(args.Value)||numericValue<=0){args.IsValid=false;WPJS.SetInnerXHTML(source,"Value must be a number greater than zero.");return}}
function fitToProductBox(img){if(null==img)return;var heightBigger=WPJS.GetClientHeight(img)>WPJS.GetClientWidth(img);if(heightBigger){WPJS.SetStyle(img,"width","150px");if(WPJS.GetClientHeight(img)>0)WPJS.SetStyle(img,"marginTop",Math.round((150-WPJS.GetClientHeight(img))/2)+"px")}else{WPJS.SetStyle(img,"height","150px");if(WPJS.GetClientWidth(img)>0)WPJS.SetStyle(img,"marginLeft",Math.round((150-WPJS.GetClientWidth(img))/2)+"px")}}
function AppendInputTypeClasses(){if(!document.getElementsByTagName)return;var inputs=document.getElementsByTagName("input");var inputLen=inputs.length;for(var i=0;i<inputLen;i++)if(inputs[i].getAttribute("type"))inputs[i].className+=" "+inputs[i].getAttribute("type")}
function DrawRating(itemId,rating){var ratingDiv=document.getElementById("RatingString_"+itemId);if(rating==0)WPJS.SetInnerXHTML(ratingDiv,"<b>No Rating</b>");else if(rating==1)WPJS.SetInnerXHTML(ratingDiv,"<b>I hate it!</b>");else if(rating==2)WPJS.SetInnerXHTML(ratingDiv,"<b>I don't like it</b>");else if(rating==3)WPJS.SetInnerXHTML(ratingDiv,"<b>I like it</b>");else if(rating==4)WPJS.SetInnerXHTML(ratingDiv,"<b>I really like it</b>");else if(rating==5)WPJS.SetInnerXHTML(ratingDiv,"<b>I love it!</b>")}
function SetExistingRating(itemId){var rating=WPJS.GetValue(document.getElementById("RatingInput_"+itemId));DrawRating(itemId,rating)}function SetRating(itemId,rating){WPJS.SetValue(document.getElementById("RatingInput_"+itemId),rating)}function JumpToPage(){var baseUrl=document.getElementById("PagerBaseUrl").value;var page=document.getElementById("JumpToPageInput").value;WPJS.GoTo(baseUrl+page)}
function SortChange(){var baseUrl=document.getElementById("SorterBaseUrl").value;var sortValue=document.getElementById("SortSelect").value;WPJS.GoTo(baseUrl+sortValue)}function WishStatusSelectionChange(){var baseUrl=document.getElementById("WishStatusSelectorBaseUrl").value;var sortValue=document.getElementById("WishStatusSelectorSelect").value;WPJS.GoTo(baseUrl+sortValue)}
function UpdateButtonCode(buttonLink,textAreaName){var newSrc=jQuery(buttonLink).children("img.addButton").attr("src");textAreaName=EnsureEl(textAreaName);jQuery(textAreaName).val(jQuery(textAreaName).val().replace(/img src=".+"/i,'img src="'+newSrc+'"'))}function VolusionCartAdd(siteUrl,sku,wid){BeginBuyNewWindow("http://"+siteUrl+"/ShoppingCart.asp?ProductCode="+sku,"VolusionCart",wid)}
function BeginBuyNewWindow(urlForNewWindow,newWindowName,wid){try{BeginBuyNoNavigate(wid,function(){var w=WPJS.GoToNewWindow(urlForNewWindow,newWindowName);try{w.focus()}catch(ex){WPJS.Debug(ex)}})}catch(ex){WPJS.Debug(ex)}}var WP_MONTHNAMES=["January","February","March","April","May","June","July","August","September","October","November","December"];var WP_DAYNAMES=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
var WP_NUMBERS=["zero","one","two","three","four","five","six","seven","eight","nine","ten"];
