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 getSubCat(cat_id) {		
	var strURL="findSubCategory.php?cat_id="+cat_id;
	var req = getXMLHTTP();
	if (req) {
	req.onreadystatechange = function() {
			if (req.readyState == 4) {
				// only if "OK"
				if (req.status == 200) {						
					document.getElementById('SubCatdiv').innerHTML=req.responseText;						
				} /*else {
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}*/
			}				
		}			
		req.open("GET", strURL, true);
		req.send(null);
	}
}

function getMarchant(cat_id) {		
	var strURL="findMarchent.php?cat_id="+cat_id;
	var req = getXMLHTTP();
	if (req) {
	req.onreadystatechange = function() {
			if (req.readyState == 4) {
				// only if "OK"
				if (req.status == 200) {						
					document.getElementById('Marchantdiv').innerHTML=req.responseText;						
				} /*else {
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}*/
			}				
		}			
		req.open("GET", strURL, true);
		req.send(null);
	}
}

function getSubMenu(cat_id,sr) {		
	var strURL="findsub_menu.php?cat_id="+cat_id+"&sr="+sr;
	var req = getXMLHTTP();
	if (req) {
	req.onreadystatechange = function() {
			if (req.readyState == 4) {
				// only if "OK"
				if (req.status == 200) {						
					document.getElementById('subMenu').innerHTML=req.responseText;						
				} /*else {
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}*/
			}				
		}			
		req.open("GET", strURL, true);
		req.send(null);
	}
}

function getMoreOffers(cmpny_id,sr) {		
	var strURL="findMoreOffer.php?cmpny_id="+cmpny_id;
	var req = getXMLHTTP();
	if (req) {
	req.onreadystatechange = function() {
		if (req.readyState == 4) {
			// only if "OK"
			if (req.status == 200) {						
				document.getElementById('more_offers_'+sr).innerHTML=req.responseText;						
			} /*else {
				alert("There was a problem while using XMLHTTP:\n" + req.statusText);
			}*/
		}				
	}			
	req.open("GET", strURL, true);
	req.send(null);
	}
}

//function to process an XMLHttpRequest
function process_ajax()
{
	var strURL="changedeal.php";
	var req = getXMLHTTP();
	if (req) {
		req.onreadystatechange = function() {
		if (req.readyState == 4) {
			// only if "OK"
			if (req.status == 200) {						
				document.getElementById('changedeal').innerHTML=req.responseText;						
			}
		}				
	}			
	req.open("GET", strURL, true);
	req.send(null);
	}	
}

function getLocation(city_id,i) {
	//alert(city_id);
	var strURL="findLocation.php?city_id="+city_id+"&pos="+i;
	var req = getXMLHTTP();
	if (req) {
	req.onreadystatechange = function() {
		if (req.readyState == 4) {
			// only if "OK"
			if (req.status == 200) {						
				document.getElementById('locationDiv_'+i).innerHTML=req.responseText;
			} /*else {
				alert("There was a problem while using XMLHTTP:\n" + req.statusText);
			}*/
		}				
	}			
	req.open("GET", strURL, true);
	req.send(null);
	}
}

function getRegLocation(city_id) {		
	var strURL="findRegLocation.php?city_id="+city_id;
	var req = getXMLHTTP();
	if (req) {
	req.onreadystatechange = function() {
			if (req.readyState == 4) {
				// only if "OK"
				if (req.status == 200) {						
					document.getElementById('locationDiv').innerHTML=req.responseText;						
				} /*else {
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}*/
			}				
		}			
		req.open("GET", strURL, true);
		req.send(null);
	}
}
