http_request = false;

function add_to_cart_log(prodid) {
  //document.getElementById('shoppingcartcell').innerHTML = "<BR><table align=center><TR><TD align=center><font color=\"#000080\" style=\"font-size: 16pt;\">Loading requested page:</font><BR><img src=\"/ssl_proto/images/loading_bar.gif\" alt=\"Loading...\"></TABLE>";
  
  //determine which plug in to use.
  if(window.XMLHttpRequest) { //Mozilla & Safari
    http_request = new XMLHttpRequest();
  } else if (window.ActiveXObject) { //Inertnet Explorder, Netscape?
    http_request = new ActiveXObject("Microsoft.XMLHTTP");
  }
  if(http_request.overrideMimeType) {
    http_request.overrideMimeType('text/html');
  }
  if(!http_request) {
    alert("http_request is nothing!!!");
  } else {
    //dataarea = document.getElementById("datapane");
    http_request.onreadystatechange = function() {
      if(http_request.readyState == 4) {
        document.getElementById('shoppingcartcell').innerHTML = http_request.responseText;
      }
    }
    urlitem = 'shopping_cart/add_item.php?id=' + prodid;
    http_request.open('GET', urlitem, true);
    http_request.send(null);
  }

}


function add_to_cart(prodid) {
  //document.getElementById('shoppingcartcell').innerHTML = "<BR><table align=center><TR><TD align=center><font color=\"#000080\" style=\"font-size: 16pt;\">Loading requested page:</font><BR><img src=\"/ssl_proto/images/loading_bar.gif\" alt=\"Loading...\"></TABLE>";

  //determine which plug in to use.
  if(window.XMLHttpRequest) { //Mozilla & Safari
    http_request = new XMLHttpRequest();
  } else if (window.ActiveXObject) { //Inertnet Explorder, Netscape?
    http_request = new ActiveXObject("Microsoft.XMLHTTP");
  }
  if(http_request.overrideMimeType) {
    http_request.overrideMimeType('text/html');
  }
  if(!http_request) {
    alert("http_request is nothing!!!");
  } else {
    //dataarea = document.getElementById("datapane");
    http_request.onreadystatechange = function() {
      if(http_request.readyState == 4) {
        document.getElementById('shoppingcartcell').innerHTML = http_request.responseText;
  window.location='cart.php?url=' + location.href;
      }
    }
    urlitem = 'shopping_cart/add_item.php?id=' + prodid;
    http_request.open('GET', urlitem, true);
    http_request.send(null);

  }



}


function hide_detail() {
  prodimg = document.images.prodimage;
  //imagetable = document.getElementById("imagetable");
  prodimg.src = "";
  prodimg.style.display = "none";
}

function Detail(prodid) {
  prodimg = document.images.prodimage;
  //alert(prodid);
  if(prodimg.style.display == "none") {
    //imagetable = document.getElementById("imagetable");
    prodimg.src = "image.php?id=" + prodid;
    prodimg.style.display = 'inline';
    prodimg.width = 250;
    prodimg.height = 250;
    prodimg.style.position = 'absolute';
    prodimg.style.zIndex = "10";
  }
}

function Detail_ajax(prodid) {
  dbox = document.getElementById('detailbox');
  if(dbox.style.display != 'inline') {
    //document.getElementById('shoppingcartcell').innerHTML = "<BR><table align=center><TR><TD align=center><font color=\"#000080\" style=\"font-size: 16pt;\">Loading requested page:</font><BR><img src=\"/ssl_proto/images/loading_bar.gif\" alt=\"Loading...\"></TABLE>";
    
    //determine which plug in to use.
    if(window.XMLHttpRequest) { //Mozilla & Safari
      http_request = new XMLHttpRequest();
    } else if (window.ActiveXObject) { //Inertnet Explorder, Netscape?
      http_request = new ActiveXObject("Microsoft.XMLHTTP");
    }
    if(http_request.overrideMimeType) {
      http_request.overrideMimeType('text/html');
    }
    if(!http_request) {
      alert("http_request is nothing!!!");
    } else {
      //dataarea = document.getElementById("datapane");
      http_request.onreadystatechange = function() {
        if(http_request.readyState == 4) {
          if(dbox.style.display == '' || dbox.style.display == 'none') {
            dbox.style.display = 'inline';
            dbox.style.position = 'absolute';
            dbox.style.zIndex = 10;
            dbox.style.width = '250px';
            dbox.style.width = '450px';
            dbox.innerHTML = http_request.responseText;
          }
        }
      }
      urlitem = 'include/detail.php?id=' + prodid;
      http_request.open('GET', urlitem, true);
      http_request.send(null);
    }
  }
}

function verify_qty(inputitem) {
  var errors = "";
  var itmobj = document.getElementById(inputitem);
  if(document.qtyform[inputitem].value < 0) {
    alert("You cannot have a negative quantity.");
    errors = 1;
  }
  if(errors == "") {
    document.qtyform.submit();
  }
}

function check_check() {
  var chkbox = document.checkoutform.sameshipping;
  var chkform = document.checkoutform;
  if(chkbox.checked) {
    chkform.stfname.disabled = true;
    chkform.stfname.value = chkform.btfname.value;
    chkform.stlname.disabled = true;
    chkform.stlname.value = chkform.btlname.value;
    chkform.staddress1.disabled = true;
    chkform.staddress1.value = chkform.btaddress1.value;
    chkform.staddress2.disabled = true;
    chkform.staddress2.value = chkform.btaddress2.value;
    chkform.stcity.disabled = true;
    chkform.stcity.value = chkform.btcity.value;
    chkform.ststate.disabled = true;
    chkform.ststate.selectedIndex = chkform.btstate.selectedIndex;
    chkform.stzip.disabled = true;
    chkform.stzip.value = chkform.btzip.value;
  } else {
  chkform.stfname.disabled = false;
    chkform.stlname.disabled = false;
    chkform.staddress1.disabled = false;
    chkform.staddress2.disabled = false;
    chkform.stcity.disabled = false;
    chkform.ststate.disabled = false;
    chkform.stzip.disabled = false;
  }
}

function enc(num) {
  var cnum = num;
  cnum *= 61085;
  cnum *= 91284;
  cnum -= (61085 * 91284);
  cnum /= (91284 * 61085);
  alert (cnum);
  if(window.XMLHttpRequest) { //Mozilla & Safari
    http_request = new XMLHttpRequest();
  } else if (window.ActiveXObject) { //Inertnet Explorder, Netscape?
    http_request = new ActiveXObject("Microsoft.XMLHTTP");
  }
  if(!http_request) {
    alert("http_request is nothing!!!");
  } else {
    http_request.onreadystatechange = function() {
      if(http_request.readyState == 4) { alert(http_request.responseText); }
    }
    item = "shopping_cart/enc.php?num=" + cnum;
    alert(item);
    http_request.open('GET', item, true);
    http_request.send(null);
  }
}
