﻿// JScript File

var tophttpRequest=false;

function topmakeObjecttop()
{
    var tophttpRequest;
    if(window.XMLHttpRequest)
    {
        tophttpRequest=new XMLHttpRequest();
    }
    else if(window.ActiveXObject)
    {
        try
        {
            tophttpRequest=new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch(e)
        {
            tophttpRequest=new ActiveXObject("Microsoft.XMLHTTP");
        }            
    }
    
    return tophttpRequest;
}

tophttpRequest = topmakeObjecttop();

function Top_processRequest()
{
    if(tophttpRequest==null)
    {
    tophttpRequest = topmakeObjecttop();
    }
    if(tophttpRequest.readyState < 4)
    {
    
     document.getElementById("search_suggest").style.display="none";
     document.getElementById("searchbox").className="search_Prog";
    }
    if(tophttpRequest.readyState == 4)
    {
   
        if(tophttpRequest.status==200)
        {
            var response=tophttpRequest.responseText;
          // alert(response);
          document.getElementById("search_suggest").style.display="none";
          document.getElementById("search_suggest").innerHTML=response;
         if(response!="0")
         {
          document.getElementById("searchbox").className="sml_grey";
          document.getElementById("search_suggest").style.display="block";   
          }
          else
          {
          document.getElementById("search_suggest").style.display="none";
          
          }
       }
    }
}

function searchSuggest()
{
   /*Call Ajax*/
  // alert("hi");
  // alert(document.getElementById("searchbox").style.top);
   var searchtext=document.getElementById("searchbox").value;
   searchtext=encodeURIComponent(searchtext);
   document.getElementById("search_suggest").style.display="none";
   if(searchtext.length>2)
   {
   document.getElementById("searchbox").className="search_Prog";
   //httpRequest.open("POST","AjaxSearchHelp.aspx",true);
   tophttpRequest.open("POST","https://www.spiritvoyage.com/AjaxSearchHelp.aspx",true);
   tophttpRequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
   tophttpRequest.onreadystatechange=Top_processRequest;
   tophttpRequest.send("searchtext="+searchtext);
   }
}
 
 function helpselected(obj)
 {
   document.getElementById("searchbox").value=obj;  
    document.getElementById("search_suggest").style.display="none";
 }
//ClearAndSetddllistItems(XmlHttp.responseXML.documentElement);
// 
//function ClearAndSetddllistItems(TableNode)
//{
//   
//    var ddllist = document.getElementById(ValToDDL);
//	//Clears the state combo box contents.
//	for (var count = ddllist.options.length-1; count >-1; count--)
//	{
//		ddllist.options[count] = null;
//	}
//     
//	var FieldNode = TableNode.getElementsByTagName('name');
//	var FieldNode1 = TableNode.getElementsByTagName('id');
//	//alert(FieldNode.length);
//	//alert(FieldNode.item(1).firstChild.nodeValue);
//	var textValue;
//	var textID; 
//	var optionItem;
//	
//	//Add new states list to the state combo box.
//	for (var count = 0; count < FieldNode.length; count++)
//	{
//   		textValue = FieldNode.item(count).firstChild.nodeValue;
//		textID= FieldNode1.item(count).firstChild.nodeValue
//		optionItem = new Option( textValue,textID,false, false);
//		ddllist.options[ddllist.length] = optionItem;
//	}
//}


