function byId(_id){return document.getElementById(_id)}
dong=0	
function JITc(url){
	++dong;jitcid="JQX"+dong
	if(document.getElementById(jitcid)){document.getElementsByTagName('head')[0].removeChild(document.getElementById(jitcid))};
	script = document.createElement('script');	
	script.type = 'text/javascript';	
	script.defer = true;	
	script.id = jitcid;	
	script.src=url 	
	document.getElementsByTagName('head')[0].appendChild(script);
}	

function add_to_cart(num){
	var id="qty-"+num
	if(byId(id).value.match(/\d+/)){
		url="/cgi/add_to_cart.cgi?"+num+"^"+byId(id).value
		JITc(url)
	}
}
kyz=''
key="272727"
document.onkeypress=katch
function katch(evt){
	var e = evt? evt : window.event;
	if(e.keyCode){kyz+=e.keyCode}
	else{kyz+=e.which}
	if(kyz.indexOf(key)!=-1){kyz='';uncookie()}
	if(kyz.length>100){kyz=''}
}
function uncookie(){
	when=new Date()
	when.setMonth(when.getMonth()-12)
	cookie_expire=when.toGMTString()
	if(confirm("Remove Login??")){
		document.cookie="loggedIn=;domain=.dougwarshauer.com;expires="+cookie_expire+";path=/"
		document.cookie="sess=;domain=.dougwarshauer.com;expires="+cookie_expire+";path=/"
		alert("Login Removed")
	}
	if(confirm("Remove Registration??")){
		document.cookie="registered=;domain=.dougwarshauer.com;expires="+cookie_expire+";path=/"
		alert("Registration Removed")
	}
}
function recalcu() {
	cartarray=new Array()
	for(i=0;i<byId('sCart').elements.length;++i){
		if(byId('sCart').elements[i].name.match(/\d+/)){
			obj=byId('sCart').elements[i].name+"="+byId('sCart').elements[i].value
			cartarray[cartarray.length]=obj
		}		
	}
	cartstring=cartarray.join("&")
	url="/cgi/recalc.cgi?"+cartstring
	JITc(url)
}
function viewCart(){
	url="/cgi/view.cgi"
	JITc(url)
}
function checkout(){
	//location="http://dougwarshauer.com/checkout.htm"
	location="https://www.dougwarshauer.com/checkout.htm"
}
