function switchImage(img,id){
	var button = document.getElementById(id);
	button.style.backgroundImage = "url("+img+")";
}

function showImage(img) {
	picture = window.open (img,'FastFire','status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,height=530,width=800');
	picture.moveTo(100,100);
}

function validateForm() {
	// Verify required fields are not empty, if they are, 
	// kick out a message and exit fcn

	// List of Required Fields:
	// - email
	// - password
	// - password2 (must match password)
	// - fname
	// - lname
	// - company
	// - resale
	// - phone

	var errorMsg = "";
	var appForm = document.getElementById('application_form');

	// Note: this could be much more sophisticated; i.e. you could mark each empty field.
	// 		 For that matter, you could employ AJAX techniques to indicate required fields
	//		 prior to submission.
	//		 Also, a summary screen showing all values could be shown before submission.

	// Make sure required fields are not empty
	if (appForm.elements["email"].value == "") errorMsg="Email is a required field.  Please fill-out and re-submit the form.";
	if (appForm.elements["password"].value == "") errorMsg="Password is a required field.  Please fill-out and re-submit the form.";
	if (appForm.elements["password2"].value == "") errorMsg="Your password must be entered twice.  Please fill-out and re-submit the form.";
	if (appForm.elements["fname"].value == "") errorMsg="First Name is a required field.  Please fill-out and re-submit the form.";
	if (appForm.elements["lname"].value == "") errorMsg="Last Name is a required field.  Please fill-out and re-submit the form.";
	if (appForm.elements["company"].value == "") errorMsg="Company Name is a required field.  Please fill-out and re-submit the form.";
	if (appForm.elements["resale"].value == "") errorMsg="Resale License is a required field.  Please fill-out and re-submit the form.";
	if (appForm.elements["phone"].value == "") errorMsg="Phone is a required field.  Please fill-out and re-submit the form.";

	// Make sure passwords match
	if (appForm.elements["password"].value != appForm.elements["password2"].value) errorMsg="Passwords must match.  Please check entered passwords and re-submit the form.";

	// Should check for duplicate record (existing email) before allowing
	//	Need PHP script to run the check
	// Requires jQuery, data will be 0 or 1
	//var duplicate="";
	//var email = appForm.elements["email"].value;
	//$.get("checkEmail.php",{email: email},function(data){
	/*
	$.get("http://www.fast-fire.com/checkEmail.php",{email: "harlan.shoop@gmail.com"}, function(data){
		alert("Return: "+data);
	});

	$.ajax({
		type: "POST",
		url: "checkEmail.php",
		data: 'email="harlan.shoop@gmail.com"';
		success: function(){
			alert("Email Validation");
		}
	});
	*/
	// may want to do some additional validation here

	if (errorMsg == "") {
		//alert("Submitting form");
		appForm.submit();
	} else {
		alert(errorMsg);
		// exit without doing anything else
	}

}

function dealerLogin() {
	var errorMsg = "";
	var loginForm = document.getElementById('login_form');
	var email = loginForm.elements["email"].value;
	var password = loginForm.elements["password"].value;

	if (email == "") errorMsg="No email address provided.";
	if (password == "") errorMsg="No password provided.";

	if (errorMsg == "") {
		loginForm.submit();
	} else {
		alert(errorMsg);
	}
}
