function checkoutCreateModal(type){if(savedInnerHTML)$('ModalMessage').innerHTML=savedInnerHTML;if(window.XMLHttpRequest&&type!='recover_password'){checkoutChangeOpac(0,'modalBackground');checkoutChangeOpac(0,'modalWindow');}$('modalWindow').style.display='block';$('modalBackground').style.display='block';if(type=='login'){$('ModalMessage').style.display='block';}if(type=='cart'){$('checkoutCartView').style.display='block';$('checkoutCartViewTop').style.display='inline';$('checkoutCartViewBottom').style.display='inline';}if(type=='recover_password'){$('checkoutForgotPassword').style.display='';}if(type=='terms'){$('checkoutTermsView').style.display='block';$('checkoutTermsViewTop').style.display='inline';$('checkoutTermsViewBottom').style.display='inline';}if(window.XMLHttpRequest==null)checkoutReplaceSelectsWithSpans();onWindowResize();if(window.attachEvent)window.attachEvent('onresize',onWindowResize);else if(window.addEventListener)window.addEventListener('resize',onWindowResize,false);else window.onresize=onWindowResize;if(document.all)document.documentElement.onscroll=onWindowResize;if(window.XMLHttpRequest&&type!='recover_password'){checkoutOpacity('modalBackground',0,70,700);checkoutOpacity('modalWindow',0,100,800);}}function checkoutEraseModal(type){try{if(type=='login')document.checkout_one_form.usertype.focus();else document.checkout_one_form.Customer_Notes.focus();}catch(e){}if(window.XMLHttpRequest){checkoutOpacity('modalBackground',70,0,700);if(checkoutOpacity('modalWindow',100,0,800))setTimeout("$('modalWindow').style.display=$('modalBackground').style.display='none'",800);}else{$('modalWindow').style.display=$('modalBackground').style.display='none';}for(var i=0;i<modalOptions.length;i++){$(modalOptions[i]).style.display='none';}if(window.XMLHttpRequest==null)checkoutRemoveSelectSpans();}function onWindowResize(){var left=window.XMLHttpRequest==null?document.documentElement.scrollLeft:0;var top=window.XMLHttpRequest==null?document.documentElement.scrollTop:0;var div=$('modalWindow');div.style.left=Math.max((left+(getWindowWidth()-div.offsetWidth)/2),0)+'px';div.style.top=Math.max((top+(getWindowHeight()-div.offsetHeight)/2),0)+'px';}function checkoutRemoveSelectSpans(){var selects=document.getElementsByTagName('select');for(var i=0;i<selects.length;i++){var select=selects[i];if(select.clientWidth==0||select.clientHeight==0||select.nextSibling==null||select.nextSibling.className!='selectReplacement')continue;select.parentNode.removeChild(select.nextSibling);select.style.display=select.cachedDisplay;}}function checkoutReplaceSelectsWithSpans(){var selects=document.getElementsByTagName('select');for(var i=0;i<selects.length;i++){var sel=selects[i];if(sel.clientWidth==0||sel.clientHeight==0||sel.nextSibling==null||sel.nextSibling.className=='selectReplacement')continue;var span=document.createElement('span');span.style.height=(sel.clientHeight-4)+'px';span.style.width=(sel.clientWidth-6)+'px';span.style.display='inline-block';span.style.border='1px solid rgb(200, 210, 230)';span.style.padding='1px 0 0 4px';span.style.fontFamily='Arial';span.style.position='relative';span.style.top='1px';span.className='selectReplacement';span.innerHTML=sel.options[sel.selectedIndex].innerHTML+'<img src="'+checkoutImagesDir+'/checkout_one_select_arrow.gif" alt="drop down" style="position: absolute; right: 1px; top: 1px;" />';sel.cachedDisplay=sel.style.display;sel.style.display='none';sel.parentNode.insertBefore(span,sel.nextSibling);}}function checkoutOpacity(id,opacStart,opacEnd,millisec){var speed=Math.round(millisec/100);var timer=0;if(opacStart>opacEnd){for(i=opacStart;i>=opacEnd;i--){setTimeout("checkoutChangeOpac("+i+",'"+id+"')",(timer*speed));timer++;}}else if(opacStart<opacEnd){for(i=opacStart;i<=opacEnd;i++){setTimeout("checkoutChangeOpac("+i+",'"+id+"')",(timer*speed));timer++;}}if(i==opacEnd);return true;}function checkoutChangeOpac(opacity,id){var object=$(id).style;object.opacity=(opacity/100);object.MozOpacity=(opacity/100);object.KhtmlOpacity=(opacity/100);object.filter="alpha(opacity="+opacity+")";}function getWindowWidth(){var width=document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth||document.body&&document.body.parentNode&&document.body.parentNode.clientWidth||0;return width;}function getWindowHeight(){if(window.innerHeight)return window.innerHeight;else return document.documentElement.clientHeight;}function $(id){return document.getElementById(id);}function inArray(needle,haystack){var i;for(i=0;i<haystack.length;i++)if(haystack[i].toLowerCase()==needle.toLowerCase())return true;return false;}function addEvent(obj,type,fn){if(!obj)return;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);}}function createHttpRequestObject(){var xmlHttp;if(xmlHttp)return xmlHttp;if(window.XMLHttpRequest==null){try{xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}catch(e){xmlHttp=false;}}else{try{xmlHttp=new XMLHttpRequest();}catch(e){xmlHttp=false;}}if(!xmlHttp){alert("Your current browser doesn't support the One Page Checkout. You will be redirected to a different checkout.");window.location='cart.php?mode=checkout&co_disable=Y';}else{return xmlHttp;}}function checkoutLogin(initial){if(initial=='true')checkoutCreateModal('login');if(($('modalBackground').style.opacity>=.7&&$('modalWindow').style.opacity>=1)||window.XMLHttpRequest==null){checkoutLoginAjax();}else{setTimeout("checkoutLogin('false')",500);}}function checkoutLoginAjax(){xmlHttp=createHttpRequestObject();if(xmlHttp.readyState==4||xmlHttp.readyState==0){var parameters='username='+encodeURI($('checkoutUser').value)+'&password='+encodeURI($('checkoutPass').value)+'&checkoutOne=Y'+'&mode=login'+'&usertype=C';xmlHttp.onreadystatechange=function(){if(xmlHttp.readyState==4){if(xmlHttp.status==200){var xmlResponse=xmlHttp.responseXML;if(!xmlResponse||!xmlResponse.documentElement){alert('Error communicating with the server');checkoutEraseModal('login');return;}try{var antibot=xmlResponse.getElementsByTagName('antibot')[0].childNodes[0].nodeValue;if(antibot)window.location='error_message.php?antibot_error';}catch(e){}try{var redirect=xmlResponse.getElementsByTagName('redirect')[0].childNodes[0].nodeValue;if(redirect){window.location=redirect;return;}}catch(e){}try{var invalid=xmlResponse.getElementsByTagName('invalid')[0].childNodes[0].nodeValue;if(invalid){savedInnerHTML=$('ModalMessage').innerHTML;$('ModalMessage').style.display='none';checkoutCreateModal('recover_password');return;}}catch(e){}var checkoutLoginBox=$('checkoutLoginBox').innerHTML='<span style="font-style:italic; font-weight:bold;">'+xmlResponse.getElementsByTagName('firstname')[0].childNodes[0].nodeValue+' '+xmlResponse.getElementsByTagName('lastname')[0].childNodes[0].nodeValue+'</span> '+isLoggedIn;$('checkoutLogOut').style.display='';$('registrationSection').style.display='none';var ship2diff=xmlResponse.getElementsByTagName('ship2diff')[0].childNodes[0].nodeValue;if(ship2diff=='Y')checkoutHideShippingRegFields(true);checkoutLogged=true;try{var shippingid=xmlResponse.getElementsByTagName('shippingid')[0].childNodes[0].nodeValue;if(shippingid)checkoutShippingid=shippingid;}catch(e){}try{var sessionid = xmlResponse.getElementsByTagName('sessionid')[0].childNodes[0].nodeValue;$('sid').value=sessionid;}catch(e){}for(x=0;x<defaultFields.length;x++){try{var tmpField=xmlResponse.getElementsByTagName(defaultFields[x])[0].childNodes[0].nodeValue;}catch(e){}if(tmpField&&$(defaultFields[x])){if(defaultFields[x]=='checkoutPoints'){$('checkoutPoints').innerHTML=tmpField;continue;}$(defaultFields[x]).value=tmpField;addEvent($(defaultFields[x]),'change',checkoutHideTotals);}tmpField=null;}for(x=0;x<paymentIDs.length;x++){try{var tmpPMID=xmlResponse.getElementsByTagName('pmid'+paymentIDs[x])[0].childNodes[0].nodeValue;if(!tmpPMID||$('select_'+paymentIDs[x]))continue;var tmpdescr=xmlResponse.getElementsByTagName('pmiddescr'+paymentIDs[x])[0].childNodes[0].nodeValue;var pselect=$('paymentMethodSelectid');var opt=document.createElement('option');opt.value=paymentIDs[x];opt.text=tmpdescr;opt.id='select_'+paymentIDs[x];try{pselect.add(opt,null);}catch(e){pselect.add(opt);}}catch(e){}tmpPMID=null;tmpdescr=null}if(dynamicStates){change_states($('b_country'),'b_state','b_county','State',$('b_state').value,'','','','','');change_states($('s_country'),'s_state','s_county','State',$('s_state').value,'','','','','');}if(needShipping)checkoutLoadShipping();else checkoutRebuildAllTotals(null);checkoutEraseModal('login');}else{alert("There was a problem accessing the server: "+xmlHttp.statusText);checkoutEraseModal('login');}}};xmlHttp.open('POST','include/login.php');xmlHttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');xmlHttp.setRequestHeader('Content-length',parameters.length);xmlHttp.setRequestHeader('Connection','close');xmlHttp.send(parameters);}else setTimeout('checkoutLoginAjax()',1000);}function checkoutLoadShipping(){if(!needShipping)return;checkoutShippingLoaded=false;xmlHttp=createHttpRequestObject();if($('ship2diff').value=='Y')var ship2diff=true;var stateRequired=true;var countyRequired=true;if(ship2diff){if(!$('s_state'))stateRequired=false;if(!$('s_county'))countyRequired=false;}else{if(!$('b_state'))stateRequired=false;if(!$('b_county'))countyRequired=false;}if($('s_city')||$('b_city'))var city=ship2diff?$('s_city').value:$('b_city').value;if(stateRequired&&($('s_state')||$('b_state')))var state=ship2diff?$('s_state').value:$('b_state').value;if($('s_country')||$('b_country'))var country=ship2diff?$('s_country').value:$('b_country').value;if(countyRequired&&($('s_county')||$('b_county')))var county=ship2diff?$('s_county').value:$('b_county').value;if($('s_zipcode')||$('b_zipcode'))var zipcode=ship2diff?$('s_zipcode').value:$('b_zipcode').value;var position=null;if(inArray('b_city',b_required)&&!city){var _alert='City Required \n';if(ship2diff){checkoutHighlightError('s_city','error');position=position?position:'s_city';}else{checkoutHighlightError('b_city','error');position=position?position:'b_city';}}if(inArray('b_country',b_required)&&!country){var _alert=_alert+co_country+' '+co_required+' \n';if(ship2diff){checkoutHighlightError('s_country','error');position=position?position:'s_country';}else{checkoutHighlightError('b_country','error');position=position?position:'b_country';}}if(countyRequired&&inArray('b_county',b_required)&&!county){var _alert=_alert+co_county+' '+co_required+' \n';if(ship2diff){checkoutHighlightError('s_county','error');position=position?position:'s_county';}else{checkoutHighlightError('b_county','error');position=position?position:'s_county';}}if(stateRequired&&inArray('b_state',b_required)&&!state){var _alert=_alert+co_state+' '+co_required+' \n';if(ship2diff){checkoutHighlightError('s_state','error');position=position?position:'s_state';}else{checkoutHighlightError('b_state','error');position=position?position:'b_state';}}if(inArray('b_zipcode',b_required)&&!zipcode){var _alert=_alert+co_zip+' '+co_required+' \n';if(ship2diff){checkoutHighlightError('s_zipcode','error');position=position?position:'s_zipcode';}else{checkoutHighlightError('b_zipcode','error');position=position?position:'b_zipcode';}}if(_alert){alert(_alert);if($(position))$(position).focus();return false;}if(inArray('b_city',b_required)){addEvent($('b_city'),'change',checkoutHideTotals);addEvent($('s_city'),'change',checkoutHideTotals);}if(inArray('b_state',b_required)){addEvent($('b_state'),'change',checkoutHideTotals);addEvent($('s_state'),'change',checkoutHideTotals);}if(inArray('b_country',b_required)){addEvent($('b_country'),'change',checkoutHideTotals);addEvent($('s_country'),'change',checkoutHideTotals);}if(inArray('b_county',b_required)){addEvent($('b_county'),'change',checkoutHideTotals);addEvent($('s_county'),'change',checkoutHideTotals);}if(inArray('b_zipcode',b_required)){addEvent($('b_zipcode'),'change',checkoutHideTotals);addEvent($('s_zipcode'),'change',checkoutHideTotals);}$('checkoutShippingWait').style.display='block';$('checkoutShippingMessage').style.display='none';$('checkoutShippingDisplay').style.display='none';if(xmlHttp.readyState==4||xmlHttp.readyState==0){var parameters='city='+encodeURI(city)+'&country='+encodeURI(country)+'&county='+encodeURI(county)+'&state='+encodeURI(state)+'&zipcode='+encodeURI(zipcode)+'&checkoutOne=Y';xmlHttp.onreadystatechange=function(){if(xmlHttp.readyState==4){if(xmlHttp.status==200){var xmlResponse=xmlHttp.responseXML;if(!xmlResponse||!xmlResponse.documentElement){checkoutShippingLoadError(xmlHttp.responseText);return;}$('checkoutShippingWait').style.display='none';checkoutResetCartTotals();try{var error=xmlResponse.getElementsByTagName('error')[0].childNodes[0].nodeValue;if(error){$('checkoutShippingMessage').style.display='';$('checkoutShippingError').style.display='';return;}}catch(e){}$('checkoutShippingDisplay').style.display='';$('checkoutShippingError').style.display='none';$('checkoutShippingMessage').style.display='none';checkoutShippingLoaded=true;for(x=0;x<coShippingJs.length;x++){try{var tmpField=xmlResponse.getElementsByTagName('id'+coShippingJs[x])[0].childNodes[0].nodeValue;}catch(e){}if(tmpField&&$('radio'+coShippingJs[x])){$('radio'+coShippingJs[x]).style.display='';$('rate'+coShippingJs[x]).innerHTML=tmpField;}else{if($('radio'+coShippingJs[x]))$('radio'+coShippingJs[x]).style.display='none';}tmpField=null;}for(var i=0;i<coShippingJs.length;i++){if($('radio'+coShippingJs[i]).style.display!='none'&&$('shippingid'+coShippingJs[i]).checked){checkoutRebuildCartTotals(null);return;}}for(var i=0;i<coShippingJs.length;i++){if($('radio'+coShippingJs[i]).style.display!='none'){$('radio'+coShippingJs[i]).checked=true;checkoutRebuildCartTotals(null);return;}}checkoutShippingLoadError('No Shipping Displayed');return;}else{alert("There was a problem accessing the server: "+xmlHttp.statusText);}}};xmlHttp.open('POST','cart.php?ajax_function=shipping');xmlHttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');xmlHttp.setRequestHeader('Content-length',parameters.length);xmlHttp.setRequestHeader('Connection','close');xmlHttp.send(parameters);}else setTimeout('checkoutLoadShipping()',1000);}function checkoutUsernameCheck(){checkoutShowRegistration();xmlHttp=createHttpRequestObject();$('checkoutUsernameWait').style.display='inline';var uname=$('uname').value;$('checkoutUsernameUsed').style.display='none';if(xmlHttp.readyState==4||xmlHttp.readyState==0){var parameters='uname='+encodeURI(uname)+'&checkoutOne=Y';xmlHttp.onreadystatechange=function(){if(xmlHttp.readyState==4){if(xmlHttp.status==200){var xmlResponse=xmlHttp.responseXML;if(!xmlResponse||!xmlResponse.documentElement){return;}try{var login=xmlResponse.getElementsByTagName('login')[0].childNodes[0].nodeValue;if(login=='true'){$('checkoutUsernameUsed').style.display='block';$('uname').style.borderColor='red';checkoutValidUsername=false;}else if(login=='false'){$('uname').style.borderColor='';checkoutValidUsername=true;}}catch(e){}$('checkoutUsernameWait').style.display='none';}else{alert("There was a problem accessing the server: "+xmlHttp.statusText);$('checkoutUsernameWait').style.display='none';}}};xmlHttp.open('POST','cart.php?ajax_function=unamecheck');xmlHttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');xmlHttp.setRequestHeader('Content-length',parameters.length);xmlHttp.setRequestHeader('Connection','close');xmlHttp.send(parameters);}else setTimeout('checkoutUsernameCheck()',1000);}function checkoutRebuildCartTotals(shippingid){$('checkoutTotalsSection').height=$('checkoutTotalsSection').offsetHeight;$('checkoutOneTotals').style.display='none';$('checkoutTotalsWait').style.display='block';for(var i=0;i<coShippingJs.length;i++){if($('radio'+coShippingJs[i]).style.display!='none'&&$('shippingid'+coShippingJs[i]).checked){shippingid=coShippingJs[i];break;}}if(!shippingid)shippingid=checkoutShippingid;xmlHttp=createHttpRequestObject();if(xmlHttp.readyState==4||xmlHttp.readyState==0){var parameters='shippingid='+encodeURI(shippingid)+'&action = update&mode=checkout'+'&checkoutOne=Y';xmlHttp.onreadystatechange=function(){if(xmlHttp.readyState==4){if(xmlHttp.status==200){var xmlResponse=xmlHttp.responseXML;if(!xmlResponse||!xmlResponse.documentElement){alert(co_err_load_cart_ttl);return;}try{$('checkoutDiscountTr').style.display='none';$('checkoutDiscountCouponTr').style.display='none';$('checkoutDiscountedSubtotalTr').style.display='none';$('checkoutCouponsTr').style.display='none';}catch(e){logError(e);}for(x=0;x<cartTotalsToUpdate.length;x++){try{var tmpField=xmlResponse.getElementsByTagName(cartTotalsToUpdate[x])[0].childNodes[0].nodeValue;}catch(e){}if(tmpField){if($(cartTotalsToUpdate[x])!=null)$(cartTotalsToUpdate[x]).innerHTML=tmpField;if($(cartTotalsToUpdate[x]+'Tr')!=null)$(cartTotalsToUpdate[x]+'Tr').style.display='';if(cartTotalsToUpdate[x]=='checkoutShippingCost')$('checkoutShippingTotalsDisplay').style.display='';tmpField=null;}}for(x=0;x<availableTaxes.length;x++){try{var tmpField=xmlResponse.getElementsByTagName('taxTotals'+availableTaxes[x])[0].childNodes[0].nodeValue;}catch(e){$('taxTotals'+availableTaxes[x]).style.display='none';}if(tmpField&&$('taxTotals'+availableTaxes[x])!=null)$('taxTotals'+availableTaxes[x]).style.display='';tmpField=null;}$('checkoutTotalsSection').height='';$('checkoutTotalsWait').style.display='none';$('checkoutOneTotals').style.display='block';}else{alert("There was a problem accessing the server: "+xmlHttp.statusText);}}};xmlHttp.open('POST','cart.php?ajax_function=updatetotals');xmlHttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');xmlHttp.setRequestHeader('Content-length',parameters.length);xmlHttp.setRequestHeader('Connection','close');xmlHttp.send(parameters);}else setTimeout('checkoutRebuildCartTotals()',1000);}function checkoutSaveRegInfo(){xmlHttp=createHttpRequestObject();if(xmlHttp.readyState==4||xmlHttp.readyState==0){var parameters='checkoutOne=Y&ship2diff='+$('ship2diff').value;for(x=0;x<defaultFields.length;x++){try{var tmpField=$(defaultFields[x]).value;}catch(e){}if(tmpField)parameters+='&'+defaultFields[x]+'='+encodeURI(tmpField);tmpField=null;}xmlHttp.onreadystatechange=function(){if(xmlHttp.readyState==4){if(xmlHttp.status==200){var xmlResponse=xmlHttp.responseXML;if(!xmlResponse||!xmlResponse.documentElement){alert(co_err_load_cart_ttl);return;}try{var saved=xmlResponse.getElementsByTagName('saved')[0].childNodes[0].nodeValue;}catch(e){}if(saved)return;}else{alert("There was a problem accessing the server: "+xmlHttp.statusText);}}};xmlHttp.open('POST','cart.php?ajax_function=savereginfo',false);xmlHttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');xmlHttp.setRequestHeader('Content-length',parameters.length);xmlHttp.setRequestHeader('Connection','close');xmlHttp.send(parameters);}else setTimeout('checkoutSaveRegInfo()',1000);}var error=null;function checkoutApplyCoupon(coupon,mode){if(!coupon||!mode)return;$('checkoutCouponButton').style.display='none';$('checkoutCouponWait').style.display='';$('checkoutTotalsSection').height=$('checkoutTotalsSection').offsetHeight;if(mode!='add_coupon'){$('checkoutOneTotals').style.display='none';$('checkoutTotalsWait').style.display='block';}$('checkoutCouponInput').style.display='';checkoutApplyCouponAJAX(coupon,mode);return;}function checkoutApplyCouponAJAX(coupon,mode){xmlHttp=createHttpRequestObject();if(xmlHttp.readyState==4||xmlHttp.readyState==0){var parameters='coupon='+encodeURI(coupon);if(mode=='add_coupon')parameters+='&mode = add_coupon';else parameters+='&mode = remove_coupon';parameters+=' &ajax_function=add_coupon &checkoutOne=Y';xmlHttp.onreadystatechange=function(){if(xmlHttp.readyState==4){if(xmlHttp.status==200){var xmlResponse=xmlHttp.responseXML;if(!xmlResponse||!xmlResponse.documentElement){$('checkoutCouponButton').style.display='';$('checkoutCouponWait').style.display='none';alert(co_err_load_cart_ttl);return;}try{error=xmlResponse.getElementsByTagName('error')[0].childNodes[0].nodeValue;}catch(e){}if(!error){var need_shipping=xmlResponse.getElementsByTagName('need_shipping')[0].childNodes[0].nodeValue;var egoods_in_cart=xmlResponse.getElementsByTagName('egoods_in_cart')[0].childNodes[0].nodeValue;if(need_shipping=='true')needShipping=true;else needShipping=false;if(egoods_in_cart=='true')egoodsInCart=true;else egoodsInCart=false;}if(error){alert(error);}else{checkoutRebuildCartTotals(null);checkoutShowHideShipping();if(!onSaleActive&&mode=='add_coupon')$('checkoutCouponInput').style.display='none';$('coupon').value=co_enter_discount_coupon;}$('checkoutCouponButton').style.display='';$('checkoutCouponWait').style.display='none';error=null;return;}else{alert("There was a problem accessing the server: "+xmlHttp.statusText);}}};xmlHttp.open('POST','cart.php?mode='+mode+'&ajax_function=add_coupon');xmlHttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');xmlHttp.setRequestHeader('Content-length',parameters.length);xmlHttp.setRequestHeader('Connection','close');xmlHttp.send(parameters);}else setTimeout('checkoutApplyCouponAJAX()',1000);}function checkoutLoadCart(){xmlHttp=createHttpRequestObject();if(xmlHttp.readyState==4||xmlHttp.readyState==0){var parameters='checkoutOne=Y';xmlHttp.onreadystatechange=function(){if(xmlHttp.readyState==4){if(xmlHttp.status==200){var xmlResponse=xmlHttp.responseText;if(!xmlResponse){alert(co_err_load_cart_ttl);return;}$('checkoutCartContents').innerHTML=xmlHttp.responseText;$('checkoutCartViewWait').style.display='none';}else{alert("There was a problem accessing the server: "+xmlHttp.statusText);}}};xmlHttp.open('POST','cart.php?ajax_function=load_cart');xmlHttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');xmlHttp.setRequestHeader('Content-length',parameters.length);xmlHttp.setRequestHeader('Connection','close');xmlHttp.send(parameters);}else setTimeout('checkoutLoadCart()',1000);}function checkoutRecoverPassword(){xmlHttp=createHttpRequestObject();var email=$('email_password').value;$('passwordRecoverMessage').innerHTML='';if(!email){alert(co_email_required);return;}$('forgotPasswordWait').style.display='';$('forgotPasswordButton').style.display='none';if(xmlHttp.readyState==4||xmlHttp.readyState==0){var parameters='checkoutOne=Y'+'&email='+encodeURI(email);xmlHttp.onreadystatechange=function(){if(xmlHttp.readyState==4){if(xmlHttp.status==200){var xmlResponse=xmlHttp.responseXML;if(!xmlResponse||!xmlResponse.documentElement){alert(co_err_load_shipping);return;}try{var error=xmlResponse.getElementsByTagName('error')[0].childNodes[0].nodeValue;}catch(e){}if(error){$('passwordRecoverMessage').innerHTML=co_email_not_found;}try{var sent=xmlResponse.getElementsByTagName('sent')[0].childNodes[0].nodeValue;}catch(e){}if(sent){$('passwordRecoverMessage').innerHTML=co_email_sent;}$('forgotPasswordWait').style.display='none';$('forgotPasswordButton').style.display='';return;}else{alert("There was a problem accessing the server: "+xmlHttp.statusText);}}};xmlHttp.open('POST','cart.php?ajax_function=recover_password');xmlHttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');xmlHttp.setRequestHeader('Content-length',parameters.length);xmlHttp.setRequestHeader('Connection','close');xmlHttp.send(parameters);}else setTimeout('checkoutRecoverPassword()',1000);}function checkoutUpdatePaymentid(){xmlHttp=createHttpRequestObject();if(xmlHttp.readyState==4||xmlHttp.readyState==0){var parameters='checkoutOne=Y&paymentid='+$('paymentMethodSelectid').value+'&shippingid='+checkoutShippingid;xmlHttp.onreadystatechange=function(){if(xmlHttp.readyState==4){if(xmlHttp.status==200){var xmlResponse=xmlHttp.responseXML;if(!xmlResponse||!xmlResponse.documentElement){alert(co_err_load_cart_ttl);return;}try{var error=xmlResponse.getElementsByTagName('error')[0].childNodes[0].nodeValue;if(error){paymentMethodSelect('paymentMethodSelect');alert(error);return;}}catch(e){}try{var redirect=xmlResponse.getElementsByTagName('redirect')[0].childNodes[0].nodeValue;if(redirect){window.location=redirect;return;}}catch(e){}return;}else{alert("There was a problem accessing the server: "+xmlHttp.statusText);}}};xmlHttp.open('POST','cart.php?ajax_function=update_paymentid',false);xmlHttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');xmlHttp.setRequestHeader('Content-length',parameters.length);xmlHttp.setRequestHeader('Connection','close');xmlHttp.send(parameters);}else setTimeout('checkoutUpdatePaymentid()',1000);}function checkoutHideTotals(){if(!checkoutShippingLoaded&&needShipping)return;var bgh=$('checkoutTotalsBlurry').offsetHeight;var bgw=$('checkoutTotalsBlurry').offsetWidth;var _left=(bgw-400)/2;var _top=(bgh-125)/2;$('checkoutTotalsClear').style.marginTop=_top+'px';$('checkoutTotalsClear').style.marginLeft=_left+'px';$('checkoutTotalsBlurry').style.width=bgw+'px';$('checkoutTotalsBlurry').style.height=bgh+'px';$('checkoutTotalsClear').style.display='';$('checkoutTotalsBlurry').className='modalBackgroundClass';}function checkoutRebuildAllTotals(alerterror){for(x=0;x<b_required.length;x++){if(b_required[x]=='uname'||b_required[x]=='passwd1'||b_required[x]=='passwd2'||b_required[x]=='email')continue;if($(b_required[x])&&!$(b_required[x]).value){var error=true;if(alerterror)checkoutHighlightError(b_required[x],'error');}}if(error){if(alerterror)alert(co_err_all_required_fields);return;}$('checkoutTotalsClear').style.display='none';$('checkoutTotalsBlurry').className='';$('checkoutTotalsClear').style.marginTop='';$('checkoutTotalsClear').style.marginLeft='';$('checkoutTotalsBlurry').style.width='';$('checkoutTotalsBlurry').style.height='';for(x=0;x<b_required.length;x++){if(b_required[x]=='uname'||b_required[x]=='passwd1'||b_required[x]=='passwd2')continue;if($(b_required[x]))addEvent($(b_required[x]),'change',checkoutHideTotals);}checkoutSaveRegInfo();checkoutLoadShipping();}function checkoutRequiredFields(){var submit_the_form=true;var errorMessage=null;for(x=0;x<b_required.length;x++){if(!$(b_required[x]))continue;var tmp_cell=$(b_required[x]);if(!tmp_cell.value){checkoutHighlightError(b_required[x],'error');submit_the_form=false;errorMessage=co_err_all_required_fields+'<br />';}else{checkoutHighlightError(b_required[x],'erase');}}if($('paymentMethodSelectid').value=='paymentMethodSelect'){submit_the_form=false;if(errorMessage)errorMessage+='&bull; '+co_err_payment_method+'<br />';else errorMessage='&bull; '+co_err_payment_method+'<br />';}if(inArray('uname',b_required)&&!checkoutLogged){if(!checkoutValidUsername){if(errorMessage)errorMessage+='&bull; '+co_reg_error+'<br />';else errorMessage='&bull; '+co_reg_error+'<br />';submit_the_form=false;}}if(checkoutCCCheck&&!checkoutRequiredCC(checkoutCCCheck))submit_the_form=false;if(needShipping&&!checkoutIsShippingLoaded()){submit_the_form=false;if(errorMessage)errorMessage+='&bull; '+co_err_shipping_method+'<br />';else errorMessage='&bull; '+co_err_shipping_method+'<br />';}if(submit_the_form){if(checkoutRemoveExtraPayFields())return true;}else{if(errorMessage){$('checkoutErrorDisplay').style.display='block';$('checkoutErrorDescription').innerHTML=errorMessage;}window.scrollTo(0,0);return false;}}function checkoutRequiredCC(type){if(type=1){if(checkCCNumber(document.checkout_one_form.card_number,document.checkout_one_form.card_type)&&checkExpirationDate(document.checkout_one_form.card_expire_Month,document.checkout_one_form.card_expire_Year))return true;}if(type==2){if(checkCCNumber(document.checkout_one_form.card_number,document.checkout_one_form.card_type)&&checkExpirationDate(document.checkout_one_form.card_expire_Month,document.checkout_one_form.card_expire_Year)&&checkCVV2(document.checkout_one_form.card_cvv2,document.checkout_one_form.card_type))return true;}return false;}function checkoutDoPasswordsMatch(){var ps1=$('passwd1').value;var ps2=$('passwd2').value;if(ps1!=ps2||!ps1||!ps2){if(ps2.length>=ps1.length){$('passwd1').style.borderColor='red';$('passwd2').style.borderColor='red';}$('checkoutPasswordMachError').style.display='inline';return false;}$('img_passwd1').style.display='none';$('passwd1').style.borderColor='';$('img_passwd2').style.display='none';$('passwd2').style.borderColor='';$('checkoutPasswordMachError').style.display='none';return true;}function checkoutHighlightError(field,mode){if(!$('img_'+field)||($('errorimg_'+field)&&mode!='erase'))return;var currentField=$('img_'+field);if(mode=='erase'){currentField.innerHTML='';$(field).style.borderColor='';return;}var errorImg=document.createElement('img');errorImg.height=17;errorImg.width=17;errorImg.id='errorimg_'+field;if(mode=='error')errorImg.src=errorImgPath;else if(mode=='correct')errorImg.src=checkImgPath;currentField.appendChild(errorImg);if(mode=='error'){currentField.style.display='';$(field).style.borderColor='red';}else{currentField.style.display='none';$(field).style.borderColor='';}}function checkoutRemoveErrorHighlight(){for(x=0;x<defaultFields.length;x++){if($(defaultFields[x])){if($(defaultFields[x]).value!='')checkoutHighlightError(defaultFields[x],'erase')}}}function checkoutViewCart(){$('checkoutCartContents').innerHTML='';$('checkoutCartViewWait').style.display='';checkoutCreateModal('cart');checkoutLoadCart();}function checkoutViewTerms(){checkoutCreateModal('terms');}function checkoutClickAgree(decision){checkoutEraseModal('terms');if(decision=='agree')$('agree_to_terms').checked=true;if(decision=='disagree')$('agree_to_terms').checked=false;}function paymentMethodSelect(inID){if(!inID)return;template='template_'+inID;if(inID!='paymentMethodSelect'&&$(template)){$(template).style.display='';if(paymentMethods[inID])$('shipping_method').value=paymentMethods[inID];if(paymentMethodJS[inID])checkoutCCCheck=paymentMethodJS[inID];else checkoutCCCheck=false;if(paymentScripts[inID])$('checkout_one_form').action='payment/'+paymentScripts[inID];}if(lastTemplate&&$(lastTemplate))$(lastTemplate).style.display='none';if(inID!='paymentMethodSelect'){lastTemplate=template;checkoutUpdatePaymentid();}else{lastTemplate=false;checkoutCCCheck=false;$('paymentMethodSelect').selected=true;}}function checkoutHideShippingRegFields(shID){checkoutHideTotals();if(shID==0){$('shipping_address').style.display='none';$('ship2diff').value='N';}else{$('shipping_address').style.display='block';$('ship2diff').value='Y';}}function checkoutPageLoad(){for(x=0;x<defaultFields.length;x++){if($(defaultFields[x])){if(checkoutLogged)addEvent($(defaultFields[x]),'change',checkoutHideTotals);addEvent($(defaultFields[x]),'change',checkoutRemoveErrorHighlight);}}if(paymentid)$('checkout_one_form').action='payment/'+paymentScripts[paymentid];if(checkoutPPSubmit){document.checkout_one_form.submit();return;}if(checkoutPaymentError){$('checkoutErrorDisplay').style.display='';$('checkoutErrorDescription').innerHTML='&bull; '+co_lbl_co_payment_error;}$('preloadHide').style.display='';if(window.XMLHttpRequest)checkoutOpacity('checkoutPreload',100,0,700);setTimeout("$('checkoutPreload').style.display='none'",800);if(!needShipping&&!checkoutLogged){checkoutHideTotals();if(checkoutSavedReg)checkoutRebuildAllTotals(false);$('checkoutShippingSelection').style.display='none';}if(checkoutLogged)checkoutLoadShipping();else checkoutResetCartTotals();}function checkoutEditCart(){checkoutSaveRegInfo();window.location='cart.php';}function checkoutShowRegistration(){$('passwd1display').style.display='';$('passwd2display').style.display='';if($('membershipdisplay'))$('membershipdisplay').style.display='';}function checkoutShowHideShipping(){if(needShipping){if(!egoodsInCart)$('checkoutEgoodsMessage').style.display='none';else $('checkoutEgoodsMessage').style.display='';}if(!needShipping){if(!egoodsInCart)$('checkoutEgoodsMessage').style.display='none';else $('checkoutEgoodsMessage').style.display='';$('checkoutShippingMessage').style.display='none';}}function checkoutDeleteDefault(id,defaultText){if($(id).value==defaultText)$(id).value='';return;}function checkoutResetCartTotals(){if(checkoutSubmitted)return;for(var i=0;i<availableTaxes.length;i++){$('taxTotals'+availableTaxes[i]).style.display='none';}$('checkoutShippingTotalsDisplay').style.display='none';$('checkoutCartTotal').innerHTML=$('checkoutDiscountedSubtotal').innerHTML;$('checkoutCartTotalAlter').innerHTML=$('checkoutDiscountedSubtotalAlter').innerHTML;}function checkoutIsShippingLoaded(){if(!checkoutShippingLoaded)return false;for(var i=0;i<coShippingJs.length;i++){if($('radio'+coShippingJs[i]).style.display!='none'&&$('shippingid'+coShippingJs[i]).checked)return true;}return false;}function checkoutRemoveExtraPayFields(){var curid=$('paymentMethodSelectid').value;for(x=0;x<paymentIDs.length;x++){try{if(curid!=paymentIDs[x]){$('template_div'+paymentIDs[x]).style.display='none';$('template_div'+paymentIDs[x]).innerHTML='';}}catch(e){}}return true;}function checkoutShippingLoadError(e){$('checkoutShippingError').style.display='none';$('checkoutShippingWait').style.display='none';$('checkoutShippingMessage').style.display='';$('checkoutShippingDisplay').style.display='none';logError(e);alert(co_err_load_shipping);}
