﻿// JScript File

function GetSearchString(obj)
{    
    if(obj.value.length > 1) 
    {
        //alert("Here > 1");	            
	    changevisibility('inline'); 	    
        WebControls_AutoCompleteSearch.ReturnItems(obj.value, callBack_LocationsListDIV);       
        alert("2");
	} 
	else if (obj.value.length < 1)
	{
	    //alert("Here < 2");
	    //ClearLocationsList();
	    changevisibility('none');
	}
	else 
	{
	    ClearDiv();
	}
}


function callBack_LocationsListDIV(res){
    var strOptionString = "";
    var strOptionString1 = "";
    var strOptionString2 = "";
    var LocationsAndCodes_Array=res.value.split('#');
    //alert(res.value);
    for (j = LocationsAndCodes_Array.length -1 ; j < LocationsAndCodes_Array.length; j++){
        var Locations = LocationsAndCodes_Array[j].split(',');
        strOptionString2 += "" + Locations[1] + "";
    }
    
    for (j = LocationsAndCodes_Array.length -2 ; j < LocationsAndCodes_Array.length - 1 ; j++){
        var Locations = LocationsAndCodes_Array[j].split(',');
        strOptionString1 += "<li class='islandResultData'> " + eval(LocationsAndCodes_Array.length - 2) + " of " + Locations[1] + "...</li>";
    }
    
    for (f = 0 ; f < LocationsAndCodes_Array.length - 2; f++){
        var Locations = LocationsAndCodes_Array[f].split(',');
        strOptionString += "<li><a href=\'" + strOptionString2 + "/IndividualResultTCS.aspx?touristItemID=&LocationID=" + Locations[0] + "'>" + Locations[1] + "</a></li>"; // add Results to result group
    }  
    
    document.getElementById("DivSearchStringUrls").innerHTML = strOptionString + strOptionString1;
}

function ClearDiv(){
    document.getElementById("DivSearchStringUrls").innerHTML = "";
}


function changevisibility(visibility){
    document.getElementById('DivSearchStringUrls').style.display = visibility;
}

function ClearSearchString(){
    //alert("here!");
    document.getElementById('body_Header_AutoCompleteSearch_SearchString').value="";
    //obj.value = "";
}

function swapme(url,alt){
    //alert("here!");
    document.getElementById('body_MainBody_itemImage').src=url;
    document.getElementById('body_MainBody_itemImage').alt=alt;
    //obj.value = "";
}