var contentHandler = new TagFinder(null);
var dom = new DOM();
var xu = new XML();
 var first = "true";
var noResults = "No Results";
var txtenquiry
function TagFinder(divTag) 
{
  var divTag;
  var txtTag;
  var selSpanTag;
  return divTag;
}
function u2dp (s)
{
  ret = '';
  for (i=0; i<s.length; i++)
  {
    charCode = s.charCodeAt(i);
    if ((charCode <= 127) && (charCode != 34) && (charCode != 38) &&
        (charCode != 60) && (charCode != 62))
      ret += s.charAt(i);
    else
      ret += '&#' + charCode + ';';
  }
  return ret;
}

function AjaxModifyDDL(e,strProduct) 
{


  if (contentHandler.divTag) 
  {
    var currValue = contentHandler.txtTag.value;
    currValue = currValue.replace(/   /g, '')
    currValue = u2dp(currValue);
    var strQryXML
    if ((currValue.length >= 3) && (currValue != "undefined")) 
    {
      if (DivKeyHandler(e) == true) 
      {
        xmlHttp = new Ajax().GetXmlHttpObject();
        if (xmlHttp) 
        {
					// Commented temporarily because Mozilla debugging only works for local requests.
          var mainService = dom.$("ctl00_hdnSvcMain").value;
          //var mainService = "http://localhost/online_1/Services/MainService.asmx";

          if (! (mainService == "") || (mainService == "undefined")) 
          {
            strCompCode = dom.$("ctl00_contentMain_Modify_hndCompCode").value;
            strLangCode = dom.$("ctl00_contentMain_Modify_hndLangCode").value;

            strQryXML = escape("<GetCities><CompCode>" + strCompCode + "</CompCode><Prefix>" + currValue + "</Prefix><LangCode>" + strLangCode + "</LangCode><Product>" + strProduct + "</Product></GetCities>");

            var url = mainService + "/GetCities?strInputXML=" + strQryXML;
            //                        var url = mainService + "/GetCities?strPrefix=" + currValue;
            xmlHttp.onreadystatechange = AjaxModifyDDLResponseHandler;
            xmlHttp.open("GET", url, true);
            xmlHttp.send(null);
          }
        }
        else 
        {
          alert("Error! Your browser does not seem to support Ajax!"); //Error! Your browser does not seem to support Ajax!
        }
      }
    }
    else
			ShowHideDiv(false);
  }
}

function AjaxModifyDDLResponseHandler() 
{

  var divTag = contentHandler.divTag;

  try 
  {
    if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete") 
    {
      if (xmlHttp.status == 200) 
      {

        divTag.innerHTML = "";
        if (xmlHttp.responseText == "")
					ShowHideDiv(false);
        else 
        {
          var responseTxt = new Ajax().GetResponseText(xmlHttp);
          var idx = responseTxt.lastIndexOf("+");
          var str = responseTxt.split("+");
          var suggest = "";
          for (i = 0; i < str.length; i++) 
          {
						var thisCity = str[i];
						if (thisCity.toLowerCase() == "no results")
							thisCity = noResults;
							          
            suggest += '<p id="dynaSpan' + i + '" class="normalS" onMouseOver="SuggestOver(this)" onMouseOut="SuggestOut(this)" ';
            suggest += 'onClick="Suggest(this)">' + thisCity + '</p>';
          }

//          if (new BrowserSniffer().GetBrowserType() == "cr")
//					{
//						divTag.style.overflow = "scroll";
//					}
					
          divTag.innerHTML += suggest;
          var frameHeight = str.length * 18;
          
          var myFrame = dom.$("ctl00_contentMain_Modify_myFrame");
          if (myFrame != null) 
          {
            myFrame.style.height = frameHeight + "px";
            myFrame.style.visibility = "visible";
            divTag.style.position = myFrame.style.position;
          }

          if (dom.$("modifyFrame") != null) 
          {
            dom.$("modifyFrame").style.height = frameHeight + "px";
            dom.$("modifyFrame").style.visibility = "visible";
          }

          if (dom.$("modifyFrame1") != null) 
          {
            dom.$("modifyFrame1").style.height = frameHeight + "px";
            dom.$("modifyFrame1").style.visibility = "visible";
          }
          
          var myFlightFrame = dom.$("myFlightFrame");
          if (myFlightFrame != null) 
          {
            frameHeight = str.length * 19.2;
            if (divTag.id == "divFLDepart") 
            {
              myFlightFrame.style.top = "80";
            }
            else if (divTag.id == "divFLArrival") 
            {
              myFlightFrame.style.top = "120";
            }
            myFlightFrame.style.height = frameHeight + "px";
            myFlightFrame.style.visibility = "visible";
          }
          if (i > 0) 
          {
            ShowHideDiv(true);

            // Reset spanNum and scroll to first item.
            spanNum = -1;
            ScrollSpan("down");
            contentHandler.txtTag.focus();
          }
        }
      }
      else 
      {
        divTag.innerHTML = "An error occurred while retrieving data.";//"An error occurred while retrieving data.";
        ShowHideDiv(true);
      }
    }
  }
  catch(e) 
  {
    divTag.innerHTML = "An error occurred while retrieving data.";//"An error occurred while retrieving data.";
    ShowHideDiv(true);
  }
}



function AjaxDDL(e, strProduct) 
{

  if (contentHandler.divTag) 
  {
    var strCompCode, strLangCode
    var currValue = contentHandler.txtTag.value;
		currValue = currValue.replace(/   /g, '')		
		currValue = u2dp(currValue);
    var strQryXML
   //currValue = currValue.replace(/^\s+|\s+$/g, '');
    if ((currValue.length >= 3) && (currValue != "undefined")) 
    {
      if (DivKeyHandler(e) == true) 
      {
        xmlHttp = new Ajax().GetXmlHttpObject();
        if (xmlHttp) 
        {
      
          // Commented temporarily because Mozilla debugging only works for local requests.
          var mainService = dom.$("ctl00_hdnSvcMain").value;
          
          if (! (mainService == "") || (mainService == "undefined")) 
          {
            if (dom.$("ctl00_contentMain_ModifyIntFlightSearch1_hndCompCode")!=null)
            {
              strCompCode = dom.$("ctl00_contentMain_ModifyIntFlightSearch1_hndCompCode").value;
              strLangCode = dom.$("ctl00_contentMain_ModifyIntFlightSearch1_hndLangCode").value;
            }
            else if (dom.$("ctl00_contentMain_ModifyFlightSearch1_hndCompCode")!=null)
            {
              strCompCode = dom.$("ctl00_contentMain_ModifyFlightSearch1_hndCompCode").value;
              strLangCode = dom.$("ctl00_contentMain_ModifyFlightSearch1_hndLangCode").value;
            }//This Else has been added By Vikash for MultiCity Purpose
            else if(dom.$("ctl00_contentMain_ModifyMultiCityFlightSearch1_hndCompCode")!=null)
            {
                strCompCode = dom.$("ctl00_contentMain_ModifyMultiCityFlightSearch1_hndCompCode").value;
                strLangCode = dom.$("ctl00_contentMain_ModifyMultiCityFlightSearch1_hndLangCode").value;
            }
            
            else if (dom.$("ctl00_contentMain_ctl00_hndCompCode")!=null)
            {
              strCompCode = dom.$("ctl00_contentMain_ctl00_hndCompCode").value;
              strLangCode = dom.$("ctl00_contentMain_ctl00_hndLangCode").value;
            }
           else if (dom.$("ctl00_contentMain_hndLangCode")!=null)
            {
                strCompCode = dom.$("ctl00_contentMain_hndCompCode").value;
                strLangCode = dom.$("ctl00_contentMain_hndLangCode").value;
            }
          else if (dom.$("ctl00_contentMain_ModifySightSeeing_hndCompCode")!=null)
            {
                 strCompCode = dom.$("ctl00_contentMain_ModifySightSeeing_hndCompCode").value;
                 strLangCode = dom.$("ctl00_contentMain_ModifySightSeeing_hndLangCode").value;
            }
            strQryXML = escape("<GetCities><CompCode>" + strCompCode + "</CompCode><Prefix>" + currValue + "</Prefix><LangCode>" + strLangCode + "</LangCode><Product>" + strProduct + "</Product></GetCities>");
            
            var url = mainService + "/GetCities?strInputXML=" + strQryXML;
            xmlHttp.onreadystatechange = AjaxDDLResponseHandler;
             xmlHttp.open("GET", url, true);
            xmlHttp.setRequestHeader("Content-Type","text/xml; charset=ISO-8859-1");
            xmlHttp.send(null);
          }
        }
        else 
        {
           alert("Error! Your browser does not seem to support Ajax!");//Error! Your browser does not seem to support Ajax!
        }
      }
    }
    else
    	ShowHideDiv(false);
  }
}

function AjaxDDLResponseHandler() 
{
  var divTag = contentHandler.divTag;

  try 
  {
    if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete") 
    {
   
     if (xmlHttp.status == 200) 
      {
      
        
        divTag.innerHTML = "";
      
       var responseTxt = new Ajax().GetResponseText(xmlHttp);
         var responseTxt = xmlHttp.responseText;
        if (responseTxt == "") 
					ShowHideDiv(false);
        else 
        {
          responseTxt=responseTxt.replace('<?xml version=\"1.0\" encoding=\"utf-8"?>','').replace('<string xmlns="http://quadlabs.com">','').replace('</string>','');
          var idx = responseTxt.lastIndexOf("+");
          var str = responseTxt.split("+");
          var suggest = "";
          
          for (i = 0; i < str.length; i++) 
          {
						var thisCity = str[i];
						if (thisCity.toLowerCase() == "no results")
							thisCity = noResults;
							
            suggest += '<p id="dynaSpan' + i + '" class="normalS" onMouseOver="SuggestOver(this)" onMouseOut="SuggestOut(this)" ';
            suggest += 'onClick="Suggest(this)">' + thisCity + '</p>';
          }

//					if (new BrowserSniffer().GetBrowserType() == "cr")
//					{
//						divTag.style.overflow = "scroll";
//					}

          divTag.innerHTML += suggest;
          var frameHeight = str.length * 18;
         
          var myFrame = dom.$("myFrame");
          if (myFrame != null) 
          {
            myFrame.style.height = frameHeight + "px";
            myFrame.style.visibility = "visible";
           if((navigator.userAgent.indexOf("Opera") > -1)&&(first == "true"))
           {
                myFrame.style.top = (parseInt(myFrame.offsetTop) + 10) + "px";
                divTag.style.top =  (parseInt(divTag.offsetTop) + 10)+ "px";
                first = "false";
            }
            if (new BrowserSniffer().GetBrowserType() == "ie")
			{
			    divTag.style.height = frameHeight + "px";
			}
          }

          var modifyFrame1 = dom.$("modifyFrame1")
          if (modifyFrame1 != null) 
          {
            modifyFrame1.style.height = frameHeight + "px";
            modifyFrame1.style.visibility = "visible";
          }

          var myFlightFrame = dom.$("myFlightFrame");
          if (myFlightFrame != null) 
          {
            frameHeight = str.length * 19.2;
            if (divTag.id == "divFLDepart") 
            {
              myFlightFrame.style.top = "180";
            }
            else if (divTag.id == "divFLArrival") 
            {
              myFlightFrame.style.top = "180";
            }
            myFlightFrame.style.height = frameHeight + "px";
            myFlightFrame.style.visibility = "visible";
          }
          if((myFlightFrame == null)&&(modifyFrame1 == null)&&(myFrame==null))
          {
           if((navigator.userAgent.indexOf("Opera") > -1)&&(first == "true"))
           {
                //myFrame.style.top = (parseInt(myFrame.offsetTop) + 10) + "px";
                divTag.style.top =  (parseInt(divTag.offsetTop) + 10)+ "px";
                first = "false";
            }
          }
          if (i > 0) 
          {
            ShowHideDiv(true);

            // Reset spanNum and scroll to first item.
            spanNum = -1;
            ScrollSpan("down");
            contentHandler.txtTag.focus();
          }
        }
      }
      else 
      {
        divTag.innerHTML = "An error occurred while retrieving data."; //"An error occurred while retrieving data.";
        ShowHideDiv(true);
      }
    }
  }
  catch(e) 
  {
    divTag.innerHTML = "An error occurred while retrieving data."; //"An error occurred while retrieving data.";
    ShowHideDiv(true);
  }
}
function AjaxTransferDDLResponseHandler() 
{
  var divTag = contentHandler.divTag;

  try 
  {
    if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete") 
    {
    
     if (xmlHttp.status == 200) 
      {
      
        
        divTag.innerHTML = "";
      
       
         var responseTxt = xmlHttp.responseText;
        if (responseTxt == "") 
					ShowHideDiv(false);
        else 
        {
          var idx = responseTxt.lastIndexOf("+");
          var str = responseTxt.split("+");
          var suggest = "";
          
          for (i = 0; i < str.length; i++) 
          {
						var thisCity = str[i];
						if (thisCity.toLowerCase() == "no results")
							thisCity = noResults;
							
            suggest += '<p id="dynaSpan' + i + '" class="normalS" onMouseOver="SuggestOver(this)" onMouseOut="SuggestOut(this)" ';
            suggest += 'onClick="Suggest(this)">' + thisCity + '</p>';
          }

//					if (new BrowserSniffer().GetBrowserType() == "cr")
//					{
//						divTag.style.overflow = "scroll";
//					}

          divTag.innerHTML += suggest;
          var frameHeight = str.length * 18;
         
          var myFrame = dom.$("myFrame");
          if (myFrame != null) 
          {
            myFrame.style.height = frameHeight + "px";
            myFrame.style.visibility = "visible";
           if((navigator.userAgent.indexOf("Opera") > -1)&&(first == "true"))
           {
                myFrame.style.top = (parseInt(myFrame.offsetTop) + 10) + "px";
                divTag.style.top =  (parseInt(divTag.offsetTop) + 10)+ "px";
                first = "false";
            }
            if (new BrowserSniffer().GetBrowserType() == "ie")
			{
			    divTag.style.height = frameHeight + "px";
			}
          }

          var modifyFrame1 = dom.$("modifyFrame1")
          if (modifyFrame1 != null) 
          {
            modifyFrame1.style.height = frameHeight + "px";
            modifyFrame1.style.visibility = "visible";
          }

          var myFlightFrame = dom.$("myFlightFrame");
          if (myFlightFrame != null) 
          {
            frameHeight = str.length * 19.2;
            if (divTag.id == "divFLDepart") 
            {
              myFlightFrame.style.top = "180";
            }
            else if (divTag.id == "divFLArrival") 
            {
              myFlightFrame.style.top = "180";
            }
            myFlightFrame.style.height = frameHeight + "px";
            myFlightFrame.style.visibility = "visible";
          }
          if((myFlightFrame == null)&&(modifyFrame1 == null)&&(myFrame==null))
          {
           if((navigator.userAgent.indexOf("Opera") > -1)&&(first == "true"))
           {
                //myFrame.style.top = (parseInt(myFrame.offsetTop) + 10) + "px";
                divTag.style.top =  (parseInt(divTag.offsetTop) + 10)+ "px";
                first = "false";
            }
          }
          if (i > 0) 
          {
            ShowHideDiv(true);

            // Reset spanNum and scroll to first item.
            spanNum = -1;
            ScrollSpan("down");
            contentHandler.txtTag.focus();
          }
        }
      }
      else 
      {
        divTag.innerHTML = "No Hotel Found."; //"An error occurred while retrieving data.";
        ShowHideDiv(true);
      }
    }
  }
  catch(e) 
  {
  
    divTag.innerHTML = "No Hotel Found."; //"An error occurred while retrieving data.";
    ShowHideDiv(true);
  }
}

function KeyHandler(e, divTag, txtTag) 
{
  divTag = document.getElementById(divTag);
  var evt = (window.event) ? event: e;
  if (!evt)
  	evt = window.event;

  var keyCode = evt.keyCode;
  var ENTER = 13;
  var UP = 38;
  var DOWN = 40;
  var TAB = 9;
  var SHIFT = 16;

  contentHandler.divTag = divTag;
  contentHandler.txtTag = txtTag;

  var currValue = contentHandler.txtTag.value;
  switch (keyCode) 
  {
  case ENTER:
    return false;
    break;
  case UP:
    return false;
    break;
  case DOWN:
    return false;
    break;
  case TAB:
    if (IsDivHidden() == true) 
    {
      if ((currValue.length < 3) && (currValue.length > 0))
      	return false;
      else
      	return true;
    }
    else 
    {
      Suggest(contentHandler.selSpanTag);
      ShowHideDiv(false);
      return true;
    }
    break;
  case SHIFT:
    return false;
    break;
  default:
    return true;
    break;
  }
}

function DivKeyHandler(e) 
{

  var evt = (window.event) ? event: e;
  if (!evt)
  	evt = window.event;

  var keyCode = evt.keyCode;
  var BKSPC = 8;
  var TAB = 9;
  var ALT = 18;
  var UP = 38;
  var DOWN = 40;
  var LEFT = 37;
  var RIGHT = 39;
  var ENTER = 13;
  var SHIFT = 16;
  var ESC = 27;

  var currValue = contentHandler.txtTag.value;

  //Return value will determine if fresh request to WS is to be sent.
  // False - No request
  // True - Send request (refresh)
  switch (keyCode) 
  {
  case BKSPC:
    return true;
    break;
  case TAB:
    ShowHideDiv(false);
    return false;
    break;
  case UP:
    ScrollSpan("up");
    return false;
    break;
  case DOWN:
    ScrollSpan("down");
    return false;
    break;
  case ENTER:
    Suggest(contentHandler.selSpanTag);
    ShowHideDiv(false);
    return false;
    break;
  case ESC:
    ShowHideDiv(false);
    return false;
    break;
  default:
    return true;
    break;
  }
}

function ShowHideDiv(show) 
{
  var tag = contentHandler.divTag;
  var bType = new BrowserSniffer().GetBrowserType();
  // Only Show/Hide if not already Shown/Hidden respectively.
  if (bType == "ns") // NS
  {
    if (tag.visibility == "show") 
    {
      if (show == false) 
      {
        tag.visibility = "hide";
        
        var myFrame = dom.$("myFrame");
        if (myFrame != null) 
        {
          myFrame.style.visibility = "hidden";
        }
        
        var myFlightFrame = dom.$("myFlightFrame");
        if (myFlightFrame != null) 
        {
          myFlightFrame.style.visibility = "hidden";
        }
        if (dom.$("modifyFrame") != null) 
        {
          dom.$("modifyFrame").style.visibility = "hidden";
        }
        if (dom.$("modifyFrame1") != null) 
        {
          dom.$("modifyFrame1").style.visibility = "hidden";
        }
      }
    }
    else 
    {	// if tag.visibility == "hide"
      if (show == true) 
      {
        tag.visibility = "show";
        
        var myFrame = dom.$("myFrame");
        if (myFrame != null) 
        {
          myFrame.style.visibility = "visible";
        }
        
        var myFlightFrame = dom.$("myFlightFrame");
        if (myFlightFrame != null) 
        {
          myFlightFrame.style.visibility = "visible";
        }
        if (dom.$("modifyFrame") != null) 
        {
          dom.$("modifyFrame").style.visibility = "visible";
        }
        if (dom.$("modifyFrame1") != null) 
        {
          dom.$("modifyFrame1").style.visibility = "visible";
        }
      }
    }
  }
  else 
  {	// IE or FF
    if (tag.style.visibility == "visible") 
    {
      if (show == false) 
      {
        tag.style.visibility = "hidden";

        var myFrame = dom.$("myFrame");
        if (myFrame != null) 
        {
          myFrame.style.visibility = "hidden";
        }

        var myFlightFrame = dom.$("myFlightFrame")
        if (myFlightFrame != null) 
        {
          myFlightFrame.style.visibility = "hidden";
        }

        if (dom.$("modifyFrame") != null) 
        {
          dom.$("modifyFrame").style.visibility = "hidden";
        }
        if (dom.$("modifyFrame1") != null) 
        {
          dom.$("modifyFrame1").style.visibility = "hidden";
        }
      }
    }
    else     
    {	// if tag.style.visibility == "hidden"
      if (show == true) 
      {
				// Filters disabled upon request of Faraz.
        // tag.style.filter = "progid:DXImageTransform.Microsoft.GradientWipe(GradientSize=0.0,wipestyle=1,motion=forward)";
        // tag.filters(0).Apply();
        // tag.filters(0).Play();
        tag.style.visibility = "visible";

        var myFrame = dom.$("myFrame");
        if (myFrame != null) 
        {
          myFrame.style.visibility = "visible";
        }

        var myFlightFrame = dom.$("myFlightFrame")
        if (myFlightFrame != null) 
        {
          myFlightFrame.style.visibility = "visible";
        }

        if (dom.$("modifyFrame") != null) 
        {
          dom.$("modifyFrame").style.visibility = "visible";
        }
        if (dom.$("modifyFrame1") != null) 
        {
          dom.$("modifyFrame1").style.visibility = "visible";
        }
      }
    }
  }
}

function IsDivHidden() 
{
  var divTag = contentHandler.divTag;
  if (document.layers) 
  {
    if (divTag.visibility == "show")
    	return false;
    else
    	return true;
  }
  else 
  {
    if (divTag.style.visibility == "visible")
    	return false;
    else
    	return true;
  }
}

function SuggestOver(tag) 
{
  tag.className = "highlight";
}

function SuggestOut(tag) 
{
  tag.className = "normalS";
}

function Suggest(tag) 
{
  if (tag != "undefined") 
  {
    var value;
    var bType = new BrowserSniffer().GetBrowserType();
    if (bType == "ie")
    	value = tag.innerText;
    else
    	value = tag.textContent;

    var txtTag = contentHandler.txtTag;
    var divTag = contentHandler.divTag;
    txtTag.value = value;
    ShowHideDiv(false);
    if(dom.$("ctl00_contentMain_ctl00_txtDropoffLocation")!=null || dom.$("ctl00_contentMain_ModifyTransfer_txtDropoffLocation")!=null)
    {
        if(txtTag.id=="ctl00_contentMain_ctl00_txtHTCity" || txtTag.id=="ctl00_contentMain_ModifyTransfer_txtHTCity")
        {
            CopyDestination();
        }
        
    }
    
  }
}

function FocusHandler(tag) 
{
  //		if (document.hasFocus())
  //	
  //  {
  //		checkinputtxt(tag, "", "");
  //	}
  //ShowHideDiv(acFlightFrom, false);
}

var spanNum = -1;
var spanCount = 0;

//function GetSpanItem()
//
// {
//	contentHandler.txtTag.value = contentHandler.divTag.childNodes[spanNum].value;
// }

function ScrollSpan(direction) 
{
  spanCount = contentHandler.divTag.childNodes.length
  if (direction == "down") 
  {
    if (spanNum < spanCount - 1) 
			spanNum += 1;
    else 
			spanNum = 0;
			
    SetColor(spanNum);
  }
  else 
  {
    if (spanNum == 0) 
			spanNum = spanCount - 1;
    else 
			spanNum -= 1;
			
    SetColor(spanNum);
  }
}

function SetColor(spanNo) 
{
  // Turn off highlight for all items.
  for (i = 0; i < spanCount; i++) 
  {
    if (contentHandler.divTag.childNodes[i].className == "highlight")
    	contentHandler.divTag.childNodes[i].className = "normalS";
  }
  // Turn on highlight for selected item.
  contentHandler.divTag.childNodes[spanNo].className = "highlight";
  contentHandler.selSpanTag = contentHandler.divTag.childNodes[spanNo];
}

// UNUSED NOW.
function GetXmlHttpObjectOld() 
{
  var ajax = null;
  try 
  {
    // Firefox, Opera 8.0+, Safari, IE 7
    ajax = new XMLHttpRequest();
  }
  catch(e) 
  {
    // IE 5.x, 6.0
    try 
    {
      ajax = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch(e) 
    {
      ajax = new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
  return ajax;
}

var typePre;
function fnGetState(countryCode, typePrefix,Enquiry) 
{
  typePre = typePrefix;
  txtenquiry = Enquiry
  xmlHttp = new Ajax().GetXmlHttpObject();
  var xmldom = new Ajax().GetXmlHttpObject();
  if (xmlHttp) 
  {
    var webServiceURL;

    webServiceURL = "Validations.aspx?Validate=state&countryCode=" + countryCode
    xmlHttp.open("GET", webServiceURL, true);
    xmlHttp.onreadystatechange = fnStateResult;

    xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

    xmlHttp.send(null);
  }
}

function fnStateResult() 
{

  if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete') 
  {
    if (xmlHttp.status == 200) 
    {
   
      var xmlResult = new Ajax().GetXmlHttpObject();
      var resultReturn = xmlHttp.responseText
      var totalCount
      if (resultReturn != "") 
      {
          var ddlValue = document.getElementById(typePre + "ddlState");
         

          xmlResult = xu.LoadXMLString(resultReturn);
          

        if (ddlValue.length != 0) 
        {
            totalCount = ddlValue.length - 1;

     
            for (var i = totalCount; i != 0; i--)
             {
                ddlValue.options[i] = null;

             }
          
        }  

        // add new items into ddl.
        var nodeCount = new XML().GetNodeCount(xmlResult, "/root/Row");
        for (var i = 0; i <= nodeCount; i++) 
        {
          var j = i - 1;
          if (j == -1) 
          {
            ddlValue.options[i] = new Option("--select--", "--select--");
          }
          else 
          {
            var textField = new XML().SelectNodeValue(xmlResult, "/root/Row[" + i + "]/ProvinceName"); // xmlResult.selectSingleNode("root/Row[" + j + "]/ProvinceName").text
            var valueField = new XML().SelectNodeValue(xmlResult, "/root/Row[" + i + "]/ProvinceCode"); // xmlResult.selectSingleNode("root/Row[" + j + "]/ProvinceCode").text
            if (i == 0) 
            {
              document.getElementById(typePre + "hdnState").value = textField;
            }
            ddlValue.options[i] = new Option(textField, valueField);
          }

        }
        if (document.getElementById(typePre + "hdnState").value == "") 
        {
            document.getElementById(typePre + "ddlState").value = "--select--"
            document.getElementById(typePre + "ddlState").style.display = "block";
            document.getElementById(typePre + "txtState").style.display = "none";
           
        }
        else 
        {
            document.getElementById(typePre + "ddlState").value = document.getElementById(typePre + "hdnState").value
            document.getElementById(typePre + "ddlState").style.display = "block";
            document.getElementById(typePre + "txtState").style.display = "none";
        }
      }
      else 
      {
            document.getElementById(typePre + "ddlState").style.display = "none";
        if(txtenquiry=="Enquiry")
        {
            document.getElementById(typePre + "txtState").style.display = "block";
            document.getElementById(typePre + "ddlState").style.display = "none";
           //document.getElementById(typePre + "ddlState").value = document.getElementById(typePre + "hdnState").value
           }
        else
        {
         document.getElementById(typePre + "txtState").style.display = "block";
        }
     
        document.getElementById(typePre + "hdnState").value = "";
      }
    }
  }
}






/////////////Created By Neeraj Joshi For Car 

function AjaxDDLPickupLocation(e, strProduct) 
{
//debugger;
  if (contentHandler.divTag) 
  {
    var strCompCode, strLangCode
    var currValue = contentHandler.txtTag.value;
		currValue = currValue.replace(/   /g, '')		
		currValue = u2dp(currValue);
    var strQryXML
   //currValue = currValue.replace(/^\s+|\s+$/g, '');
    if ((currValue.length >= 3) && (currValue != "undefined")) 
    {
      if (DivKeyHandler(e) == true) 
      {
        xmlHttp = new Ajax().GetXmlHttpObject();
        if (xmlHttp) 
        {
       //debugger;
          // Commented temporarily because Mozilla debugging only works for local requests.
          var mainService = dom.$("ctl00_hdnSvcMain").value;
          
          if (! (mainService == "") || (mainService == "undefined")) 
          {
            if (dom.$("ctl00_contentMain_ModifyIntFlightSearch1_hndCompCode")!=null)
            {
              strCompCode = dom.$("ctl00_contentMain_ModifyIntFlightSearch1_hndCompCode").value;
              strLangCode = dom.$("ctl00_contentMain_ModifyIntFlightSearch1_hndLangCode").value;
            }
            else if (dom.$("ctl00_contentMain_ModifyFlightSearch1_hndCompCode")!=null)
            {
              strCompCode = dom.$("ctl00_contentMain_ModifyFlightSearch1_hndCompCode").value;
              strLangCode = dom.$("ctl00_contentMain_ModifyFlightSearch1_hndLangCode").value;
            }
            else if (dom.$("ctl00_contentMain_ctl00_hndCompCode")!=null)
            {
              strCompCode = dom.$("ctl00_contentMain_ctl00_hndCompCode").value;
              strLangCode = dom.$("ctl00_contentMain_ctl00_hndLangCode").value;
            }
            else if (dom.$("ctl00_contentMain_ModifyCar_hndCompCode")!=null)
            {
              strCompCode = dom.$("ctl00_contentMain_ModifyCar_hndCompCode").value;
              strLangCode = dom.$("ctl00_contentMain_ModifyCar_hndLangCode").value;
            }
             if(ObjectExists(document.getElementById('ctl00_contentMain_ModifyCar_hdnModifyCar')) && 
        document.getElementById('ctl00_contentMain_ModifyCar_hdnModifyCar').value=="true")
            {
               strCountryCode = dom.$("ctl00_contentMain_ModifyCar_ddlCountry").value;     
               Type = dom.$("ctl00_contentMain_ModifyCar_ddlpickuptype").value;
            }else{
                strCountryCode = dom.$("ctl00_contentMain_ctl00_ddlCountry").value;     
               Type = dom.$("ctl00_contentMain_ctl00_ddlpickuptype").value;
            }
           
           if(Type.toUpperCase() =="AIRPORT")
           {Type="A"}
           else
           {Type="H"}
           if(strCountryCode!='Select')
           {
            strQryXML = escape("<GetCities><CompCode>" + strCompCode + "</CompCode><Prefix>" + currValue + "</Prefix><LangCode>" + strLangCode + "</LangCode><Product>" + strProduct + "</Product><CountryCode>" + strCountryCode + "</CountryCode><Type>" + Type + "</Type></GetCities>");
            var url = mainService + "/GetCitiesForCar?strInputXML=" + strQryXML;
            xmlHttp.onreadystatechange = AjaxDDLResponseHandler;
             xmlHttp.open("GET", url, true);
            xmlHttp.setRequestHeader("Content-Type","text/xml; charset=ISO-8859-1");
            xmlHttp.send(null);
            }
          }
        }
        else 
        {
           alert("Error! Your browser does not seem to support Ajax!");//Error! Your browser does not seem to support Ajax!
        }
      }
    }
    else
    	ShowHideDiv(false);
  }
}





function AjaxDDLDropoffLocation(e, strProduct) 
{
//debugger;
  if (contentHandler.divTag) 
  {
    var strCompCode, strLangCode
    var currValue = contentHandler.txtTag.value;
		currValue = currValue.replace(/   /g, '')		
		currValue = u2dp(currValue);
    var strQryXML
   //currValue = currValue.replace(/^\s+|\s+$/g, '');
    if ((currValue.length >= 3) && (currValue != "undefined")) 
    {
      if (DivKeyHandler(e) == true) 
      {
        xmlHttp = new Ajax().GetXmlHttpObject();
        if (xmlHttp) 
        {
       
          // Commented temporarily because Mozilla debugging only works for local requests.
          var mainService = dom.$("ctl00_hdnSvcMain").value;
          
          if (! (mainService == "") || (mainService == "undefined")) 
          {
            if (dom.$("ctl00_contentMain_ModifyIntFlightSearch1_hndCompCode")!=null)
            {
              strCompCode = dom.$("ctl00_contentMain_ModifyIntFlightSearch1_hndCompCode").value;
              strLangCode = dom.$("ctl00_contentMain_ModifyIntFlightSearch1_hndLangCode").value;
            }
            else if (dom.$("ctl00_contentMain_ModifyFlightSearch1_hndCompCode")!=null)
            {
              strCompCode = dom.$("ctl00_contentMain_ModifyFlightSearch1_hndCompCode").value;
              strLangCode = dom.$("ctl00_contentMain_ModifyFlightSearch1_hndLangCode").value;
            }
            else if (dom.$("ctl00_contentMain_ctl00_hndCompCode")!=null)
            {
              strCompCode = dom.$("ctl00_contentMain_ctl00_hndCompCode").value;
              strLangCode = dom.$("ctl00_contentMain_ctl00_hndLangCode").value;
            }
             if(ObjectExists(document.getElementById('ctl00_contentMain_ModifyCar_hdnModifyCar')) && 
        document.getElementById('ctl00_contentMain_ModifyCar_hdnModifyCar').value=="true")
            {
               strCountryCode = dom.$("ctl00_contentMain_ModifyCar_ddlCountry").value;     
               Type = dom.$("ctl00_contentMain_ModifyCar_ddlpickuptypeReturn").value;
               if(ObjectExists(document.getElementById('ctl00_contentMain_Modify_hndCompCode'))
               && ObjectExists(document.getElementById('ctl00_contentMain_Modify_hndLangCode')))
               {
                    strCompCode = dom.$("ctl00_contentMain_Modify_hndCompCode").value;
                    strLangCode = dom.$("ctl00_contentMain_Modify_hndLangCode").value;
               }
            }else{
                strCountryCode = dom.$("ctl00_contentMain_ctl00_ddlCountry").value;     
               Type = dom.$("ctl00_contentMain_ctl00_ddlpickuptypeReturn").value;
            }
            
           //strCountryCode = dom.$("ctl00_contentMain_ctl00_ddlCountry").value;
           //Type = dom.$("ctl00_contentMain_ctl00_ddlpickuptypeReturn").value;
           
            if(Type.toUpperCase() =="AIRPORT")
           {Type="A"}
           else
           {Type="H"}
           if(strCountryCode!='Select')
           {
            strQryXML = escape("<GetCities><CompCode>" + strCompCode + "</CompCode><Prefix>" + currValue + "</Prefix><LangCode>" + strLangCode + "</LangCode><Product>" + strProduct + "</Product><CountryCode>" + strCountryCode + "</CountryCode><Type>" + Type + "</Type></GetCities>");
            var url = mainService + "/GetCitiesForCar?strInputXML=" + strQryXML;
            xmlHttp.onreadystatechange = AjaxDDLResponseHandler;
             xmlHttp.open("GET", url, true);
            xmlHttp.setRequestHeader("Content-Type","text/xml; charset=ISO-8859-1");
            xmlHttp.send(null);
            }
          }
        }
        else 
        {
           alert("Error! Your browser does not seem to support Ajax!");//Error! Your browser does not seem to support Ajax!
        }
      }
    }
    else
    	ShowHideDiv(false);
  }
}

//Function .....Deepak Kumar Verma

function AjaxDDLDropoffLocation_Tfr(e, strProduct) {
//debugger

//alert('hiiiiiiii')
  if (contentHandler.divTag) 
  {
      var strCompCode, strLangCode, strCountryCode
    var currValue = contentHandler.txtTag.value;
		currValue = currValue.replace(/   /g, '')		
		currValue = u2dp(currValue);
    var strQryXML
   //currValue = currValue.replace(/^\s+|\s+$/g, '');
//   if (dom.$("ctl00_contentMain_ctl00_ddlCountry")!=null)
//    {
//       if( dom.$("ctl00_contentMain_ctl00_ddlCountry").value=="0")
//       {
//        alert("please select country");
//        return false
//       }
//    }
    if ((currValue.length >= 3) && (currValue != "undefined")) 
    {
      if (DivKeyHandler(e) == true) 
      {
        xmlHttp = new Ajax().GetXmlHttpObject();
        if (xmlHttp) 
        {
       
          // Commented temporarily because Mozilla debugging only works for local requests.
          var mainService = dom.$("ctl00_hdnSvcMain").value;
          
          if (! (mainService == "") || (mainService == "undefined")) 
          {
            if (dom.$("ctl00_contentMain_ModifySightSeeing_hndCompCode")!=null)
            {
              strCompCode = dom.$("ctl00_contentMain_ModifySightSeeing_hndCompCode").value;
              strLangCode = dom.$("ctl00_contentMain_ModifySightSeeing_hndLangCode").value;
            }
            else if (dom.$("ctl00_contentMain_ModifyFlightSearch1_hndCompCode")!=null)
            {
              strCompCode = dom.$("ctl00_contentMain_ModifyFlightSearch1_hndCompCode").value;
              strLangCode = dom.$("ctl00_contentMain_ModifyFlightSearch1_hndLangCode").value;
            }
            else if (dom.$("ctl00_contentMain_ctl00_hndCompCode")!=null)
            {
              strCompCode = dom.$("ctl00_contentMain_ctl00_hndCompCode").value;
              strLangCode = dom.$("ctl00_contentMain_ctl00_hndLangCode").value;
            }
            else if (dom.$("ctl00_contentMain_hndCompCode")!=null)
            {
              strCompCode = dom.$("ctl00_contentMain_hndCompCode").value;
              strLangCode = dom.$("ctl00_contentMain_hndLangCode").value;
            }
            if (dom.$("ctl00_contentMain_ddldestinationcountry") != null)
            {
                strCountryCode = dom.$("ctl00_contentMain_ddldestinationcountry").value;
            }
            else if (dom.$("ctl00_contentMain_ctl00_ddlCountry") != null)
            {
                strCountryCode = dom.$("ctl00_contentMain_ctl00_ddlCountry").value;
            }
            else if(dom.$("ctl00_contentMain_ModifySightSeeing_ddlCountry")!=null && strProduct=="SSG")
           {
            strCountryCode = dom.$("ctl00_contentMain_ModifySightSeeing_ddlCountry").value;
           }
           else if(dom.$("ctl00_contentMain_ModifyTransfer_ddlCountry")!=null) {
                
            strCountryCode = dom.$("ctl00_contentMain_ModifyTransfer_ddlCountry").value;
               
           }
           else if(dom.$("ctl00_contentMain_hdnCountryCode")!=null)
           {
            strCountryCode = dom.$("ctl00_contentMain_hdnCountryCode").value;
               
           }
           
           if (dom.$("ctl00_contentMain_ctl00_ddldropOffReturn")!=null)
           {
            Type = dom.$("ctl00_contentMain_ctl00_ddldropOffReturn").value;
           }
           else if(document.getElementById("ctl00_contentMain_ModifyTransfer_ddldropOffReturn")!=null)
           {
            Type  = document.getElementById("ctl00_contentMain_ModifyTransfer_ddldropOffReturn").value 
           }
           else if(document.getElementById("ctl00_contentMain_hdnDropOffCode")!=null)
           {
            Type  = document.getElementById("ctl00_contentMain_hdnDropOffCode").value 
           }
           else
           {
            Type="H"
           }
           
           if(strCountryCode!='Select')
           {
            strQryXML = escape("<GetCities><CompCode>" + strCompCode + "</CompCode><Prefix>" + currValue + "</Prefix><LangCode>" + strLangCode + "</LangCode><Product>" + strProduct + "</Product><CountryCode>" + strCountryCode + "</CountryCode><Type>" + Type + "</Type></GetCities>");
            var url = mainService + "/GetCitiesForCar?strInputXML=" + strQryXML;
            xmlHttp.onreadystatechange = AjaxDDLResponseHandler;
             xmlHttp.open("GET", url, true);
            xmlHttp.setRequestHeader("Content-Type","text/xml; charset=ISO-8859-1");
            xmlHttp.send(null);
            }
          }
        }
        else 
        {
           alert("Error! Your browser does not seem to support Ajax!");//Error! Your browser does not seem to support Ajax!
        }
      }
    }
    else
    	ShowHideDiv(false);
  }
}


//priyanka


//Function .......Deepak Kumar Verma

function AjaxDDLPickupLocation_Tfr(e, strProduct) 
{
  if (contentHandler.divTag) 
  {
    var strCompCode, strLangCode
    var currValue = contentHandler.txtTag.value;
		currValue = currValue.replace(/   /g, '')		
		currValue = u2dp(currValue);
    var strQryXML
   //currValue = currValue.replace(/^\s+|\s+$/g, '');
//    if (dom.$("ctl00_contentMain_ctl00_ddlCountry")!=null)
//    {
//       if( dom.$("ctl00_contentMain_ctl00_ddlCountry").value=="0")
//       {
//        alert("please select country");
//        return false
//       }
//    }
    
    if ((currValue.length >= 3) && (currValue != "undefined")) 
    {
      if (DivKeyHandler(e) == true) 
      {
        xmlHttp = new Ajax().GetXmlHttpObject();
        if (xmlHttp) 
        {
      
          // Commented temporarily because Mozilla debugging only works for local requests.
          var mainService = dom.$("ctl00_hdnSvcMain").value;
          
          if (! (mainService == "") || (mainService == "undefined")) 
          {
            if (dom.$("ctl00_contentMain_ModifySightSeeing_hndCompCode")!=null)
            {
              strCompCode = dom.$("ctl00_contentMain_ModifySightSeeing_hndCompCode").value;
              strLangCode = dom.$("ctl00_contentMain_ModifySightSeeing_hndLangCode").value;
            }
            else if (dom.$("ctl00_contentMain_ModifyFlightSearch1_hndCompCode")!=null)
            {
              strCompCode = dom.$("ctl00_contentMain_ModifyFlightSearch1_hndCompCode").value;
              strLangCode = dom.$("ctl00_contentMain_ModifyFlightSearch1_hndLangCode").value;
            }
            else if (dom.$("ctl00_contentMain_ctl00_hndCompCode")!=null)
            {
              strCompCode = dom.$("ctl00_contentMain_ctl00_hndCompCode").value;
              strLangCode = dom.$("ctl00_contentMain_ctl00_hndLangCode").value;
            }
            else if (dom.$("ctl00_contentMain_hndCompCode")!=null)
            {
              strCompCode = dom.$("ctl00_contentMain_hndCompCode").value;
              strLangCode = dom.$("ctl00_contentMain_hndLangCode").value;
            }
          if (dom.$("ctl00_contentMain_ctl00_ddlCountry")!=null)
          {
           strCountryCode = dom.$("ctl00_contentMain_ctl00_ddlCountry").value;
           }
            else if(dom.$("ctl00_contentMain_ModifyTransfer_ddlCountry")!=null)
           {
             strCountryCode = dom.$("ctl00_contentMain_ModifyTransfer_ddlCountry").value;
             strLangCode = dom.$("ctl00_contentMain_ModifyTransfer_hndLangCode").value;
             strCompCode = dom.$("ctl00_contentMain_ModifyTransfer_hndCompCode").value;
           }
           else if(dom.$("ctl00_contentMain_hdnCountryCode")!=null)
           {
            strCountryCode = dom.$("ctl00_contentMain_hdnCountryCode").value;
           
           }
          
           
           
               if (dom.$("ctl00_contentMain_ctl00_ddlpickuptype")!=null)
               {
                Type = dom.$("ctl00_contentMain_ctl00_ddlpickuptype").value;
               }
               else if(document.getElementById("ctl00_contentMain_ModifyTransfer_ddlpickuptype")!=null)
               {
                Type = document.getElementById("ctl00_contentMain_ModifyTransfer_ddlpickuptype").value
               }
               else if(document.getElementById("ctl00_contentMain_hdnPickupCode")!=null)
               {
                  Type = document.getElementById("ctl00_contentMain_hdnPickupCode").value
                  
               }
               else
               {
                Type="H"
               }
           
           if(strCountryCode!='Select')
           {
            strQryXML = escape("<GetCities><CompCode>" + strCompCode + "</CompCode><Prefix>" + currValue + "</Prefix><LangCode>" + strLangCode + "</LangCode><Product>" + strProduct + "</Product><CountryCode>" + strCountryCode + "</CountryCode><Type>" + Type + "</Type></GetCities>");
            var url = mainService + "/GetCitiesForCar?strInputXML=" + strQryXML;
            xmlHttp.onreadystatechange = AjaxDDLResponseHandler;
             xmlHttp.open("GET", url, true);
            xmlHttp.setRequestHeader("Content-Type","text/xml; charset=ISO-8859-1");
            xmlHttp.send(null);
            }
          }
        }
        else 
        {
           alert("Error! Your browser does not seem to support Ajax!");//Error! Your browser does not seem to support Ajax!
        }
      }
    }
    else
    	ShowHideDiv(false);
  }
}


function AjaxGetHotelName(e,CityCode) 
{
  if (contentHandler.divTag) 
  {
   var CityCode 
    var currValue = contentHandler.txtTag.value;
		currValue = currValue.replace(/   /g, '')		
		currValue = u2dp(currValue);
    var strQryXML
   //currValue = currValue.replace(/^\s+|\s+$/g, '');
    if ((currValue.length >= 3) && (currValue != "undefined")) 
    {
       
      if (DivKeyHandler(e) == true) 
      {
        xmlHttp = new Ajax().GetXmlHttpObject();
        if (xmlHttp) 
        {
         
           var supplierCode = dom.$("ctl00_contentMain_hdnSupplierCode").value;
          var header = dom.$("ctl00_contentMain_hdnHeaderXml").value;
        
          strQryXML = escape("<HotelList>" + header + "<SearchQuery><CCode>" + supplierCode + "</CCode><CityCode>" + CityCode + "</CityCode><HotelName>" + currValue + "</HotelName></SearchQuery></HotelList>")
          if (xmlHttp)
           {
               var webServiceURL;
                webServiceURL= "SSDetails.aspx?HotelsName=hotelName&strInputXML=" + strQryXML
                xmlHttp.onreadystatechange = AjaxTransferDDLResponseHandler;
                xmlHttp.open("GET", webServiceURL, true);
                xmlHttp.setRequestHeader("Content-Type","text/xml; charset=ISO-8859-1");
                xmlHttp.send(null);
            
//               xmlHttp.open("GET", webServiceURL, true);
//               xmlHttp.onreadystatechange = AjaxDDLResponseHandler;
//               //xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
//               xmlHttp.setRequestHeader("Content-Type","text/xml; charset=ISO-8859-1");
//               xmlHttp.send(null);
           }
          
        }
        else 
        {
           alert("Error! Your browser does not seem to support Ajax!");//Error! Your browser does not seem to support Ajax!
        }
      }
    }
    else
    	ShowHideDiv(false);
  }
}

