function EventEndCPan(){
   //If the timer is set, clear it and reset it

   if (endPanTimer != null)   {
      window.clearTimeout(endPanTimer);
   }
   endPanTimer = window.setTimeout(HandleEndPan, END_PAN_TIMER_DELAY);
} 


function HandleEndPan(){

	endPanTimer = null; 
	myzoomlevel  = map.GetZoomLevel();
	thismapcenter = map.GetCenter();
	icon = "searchlist";
	//getPropInfo();
	submitSearch(document.sidesearch);
} 


function updateSearch(){

	map.DeleteAllShapes();
	//getFrmparameters(url, icon);
	submitSearch(document.sidesearch);
	}

	// Call the Web service method to get the lat/longs 

function stopMappan(){
	
	map.DetachEvent("onendpan",EventEndCPan);
	map.DetachEvent("onendzoom", EventEndCPan);

	}


var isBusy;
var mapPoints;
var totalcnt;

function CallToGetList (url, icon){
//	alert(url)
	var  xmlhttp=getHTTPObject();	
	xmlhttp.onreadystatechange=function(){
		if (xmlhttp.readyState == 4) {
        // only if "OK"
        if (xmlhttp.status == 200) {
		 isBusy=false;
			SucceededCallback(xmlhttp.responseText, icon, url);
	
		} else {
            alert("There was a problem retrieving the lisitngs:\n" +    xmlhttp.statusText);
			isBusy=false;
        }
 		}
	};



  	xmlhttp.open("GET",url,true);
  	xmlhttp.send(null);
	isBusy=true;
}

//added function:
//do not touch below
 function getHTTPObject() {
  var xmlhttp;
    try {
      xmlhttp = new XMLHttpRequest();
    } catch (e) {
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
  
  return xmlhttp;
}


// This is the callback function that 
// processes the value returned by the Web service.
function SucceededCallback(result, icon, url){

    var points = result;
	var propIcon = "/images/icons/smbluePointer.gif";
	//mapPoints = new Array(1);
	if(points.length > 0 ) {
		
        var latLongTokens = points.split('|');
        var veLatLongs = new Array(latLongTokens.length -1);
		
        //alert(latLongTokens.length);
        var centerLatLong;
		totalcnt = latLongTokens[0].split(',')[1];
		if(totalcnt >0){
			mapPoints = new Array(totalcnt);
		}
		
		if(totalcnt < 202){
			
		//var stoppanning ;	
        for(index = 1; index <= veLatLongs.length-1; index++)   {
		
			var latitude = latLongTokens[index].split('~')[0];
			var longitude = latLongTokens[index].split('~')[1];
			var address  = latLongTokens[index].split('~')[2];
			var mlnum  = latLongTokens[index].split('~')[3];
			var pid  = latLongTokens[index].split('~')[4];
			var pPrice  = latLongTokens[index].split('~')[5];
			var propclass = latLongTokens[index].split('~')[6];
			var bed = latLongTokens[index].split('~')[7];
			var bath  = latLongTokens[index].split('~')[8];
			
			var sqft = latLongTokens[index].split('~')[9];
			var sqftsrc = latLongTokens[index].split('~')[10];
			
			var PropStatus  = latLongTokens[index].split('~')[11];
			var city  = latLongTokens[index].split('~')[12];
			var zip  = latLongTokens[index].split('~')[13];
			var image  = latLongTokens[index].split('~')[14];
			var soldRange  = latLongTokens[index].split('~')[15];
			var state = "TX";
			//number formating
			if(PropStatus != 'Closed'){
				pPrice = '$'+new NumberFormat(pPrice).toFormatted();
			}else
				pPrice = '$'+soldRange;
				
			//alert(pPrice);
			
			
			sqft = new NumberFormat(sqft).toFormatted();
			detailurl = 'http://search.har.com/engine/';
			
			if(PropStatus == 'Closed'){
				//pPrice =soldRange;
				detailurl = 'http://www.har.com/HomeValue/';
				propIcon = "/images/icons/redPointerSmall.gif";
			}
			
			if(pid ==7){
				propIcon = "/images/icons/smlease.gif";
				}

				
			if (index == 1 && (icon =='singlepoint'|| icon =='searchwithloc' )){
			   	centerLatLong = new VELatLong (latitude, longitude);
				map.SetCenterAndZoom(centerLatLong, myzoomlevel);
				thismapcenter = map.GetCenter();
			
			}
			

			
			veLatLongs[index] = new VELatLong(latitude, longitude);
			if( (pid != 6 && pid !=2) || PropStatus == 'Closed'){
							
				propString = "<div style='width:200px'><a href='"+detailurl+address.replace(/ /g, '-')+"-"+city.replace(/ /g, '-')+"-"+zip+"_HAR"+mlnum+".htm' target='new'><img src='"+image+"' width='190' height='155px' border='0'></a><div  id='propDetailDiv' style='font-size:10px; background-color:ffffff;width:200px'>"+"<span class='mdBlueBold'>"+address+"<br></span> "+city+', '+zip+"<br>"+pPrice+" (" +propclass+")- " + PropStatus 

				if(bed != '')
					propString = propString +"<br>"+bed + " Bed";
				if(bath != '')
					propString = propString +" / "+bath + " Bath";
			
				
				if(sqft != '')
					propString = propString +"<br>SQFT: "+sqft;
				if(sqftsrc != '')
					propString = propString +sqftsrc;
			//address = address.replace(' ', '-');

				propString = propString +"<br><a href='"+detailurl+address.replace(/ /g, '-')+"-"+city.replace(/ /g, '-')+"-"+zip+"_HAR"+mlnum+".htm' target='new'><img src='/images/icons/btnDetails.gif' border='0'></a>"

		}
		if((pid ==6 || pid== 2) &&  PropStatus != 'Closed'){
			propString = "<div style='width:200px'><a href='"+detailurl+address.replace(/ /g, '-')+"-"+city.replace(/ /g, '-')+"-"+zip+"_HAR"+mlnum+".htm' target='new'><img src='"+image+"' width='190' height='155px' border='0'></a>"
			
			propString += "<iframe src='multiLists.cfm?mlnum="+mlnum + "' width='200' height='200px' scrolling='auto' frameborder='0' marginwidth='0' marginheight='0'></iframe>"
		
		}

propString = propString +"<br>Drive Direction <a href='#' onclick=\"javascript:showDriveDiv('drivedivfrom');\">From Here</a>  <a href='#' onclick=\"javascript:showDriveDiv('drivedivto');\">To Here</a></div></div>";
propString = propString +"<div>";



var driveDivHTMLfrom = "";
driveDivHTMLfrom = driveDivHTMLfrom +"<div id='drivedivfrom' style='display:none;width:200px;backgroudcolor:ffffff;font-size:10px;font-family:Verdana'><input style='font-size:10px;font-family:Arial' id='txtFrom' type='text' name='txtFrom' value=' "+address+','+city+','+zip+"' size='40'>"
driveDivHTMLfrom = driveDivHTMLfrom +"<br>  To:<INPUT style='font-size:10px;font-family:Arial' id='fromtxtTo' type='text' name='fromtxtTo' value='' size='40'>"

driveDivHTMLfrom = driveDivHTMLfrom +"<br><INPUT  style='font-size:10px;font-family:Arial' id='find' type='button' value='Find' onclick=\"FindLoc('from');\" ></div>"

var driveDivHTMLto = "";
driveDivHTMLto = driveDivHTMLto +"<div id='drivedivto' style='display:none;width:200px;backgroudcolor:ffffff;font-size:10px;font-family:Verdana'><input style='font-size:10px;font-family:Arial' id='totxtFrom' type='text' name='totxtFrom' value='' size='40'>"
driveDivHTMLto = driveDivHTMLto +"<br>  To:<INPUT style='font-size:10px;font-family:Arial' id='txtTo' type='text' name='txtTo' value=' "+address+','+city+','+zip+"' size='40'>"

driveDivHTMLto = driveDivHTMLto +"<br><INPUT  style='font-size:10px;font-family:Arial' id='find' type='button' value='Find' onclick=\"FindLoc('to');\" ></div>"

propString = propString +driveDivHTMLto + driveDivHTMLfrom;

//var myPin = new VEPushpin(mlnum, veLatLongs[index], propIcon, 'Property Information', propString, 'iconStyle',    'titleSytle',  'detailsStyle');

var shape = new VEShape(VEShapeType.Pushpin, veLatLongs[index]);

         //Set the icon
         shape.SetCustomIcon(propIcon);
         
         //Set the info box
       //  map.ClearInfoBoxStyles();
	   if(pid != 6 && pid !=2){
         shape.SetTitle("<font face='Arial, Helvetica, sans-serif' size='1px' color='666666'>Property Information</font>");
	   }
	   
	   if(pid == 6 || pid ==2){
		     shape.SetTitle("<span class='mdBlueBold'>"+address+"</span>");

		   }
         shape.SetDescription(propString);
  
         //Add the shape the the map
		try{

			 map.AddShape(shape);
		
		}
		catch(e){}
		
		    var currentMarkerID = shape.GetID();
		
		mapPoints[index-1] ={"latitude": latitude,"longitude":longitude, "address": address,"mlnum":mlnum, "property_class_id":pid,"propclass": propclass, "bed":bed,"bath":bath,"zipcode":zip,"city":city,"image":image, "PropStatus":PropStatus, "pPrice":pPrice,"sqft":sqft, "shapid":currentMarkerID,"soldRange":soldRange};
			
        }//end for
	//	alert(outputHTML);	
	
	//alert('will call processResultsinArray');
	processResultsinArray();
		
      }//if  results less 202
			//alert(icon+'edn');
		
    }// end if
	
	//alert(icon);
		if( icon != 'poly'){
			map.AttachEvent("onendpan",EventEndCPan);
			map.AttachEvent("onendzoom", EventEndCPan);
			
		}
		
	//	alert(url + ',' + icon);
		
}


if (typeof(Sys) !== "undefined") Sys.Application.notifyScriptLoaded();
