﻿function getXMLHTTPRequest() {
try {
req = new XMLHttpRequest();
} catch(err1) {
  try {
  req = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (err2) {
    try {
    req = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (err3) {
      req = false;
    }
  }
}
return req;
}

var http = getXMLHTTPRequest();

function getStock() {
  var myurl = 'stock.php';
  myRand = parseInt(Math.random()*999999999999999);
  var id = document.getElementById('id').value;
  var opt1 = document.getElementById('opt1').value;
  var opt2 = document.getElementById('opt2').value;
  var modurl = myurl+"?rand="+myRand+"&opt1="+opt1+"&opt2="+opt2+"&id="+id;
  
  http.open("GET", modurl, true);
  http.onreadystatechange = useHttpResponse;
  http.send(null);
}

function useHttpResponse() {
   if (http.readyState == 4) {
    if(http.status == 200) {
      var mytext = http.responseText;
      document.getElementById('stockDiv').innerHTML = mytext;
    }
  } else {
  	//document.getElementById('stockDiv').innerHTML = "<img src='ajax-loader.gif'>";
  }
}

function getStock1() {
  var myurl = 'stock.php';
  myRand = parseInt(Math.random()*999999999999999);
  var id = document.getElementById('id1').value;
  var opt1 = document.getElementById('opt11').value;
  var opt2 = document.getElementById('opt21').value;
  var modurl = myurl+"?rand="+myRand+"&opt1="+opt1+"&opt2="+opt2+"&id="+id;
  
  http.open("GET", modurl, true);
  http.onreadystatechange = useHttpResponse1;
  http.send(null);
}

function useHttpResponse1() {
   if (http.readyState == 4) {
    if(http.status == 200) {
      var mytext = http.responseText;
      document.getElementById('stockDiv1').innerHTML = mytext;
    }
  } else {
  	//document.getElementById('stockDiv1').innerHTML = "<img src='ajax-loader.gif'>";
  }
}


function getStock2() {
  var myurl = 'stock.php';
  myRand = parseInt(Math.random()*999999999999999);
  var id = document.getElementById('id2').value;
  var opt1 = document.getElementById('opt12').value;
  var opt2 = document.getElementById('opt22').value;
  var modurl = myurl+"?rand="+myRand+"&opt1="+opt1+"&opt2="+opt2+"&id="+id;
  
  http.open("GET", modurl, true);
  http.onreadystatechange = useHttpResponse2;
  http.send(null);
}

function useHttpResponse2() {
   if (http.readyState == 4) {
    if(http.status == 200) {
      var mytext = http.responseText;
      document.getElementById('stockDiv2').innerHTML = mytext;
    }
  } else {
  	//document.getElementById('stockDiv1').innerHTML = "<img src='ajax-loader.gif'>";
  }
}


function getStock3() {
  var myurl = 'stock.php';
  myRand = parseInt(Math.random()*999999999999999);
  var id = document.getElementById('id3').value;
  var opt1 = document.getElementById('opt13').value;
  var opt2 = document.getElementById('opt23').value;
  var modurl = myurl+"?rand="+myRand+"&opt1="+opt1+"&opt2="+opt2+"&id="+id;
  
  http.open("GET", modurl, true);
  http.onreadystatechange = useHttpResponse3;
  http.send(null);
}

function useHttpResponse3() {
   if (http.readyState == 4) {
    if(http.status == 200) {
      var mytext = http.responseText;
      document.getElementById('stockDiv3').innerHTML = mytext;
    }
  } else {
  	//document.getElementById('stockDiv1').innerHTML = "<img src='ajax-loader.gif'>";
  }
}
