
//####################################################//
//Delcaration of string variables//


function valSurvey(){

if 	(
	
	validatepage() == true &&
	valCitizen() == true &&
	valAge() == true &&
	valApplied() == true &&
	valRelatives() == true &&
	valFelony() == true &&
	done() == true
	
	

	

	
	
	
	)
	{
return true;
	
	}
	return false;

}



function validateDate(fld) {
    var RegExPattern = /^(?=\d)(?:(?:(?:(?:(?:0?[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0?[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})|(?:0?2(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))|(?:(?:0?[1-9])|(?:1[0-2]))(\/|-|\.)(?:0?[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2}))($|\ (?=\d)))?(((0?[1-9]|1[012])(:[0-5]\d){0,2}(\ [AP]M))|([01]\d|2[0-3])(:[0-5]\d){1,2})?$/;
    var errorMessage = 'Please enter valid date as month, day, and four digit year.\nYou may use a slash, hyphen or period to separate the values.\nThe date must be a real date. 2-30-2000 would not be accepted.\nFormay mm/dd/yyyy.';
    if ((fld.value.match(RegExPattern)) && (fld.value!='')) {
        
    } else {
        alert(errorMessage);
        fld.focus();
    } 
}





function done(){
if ( validatepage() == true && 	valCitizen() == true && valAge() == true && valApplied() == true && valRelatives() == true && valFelony()== true )
	
	alert("Application Submitted Successfully")
	return true;

	

	
}



function valCitizen() {

chosen = ""
len = document.cis.rbgcitizen.length

for (i = 0; i <len; i++) {
if (document.cis.rbgcitizen[i].checked) {
chosen =  document.cis.rbgcitizen[i].value 
}
}

if (chosen == "") {
alert("Answer Citizen Question ")
lblCitizen.innerHTML = '<b><< YOU MUST ANSWER</b>'
return false;
}


else {
//alert(chosen )
lblCitizen.innerHTML = ''
return true;
}
}



function valAge() {

chosen = ""
len = document.cis.rbg18.length

for (i = 0; i <len; i++) {
if (document.cis.rbg18[i].checked) {
chosen =  document.cis.rbg18[i].value 
}
}

if (chosen == "") {
alert("Answer Are you at least 18 years of age Question ")
lblage18.innerHTML = '<b><< YOU MUST ANSWER</b>'
return false;
}


else {
//alert(chosen )
lblage18.innerHTML = ''
return true;
}
}





function valApplied() {

chosen = ""
len = document.cis.rbgapplied.length

for (i = 0; i <len; i++) {
if (document.cis.rbgapplied[i].checked) {
chosen =  document.cis.rbgapplied[i].value 
}
}

if (chosen == "") {
alert("Answer Ever Applied before Question ")
lblappliedbefore.innerHTML = '<b><< YOU MUST ANSWER</b>'
return false;
}


else if (chosen == "yes" && document.cis.txtdateapplied.value.length < 1   )
{
	
	alert("Answer Applied Date Question")
	document.cis.txtdateapplied.style.background = 'Yellow'
	lblappliedbefore.innerHTML = ''
	return false;
}


else if (chosen == "yes" && document.cis.txtlocationapplied.value.length < 1 )
{
	
	alert("Answer Applied Location Applied Question")
	document.cis.txtlocationapplied.style.background = 'Yellow'
	lblappliedbefore.innerHTML = ''
	return false;
}



else if (chosen == "yes" && document.cis.txtpositionapplied.value.length < 1 )
{
	
	alert("Answer Applied Position Applied Question")
	document.cis.txtpositionapplied.style.background = 'Yellow'
	lblappliedbefore.innerHTML = ''
	return false;
}





else if (chosen == "yes" && document.cis.txtdateapplied.value.length >=  1 && document.cis.txtlocationapplied.value.length >=  1 && document.cis.txtpositionapplied.value.length >=  1)
{
	//alert(chosen )
	//alert(document.cis.txtdateapplied.value)
	//alert(document.cis.txtlocationapplied.value)
	//alert(document.cis.txtpositionapplied.value)
	document.cis.txtdateapplied.style.background = 'White'
	document.cis.txtlocationapplied.style.background = 'White'
	document.cis.txtpositionapplied.style.background = 'White'
	lblappliedbefore.innerHTML = ''
	return true;
}

else {
//alert(chosen )
document.cis.txtdateapplied.style.background = 'White'
document.cis.txtlocationapplied.style.background = 'White'
document.cis.txtpositionapplied.style.background = 'White'
lblappliedbefore.innerHTML = ''
return true;
}
}



function valRelatives() {

chosen = ""
len = document.cis.rbgrelatives.length

for (i = 0; i <len; i++) {
if (document.cis.rbgrelatives[i].checked) {
chosen =  document.cis.rbgrelatives[i].value 
}
}

if (chosen == "") {
alert("Answer Relatives Question ")
lblrelatives.innerHTML = '<b><< YOU MUST ANSWER</b>'
return false;
}

else if (chosen == "yes" && document.cis.txtrelatives.value.length < 1)
{
	document.cis.txtrelatives.style.background = 'Yellow'
	alert("Answer Relatives Question")
	lblrelatives.innerHTML = ''
	return false;
}


else if (chosen == "yes" && document.cis.txtrelatives.value.length >=  1)
{
	//alert(chosen )
	//alert(document.cis.txtrelatives.value)
	document.cis.txtrelatives.style.background = 'White'
	lblrelatives.innerHTML = '</b>'
	return true;
}

else {
//alert(chosen )
document.cis.txtrelatives.style.background = 'White'
lblrelatives.innerHTML = ''
return true;
}
}


function valFelony() {

chosen = ""
len = document.cis.rbgfelony.length

for (i = 0; i <len; i++) {
if (document.cis.rbgfelony[i].checked) {
chosen =  document.cis.rbgfelony[i].value 
}
}

if (chosen == "") {
alert("Answer Felony Question ")
lblfelony.innerHTML = '<b><< YOU MUST ANSWER</b>'
return false;
}


else if (chosen == "yes" && document.cis.txtdatefelony.value.length < 1   )
{
	
	alert("Answer Felony Date Question")
	document.cis.txtdatefelony.style.background = 'Yellow'
	lblfelony.innerHTML = ''
	return false;
}


else if (chosen == "yes" && document.cis.txtlocationfelony.value.length < 1 )
{
	
	alert("Answer Felony Location Applied Question")
	document.cis.txtlocationfelony.style.background = 'Yellow'
	lblfelony.innerHTML = ''
	return false;
}



else if (chosen == "yes" && document.cis.txtnatureoffense.value.length < 1 )
{
	
	alert("Answer Felony nature of offense Question")
	document.cis.txtnatureoffense.style.background = 'Yellow'
	lblfelony.innerHTML = ''
	return false;
}





else if (chosen == "yes" && document.cis.txtdatefelony.value.length >=  1 && document.cis.txtlocationfelony.value.length >=  1 && document.cis.txtnatureoffense.value.length >=  1)
{
	//alert(chosen )
	//alert(document.cis.txtdatefelony.value)
	//alert(document.cis.txtlocationfelony.value)
	//alert(document.cis.txtnatureoffense.value)
	document.cis.txtdatefelony.style.background = 'White'
	document.cis.txtlocationfelony.style.background = 'White'
	document.cis.txtnatureoffense.style.background = 'White'
	lblfelony.innerHTML = ''
	return true;
}

else {
//alert(chosen )
document.cis.txtdatefelony.style.background = 'White'
document.cis.txtlocationfelony.style.background = 'White'
document.cis.txtnatureoffense.style.background = 'White'
lblfelony.innerHTML = ''
return true;
}
}



	


function validatepage()  {



var msg = '';


if (document.cis.lname.value =='') 
{
msg = msg + "\n -Last Name";
document.cis.lname.style.background = 'Yellow'
}
else
{
document.cis.lname.style.background = 'White'
}




if (document.cis.fname.value =='') 
{
msg = msg + "\n -First Name";
document.cis.fname.style.background = 'Yellow'
}
else
{
document.cis.fname.style.background = 'White'
}


if (document.cis.datetoday.value =='') 
{
msg = msg + "\n -Todays Date";
document.cis.datetoday.style.background = 'Yellow'

}
else
{
document.cis.datetoday.style.background = 'White'

}











if (document.cis.address.value =='') 
{
msg = msg + "\n -Adress";
document.cis.address.style.background = 'Yellow'
}
else
{
document.cis.address.style.background = 'White'
}



if (document.cis.city.value =='') 
{
msg = msg + "\n -City";
document.cis.city.style.background = 'Yellow'
}
else
{
document.cis.city.style.background = 'White'
}




if (document.cis.zip.value =='') 
{
msg = msg + "\n -zip";
document.cis.zip.style.background = 'Yellow'

}
else
{
document.cis.zip.style.background = 'White'
}




if (isNaN(document.cis.zip.value) == true)  
{
alert  ("zip not a number  ");
document.cis.zip.style.background = 'Yellow'
return false;
}



if (document.cis.zip.value.length < 5) 
{
msg = msg + "\n -zip must have 5 digits";
document.cis.zip.style.background = 'Yellow'
}



if (document.cis.countyres.value == '') 
{
msg = msg + "\n -County Residence";
document.cis.countyres.style.background = 'Yellow'
}
else
{
document.cis.countyres.style.background = 'White'
}



if (document.cis.state.value =='') 
{
msg = msg + "\n -state";
document.cis.state.style.background = 'Yellow'
}
else
{
document.cis.state.style.background = 'White'
}


if (document.cis.homephone.value == '')
{
msg = msg + "\n -Main Phone";
document.cis.homephone.style.background = 'Yellow'
}
else
{
document.cis.homephone.style.background = 'White'
}


if (isNaN(document.cis.homephone.value) == true)  
{
alert  ("Main phone not a number  ");
document.cis.homephone.style.background = 'Yellow'
return false;
}

if (document.cis.homephone.value.length < 10) 
{
msg = msg + "\n -Main phone must have 10 digits";
document.cis.homephone.style.background = 'Yellow'
}


/*if (document.cis.socnumber.value == '')
{
msg = msg + "\n -Social Number";
document.cis.socnumber.style.background = 'Yellow'
}
else
{
document.cis.socnumber.style.background = 'White'
}


if (isNaN(document.cis.socnumber.value) == true)  
{
alert  ("Social Number not a number  ");
document.cis.socnumber.style.background = 'Yellow'
return false;
}

if (document.cis.socnumber.value.length < 9) 
{
msg = msg + "\n -Social Number must have 9 digits";
document.cis.socnumber.style.background = 'Yellow'
}
*/

if (document.cis.posapplied.value == '')
{
msg = msg + "\n -Position apllied for";
document.cis.posapplied.style.background = 'Yellow'
}
else
{
document.cis.posapplied.style.background = 'White'
}


if (document.cis.wageexpect.value == '')
{
msg = msg + "\n -Wage Expected";
document.cis.wageexpect.style.background = 'Yellow'
}
else
{
document.cis.wageexpect.style.background = 'White'
}


if (document.cis.availdate.value == '')
{
msg = msg + "\n -Date Available";
document.cis.availdate.style.background = 'Yellow'
}
else
{
document.cis.availdate.style.background = 'White'
}


if (document.cis.txtaddresshigh.value == '')
{
msg = msg + "\n -At least a High School Degree is required. Addres";
document.cis.txtaddresshigh.style.background = 'Yellow'
}
else
{
document.cis.txtaddresshigh.style.background = 'White'
}


if (document.cis.txtmajorhigh.value == '')
{
msg = msg + "\n -At least a High School Degree is required. Major";
document.cis.txtmajorhigh.style.background = 'Yellow'
}
else
{
document.cis.txtmajorhigh.style.background = 'White'
}






/*if (document.cis.txtcompany1.value == '')
{
msg = msg + "\n -Enter at least one job reference. Company Name";
document.cis.txtcompany1.style.background = 'Yellow'
}
else
{
document.cis.txtcompany1.style.background = 'White'
}


if (document.cis.txttelenum1.value == '')
{
msg = msg + "\n -Enter at least one job reference. Telephone Number";
document.cis.txttelenum1.style.background = 'Yellow'
}
else
{
document.cis.txttelenum1.style.background = 'White'
}



if (document.cis.txtbusaddress1.value == '')
{
msg = msg + "\n -Enter at least one job reference. Business Address";
document.cis.txtbusaddress1.style.background = 'Yellow'
}
else
{
document.cis.txtbusaddress1.style.background = 'White'
}


if (document.cis.txtdateofemploy1.value == '')
{
msg = msg + "\n -Enter at least one job reference. Date of Employment";
document.cis.txtdateofemploy1.style.background = 'Yellow'
}
else
{
document.cis.txtdateofemploy1.style.background = 'White'
}


if (document.cis.txtjobtitle1.value == '')
{
msg = msg + "\n -Enter at least one job reference. Job Title";
document.cis.txtjobtitle1.style.background = 'Yellow'
}
else
{
document.cis.txtjobtitle1.style.background = 'White'
}

if (document.cis.txtratepay1.value == '')
{
msg = msg + "\n -Enter at least one job reference. Rate of Pay";
document.cis.txtratepay1.style.background = 'Yellow'
}
else
{
document.cis.txtratepay1.style.background = 'White'
}


if (document.cis.txtsupname1.value == '')
{
msg = msg + "\n -Enter at least one job reference. Supervisors Name";
document.cis.txtsupname1.style.background = 'Yellow'
}
else
{
document.cis.txtsupname1.style.background = 'White'
}


if (document.cis.txtresleaving1.value == '')
{
msg = msg + "\n -Enter at least one job reference. Reason for Leaving";
document.cis.txtresleaving1.style.background = 'Yellow'
}
else
{
document.cis.txtresleaving1.style.background = 'White'
}


if (document.cis.txtduties1.value == '')
{
msg = msg + "\n -Enter at least one job reference. Duties";
document.cis.txtduties1.style.background = 'Yellow'
}
else
{
document.cis.txtduties1.style.background = 'White'
}
*/



if (document.cis.txtappsign.value == '')
{
msg = msg + "\n -Fill out Application Signature";
document.cis.txtappsign.style.background = 'Yellow'
}
else
{
document.cis.txtappsign.style.background = 'White'
}


if (document.cis.txtdatecert.value == '')
{
msg = msg + "\n -Fill out Application Date";
document.cis.txtdatecert.style.background = 'Yellow'
}
else
{
document.cis.txtdatecert.style.background = 'White'
}




if (document.cis.txtconsumerdated.value == '')
{
msg = msg + "\n -Fill out Consumer Report. Dated";
document.cis.txtconsumerdated.style.background = 'Yellow'

}
else
{
document.cis.txtconsumerdated.style.background = 'White'
}



if (document.cis.txtconsumersigned.value == '')
{
msg = msg + "\n -Fill out Consumer Report. Signature";
document.cis.txtconsumersigned.style.background = 'Yellow'
}
else
{
document.cis.txtconsumersigned.style.background = 'White'
}


if (msg!="")
{
msg = (msg +"\n following items need entered:");
alert(msg);
return(false);
}

else 
{

return(true);

}

}



