﻿// JScript File

function ResetContinents()
{
    lDropDown = document.getElementById("ctl00_ContentPlaceHolder1_ddl_ContinentSearch");
    lDropDown.SelectedIndex  = -1;
    alert("fired");
}

function ClearDropDown(pDropDown)
{
    for (var i= pDropDown.options.length; i > 0; i--)
    {
         pDropDown.options[i]=null;
    }
}
function GetCountries()
{
    lDropDown = document.getElementById("ctl00_ContentPlaceHolder1_ddl_Country");
    
    lResult = Index.GetCountries(document.getElementById("ctl00_ContentPlaceHolder1_ddl_ContinentSearch").value );
    if (lResult.value != null)
    {
        ClearDropDown(lDropDown);
        lResultArray = lResult.value.split("|");
        if (lResultArray.length > 1)
        {
            lDropDown.options[0] = new Option("Select a Country", "");
            for (i =0;  i < lResultArray.length -1; i++) 
	        {
	            lRecord = lResultArray[i].split("~");
	            lDropDown.options[i+1] = new Option(lRecord[0], lRecord[0]);
	        }
        
        }
    }
    
}


function GetCountries_SP()
{
    lDropDown = document.getElementById("ctl00_ContentPlaceHolder2_ddl_Country");
    lResult = Search.GetCountries(document.getElementById("ctl00_ContentPlaceHolder2_ddl_ContinentSearch").value );
    if (lResult.value != null)
    {
        ClearDropDown(lDropDown);
        lResultArray = lResult.value.split("|");
        if (lResultArray.length > 1)
        {
            lDropDown.options[0] = new Option("Select a Country", "");
            for (i =1;  i < lResultArray.length -1; i++) 
	        {
	            lRecord = lResultArray[i].split("~");
	            lDropDown.options[i] = new Option(lRecord[0], lRecord[0]);
	        }
        
        }
    }
    
}

function JoinMailingList()
{

    if (
    document.getElementById("ctl00_ContentPlaceHolder2_edt_EmailAddress").value != null &&
    document.getElementById("ctl00_ContentPlaceHolder2_edt_EmailAddress").value != "" &&
    document.getElementById("ctl00_ContentPlaceHolder2_rev_Email").style.visibility == "hidden"    )
    {
        lEmailAddress = document.getElementById("ctl00_ContentPlaceHolder2_edt_EmailAddress").value;
        Index.JoinEmailList(lEmailAddress);
        document.getElementById("ctl00_ContentPlaceHolder2_edt_EmailAddress").value ="";
        alert("You email address has been added to our Ultitude Insider's list");
      
    }
    else 
    {
        alert("Your email address seems incorrect. Please try again.");
        document.getElementById("ctl00_ContentPlaceHolder2_edt_EmailAddress").focus();
       
    }


  
}

function GetAirportCities()
{
    lDropDown = document.getElementById("ctl00_ContentPlaceHolder2_ddl_DepartureCity");
    lResult = SSL_Book_Online.GetAirportCities(document.getElementById("ctl00_ContentPlaceHolder2_ddl_DepartureState").value );
    if (lResult.value != null)
    {
        ClearDropDown(lDropDown);
        lResultArray = lResult.value.split("|");
        if (lResultArray.length > 1)
        {
            lDropDown.options[0] = new Option("Select a City", "");
            for (i =1;  i < lResultArray.length -1; i++) 
	        {
	            lRecord = lResultArray[i].split("~");
	            lDropDown.options[i] = new Option(lRecord[1]+ "-"+lRecord[3], lRecord[1]+ "-"+lRecord[3]+"("+lRecord[2]+")");
	        }
        
        }
    }
    
}
