﻿
//################ SEARCH CRITERIA ELEMENTS (left column) ########################################
//**** Expand/Collapse listing search elements
function toggleSearch(id) {
	var obj = document.getElementById('divSearch_'+id);
	if(obj.style.display=='none') {
		obj.style.display='block';
		document.getElementById('arrow_'+id).src='../App_Themes/Default/Images/Map/arrow_down_blue.png';
	}
	else {
		obj.style.display='none';
		document.getElementById('arrow_'+id).src='../App_Themes/Default/Images/Map/arrow_right_blue.png';
	}
}
//***** Show/Hide Units or Acres
function togglePropOptions(id) { 
     switch(id)
	    {
	    case 0: //House
	        _search.SetUnits(null,null);removeOption('Units');
	        _search.SetAcres(null,null);removeOption('Acres');
	        loadCommonFeaturesHouse();
	      break    
	    case 1: //Condo
	        _search.SetUnits(null,null);removeOption('Units');
	        _search.SetAcres(null,null);removeOption('Acres');
	        loadCommonFeaturesCondo();
	      break
	    case 2: //Multi
	        _search.SetAcres(null,null);removeOption('Acres');
	        loadCommonFeatureIDsMulti();
	        highlight('spanUnits');
	      break
	    case 3: //Land
	        _search.SetUnits(null,null);removeOption('Units');
	        _search.SetBedrooms(null,null);removeOption('Beds');
	        _search.SetBathrooms(null,null);removeOption('Baths');
	        loadCommonFeatureIDsLand();
	        highlight('spanAcres');
	      break
	    }
	    plus('Prop',id);
}
//**** Expand/Collapse Sold search elements
function toggleSearchSold(id) {
	var obj = document.getElementById('divSearch_'+id);
	if(obj.style.display=='none') {
		obj.style.display='block';
		document.getElementById('arrow_'+id).src='../App_Themes/Default/Images/Map/arrow_down_blue.png';
	}
	else {
		obj.style.display='none';
		document.getElementById('arrow_'+id).src='../App_Themes/Default/Images/Map/arrow_right_blue.png';
	}
}

function closeOptionsBox(id) {
    var obj = $(id);
    if (obj.style.display == 'block') {
        obj.style.display = 'none';
    } 
}


function toggleOptionsBox(id)
{
    var obj=$(id);
    if(obj.style.display=='block') {
        obj.style.display='none'; }
    else {
        obj.style.display='block';
        if(id=='poiOptions') {document.getElementById('txtPoiSearch').focus();}
        }
    if(id!='foreclosureOptions'){($('foreclosureOptions')===undefined || $('foreclosureOptions')===null)?'':$('foreclosureOptions').style.display='none';}
    if(id!='soldOptions'){($('soldOptions')===undefined || $('soldOptions')===null)?'':$('soldOptions').style.display='none';}
    if(id!='schoolOptions'){($('schoolOptions')===undefined || $('schoolOptions')===null)?'':$('schoolOptions').style.display='none';}
    if(id!='poiOptions'){($('poiOptions')===undefined || $('poiOptions')===null)?'':$('poiOptions').style.display='none';}
    if(id!='boundaryOptions'){($('boundaryOptions')===undefined || $('boundaryOptions')===null)?'':$('boundaryOptions').style.display='none';}
    if(id!='shapeOptions'){($('shapeOptions')===undefined || $('shapeOptions')===null)?'':$('shapeOptions').style.display='none';}
}
//toggle page view between map and list
function toggleView(state) {
    if(state=="Map") {
        try
        {
            $('searchMode').value='Map';
            $('mapTanButtons').style.display='block';
            $('listTanButtons').style.display='none';
            $('divList').style.display = 'none';
            $('divListColumn').style.display = 'none';
            $('divBlueLabelSearch').style.display = 'none'
            if (boolShowBlueLabelEnabled=="true") {
                $('divBlueLabelSearch').style.display = 'block';
                if (typeof (jQuery) !== 'undefined') {
                    jQuery('#divBlueLabelSearch').show();
                }
            }         
        } catch(err) {}
    }
    else { // list
        try
        {   if ((typeof (_search) !== 'undefined') && (_search != null) && (_search.Criteria.toLowerCase() === 'bluelabel')) {
                _search.Criteria = '';
                }
            $('searchMode').value='List';
            $('mapTanButtons').style.display='none';
            $('listTanButtons').style.display='block';
            $('divList').style.display = 'block';
            $('divListColumn').style.display = 'block';
            $('divDemographics').style.display='none';
            ($('foreclosureOptions')===undefined || $('foreclosureOptions')===null)?'':$('foreclosureOptions').style.display='none';
            ($('soldOptions')===undefined || $('soldOptions')===null)?'':$('soldOptions').style.display='none';
            ($('schoolOptions')===undefined || $('schoolOptions')===null)?'':$('schoolOptions').style.display='none';
            ($('poiOptions')===undefined || $('poiOptions')===null)?'':$('poiOptions').style.display='none';
            ($('boundaryOptions')===undefined || $('boundaryOptions')===null)?'':$('boundaryOptions').style.display='none';
            ($('shapeOptions')===undefined || $('shapeOptions')===null)?'':$('shapeOptions').style.display='none';
            if (typeof (jQuery) !== 'undefined') {
                jQuery('#divBlueLabelSearch').hide();
                jQuery('#searchingForBlueLabelREO').remove();
            }
        } catch(err) {}
    }   
    _paging.pageNumber = 1;
    _paging.currentGroup = 1; 
}
function toggleMenu(divId) {
        if(document.getElementById(divId).style.display=='block') {
        document.getElementById(divId).style.display='none';}
    else {document.getElementById(divId).style.display='block';}
}
function toggleStar(obj) {
    if(obj.src.indexOf('fav_star_normal.png')!= -1) {
        obj.src="../App_Themes/Default/Images/Map/fav_star_hover.png"; }
    else {
        obj.src="../App_Themes/Default/Images/Map/fav_star_normal.png";}
}
function toggleStarsOver(ListingID,starId) {
    for(i=1; i<=starId; i++) {
        $(ListingID+"_Star_"+i).src="../App_Themes/Default/Images/Map/fav_star_hover.png";
    }
}
function toggleStarsOut(ListingID) {
    var currRating = $("rating_"+ListingID).value;
    RefreshStars(ListingID, currRating);
}

function RefreshStars(listingID, currRating) {
    for (i = 1; i <= 5; i++) { //first clear all stars
        var starImg = $(listingID + "_Star_" + i);
        if( starImg != null )
        starImg.src = "../App_Themes/Default/Images/Map/fav_star_normal.png";
    }
    for (i = 1; i <= currRating; i++) { //highlight stars for current rating
        var starImg = $(listingID + "_Star_" + i);
        if (starImg != null)
            starImg.src = "../App_Themes/Default/Images/Map/fav_star_rollover.png";
    }
}
function togglePhoto(MlsListingID,PhotoCount,Direction) {  
$('miniMap_'+MlsListingID).style.display='none';
 var letters=["","","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","aa","bb","cc","dd","ee","ff","gg","hh","ii","jj","kk","ll","mm","nn","oo","pp","qq","rr","ss","tt","uu","vv","ww","xx","yy","zz"];
 var obj=$("Photo_"+MlsListingID);
 var path = obj.src.substring(0,obj.src.lastIndexOf("/"))+"/";
 var fullFileName = obj.src.substring(obj.src.lastIndexOf("/")+1,obj.src.length);
 var fileName = fullFileName.substring(0,fullFileName.lastIndexOf(".")); //file name without the .jpg on the end
 var selected = parseInt($(MlsListingID+"_Photo_1").innerHTML); //currently selected image
 
 if(Direction=="R"){
    if(selected==PhotoCount) {
        obj.src=path+MlsListingID+".jpg";
        $(MlsListingID+"_Photo_1").innerHTML="1";
        }
     else {
        obj.src=path+MlsListingID+letters[selected+1]+".jpg";
        $(MlsListingID+"_Photo_1").innerHTML=selected+1;
     }
 }
 if(Direction=="L"){
    if(selected=="1") {
        obj.src=path+MlsListingID+letters[PhotoCount]+".jpg";
        $(MlsListingID+"_Photo_1").innerHTML=PhotoCount;
        }
     else {
        obj.src=path+MlsListingID+letters[selected-1]+".jpg";
        $(MlsListingID+"_Photo_1").innerHTML=selected-1;
     }
 }
 //http://photos2.hbm2.com/000/3/6/9/0/3518096.jpg
}
function toggleAdvancedSearch(AdvancedSearchType) {
    _advancedSearch.AdvancedSearchType = AdvancedSearchType;
    $('divAdvancedSearch').style.display='block';
    _advancedSearch.DisplayAdvancedSearch();
}
function toggleMiniMap(MlsListingID, Latitude, Longitude) {
    if ($('miniMap_' + MlsListingID).style.display == 'block') {
        $('miniMap_' + MlsListingID).style.display = 'none'; $('a_miniMap_' + MlsListingID).innerText = 'View Map';
    }
    else {
        $('miniMap_' + MlsListingID).style.display = 'block';
        $('a_miniMap_' + MlsListingID).innerText = 'View Photos';
        var map = new VEMap('miniMap_' + MlsListingID);
        map.LoadMap(new VELatLong(Latitude, Longitude), 12, 'r', true);
        map.HideDashboard();
        var Shape = new VEShape(VEShapeType.Pushpin, new VELatLong(Latitude, Longitude));
        Shape.SetCustomIcon("../App_Themes/Default/Images/Map/icon_listing.gif");
        map.AddShape(Shape);
    }
}
