// JavaScript Document

/******************************************************************
** This document will validate email, name and message fields from contact.php 
** Oakbridge Management, 2008 - created by Digital Surgeons
*******************************************************************/
/*window.onload = initValid;

function initValid() {
	document.getElementById('name').onblur = validName();
	document.getElementById('email').onblur = validEmail();
	document.getElementById('message').onblur = validMessage();
}*/

function validEmail() {
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var address = document.forms['oakCont'].elements['email'].value;
   if(reg.test(address) == false) {
	  document.getElementById('errorEmail').innerHTML = '*Invalid e-mail address.';
   } else {
	  document.getElementById('errorEmail').innerHTML = '';
   }
}

function validName() {
	var theName = document.forms['oakCont'].elements['name'].value;
	if(theName.length < 1) {
		document.getElementById('errorName').innerHTML = '*Please fill out your name.';
	} else {
		document.getElementById('errorName').innerHTML = '';
	}
}

function validMessage() {
	var theMssg = document.forms['oakCont'].elements['message'].value;
	if(theMssg.length < 1) {
		document.getElementById('errorMssg').innerHTML = '*Please fill out a message.';
	} else {
		document.getElementById('errorMssg').innerHTML = '';
	}
}


function vName(elem,err) {
	var theName = document.forms['oakApply'].elements[elem].value;
	if(theName.length < 1) {
		document.getElementById(err).innerHTML = '*Please fill out the name.';
	} else {
		document.getElementById(err).innerHTML = '';
	}
}

function vAddress(elem,err) {
	var theName = document.forms['oakApply'].elements[elem].value;
	if(theName.length < 1) {
		document.getElementById(err).innerHTML = '*Please fill out the address.';
	} else {
		document.getElementById(err).innerHTML = '';
	}
}

function vUnit(elem,err) {
	var theName = document.forms['oakApply'].elements[elem].value;
	if(theName.length < 1) {
		document.getElementById(err).innerHTML = '*Please fill out the unit.';
	} else {
		document.getElementById(err).innerHTML = '';
	}
}

function vRent(elem,err) {
	var theName = document.forms['oakApply'].elements[elem].value;
	if(theName.length < 1) {
		document.getElementById(err).innerHTML = '*Please fill out the rent.';
	} else {
		document.getElementById(err).innerHTML = '';
	}
}

function vEmail(elem,err) {
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var address = document.forms['oakApply'].elements[elem].value;
   if(reg.test(address) == false) {
	  document.getElementById(err).innerHTML = '*Please enter a valid email address.';
   } else {
	  document.getElementById(err).innerHTML = '';
   }
}

function vTelephone(elem,err) {
	var theName = document.forms['oakApply'].elements[elem].value;
	if(theName.length < 1) {
		document.getElementById(err).innerHTML = '*Please fill out the telephone.';
	} else {
		document.getElementById(err).innerHTML = '';
	}
}
function vSecCode(code) {
	var theName = document.forms['oakApply'].elements['security_code'].value;
	if(theName.length < 1) {
		document.getElementById('errorSecCode').innerHTML = '*Please fill security code.';
	} else {
	}
}
function subAForm()
{
	alert("Submitting");
 document.forms['oakApply'].submit();
}


function bodyInit(){
hideOForm();
hideMForm();
showEmployerForm();
}

function showEmployerForm(){
document.getElementById('einfo').style.display = "block";
document.getElementById('sinfo').style.display = "none";
}

function showSchoolForm(){
document.getElementById('einfo').style.display = "none";
document.getElementById('sinfo').style.display = "block";
}

function hideESForm(){
document.getElementById('einfo').style.display = "none";
document.getElementById('sinfo').style.display = "none";
}

function showOForm(){
document.getElementById('oinfo').style.display = "block";
}

function hideOForm(){
document.getElementById('oinfo').style.display = "none";
}

function showMForm(){
document.getElementById('minfo').style.display = "block";
}

function hideMForm(){
document.getElementById('minfo').style.display = "none";
}
