	var xmlHttp;
	var xmlHttpManual;
	
	var xmlHttpObject;
	var xmlHttpObject1;
    
    var is_ie = (navigator.userAgent.indexOf('MSIE') >= 0) ? 1 : 0;
    var is_ie5 = (navigator.appVersion.indexOf("MSIE 5.5")!=-1) ? 1 : 0;
    var is_opera = ((navigator.userAgent.indexOf("Opera6")!=-1)||(navigator.userAgent.indexOf("Opera/6")!=-1)) ? 1 : 0;
    //netscape, safari, mozilla behave the same???
    var is_netscape = (navigator.userAgent.indexOf('Netscape') >= 0) ? 1 : 0;

    function EditCityAlias(bFlag, bAdd, strCity, strAlias, bManual){
		
        //if (strCity.length > 0){	//VN - remove later
            //Append the name to search for to the requestEditCityURL
            //var url = requestEditCityURL + bFlag + "&bAdd=" + bAdd + "&City=" + strCity + "&Alias=" + strAlias;
            
		    var requestEditCityURL = 'editCityAlias.aspx?bFlag=';

            //alert(strCity);
            var url = "";
            if (strAlias != "")
				url = requestEditCityURL + bFlag + "&bAdd=" + bAdd + "&City=" + strCity + "&Alias=" + strAlias;
			else
				url = requestEditCityURL + bFlag + "&bAdd=" + bAdd + "&City=" + strCity;
				
            if (bManual == "true")
				url += "&bManual=true";
				
			
			//I don't know how to avoid IE chaching. E.g. if you IE has "Every visit to page" settings - all set
			//but if has "Automatically" - we have the following situation:
			// 1. check correctCity checkbox - all is ok - city will be added to DB table
			// 2. uncheck this correctCity checkbox - all is ok - city will be deleted from DB table
			// 3. check this correctCity checkbox AGAIN - nothing happend - it loks like something ???returns??? from server but city is not added to DB table
			// so I'll add into EACH request unique value (to avoid chaching)
			var d = new Date();		
			var date = d.getTime();
			url += "&Time=" + date;
			//alert("date = " + date);
			
            
            //Create the xmlHttp object to use in the request
            //stateChangeHandler will fire when the state has changed, i.e. data is received back
            // This is non-blocking (asynchronous)
            xmlHttp = GetXmlHttpObject(stateChangeHandler);
            
            //Send the xmlHttp get to the specified url
            
            //alert("EditCityAlias url = " + url);
            xmlHttp_Get(xmlHttp, url);
        //}
        //else {
            //Textbox blanked out, clear the results
            //document.getElementById('nameList').innerHTML = '';
        //}
    }

    //stateChangeHandler will fire when the state has changed, i.e. data is received back
    // This is non-blocking (asynchronous)
    function stateChangeHandler()
    {
        //readyState of 4 or 'complete' represents that data has been returned
        if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete'){
            //Gather the results from the callback
            var str = xmlHttp.responseText;

            //Populate the innerHTML of the div with the results
            //document.getElementById('nameList').innerHTML = str;
            
            //alert(str);
            document.getElementById('nameList').innerHTML = str;
            //alert("EditCityAlias answer (nameList) = " + str);
        }
    }

    // XMLHttp send GET request
    function xmlHttp_Get(xmlhttp, url) {
        xmlhttp.open('GET', url, true);
        xmlhttp.send(null);
    }

    // XMLHttp send GET request
    function xmlHttp_GetSynch(xmlhttp, url) {
        xmlhttp.open('GET', url, false);	// synchronous Ajax call
        xmlhttp.send(null);
    }

    function GetXmlHttpObject(handler) {
        var objXmlHttp = null;    //Holds the local xmlHTTP object instance

        //Depending on the browser, try to create the xmlHttp object
        if (is_ie){
            //The object to create depends on version of IE
            //If it isn't ie5, then default to the Msxml2.XMLHTTP object
            var strObjName = (is_ie5) ? 'Microsoft.XMLHTTP' : 'Msxml2.XMLHTTP';
            
            //Attempt to create the object
            try{
                objXmlHttp = new ActiveXObject(strObjName);
                objXmlHttp.onreadystatechange = handler;
            }
            catch(e){
            //Object creation errored
                alert('IE detected, but object could not be created. Verify that active scripting and activeX controls are enabled');
                return;
            }
        }
        else if (is_opera){
            //Opera has some issues with xmlHttp object functionality
            alert('Opera detected. The page may not behave as expected.');
            return;
        }
        else{
            // Mozilla | Netscape | Safari
            objXmlHttp = new XMLHttpRequest();
            objXmlHttp.onload = handler;
            objXmlHttp.onerror = handler;
        }
        
        //Return the instantiated object
        return objXmlHttp;
    }

    function UseValue(strVal){
        document.frmStuff.txtName.value = strVal;
    } 

    function EditManualAlias(bAdd, strAlias)
    {
        var requestURL = 'editManualAlias.aspx';

        var url = "";
		url = requestURL; // + bAdd + "&Alias=" + strAlias;

		//I don't know how to avoid IE chaching. E.g. if you IE has "Every visit to page" settings - all set
		//but if has "Automatically" - we have the following situation:
		// 1. check correctCity checkbox - all is ok - city will be added to DB table
		// 2. uncheck this correctCity checkbox - all is ok - city will be deleted from DB table
		// 3. check this correctCity checkbox AGAIN - nothing happend - it loks like something ???returns??? from server but city is not added to DB table
		// so I'll add into EACH request unique value (to avoid chaching)
		var d = new Date();		
		var date = d.getTime();
		url += "?Time=" + date;
		//alert("date = " + date);
		
		
        
        //Create the xmlHttp object to use in the request
        //stateChangeHandler will fire when the state has changed, i.e. data is received back
        // This is non-blocking (asynchronous)
        xmlHttpManual = GetXmlHttpObject(stateChangeHandlerManualAlias);
        
        //Send the xmlHttpManual get to the specified url
        xmlHttp_Get(xmlHttpManual, url);
    }

    //stateChangeHandler will fire when the state has changed, i.e. data is received back
    // This is non-blocking (asynchronous)
    function stateChangeHandlerManualAlias()
    {
        //readyState of 4 or 'complete' represents that data has been returned
        if (xmlHttpManual.readyState == 4 || xmlHttpManual.readyState == 'complete'){
            //Gather the results from the callback
            var str = xmlHttpManual.responseText;

            //Populate the innerHTML of the div with the results

            document.getElementById('manualList').innerHTML = str;
            //alert("EditManualAlias answer (manualList) = " + str);
        }
    }

	/////////////////////////////////////////////////////////////
    function requestAjax(strUrl, responseHandler, strHandler)
    {
		var  url = strUrl; 

		//I don't know how to avoid IE chaching. 
		// so I'll add into EACH request unique value (to avoid chaching)
		var d = new Date();		
		var date = d.getTime();
		url += "&Time=" + date;

		//I use different objects for different requests 
		//because there were situations where 2 request were sent and when they use the same xmlHttpObject object answers can mix by each other
		//need to think how to do this normally

		if (strHandler == "fillTblSearches")
		//if (responseHandler == "fillTblSearches")
		{
			xmlHttpObject = GetXmlHttpObject(responseHandler);
			xmlHttp_Get(xmlHttpObject, url);
		}
		if (strHandler == "fillSearchParams")
		//if (responseHandler == "fillSearchParams")
		{
			xmlHttpObject1 = GetXmlHttpObject(responseHandler);
			xmlHttp_Get(xmlHttpObject1, url);
		}
		if (strHandler == "synchAjaxCall")
		{
			xmlHttpObject1 = GetXmlHttpObject(responseHandler);	//doesn't matter xmlHttpObject or xmlHttpObject1
			xmlHttp_GetSynch(xmlHttpObject1, url);	// synchronous Ajax call
		}
		
		/////////////////////////////////////////////
    }

    // This is non-blocking (asynchronous)
    function fillTblSearches()
    {
        //readyState of 4 or 'complete' represents that data has been returned
        if (xmlHttpObject.readyState == 4 || xmlHttpObject.readyState == 'complete'){
            //Gather the results from the callback
            var str = xmlHttpObject.responseText;

            //Populate the innerHTML of the div with the results

            document.getElementById('tblSearches').innerHTML = str;
            //alert("EditManualAlias answer (manualList) = " + str);
        }
    }
    
    // This is non-blocking (asynchronous)
    function fillSearchParams()
    {
        //readyState of 4 or 'complete' represents that data has been returned
        if (xmlHttpObject1.readyState == 4 || xmlHttpObject1.readyState == 'complete'){
            //Gather the results from the callback
            var str = xmlHttpObject1.responseText;

            document.getElementById('searchParams').innerHTML = str;
            srchSaver_showSelectedSearchSaverParams();
        }
    }


////////////Google maps section START
	var map = null;
    var geocoder = null;
    var strAjaxAnswer = "";
	//var marker = null;
    
    function showPropOnMap(lblCenterLat, lblCenterLong, lblMls) 
    {
		if (GBrowserIsCompatible()) 
		{
			map = new GMap2(document.getElementById("map_canvas"));
			map.setCenter(new GLatLng(lblCenterLat, lblCenterLong), 12);

			var mapControl = new GMapTypeControl();
			map.addControl(mapControl);
			map.addControl(new GLargeMapControl());			
			map.addControl(mapControl);
			map.addControl(new GOverviewMapControl());			
			
			geocoder = new GClientGeocoder();
		}
		if (geocoder) 
		{
			var marker = new GMarker(new GLatLng(lblCenterLat, lblCenterLong));
		
	    	//var requestURL = 'googleMapsInfoWindow.aspx?mls=' + lblMls;
	    	var requestURL = 'googleMapsInfoWindow.aspx?pid=' + lblMls;
			requestAjax(requestURL, fillInfoWindow, "synchAjaxCall"); //VN. Jan 2009 - need to create something more generic
			var strResp = strAjaxAnswer;
			//alert("strResp = " + strResp);
			
			map.addOverlay(createMarker(marker, strResp, lblMls));
		}
    }

    function createMarker(marker, strResponse, prop_mls) 
    {
		GEvent.addListener(marker, "click", function() {
			marker.openInfoWindowHtml(strResponse);
		});
		
	  return marker;
	}	
	
    function fillInfoWindow()
    {
        //readyState of 4 or 'complete' represents that data has been returned
        if (xmlHttpObject1.readyState == 4 || xmlHttpObject1.readyState == 'complete')
        {
            strAjaxAnswer = xmlHttpObject1.responseText;
        }
    }
////////////Google maps section ENDz	





