var xmlDOM;var xmlHTTP;var clearImageTimer=null;var alternateColors=new Array();var currentColor=null;function isIE(){return window.ActiveXObject;}
function isMozilla(){return window.XMLHttpRequest;}
function getBrowserType(){if(navigator.appName=="Netscape"){if(navigator.userAgent.split("/")[2].split(" ")[1]=="Firefox")return"Firefox";if(navigator.appVersion.split("/")[1].split(" ")[4]=="Chrome")return"Chrome";if(navigator.appVersion.split("/")[2].split(" ")[1]=="Safari")return"Safari";}
if(navigator.appName=="Microsoft Internet Explorer")return"IE";return navigator.appName;}
function getBrowserVersion(){if(getBrowserType()=="IE")
return parseFloat(navigator.appVersion.split(";")[1].split(" ")[2]);if(getBrowserType()=="Firefox")
return navigator.userAgent.split("/")[3];if(getBrowserType()=="Opera")
return parseFloat(navigator.userAgent.split("/")[1].split(" ")[0]);if(getBrowserType()=="Chrome")
return parseFloat(navigator.appVersion.split("/")[2].split(" ")[0]);if(getBrowserType()=="Safari")
return parseFloat(navigator.appVersion.split("/")[2].split(" ")[0]);return null;}
var Product=Class.create({initialize:function(product){this.xml=product;this.active=xmlInfo(product,"active",0);this.productId=xmlInfo(product,"productId",0);this.colorDescription=xmlInfo(product,"colorDescription",0);this.description=xmlInfo(product,"description",0);this.colorId=xmlInfo(product,"colorId",0);this.thumbnail=xmlInfo(product,"image",0);this.name=xmlInfo(product,"name",0);this.wasPrice=xmlInfo(product,"original",0)=="no-sale"?"":xmlInfo(product,"original",0);this.styleDescription=xmlInfo(product,"style",0)+" "+xmlInfo(product,"colorId",0);this.styleId=xmlInfo(product,"style",0);this.nowPrice=xmlInfo(product,"sale",0);this.salesText=xmlInfo(product,"original",0)!="no-sale"?"SALE!":"";this.onSale=xmlInfo(product,"original",0)=="no-sale"?false:true;this.otherDetails=new Array();for(var i=0;i<xmlObject(product,"details").length;i++){this.otherDetails[i]=xmlInfo(product,"details",i);}
this.colors=new Array();for(var i=0;i<xmlObject(xmlObject(product,"colors")[0],"color").length;i++){this.colors[i]=xmlObject(xmlObject(product,"colors")[0],"color")[i];}
this.skus=new Array();this.skuAvailable=new Array();for(var i=0;i<xmlObject(xmlObject(product,"sizes")[0],"size").length;i++){this.skus[i]=xmlObject(xmlObject(product,"sizes")[0],"size")[i];this.skuAvailable[i]=xmlAttribute(xmlObject(xmlObject(product,"sizes")[0],"size")[i],"available");}},getColorArray:function(iterator){var colorArray=new Array();colorArray[0]=this.getColorName(iterator);colorArray[2]=this.getColorSelected(iterator);colorArray[1]=this.getColorProductId(iterator);colorArray[3]=this.getColorThumbnail(iterator);return colorArray;},getColorName:function(iterator){return this.colors[iterator].firstChild.nodeValue.replace("=AMPERSAND=","&");},getColorProductId:function(iterator){return xmlAttribute(this.colors[iterator],"productId");},getColorSelected:function(iterator){return xmlAttribute(this.colors[iterator],"selected");},getColorThumbnail:function(iterator){return xmlAttribute(this.colors[iterator],"thumbnail");},getSizeArray:function(iterator){var sizeArray=new Array();sizeArray[0]=this.getSizeText(iterator);sizeArray[1]=this.getSizeSku(iterator);return sizeArray;},getSizeText:function(iterator){return this.skus[iterator].firstChild.nodeValue.replace("=AMPERSAND=","&");},getSizeSku:function(iterator){return xmlAttribute(this.skus[iterator],"sku");}});var AlternateProduct=Class.create({initialize:function(productId,iterator){this.productId=productId;this.iterator=iterator;var url="/store/results/fragments/productLookupXML.jsp?productId="+this.productId;new Ajax.Request(url,{method:'get',onSuccess:function(response){var product=xmlObject(response.responseXML,'product')[0];alternateColors[iterator]=new Product(product);},onFailure:function(){}});}});var CurrentProduct=Class.create({initialize:function(productId){this.productId=productId;var url="/store/results/fragments/productLookupXML.jsp?productId="+this.productId;new Ajax.Request(url,{method:'get',onSuccess:function(response){var product=xmlObject(response.responseXML,'product')[0];currentColor=new Product(product);},onFailure:function(){}});}});var AlsoRecommendedProduct=Class.create({initialize:function(pProductLink,pContainerId){this.productId=pProductLink.split('=')[1];var url='/store/results/fragments/productLookupXML.jsp?productId='+this.productId;new Ajax.Request(url,{method:'get',onSuccess:function(response){var productObj=new Product(xmlObject(response.responseXML,'product')[0]);var container=new Element('div',{'class':'product','id':'suggest_'+productObj.productId});var thumbnail=new Element('div',{'class':'thumbnail'});var link=new Element('a',{'href':'/store/catalog/product.jsp?productId='+productObj.productId});link.appendChild(new Element('img',{'src':'/store/'+convertLargeImageToSmall(productObj.thumbnail),'alt':productObj.name}));var details=new Element('div',{'class':'details'});var name=new Element('div',{'class':'name'});name.appendChild(new Element('a',{'href':pProductLink}).update(productObj.name));thumbnail.appendChild(link);details.appendChild(name);if(productObj.onSale){details.appendChild(new Element('div',{'class':'nowPrice'}).update('Now: '+productObj.nowPrice));details.appendChild(new Element('div',{'class':'wasPrice'}).update('Was: '+productObj.wasPrice));}else{details.appendChild(new Element('div',{'class':'origPrice'}).update(productObj.nowPrice));}
container.appendChild(thumbnail);container.appendChild(details);$(pContainerId).appendChild(container);Event.observe('suggest_'+productObj.productId,'mouseover',function(){mws_hoverOn(this)});Event.observe('suggest_'+productObj.productId,'mouseout',function(){mws_hoverOff(this)});},onFailure:function(){}});}});function dcImageLoader(pImageURL){var image=new Image;image.src=pImageURL;}
function redirectPage(url){window.location=url;}
function changeMouseOverClass(objName,className){addAttribute(objName,"class",className);addAttribute(objName,"className",className);}
function getElementsByClassName(classname,nodeName){node=!nodeName?document.getElementsByTagName("body")[0]:$(nodeName);if(!node)node=document.getElementsByTagName("body")[0];var a=[];var re=new RegExp('\\b'+classname+'\\b');var els=node.getElementsByTagName("*");for(var i=0,j=els.length;i<j;i++)
if(re.test(els[i].className))a.push(els[i]);return a;}
function setValue(id,value){$(id).innerHTML=value=="null"?"":value;}
function prepAJAX(){if(window.ActiveXObject){xmlDOM=new ActiveXObject("Microsoft.XMLDOM");xmlHTTP=new ActiveXObject("Microsoft.XMLHTTP");}else{xmlHTTP=new XMLHttpRequest();}}
function prepPostForAJAX(pLength){xmlHTTP.setRequestHeader("Content-type","application/x-www-form-urlencoded");xmlHTTP.setRequestHeader("Content-length",pLength);xmlHTTP.setRequestHeader("Connection","close");}
function xmlInfo(obj,tag,number){if(obj.getElementsByTagName(tag)[number].firstChild!=null)
return obj.getElementsByTagName(tag)[number].firstChild.nodeValue.replace("=AMPERSAND=","&");else
return"";}
function xmlObject(obj,tag){return obj.getElementsByTagName(tag);}
function xmlAttribute(obj,attribute){return obj.getAttribute(attribute);}
function createOption(optionValue,optionText){var option=document.createElement("OPTION");option.value=optionValue;option.text=optionText;return option;}
function addElement(parent,type,id){var parentObj=$(parent);var newObj=document.createElement(type);if(id!="")
newObj.setAttribute("id",id);parentObj.appendChild(newObj);}
function removeElement(parent,id){$(parent).removeChild(id);}
function addElementWithClass(parent,type,id,className){var parentObj=$(parent)
var newObj=document.createElement(type);newObj.setAttribute("id",id);newObj.setAttribute("class",className);newObj.setAttribute("className",className);parentObj.appendChild(newObj);}
function removeElement(parent,child){var parentObj=$(parent);var childObj=$(child);parentObj.removeChild(childObj);}
function displayElement(id){$(id).style.display="block";}
function hideElement(id){$(id).style.display="none";}
function addAttribute(objName,attribute,value){var obj=$(objName);obj.setAttribute(attribute,value);}
function appendAttribute(objName,attribute,value){var newValue=getAttribute(objName,attribute)+";"+value;addAttribute(objName,attribute,newValue);}
function getAttribute(objName,attribute){return $(objName).getAttribute(attribute);}
function removeAttribute(objName,attribute){var obj=$(objName);obj.removeAttribute(attribute);}
function addText(objName,text){var textNode=document.createTextNode(text)
$(objName).appendChild(textNode);}
function changeText(objName,text){var obj=$(objName);obj.innerHTML=text;}
function addErrorMessage(objName,text){addElement(objName,"span","error_"+objName);addAttribute("error_"+objName,"class","errorMessage");addAttribute("error_"+objName,"className","errorMessage");addText("error_"+objName,text);}
function getViewportHeight(){if(window.innerHeight!=window.undefined)return window.innerHeight;if(document.compatMode=='CSS1Compat')return document.documentElement.clientHeight;if(document.body)return document.body.clientHeight;return window.undefined;}
function getViewportWidth(){if(window.innerWidth!=window.undefined)return window.innerWidth;if(document.compatMode=='CSS1Compat')return document.documentElement.clientWidth;if(document.body)return document.body.clientWidth;return window.undefined;}
function loadImage(imageName,height,width){var loadingPic=height!=null&&width!=null?new Image(height,width):new Image();loadingPic.src=imageName;}
function loadColorImage(imageName){imageName=convertSmallImageToLarge(imageName);loadImage(imageName,255,255);}
function convertSmallImageToLarge(imageName){return imageName.replace("/sm","/lg").replace(".gif",".jpg");}
function convertToExtraLarge(imageName){return imageName.replace("/sm","/xl").replace("/lg","/xl").replace(".gif",".jpg");}
function convertLargeImageToSmall(imageName){return imageName.replace("/lg","/sm").replace(".jpg",".gif");}
function clearMouseOverImage(){clearImageTimer=setTimeout("$('imageOver').style.display='none'",125);}
function showMouseOverImage(colorImage){clearTimeout(clearImageTimer);colorImage=convertSmallImageToLarge(colorImage);setValue("imageOver","");addElement("imageOver","img","imageOverImg");addAttribute("imageOverImg","src",colorImage);$("imageOver").style.display="block";}
function unencode(pUrl){var sUrl=new Array();var sParams=new Array();if(pUrl.toUpperCase().indexOf("%2FSTORE%2FCATALOG")>-1){pUrl=pUrl.replace(/%2F/g,"/");pUrl=pUrl.replace(/%3F/g,"?");pUrl=pUrl.replace(/%3D/g,"=");pUrl=pUrl.replace(/%26/g,"&");pUrl=pUrl.replace(/%25/g,"%");sUrl=pUrl.split("?");if(sUrl.length>=2){var pParams=sUrl[1];var pId="";sParams=pParams.split("&");for(var i=0;i<sParams.length;i++){if(sParams[i].indexOf("productId=")>-1){pId=sParams[i];}}
if(pId!=""){pUrl=urlCText+"/store/catalog/product.jsp?"+pId;}
else{pUrl=urlCText+"/store/index.jsp";}}
else{pUrl=urlCText+"/store/index.jsp";}}
else if(pUrl.toUpperCase().indexOf("%2FSTORE%2FIMAGES")>-1){pUrl=pUrl.replace(/%2F/g,"/");pUrl=pUrl.replace(/%3F/g,"?");pUrl=pUrl.replace(/%3D/g,"=");pUrl=pUrl.replace(/%26/g,"&");pUrl=pUrl.replace(/%25/g,"%");pUrl=urlCText+pUrl}
else{pUrl=urlCText+pUrl}
return pUrl;}
function displayYellowMessage(questionObj,message,pos){addElement("body","div","yellowMessage");$("yellowMessage").innerHTML=yellowMsgArray[message];var curleft=curtop=0;var obj=questionObj;if(obj.offsetParent){do{curleft+=obj.offsetLeft;curtop+=obj.offsetTop;}while(obj=obj.offsetParent);}
curleft=pos=="left"?curleft-110:curleft+20;curtop-=20;$("yellowMessage").style.left=(curleft)+"px";$("yellowMessage").style.top=curtop+"px";}
function hideYellowMessage(){removeElement("body","yellowMessage");}
var yellowMsgArray=new Array("We require an e-mail address for all online orders.<br/><br/>If you do not have an e-mail address, please call 1-888-777-3949 to place your order.","New customer registration","We are required to charge tax in states for which we have a physical store location.","Your CVV number is located...","We require a phone number in case there are problems with your order or shipping.","Phone numbers are necessary if we have any questions regarding delivery.");yellowMsgArray["UPS Ground - $7.99"]="Once item is shipped, in-transit time typically takes 3-5 business days.";yellowMsgArray["Rush - $11.99"]="Once item is shipped, in-transit time typically takes two business days.";yellowMsgArray["Express - $19.99"]="Once item is shipped, in-transit time typically takes one business day.";function addToWishList(pProductId,pSkuId){var url="/store/catalog/fragments/addToGiftList.jsp?productId="+pProductId+"&skuId="+pSkuId;new Ajax.Request(url,{method:'get',onSuccess:function(response){if(xmlInfo(response.responseXML,"result",0)=="success"){window.location=xmlInfo(response.responseXML,"redirectURL",0);}}});}
function getRadioValue(formName,radioName){return Form.getInputs(formName,'radio',radioName).find(function(radio){return radio.checked;}).value;}
function adjustDefaultText(formObj,defaultText,newText){if(formObj.value==defaultText)formObj.value=newText;}
function createTest(objName){addElement(objName,"div","testInfo");}
function addTestInfo(value){try{$("testInfo").innerHTML+=value+"<br/>";}catch(e){}}
