// JavaScript Document
var xmlhttp;

// Get Product Description
function GetProductDesc(str)
{
   xmlhttp = GetXmlHttpObject();
   if (xmlhttp == null)
   {
      alert ("Browser does not support HTTP Request");
      return;
   }
   var url = "getdesc.php";
   url = url + "?q=" + str;
   url = url + "&sid=" + Math.random();
   xmlhttp.onreadystatechange = GotDesc;
   xmlhttp.open("GET", url, true);
   xmlhttp.send(null);
}

function GotDesc()
{
   if (xmlhttp.readyState == 4)
   {
      document.forms["QOE"].Desc.value = xmlhttp.responseText;
      if (document.forms["QOE"].Desc.value == "NOF")
      {
         document.forms["QOE"].Desc.value = "";
         alert ("Product Code '" + document.forms["QOE"].SKU.value + "' was not found.")
         document.forms["QOE"].SKU.value = "";
         document.forms["QOE"].Qty.value = "";
         document.getElementById('SKU').focus()
      }
   }
}



function AddToCart(str)
{

   xmlhttp = GetXmlHttpObject();
   if (xmlhttp == null)
   {
      alert ("Browser does not support HTTP Request");
      return;
   }
   var url = "AddToCart.php";
   url = url + "?Qty=" + document.forms["QOE"].Qty.value;
   url = url + "&PatchNo=" + document.forms["QOE"].SKU.value;
   url = url + "&sid=" + Math.random();

   xmlhttp.onreadystatechange = RecordAdded;
   xmlhttp.open("GET", url, true);
   xmlhttp.send(null);
   document.forms["QOE"].SKU.value = "";
   document.forms["QOE"].Qty.value = "";
   document.forms["QOE"].Desc.value = "";
   document.getElementById('SKU').focus()

}


function RecordAdded()
{
   if (xmlhttp.readyState == 4)
   {
      document.getElementById("QOE_ShowCart").innerHTML = xmlhttp.responseText;
   }
}

function GetXmlHttpObject()
{
   if (window.XMLHttpRequest)
   {
      // code for IE7 + , Firefox, Chrome, Opera, Safari
      return new XMLHttpRequest();
   }
   if (window.ActiveXObject)
   {
      // code for IE6, IE5
      return new ActiveXObject("Microsoft.XMLHTTP");
   }
   return null;
}

