﻿    //Main Objects
    var oGrid;
    var oPowerMap;
    var oPropertySearch;
    var oMapSlider;
    //Settings
    var iListPerPage = 100;
    var iLimitToShow;
    var PageNum = 1;
    var LPP = 10;
    var LoadingResult = false;
    var tDefaultLatLong = new Array();
    var MapLatitude = (!DataFloat.Agora.Util.IsEmptyOrNull(DataFloat.Agora.Util.Request.QueryString["lat"])) ? parseFloat(DataFloat.Agora.Util.Request.QueryString["lat"]) : 32.6142652;
    var MapLongitude = (!DataFloat.Agora.Util.IsEmptyOrNull(DataFloat.Agora.Util.Request.QueryString["long"])) ? parseFloat(DataFloat.Agora.Util.Request.QueryString["long"]) : -85.4476193;
    var dLast14days = DataFloat.Agora.Util.getSpecficDate(-100, 0, 0, 'YMD', "");
    tDefaultLatLong[320] = {Lat: MapLatitude, Long: MapLongitude};
    var fdlBoard = new Array();
    
    //Variables
    var bAdvacendSearchStatus = true;
    var iCurrentLoad = 0;
    var oCurrentDraw = null;
    var iCurrentImgPreview = 1;
    var oDataMapSource;
    var bDrawHasName = false;
    var allowToDraw = true;
    var iCurrentBoard = 200;
    var arrLoadedPops = new Array();    
    var mapAjax;
    var DrawAreas;
    var oComboManager;
    var arrProperties;

$(document).ready(function() {
    iLimitToShow = 200;
    oPowerMap = new DataFloat.Agora.RealMap("divMapMs");
    //oPowerMap.onElementClickUp = DoSearch;

//    oComboManager = new DataFloat.Agora.CustomDropBox(document.getElementById('IntineraryOrder'), true);
    
   //New Map
    mapAjax = new DataFloat.Agora.AjaxManager();
    mapAjax.MapManager = oPowerMap;
    mapAjax.MapManager.OnMapChangeCenter = false;
    mapAjax.MapManager.LoadMap();
    mapAjax.MapManager.VirtualMap.SetCenterAndZoom(new VELatLong(tDefaultLatLong[320].Lat, tDefaultLatLong[320].Long), 11)
    //mapAjax.MapManager.VirtualMap.AttachEvent("onmouseover", mapAjax.MapManager.OnMouseOverPin);
    //mapAjax.MapManager.VirtualMap.AttachEvent("onendzoom", oPowerMap_OnEndZoom);
    //mapAjax.MapManager.VirtualMap.AttachEvent("onendpan", CatchEventPOI);
    //New Map
    
    //Map Layout [Layers] Components
    //mapAjax.MapManager.AddMessage('SearchBar','<a href="javascript:AdvancedSearchTab_OnClick();" onclick="AdvancedSearchTab_OnClick();"><img src="Images/agora_map_collapsebar.gif"/></a>', 'criteriaBar');
    //mapAjax.MapManager.AddMessage('InfoBoxContainer', mapAjax.MapManager.NewFixedBox('InfoBox', '', DataFloat.Agora.IU.BoxStyle.Alert) , 'InfoBox');
    //mapAjax.MapManager.AddMessage('DrawingBoxContainer',mapAjax.MapManager.NewFixedBox('DrawingBox', '<br/><u>To draw square box over interested area:</u><br/><br/>1.	Place hand near area of interest<br/><br/>2.	Left click on mouse and hold button<br/><br/>3.	Drag square box to cover interested area', DataFloat.Agora.IU.BoxStyle.Neutral) , 'DrawingBox');
        
	accordionActions();	
	oMapSearch_OnLoad(OfficeJSon);
})
    
    function SetMapLocation(BoardId){
        iCurrentBoard = 320;
        mapAjax.MapManager.VirtualMap.SetCenterAndZoom(new VELatLong(tDefaultLatLong[320].Lat, tDefaultLatLong[320].Long), 10)
    }
    
    function ViewPropertyDetails(MlsNumber){
		    window.open('/PropertyDetail.aspx?RecordType=320&searchType=Map&get=1&Agora__Item__Detail=1&n_k=' + MlsNumber);
		}

    function AdvancedSearchTab_OnClick(){
	    if (bAdvacendSearchStatus)
	        $('#SearchCriteria').hide();
	    else
	        $('#SearchCriteria').show();
	    bAdvacendSearchStatus = !bAdvacendSearchStatus;
	}
	
	function DoSearch(pinObject){
        var oPinClick = null; 
	    if (pinObject != undefined)
	        oPinClick = oPowerMap.VirtualMap.GetShapeByID(pinObject.elementID);
   
   	    if (oPinClick == null){
	        mapAjax.StopAllRequest();
            var VELatLongRectangle = oPowerMap.VirtualMap.GetMapView();
	    
		    //New Map Search
		    
		    var drawParam;
		    var arrCheckArea = $('.cbxmyareas');
		    var arrCheckAreaToSearch = new Array();
		    var arrAllDraw = oPowerMap.GetAllDraw();
		    if (arrCheckArea.length > 0){
		        var arrDrawAreasToSearch = new Array();
		        for (iCkA=0;iCkA<arrCheckArea.length;iCkA++){
		            if (arrCheckArea[iCkA].checked)
		                arrCheckAreaToSearch.push(arrAllDraw[iCkA]);
		        }
		    }
		    drawParam = (arrCheckAreaToSearch.toAgoraAreaSearch());
	        
		    var searchLatMin, searchLatMax, searchLongMin, searchLongMax;
		    if (drawParam == ''){
		        searchLatMin = VELatLongRectangle.BottomRightLatLong.Latitude;
		        searchLatMax = VELatLongRectangle.TopLeftLatLong.Latitude;
		        searchLongMin = VELatLongRectangle.TopLeftLatLong.Longitude;
		        searchLongMax = VELatLongRectangle.BottomRightLatLong.Longitude;
            }else{
                var arrSplitLat = drawParam.split('|');
                var pointA = arrSplitLat[0].split(',');
                var pointB = arrSplitLat[1].split(',');
                var pointC = arrSplitLat[2].split(',');
                                
                searchLatMin = pointB[0];
		        searchLatMax = pointA[0];
		        searchLongMin = pointA[1];
		        searchLongMax = pointC[1];
                if (searchLatMin > searchLatMax)
                {
                    var searchLatTemp = searchLatMin;
                    searchLatMin = searchLatMax;
                    searchLatMax = searchLatTemp;
                }
                if (searchLongMin < searchLongMax)
                {
                    var searchLongTemp = searchLongMin;
                    searchLongMin = searchLongMax;
                    searchLongMax = searchLongTemp;            
                }
            }		    
		    var mapParam = "Agora__ItemPerPage=101&dec_LatMin=" + searchLatMin + "&dec_LatMax=" + searchLatMax + "&dec_LongMin=" + searchLongMin + "&dec_LongMax=" + searchLongMax + "&" + serializeForm('frmMapSearch');;
		    mapAjax.ItemPerPage = 101;
		    mapAjax.FormParams = mapParam;
            mapAjax.NewSystemRequest(DataFloat.Agora.Services.ServiceMapSearch, null, oMapSearch_OnLoad);
        }else{
            MlsNumber = oPinClick.MlsNumber; 
            oPowerMap_PinClick(null, MlsNumber);
        }
	}
	
	function oMapSearch_OnLoad(result){
	        //AdvancedSearchTab_OnClick();

	        arrProperties = JSON.parse(result);
	        
	        mapAjax.MapManager.ClearAll();
	  	    var arrPin = new Array();
	  	    var arrMls = new Array();
            PinClass = null;	  	    
	  	    for(var i = 0; i < arrProperties.length ; i++){
                iMLSNum = arrProperties[i]["mls"];
                //iName = arrProperties[i]["name"];
                iName =  "";
                iLatitude = arrProperties[i]["lat"];
                iLongitude = arrProperties[i]["long"];
                iKmls = arrProperties[i]["kmls"];
                iListDate = arrProperties[i]["listdate"];
                arrMls.push(arrProperties[i]["mls"]);
                if (iLatitude && iLongitude)
                {
				    //var Html = "<b><a href='OfficeDetail.aspx?RecordType=2&n_k="+ arrProperties[i]["OfficeKey"]+ "'>"+arrProperties[i]["name"]+"</a></b><br/>"+arrProperties[i]["OfficeAddress"]+"<br/>"+arrProperties[i]["OfficeCity"]+"&#160;"+arrProperties[i]["OfficeState"]+"&#160;"+arrProperties[i]["OfficeZip"]+"<br/>"+arrProperties[i]["OfficePhone"];
				    var Html = "<b>"+arrProperties[i]["name"]+"</b><br/>"+arrProperties[i]["OfficeAddress"]+"<br/>"+arrProperties[i]["OfficeCity"]+"&#160;"+arrProperties[i]["OfficeState"]+"&#160;"+arrProperties[i]["OfficeZip"]+"<br/>"+arrProperties[i]["OfficePhone"];
					arrPin[arrPin.length] = new mapAjax.MapManager.PinObject(i, iName, iLatitude, iLongitude, iMLSNum, PinClass, Html , iKmls);
			    }
            }
            mapAjax.MapManager.NewItem(arrPin);
            /*StartListView();*/
	}
		
	function GetNumber(mls)
	{
	    var ListingClass = $(".Agora_Pin_"+mls).attr("class");
	    if (ListingClass.indexOf("NewPin")!=-1)
	    {
	        $("#Status_"+mls).removeClass("active");
	        $("#Status_"+mls).addClass("new");
	    }
	    var CurrentPosition = $(".Agora_Pin_"+mls).attr("id").replace("Agora_Pin_","");
	    $("#Number_"+mls).html(CurrentPosition);
	}
	
	function CheckStatus(HolderID, Date)
	{  
	    var dLast14days = DataFloat.Agora.Util.getSpecficDate(-14, 0, 0, 'YMD', "");
	    if (Date >= dLast14days)
	    {
	        $("#"+HolderID).removeClass("active");
	        $("#"+HolderID).addClass("new");
	    }
	}
	
	function ShowOnlySelected()
	{
	    var CheckedListings = $("input:checked[name=ShowOnMap]").get();
	    if (CheckedListings.length>=1)
	    {
	        $("div.DefaultPin").hide();
	        $("div.NewPin").hide();
	        for (var i=0; i<CheckedListings.length; i++)
	        {
	            $('.Agora_Pin_'+CheckedListings[i].value).show();
	        }
	    }else alert("Please check at least 1 listing to show");
	}
	
	function ClearSelected()
	{
        $('input:checked[name=ShowOnMap]').removeAttr('checked'); 
        $('.DefaultPin').show();	
	}
	
	function StartListView()
	{
	    PageNum = 1;
        $("#ListingBody").html("");
        GetMapResult();
	}
	
	function GetMapResult()
	{
	    if (arrProperties.length>=1)
	    {
	        $("#processing").html("...Loading&#160;<img src='/images/bg_loading.gif'/>");
	        LoadingResult = true;
	        var ResultMLS = "n_k=";
	        for (var i=0; i<arrProperties.length; i++)
	        {
	            FirstList = ((PageNum - 1) * LPP) + 1;
	            LastList = (PageNum * LPP);
	            if (i+1>=FirstList && i+1<=LastList)
	            {
	                if (i+1!=FirstList) ResultMLS += ",";
	                ResultMLS += arrProperties[i]["kmls"];
	            }
	        }
    	    
	        var HtmlView = "MapResult"+$("#results_view").val()+"_320";
            var AspNet_formParams = "HtmlInterface="+HtmlView+"&RecordType=320&"+ResultMLS;
            var ajaxResult = new DataFloat.Agora.AjaxManager(AspNet_formParams);
            ajaxResult.NewSystemRequest(DataFloat.Agora.Services.ServiceContentManagerMultipleHtml, 1, function(data){
                $("#ListingBody").append(data);
                $("#ListingBody tr:odd").addClass("alt");
                $("#processing").empty();
            });            
        }
	}
	
	/* GRID */
	function OnListViewOver(e)
	{
	    var oPinToFind = oPowerMap.GetPinByMlsNumber(this.id);
	    if (oPinToFind!=null)
	        ShowMapPopup(oPinToFind);

        $('.Agora_Pin_'+this.id).parent().mouseover();
	}	
	
    function OnListViewOut(e)
	{
        $('.Agora_Pin_'+this.id).parent().mouseout();
	}		
	
	//Grid Behavior
	function Grid_OnRowClick(index){
	    ViewPropertyDetails(arrProperties[index].kmls);
	    //ViewPropertyDetails($("#Agora_Grid_Tr_"+index+" .Agora_Grid_mls").html());
	    //oPowerMap_PinClick(null, arrProperties[index].mls, parseInt(index)+1);
	}
	
	function Grid_OnRowMouseOver(index){
	    var oPinToFind = oPowerMap.GetPinByMlsNumber(arrProperties[index].kmls)
        $("#Agora_Pin_"+(parseInt(index)+1)).parent().mouseover();
	    oPowerMap.HigligthPin(parseInt(index)+1);
	    
	}
	
	function Grid_OnRowMouseOut(index){
	    oPowerMap.RemoveHigligth(parseInt(index)+1);
	}
	//Grid Behavior
	
	function NavGrid(direction, page){
	    page = String.IsEmptyOrNull(direction) ? page : oGrid.CurrentPage + direction;
	    oGrid.LoadContent(page);oGrid.CreateNavigation('NavGrid');
	}
	
	
	/* GRID */

	/* MAP */
	function oPowerMap_PinClick(e, MlsNumber, index){
	    if (!oPowerMap.DrawMode){
	        oPowerMap.RemoveAllHigligth();
	        if (e != null && e != undefined){ oPinClick = oPowerMap.VirtualMap.GetShapeByID(e.elementID); if (oPinClick!=null) { MlsNumber = oPinClick.MlsNumber; index = oPinClick.Position+1;}}
	        if ((MlsNumber != null && MlsNumber != undefined)){
	            oPowerMap.HigligthPin(index);
	            iCurrentImgPreview = 1;
	            var oPropertySearchPreview = new DataFloat.Agora.AjaxManager();    
	            oPropertySearchPreview.FormParams = "RecordType=" + iCurrentBoard + "&0110_exc=" + MlsNumber + "&HtmlInterface=NewMapPreview";
	            oPropertySearchPreview.NewRequest(DataFloat.Agora.Services.ServiceGetHtmlContent, 1, null, "PropertyPreview", true);
	        }else{
	            //DoSearch();
	        }
        }
    }
    
	
	function GoPhoto(Direction, ImgName, IndexName, Count, ImgSrc){
	        iCurrentImgPreview = $("#" + IndexName).html();
		    iCurrentImgPreview =  parseInt(iCurrentImgPreview) + (1*Direction);
		    if (iCurrentImgPreview <= 1)
		    {
		        $('.Previous').hide();
		        iCurrentImgPreview=1;
		    }else $('.Previous').show();
		    if (iCurrentImgPreview >= Count)
		    {
		        $('.Next').hide();
		        iCurrentImgPreview=Count;
		    }else $('.Next').show();
		    	    		    
		    $('#' + IndexName).html(iCurrentImgPreview);
		    $("#" + ImgName).attr('src', $('#ImageIndex_' + iCurrentImgPreview).val());
		    
		}   
		
		
        DataFloat.Agora.RealMap.prototype.OnMouseOverPin = function(e){
        
	        if(e.elementID)
	        {
		        var pin = mapAjax.MapManager.VirtualMap.GetShapeByID(e.elementID);
        		ShowMapPopup(pin);
	        }
        }	
		
        function ShowMapPopup(pin){
            var k = pin.MlsNumber;
        		if (arrLoadedPops[k] == undefined){
		            arrLoadedPops[k] = true;

		            if (!IsNumeric(k)) return;
 		            pin.SetDescription("<div id='PropertyInfo_"+pin.kmls+"' style='width:450px' ><img src='/images/ran_bg_loading.gif'/> Loading...</div>"); 
            		
		            mapAjax.MapManager.getPopInfo(pin.kmls,"PropertyInfo_"+pin.kmls, pin);
		            
                }
        }		
	
        DataFloat.Agora.RealMap.prototype.getPopInfo = function(k, divID, pinObejct){
            var VEPopUpRequest = new DataFloat.Agora.AjaxManager("RecordType=320&HtmlInterface=MapPopUpInfo_320&n_k="+k);
            VEPopUpRequest.NewSystemRequest(DataFloat.Agora.Services.ServiceContentManagerMultipleHtml, 1, function(data){
                $("#"+divID).html(data);
                pinObejct.SetDescription(data);
            });
        }			
		
		
		function GetMapPOI(CodeNum, Type)
		{
		    var POIRequest = "20";

		    if ($("#POI"+Type).attr("class")=="POIUnselected")
		    {
		        $("#POI"+Type).removeClass("POIUnselected");
		        $("#POI"+Type).addClass("POISelected");
		        $("#POI"+Type).parent("span").addClass("POISelected");
		        $("#POI"+Type).parent("span").removeClass("POIUnselected");
                mapAjax.MapManager.ShowPOI(DataFloat.Agora.Services.ServicePOI, CodeNum, Type,POIRequest);
            }else
            {
                mapAjax.MapManager.RemovePOI(Type);
		        $("#POI"+Type).removeClass("POISelected");
		        $("#POI"+Type).addClass("POIUnselected");
                $("#POI"+Type).parent("span").removeClass("POISelected");
		        $("#POI"+Type).parent("span").addClass("POIUnselected");		        
            }
	        
		}
		
		var PropertyLatitude = null;
		var PropertyLongitude = null;
		var PropertyAddress = null;
		
        function GetPropertyDirection(Latitude, Longitude, PFullAddress)
        {
            PropertyLatitude = Latitude;
            PropertyLongitude = Longitude;
            PropertyAddress = escape(PFullAddress);
            $("#StartingLocation").focus();
        }
        
        function GetMapDirection(StartLocationID)
        {
            var FromLocation = $("#"+StartLocationID).val();
            if (FromLocation=="") return;
            
            DataFloat.Agora.Util.NewPop('/POP/PropertyDetailMapDirections.aspx?Latitude=' + PropertyLatitude + '&Longitude=' + PropertyLongitude + '&AddressTo=' + PropertyAddress + "&AddressFrom=" + FromLocation, 1000, 500);
        }
        
        
	    function Directions_OnLoad(route){
	        // Unroll route
               var legs     = route.RouteLegs;
               var turns    = "Total distance: " + route.Distance.toFixed(1) + " mi\n";
               var numTurns = 0;
               var leg      = null;
               directionLoaded = true;
               dataSourceDirections = new Array();

                for(var i = 0; i < legs.length; i++)
                {

                   leg = legs[i];
                   var turn = null;
                      
                   for(var j = 0; j < leg.Itinerary.Items.length; j ++)
                   {
                      
                      turn = leg.Itinerary.Items[j];
                      dataSourceDirections.push({Step: turn.Text, Distance: turn.Distance.toFixed(1)});
                      numTurns++;
                   }
                }
                $('#DrawingBoxContainer').hide();
	    }        
    	    
	    function Directions_StillWorking(){
	        $('#DrawingBox').html('<img src="/Css/MapSearch/agora_map_box_ico_alert.gif"/>We are working on your request.<br/>Please wait...');
	    }
	    
	    function Directions_CheckTimeout(){
	        if (!directionLoaded){
	            $('#DrawingBox').html("We didn't get to process your request.<br/><br/><a href='javascript:StartDrivingDirections()'>Try Again</a> &nbsp;&nbsp;&nbsp;<a href='javascript:$(\"#DrawingBoxContainer\").hide();'>Cancel</a>");
                directionLoaded = true;
	        }
	    }
	    
	    function ClearDirection(){
	        mapAjax.MapManager.VirtualMap.DeleteRoute();
	        document.getElementById("IntineraryOrder").length=0;
	    }	    
	    
	    var directionLoaded = true;
	    function ShowDirections(){
    	    
	        var AddressStart = $('#StreetAddress').val();
    	    
	        if (AddressStart != ''){
	            $('#DrawingBoxContainer').show();
	            $('#DrawingBox').html("Processing your request.<br/>Please wait...");
	            var options = new VERouteOptions();
                options.RouteCallback = Directions_OnLoad;
                
	            var arrPoints = new Array();
	            var arrAddress = oComboManager.TextToArray();
                arrPoints.push(AddressStart);
	            for (iA=0;iA<arrAddress.length;iA++)
	                arrPoints.push(arrAddress[iA]);
    	            
	            directionLoaded = false;
	            mapAjax.MapManager.VirtualMap.GetDirections(arrPoints, options);
	            setTimeout("Directions_StillWorking()", 5000);
	            setTimeout("Directions_CheckTimeout()", 10000);
    	    
	        }
	    }
	    
	    function GetIndex(MlsNumber){
	        for (iDs = 0; iDs < arrProperties.length; iDs++){
	            if (arrProperties[iDs].kmls == MlsNumber)
	                return iDs;
	        }
	    }
    	
	    
	
	var MapX;
	var MapY;
	function OnEventCatchPosition(e)
	{
	    MapX = e.mapX;
	    MapY = e.mapY;
	}
	function OnEventMouseForPOI(e)
	{
        if (MapX != e.mapX && MapY != e.mapY)
        {
            CatchEventPOI();
	    }
	}
	
	function CatchEventPOI()
	{
        var POIArr = $(".POISelected").get();
        for (var i=0; i<POIArr.length; i++)
        {
            var FuncName = $('#'+POIArr[i].id).attr("onclick");
            eval(FuncName)();
            eval(FuncName)();
        }
        //return false;
	}
	var ignoreZoomEvent = false;
	function oPowerMap_OnEndZoom(){
	    if (oMapSlider != undefined && !ignoreZoomEvent){
	        var zoomLevel = mapAjax.MapManager.VirtualMap.GetZoomLevel();
	        zoomLevel = parseInt((100 * zoomLevel) / 19);
	        oMapSlider.unsubscribe("change", Slider_OnChange);
	        oMapSlider.setValue(zoomLevel/scaleFactor);
	        oMapSlider.subscribe("change", Slider_OnChange);
	        CatchEventPOI();
        }
	}   
	
	function Slider_SrollOut(){
	    ignoreZoomEvent = true;
	    oMapSlider.setValue(oMapSlider.getValue()-5);
	    setTimeout("ignoreZoomEvent = false;", 2000);
	}
	
	function Slider_SrollIn(){
	    ignoreZoomEvent = true;
	    oMapSlider.setValue(oMapSlider.getValue()+5);
	    setTimeout("ignoreZoomEvent = false;", 2000);
	}
	
	    
	function SliderToMapZoom(SliderLevel){
	    var iSliderLevel = (SliderLevel>100) ? 100 : SliderLevel;
	    var iNew = 6+((19-6)/100) * iSliderLevel;
	    
	    return parseInt(iNew);
	}
	
	
	function Slider_OnChange(offsetFromStart){
	    var iSliderLevel = SliderToMapZoom(oMapSlider.getRealValue()); 
	    
	    mapAjax.MapManager.VirtualMap.SetZoomLevel(iSliderLevel)
	}



//Handles the slide movement of accordion elements
function accordionActions() {
	$('.accordion .content').not('.first').hide();
	$('.accordion .title').click(function() {
		$(this).siblings('.content').slideDown();
		$(this).parents('.accordion').children('.section').children('.content').not($(this).siblings('.content')).slideUp();
	});
}





//***************************************************************************************************
// Compare Properties
//***************************************************************************************************
function addPropertyCompare(Elem)
{
        //var k =  Elem.value;
        var k =  Elem;
        var foundMLS = false;
        var newPropertyList = "";
	    var propertyList = (DataFloat.Agora.Util.ReadCookie('CompareProperties')!=undefined) ? DataFloat.Agora.Util.ReadCookie('CompareProperties') : "";
        if (propertyList!='')
        {
	        var properties = propertyList.split(',');
	        for (var i=0; i<properties.length; i++)
	        {
	            if ($.trim(properties[i])!='' && $.trim(properties[i])!=k) 
	            {
	                if ($.trim(newPropertyList)!='') newPropertyList += ',';
	                newPropertyList +=  properties[i];
	            }
	        }
	        
        }
        //if (Elem.checked) 
        if ($("#compare_"+k).attr("checked"))
        {
            if ($.trim(newPropertyList)!='') newPropertyList += ',';
            newPropertyList +=  k;
        }
        var newPropertyArr = newPropertyList.split(',');
        if (newPropertyArr.length>4)
        {
         //   Elem.checked = false;
            $("#compare_"+k).removeAttr("checked");
            alert('You cannot compare more than 4 properties');
        }
        else DataFloat.Agora.Util.SetCookie('CompareProperties', newPropertyList, 0.167);
        return false;
}

function toggleCompare(id)
{
	if ($("#compare_"+id).attr("checked"))
	{
		$("#compare_"+id).removeAttr("checked")
	}else{
		$("#compare_"+id).attr("checked","checked");
	}
}

function checkCompare(){

	var propertyList = DataFloat.Agora.Util.ReadCookie('CompareProperties');
	
	if (propertyList==null)
		propertyList = '';
	else if ($.trim(propertyList)!='')
	{
		var properties = propertyList.split(',');

		for (var i=0; i<properties.length; i++){

			if($("#compare_" + properties[i]).size()){
				$("#compare_" + properties[i]).attr({ checked: "checked" });
			}
		}
	}
}


    function getComparePropertyList()
    {
	    alert(DataFloat.Agora.Util.ReadCookie('CompareProperties'));
    }

    function cleanPropertyList()
    {
	    DataFloat.Agora.Util.DeleteCookie('CompareProperties');
    }
    function removeChecked(){
	    $("input").removeAttr("checked");
    }
    function compareProperties()
    {
	    var propertyList = DataFloat.Agora.Util.ReadCookie('CompareProperties');
	    if (propertyList==null)
	    {
		    alert('Please select at least two properties to compare');
		    return;		
	    }
    	
	    var properties = propertyList.split(',');
    	
	    if (properties.length<2) 
	    {
		    alert('Please select at least two properties to compare');
		    return;
	    }
    	
	    window.open(DOCUMENT_ROOT+'/CompareProperties.aspx?RecordType='+RecordType+'&compare='+propertyList);
    }

    var config = {    
         sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)    
         interval: 50, // number = milliseconds for onMouseOver polling interval    
         over: OnListViewOver, // function = onMouseOver callback (REQUIRED)    
         timeout: 300, // number = milliseconds delay before onMouseOut    
         out: OnListViewOut // function = onMouseOut callback (REQUIRED)    
    };

    function MapReady()
    {
        LoadingResult = false;
        $("div.overflow").scroll(function(){
            var elem = $('div.overflow');
            if (elem[0].scrollHeight - elem.scrollTop() / elem.outerHeight() > 0.8) {
              if ((PageNum * LPP) < arrProperties.length && !LoadingResult)
              {
                PageNum++;
                GetMapResult();
              }
            }
        });	
        
        $(".Agora_Map_Tr").hoverIntent( config );
       
    }






function FindAgentAlphabetic(pString){
    document.location.href = 'AgentResult.aspx?0040=1&0520_right=' + pString;
}