﻿// JScript File

var SearLocations_SearchID = 0;

function SearchLocations(sVenueName, sAddress1, sCity, iStateID, sZip){

    //alert(sVenueName + ", " + sAddress1 + ", " + sCity + ", " + iStateID + ", " + sZip);
    
    SearLocations_SearchID = GetRandomNumber();

    RichmondBarsAndRestaurants.LocationsSearchService.SearchLocations(sVenueName, sAddress1, sCity, iStateID, sZip, 
        SearLocations_SearchID, 
        SucceededCallback_SearchLocations, OnError_SearchLocations, OnTimeout_SearchLocations);         
    
}

function SucceededCallback_SearchLocations(result) {

    if (result.SearchID == SearLocations_SearchID){ // if not latest search, ignore
        
        try {   
            if (typeof EditSpecial_SearchLocations_DisplayResults_Internal == "function") {
                EditSpecial_SearchLocations_DisplayResults_Internal(result.LocationDisplayObjs);
            }
        }catch(SpecialEdit_exc) { }
        
        try {
            if (typeof PostControl_SearchLocations_DisplayResults_Internal == "function") {
                PostControl_SearchLocations_DisplayResults_Internal(result.LocationDisplayObjs);
            }
        }catch(PostControl_exc) { }
        
    }

//    alert(result.length);  
//    
//    if (result.length == 0){	    
//	    return;
//    }

//    document.getElementById("SiteImageLinks").innerHTML = "";
//    
//    var c = '<table style="width:100%;" cellpadding="0" cellspacing="0">';
//	var count = 0;
//	var SitesPerRow = 2;
//    for (var i=0; i < result.length; i++){
//		count = count + 1;
//		if ((count % Number(SitesPerRow) == 1)){
//		    if (count > 1){c += '</tr>';}
//			c += '<tr>';
//		}
//		c += "<td width=\"50%\" align=\"center\">" + result[i] + "</td>";
//	}  
//    c += '</tr></table>';
//			
//    getRef("SiteImageLinks").innerHTML = c; 
    
}

function OnError_SearchLocations(result){
    //alert(result.get_message());
}

function OnTimeout_SearchLocations(result){
    //alert(result.get_message());
}

