// Ver: 1.0 usmanrv@gmail.com
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();
var innerItemId =123123;
var innerREGIM =0;
var FlagAjax=0;
function getInstallationNo(iditem)
{
// document.getElementById("MyErrorMes").innerHTML = "<tr><td align=center><font face=arial color=Crimson size=2><strong>Installation locations may not be assigned without signing in as a customer first.</strong></font></td></tr>";
document.getElementById('Installation'+iditem).value = " ";
alert("Installation locations may not be assigned without signing in as a customer first.");
}
function getCommentNo()
{
//  document.getElementById('MyErrorMes').innerHTML = '<tr><td align=center><font face=arial color=Crimson size=2><strong>Comments for each product  may not be assigned without signing in as a customer first.</strong></font></td></tr>';
alert("Comments for each product  may not be assigned without signing in as a customer first.");
}
function getMoveNo()
{
//  document.getElementById('MyErrorMes').innerHTML = '<tr><td align=center><font face=arial color=Crimson size=2><strong>Comments for each product  may not be assigned without signing in as a customer first.</strong></font></td></tr>';
alert("Products in Wish List  may not be moved without signing in as a customer first.");
}
function getRemoveNo()
{
//  document.getElementById('MyErrorMes').innerHTML = '<tr><td align=center><font face=arial color=Crimson size=2><strong>Comments for each product  may not be assigned without signing in as a customer first.</strong></font></td></tr>';
alert("Products in Wish List  may not be removed without signing in as a customer first.");
}

function getAjaxGlavImg(iditem) {
  var myurl = 'usmanajax2.asp?individual='+iditem;
if (FlagAjax == 0 )
{
FlagAjax=1;
  innerItemId=iditem;
  myRand = parseInt(Math.random()*999999999999999);
  var mynumber="Installation"+iditem;
  // add random number to URL to avoid cache problems
  var modurl = myurl+"&rand="+myRand+" ";
//document.write(modurl);
  http.open("GET", modurl, true);
  // set up the callback function
  http.onreadystatechange = useHttpResponseIndividual;
  http.send(null);
}
}
 
function getInstallationItem(iditem,REGIM) {
  var myurl = 'usmanajax.asp?install='+iditem;
if (FlagAjax == 0 )
{
FlagAjax=1;
  innerItemId=iditem;
   if (REGIM == 1) 
   {
      myurl=myurl+"&other=Yes";
   }
   if (REGIM == 2) 
   {
      myurl=myurl+"&droplist=Yes";
   }
  myRand = parseInt(Math.random()*999999999999999);
  var mynumber="Installation"+iditem;
  // add random number to URL to avoid cache problems
  var modurl = myurl+"&rand="+myRand+"&ivalue="+escape(document.getElementById("Installation"+iditem).value)+" ";
//document.write(modurl);
  http.open("GET", modurl, true);
  // set up the callback function
  http.onreadystatechange = useHttpResponseInstallation;
  http.send(null);
}
}
function getALItem(iditem,REGIM) {
  var myurl = 'usmanajax.asp?AL='+iditem+'&regim='+REGIM;
if (FlagAjax == 0 )
{
FlagAjax=1;
  innerItemId=iditem;
  innerREGIM=REGIM;
  myRand = parseInt(Math.random()*999999999999999);
  var mynumber="Installation"+iditem;
  // add random number to URL to avoid cache problems           
  var modurl = myurl+"&rand="+myRand+"&ivalue=";
	if (REGIM==1)
	{
	modurl=modurl+escape(document.getElementById("ALTXT"+iditem).value)+" ";
	}
	if (REGIM==2)
	{
	modurl=modurl+escape(document.getElementById("ALID"+iditem).value)+" ";
	}
	if (REGIM==3)
	{
	modurl=modurl+escape(document.getElementById("ALSIZE"+iditem).value)+" ";
	}
	if (REGIM==7)
	{
	modurl=modurl+escape(document.getElementById("ALCOST"+iditem).value)+" ";
	}

//document.write(modurl);
  http.open("GET", modurl, true);
  // set up the callback function
  http.onreadystatechange = useHttpALResponse;
  http.send(null);
}
}
function getALInstallation(iditem,REGIM) {
  var myurl = 'usmanajax.asp?ALinstall='+iditem;
if (FlagAjax == 0 )
{
FlagAjax=1;
  innerItemId=iditem;
   if (REGIM == 1) 
   {
      myurl=myurl+"&other=Yes";
   }
   if (REGIM == 2) 
   {
      myurl=myurl+"&droplist=Yes";
   }
  myRand = parseInt(Math.random()*999999999999999);
  var mynumber="Installation"+iditem;
  // add random number to URL to avoid cache problems
  var modurl = myurl+"&rand="+myRand+"&ivalue="+escape(document.getElementById("ALPROD"+iditem).value)+" ";
//document.write(modurl);
  http.open("GET", modurl, true);
  // set up the callback function
  http.onreadystatechange = useHttpResponseALInstallation;
  http.send(null);
}
}

function getQuantity(iditem) {
  var myurl = 'usmanajax.asp?item='+iditem+'&quantity='+document.getElementById("QTY"+iditem).value;
  innerItemId=iditem;
  myRand = parseInt(Math.random()*999999999999999);
  // add random number to URL to avoid cache problems
  var modurl = myurl+"&rand="+myRand+"";
  http.open("GET", modurl, true);
  // set up the callback function
  http.onreadystatechange = useHttpResponseQuantity;
  http.send(null);
}
function getLDQuantity(iditem) {
  var myurl = 'usmanajax.asp?item='+iditem+'&LDquantity='+document.getElementById("QTY"+iditem).value;
  innerItemId=iditem;
  myRand = parseInt(Math.random()*999999999999999);
  // add random number to URL to avoid cache problems
  var modurl = myurl+"&rand="+myRand+"";
  http.open("GET", modurl, true);
  // set up the callback function
  http.onreadystatechange = useHttpResponseQuantity;
  http.send(null);
}
function getALQuantity(iditem) {
  var myurl = 'usmanajax.asp?item='+iditem+'&ALquantity='+document.getElementById("ALQTY"+iditem).value;
  innerItemId=iditem;
  myRand = parseInt(Math.random()*999999999999999);
  // add random number to URL to avoid cache problems
  var modurl = myurl+"&rand="+myRand+"";
  http.open("GET", modurl, true);
  // set up the callback function
  http.onreadystatechange = useHttpResponseALQuantity;
  http.send(null);
}

function getComment(iditem,REGIM) {
if (FlagAjax == 0)
{
FlagAjax=1;
  var myurl = 'usmanajax.asp?comment='+iditem;
  innerItemId=iditem;
  myRand = parseInt(Math.random()*999999999999999);
  // add random number to URL to avoid cache problems
  var modurl = myurl+"&rand="+myRand
   if (REGIM == 0)
   {
    modurl=modurl+"&ivalue="+escape(document.getElementById("NoticePr"+iditem).value)+"";
   }
   if (REGIM == 1)
   {
    modurl=modurl+"&addcomment=Yes";
   }
   if (REGIM == 2)
   {
    modurl=modurl+"&delcomment=Yes";
   }
  http.open("GET", modurl, true);
  // set up the callback function
  http.onreadystatechange = useHttpResponseNotice;
  http.send(null);
}
}
function getALComment(iditem,REGIM) {
if (FlagAjax == 0)
{
FlagAjax=1;
  var myurl = 'usmanajax.asp?ALcomment='+iditem;
  innerItemId=iditem;
  myRand = parseInt(Math.random()*999999999999999);
  // add random number to URL to avoid cache problems
  var modurl = myurl+"&rand="+myRand
   if (REGIM == 0)
   {
    modurl=modurl+"&ivalue="+escape(document.getElementById("ALNOTI"+iditem).value)+"";
   }
   if (REGIM == 1)
   {
    modurl=modurl+"&addcomment=Yes";
   }
   if (REGIM == 2)
   {
    modurl=modurl+"&delcomment=Yes";
   }
  http.open("GET", modurl, true);
  // set up the callback function
  http.onreadystatechange = useHttpResponseALNotice;
  http.send(null);
}
}

function getMoveUpRow(iditem) {
if (FlagAjax == 0)
{
FlagAjax=1;
  var myurl = 'usmanajax.asp?moveup='+iditem
  innerItemId=iditem;
  myRand = parseInt(Math.random()*999999999999999);
  // add random number to URL to avoid cache problems
  var modurl = myurl+"&rand="+myRand+"";
  http.open("GET", modurl, true);
  // set up the callback function
  http.onreadystatechange = useHttpResponseMoveUp;
  http.send(null);
}
}
function getMoveDownRow(iditem) {
if (FlagAjax == 0)
{
FlagAjax=1;
  var myurl = 'usmanajax.asp?movedown='+iditem
  innerItemId=iditem;
  myRand = parseInt(Math.random()*999999999999999);
  // add random number to URL to avoid cache problems
  var modurl = myurl+"&rand="+myRand+"";
  http.open("GET", modurl, true);
  // set up the callback function
  http.onreadystatechange = useHttpResponseMoveDown;
  http.send(null);
}
}

function getRemoveRow(iditem,uoidCart){
 	if (confirm("Are you sure you want to delete item "+uoidCart+"? \n ")) {
		if (FlagAjax == 0)
		{
		FlagAjax=1;
		  var myurl = 'usmanajax.asp?removerow='+iditem
		  innerItemId=iditem;
		  myRand = parseInt(Math.random()*999999999999999);
		  // add random number to URL to avoid cache problems
		  var modurl = myurl+"&rand="+myRand+"";
		  http.open("GET", modurl, true);
		  // set up the callback function
		  http.onreadystatechange = useHttpResponseRemoveRow;
		  http.send(null);
		}

	}
}

function getAjaxAddItem(iditem,idprice){
		if (FlagAjax == 0)
		{
		FlagAjax=1;
		  var myurl = 'usmanajax2.asp?additem='+iditem+'&price='+idprice;
		  innerItemId=iditem;
		  myRand = parseInt(Math.random()*999999999999999);
		  // add random number to URL to avoid cache problems
		  var modurl = myurl+"&rand="+myRand+"";
		  http.open("GET", modurl, true);
		  // set up the callback function
		  http.onreadystatechange = useHttpResponseAddItem;
		  http.send(null);
		}
}

function getLDRemoveRow(iditem,uoidCart){
 	if (confirm("Are you sure you want to delete item "+uoidCart+"? \n ")) {
		if (FlagAjax == 0)
		{
		FlagAjax=1;
		  var myurl = 'usmanajax.asp?LDremoverow='+iditem
		  innerItemId=iditem;
		  myRand = parseInt(Math.random()*999999999999999);
		  // add random number to URL to avoid cache problems
		  var modurl = myurl+"&rand="+myRand+"";
		  http.open("GET", modurl, true);
		  // set up the callback function
		  http.onreadystatechange = useHttpResponseLDRemoveRow;
		  http.send(null);
		}

	}
}
function getALRemoveRow(iditem,uoidCart){
 	if (confirm("Are you sure you want to delete item "+uoidCart+"? \n ")) {
		if (FlagAjax == 0)
		{
		FlagAjax=1;
		  var myurl = 'usmanajax.asp?ALremoverow='+iditem
		  innerItemId=iditem;
		  myRand = parseInt(Math.random()*999999999999999);
		  // add random number to URL to avoid cache problems
		  var modurl = myurl+"&rand="+myRand+"";
		  http.open("GET", modurl, true);
		  // set up the callback function
		  http.onreadystatechange = useHttpResponseALRemoveRow;
		  http.send(null);
		}

	}
}


/////////////////////////////////////////////////////////////////

function useHttpResponseInstallation() {
   if (http.readyState == 4) {
    if(http.status == 200) {
       document.getElementById("XPROD"+innerItemId).innerHTML = http.responseText;
  http.onreadystatechange =null;
	FlagAjax=0;
 }
  } else {
  document.getElementById('XPROD'+innerItemId).innerHTML = '<img src="anim.gif">';
  }
}
function useHttpResponseAddItem() {
   if (http.readyState == 4) {
    if(http.status == 200) {
	var myresponse=http.responseText;
	var mysplit=myresponse.split("%%");
                   if (mysplit[0] !="xxx")
		{
               document.getElementById("XITEMTOTAL").innerHTML = "<strong>"+mysplit[1]+"</strong>";
               document.getElementById("XQTYTOTAL").innerHTML = "<strong>"+mysplit[2]+"</strong>";
               document.getElementById("XTOTAL").innerHTML = "<strong>"+mysplit[3]+"</strong>";
  http.onreadystatechange =null;
alert("Product #"+innerItemId+" was added to Your Wish List");
		}
		FlagAjax=0;
 }
  } else {
  document.getElementById('XTOTAL').innerHTML = '<img src="anim.gif">';
  }
}

function useHttpResponseQuantity() {
   if (http.readyState == 4) {
    if(http.status == 200) {
	var myresponse=http.responseText;
	var mysplit=myresponse.split("%%");
               document.getElementById("XQTY"+innerItemId).innerHTML =mysplit[0];
				if (mysplit[1]!="xxx")
               document.getElementById("XPRIC"+innerItemId).innerHTML = mysplit[1];
               document.getElementById("XQTYTOTAL").innerHTML = "<strong>"+mysplit[2]+"</strong>";
               document.getElementById("XTOTAL").innerHTML ="<strong>"+mysplit[3]+"</strong>";
//               document.getElementById("XTOTAL").innerHTML = "xxx1241241="+mysplit[3]+"=";
  http.onreadystatechange =null;
		FlagAjax=0;
 }
  } else {
  document.getElementById('XQTY'+innerItemId).innerHTML = '<img src="anim.gif">';
  }
}
function useHttpResponseALQuantity() {
   if (http.readyState == 4) {
    if(http.status == 200) {
	var myresponse=http.responseText;
	var mysplit=myresponse.split("%%");
               document.getElementById("XALQTY"+innerItemId).innerHTML = mysplit[0];
               document.getElementById("XALPRIC"+innerItemId).innerHTML = mysplit[1];
               document.getElementById("XQTYTOTAL").innerHTML ="<strong>"+mysplit[2]+"</strong>";
               document.getElementById("XTOTAL").innerHTML ="<strong>"+mysplit[3]+"</strong>";
  http.onreadystatechange =null;
		FlagAjax=0;
 }
  } else {
  document.getElementById('XALQTY'+innerItemId).innerHTML = '<img src="anim.gif">';
  }
}

function useHttpResponseNotice() {
   if (http.readyState == 4) {
    if(http.status == 200) {
       document.getElementById("XNOTI"+innerItemId).innerHTML = http.responseText;
  http.onreadystatechange =null;
	FlagAjax=0;
 }
  } else {
  document.getElementById('XNOTI'+innerItemId).innerHTML = '<img src="anim.gif">';
  }
}

function useHttpResponseMoveUp() {
   if (http.readyState == 4) {
    if(http.status == 200) {
	var myresponse=http.responseText;
	var mysplit=myresponse.split("%%");
                   if (mysplit[0] !="xxx")
		{
	var prominnerhtml=document.getElementById("XROW"+mysplit[0]).innerHTML;
          document.getElementById("XROW"+mysplit[0]).innerHTML =document.getElementById("XROW"+mysplit[1]).innerHTML;
          document.getElementById("XROW"+mysplit[1]).innerHTML =prominnerhtml;
	  document.getElementById('XUPROW'+mysplit[2]).innerHTML =mysplit[5];
	  document.getElementById('XUPROW'+mysplit[3]).innerHTML =mysplit[4];
                   if (mysplit[6] !="xxx")
			{
	  document.getElementById('XDownROW'+mysplit[2]).innerHTML =mysplit[6];
	  document.getElementById('XDownROW'+mysplit[3]).innerHTML =mysplit[7];
			}
		}
  http.onreadystatechange =null;
		FlagAjax=0;
	 }
	  } else {
	  document.getElementById('XUPROW'+innerItemId).innerHTML = '<img src="anim.gif">';
	  }
}
function useHttpResponseMoveDown() {
   if (http.readyState == 4) {
    if(http.status == 200) {
	var myresponse=http.responseText;
	var mysplit=myresponse.split("%%");
                   if (mysplit[0] !="xxx")
		{
	var prominnerhtml=document.getElementById("XROW"+mysplit[0]).innerHTML;
          document.getElementById("XROW"+mysplit[0]).innerHTML =document.getElementById("XROW"+mysplit[1]).innerHTML;
          document.getElementById("XROW"+mysplit[1]).innerHTML =prominnerhtml;
	  document.getElementById('XDownROW'+mysplit[2]).innerHTML =mysplit[4];
	  document.getElementById('XDownROW'+mysplit[3]).innerHTML =mysplit[5];
                   if (mysplit[6] !="xxx")
			{
	  document.getElementById('XUPROW'+mysplit[2]).innerHTML =mysplit[6];
	  document.getElementById('XUPROW'+mysplit[3]).innerHTML =mysplit[7];
			}
		}
  http.onreadystatechange =null;
		FlagAjax=0;
	 }
	  } else {
	  document.getElementById('XDownROW'+innerItemId).innerHTML = '<img src="anim.gif">';
	  }
}


function useHttpResponseRemoveRow() {
   if (http.readyState == 4) {
    if(http.status == 200) {
	var myresponse=http.responseText;
	var mysplit=myresponse.split("%%");
 	var k=0;
                   if (mysplit[0] !="xxx")
		{
                      for (i=mysplit[0];i<=mysplit[1]-1;i++)
			{
k=1+parseInt(i);
               	          document.getElementById("XROW"+i).innerHTML = document.getElementById("XROW"+k).innerHTML;
			}
		if (mysplit[1] == 0)
		{
               document.getElementById("XROW0").innerHTML = "<table width=100%><tr><td align=center width=100%  class=categorytitles>Your wish list is empty.</td></tr></table>  ";
		}
		else
		{
               document.getElementById("XROW"+mysplit[1]).innerHTML = "  ";
		}
               document.getElementById("XITEMTOTAL").innerHTML = "<b>"+mysplit[2]+"</b>";
               document.getElementById("XQTYTOTAL").innerHTML = "<b>"+mysplit[3]+"</b>";
               document.getElementById("XTOTAL").innerHTML = "<b>"+mysplit[4]+"</b>";
                   if (mysplit[5] !="xxx")
                   {
				if (document.getElementById("XUPROW"+mysplit[5])) {
	                       document.getElementById("XUPROW"+mysplit[5]).innerHTML = mysplit[6];;
				}
				if (document.getElementById("XDownROW"+mysplit[5])) {
	                       document.getElementById("XDownROW"+mysplit[5]).innerHTML = mysplit[7];;
				}


                   }
		}
  http.onreadystatechange =null;
		FlagAjax=0;
	 }
	  } else {
	  document.getElementById('XDownROW'+innerItemId).innerHTML = '<img src="anim.gif">';
	  }
}

function useHttpResponseLDRemoveRow() {
   if (http.readyState == 4) {
    if(http.status == 200) {
	var myresponse=http.responseText;
	var mysplit=myresponse.split("%%");
 	var k=0;
                   if (mysplit[0] !="xxx")
		{
                      for (i=mysplit[0];i<=mysplit[1]-1;i++)
			{
k=1+parseInt(i);
               	          document.getElementById("XLDROW"+i).innerHTML = document.getElementById("XLDROW"+k).innerHTML;
			}
               document.getElementById("XLDROW"+mysplit[1]).innerHTML = "  ";
               document.getElementById("XITEMTOTAL").innerHTML = "<strong>"+mysplit[2]+"</strong>";
               document.getElementById("XQTYTOTAL").innerHTML = "<strong>"+mysplit[3]+"</strong>";
               document.getElementById("XTOTAL").innerHTML = "<strong>"+mysplit[4]+"</strong>";
		}
  http.onreadystatechange =null;
		FlagAjax=0;
	 }
	  } else {
//	  document.getElementById('XDownROW'+innerItemId).innerHTML = '<img src="anim.gif">';
	  }
}
function useHttpResponseALRemoveRow() {
   if (http.readyState == 4) {
    if(http.status == 200) {
	var myresponse=http.responseText;
	var mysplit=myresponse.split("%%");
 	var k=0;
                   if (mysplit[0] !="xxx")
		{
                      for (i=mysplit[0];i<=mysplit[1]-1;i++)
			{
k=1+parseInt(i);
               	          document.getElementById("XALROW"+i).innerHTML = document.getElementById("XALROW"+k).innerHTML;
			}
               document.getElementById("XALROW"+mysplit[1]).innerHTML = "  ";
               document.getElementById("XITEMTOTAL").innerHTML = "<strong>"+mysplit[2]+"</strong>";
               document.getElementById("XQTYTOTAL").innerHTML = "<strong>"+mysplit[3]+"</strong>";
               document.getElementById("XTOTAL").innerHTML = "<strong>"+mysplit[4]+"</strong>";
		}
  http.onreadystatechange =null;
		FlagAjax=0;
	 }
	  } else {
//	  document.getElementById('XALROW'+innerItemId).innerHTML = '<img src="anim.gif">';
	  }
}

function useHttpALResponse() {
   if (http.readyState == 4) {
    if(http.status == 200) {
	var myresponse=http.responseText;
		if (innerREGIM==1)
		{
               document.getElementById("XALTXT"+innerItemId).innerHTML = myresponse;
		}
		if (innerREGIM==2)
		{
               document.getElementById("XALID"+innerItemId).innerHTML = myresponse;
		}
		if (innerREGIM==3)
		{
               document.getElementById("XALSIZE"+innerItemId).innerHTML = myresponse;
		}
		if (innerREGIM==7)
		{
	var mysplit=myresponse.split("%%");
               document.getElementById("XALCOST"+innerItemId).innerHTML = mysplit[0];
               document.getElementById("XALPRIC"+innerItemId).innerHTML = mysplit[1];
               document.getElementById("XTOTAL").innerHTML = "<strong>"+mysplit[2]+"</strong>";
		}

  http.onreadystatechange =null;
		FlagAjax=0;
	 }
	  } else {
		if (innerREGIM==1)
		{
		  document.getElementById('XALTXT'+innerItemId).innerHTML = '<img src="anim.gif">';
		}
		if (innerREGIM==2)
		{
		  document.getElementById('XALID'+innerItemId).innerHTML = '<img src="anim.gif">';
		}
		if (innerREGIM==3)
		{
		  document.getElementById('XALSIZE'+innerItemId).innerHTML = '<img src="anim.gif">';
		}
		if (innerREGIM==7)
		{
		  document.getElementById('XALCOST'+innerItemId).innerHTML = '<img src="anim.gif">';
		}

	  }
}

function useHttpResponseALInstallation() {
   if (http.readyState == 4) {
    if(http.status == 200) {
       document.getElementById("XALPROD"+innerItemId).innerHTML = http.responseText;
  http.onreadystatechange =null;
	FlagAjax=0;
 }
  } else {
  document.getElementById('XALPROD'+innerItemId).innerHTML = '<img src="anim.gif">';
  }
}
function useHttpResponseALNotice() {
   if (http.readyState == 4) {
    if(http.status == 200) {
       document.getElementById("XALNOTI"+innerItemId).innerHTML = http.responseText;
  http.onreadystatechange =null;
	FlagAjax=0;
 }
  } else {
  document.getElementById('XALNOTI'+innerItemId).innerHTML = '<img src="anim.gif">';
  }
}
