// JavaScript Document

<!--

function formCheck(formobj){
	//1) Enter name of mandatory fields
	var fieldRequired = Array("Form_Sent_By", "realname", "Telephone", "email");
	//2) Enter field description to appear in the dialog box
	var fieldDescription = Array("Form Completed By", "Name ", "Daytime Telephone", "Email",  "Make", "Model Name", "Model Details", "Contract Type", "Contract Term", "Annual Mileage", "Include Maintenance");
	//3) Enter dialog message
	var alertMsg = "Please complete the following required fields:\n";
	
	var alertMsgconfirm = "Please take a moment to verify your contact details." + '\n' + "Click on 'Cancel' to return to the page and correct an entry" + '\n' + "or click 'OK' to proceed.\n\n\n";
	
	var l_Msg = alertMsg.length;
	
	for (var i = 0; i < fieldRequired.length; i++){
		var obj = formobj.elements[fieldRequired[i]];
		if (obj){
			switch(obj.type){
			case "select-one":
				if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == "" || obj.options[obj.selectedIndex].text == "Please Select" || obj.options[obj.selectedIndex].text == "Not required for Personal Contracts"){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				else 
				if (obj.selectedIndex != -1 || obj.options[obj.selectedIndex].text != "" || obj.options[obj.selectedIndex].text != "Please Select" || obj.options[obj.selectedIndex].text != "Not required for Personal Contracts"){
					alertMsgconfirm += " # " + fieldDescription[i] + " - " + obj.options[obj.selectedIndex].text + "\n\n";
				}
				break;
			case "select-multiple":
				if (obj.selectedIndex == -1){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "value":
			if (obj.value == "Please Select" || obj.value == null){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
			case "text":
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				else 
				if (obj.value != "" || obj.value != null){
					alertMsgconfirm += " # " + fieldDescription[i] + " - " + obj.value + "\n\n";
				}
				break;
			case "textarea":
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				else 
				if (obj.value != "" || obj.value != null){
					alertMsgconfirm += " # " + fieldDescription[i] + " - " + obj.value + "\n\n";
				}
				break;
			default:
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
			}
		}
	}

	if (alertMsg.length == l_Msg){
		//alert(alertMsgconfirm);
		return confirm(alertMsgconfirm);
		//return true;
	}else{
		alert(alertMsg);
		return false;
		
	}
}
function verify(){
	formCheck(formobj)
       //we get the values in the form out of the 0 index in the forms[] array since it's the only form in the document
       msg = "Please Verify the Information you Entered: \n\n Lease Term: " + document.forms[0].term.value + "\n Annual Mileage: " + document.forms[0].mileage.value + "\n\n If this information is correct, click 'OK'"
       return confirm(msg);
}

//-->

