/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


  
var choosed=null;
var ac=null;
function doSearch(){
  var baseurl="http://www.not1night.com.au/";
  var url="";
  if(choosed==null)
  {
    var refBox=document.getElementById("Search");
    var typed=refBox.value;
    var entryCount=ac.entryCount;
    for(var i=0;i<entryCount;++i){
      var entry= ac.getEntry(i);
      if(entry.innerHTML==typed){
        choosed=entry.id;
        break;
      } 
    }
    if(choosed==null){
      alert("Please choose one item from list");
      return false;
    }
  }
  if(choosed.indexOf("h")==0){
    var splited=choosed.split(":");
    url=baseurl+"?page=Customer:AvailabilityDetail&hotel_id="+splited[1];   
  }else if(choosed.indexOf("s")==0){
    var splited=choosed.split(";");

    var subregion=splited[0].split(":");
    var region=splited[1].split(":");
    var country=splited[2].split(":");
    url=baseurl+"?page=Customer:AvailabilityPage&countryid="+country[1]+"&regionid="+region[1]+"&subregionid="+subregion[1];
  }
  else if(choosed.indexOf("r")==0){
    var splited=choosed.split(";");
    var region=splited[0].split(":");
    var country=splited[1].split(":");
    url=baseurl+"?page=Customer:AvailabilityPage&countryid="+country[1]+"&regionid="+region[1];
  }else if(choosed.indexOf("c")==0){
    var splited=choosed.split(":");
    var countryid=splited[1];
    url=baseurl+"hotels/";
    if(countryid ==1 ){
      url+="Australia-hotels.html";   
    }else if(countryid ==4){
      url+="New-Zealand-hotels.html"; 
    }else if(countryid==46){
      url+="Cook-Islands-hotels.html";
    }else if(countryid==70){
      url+="Fiji-hotels.html";
    }else if(countryid==157){
      url+="New-Caledonia-hotels.html";
    }else if(countryid==235){
      url+="Vanuatu-hotels.html";
    }
  }
  window.location=url;
  return false;
}
  
