function getXMLHTTP() { //fuction to return the xml http object
		var xmlhttp=false;	
		try{
			xmlhttp=new XMLHttpRequest();
		}
		catch(e)	{		
			try{			
				xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e){
				try{
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
				}
				catch(e1){
					xmlhttp=false;
				}
			}
		}
		return xmlhttp;
	}
	
	function getData(strURL,div) {	
	
	var data = strURL.split('&');
	var data2 = data[0].split('=');
		var req = getXMLHTTP();
		if (req) {
			// show loader image when request comes from the page 
			req.onreadystatechange = function() 
			{
				if (req.readyState == 4) {
					// only if "OK"
					
					if (req.status == 200) {	
						
						document.getElementById(div).innerHTML=req.responseText;	
						//alert(req.responseText);
						
						 if(document.getElementById('txtQuantity'+data2[1]))
							 getData('get_total_price.php','grandTotal');
						if(document.getElementById('txtQuantity'+data2[1]))
						 {	
							document.getElementById('txtQuantity'+data2[1]).focus();
						 }	 
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}
				else
				 {
					 document.getElementById(div).innerHTML="<div align='center' valign='middle' ><img src='http://www.mouthwatchers.com/images/loader.gif' border='0' height='20' width='20'></div>";
				 }
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}
	}
	
function trimspaces(str)
{
	while((str.indexOf(' ',0) == 0) && (str.length > 1))
	{
		str = str.substring(1, str.length);
	}
	while((str.lastIndexOf(' ') == (str.length - 1) && (str.length > 1)))
	{
		str = str.substring(0,(str.length - 1));
	}
	if((str.indexOf(' ',0) == 0) && (str.length == 1)) str = '';
	return str;
}

function returnSingleValueByAjax(strURL)
{  
	var aRequest;
	// Mozilla/Safari
	if (window.XMLHttpRequest)	{
		aRequest= new XMLHttpRequest();
	}
	// IE
	else if (window.ActiveXObject)	{
		aRequest = new ActiveXObject("Microsoft.XMLHTTP");
	}
	aRequest.open("GET", strURL, false);
	 aRequest.send(null);
	 return  trimspaces(aRequest.responseText.replace(/[\r\n]+/g, ""));	
}

function returnResponseByAjax(strURL)
{  //alert(strURL);
	var aRequest;
	// Mozilla/Safari
	if (window.XMLHttpRequest)	{
		aRequest= new XMLHttpRequest();
	}
	// IE
	else if (window.ActiveXObject)	{
		aRequest = new ActiveXObject("Microsoft.XMLHTTP");
	}
	aRequest.open("GET", strURL, false);
	 aRequest.send(null);
}
