function emptycart()
{
   SetCookie("BUYCART","","Thu, 01-Jan-1970 00:00:01 GMT");
   SetCookie("RENTCART","","Thu, 01-Jan-1970 00:00:01 GMT");
}

function updatecart(type,item,val)
{
  if(type=="Buy") {
    list = GetCookie("BUYCART");
    if(list==null) list = "";
  } else {
    list = GetCookie("RENTCART");
    if(list==null) list = "";
  }

  if(val>0) {  
    litem = "i=" + item + ",";
    pos = list.indexOf(litem);
    if(pos != -1) {
      fpart = list.substr(0,pos);
      spart = list.substr(pos,list.length);
      pos2  = spart.indexOf(":");
      spart = spart.substr(pos2+1,spart.length);

      quant = val;
      newpart = litem + "n=" + quant + ":";
      nlist = fpart + newpart + spart;
   
      if(type=="Buy") {
        SetCookie("BUYCART",nlist); 
      } else {
        SetCookie("RENTCART",nlist);
      } 
    }
  }
  document.location.href="main.shtml?page=viewcart";
}

function delfromcart(type,item)
{
  if(type=="Buy") {
    list = GetCookie("BUYCART");
    if(list==null) list = "";
  } else {
    list = GetCookie("RENTCART");
    if(list==null) list = "";
  }
  
  litem = "i=" + item + ",";
  pos = list.indexOf(litem);
  if(pos != -1) {
    fpart = list.substr(0,pos);
    spart = list.substr(pos,list.length);
    pos2  = spart.indexOf(":");
    spart = spart.substr(pos2+1,spart.length);
    nlist = fpart + spart;

    if(type=="Buy") {
      SetCookie("BUYCART",nlist); 
    } else {
      SetCookie("RENTCART",nlist);
    } 
  }

  document.location.href="main.shtml?page=viewcart";
}

function addtocart(type,item)
{
  if(type=="BUY") {
    list = GetCookie("BUYCART");
    if(list==null) list = "";
  } else {
    list = GetCookie("RENTCART");
    if(list==null) list = "";
  }
  
  litem = "i=" + item + ",";

  if(list.indexOf(litem)==-1) {
    list = list + "i=" + item + ",n=1:";
   
    if(type=="BUY") {
      SetCookie("BUYCART",list); 
    } else {
      SetCookie("RENTCART",list);
    }
  }
  document.location.href="main.shtml?page=viewcart";
}

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 SetCookie (name, value, expires)
{  
  var argv = SetCookie.arguments;  
  var argc = SetCookie.arguments.length;  
  var path = (argc > 3) ? argv[3] : null;  
  var domain = (argc > 4) ? argv[4] : null;  
  var secure = (argc > 5) ? argv[5] : false;  

  document.cookie = name + "=" + escape (value) + 
    ((expires == null) ? "" : ("; expires=" + expires)) + 
    ((path == null) ? "" : ("; path=" + path)) +  
    ((domain == null) ? "" : ("; domain=" + domain)) +    
    ((secure == true) ? "; secure" : "");
}

function DeleteCookie (name) 
{  
  var exp = new Date();  
  exp.setTime (exp.getTime() - 1);  
  var cval = GetCookie (name);  
  document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}
 
function infowin()
{
  var opt="toolbar=no,scrollbars=yes,directories=no,location=no,menubar=no,width=420,height=600";
  morei = window.open("moreinfo.html", "moreinfo", opt);
  morei.focus();
}

function openpict(pict)
{

  img = "products/images/" + pict;
  document.longdescimg.src = img;
}


function buildspot(models,heading,buy,rent)
{
  document.writeln("<table width=290>");
  mods = models.split("[");

  for (i=0 ; i < mods.length; i=i+2) {
    document.writeln("<tr>");
    document.writeln("<td>");
    document.writeln("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"290\">");
    document.writeln("<tr>");
    document.writeln("<td><img src=\"spacer.gif\" width=\"11\"  height=\"1\" border=\"0\" alt=\"\"></td>");
    document.writeln("<td><img src=\"spacer.gif\" width=\"266\" height=\"1\" border=\"0\" alt=\"\"></td>");
    document.writeln("<td><img src=\"spacer.gif\" width=\"13\"  height=\"1\" border=\"0\" alt=\"\"></td>");
    document.writeln("<td><img src=\"spacer.gif\" width=\"1\"   height=\"1\" border=\"0\" alt=\"\"></td>");
    document.writeln("</tr>");
    document.writeln("<tr>");
    document.writeln("<td rowspan=\"3\"><img name=\"shortblue_r1_c1\" src=\"shortblue_r1_c1.gif\" width=\"11\" height=\"24\" border=\"0\" alt=\"\"></td>");
    document.writeln("<td><img name=\"shortblue_r1_c2\" src=\"shortblue_r1_c2.gif\" width=\"266\" height=\"5\" border=\"0\" alt=\"\"></td>");
    document.writeln("<td rowspan=\"3\"><img name=\"shortblue_r1_c3\" src=\"shortblue_r1_c3.gif\" width=\"13\" height=\"24\" border=\"0\" alt=\"\"></td>");
    document.writeln("<td><img src=\"spacer.gif\" width=\"1\" height=\"5\" border=\"0\" alt=\"\"></td>");
    document.writeln("</tr>");
    document.writeln("<tr>");
    document.writeln("<td bgcolor=\"#A2BDEC\">");
    document.writeln(heading);
    document.writeln("</td>");
    document.writeln("<td><img src=\"spacer.gif\" width=\"1\" height=\"15\" border=\"0\" alt=\"\"></td>");
    document.writeln("</tr>");
    document.writeln("<tr>");
    document.writeln("<td><img name=\"shortblue_r3_c2\" src=\"shortblue_r3_c2.gif\" width=\"266\" height=\"4\" border=\"0\" alt=\"\"></td>");
    document.writeln("<td><img src=\"spacer.gif\" width=\"1\" height=\"4\" border=\"0\" alt=\"\"></td>");
    document.writeln("</tr>");
    document.writeln("</table>");
    document.writeln("</td></tr><tr>");
    document.writeln("<td valign=\"bot\" width=\"75\">");
    line = "<b>"+mods[i+1]+"</b><br>";
    document.writeln(line);
    line = "<img align=\"left\" src=\"products/"+mods[i]+"/pict.jpg\">";
    document.writeln(line);
    document.writeln(mods[i+1]);
    document.writeln("<br>");
    document.writeln("</td></tr>");
    document.writeln("<tr><td align=\"Left\">");
    if(buy == 1) 
      document.writeln("<Img src=\"buyimg.gif\" alt=\"Buy\">");
    if(rent == 1) 
      document.writeln("<Img src=\"rentimg.gif\" alt=\"Rent\">");
    document.writeln("</td></tr>");
  }

  document.writeln("</table>");
}

function display_tabs(disp,name,link)
{
      if(name==curpage) {
        line = "<td align=\"center\" valign=\"middle\" width=\"75\" bgcolor=\"#99b3cd\">";
        line = line + "<A class=\"tabs\"";
        line = line + " href=\"" + link + "\">" + disp + "</a></td>";
      } else {
        line = "<td align=\"center\" valign=\"middle\" width=\"75\" bgcolor=\"#ffffff\">";
        line = line + "<A class=\"tabsn\"";
        line = line + " href=\"" + link + "\">" + disp + "</a></td>";
      }
      document.writeln(line);
      line = "<td width=\"1\" bgcolor=\"#99b3cd\">";
      line = line + "<img width=\"1\" height=\"30\" border=\"0\" src=\"spacer.gif\" alt=\"\"></td>";
      document.writeln(line);
}

function display_cats(name)
{
  document.writeln("<tr>");
  line="<td nowrap align=\"left\" bgcolor=\"#ffffff\" class=\"tdtext\">";
  document.writeln(line);
  line="&nbsp;<A class=\"cattext\" Href=\"main.shtml?page=catalog&sub=";
  line=line + name + "\">" + name + "</A>";
  document.writeln(line);
  document.writeln("</td>");
  line="<td bgcolor=\"#99b3cd\" width=\"5\"><img src=\"spacer.gif\" alt=\"\" width=\"5\" height=\"1\"></td>";
  document.writeln(line);
  document.writeln("</tr>");
}
