// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

image0 = new Image();
image0.src = "/images/buttons_off_1.jpg";

image1 = new Image();
image1.src = "/images/buttons_off_2.jpg";

image2 = new Image();
image2.src = "/images/buttons_off_3.jpg";

image3 = new Image();
image3.src = "/images/buttons_off_4.jpg";

image4 = new Image();
image4.src = "/images/buttons_off_5.jpg";


/* fade flashes automatically */
Event.observe(window, 'load', function() { 
  $A(document.getElementsByClassName('alert')).each(function(o) {
    o.opacity = 40.0
    Effect.Fade(o, {duration: 4.0})
  });
});

function sameShip() {
	if(document.getElementById("cart_shipSame").checked)
	{
        document.getElementById("cart_shipping_title").value = document.getElementById("cart_title").value;
        document.getElementById("cart_shipping_first").value = document.getElementById("cart_first_name").value;
        document.getElementById("cart_shipping_last").value = document.getElementById("cart_last_name").value;
        document.getElementById("cart_shipping_company").value = document.getElementById("cart_company").value;
        document.getElementById("cart_shipping_address1").value = document.getElementById("cart_address1").value;
        document.getElementById("cart_shipping_address2").value = document.getElementById("cart_address2").value;
        document.getElementById("cart_shipping_city").value = document.getElementById("cart_city").value;
        document.getElementById("cart_shipping_state").value = document.getElementById("cart_state").value;
        document.getElementById("cart_shipping_zip").value = document.getElementById("cart_zip").value;
		document.getElementById("cart_shipping_country").value = document.getElementById("cart_country").value;
	}
	else   {
        document.getElementById("cart_shipping_title").value = "";
        document.getElementById("cart_shipping_first").value = "";
        document.getElementById("cart_shipping_last").value = "";
        document.getElementById("cart_shipping_company").value = "";
        document.getElementById("cart_shipping_address1").value = "";
        document.getElementById("cart_shipping_address2").value = "";
        document.getElementById("cart_shipping_city").value = "";
        document.getElementById("cart_shipping_state").value = "";
        document.getElementById("cart_shipping_zip").value = "";
		document.getElementById("cart_shipping_country").value = "";
	}
}

function check_contact() {
	var smsg = '';
	
	if (document.getElementById('contact_name').value == '') { smsg += '\nPlease enter your name.';	}	
	if (document.getElementById('contact_email').value == '') { smsg += '\nPlease enter your email.'; }	
	
	if (smsg != '') {
		alert('Please review the following errors and correct:\n' + smsg);
		return false;
	}
	else {
		return true;
	}
}	

function check_directions() {
	var smsg = '';
	
	if (document.getElementById('from_address').value == '') { smsg += '\nPlease enter your address.'; }
	if (document.getElementById('from_city').value == '') { smsg += '\nPlease enter your city.'; }	
	if (document.getElementById('from_state').value == '') { smsg += '\nPlease enter your state.'; }	
	if (document.getElementById('from_zip').value == '') { smsg += '\nPlease enter your zipcode.'; }			
	
	if (smsg != '') {
		smsg = 'Please review the following errors and correct:\n' + smsg
	}
	
	return smsg;

}	

function check_calcgm() {
	var smsg = '';
	
	if (document.getElementById('fuel_lbhr').value == '') { smsg += '\nPlease enter Fuel lb/hr.';	}	
	
	if (smsg != '') {
		alert('Please review the following errors and correct:\n' + smsg);
		return false;
	}
	else {
		return true;
	}
}	

function check_calcfuel() {
	var smsg = '';
	
	if (document.getElementById('fuel_galmin').value == '') { smsg += '\nPlease enter gal/min.'; }
	if (document.getElementById('fuel_length').value == '') { smsg += '\nPlease enter Fuel Line Length-ft.'; }
	if (document.getElementById('fuel_hoseid').value == '') { smsg += '\nPlease enter hose ID in.';	}	
	if (document.getElementById('fuel_density').value == '') { smsg += '\nPlease enter Density-SG.'; }
	if (document.getElementById('fuel_elevation').value == '') { smsg += '\nPlease enter Fuel rail elevation-ft.'; }	
	
	if (smsg != '') {
		alert('Please review the following errors and correct:\n' + smsg);
		return false;
	}
	else {
		return true;
	}
}	