var today = new Date();
var expiry = new Date(today.getTime() + 365 * 24 * 60 * 60 * 1000);
 

function getCookieVal (offset) {
 var endstr = document.cookie.indexOf (";", offset);
 if (endstr == -1) { endstr = document.cookie.length; }
 return unescape(document.cookie.substring(offset, endstr));
 }
 
function GetCookie (name) {
 var arg = name + "=";
 var alen = arg.length;
 var clen = document.cookie.length;
 var i = 0;
 while (i < clen) {
  var j = i + alen;
  if (document.cookie.substring(i, j) == arg) {
   return getCookieVal (j);
   }
  i = document.cookie.indexOf(" ", i) + 1;
  if (i == 0) break; 
  }
 return null;
 }
 
function DeleteCookie (name,path,domain) {
var today = new Date();
var expiry2 = new Date(today.getTime() - 24*60* 60 * 1000);
 if (GetCookie(name)) {
  document.cookie = name + "=" + "; expires=" + expiry2.toGMTString()
  }
 }
 
function SetCookie (name,value,expires,path,domain,secure) {
var today = new Date();
var expiry1 = new Date(today.getTime() +  24*60*60 * 1000);
 
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "; expires=" + expiry1.toGMTString()) +";path=/"


 }




function add(name,n_form,add_text){
if(!isNaN(n_form)){
	if(document.forms[0][n_form].value==""){return}
	n_form=(document.forms[0][n_form].value+"||")
}
try{cart.close()}
catch(e){}
wid_scr=(document.all)?window.document.body.clientWidth:window.innerWidth
cart=window.open("http://www.tuvproductions.com/add_to_cart.htm#"+(name+"").replace("&","^^^")+"&"+(n_form+"").replace("&","^^^")+"&"+(add_text+"").replace("&","^^^"),"cart","top=200, left="+(wid_scr-220)+", width=220, height=160, resizable=1")
cart.focus()
}

function view(){
window.location.href="http://www.tuvproductions.com/cart.asp"
}


function chan(n){
cook2=new Array()

a=""
j=0
for (i=1; i<n; i++){

	cook=document.f1["s"+i].value
	if (document.f1["d"+i].checked==1){
	}else{
		qty=document.f1["q"+i].value
		if (isNaN(qty)){
		alert(qty+" - NaN")
		return false
		}else{
		qty=Math.floor(qty)

		cook2[j]=cook+"|"+qty
		j++
		}
	}
}
cook=cook2.join("*")+"*"

SetCookie("shop",cook)
return true
}

function re(n){

if(chan(n))window.location.reload()
}
function check(n){
if(chan(n))window.location.href="check.asp"
}

