//////////////////////////////////////////////////////////////////////////////////
// This validation file contains
//
//  validateChangedPassword()  ************************For ChangePassword Form
//  checklogin()               ************************For Login checking Form
//  validateezin()             ************************For E-Zin date validation Form
//  validateschedule()         ************************For Online Shedule Form
//  validateinformation_topic()************************For Information Topic Form 
//  validatesub()              ************************For Subscription Form
//  validateservice()          ************************For Online-Service Form
//  validateonlinereg()        ************************For Online-Registration Form
//  validatepayment()          ************************For Payment(Online-Registration) Form
//  validatecontact()          ************************For Contact Info
//  validateinst()             ************************For Installation Services Form
//  validateemp()              ************************For Employent Application Form
//  validateque()              ************************For Post Question Form
//  validatecon()              ************************For ContactUs Form
//  validatecontactus()        ************************For ContactUs Form
//
////////////////////////////////////////////////////////////////////////////////
function returnFalse(obj){
	obj.focus();
	return false;
}



function validateChangedPassword(){
	if(trim(document.pwdFrm.old_pwd.value)==""){
		alert("Please enter old password.");
		return returnFalse(document.pwdFrm.old_pwd);
	}
	if(trim(document.pwdFrm.new_pwd.value)==""){
		alert("Please enter new password.");
		return returnFalse(document.pwdFrm.new_pwd);
	}
	else{
		if(validatePassword(document.pwdFrm.new_pwd.value)==false){
			alert("Invalid new password");
			return returnFalse(document.pwdFrm.new_pwd);
		}
	}
	if(trim(document.pwdFrm.new_pwd.value)!=trim(document.pwdFrm.conf_pwd.value)){
		alert("Confirm password failed.");
		return returnFalse(document.pwdFrm.conf_pwd);
	}
	document.pwdFrm.submit();
}

function checkLogin(){
	if (trim(document.loginFrm.pwd.value)=="")	{
		alert("Please enter password.");
		return returnFalse(document.loginFrm.pwd);
	}else{
		if (validatePassword(trim(document.loginFrm.pwd.value))==false){
			alert("Invalid password.");
			return returnFalse(document.loginFrm.pwd);
		}
	}
	document.loginFrm.submit();
}

function validateezin(){
	if (trim(document.ezin_frm.ezin_month.value)==""){
		alert("Please select E-zine month.");
		return returnFalse(document.ezin_frm.ezin_month);
	}
	if (trim(document.ezin_frm.ezin_year.value)==""){
		alert("Please select E-zine year.");
		return returnFalse(document.ezin_frm.ezin_year);
	}	
	if(trim(document.ezin_frm.operation.value)=="insert")
	{
		if (trim(document.ezin_frm.ezin_pdf.value)==""){
			alert("Please select an E-zine file");
			return returnFalse(document.ezin_frm.ezin_pdf);
		}		
	}
	if(trim(document.ezin_frm.operation.value)=="update")
		{
			//alert(document.ezin_frm.operation.value);
			if (trim(document.ezin_frm.ezin_pdf.value)==""){
			alert("Please select an E-zine file");
			return returnFalse(document.ezin_frm.ezin_pdf);
		}
	  }
	
	
	var i=0;
	version="";
	for(cnt=0;cnt<document.ezin_frm.ezin_version.length;cnt++){
		
		if(document.ezin_frm.ezin_version[cnt].checked) {
			if(document.ezin_frm.ezin_version[cnt].value=="R") {
				version="R";
				i=1;
			}
			if(document.ezin_frm.ezin_version[cnt].value=="C") {
				if(i==1){
					//version="R,C";	
					version="R";	
				}else{
					version="C";
				}
			}
			
		}		
	}
	if(version==""){
		alert("Select version of E-zine");
		return returnFalse(document.ezin_frm.ezin_version[0]);
	}else{
		document.ezin_frm.ezinversion.value=version;
	}
	document.ezin_frm.action="db_ezinmanager.php";
	document.ezin_frm.submit();
}


/******************************/
function validateschedule(){
	if(trim(document.schedule_frm.schedule_title.value)==""){
		alert("Enter title");
		return returnFalse(document.schedule_frm.schedule_title);
	}
	if(trim(document.schedule_frm.schedule_description.value)==""){
		alert("Enter description");
		return returnFalse(document.schedule_frm.schedule_description);
	}
	if(trim(document.schedule_frm.schedule_date.value)==""){
		alert("Enter date");
		return returnFalse(document.schedule_frm.schedule_date);
	}
	if(trim(document.schedule_frm.schedule_time.value)==""){
		alert("Enter time");
		return returnFalse(document.schedule_frm.schedule_time);
	}
	if(trim(document.schedule_frm.schedule_duration.value)==""){
		alert("Enter duration");
		return returnFalse(document.schedule_frm.schedule_duration);
	}	
	if(trim(document.schedule_frm.schedule_cost.value)==""){
		alert("Enter cost");
		return returnFalse(document.schedule_frm.schedule_cost );
	}		
	if(trim(document.schedule_frm.schedule_Instructor.value)==""){
		alert("Enter instructor");
		return returnFalse(document.schedule_frm.schedule_Instructor  );
	}		
	
	document.schedule_frm.action="db_tcmanager.php";
	document.schedule_frm.submit();
}
/******************************/


function validateinformation_topic(){
	if (trim(document.information_topic_frm.information_topic.value)==""){
		alert("Please select information topic.");
		return returnFalse(document.information_topic_frm.information_topic);
	}
	document.information_topic_frm.action="db_information_topic.php";
	document.information_topic_frm.submit();
}
function validateemail(){
	if (trim(document.email_frm.email_subject.value)==""){
		alert("Please select email subject.");
		return returnFalse(document.email_frm.email_subject);
	}
	if (trim(document.email_frm.email_contents.value)==""){
		alert("Please select email contents.");
		return returnFalse(document.email_frm.email_contents);
	}
	
	document.email_frm.action="db_email.php";
	document.email_frm.submit();
}



function validatesub(){
	
	if(trim(document.frmsub.subscription_first_name.value)==""){
		alert("Enter first name");
		//return false;
		return returnFalse(document.frmsub.subscription_first_name);
		
	}
	if(!checkSalutation(document.frmsub.subscription_first_name.value)){
		alert("Invalid first name");
		return returnFalse(document.frmsub.subscription_first_name);
	}
	if(trim(document.frmsub.subscription_last_name.value)==""){
		alert("Enter last name");
		//return false;
		return returnFalse(document.frmsub.subscription_last_name);
	}
	if(!checkSalutation(document.frmsub.subscription_last_name.value)){
		alert("Invalid last name");
		//return false;
		return returnFalse(document.frmsub.subscription_last_name);
	}
	if(trim(document.frmsub.subscription_email_id.value)==""){
		alert("Enter Email ID");
		//return false;
		return returnFalse(document.frmsub.subscription_email_id);
	}
	if(!checkEmailAddress(document.frmsub.subscription_email_id.value)){
		alert("Invalid Email ID");
		//return false;
		return returnFalse(document.frmsub.subscription_email_id);
	}
	//checkEmailAddress
	var i=0;
	document.frmsub.version.value="";
	for (counter = 0; counter < document.frmsub.subscription_version.length; counter++){
		if (document.frmsub.subscription_version[counter].checked){ 
			//alert(document.frmsub.subscription_version[counter].value);
			i=1;
			if(document.frmsub.version.value==""){
				document.frmsub.version.value=document.frmsub.subscription_version[counter].value;
			}else{
				document.frmsub.version.value=document.frmsub.version.value+","+document.frmsub.subscription_version[counter].value;
			}
		}
	}
	if(i==0){
		alert("Select at least one version");
		return false;
	}
	if(trim(document.frmsub.subscription_address.value)!=""){
		if(!checkadd(document.frmsub.subscription_address.value)){
			alert("Invalid address details");
			//return false;
			return returnFalse(document.frmsub.subscription_address);
		}
	}
	if(trim(document.frmsub.subscription_city.value)!=""){
		if(!checkcity(document.frmsub.subscription_city.value)){
			alert("Invalid city details");
			//return false;
			return returnFalse(document.frmsub.subscription_city);
		}
	}
	if(trim(document.frmsub.subscription_state.value)!=""){
		if(!checkcity(document.frmsub.subscription_state.value)){
			alert("Invalid state details");
			//return false;
			return returnFalse(document.frmsub.subscription_state);
		}
	}	
	if(!trim(document.frmsub.subscription_zip.value)==""){
		if(!inValidCharZip(document.frmsub.subscription_zip.value)){
			alert("Invalid zip code");
			//return false;
			return returnFalse(document.frmsub.subscription_zip);
		}
	}
	if(trim(document.frmsub.subscription_home_phone.value)!=""){
		if(!checkPhone(document.frmsub.subscription_home_phone.value)){
			alert("Invalid home phone number");
			//return false;
			return returnFalse(document.frmsub.subscription_home_phone);
		}
	}	
	if(trim(document.frmsub.subscription_cell_phone.value)!=""){
		if(!checkPhone(document.frmsub.subscription_cell_phone.value)){
			alert("Invalid cell phone number");
			//return false;
			return returnFalse(document.frmsub.subscription_cell_phone);
		}
	}		
	
	document.frmsub.subscription_information.value="";
	for (counter = 0; counter < document.frmsub.information_topics.length; counter++){
		if (document.frmsub.information_topics[counter].checked){ 
			i=1;
			if(document.frmsub.subscription_information.value==""){
				document.frmsub.subscription_information.value=document.frmsub.information_topics[counter].value;
			}else{
				document.frmsub.subscription_information.value=document.frmsub.subscription_information.value+","+document.frmsub.information_topics[counter].value;
			}
		}
	}
	if(trim(document.frmsub.hear_about.value)==""){
		alert("Please select How did you here about us");
		return returnFalse(document.frmsub.hear_about);
		}
	document.frmsub.action="admin/db_subscription.php";
	document.frmsub.submit();
}

//////service
function service_popup(serviceid) { 
	var title ="";
	w=500;
	h=575;
     var winl = (screen.width - w) / 2;
     var wint = (screen.height - h) / 2;
     winprops = 'height='+h+',width='+w+',scrollbar,top='+wint+',left='+winl+'resizable=0'
	 var win=window.open("../popups/service_popup.php?service_id="+serviceid+"&"+title+"", "mywin", winprops);
	 win.focus();
   } 
/*function service_popup(serviceid){
	window.open("../popups/service_popup.php?service_id="+serviceid);
}*/
function validateservice(date1,date2){
	
	if(trim(document.frmsub.service_first_name.value)==""){
		alert("Enter first name");
		//return false;
		return returnFalse(document.frmsub.service_first_name);
	}
	if(!checkSalutation(document.frmsub.service_first_name.value)){
		alert("Invalid first name");
		//return false;
		return returnFalse(document.frmsub.service_first_name);
	}
	if(trim(document.frmsub.service_last_name.value)==""){
		alert("Enter last name");
		//return false;
		return returnFalse(document.frmsub.service_last_name);
	}
	if(!checkSalutation(document.frmsub.service_last_name.value)){
		alert("Invalid last name");
		//return false;
		return returnFalse(document.frmsub.service_last_name);
	}

	if(trim(document.frmsub.service_home_phone.value)!=""){
		if(!checkPhone(document.frmsub.service_home_phone.value)){
			alert("Invalid Primary phone number");
			//return false;
			return returnFalse(document.frmsub.service_home_phone);
		}
	}else{
		alert("Enter Primary phone details");
		return returnFalse(document.frmsub.service_home_phone);
	}
	if(trim(document.frmsub.service_cell_phone.value)!=""){
		if(!checkPhone(document.frmsub.service_cell_phone.value)){
			alert("Invalid cell phone number");
			return returnFalse(document.frmsub.service_cell_phone);
			//return false;
		}
	}		
	
	if(!trim(document.frmsub.service_email_id.value)==""){
			if(!checkEmailAddress(document.frmsub.service_email_id.value)){
				alert("Invalid Email ID");
				//return false;
				return returnFalse(document.frmsub.service_email_id);
			}
		}
		

	var i=0;
	var appointment="";
	document.frmsub.version.value="";
	for (counter = 0; counter < document.frmsub.service_version.length; counter++){
		if (document.frmsub.service_version[counter].checked){ 
			i=1;
			if(document.frmsub.service_version[counter].value=="C"){
				appointment="C";
			}
			if(document.frmsub.service_version[counter].value=="R"){
				appointment="R";
			}			
			if(document.frmsub.version.value==""){
				document.frmsub.version.value=document.frmsub.service_version[counter].value;
			}else{
				document.frmsub.version.value=document.frmsub.version.value+","+document.frmsub.service_version[counter].value;
			}
		}
	}
	if(i==0){
		alert("Select at least one version");
		return false;
	}
	if(appointment=="C"){
		if(trim(document.frmsub.service_company.value)==""){
			alert("Select company.");
			return false;
		}
	}
	//if(trim(document.frmsub.service_address.value)!=""){
		if(trim(document.frmsub.service_address.value=="")){
			alert("Invalid address details");
			//return false;
			return returnFalse(document.frmsub.service_address);
		}
	//}
	//if(trim(document.frmsub.service_city.value)!=""){
		if(!checkcity(document.frmsub.service_city.value)){
			alert("Invalid city details");
			//return false;
			return returnFalse(document.frmsub.service_city);
		}
	//}
	//if(trim(document.frmsub.service_state.value)!=""){
		if(!checkcity(document.frmsub.service_state.value)){
			alert("Invalid state details");
			//return false;
			return returnFalse(document.frmsub.service_state);
		}
	//}	
	//if(!trim(document.frmsub.service_zip.value)==""){
		if(!inValidCharZip(document.frmsub.service_zip.value)){
			alert("Invalid zip code");
			//return false;
			return returnFalse(document.frmsub.service_zip);
		}
	//}
		if((document.frmsub.service_request.value==" ")){
			alert("Select service request");
			//return false;
			return returnFalse(document.frmsub.service_request);
		}
		if(trim(document.frmsub.service_description.value=="")){
			alert("Invalid description details");
			//return false;
			return returnFalse(document.frmsub.service_description);
		}
		
		
		if(trim(document.frmsub.service_date1.value=="")){
			alert("Invalid appointment date 1 details");
			//return false;
			return returnFalse(document.frmsub.service_date1);
		}
		
		date2=document.frmsub.service_date1.value;
		/*if(date_difference(date1,date2)){
			alert('1st Choice AppointmentDate is Lessthan Todays Date');
			return returnFalse(document.frmsub.service_date1);
		}*/
		if(!isfutureDate(date2)){
			alert("1st Choice Appointment Date should be greater than Todays Date.")
			return false;
		}
		
		if(trim(document.frmsub.service_time1.value=="")){
			alert("Invalid appointment time 1 details");
			//return false;
			return returnFalse(document.frmsub.service_time1);
		}
		
		if(trim(document.frmsub.service_date2.value=="")){
			alert("Invalid appointment date 2 details");
			//return false;
			return returnFalse(document.frmsub.service_date2);
		
		}
		$date2=document.frmsub.service_date2.value;
		/*if(istodayorgreaterDate(date1,date2)){
			alert('2nd Choice AppointmentDate is Lessthan Todays Date');
			return returnFalse(document.frmsub.service_date2);
		}*/
		if(!isfutureDate(date2)){
			alert("2nd Choice Appointment Date should be greater than Todays Date.")
			return false;
		}
		
		if(trim(document.frmsub.service_time2.value=="")){
			alert("Invalid appointment time 2 details");
			//return false;
			return returnFalse(document.frmsub.service_time2);
		}
		
		if(trim(document.frmsub.hear_about.value)==""){
		alert("Please select How did you here about us");
		return returnFalse(document.frmsub.hear_about);
		}
		
		
		
	
	document.frmsub.action="admin/db_service.php";
	document.frmsub.submit();
}




/******************************************/
/********************************/
function validateonlinereg(){
	
	if(trim(document.frmsub.reg_first_name.value)==""){
		alert("Enter first name");
		//return false;
		return returnFalse(document.frmsub.reg_first_name);
	}
	if(!checkSalutation(document.frmsub.reg_first_name.value)){
		alert("Invalid first name");
		//return false;
		return returnFalse(document.frmsub.reg_first_name);
	}
	if(trim(document.frmsub.reg_last_name.value)==""){
		alert("Enter last name");
		//return false;
		return returnFalse(document.frmsub.reg_last_name);
	}
	if(!checkSalutation(document.frmsub.reg_last_name.value)){
		alert("Invalid last name");
		//return false;
		return returnFalse(document.frmsub.reg_last_name);
	}

	//if(trim(document.frmsub.reg_address.value)!=""){
		if(trim(document.frmsub.reg_address.value=="")){
			alert("please Enter Address");
			//return false;
			return returnFalse(document.frmsub.reg_address);
		}
		
		if(trim(document.frmsub.reg_city.value=="")){
			alert("please Enter City");
			//return false;
			return returnFalse(document.frmsub.reg_city);
		}
		
		
	//}
	//if(trim(document.frmsub.reg_city.value)!=""){
		if(!checkcity(document.frmsub.reg_city.value)){
			alert("Invalid city details");
			//return false;
			return returnFalse(document.frmsub.reg_city);
		}
	//}
	//if(trim(document.frmsub.reg_state.value)!=""){
		if((document.frmsub.reg_state.value=="")){
			alert("Please Enter State Details");
			//return false;
			return returnFalse(document.frmsub.reg_state);
		}
		
	//}	
	
	if(trim(document.frmsub.reg_zip.value)==""){
		
		alert("Please Enter zip code");
			//return false;
			return returnFalse(document.frmsub.reg_zip);
	}


	if(trim(document.frmsub.reg_home_phone.value)!=""){
		if(!checkPhone(document.frmsub.reg_home_phone.value)){
			alert("Invalid home phone number");
			//return false;
			return returnFalse(document.frmsub.reg_home_phone);
		}
	}else{
			alert("Please Enter home phone number");
			return returnFalse(document.frmsub.reg_home_phone);
	}
		
	/*
	if(!trim(document.frmsub.reg_email_id.value)==""){
			if(!checkEmailAddress(document.frmsub.reg_email_id.value)){
				alert("Invalid Email ID");
				//return false;
				return returnFalse(document.frmsub.reg_email_id);
			}
		}else{
			alert("Please Enter E-mail");
			return returnFalse(document.frmsub.reg_email_id);
	}
		*/

	var i=0;
	var appointment="";
	document.frmsub.reg_payment.value="";
	for (counter = 0; counter < document.frmsub.reg_payment.length; counter++){
		if (document.frmsub.reg_payment[counter].checked){ 
			i=1;
			if(document.frmsub.reg_payment[counter].value=="cash"){
				appointment="cash";
			}
			if(document.frmsub.reg_payment[counter].value=="cheque"){
				appointment="cheque";
			}			
			if(document.frmsub.reg_payment[counter].value=="creditcard"){
				appointment="creditcard";
			}
			if(document.frmsub.reg_payment[counter].value=="other"){
				appointment="other";
			}	
			
			if(document.frmsub.reg_payment.value==""){
				document.frmsub.reg_payment.value=document.frmsub.reg_payment[counter].value;
			}else{
				document.frmsub.reg_payment.value=document.frmsub.reg_payment.value+","+document.frmsub.reg_payment[counter].value;
			}
		}
	}
	if(i==0){
		alert("Select at least one payment method");
		return false;
	}
	if(appointment=="other"){
		if(trim(document.frmsub.reg_otherpayment.value)==""){
			alert("Enter other payment details.");
			return false;
		}
	}
	
	if(trim(document.frmsub.reg_enquiry.value)==""){
		alert("Please select How did you here about us");
		return returnFalse(document.frmsub.reg_enquiry)
	}
	
	
	
/*	if(trim(document.frmsub.reg_description.value=="")){
		alert("Invalid description details");
		//return false;
		return returnFalse(document.frmsub.reg_description);
	}*/
		
	
	document.frmsub.action="admin/db_reg.php";
	document.frmsub.submit();
}


function validatepayment(){
	var i=0;
	var appointment="";
	document.frmsub.payment.value="";
	for (counter = 0; counter < document.frmsub.reg_payment.length; counter++){
		if (document.frmsub.reg_payment[counter].checked){ 
			i=1;
			if(document.frmsub.reg_payment[counter].value=="cash"){
				appointment="cash";
			}
			if(document.frmsub.reg_payment[counter].value=="cheque"){
				appointment="cheque";
			}			
			if(document.frmsub.reg_payment[counter].value=="creditcard"){
				appointment="creditcard";
			}
			if(document.frmsub.reg_payment[counter].value=="other"){
				appointment="other";
			}	
			
			if(document.frmsub.payment.value==""){
				document.frmsub.payment.value=document.frmsub.reg_payment[counter].value;
			}else{
				document.frmsub.payment.value=document.frmsub.payment.value+","+document.frmsub.reg_payment[counter].value;
			}
		}
	}
	if(i==0){
		//alert("Select at least one payment method");
		//return false;
	}
	if(appointment=="other"){
		if(trim(document.frmsub.reg_otherpayment.value)==""){	
			document.frmsub.reg_otherpayment.disabled=false;
		}
	}else{		
		document.frmsub.reg_otherpayment.value="";
		document.frmsub.reg_otherpayment.disabled=true;
	}
}

function validatecontact(){
	var i=0;
	var contact="";
	document.frmcontact.payment.value="";
	for (counter = 0; counter < document.frmcontact.phone.length; counter++){
		if (document.frmcontact.phone[counter].checked){ 
			i=1;
			if(document.frmcontact.phone[counter].value=="phone"){
				contact="phone";
			}
			if(document.frmcontact.phone[counter].value=="email"){
				contact="email";
			}			
						
			if(document.frmcontact.payment.value==""){
				document.frmcontact.payment.value=document.frmcontact.phone[counter].value;
			}else{
				document.frmcontact.payment.value=document.frmcontact.payment.value+","+document.frmcontact.phone[counter].value;
			}
		}
	}
}

/******************************************/
//////
function validateinst(){
	if(trim(document.frmcity.street_name.value)==""){
		alert("Enter Street Name");
		returnFalse(document.frmcity.street_name)
		return false;
	}
	
	if(trim(document.frmcity.city.value)=="0"){
		alert("Please Select City.");
		returnFalse(document.frmcity.city)
		return false;
	}
	
	if(trim(document.frmcity.state.value)=="0"){
		alert("Please Select State.");
		returnFalse(document.frmcity.state)
		return false;
	}
	
	if(trim(document.frmcity.zip.value)!=""){
		if(!checkPhone(document.frmcity.zip.value)){
			alert("Invalid Zip number");
			//return false;
			return returnFalse(document.frmcity.zip);
		}
	}else{
			alert("Enter Zip number");
			return returnFalse(document.frmcity.zip);
	}
	
	if(trim(document.frmcity.description.value)==""){
		alert("Please Enter Description.");
		return returnFalse(document.frmcity.description)
	}
	
	
	if(trim(document.frmcity.file2.value)==""){
		alert("Please upload the image");
		return returnFalse(document.frmcity.file2)
	}
	document.frmcity.action="../admin/db_installation.php";
	document.frmcity.submit();
}
//********************
function validatepdf(){
	if(trim(document.pdf_frm.pdf_title.value)==""){
		alert("Please Enter PDF Title.");
		return returnFalse(document.pdf_frm.pdf_title)

	}
	if(trim(document.pdf_frm.file1.value)==""){
		alert("Please Enter PDF File.");
		return returnFalse(document.pdf_frm.file1)
	}
	
	rest =document.pdf_frm.file1.value.substr(document.pdf_frm.file1.value.length-3,document.pdf_frm.file1.value.length)
	//alert(rest);
	if(rest!="pdf"){
		alert("Please Upload Only PDF File");
		return returnFalse(document.pdf_frm.file1)
	}

	document.pdf_frm.action="../admin/db_reports.php";
	document.pdf_frm.submit();
}

function validatetesti(){
	if(trim(document.testi_frm.client_name.value)==""){
		alert("Enter Client Name.");
		return returnFalse(document.testi_frm.client_name)
	}
	
	var i=0;
	var testimonial="";
	document.testi_frm.version.value="";
	for (counter = 0; counter < document.testi_frm.active.length; counter++){
		if (document.testi_frm.active[counter].checked){ 
			i=1;
			if(document.testi_frm.active[counter].value=="Residential"){
				testimonial="Residential";
			}
			if(document.testi_frm.active[counter].value=="Commercial"){
				testimonial="Commercial";
			}			
			if(document.testi_frm.version.value==""){
				document.testi_frm.version.value=document.testi_frm.active[counter].value;
			}else{
				document.testi_frm.version.value=document.testi_frm.version.value+","+document.testi_frm.active[counter].value;
			}
		}
	}
	if(i==0){
		alert("Select at least one Option");
		return false;
	}
	
	document.testi_frm.action="../admin/db_testimonials.php";
	document.testi_frm.submit();
}

function returnFalse(obj){
	obj.focus();
	return false;
}
function validatepro(){
	if(trim(document.pro_frm.project_title.value)==""){
		alert("Enter Project Title.");
		return returnFalse(document.pro_frm.project_title)
	}
	
	var i=0;
	var project="";
	document.pro_frm.version.value="";
	for (counter = 0; counter < document.pro_frm.active.length; counter++){
		if (document.pro_frm.active[counter].checked){ 
			i=1;
			if(document.pro_frm.active[counter].value=="Residential"){
				testimonial="Residential";
			}
			if(document.pro_frm.active[counter].value=="Commercial"){
				testimonial="Commercial";
			}			
			if(document.pro_frm.version.value==""){
				document.pro_frm.version.value=document.pro_frm.active[counter].value;
			}else{
				document.pro_frm.version.value=document.pro_frm.version.value+","+document.pro_frm.active[counter].value;
			}
		}
	}
	if(i==0){
		alert("Select at least one Option");
		return false;
	}
	
	if(trim(document.pro_frm.category.value)=="0"){
			alert("Please Select Any One Category!");
			return returnFalse(document.pro_frm.category)
	}
	
	if(trim(document.pro_frm.file1.value)==""){
		alert("Please upload the image");
		return returnFalse(document.pro_frm.file1)
	}
	
	document.pro_frm.action="../admin/db_project.php";
	document.pro_frm.submit();
}



function validateemp(){
	
	
	if(trim(document.emp_frm.lname.value)==""){
		alert("Please Enter Last Name.");
		return returnFalse(document.emp_frm.lname)
	}
	if(!checkSalutation(document.emp_frm.lname.value)){
		alert("Invalid Last name");
		return returnFalse(document.emp_frm.lname)
	}
	
	if(trim(document.emp_frm.fname.value)==""){
		alert("Please Enter First Name");
		return returnFalse(document.emp_frm.fname)
	}
	
	if(!checkSalutation(document.emp_frm.fname.value)){
		alert("Invalid first name");
		return returnFalse(document.emp_frm.fname)
	}
	
	
	if(trim(document.emp_frm.middle_name.value)==""){
		alert("Please Enter Middle Name");
		return returnFalse(document.emp_frm.middle_name)
	}
	if(!checkSalutation(document.emp_frm.middle_name.value)){
		alert("Invalid Middle name");
		return returnFalse(document.emp_frm.middle_name)
	}
	
	
	
	if(trim(document.emp_frm.street_address.value)==""){
		alert("Please Enter Street Address");
		return returnFalse(document.emp_frm.street_address)
	}
	
	if(trim(document.emp_frm.home_phone.value)==""){
		alert("Please Enter Home Phone Number");
		return returnFalse(document.emp_frm.home_phone)
	}
												/*
												if(trim(document.emp_frm.phone.value)=="")
												{
													alert("Please Enter Phone Number.");
													return returnFalse(document.emp_frm.phone)
												}*/
		if(checkPhone(trim(document.emp_frm.home_phone.value))=="")
		{
		alert("Please Enter Correct Home Phone Number.");
		return returnFalse(document.emp_frm.home_phone)
	    }
		if(trim(document.emp_frm.city.value)==""){
		alert("Please Enter City");
		return returnFalse(document.emp_frm.city)
	}
		if(trim(document.emp_frm.state.value)==""){
		alert("Please Enter State");
		return returnFalse(document.emp_frm.state)
	}
	if(trim(document.emp_frm.zip.value)==""){
		alert("Please Enter Zip");
		return returnFalse(document.emp_frm.zip)
	}
	
	
	if(trim(document.emp_frm.email.value)==""){
		alert("Please Enter E-mail");
		returnFalse(document.emp_frm.email)
		return false;
	}


	if(checkEmailAddress(trim(document.emp_frm.email.value))==""){
		alert("Invalid Email-Id.");
		return returnFalse(document.emp_frm.email)
	}
	
		
    if(trim(document.emp_frm.ever_applied[0].checked)==true)
	{
	if(document.emp_frm.month_year.value=='')
	{ 
	alert('Please Enter Month and Year');
	return returnFalse(document.emp_frm.month_year)
	}
	if(document.emp_frm.location.value=='')
	{ 
	alert('Please Enter Location');
	return returnFalse(document.emp_frm.location)
	}
	
	
	}
	
	

    if(trim(document.emp_frm.SSN.value)==""){
		alert("Please Enter SSN");
		return returnFalse(document.emp_frm.SSN)
	}
	if(trim(document.emp_frm.position_desired.value)==""){
		alert("Please Enter Position Desired");
		return returnFalse(document.emp_frm.position_desired)
	}
	if(trim(document.emp_frm.pay_expected.value)==""){
		alert("Please Enter Pay Expected");
		return returnFalse(document.emp_frm.pay_expected)
	}
	
	
	if(trim(document.emp_frm.available_full_time[1].checked)==true)
	{
		if(document.emp_frm.wat_hrs.value=='')
	{ 
	alert('Please Enter what hours can you work?');
	return returnFalse(document.emp_frm.wat_hrs)
	}
	
	}
	
	
		
	if(document.emp_frm.date_available.value=='')
	{
		alert("Please Fill When will you be available to begin work?");
		return returnFalse(document.emp_frm.date_available)
	}
		
		
		
	/*	

if(trim(document.emp_frm.email.value)==""){
		alert("Please Enter E-mail");
		returnFalse(document.emp_frm.email)
		return false;
	}


	if(checkEmailAddress(trim(document.emp_frm.email.value))==""){
		alert("Invalid Email-Id.");
		return returnFalse(document.emp_frm.email)
	}
	
	if(trim(document.emp_frm.position.value)==""){
		alert("Please Enter Position Desired.");
		return returnFalse(document.emp_frm.position)
	}
	
	
	
	
	
	var i=0;
	var employee="";
	document.emp_frm.version.value="";
	for (counter = 0; counter < document.emp_frm.active.length; counter++){
		if (document.emp_frm.active[counter].checked){ 
			i=1;
			if(document.emp_frm.active[counter].value=="Yes"){
				employee="Yes";
			}
			if(document.emp_frm.active[counter].value=="No"){
				employee="No";
			}			
			if(document.emp_frm.version.value==""){
				document.emp_frm.version.value=document.emp_frm.active[counter].value;
			}else{
				document.emp_frm.version.value=document.emp_frm.version.value+","+document.emp_frm.active[counter].value;
			}
		}
	}
	if(i==0){
		alert("Select at least one Option");
		return false;
	}
	
	
	
	
	if(trim(document.emp_frm.operation.value)=="insert"){
		rest =document.emp_frm.file1.value.substr(document.emp_frm.file1.value.length-3,document.emp_frm.file1.value.length)
		//alert(rest);
		if(rest!="doc" && rest!="rtf" && rest!="txt" && rest!="pdf"){
			alert("Please upload only DOC,RTF,TXT,PDF format only");
			return false;
		}
	}
	
	//if(trim(document.emp_frm.file1.value)=="doc")
	
	*/
	document.emp_frm.action="admin/db_emp_app.php";
	document.emp_frm.submit();
}

function validateque(){
	
	if(trim(document.frmque.question_first_name.value)==""){
		alert("Enter first name");
		return returnFalse(document.frmque.question_first_name)
	}
	if(!checkSalutation(document.frmque.question_first_name.value)){
		alert("Invalid first name");
		return returnFalse(document.frmque.question_first_name)
	}
	if(trim(document.frmque.question_last_name.value)==""){
		alert("Enter last name");
		return returnFalse(document.frmque.question_last_name)
	}
	if(!checkSalutation(document.frmque.question_last_name.value)){
		alert("Invalid last name");
		return returnFalse(document.frmque.question_last_name)
	}
	if(trim(document.frmque.question_email_id.value)==""){
		alert("Enter Email ID");
		return returnFalse(document.frmque.question_email_id)
	}
	if(!checkEmailAddress(document.frmque.question_email_id.value)){
		alert("Invalid Email ID");
		return returnFalse(document.frmque.question_email_id)
	}
	//checkEmailAddress  
		
	if(trim(document.frmque.category.value)=="0"){
			alert("Please Select Any One Category!");
			return returnFalse(document.frmque.category)
	}
		if(trim(document.frmque.question_address.value)==""){
				alert("Please Enter Question");
			return returnFalse(document.frmque.question_address)
	}
		
	if(trim(document.frmque.street_address.value)!=""){
		if(!checkadd(document.frmque.street_address.value)){
			alert("Invalid address details");
			return returnFalse(document.frmque.street_address)
		}
	}
	if(trim(document.frmque.question_city.value)!=""){
		if(!checkcity(document.frmque.question_city.value)){
			alert("Invalid city details");
			return returnFalse(document.frmque.question_city)
		}
	}
	if(trim(document.frmque.question_state.value)!=""){
		if(!checkcity(document.frmque.question_state.value)){
			alert("Invalid state details");
			return returnFalse(document.frmque.question_state)
		}
	}
	
	if(!trim(document.frmque.question_zip.value)==""){
		if(!inValidCharZip(document.frmque.question_zip.value)){
			alert("Invalid zip code");
			return returnFalse(document.frmque.question_zip)
		}
	}
	if(trim(document.frmque.question_home_phone.value)!=""){
		if(!checkPhone(document.frmque.question_home_phone.value)){
			alert("Invalid home phone number");
			return returnFalse(document.frmque.question_home_phone)
		}
	}	
	if(trim(document.frmque.question_cell_phone.value)!=""){
		if(!checkPhone(document.frmque.question_cell_phone.value)){
			alert("Invalid cell phone number");
			return returnFalse(document.frmque.question_cell_phone)
		}
	}
	if(trim(document.frmque.hear_about.value)==""){
		alert("Please select How did you here about us");
		return returnFalse(document.frmque.hear_about)
	}
	
	document.frmque.question_information.value=""; 
	for (counter = 0; counter < document.frmque.information_topics.length; counter++){
		if (document.frmque.information_topics[counter].checked){ 
			i=1;
			if(document.frmque.question_information.value==""){
				document.frmque.question_information.value=document.frmque.information_topics[counter].value;
			}else{
				document.frmque.question_information.value=document.frmque.question_information.value+","+document.frmque.information_topics[counter].value;
			}
		}
	}
	document.frmque.action="admin/db_question.php";
	document.frmque.submit();
	
}
function returnFalse(obj){
	obj.focus();
	return false;
}
//Validation for contact us form
function validatecon(){
	
	if(trim(document.frmcontact.fname.value)==""){
		alert("Enter first name");
		return returnFalse(document.frmcontact.fname)
	}
	if(!checkSalutation(document.frmcontact.fname.value)){
		alert("Invalid first name");
		return returnFalse(document.frmcontact.fname)
	}
	if(trim(document.frmcontact.lname.value)==""){
		alert("Enter last name");
		return returnFalse(document.frmcontact.lname)
	}
	if(!checkSalutation(document.frmcontact.lname.value)){
		alert("Invalid last name");
		return returnFalse(document.frmcontact.lname)
	}
	
	if(trim(document.frmcontact.phone.value!="")){
		if(!checkPhone(document.frmcontact.phone.value)){
			alert("Invalid Phone Number");
			return returnFalse(document.frmcontact.phone)
		}
	}
	
	if(trim(document.frmcontact.email.value!="")){
		if(!checkEmailAddress(document.frmcontact.email.value)){
			alert("Invalid Email Address");
			return returnFalse(document.frmcontact.email)
		}
	}
	
	if(document.frmcontact.R[0].checked){
		if(trim(document.frmcontact.phone.value=="")){
			alert("Please Enter Phone Number");
			return returnFalse(document.frmcontact.phone)
		}else{
			if(!checkPhone(document.frmcontact.phone.value)){
				alert("Invalid Phone Number");
				return returnFalse(document.frmcontact.phone);
			}
		}
	};
	if(document.frmcontact.R[1].checked){
		if(trim(document.frmcontact.email.value=="")){
			alert("Please Enter Email Address");
			return returnFalse(document.frmcontact.email)
		}else{
			if(!checkEmailAddress(document.frmcontact.email.value)){
				alert("Invalid Email Address");
				return returnFalse(document.frmcontact.email)
			}
		}
	};
	
	//checkEmailAddress
		
	if(trim(document.frmcontact.street_address.value)==""){
			alert("Pls Enter Address details");
			return returnFalse(document.frmcontact.street_address)
		
	}
	if(trim(document.frmcontact.city.value)!=""){
		if(!checkcity(document.frmcontact.city.value)){
			alert("Invalid city details");
			return returnFalse(document.frmcontact.city)
		}
	}
	if(trim(document.frmcontact.state.value)!=""){
		if(!checkcity(document.frmcontact.state.value)){
			alert("Invalid state details");
			return returnFalse(document.frmcontact.state)
		}
	}
	
	if(trim(document.frmcontact.zip.value)!=""){
		if(!inValidCharZip(document.frmcontact.zip.value)){
			alert("Invalid zip code");
			return returnFalse(document.frmcontact.zip)
		}
	}
	
	if(trim(document.frmcontact.service_time.value)==""){
			alert("Select Service Time");
			return returnFalse(document.frmcontact.service_time)
	}
	
	
	document.frmcontact.action="admin/db_contact.php";
	document.frmcontact.submit();
	
}



function validatesubcancel(version){
	if(!checkEmailAddress(document.frmsub.subscription_email_id.value)){
		alert("Invalid Email ID");
		return false;
	}
	//checkEmailAddress
	var i=0;
	document.frmsub.subscription_version.value="";
	for (counter = 0; counter < document.frmsub.version.length; counter++){
		if (document.frmsub.version[counter].checked){ 
			//alert(document.frmsub.subscription_version[counter].value);
			i=1;
			if(document.frmsub.subscription_version.value==""){
				document.frmsub.subscription_version.value=document.frmsub.version[counter].value;
			}else{
				document.frmsub.subscription_version.value=document.frmsub.subscription_version.value+","+document.frmsub.version[counter].value;
			}
		}
	}
	if(i==0){
		alert("Select at least one version");
		return false;
	}
     
	document.frmsub.action="subscription_confirmation.php?message="+document.frmsub.subscription_version.value;
	document.frmsub.submit();
}

/////////// The following Function validate contactus form /////////


function validatecontactus()
{
if(document.frmcontact.contact_first_name.value=="")
{
alert('Please Enter First Name');
document.frmcontact.contact_first_name.focus();
return false;
}
if(document.frmcontact.contact_last_name.value=="")
{
alert('Please Enter Last Name');
document.frmcontact.contact_last_name.focus();
return false;
}


if(document.frmcontact.R[0].checked){
	if(document.frmcontact.contact_phone.value=="")	{
		alert("Please Enter Phone Number");
		document.frmcontact.contact_phone.focus();
		return false;
	}else{
		if(!checkPhone(document.frmcontact.contact_phone.value)){
			alert("Invalid Phone Number");
			document.frmcontact.contact_phone.focus();
			return false;
		}
	}
}

if(document.frmcontact.R[1].checked)
{

	if(document.frmcontact.contact_email.value=="")
	{
	alert("Please Enter Email Address");
	document.frmcontact.contact_email.focus();
	return false;
	}
}
if(trim(document.frmcontact.contact_hear_about.value)==""){
		alert("Please select How did you here about us");
		return false;
}

var flag=0;
for (counter = 0; counter < document.frmcontact.contact_req_info.length; counter++)
{
	if (document.frmcontact.contact_req_info[counter].checked)
	{
		flag=1;
	}
}
if(flag==0){
	alert("Please Check Your Interested Topic");
	return false;
}

document.frmcontact.subscription_information.value="";

	for (counter = 0; counter < document.frmcontact.contact_req_info.length; counter++){
		if (document.frmcontact.contact_req_info[counter].checked){ 
			i=1;
			if(document.frmcontact.subscription_information.value==""){
				document.frmcontact.subscription_information.value=document.frmcontact.contact_req_info[counter].value;
			}else{
				document.frmcontact.subscription_information.value=document.frmcontact.subscription_information.value+","+document.frmcontact.contact_req_info[counter].value;
			}
		}
	}
document.frmcontact.submit();
}