var mapSearchControl;

var strLati, strLong, strAptAddress, strCustomNoteWindow, strShortSiteName, strLatiLong;

function fnSearchTextKeyword() {
    var strSearchKeyword = document.getElementById("txtSearch").value;

    if ((strSearchKeyword == "") || (strSearchKeyword == "search the map")) {
        alert("Select a key work to search");
        return false;
    }
    //alert(strAptAddress);
    fnLocatePlaceOnMapByKeyword(strSearchKeyword, strLati, strLong);
}
// This fuction search for multiple locations based on a keyword  
function fnLocatePlaceOnMapByKeyword(argKeyword, argLati, argLong) {
    var objPropLocation = new VELatLong(Number(argLati), Number(argLong))

    // map.LoadMap();

    mapSearchControl.DeleteAllShapes();

    // map.LoadMap();

    // var strAddress = document.getElementById("PropHiddenAddress").value;

    addPropPin(objPropLocation);    

    try {
        mapSearchControl.Find(argKeyword, objPropLocation);
    }
    catch (e) {
        alert(e.message);
    }
}
function addPropPin(objPropLoction) {
    var pin = new VEShape(VEShapeType.Pushpin, objPropLoction);
    pin.SetTitle(strShortSiteName);
    pin.SetDescription(strCustomNoteWindow);
    var icon = "<div style='position:relative;margin-top:-24px;width:32;height:44px;background-image:url(\"images/GreenArrow.gif\")'/> ";

    pin.SetCustomIcon(icon);
    mapSearchControl.AddShape(pin);
}
 function XBrowserAddHandler(target,eventName,handlerName)
 {
 if ( target.addEventListener )
    target.addEventListener(eventName, handlerName, false);
 else if ( target.attachEvent )
    target.attachEvent("on" + eventName, handlerName);
 else
    target["on" + eventName] = handlerName;
 }

