//preloading one image
/*
var roll1 = new Image();
roll1.src = "images/menu_left_hover.gif";
var roll2 = new Image();
roll2.src = "images/menu_right_hover.gif";

function findObj(theObj, theDoc)
{
  var p, i, foundObj;
  
  if(!theDoc) theDoc = document;
  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
  {
    theDoc = parent.frames[theObj.substring(p+1)].document;
    theObj = theObj.substring(0,p);
  }
  if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
  for (i=0; !foundObj && i < theDoc.forms.length; i++) 
    foundObj = theDoc.forms[i][theObj];
  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
    foundObj = findObj(theObj,theDoc.layers[i].document);
  if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
  
  return foundObj;
}

function overIt(obj) {
	var m = findObj(obj + "_left");
	m.src = "images/menu_left_hover.gif";
	var m = findObj(obj + "_right");
	m.src = "images/menu_right_hover.gif";
}

function outIt(obj) {
	var m = findObj(obj + "_left");
	m.src = "images/menu_left.gif";
	var m = findObj(obj + "_right");
	m.src = "images/menu_right.gif";
}
*/

// This method is called from Reservation.aspx page.  All objects
// used in this method are defined in Reservation.aspx page
function setLocationOnReservationForm(listBox, textBox)
{
    if (listBox[listBox.selectedIndex].value != "[Select]")
        textBox.value = listBox[listBox.selectedIndex].value;
}

// This method is called from Reservation.aspx page.  All objects
// used in this method are defined in Reservation.aspx page
function showHidePickupAirportDiv(listBox)
{
    var divPAd = document.getElementById('divPickupAddress');
    var divPAir = document.getElementById('divPickupAirport');
    if (listBox[listBox.selectedIndex].value == "[Select]")
    {
        divPAd.style.display = '';
        divPAir.style.display = 'none';    
    }
    else
    {
        divPAd.style.display = 'none';
        divPAir.style.display = '';
    }
}

// This method is called from Fares.aspx page.  All objects
// used in this method are defined in Fares.aspx page
function ShowHideLocalInter(which)
{
    var location = '';
    var divControl = null;
    if (which == 'pickup')
    {
        divControl = document.getElementById('divPickupLocalInter');
        location = cmbPickupLocation.GetText();
    }
    else if (which == 'dropoff')
    {
        divControl = document.getElementById('divDropoffLocalInter');
        location = cmbDropoffLocation.GetText();
    }
    
    //alert(location);
    //alert(divControl);
    if (divControl != null)
    {
        if (location == 'EWR' || location == 'LGA' || location == 'JFK' || location == 'TAP' || location == 'WAP')
        {
            divControl.style.display = '';
        }
        else
        {
            divControl.style.display = 'none';
        }    
    }
}

// This method is called from Fares.aspx page.  All objects
// used in this method are defined in Fares.aspx page
function CalculatePrice()
{
    lblPrice.SetValue('Please wait while calculating...');
    
    var pickupLocation = cmbPickupLocation.GetText();
    var pickupDomesticChecked = radPickupDomestic.checked;            
    var pickupInterChecked = radPickupInter.checked;
    var pickupTimeValue = ddlPickupTime.value;
    var pickupAMPMValue = ddlPickupAMPM.value;
        
    var dropoffLocation = cmbDropoffLocation.GetText();
    var dropoffDomesticChecked = radDropoffDomestic.checked;
    var dropoffInterChecked = radDropoffInter.checked;
    var dropoffTimeValue = ddlDropoffTime.value;
    var dropoffAMPMValue = ddlDropoffAMPM.value;

    var vals = pickupLocation + "|" + dropoffLocation + "|" +
               pickupDomesticChecked + "|" + dropoffDomesticChecked + "|" +
               pickupInterChecked + "|" + dropoffInterChecked + "|" +
               pickupTimeValue + "|" + dropoffTimeValue + "|" +
               pickupAMPMValue + "|" + dropoffAMPMValue;
    
    //alert(vals);
    callBackPrice.SendCallback(vals);        
    //alert("done");        
}

// This method is called from Fares.aspx page.  All objects
// used in this method are defined in Fares.aspx page
function SendQuoteEMail()
{
    var result = "";

    var quoteYourName = txbQuoteYourName.value;
    var quoteYourEMail = txbQuoteYourEMail.value;
    var quoteYourPhone = txbQuoteYourPhone.value;
    var quotePickupLocation = txbQuotePickupLocation.value;
    var quoteDropoffLocation = txbQuoteDropoffLocation.value;
    var quotePickupTime = ddlQuotePickupTime.value;
    var quotePickupAMPM = ddlQuotePickupAMPM.value;
    
    if (quoteYourName == "")
        result = "Error: Your Name is required.";
    else if (quoteYourEMail == "")
        result = "Error: Your E-Mail is required.";
    else if (quoteYourEMail.indexOf('@') < 0 || quoteYourEMail.indexOf('.') < 0)
        result = "Error: E-Mail is invalid.";
    else if (quoteYourPhone == "")
        result = "Error: Your Phone is required.";
    else if (quotePickupLocation == "")
        result = "Error: Pickup Location is required.";
    else if (quoteDropoffLocation == "")
        result = "Error: Dropoff Location is required.";            
    
    if (result != "")
    {
        lblQuoteResponse.SetValue(result);
    }
    else
    {
        var vals = quoteYourName + "|" +
                quoteYourEMail + "|" +
                quoteYourPhone + "|" +
                quotePickupLocation + "|" +
                quoteDropoffLocation + "|" +
                quotePickupTime + "|" +
                quotePickupAMPM;
        callBackQuote.SendCallback(vals);        
    }
    //alert("done");        
}

// This method is called from Fares.aspx page.  All objects
// used in this method are defined in Fares.aspx page
function UpdateFromCallbackPrice(result)
{
    try
    {
        var resultArray = result.split('|');
        
        //alert(resultArray[0] + "\r\n" + resultArray[1] + "\r\n" + resultArray[2] + "\r\n" + resultArray[3]);
        
        lblPrice.SetValue(resultArray[1]);
        lblError.SetValue('');
        if (resultArray[0] != ' ')
            lblError.SetValue(resultArray[0]);        
        //alert(lblError.GetValue());
        cmbPickupLocation.SetText(resultArray[2]);
        cmbDropoffLocation.SetText(resultArray[3]);
        
        if (resultArray[1] != '' && resultArray[1] != 'N/A')
            lblSalesTax.SetValue(' + 7% NJ Sales Tax');
        else
            lblSalesTax.SetValue('');
        
    }
    catch(err)
    {
        ;
    }
}
    
// This method is called from Fares.aspx page.  All objects
// used in this method are defined in Fares.aspx page
function UpdateFromCallbackQuote(result)
{
    try
    {
        lblQuoteResponse.SetValue(result);    
    }
    catch(err)
    {
        ;
    }  
}
