
function SetCookie(name, value, expiredays)
{
  var todayDate = new Date();
  todayDate.setDate(todayDate.getDate() + expiredays);
  document.cookie = name + "=" + value + "; expires=" +
                    todayDate.toGMTString() + "; path=/;" 
}

function saveclient() 
{  
 SetCookie("PSPORG", escape(ptlclientinfo.orgname.value), 1000);
 SetCookie("PSPDPOS", escape(ptlclientinfo.dposname.value), 1000);
 SetCookie("PSPFIO", escape(ptlclientinfo.name.value), 1000);
 SetCookie("PSPPHN", escape(ptlclientinfo.phone.value), 1000);
 SetCookie("PSPNTE", escape(ptlclientinfo.note.value), 1000);
 email = ptlclientinfo.email.value;
 SetCookie("PSPEML", escape(email.replace(/ /gi, "")), 1000);
}

function saveadress() 
{  
 SetCookie("PSPADR", escape(ptlshoporder.adress.value), 1000);
}

function savedlvrbstp() 
{  
 bagrecalc.basetpid.value = ptlshoporder.basetpid.options[document.ptlshoporder.basetpid.selectedIndex].value;
 bagrecalc.dlvrtpid.value = ptlshoporder.dlvrtpid.options[document.ptlshoporder.dlvrtpid.selectedIndex].value;
 if (document.ptlshoporder.dlvrtpid.selectedIndex > 0)
 bagrecalc.dlvrid.value = ptlshoporder.dlvrid.options[document.ptlshoporder.dlvrid.selectedIndex].value;
 else bagrecalc.dlvrid.value = '';
}

function savetools(qty)
{
  var isimg,isimggrp,store,transit,order;

  if(ptltools.needimg.checked) isimg = "Y"; else isimg = "N";  
  if(ptltools.needimggrp.checked) isimggrp = "Y"; else isimggrp = "N";  
  if(ptltools.onstore.checked) store = "Y"; else store = "N";
  if(ptltools.ontransit.checked) transit = "Y";  else transit = "N";
  if(ptltools.onorder.checked) order = "Y"; else order = "N";

  SetCookie("PSPISIMGGRP", isimggrp, 1000);
  SetCookie("PSPISIMG", isimg, 1000);
  SetCookie("PSPSTORE", store, 1000);
  SetCookie("PSPTRANSIT", transit, 1000);
  SetCookie("PSPORDER", order, 1000);
  SetCookie("PSPROWS",qty, 1000);
  
  rnd = getRandom();

  url = document.ptltools.url_back.value;
  if (url.indexOf("seed=")>=0) url = url.substring(0,url.indexOf("seed=")-1);
  url = url + "&prm=" + isimg + isimggrp + store + transit + order + qty;
  url = url + "&seed="+String(rnd);
  url = url.toLowerCase()
  window.close();
  top.opener.location = url;
}

function saverows(qty)
{
  SetCookie("PSPROWS",qty, 1000);
  
  rnd = getRandom();

  url = document.ptlrowdisp.urlback.value;
  if (url.indexOf("seed=")>=0) url = url.substring(0,url.indexOf("seed=")-1);
  if (url.indexOf("prm=")>=0) url = url + qty;
  url = url + "&seed="+String(rnd);
  url = url.toLowerCase()
  window.location = url;
}


