// The path of where the PHP script
var phpscript = '/includes_dmg/ajax.php?f=';

// Create the Divtag Handler -- Mainly an IE 6 Fix 
var divhandler = new handleDivTag(null); 
var timestamp = new Date().getTime();

// Function for making the AJAX object
function createRequestObject() {
   var request;
	// Firefox, Safari, Opera... 
	if(window.XMLHttpRequest){ 
		request = new XMLHttpRequest();
	// Internet Explorer 5+ 
   	} else if(window.ActiveXObject) {
      	request = new ActiveXObject("Msxml2.XMLHTTP");
	// There is an error or an old browser is being used.
	} else if(window.ActiveXObject) {
      	request = new ActiveXObject("Microsoft.XMLHTTP");
	// There is an error or an old browser is being used.
	}else {
		request = null;
		alert('Problem creating the XMLHttpRequest object');
   	}
   	return request;
} 

// Creating the divtag object
function handleDivTag(divtag) { 
   var divtag; 
   return divtag; 
} 

// Make the XMLHttpRequest object 
var http = createRequestObject(); 


// Main AJAX request function, called via event handlers
function sendRequest(act, value1, value2, value3, divtag) { 
	// Open PHP script for requests and send values via GET
   http.open('get', phpscript+act+'&value1='+escape(value1)+'&value2='+escape(value2)+'&value3='+escape(value3)+'&timestamp='+timestamp); 
   // When ready, handle the response
   http.onreadystatechange = handleResponse;
   // Pass the divtag through
   divhandler.divtag = divtag;
   // Send nothing (GET has already passed values)
   http.send(null);
}

function handleResponse() { 
	// Checking if server is ready
	if(http.readyState == 4){
		if(http.status == 200){ 
			var response = http.responseText; 
			if(response == 'No Popup Needed!!')
			{
				ligthenPage();
/*			}else if(divhandler.divtag == 'conWarn' && response != 'No Popup Needed!!'){
				enableOptions(response)
*/			}else{
				document.getElementById(divhandler.divtag).innerHTML = response;
			}
		}else{ 
			alert("ERROR! Request status is "+ http.status); 
		}
	}
}

function poupmap(objFrm){
	var strLatitude = '';
	var strLongitude = '';
	if(document.getElementById('strLatitude')){
		strLatitude = document.getElementById('strLatitude').value;	
	}
	if(document.getElementById('strLongitude')){
		strLongitude = document.getElementById('strLongitude').value;	
	}
	//alert('strLatitude='+strLatitude);
	window.open ("directory_db/listing_map.php?strLatitude="+strLatitude+"&strLongitude="+strLongitude, "map","status=1,resizable=1,width=610,height=600");	
}

function getList(strCase, objSel, objSel2, strDiv){
	
	var myStr = '';
	for(i=0; i<objSel.options.length; i++)
	{
		if(objSel[i].selected)
		{
			myStr += '||' + objSel[i].value+'||,';
		}
	}
	
	var myStr2 = '';
	if(objSel2){
		for(i=0; i<objSel2.options.length; i++)
		{
			if(objSel2[i].selected)
			{
				myStr2 += '||' + objSel2[i].value+'||,';
			}
		}		
	}
	//alert(myStr);
	sendRequest(strCase, myStr, myStr2, '', strDiv);
}