function Cart_AJAX_action(prdid,efmac,efwin,esmac,eswin,egmac,egwin,allmac,allwin,downCom,SendByPost,appleqty,windowsqty,action,progressRegion,booktype)
{
	var httpRequest = CreateXMLHTTPRequest();		
	httpRequest.onreadystatechange = function(){
 
	if(httpRequest.readyState == 4 )
	{
		 
		//document.getElementById('3rdLevel').innerHTML = html;
			  
				var dataArray = httpRequest.responseText.split("::");
				  
				if (document.getElementById('itemCounter') != null)
				{
					document.getElementById('itemCounter').innerHTML = dataArray[0] +" "+ "ITEMS";
					document.getElementById('totalCost').innerHTML = "&pound;"+dataArray[1];
				}
				
				if (document.getElementById('itemCounterS') != null && document.getElementById('totalCostS'))
				{
					document.getElementById('itemCounterS').innerHTML = dataArray[0];
					document.getElementById('totalCostS').innerHTML = "$" + dataArray[1];
				}
			 
			 	if(action == 'R' )
				{
					document.form2.submit();
				}
						  
				TaskCompletionDiv(progressRegion); //document.getElementById(progressRegion).innerHTML = "Cart updated.";	
				
		}
	else{
	 	 ShowProgressDiv(progressRegion);//document.getElementById(progressRegion).innerHTML = "<img src='images/indicator.gif' />";			
	}
	
	}	 
	var completePath = 'ajax-cart-action.php?id=' + prdid 
	+ '&efmac='+ efmac + '&efwin=' + efwin 
	+ '&esmac='+ esmac + '&eswin='+ eswin
	+ '&egmac='+ egmac + '&egwin='+ egwin
	+ '&allmac='+ allmac + '&allwin='+ allwin	
	+ '&downCom='+ downCom + '&SendByPost='+ SendByPost	
	+ '&appleqty='+ appleqty + '&windowsqty='+ windowsqty	
	+ '&booktype='+ booktype + '&action='+ action;
	
	httpRequest.open('GET',completePath,true);
	httpRequest.send(null);	
	
}

function Customer_Existance(loginId, ctrlId, messageRegion, progressRegion)
{
	var httpRequest = CreateXMLHTTPRequest();		
	
	httpRequest.onreadystatechange = function(){
		
	if(httpRequest.readyState == 4 ){

			document.getElementById(progressRegion).innerHTML = "";
			if (httpRequest.responseText == "true")
			{
				document.getElementById(messageRegion).innerHTML = "Login Id already exist.";
				document.getElementById(ctrlId).value = "";
				document.getElementById(ctrlId).focus();
			}
			
		}
		else
			document.getElementById(progressRegion).innerHTML = "<img src='images/indicator.gif' />";			
	}
	
	var completePath = 'ajax-customer-existance.php?loginId=' + loginId;
	httpRequest.open('GET', completePath , true);
	httpRequest.send(null);	
	
}

function Customer_Existance_Validate(loginId, ctrlId, messageRegion, progressRegion)
{
	var httpRequest = CreateXMLHTTPRequest();		
	
	httpRequest.onreadystatechange = function(){
		
	if(httpRequest.readyState == 4 ){

			document.getElementById(messageRegion).value = httpRequest.responseText;
			if (document.getElementById(messageRegion).value)
			{
				document.getElementById(progressRegion).innerHTML = "Login Id already exist."
				//alert("Login Id already exist.");
			}
		}
	}
	
	var completePath = 'ajax-customer-existance.php?loginId=' + loginId;
	httpRequest.open('GET', completePath , true);
	httpRequest.send(null);	
	
}

function CreateXMLHTTPRequest()
{
	
	var httpRequest;
	
	try{
		httpRequest = new XMLHttpRequest();
	}
	catch(e){

		try{
			httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e){

			try{
				httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e){
				alert ('No AJAX supported browser detected.');
				return false;
			}
		}
		
	}
	
	return httpRequest;
}


function CartEmpty()
{
 
	Cart_AJAX_action(0,0,0,0,0,0,0,0,0,0,0,0,0,'E',0,0);
	window.location.href = "index.php";

}

function LoadSubCategory(ctgId, scgId, ctrlId)
{
	
	var httpRequest = CreateXMLHTTPRequest();		
	
	httpRequest.onreadystatechange = function(){
		
	if(httpRequest.readyState == 4 ){

			document.getElementById(ctrlId).innerHTML = httpRequest.responseText;
		
		}
	}
	
	var completePath = '../products/ajax-load-subcategory.php?ctgId=' + ctgId + '&scgId=' + scgId;
	httpRequest.open('GET', completePath , true);
	httpRequest.send(null);	
}


function LoadBrands(scgId, brdId, ctrlId)
{
	var httpRequest = CreateXMLHTTPRequest();		
	
	httpRequest.onreadystatechange = function(){
		
	if(httpRequest.readyState == 4 ){

			document.getElementById(ctrlId).innerHTML = httpRequest.responseText;
		
		}
	}
	
	var completePath = '../products/ajax-load-scbrand.php?scgId=' + scgId + '&brdId=' + brdId;
	httpRequest.open('GET', completePath , true);
	httpRequest.send(null);	
}


function ShowProgressDiv(divId)
{
	if(divId != 0)
	{
	var obj1 = document.getElementById(divId);
	obj1.style.visibility = 'visible';
	obj1.style.display = 'block';
	}
}

function TaskCompletionDiv(divId)
{
	if(divId != 0)
	{
	
	var obj1 = document.getElementById(divId);
	obj1.innerHTML = '<table align="left"><tr><td align="right">' + 
	'<a href="javascript:void(0)" onclick="HideProgressDiv()"><img src="images/close.png" border="0" /></a></td></tr><tr><td class="sub_total_TXT">Cart has been updated.</td></tr></table>';
	}
}
function HideProgressDiv()
{
	var obj1 = document.getElementById('msglayer');
	obj1.style.visibility = 'hidden';
	obj1.style.display = 'none';
	
}

function position(ctrl)
{
	 
		 
	var pos = Position.get(ctrl);
	Position.set('msglayer',pos);
}


function LoadSubCategorySearch(ctgId, scgId, ctrlId)
{
	
	var httpRequest = CreateXMLHTTPRequest();		
	
	httpRequest.onreadystatechange = function(){
		
	if(httpRequest.readyState == 4 ){

			document.getElementById(ctrlId).innerHTML = httpRequest.responseText;
		
		}
	}
	
	var completePath = '../products/ajax-load-ssubcategory.php?ctgId=' + ctgId + '&scgId=' + scgId;
	httpRequest.open('GET', completePath , true);
	httpRequest.send(null);	
}


function LoadBrandsSearch(scgId, brdId, ctrlId)
{
	var httpRequest = CreateXMLHTTPRequest();		
	
	httpRequest.onreadystatechange = function(){
		
	if(httpRequest.readyState == 4 ){

			document.getElementById(ctrlId).innerHTML = httpRequest.responseText;
		
		}
	}
	
	var completePath = '../products/ajax-load-sscbrand.php?scgId=' + scgId + '&brdId=' + brdId;
	httpRequest.open('GET', completePath , true);
	httpRequest.send(null);	
}


function UpdateSelectedDiv(divId, level)
{
	var httpRequest = CreateXMLHTTPRequest();		
	//alert(divId);
	httpRequest.onreadystatechange = function(){
		
		if(httpRequest.readyState == 4 ){

			//document.getElementById(ctrlId).innerHTML = httpRequest.responseText;
		
		}
	}
	
	var completePath = 'ajax-menu-action.php?divId=' + divId + "&level=" + level;
	httpRequest.open('GET', completePath , true);
	httpRequest.send(null);	
}