// Compiled by: Burnz ^_^
function count_chars() { 
  counter = document.warrantyappa.txtask.value 
  left = (250 - (counter.length)) 
	  
	 if ( left <= 0 ) { 
		document.warrantyappa.count.value = 0 
		document.warrantyappa.txtask.value = document.warrantyappa.txtask.value.substr(0,250) 
	 } else { 
		document.warrantyappa.count.value = left 
	 } 
} 

function nextbox(fldobj,nbox)
{
if(fldobj.value.length>2)
{document.form.elements[nbox].focus()}
}

function getKeyCode(e)
{
	if (window.event)
	   return window.event.keyCode;
	else if (e)
	   return e.which;
	else
	   return null;
}
function keyRestrict(e, validchars) { 
	var key='', keychar='';
	key = getKeyCode(e);
	if (key == null) return true;
	keychar = String.fromCharCode(key);
	keychar = keychar.toLowerCase();
	validchars = validchars.toLowerCase();
	if (validchars.indexOf(keychar) != -1)
		return true;
	if ( key==null || key==0 || key==8 || key==9 || key==13 || key==27 )
		return true;
	return false;
}

function awarranty()
{
	var themessage = "Please complete the following fields: \r\n";
	var msgctr = 0;
	//GENERAL PROJECT INFORMATION
	themessage = themessage + "\r\n GENERAL PROJECT INFORMATION";
	if (document.warrantyappa.aprojname.value=="") {
	themessage = themessage + "\r\n Project Name";
	msgctr = msgctr+1;
	}
	if (document.warrantyappa.aprojadd.value=="") {
	themessage = themessage + "\r\n Project Address";
	msgctr = msgctr+1;
	}
	if (document.warrantyappa.afuncbldg.value=="") {
	themessage = themessage + "\r\n Function of Building (s)";
	msgctr = msgctr+1;
	}
	if (document.warrantyappa.abldgowner.value=="") {
	themessage = themessage + "\r\n Building Owner/Company Name";
	msgctr = msgctr+1;
	}
	if (document.warrantyappa.adirectcor.value=="") {
	themessage = themessage + "\r\n Direct correspondence to";
	msgctr = msgctr+1;
	}
	if (document.warrantyappa.atitle.value=="") {
	themessage = themessage + "\r\n Title";
	msgctr = msgctr+1;
	}
	if (document.warrantyappa.aadd.value=="") {
	themessage = themessage + "\r\n Address";
	msgctr = msgctr+1;
	}
	if (document.warrantyappa.aphone.value=="") {
	themessage = themessage + "\r\n Owner / Contact Phone";
	msgctr = msgctr+1;
	}
	if (document.warrantyappa.afax.value=="") {
	themessage = themessage + "\r\n Fax";
	msgctr = msgctr+1;
	}
	
/*
	chkctr=0;
	
		if (document.warrantyappa.achksystem[0].checked==true) {
		chkctr = chkctr+1;
		}
		if (document.warrantyappa.achksystem[1].checked==true) {
		chkctr = chkctr+1;
		}
		if (document.warrantyappa.achksystem[2].checked==true) {
		chkctr = chkctr+1;
		}
		if (document.warrantyappa.achksystem[3].checked==true) {
		chkctr = chkctr+1;
		}
		if (document.warrantyappa.achksystem[4].checked==true) {
		chkctr = chkctr+1;
		}
		if (document.warrantyappa.achksystem[5].checked==true) {
		chkctr = chkctr+1;
		}
		if (document.warrantyappa.achksystem[6].checked==true) {
		chkctr = chkctr+1;
		}
		if (document.warrantyappa.achksystem[7].checked==true) {
		chkctr = chkctr+1;
		}
		

	if(chkctr==0){
	themessage = themessage + "\r\n Type of System";
	msgctr = msgctr+1;
	}

*/
	if (document.warrantyappa.aexpstart.value=="") {
	themessage = themessage + "\r\n Expected Start Date";
	msgctr = msgctr+1;
	}
	if (document.warrantyappa.aexpcomdate.value=="") {
	themessage = themessage + "\r\n Expected Completion Date";
	msgctr = msgctr+1;
	}
	if (document.warrantyappa.aprsqft.value=="") {
	themessage = themessage + "\r\n Project Square Footage";
	msgctr = msgctr+1;
	}
	if (document.warrantyappa.aprdeckty.value=="") {
	themessage = themessage + "\r\n Project Deck Type";
	msgctr = msgctr+1;
	}
	if (document.warrantyappa.anumexpr.value=="") {
	themessage = themessage + "\r\n Number of Existing Roofs";
	msgctr = msgctr+1;
	}
	if (document.warrantyappa.atypesub.value=="") {
	themessage = themessage + "\r\n Type of Substrate and Existing System";
	msgctr = msgctr+1;
	}
	if (document.warrantyappa.aage.value=="") {
	themessage = themessage + "\r\n Age";
	msgctr = msgctr+1;
	}
	if (document.warrantyappa.avapordesc.value=="" && document.warrantyappa.achkvapor[1].checked==true) {
	themessage = themessage + "\r\n High Vapor Drive Description";
	msgctr = msgctr+1;
	}
	if (document.warrantyappa.adescsub.value=="") {
	themessage = themessage + "\r\n Describe Substrate Preparation";
	msgctr = msgctr+1;
	}
	if (document.warrantyappa.amethodapp.value=="") {
	themessage = themessage + "\r\n Method of Application";
	msgctr = msgctr+1;
	}
	if (document.warrantyappa.aantiche.value=="") {
	themessage = themessage + "\r\n Anticipated Chemical Attack";
	msgctr = msgctr+1;
	}
	if (document.warrantyappa.aextsta.value=="") {
	themessage = themessage + "\r\n Extent of standing water 48 hours after rain";
	msgctr = msgctr+1;
	}
	if (document.warrantyappa.aaddcom.value=="") {
	themessage = themessage + "\r\n Additional Comments";
	msgctr = msgctr+1;
	}
	
	if (msgctr==0){
	themessage = themessage + "\r\n---Completed---";
	}

	//SPECIFIERīS INFORMATION
	themessage = themessage + "\r\n\r\n SPECIFIERīS INFORMATION";
	msgctr=0;
	
	if (document.warrantyappa.aspename.value=="") {
	themessage = themessage + "\r\n Name";
	msgctr = msgctr+1;
	}
	if (document.warrantyappa.aspeadd.value=="") {
	themessage = themessage + "\r\n Address";
	msgctr = msgctr+1;
	}
	if (document.warrantyappa.aspephone.value=="") {
	themessage = themessage + "\r\n Phone";
	msgctr = msgctr+1;
	}
	
	if (msgctr==0){
	themessage = themessage + "\r\n---Completed---";
	}

	//APPLICATOR INFORMATION
	themessage = themessage + "\r\n\r\n APPLICATOR INFORMATION";
	msgctr=0;
	
	if (document.warrantyappa.aappcomname.value=="") {
	themessage = themessage + "\r\n Company Name";
	msgctr = msgctr+1;
	}
	if (document.warrantyappa.aappadd.value=="") {
	themessage = themessage + "\r\n Address";
	msgctr = msgctr+1;
	}
	if (document.warrantyappa.aappphone.value=="") {
	themessage = themessage + "\r\n Phone";
	msgctr = msgctr+1;
	}
	if (document.warrantyappa.aappfax.value=="") {
	themessage = themessage + "\r\n Fax";
	msgctr = msgctr+1;
	}
	if (document.warrantyappa.aapplicense.value=="") {
	themessage = themessage + "\r\n License";
	msgctr = msgctr+1;
	}
	if (document.warrantyappa.aappprojman.value=="") {
	themessage = themessage + "\r\n Project Manager";
	msgctr = msgctr+1;
	}
	
	
	if (document.warrantyappa.txttitle.value=="") {
	themessage = themessage + "\r\n Title";
	msgctr = msgctr+1;
	}
	
		if (document.warrantyappa.txtname.value=="") {
	themessage = themessage + "\r\n Name";
	msgctr = msgctr+1;
	}
	
	
	

//email validation	
  if (document.warrantyappa.txtemail.value =="") 
    {
    themessage = themessage + "\r\n Email";
	msgctr = msgctr+1;
    }
else{
		
var str=document.warrantyappa.txtemail.value
var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
if (filter.test(str))
testresults=true
else{
themessage = themessage + "\r\n Valid Email";
msgctr = msgctr+1;
}}//end email validation
	

	
	
	
	if (msgctr==0){
	themessage = themessage + "\r\n---Completed---";
	}


//alert if fields are empty and cancel form submit
	if (themessage == "Please complete the following fields: \r\n\r\n GENERAL PROJECT INFORMATION\r\n---Completed---\r\n\r\n SPECIFIERīS INFORMATION\r\n---Completed---\r\n\r\n APPLICATOR INFORMATION\r\n---Completed---")
	{
//		document.warrantyappa.action = "warranty_applicationb.shtml"; 
		document.warrantyappa.action = "sendmail.php"; 
		document.warrantyappa.submit(); 
//		document.warrantyappa.reset();

	}
	else
	{
		alert(themessage);
		return false;
	}
}