<!--
//Courtesy of SmartWebby.com
var digits = "0123456789";
var phoneNumberDelimiters = "()- ";
var validWorldPhoneChars = phoneNumberDelimiters + "+";
var minDigitsInIPhoneNumber = 10;

function isInteger(s)
{   
	var i;
	for (i = 0; i < s.length; i++)
	{   
		// Check that current character is number.
		var c = s.charAt(i);
		if (((c < "0") || (c > "9"))) return false;
	}
	// All characters are numbers.
	return true;
}

function stripCharsInBag(s, bag)
{
	var i;
	var returnString = "";
	// Search through string's characters one by one.
	// If character is not in bag, append to returnString.
	for (i = 0; i < s.length; i++)
	{   
		// Check that current character isn't whitespace.
		var c = s.charAt(i);
		if (bag.indexOf(c) == -1) returnString += c;
	}
	return returnString;
}

function checkInternationalPhone(strPhone)
{
	s=stripCharsInBag(strPhone,validWorldPhoneChars);
	return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}

function validate_phone(a)
{
	var g=eval(a).value;
	if ((g==null)||(g==""))
	{
		alert("Please enter your Phone Number");
		eval(a).focus();
		return false;
	}
	if (checkInternationalPhone(g)==false)
	{
		alert("Please enter Phone Number in the format shown.");
		eval(a).value="";
		eval(a).focus();
		return false;
	}
		return true;
}

// Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isInteger(s)
{
	var i;
	for (i = 0; i < s.length; i++)
	{   
		// Check that current character is number.
		var c = s.charAt(i);
		if (((c < "0") || (c > "9"))) return false;
		
		// All characters are numbers.
		return true;
	}
}

function stripCharsInBag(s, bag)
{
	var i;
	var returnString = "";
	// Search through string's characters one by one.
	// If character is not in bag, append to returnString.
	for (i = 0; i < s.length; i++)
	{   
		var c = s.charAt(i);
		if (bag.indexOf(c) == -1) returnString += c;
	}
	return returnString;
}

function daysInFebruary (year)
{
	// February has 29 days in any year evenly divisible by four,
	// EXCEPT for centurial years which are not also divisible by 400.
	return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}

function DaysArray(n)
{
	for (var i = 1; i <= n; i++) 
	{
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) 
		{this[i] = 29}
	} 
	return this;
}

function isDate(a){
var dtStr=eval(a).value;
var daysInMonth = DaysArray(12)
var pos1=dtStr.indexOf(dtCh)
var pos2=dtStr.indexOf(dtCh,pos1+1)
var strMonth=dtStr.substring(0,pos1)
var strDay=dtStr.substring(pos1+1,pos2)
var strYear=dtStr.substring(pos2+1)
strYr=strYear
if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
for (var i = 1; i <= 3; i++) {
if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
}
month=parseInt(strMonth)
day=parseInt(strDay)
year=parseInt(strYr)
if (pos1==-1 || pos2==-1){
alert("The date format should be : mm/dd/yyyy")
return false
}
if (strMonth.length<1 || month<1 || month>12){
alert("Please enter a valid month")
eval(a).value="";
return false
}
if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
alert("Please enter a valid day")
eval(a).value="";
return false
}
if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
eval(a).value="";
return false
}
if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
alert("Please enter a valid date")
eval(a).value="";
return false
}
return true
}

function check_email(a) {
var x = eval(a).value;
var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9])+$/;
if (!(filter.test(x))) {
alert("Please enter a valid Email address");
eval(a).focus();
eval(a).value="";
return false;
}
return true;
}

function check_alphanum(a) {
var x = eval(a).value;
// space is also present in the string
var filter=/^([ a-zA-Z0-9,.-])+$/;
if (!(filter.test(x))) {
alert("Please enter only letters and/or numbers.");
eval(a).value="";
eval(a).focus();
return false;
}
return true;
}

function check_num(a,b) {
var x = eval(a).value;
// space is also present in the string
var filter  = /^([0-9])+$/;
if (!(filter.test(x))) {
alert("Please enter only a number(s).");
eval(a).value="";
eval(a).focus();
return false;
}
if ((b=="ssn") && (x.length != 9)){
alert("Please enter a valid social security number.");
eval(a).value="";
eval(a).focus();
return false;
}
return true;
}

function validate(){

var aname=document.app.name.value;
var aemail=document.app.email.value;
var aphone=document.app.phone1.value;
var aaddress=document.app.address.value;

var alphaNum= new RegExp(/^[a-z, ]+$/gi);

if (aname==""){
alert("Please enter your name as shown.");
document.app.name.focus();
return;
}

if (aemail==""){
alert("Please enter your email.");
document.app.email.focus();
return;
}

if (aphone==""){
alert("Please enter your phone number.");
document.app.phone1.focus();
return;
}

if (aaddress==""){
alert("Please enter your address.");
document.app.address.focus();
return;
}

if (!alphaNum.test(aname)){
alert("Please enter only letters and commas in the name field");
document.app.name.focus();
return;
}

if (document.app.cert1.value=="No"){
alert ("Please select YES to certify that you have read\n the Applicant's Certification and Agreement.");
document.app.cert1.focus();
return;
}
if (document.app.cert2.value=="No"){
alert ("Please select YES to acknowledge your \ncommitment to the initial availability schedule.");
document.app.cert2.focus();
return;
}
//document.app.flag.value="1";


document.app.submit();
}



function validate_preview(){

var aname=document.app.firstname.value;
var aemail=document.app.email.value;
var aphone=document.app.phone1.value;
var aaddress=document.app.address.value;

var alphaNum= new RegExp(/^[a-z, ]+$/gi);

if (aname==""){
alert("Please enter your name.");
document.app.firstname.focus();
return;
}

if (aemail==""){
alert("Please enter your email.");
document.app.email.focus();
return;
}

if (aphone==""){
alert("Please enter your phone number.");
document.app.phone1.focus();
return;
}

if (aaddress==""){
alert("Please enter your address.");
document.app.address.focus();
return;
}

if (!alphaNum.test(aname)){
alert("Please enter only letters and commas in the name field");
document.app.name.focus();
return;
}

if (document.app.cert1.value=="No"){
alert ("Please select YES to certify that you have read\n the Applicant's Certification and Agreement.");
document.app.cert1.focus();
return;
}
if (document.app.cert2.value=="No"){
alert ("Please select YES to acknowledge your \ncommitment to the initial availability schedule.");
document.app.cert2.focus();
return;
}
//document.app.flag.value="1";


//var montotime[0] = 0; 
//var monfromtime[0]  = 0;
//var tuetotime[0]  = 0;
//var tuefromtime[0]  = 0;
//var wedtotime[0]  = 0;
//var wedfromtime[0]  = 0;
//var thurstotime[0]  = 0;
//var thursfromtime[0] = 0;
//var fritotime[0] = 0;
//var frifromtime[0] = 0;
//var sattotime[0] = 0;
//var satfromtime[0] = 0;
//var suntotime[0] = 0;
//var sunfromtime[0] = 0;



if(document.app.monfromavail.value != "")
{
var monfrom = document.app.monfromavail.value;
var monfromtime = monfrom.split(" ");
}
if(document.app.montoavail.value != "")
{
var monto = document.app.montoavail.value;
var montotime = monto.split(" ");
}
if(document.app.tuesfromavail.value != "")
{
var tuesfrom = document.app.tuesfromavail.value;
var tuesfromtime = tuesfrom.split(" ");
}
if(document.app.tuestoavail.value != "")
{
var tuesto = document.app.tuestoavail.value;
var tuestotime = tuesto.split(" ");
}
if(document.app.wedfromavail.value != "")
{
var wedfrom = document.app.wedfromavail.value;
var wedfromtime = wedfrom.split(" ");
}
if(document.app.wedtoavail.value != "")
{
var wedto = document.app.wedtoavail.value;
var wedtotime = wedto.split(" ");
}
if(document.app.thursfromavail.value != "")
{
var thursfrom = document.app.thursfromavail.value;
var thursfromtime = thursfrom.split(" ");
}
if(document.app.thurstoavail.value != "")
{
var thursto = document.app.thurstoavail.value;
var thurstotime = thursto.split(" ");
}
if(document.app.frifromavail.value != "")
{
var frifrom = document.app.frifromavail.value;
var frifromtime = frifrom.split(" ");
}
if(document.app.fritoavail.value != "")
{
var frito = document.app.fritoavail.value;
var fritotime = frito.split(" ");
}
if(document.app.satfromavail.value != "")
{
var satfrom = document.app.satfromavail.value;
var satfromtime = satfrom.split(" ");
}
if(document.app.sattoavail.value != "")
{
var satto = document.app.sattoavail.value;
var sattotime = satto.split(" ");
}
if(document.app.sunfromavail.value != "")
{
var sunfrom = document.app.sunfromavail.value;
var sunfromtime = sunfrom.split(" ");
}
if(document.app.suntoavail.value != "")
{
var sunto = document.app.suntoavail.value;
var suntotime = sunto.split(" ");
}

if(document.app.adminjob.value!="other" && document.app.adminjob.value!="manager")
{

	if(((document.app.monfromavail.value=="5 PM" || document.app.monfromavail.value=="6 PM" || document.app.monfromavail.value=="7 PM" || document.app.monfromavail.value=="8 PM" || document.app.monfromavail.value=="9 PM" || document.app.monfromavail.value=="10 PM" || document.app.monfromavail.value=="11 PM" || document.app.monfromavail.value=="12 mid" || document.app.montoavail.value=="9 PM" || document.app.montoavail.value=="10 PM" || document.app.montoavail.value=="11 PM" || document.app.montoavail.value=="12 mid" || document.app.tuesfromavail.value=="5 PM" || document.app.tuesfromavail.value=="6 PM" || document.app.tuesfromavail.value=="7 PM" || document.app.tuesfromavail.value=="8 PM" || document.app.tuesfromavail.value=="9 PM" || document.app.tuesfromavail.value=="10 PM" || document.app.tuesfromavail.value=="11 PM" || document.app.tuesfromavail.value=="12 mid" || document.app.tuestoavail.value=="9 PM" || document.app.tuestoavail.value=="10 PM" || document.app.tuestoavail.value=="11 PM" || document.app.tuestoavail.value=="12 mid" || document.app.wedfromavail.value=="5 PM" || document.app.wedfromavail.value=="6 PM" || document.app.wedfromavail.value=="7 PM" || document.app.wedfromavail.value=="8 PM" || document.app.wedfromavail.value=="9 PM" || document.app.wedfromavail.value=="10 PM" || document.app.wedfromavail.value=="11 PM" || document.app.wedfromavail.value=="12 mid" || document.app.wedtoavail.value=="9 PM" || document.app.wedtoavail.value=="10 PM" || document.app.wedtoavail.value=="11 PM" || document.app.wedtoavail.value=="12 mid" || document.app.thursfromavail.value=="5 PM" || document.app.thursfromavail.value=="6 PM" || document.app.thursfromavail.value=="7 PM" || document.app.thursfromavail.value=="9 PM" || document.app.thursfromavail.value=="10 PM" || document.app.thursfromavail.value=="11 PM" || document.app.thursfromavail.value=="12 mid" || document.app.thurstoavail.value=="9 PM" || document.app.thurstoavail.value=="10 PM" || document.app.thurstoavail.value=="11 PM" || document.app.thurstoavail.value=="12 mid" || document.app.frifromavail.value=="5 PM" || document.app.frifromavail.value=="6 PM" || document.app.frifromavail.value=="7 PM" || document.app.frifromavail.value=="8 PM" || document.app.frifromavail.value=="9 PM" || document.app.frifromavail.value=="10 PM" || document.app.frifromavail.value=="11 PM" || document.app.frifromavail.value=="12 mid" || document.app.fritoavail.value=="9 PM" || document.app.fritoavail.value=="10 PM" || document.app.fritoavail.value=="11 PM" || document.app.fritoavail.value=="12 mid")) && ((document.app.satfromavail.value!="" && document.app.sattoavail.value!="") || (document.app.sunfromavail.value!="" && document.app.suntoavail.value!=""))  )<!--&& ((montotime[0] - monfromtime[0] >= 4) || (tuetotime[0] - tuefromtime[0] >= 4) || (wedtotime[0] - wedfromtime[0] >= 4) || (thurstotime[0] - thursfromtime[0] >= 4) || (fritotime[0] - frifromtime[0] >= 4) || (sattotime[0] - satfromtime[0] >= 4) || (suntotime[0] - sunfromtime[0] >= 4))-->
	{
		document.app.submit();
	}
	else
	{
			alert ("We require all new hires to work at least one night shift  (4 hours after 5pm) and a Saturday or Sunday shift.");
			document.app.monfromavail.focus();
			return;
	}
}
else
{
		//alert(document.app.sourcesession.value);
		//alert(document.app.adminjob.value);
		document.app.submit();
}

}




function check_clear(){
var ret_val = confirm("Are you sure you want to clear\nall information from this form?");
if (ret_val ==true){
document.app.reset();
}else{
return;
}
}

function checkurl(){
var a=document.cookie;
if ( (document.app.flag.value!="1") && (a.indexOf("applied")==-1) ){
self.location.href = "unload.php";
}
}

function resetflag(){
document.app.flag.value="";
}
//-->


