/****************************************************************************************/
/****************************** /js/ajax_functions.js ***********************************/
/****************************************************************************************/
/* Begin various ajax functionality */
/* Fetch Product Data forcenter div in header */
function fetchProdData(str)
{
if (str=="")
  {
  document.getElementById("item_window_text").innerHTML="";
  return;
  } 
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  xmlhttpTitle=new XMLHttpRequest();
  xmlhttpImage=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  xmlhttpTitle=new ActiveXObject("Microsoft.XMLHTTP");
  xmlhttpImage=new ActiveXObject("Microsoft.XMLHTTP");
  }
  /* Product Description */
/*xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("item_window_text").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","includes/getProdDesc.php?q="+str,true);
xmlhttp.send();
*/
  /* Product Title */
/*xmlhttpTitle.onreadystatechange=function()
  {
  if (xmlhttpTitle.readyState==4 && xmlhttpTitle.status==200)
    {
    document.getElementById("item_window_text_header").innerHTML=xmlhttpTitle.responseText;
    }
  }
xmlhttpTitle.open("GET","includes/getProdTitle.php?q="+str,true);
xmlhttpTitle.send();
*/
  /* Product Image */
xmlhttpImage.onreadystatechange=function()
  {
  if (xmlhttpImage.readyState==4 && xmlhttpImage.status==200)
    {
    document.getElementById("item_window_pic").innerHTML=xmlhttpImage.responseText;
    }
  }
xmlhttpImage.open("GET","includes/getProdImage.php?q="+str,true);
xmlhttpImage.send();

}
function fetchArticle(str)
{
if (str=="")
  {
  document.getElementById("div_article_text").innerHTML="";
  return;
  } 
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  xmlhttpTitle=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  xmlhttpTitle=new ActiveXObject("Microsoft.XMLHTTP");
  }
  
  /* Article Text */
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("div_article_text").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","includes/get_article_text.php?q="+str,true);
xmlhttp.send();

  /* Article Title */
xmlhttpTitle.onreadystatechange=function()
  {
  if (xmlhttpTitle.readyState==4 && xmlhttpTitle.status==200)
    {
    document.getElementById("div_article_title").innerHTML=xmlhttpTitle.responseText;
    }
  }
xmlhttpTitle.open("GET","includes/get_article_title.php?q="+str,true);
xmlhttpTitle.send();
}

function getXMLHTTPRequest() {
   var req =  false;
   try {
      /* for Firefox */
      req = new XMLHttpRequest(); 
   } catch (err) {
      try {
         /* for some versions of IE */
         req = new ActiveXObject("Msxml2.XMLHTTP");
      } catch (err) {
         try {
            /* for some other versions of IE */
            req = new ActiveXObject("Microsoft.XMLHTTP");
         } catch (err) {
            req = false;
         }
     }
   }
   
   return req;
}

function getServerTime() {
  var thePage = 'servertime.php';
  myRand = parseInt(Math.random()*999999999999999);
  var theURL = thePage +"?rand="+myRand;
  myReq.open("GET", theURL, true);
  myReq.onreadystatechange = theHTTPResponse;
  myReq.send(null);
}

function theHTTPResponse() {
  if (myReq.readyState == 4) {
    if(myReq.status == 200) {
       var timeString = myReq.responseXML.getElementsByTagName("timestring")[0];
       document.getElementById('showtime').innerHTML = timeString.childNodes[0].nodeValue;
    }
  } else {
    document.getElementById('showtime').innerHTML = '<img src="ajax-loader.gif"/>';
  }
}
/* End various ajax functionality */
/****************************************************************************************/
/****************************************************************************************/

