var xmlhttp;

function addToCart(prodid,quantity,price,action)
{
	
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  }
var loadingdiv = document.getElementById('loading');
loadingdiv.style.display = "block";
var url="http://computerbits.ie/cart.php";
var url = "http://qaserver/computerbits/cart.php";
url = "http://";
var hostname = window.location.hostname;
url = url+hostname;
url = url + "/cart.php";
url=url+"?prodid="+prodid+"&quantity="+quantity+"&price="+price+"&action="+action;
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function getCode()
{
	setTimeout("getCode1()",2000);;

}

function getCode1()
{
		xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  }
var url="../includes/captcha-secureimage/captcha-secureimage/securimage_get.php";
url=url+"?sid="+Math.random();
xmlhttp.onreadystatechange=stateChanged1;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function vatonoff(hostpath)
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  }
 catid = document.getElementById('catid').value;
var url=hostpath+"vatonoff.php?catid="+catid;
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=stateChanged2;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function stateChanged2()
{
if (xmlhttp.readyState==4)
	{
	
		
			response = xmlhttp.responseText;
			if(response != '')
			{
			arr = response.split("---");
			path = arr[0];
			data = arr[1];
			
			//alert(data);
			if(data != '')
			{
			document.getElementById('frontpage').innerHTML = data;
			}
			}
			document.getElementById('imgvatonoff').src = path;
			
			
		
	}
}

function newsletter(val)
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  }
var url="newsletter.php?val="+val+"&sid="+Math.random();
xmlhttp.onreadystatechange=stateChanged3;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);

}

function getsubcat(val,subcatid)
{
	xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  }
var url="getSubCat.php?val="+val+"&subcat="+subcatid+"&sid="+Math.random();
xmlhttp.onreadystatechange=stateChanged4;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);	
xmlhttp.close;
}

/* Created By VRS */
function loadSubcat(val,subcatid,ssc1)
{
	xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  }
var url="getSubCat.php?val="+val+"&subcat="+subcatid+"&sid="+Math.random();
xmlhttp.onreadystatechange=stateChanged4;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);	

xmlhttp1=GetXmlHttpObject();
if (xmlhttp1==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  }

var url1="getSubSubCat.php?val="+subcatid+"&subcat="+ssc1+"&sid="+Math.random();
xmlhttp1.onreadystatechange=stateChanged07;
xmlhttp1.open("GET",url1,true);

xmlhttp1.send(null);	


}
/* End */

function getsubsubcat(val,subcatid)
{
	xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  }
var url="getSubSubCat.php?val="+val+"&subcat="+subcatid+"&sid="+Math.random();
xmlhttp.onreadystatechange=stateChanged7;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);	
}

function editCust(val,custid,shipname,shiplname,shipadd,fname,lname,address)
{
	//alert("hi");
	xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  }
var url="editCust.php?email="+val+"&custid="+custid+"&shipname="+shipname+"&shiplname="+shiplname+"&shipadd="+shipadd+"&fname="+fname+"&lname="+lname+"&address="+address+"&sid="+Math.random();
//alert(url);
xmlhttp.onreadystatechange=stateChanged5;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);	
}

function getCat(catid,cattype,siteurl)
{
	xmlhttp=GetXmlHttpObject();
//alert(siteurl);
if (xmlhttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  }
  document.getElementById('catid').value = catid;
var url=siteurl+"getcat.php?catid="+catid+"&cattype="+cattype+"&sid="+Math.random();
//alert(url);
xmlhttp.onreadystatechange=stateChanged6;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);	
}

function stateChanged6()
{
if (xmlhttp.readyState==4)
	{
			//alert(xmlhttp.responseText);
		document.getElementById('frontpage').innerHTML = (xmlhttp.responseText);
	}
}



function stateChanged()
{
if (xmlhttp.readyState==4)
{
	if (xmlhttp.readyState==4)
	{
		//document.getElementById('testimonial').innerHTML = xmlhttp.responseText;
		//alert(xmlhttp.responseText);
				
		setTimeout("loadloader()",3000);
		
		
		
	}
	
}

}
function loadloader()
{
		var loadingdiv = document.getElementById('loading');
		loadingdiv.style.display = "none";
		
		var	response = xmlhttp.responseXML.documentElement;
		//alert(response.getElementsByTagName("vatamount")[0].firstChild.data);
		//alert(response.getElementsByTagName("prodcount")[0].firstChild.data);
		document.getElementById('prodcount').innerHTML = response.getElementsByTagName("prodcount")[0].firstChild.data;
		
		document.getElementById('totalamount').innerHTML = response.getElementsByTagName("totalamount")[0].firstChild.data;
		
		document.getElementById('shipping').value = response.getElementsByTagName("shipping")[0].firstChild.data;
		
		document.getElementById('vatamount').value = response.getElementsByTagName("vatamount")[0].firstChild.data;
		//alert(response.getElementsByTagName("vatamount")[0].firstChild.data);
		var action = response.getElementsByTagName("action")[0].firstChild.data;
		if(action == 'view')
		{
				document.getElementById('carttotal').value = response.getElementsByTagName("totalamount")[0].firstChild.data;
		}
	//	alert("hi");
}


function stateChanged1()
{
if (xmlhttp.readyState==4)
	{
		//document.getElementById('md5').value = xmlhttp.responseText;
		var	response = xmlhttp.responseXML.documentElement;
		document.getElementById('md5').value = response.getElementsByTagName("md5")[0].firstChild.data;
		document.getElementById('random').value = response.getElementsByTagName("random")[0].firstChild.data;
		document.getElementById('codeval').value = response.getElementsByTagName("code")[0].firstChild.data;
		
	}
}



function stateChanged3()
{
if (xmlhttp.readyState==4)
	{
		document.getElementById('msg').innerHTML = xmlhttp.responseText;
		
	}
}

function stateChanged4()
{
if (xmlhttp.readyState==4)
	{
			document.getElementById('subcat').innerHTML = xmlhttp.responseText;
		
	}
}

function stateChanged5()
{
if (xmlhttp.readyState==4)
	{
		//alert(xmlhttp.responseText);
		document.getElementById('msg').innerHTML = "Record updated successfully";
		location.href = "customerInfo.php?cid="+xmlhttp.responseText;
	}
}


function stateChanged7()
{
if (xmlhttp.readyState==4)
	{
			document.getElementById('subsubcat').innerHTML = xmlhttp.responseText;
		
	}
}

function stateChanged07()
{
if (xmlhttp.readyState==4)
	{
			document.getElementById('subsubcat').innerHTML = xmlhttp1.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;
}

