/**
* DVMarina.com
* The California Parks Company
*/

$(document).ready(function(){ 
	$("#JobsPageJobOpportunities").addClass("tundra");
}); 

//To force visitors to agree with our Terms & Conditions for boat reservations
function checkCheckBox(policy) {
  if (policy.agree.checked == true) {
	changeURL();
	return true;
	}
  else{
	alert('You must accept our Reservation and\nGeneral Use Policies to continue.');
	return false;
  }		
}

//URL redirection
function changeURL(){
	window.setTimeout('window.location="https://rezweb.com/calparks/default.asp"; ',1000);
}

//To change background color on focus
function changeBg(box){
	box.style.backgroundColor = "#F4F2E3";		
}

//Contact us form validation starts
//This function is used to trim any string value using javascript
function trimString (str) {
  return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
}

//This function is used for email validation
function isValid(str) {
	var emailFilter=/^.+@.+\..{2,3}$/;
	if (!(str.match(emailFilter))) { 
        return false;
	}
	else {
		return true;
	}
}

//Contact us form validation starts 
function validateEmailFrm(){
	var errorMsg = "";
	var frm=document.frm;
	var i = 0;

	var regStr = /^[a-zA-Z ]+$/;	
	var regStr1 = /^[a-zA-Z0-9 ]+$/;	

	var fname=trimString(frm.firstname.value);
	var lname=trimString(frm.lastname.value);

	var nmStr = /^[0-9.+]+$/;	
	

	for( i=0; i<frm.elements.length; i++ )  {

		if(frm.elements[i].name == "firstname" && (trimString(frm.elements[i].value)) == "") {
			errorMsg += "- First Name is required\n";
		}		
		if(frm.elements[i].name == "firstname" && (trimString(frm.elements[i].value)) != "") {
			if(!fname.match(regStr)) {
				errorMsg += "- Only letters are allowed in the \"First Name\"\n";
			}
		}
		if(frm.elements[i].name == "lastname" && (trimString(frm.elements[i].value)) == "") {
			errorMsg += "- Last Name is required\n";
		}		
		if(frm.elements[i].name == "lastname" && (trimString(frm.elements[i].value)) != "") {
			if(!lname.match(regStr)) {
				errorMsg += "- Only letters are allowed in the \"Last Name\"\n";
			}
		}
		if(frm.elements[i].name == "email" && (trimString(frm.elements[i].value)) == "") {
			errorMsg += "- Email address is required\n";
		}
		if(frm.elements[i].name == "email" && (trimString(frm.elements[i].value)) != "") {			
			var emvar=trimString(frm.elements[i].value);
			if(!isValid(emvar)) {
				errorMsg += "- The email address that you entered is not valid\n";
			}
		}
		if(frm.elements[i].name == "phone" && (trimString(frm.elements[i].value)) == "") {
			errorMsg += "- Phone number is required\n";
		}			
		if(frm.elements[i].name == "comments" && (trimString(frm.elements[i].value)) == "") {		
			errorMsg += "- Message is required\n";
		}
		if(frm.elements[i].name == "anti-spam" && (trimString(frm.elements[i].value)) != "121") {		
			errorMsg += "- Anti-spam: correct answer is required";
		}
	}
	if(errorMsg == "") {
		return true;
	} else {
		alert("The following error(s) occurred:\n\n"+errorMsg);
		return false;
	}
}
//Contact us form validation ends 

















