var cache=new Object();function getObject(objectName){var shortName=objectName;while(shortName.indexOf(" ")!=-1){shortName=shortName.replace(" ","")}var tmp=eval("cache."+shortName);if(!(tmp)){tmp=getDocObject(document,objectName);eval("cache."+shortName+" = tmp")}return(tmp)}function getDocObject(doc,objectName){var tmpObj;if(doc.getElementById){tmpObj=doc.getElementById(objectName);if(tmpObj==null){if(document.getClientName){tmpObj=doc.getElementById(getClientName(objectName))}}if(tmpObj==null){tmpObj=doc.getElementsByName(objectName)[0]}}else{if(doc.all){tmpObj=doc.all[objectName]}}return(tmpObj)}function numOnly(ev){if(ev==null){ev=window.event}var thisKey=ev.keyCode?ev.keyCode:ev.which;if(thisKey==0){thisKey=ev.keyCode}var valid=false;if(thisKey==8||thisKey==9||thisKey==46||(thisKey>47&&thisKey<58)||(thisKey>36&&thisKey<41)){valid=true}if(!valid){ev.returnValue=false}return(valid)}function numEnterOnly(ev){}function rawPrice(priceString){var price=0;if(priceString!="TBC"){price=priceString.replace("$","").replace(",","")*1}return(price)}function price(value){return("$"+CommaFormatted(CurrencyFormatted(value)))}function CurrencyFormatted(amount){var i=parseFloat(amount);if(isNaN(i)){i=0}var minus="";if(i<0){minus="-"}i=Math.abs(i);i=parseInt((i+0.005)*100);i=i/100;s=new String(i);if(s.indexOf(".")<0){s+=".00"}if(s.indexOf(".")==(s.length-2)){s+="0"}s=minus+s;return s}function CommaFormatted(amount){var delimiter=",";var a=amount.split(".",2);var d=a[1];var i=parseInt(a[0]);if(isNaN(i)){return""}var minus="";if(i<0){minus="-"}i=Math.abs(i);var n=new String(i);var a=[];while(n.length>3){var nn=n.substr(n.length-3);a.unshift(nn);n=n.substr(0,n.length-3)}if(n.length>0){a.unshift(n)}n=a.join(delimiter);if(d.length<1){amount=n}else{amount=n+"."+d}amount=minus+amount;return amount}function TwoDecimals(strToRound){strToRound=strToRound.toString();iDecimalMarker=strToRound.indexOf(".");if(iDecimalMarker<1){strFinal=strToRound+".00"}else{strPart1=strToRound.substring(0,iDecimalMarker);strPart2=strToRound.substring(iDecimalMarker+1,strToRound.length);strPart3=strPart2.substring(0,2)+"."+strPart2.substring(2,strPart2.length+1);if(strPart3.substring(0,1)!=0){strPart3=Math.round(strPart3)}else{if(strPart3.substring(0,1)=="0"){strPart3=strPart3.substring(0,strPart3.length+1);strPart3=Math.round(strPart3);strPart3.toString();strPart3="0"+strPart3}}strPart3=strPart3.toString();if(strPart3.length<2&&strPart3.length>0){strPart3=strPart3+"0"}var tmpStr=strPart1.reverse();var x=0;while(x<tmpStr.length){}strPart1+=tmpStr.s;strFinal=strPart1+"."+strPart3}return strFinal}var __callbackObject=new Object();function WebForm_DoCallback(eventTarget,eventArgument,eventCallback,context,errorCallback){re=new RegExp("\\x2B","g");if(__nonMSDOMBrowser){var xmlRequest=new XMLHttpRequest();postData=__theFormPostData+"__CALLBACKID="+eventTarget+"&__CALLBACKPARAM="+escape(eventArgument).replace(re,"%2B");if(pageUrl.indexOf("?")!=-1){xmlRequest.open("GET",pageUrl+"&"+postData,false)}else{xmlRequest.open("GET",pageUrl+"?"+postData,false)}xmlRequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded");xmlRequest.send(null);response=xmlRequest.responseText;if(response.charAt(0)=="s"){if(eventCallback!=null){eventCallback(response.substring(1),context)}}else{if(errorCallback!=null){errorCallback(response.substring(1),context)}}}else{var xmlRequest=new ActiveXObject("Microsoft.XMLHTTP");xmlRequest.onreadystatechange=WebForm_CallbackComplete;__callbackObject.xmlRequest=xmlRequest;__callbackObject.eventCallback=eventCallback;__callbackObject.context=context;__callbackObject.errorCallback=errorCallback;postData=__theFormPostData+"__CALLBACKID="+eventTarget+"&__CALLBACKPARAM="+escape(eventArgument).replace(re,"%2B");usePost=false;if(pageUrl.length+postData.length+1>2067){usePost=true}if(usePost){xmlRequest.open("POST",pageUrl,true);xmlRequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded");xmlRequest.send(postData)}else{if(pageUrl.indexOf("?")!=-1){xmlRequest.open("GET",pageUrl+"&"+postData,true)}else{xmlRequest.open("GET",pageUrl+"?"+postData,true)}xmlRequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded");xmlRequest.send()}}}function WebForm_CallbackComplete(){if(__callbackObject.xmlRequest.readyState==4){response=__callbackObject.xmlRequest.responseText;if(response.charAt(0)=="s"){if(__callbackObject.eventCallback!=null){__callbackObject.eventCallback(response.substring(1),__callbackObject.context)}}else{if(__callbackObject.errorCallback!=null){__callbackObject.errorCallback(response.substring(1),__callbackObject.context)}}}}var __nonMSDOMBrowser=(window.navigator.appName.toLowerCase().indexOf("explorer")==-1);var __theFormPostData="";function WebForm_InitCallback(theForm){count=theForm.elements.length;var element;re=new RegExp("\\x2B","g");for(i=0;i<count;i++){element=theForm.elements[i];if(element.tagName.toLowerCase()=="input"){__theFormPostData+=element.name+"="+element.value.replace(re,"%2B")+"&"}else{if(element.tagName.toLowerCase()=="select"){selectCount=element.children.length;for(j=0;j<selectCount;j++){selectChild=element.children[j];if((selectChild.tagName.toLowerCase()=="option")&&(selectChild.selected==true)){__theFormPostData+=element.name+"="+selectChild.value.replace(re,"%2B")+"&"}}}}}}function reTotal(rowIndex,productCode,shipping,isOnSpecial){var freeShippingThreshold=99999999;var qtyBox=getObject("qty"+rowIndex);var costBox=getObject("cost"+rowIndex);var totalSpan=getObject("total"+rowIndex);if(totalSpan){var newTotal;if(qtyBox.value>5&&isOnSpecial){alert("You cannot order more than 5 units of this item");qtyBox.value=5}if(costBox.value!="0"){newTotal=costBox.value*qtyBox.value;totalSpan.innerHTML=price(newTotal)}if(sTotal){var total=0;var x=0;var iTotal=getObject("total"+x);var shippingCost=0;var shipping=$("shippingcost").value*1;var totalForOrder=0;var tempTotal=0;var preOrder;var shippingForOrder=0;while(iTotal){tempTotal=rawPrice(iTotal.innerHTML);total+=tempTotal;var qty=getObject("qty"+x);preOrder=getObject("preorder"+x);x++;iTotal=getObject("total"+x);if(preOrder.value=="True"&&parseInt(qty.value)>0){shipping+=shippingCost}else{totalForOrder+=tempTotal}if(totalForOrder<=freeShippingThreshold&&totalForOrder>0){shippingForOrder=shipping}else{if(totalForOrder>freeShippingThreshold){shippingForOrder=0;shipping=0}}}sTotal.innerHTML=price(total);gTotal.innerHTML=price(shippingForOrder+total)}}new Ajax.Request("/viewcart",{method:"get",parameters:{callback:"true",param:"ChangeQuantity|"+productCode+"|"+qtyBox.value}});return(true)}function OnError(message,context){alert("An unhandled exception has occurred:\n"+message)}function changeFreight(){if(rawPrice(sTotal.innerHTML)<=400){freight.innerHTML=shippingCost}else{freight.innerHTML="$0.00"}gTotal.innerHTML=price(rawPrice(freight.innerHTML)+rawPrice(sTotal.innerHTML))};
