﻿function Show(sElement) {
if ( document.getElementById(sElement) != null ) {
    document.getElementById(sElement).style.display = 'block' ; }
}
    
function Hide(sElement) {
if ( document.getElementById(sElement) != null ) {
    document.getElementById(sElement).style.display = 'none' ; }
}
    
function Focus(sElement) {
if ( document.getElementById(sElement) != null ) {
        document.getElementById(sElement).focus() ; }
} 

function NotPersonalEffects() {

    notpersonaleffects = false ;

    if (document.getElementById('quote_form_Packing_Section') == null)  
        {
            notpersonaleffects = true ;
        }
    
    return notpersonaleffects

} 

function ShowHideDepartState(DepartureCountry) {

	if (DepartureCountry == 'United States of America') {
	    Show('quote_form_DepartStateSection') ;
	    Hide('quote_form_Departure_City_Section') ;
	    }	
	else {
	    Show('quote_form_Name_Section') ;
	    Hide('quote_form_DepartStateSection') ;
	    Show('quote_form_Departure_City_Section') ;
	     }

	Show('quote_form_Tel_Number_Section') ;
}

function ShowHidePackingDescription(PackingOption) {

	if (PackingOption == 'Other') {
		Show('quote_form_Packing_Description_Section') ;
	    Focus('quote_form_Packing_Description'); 
	    }	
	else {
	    Hide('quote_form_Packing_Description_Section') ;
	    Focus('quote_form_Moving_Month');	
	     }
}

function ShowHideArriveState(ArrivalCountry,DepartureCountry) {

	if (ArrivalCountry == 'United States of America') 
	    {  Show('quote_form_ArriveStateSection') ;
	        
	        if ( NotPersonalEffects()) {
	            Hide('quote_form_Arrival_City_Section') ; }
        }
	else {
		Hide('quote_form_ArriveStateSection') ;
		Show('quote_form_Arrival_City_Section') ;
	    
	    if (DepartureCountry == 'United States of America' && 
	        NotPersonalEffects()) 
	        {
	        /* Add Tel Number 250209 */
	        /* Start 
	        Hide('quote_form_Tel_Number_Section') ;
	        End */
	        Hide('quote_form_Name_Section') ; 
	        }
	    else {
	    	Show('quote_form_Tel_Number_Section') ;
	        Show('quote_form_Name_Section') ; 
	        }	       
	    }
}

function GoToInterstate(ArrivalCountry,DepartureCountry) {

	if (ArrivalCountry == 'United States of America' && 
        DepartureCountry == 'United States of America' &&
	    window.location.href.indexOf('uote.aspx') == -1 ) {
        if ( confirm('Ooops! This form is for International Car Shipping only. If you are shipping within the US click OK to go to our Interstate quote form or CANCEL to continue with your overseas enquiry.') ) {
                     window.location='http://www.autocarshippers.com/Car_Movers_Auto_Transport_USA.html'; }
	    } 
}

function HideSections(theValue) {
   
    if (theValue != 'United States of America') {
        Hide('quote_form_DepartStateSection') ; 
        Show('quote_form_Departure_City_Section') ; 
        }
    else {
        Show('quote_form_DepartStateSection') ; 
        if ( NotPersonalEffects() ) {
            Hide('quote_form_Departure_City_Section') ; } 
        }            
 
    if ( document.getElementById('quote_form_Arrive_Country_Section') != null ) {
      Hide('quote_form_ArriveStateSection') ; 
      }
   
    if (NotPersonalEffects()) {
        Hide('quote_form_Arrival_City_Section') ;
        Hide('quote_form_Confirm_Email_Section') ; }
 
    /* If the arrive country section is there this is not an interstate lead so
    we hide the name and telephone number unless this is
    a personal effects lead so we show them */
   
    if ( document.getElementById('quote_form_Arrive_Country_Section') != null &&
        NotPersonalEffects() )
    {
        Hide('quote_form_Name_Section') ;
        Hide('quote_form_Tel_Number_Section') ; 
        }
      
    Focus('quote_form_Shipment_Type') ;
}

function ValidatePage() {

    progress = true ;
    
    if (document.getElementById('quote_form_ArriveStateSection').style.display != 'none') {
        if (document.getElementById('quote_form_Arrive_State').selectedIndex==0) {
            progress = false;
            alert('Please select an arrival state') ;
            }
        }

    if (document.getElementById('quote_form_DepartStateSection').style.display != 'none' ) {
        if (document.getElementById('quote_form_Depart_State').selectedIndex==0) {
            progress = false;
            alert('Please select a departure state') ;
            }
        }
          
    return progress;
}

function OpenCalculator() {
    openWindow = window.open("calculator.htm","Calculator","width=600,height=600,scrollbars=yes");
}

function updateVolume(volume) {
    document.getElementById('quote_form_Size').value=volume;
    document.getElementById('quote_form_Measurement').selectedIndex=1;
    Focus('quote_form_Moving_Month');
}

function updateItemsString(items) {
    document.getElementById('quote_form_Extra_Information').value= items ;
}
