// JavaScript Document
var xmlHttp

function showcart(start,qty,stockQty)
{

	document.getElementById("cartdiv").style.display = "";
	document.getElementById("cartbefore").style.display = "";
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Browser does not support HTTP Request")
	return
	} 
	var url3="cart_ajax.php";
	url3=url3+"?start="+start+"&qty="+qty+"&stockQty="+stockQty;
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url3,true)
	xmlHttp.send(null)
} 



function stateChanged() 
{ 

	if(xmlHttp.readyState==1)
	{
	document.getElementById("loadingtxt").innerHTML="<strong>Loading Your Cart Please Wait...</strong>"	;
	document.getElementById("loadingimg").innerHTML="<strong><img src='images/ajax-loader.gif' border='0'></strong>";
	
	}
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
				{
				document.getElementById("cartbefore").style.display = "none";
				document.getElementById("cart").style.display = "block";
				document.getElementById("cart").innerHTML=xmlHttp.responseText;
				document.getElementById("loadingtxt").innerHTML="";
				document.getElementById("loadingimg").innerHTML="";
				}
				
}

function GetXmlHttpObject()
{
var xmlHttp=null;

try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}


// JavaScript Document
function showNavigationMenu(showMenu, hideMenu, showImage, hideImage) {
	document.getElementById(showMenu).style.display ='';
	document.getElementById(hideMenu).style.display ='none';
	document.getElementById(showImage).style.display ='';
	document.getElementById(hideImage).style.display ='none';
}

function showTitleTooltips(divId) {
	document.getElementById(divId).style.display='';
}


function Paging(start)
{
showcart(start);
}

function hidecart()
{
document.getElementById("cart").style.display = "none";
document.getElementById("cartdiv").style.display = "none";
}




function showTechSpecs(showDiv, showTab, id) { 
	for (var i=1; i <= 3; i++)
	{
		
		if(i == id) {
			document.getElementById(showDiv+"_"+i).style.display ='';
			document.getElementById(showTab+"_"+i).className ='active';
		} else {	
			document.getElementById(showDiv+"_"+i).style.display ='none';
			document.getElementById(showTab+"_"+i).className ='';
		}	
	}
	
}

// EVENT HANDLERS
function pressButton(btName, btSrc) { 
 if (document.images)
  eval('document.'+btName+'.src='+btSrc+'_down.src');
}

function releaseButton(btName, btSrc) {
 if (document.images)
  eval('document.'+btName+'.src='+btSrc+'_up.src');
}


//Create a boolean variable to check for a valid Internet Explorer instance.
var xmlhttpC = false;
//Check if we are using IE.
try {
//If the Javascript version is greater than 5.
xmlhttpC = new ActiveXObject("Msxml2.XMLHTTP");
//alert ("You are using Microsoft Internet Explorer.");
} catch (e) {
//If not, then use the older active x object.
try {
//If we are using Internet Explorer.
xmlhttpC = new ActiveXObject("Microsoft.XMLHTTP");
//alert ("You are using Microsoft Internet Explorer");
} catch (E) {
//Else we must be using a non-IE browser.
xmlhttpC = false;
}
}
//If we are using a non-IE browser, create a javascript instance of the object.
if (!xmlhttpC && typeof XMLHttpRequest != 'undefined') {
xmlhttpC = new XMLHttpRequest();
//alert ("You are not using Microsoft Internet Explorer");
}
function updateCart(serverPage, id, formField) {
	//var obj = document.getElementById(objID);
	xmlhttpC.open("GET", serverPage);	
	xmlhttpC.onreadystatechange = function() {
		if (xmlhttpC.readyState==4 || xmlhttpC.readyState=="complete"){
			var allData = xmlhttpC.responseText.split("~");
			formField.value = allData[0];
			document.getElementById("price_"+id).innerHTML = allData[1];
			document.getElementById("subTotal").innerHTML  = allData[2];
			document.getElementById("vatCharge").innerHTML = allData[3];
			document.getElementById("exVat").innerHTML     = allData[4];
			document.getElementById("cartTotal").innerHTML = allData[2];
			document.getElementById("cartTotals").innerHTML = allData[2];
		}
	}
	xmlhttpC.send(null);
}

function changeQty(formField, operation, id) {
	var qtyValue = document.getElementById("cartvalue").value;
	updateCart('addtocart.php?action=ajaxupdate&qty='+qtyValue+'&id='+id, id, formField);
}

