function validateInteger(argvalue){argvalue=argvalue.toString();var validChars="0123456789";var startFrom=0;if(argvalue.substring(0,2)=="0x"){validChars="0123456789abcdefABCDEF";startFrom=2;}else if(argvalue.charAt(0)=="0"){validChars="01234567";startFrom=1;}
for(var n=startFrom;n<argvalue.length;n++){if(validChars.indexOf(argvalue.substring(n,n+1))==-1)return false;}
return true;}
function addToCartFunction(){var addToCartBtnElement=document.getElementById('addToCartBtn');addToCartBtnElement.disabled="disabled";var form=document.getElementById("addToCart");var listingOptionId=null;var quantity=form.entryQuantity.value;if(form.listingOptionId){listingOptionId=form.listingOptionId.value;}
sfAddToCart(listingId,listingOptionId,quantity);}
function smartTrunc(targetDiv,maxHeight,defaultFontSize){if(!targetDiv){return;}
if(targetDiv&&targetDiv.scrollHeight&&targetDiv.scrollHeight>maxHeight){targetDiv.innerHTML=targetDiv.innerHTML+'...';while(targetDiv.scrollHeight>maxHeight&&targetDiv.innerHTML.length>3){targetDiv.innerHTML=targetDiv.innerHTML.substring(0,targetDiv.innerHTML.length-4)+'...';}}}
function favByObject(imageurl,userProfileId){this.imageurl=imageurl;this.loginId=userProfileId;this.itemHTML=getFavByItemHTML(imageurl,userProfileId);}
function getFavByItemHTML(url,loginName){var html='<a href=/users/'+loginName+'><img src="'+url+'" width="52" height="52" border="0" alt="" title="'+loginName+'"/></a>';return html;};function listingPhotosCarouselItem(index,bigThumbURL){this.bigThumbURL=bigThumbURL;this.index=index;this.itemHTML=listingPhotosCarousel_getItemHTML(this);}
function listingPhotosCarousel_getItemHTML(lPhotosObj){var html='<a href=javascript:showListingPhotos("'+lPhotosObj.index+'");><img src="'+lPhotosObj.bigThumbURL+'" width="130" height="105" border="0" class="imageborder"/></a>';return html;};function changeExternalEmbedCode(vidBoxText){if(vidBoxText.indexOf("www.youtube.com")>1){if(vidBoxText.indexOf("wmode")<1){vidBoxText=vidBoxText.replace('allowfullscreen=','wmode="transparent" allowfullscreen=');}
if(vidBoxText.indexOf('height="344"')>1||vidBoxText.indexOf('width="425"')>1){vidBoxText=vidBoxText.replace(/height="344"/g,'height="386"');vidBoxText=vidBoxText.replace(/width="425"/g,'width="480"');}
if(vidBoxText.indexOf('height=344')>1||vidBoxText.indexOf('width=425')>1){vidBoxText=vidBoxText.replace(/height=344/g,'height=386');vidBoxText=vidBoxText.replace(/width=425/g,'width=480');}}
return vidBoxText;}
function fixExternalEmbedCode(){document.getElementById('videocontainer').innerHTML=changeExternalEmbedCode(document.getElementById('videocontainer').innerHTML);}
function clearExternalEmbedCodeItemTab(){var vidBox=document.getElementById('tab1');vidBox.innerHTML='';}
function fixExternalEmbedCodeItemTab(){document.getElementById('listing-external-embed-code').innerHTML=changeExternalEmbedCode(document.getElementById('listing-external-embed-code').innerHTML);document.getElementById('tab1').innerHTML=changeExternalEmbedCode(document.getElementById('listing-external-embed-code').innerHTML);}
function clearExternalEmbedCodeDesignerTab(){var vidBox=document.getElementById('tab2');vidBox.innerHTML='';}
function fixExternalEmbedCodeDesignerTab(){document.getElementById('store-external-embed-code').innerHTML=changeExternalEmbedCode(document.getElementById('store-external-embed-code').innerHTML);document.getElementById('tab2').innerHTML=changeExternalEmbedCode(document.getElementById('store-external-embed-code').innerHTML);};var combodropoffsetY=2
var combozindex=100
function dhtmlselect(setValue,selectid,numOptions,selectwidth,optionwidth,divToHide){var dhtmlselectbox=document.getElementById("dhtml_"+selectid);if(typeof selectwidth!="undefined")
dhtmlselectbox.style.width=selectwidth;if(typeof optionwidth!="undefined")
document.getElementById("optionsDropdown").style.width=optionwidth;document.getElementById("optionsDropdown").style.top=dhtmlselectbox.offsetHeight-combodropoffsetY+"px";dhtmlselectbox.getElementsByTagName("span")[0].onclick=mainBoxOnClick;if(numOptions){widenAsNeeded(document.getElementById("optionsDropdown"),numOptions*17,350);}}
var hideMenuClickoutToggle=false;function mainBoxOnClick(){var dropdown=document.getElementById("optionsDropdown");if(dropdown.style.display=="block"){dropdown.style.display="none";activateAddToCart();}else{document.getElementById('dhtml_listingOptionId').style.overflow="visible";dropdown.style.display="block";dropdown.style.visibility="visible";deactivateAddToCart();document.onclick=hideMenuClickout;hideMenuClickoutToggle=false;}}
function pulsateItem(itemName){hideMenuClickoutToggle=false;Effect.Pulsate(itemName,{pulses:3,duration:1.0});return false;}
function hideMenuClickout(){if(document.getElementById("optionsDropdown").style.display!="none"&&hideMenuClickoutToggle){hideMenu();hideMenuClickoutToggle=false;}
else{hideMenuClickoutToggle=true;}}
function hideMenu(){document.getElementById("optionsDropdown").style.display="none";document.getElementById('dhtml_listingOptionId').style.overflow="hidden";document.onclick='';activateAddToCart();}
var savedAddToCartBtnOnClick=null;function activateAddToCart(){if(savedAddToCartBtnOnClick!=null){document.getElementById('addToCartBtn').onclick=savedAddToCartBtnOnClick;}}
function deactivateAddToCart(){savedAddToCartBtnOnClick=document.getElementById('addToCartBtn').onclick;document.getElementById('addToCartBtn').onclick='';}
function dhtmlselectChange(selectid,selectedValue,selectedText,quantity,selectedPrice,selectedRegularPrice){var setValue=selectid;var textId="dhtml_"+selectid+"_text";var priceId="dhtml_"+selectid+"_price";document.getElementById(setValue).value=selectedValue;if(selectedText.length>25){var shortText=selectedText.substring(0,25)+"&hellip;";document.getElementById(textId).innerHTML=shortText;}else{document.getElementById(textId).innerHTML=selectedText;}
document.getElementById(priceId).innerHTML='';document.getElementById('listingPrice').className='header1';document.getElementById('listingPrice').innerHTML='$'+selectedPrice;if(parseFloat(selectedPrice.replace(/,/g,''))<parseFloat(selectedRegularPrice.replace(/,/g,''))){document.getElementById('listingPrice').className='isSale '+document.getElementById('listingPrice').className;document.getElementById('listingPrice').innerHTML='SALE: '+document.getElementById('listingPrice').innerHTML;document.getElementById('listingRegularPrice').innerHTML='(REG: $'+selectedRegularPrice+')';}else{document.getElementById('listingRegularPrice').innerHTML='';}
updateQuantity('listingQuantity',quantity);document.getElementById("optionsDropdown").style.display="block";setTimeout("hideMenu();",1);activateAddToCart();}
function updateQuantity(quantityDivName,quantity){var quantityDiv=document.getElementById(quantityDivName);if(!quantityDiv){return;}
if(quantity<=20){quantityDiv.innerHTML=quantity+' in stock';}else{quantityDiv.innerHTML='In Stock';}}
function widenAsNeeded(div,targetHeight,maxWidth){var step=1;if(!div){return;}
if(!div.scrollHeight){return;}
var currWidth=parseInt(div.style.width);while(div.scrollHeight>targetHeight&&currWidth<=(maxWidth-step)){div.style.width=(currWidth+step)+"px";currWidth=parseInt(div.style.width);}};var hoverDelay=200;var cancelDelay=200;var loadingTimer=500;var isHoverActive=true;var onfocusFunction=window.onfocus;window.onfocus=new Function("if(onfocusFunction != null) {eval('onfocusFunction');}isHoverActive = true;");window.onblur=new Function("isHoverActive = false;");var hoverDebug=false;var divWithMouse=null;var currentHoverOnTask=null;var currentHoverOffTask=null;var divWithActiveHover=null;var lastDivIdIn=null;var xOffsets=new Array();var yOffsets=new Array();var defaultMainDiv="header-myaccount";function findPos(obj){var curleft=curtop=0;if(obj.offsetParent){do{curleft+=obj.offsetLeft;curtop+=obj.offsetTop;}while(obj=obj.offsetParent);}
return[curleft,curtop];}
function proposeDivForHover(mainDivId,xOff,yOff){var mainDiv=document.getElementById(mainDivId);if(!mainDiv){talert('mainDiv is null: '+mainDivId);}
if(divWithActiveHover&&mainDiv.id==divWithActiveHover.id){talert('not hovering (already on)');return;}
if(currentHoverOnTask!=null){clearTimeout(currentHoverOnTask);currentHoverOnTask=null;}
divWithMouse=mainDiv;currentHoverOnTask=setTimeout(function(){turnOnDivHover(mainDivId,xOff,yOff);},hoverDelay);}
function proposeCancelHover(mainDivId){var mainDiv=document.getElementById(mainDivId);if(!mainDiv){talert('mainDiv is null: '+mainDivId);}
if(mainDiv!=divWithActiveHover&&mainDiv!=divWithMouse){return;}
divWithMouse=mainDiv;currentHoverOffTask=setTimeout(function(){ifOutCancelHover(mainDivId);},cancelDelay);}
function ifOutCancelHover(mainDivId){turnOffDivHover(mainDivId);}
function turnOnDivHover(mainDivId,xOff,yOff){talert("beg hover on for "+mainDivId);var mainDiv=document.getElementById(mainDivId);if(!mainDiv){talert('mainDiv is null: '+mainDivId);return;}
if(divWithActiveHover){turnOffDivHover(divWithActiveHover.id);}else{talert('no active hover');}
divWithActiveHover=mainDiv;var hoverDiv=document.getElementById(mainDivId+'-hover');if(!hoverDiv){talert('no hoverDiv for divId '+mainDivId);return;}
var mainDivPos=findPos(mainDiv);hoverDiv.style.left=(mainDivPos[0]+xOff)+'px';hoverDiv.style.top=(mainDivPos[1]+yOff)+'px';hoverDiv.style.visibility='visible';var list1=document.getElementById("selectedFavListing-dashboard-widget");if(list1!=null&&mainDivId==defaultMainDiv){list1.style.visibility='visible';}
var list2=document.getElementById("selectedListing-dashboard-widget");if(list2!=null&&mainDivId==defaultMainDiv){list2.style.visibility='visible';}
var hoverHook=document.getElementById(mainDivId+'-hoverhook');if(hoverHook){hoverHook.focus();hoverHook.style.display='none';}
talert("end hover on for "+mainDivId);}
function turnOffDivHover(mainDivId){if(currentHoverOffTask!=null){clearTimeout(currentHoverOffTask);currentHoverOffTask=null;}
talert("hover off for "+mainDivId);var hoverDiv=document.getElementById(mainDivId+'-hover');if(!hoverDiv){talert('no hoverDiv for divId '+mainDivId);return;}
divWithActiveHover=null;hoverDiv.style.visibility='hidden';var list1=document.getElementById("selectedFavListing-dashboard-widget");if(list1!=null&&mainDivId==defaultMainDiv){list1.style.visibility='hidden';}
var list2=document.getElementById("selectedListing-dashboard-widget");if(list2!=null&&mainDivId==defaultMainDiv){list2.style.visibility='hidden';}}
function onMouseInHandler(mainDivId,xOff,yOff){if(!isHoverActive){}
if(xOff==null){xOff=18;}
if(yOff==null){yOff=18;}
lastDivIdIn=mainDivId;if(divWithActiveHover&&mainDivId==divWithActiveHover.id&&currentHoverOffTask!=null){clearTimeout(currentHoverOffTask);currentHoverOffTask=null;}
proposeDivForHover(mainDivId,xOff,yOff);}
function onMouseOutHandler(mainDivId){if(currentHoverOnTask!=null){clearTimeout(currentHoverOnTask);currentHoverOnTask=null;}
if(divWithActiveHover&&mainDivId==divWithActiveHover.id){proposeCancelHover(mainDivId);}else{talert('ignoring mouse out for '+mainDivId);}}
function talert(message){}
function setuphoverDebug(){if(hoverDebug){talertDiv=document.getElementById('talert');talertDiv.style.display="block";talertDiv.style.backgroundColor="white";talertDiv.style.border=2;talertDiv.style.position="absolute";talertDiv.style.top="1030px";talertDiv.style.left="400px";talert=new Function("message","var talertDiv =document.getElementById('talert'); talertDiv.innerHTML = message + '<br/>' + talertDiv.innerHTML;");thoverDebugDiv=document.getElementById('thoverDebug');thoverDebugDiv.style.display="block";thoverDebugDiv.style.backgroundColor="white";thoverDebugDiv.style.border=2;thoverDebugDiv.style.position="absolute";thoverDebugDiv.style.top="730px";thoverDebugDiv.style.left="400px";starthoverDebugOutput();}}
function starthoverDebugOutput(){thoverDebugDiv=document.getElementById('thoverDebug');var thoverDebugHtml='';thoverDebugHtml+='hoverDelay = '+hoverDelay+'<br/>';thoverDebugHtml+='cancelDelay = '+cancelDelay+'<br/>';thoverDebugHtml+='loadingTimer = '+loadingTimer+'<br/>';thoverDebugHtml+='divWithMouse = '+divWithMouse+'<br/>';thoverDebugHtml+='currentHoverOnTask = '+currentHoverOnTask+'<br/>';thoverDebugHtml+='currentHoverOffTask = '+currentHoverOffTask+'<br/>';thoverDebugHtml+='divWithActiveHover = '+divWithActiveHover+'<br/>';thoverDebugHtml+='lastDivIdIn = '+lastDivIdIn+'<br/>';thoverDebugHtml+='isHoverActive = '+isHoverActive+'<br/>';thoverDebugDiv.innerHTML=thoverDebugHtml;setTimeout('starthoverDebugOutput()',500);};BackColor="palegreen";ForeColor="navy";CountActive=true;CountStepper=-1;LeadingZero=true;DisplayFormat="%%D%%  %%H%% %%M%% %%S%%";FinishMessage="It is finally here!";SetTimeOutPeriod=1000;function calcage(secs,num1,num2,suffix){i=((Math.floor(secs/num1))%num2);s=((Math.floor(secs/num1))%num2).toString();if(i==0){return' ';}
if(LeadingZero&&i<10){if(i==1){s="0"+s+' '+suffix;}else{s="0"+s+' '+suffix+'s';}}else{s=s+' '+suffix+'s';}
return s;}
function CountBack(secs){var obj=document.getElementById("countdown");if(secs<0){hideSpecialOffers();obj.innerHTML=FinishMessage;return;}
if(secs>86400){DisplayStr=DisplayFormat.replace(/%%D%%/g,calcage(secs,86400,100000,'Day'));DisplayStr=DisplayStr.replace(/%%H%%/g,calcage(secs,3600,24,'hr'));DisplayStr=DisplayStr.replace(/%%M%%/g,calcage(secs,60,60,'min'));DisplayStr=DisplayStr.replace(/%%S%%/g,calcage(secs,1,60,'sec'));}else{DisplayStr=DisplayFormat.replace(/%%D%%/g,calcage(secs,86400,100000,'Day'));DisplayStr=DisplayStr.replace(/%%H%%/g,calcage(secs,3600,24,'hour'));DisplayStr=DisplayStr.replace(/%%M%%/g,calcage(secs,60,60,'minute'));DisplayStr=DisplayStr.replace(/%%S%%/g,calcage(secs,1,60,'second'));}
DisplayStr=beautify(DisplayStr);obj.innerHTML=DisplayStr;if(CountActive){setTimeout("CountBack("+(secs+CountStepper)+")",SetTimeOutPeriod);}}
function beautify(str){str="<strong>Time Remaining: "+str+"</strong>";return str;}
function showCountdown(TargetDate,nowDate){if(typeof(BackColor)=="undefined")
BackColor="white";if(typeof(ForeColor)=="undefined")
ForeColor="black";if(typeof(DisplayFormat)=="undefined")
DisplayFormat="%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%% Seconds.";if(typeof(CountActive)=="undefined")
CountActive=true;if(typeof(FinishMessage)=="undefined")
FinishMessage="";if(typeof(CountStepper)!="number")
CountStepper=-1;if(typeof(LeadingZero)=="undefined")
LeadingZero=true;CountStepper=Math.ceil(CountStepper);if(CountStepper==0)
CountActive=false;SetTimeOutPeriod=(Math.abs(CountStepper)-1)*1000+990;var dthen=new Date(TargetDate);var dnow=new Date(nowDate);if(CountStepper>0)
ddiff=new Date(dnow-dthen);else
ddiff=new Date(dthen-dnow);gsecs=Math.floor(ddiff.valueOf()/1000);if(gsecs>0){CountBack(gsecs);}else{hideSpecialOffers();}}
function hideSpecialOffers(){$('specialoffer-box').style.display='none';}
function getSpecialOffers(page,template,listing,id){var url="/specialoffers.html?&template="+template;if(page!=""){url=url+"&page="+page;}
if(listing!=""){url=url+"&listing="+listing;}
new Ajax.Updater('',url,{method:'post',onComplete:function(res){if(res.status!=200||(res.responseXML==null)){return;}
var contents=getNodeValue(res.responseXML,'content');if(contents==''){return;}
showObject(id);document.getElementById(id).innerHTML=contents;var targetDate=getNodeValue(res.responseXML,'endDate');var nowDate=getNodeValue(res.responseXML,'nowDate');showCountdown(targetDate,nowDate);}});}