// JavaScript Document
<!-- 
//   Copyright 2000 William and Mari Bontrager
//   Copyright 2003 Bontrager Connection, LLC
//
// 	 When the form's submit button is clicked a second 
//   time, the click trap is set. Here, specify how 
//   many seconds the trap exist before it's released.

TrapClicksForHowManySeconds = 10;
// If the user clicks the submit button and causes a 
//    trap, or clicks when a trip is set, you may spawn 
//    an alert box with a message. If you do want to 
//    spawn the alert box, specify the message between 
//    the quotation marks. Otherwise, leave it blank.
//(Blank is two consecutive quotation mark characters, 
//    with nothing between them.)
// Note: If you use any quotation marks in the message 
//       itself, those must be preceeded with a back-slash 
//       character. Example: "My name is \"tall\", okay?"

AlertBoxMessage = "A single click is sufficient. The server should respond momentarily.\n\n\nClick the \"OK\" button.";
// If the user clicks the submit button and causes a trap, 
//    or clicks when a trip is set, you may spawn a popup 
//    box. If you want to spawn the popup box, specify 
//    the URL of the web page to insert into the popup. 
//    Otherwise, leave it blank. You may also specify 
//    the height of the popup and the width of the popup.

// If you want the submit button to change its text when 
//    it is clicked, specify the name you assigned to the 
//    form, the name you assigned to the submit button 
//    form field, and the new text for the submit button. 
//    Otherwise, leave at least one of these blank.

NameOfForm = "generalform";
NameOfSubmitButton = "submit";
NewTextForSubmitButton = "";

// ////////////////////////////////////////// //
// NO CUSTOMIZATION REQUIRED BELOW THIS POINT //
// ////////////////////////////////////////// //


TrapTime = 0;
DoubleClickTrapperCounter = 0;


function DoubleClickTrapperAction() {
DoubleClickTrapperCounter++;
DoubleClickTrapperButton();
var trapTheClick = false;
if(DoubleClickTrapperCounter > 1 ) { trapTheClick = true; }
if(trapTheClick == true) {
	if(TrapTime == 0) {
		var tDate = new Date;
		TrapTime = tDate.valueOf();
		}
	else {
		var tDate = new Date;
		var localTrapTime = tDate.valueOf();
		if((localTrapTime - TrapTime) > (TrapClicksForHowManySeconds * 1000)) {
			TrapTime = 0;
			trapTheClick = false;
			DoubleClickTrapperCounter = 0;
			}
		}
	}
var valueToReturn = true;
if(trapTheClick == true) {
	valueToReturn = false;
	DoubleClickTrapperAlert();
	}
return valueToReturn;
} // end of function DoubleClickTrapperAction()


function DoubleClickTrapperButton() {
var formname   = StripSpaces(NameOfForm);
var submitname = StripSpaces(NameOfSubmitButton);
var newtext    = StripSpaces(NewTextForSubmitButton);
if(formname.length > 0 && submitname.length > 0 && newtext.length > 0) {
	var s = 'document.' + NameOfForm + '.' + NameOfSubmitButton + ".value = '" + NewTextForSubmitButton + "'";
	eval(s);
	}
} // end of function DoubleClickTrapperButton()


function DoubleClickTrapperAlert() {
var message = StripSpaces(AlertBoxMessage);
if(message.length > 0) { alert(AlertBoxMessage); }
} // end of function DoubleClickTrapperAlert()


function StripSpaces(s) {
while(s.indexOf(' ') == 0) { s = s.substr(1); }
return s;
} // end of function StripSpaces()

// -->
var testresults

function checkemail(){
 var str=document.generalform.email.value
 var filter=/^.+@.+\..{2,3}$/

 if (filter.test(str))
    testresults=true
 else {
    alert("Please enter a valid email address!")
	document.generalform.email.value="";
	document.generalform.email.focus();
    testresults=false
}
 return (testresults)
}

function cronicDigit(c)
	{
	   var test = "" + c;

		if (test == "0" || test == "1" || test == "2" || test == "3" || test == "4"
	        || test == "5" || test == "6" || test == "7" || test == "8" || test == "9" || test == "-" || test == "+" || test == " ")
	        {
	             return true;
	        }
	         return false;  
	}
	
function cronicAllDigit(s)
	{
	   var test = "" + s;
	        for (var k =0; k < test.length; k++)
	        {
			  var c = test.substring(k, k+1);
	             if (cronicDigit(c) == false)
	             {
	                 return false;
	             }
	         }
	}
	
function cronicFieldYes()
{
		document.generalform.txtQ4.disabled=false;
		document.generalform.txtQ4.focus();
}

function cronicFieldNo()
{
		document.generalform.txtQ4.disabled=true;
		document.generalform.txtQ4.value="";
}

function checkinfo(form)
{

	missinginfo="";
	
		if (document.generalform.name.value =="")
		{
			 missinginfo += "Please enter your name";
			 alert(missinginfo);
			 document.generalform.name.focus();
			 return false;
		 }
		 if (document.generalform.mobileno.value =="")
		{
			 missinginfo += "Please enter your mobile number";
			 alert(missinginfo);
			 document.generalform.mobileno.focus();
			 return false;
		 }else if (cronicAllDigit(document.generalform.mobileno.value) == false)
		{
			alert("Please enter a valid mobile number!");
			document.generalform.mobileno.value="";
			document.generalform.mobileno.focus();
			return false;
		}
		 if (document.generalform.email.value =="")
		{
			 missinginfo += "Please enter your e-mail";
			 alert(missinginfo);
			 document.generalform.email.focus();
			 return false;
		 }
		  if (document.generalform.position.value =="")
		{
			 missinginfo += "Please enter your applied position";
			 alert(missinginfo);
			 document.generalform.position.focus();
			 return false;
		 }
		 if (document.generalform.txtQ1.value =="")
		{
			 missinginfo += "Please answer question 1";
			 alert(missinginfo);
			 document.generalform.txtQ1.focus();
			 return false;
		 }
		 if (document.generalform.txtQ2.value =="")
		{
			 missinginfo += "Please answer question 2";
			 alert(missinginfo);
			 document.generalform.txtQ2.focus();
			 return false;
		 }
		 if (document.generalform.txtQ3.value =="")
		{
			 missinginfo += "Please answer question 3";
			 alert(missinginfo);
			 document.generalform.txtQ3.focus();
			 return false;
		 }
		var groupa = document.generalform.rdbQ4;
		for (var i=0; i<groupa.length; i++) {
		if (groupa[i].checked) break;
		}
		if (i==groupa.length)
		{
		alert("Please select 'YES' or 'NO' on question 4");
		return false;
		}
	
		var c=i+1;
		if (c==2)
		{
		if (document.generalform.rdbQ4.value=="")
		{
			alert("Please answer question 4");
			document.generalform.txtQ4.focus();
			return false;
		}
		}
		if (document.generalform.txtQ3.value =="")
		{
			 missinginfo += "Please answer question 3";
			 alert(missinginfo);
			 document.generalform.txtQ3.focus();
			 return false;
		 }
		 if (document.generalform.txtQ5.value =="")
		{
			 missinginfo += "Please answer question 5";
			 alert(missinginfo);
			 document.generalform.txtQ5.focus();
			 return false;
		 }
		 if (document.generalform.txtQ6.value =="")
		{
			 missinginfo += "Please answer question 6";
			 alert(missinginfo);
			 document.generalform.txtQ6.focus();
			 return false;
		 }
		 if (document.generalform.txtQ7.value =="")
		{
			 missinginfo += "Please answer question 7";
			 alert(missinginfo);
			 document.generalform.txtQ7.focus();
			 return false;
		 }
		 var groupa = document.generalform.rdbQ8;
		for (var i=0; i<groupa.length; i++) {
		if (groupa[i].checked) break;
		}
		if (i==groupa.length)
		{
		alert("Please check one button on question 8");
		return false;
		}
		if (document.generalform.txtQ8.value =="")
		{
			 missinginfo += "Please answer question 8";
			 alert(missinginfo);
			 document.generalform.txtQ8.focus();
			 return false;
		 }
		 if (document.generalform.txtQ9.value =="")
		{
			 missinginfo += "Please answer question 9";
			 alert(missinginfo);
			 document.generalform.txtQ9.focus();
			 return false;
		 }
		 if (document.generalform.txtQ10.value =="")
		{
			 missinginfo += "Please answer question 10";
			 alert(missinginfo);
			 document.generalform.txtQ10.focus();
			 return false;
		 }
		 if (document.generalform.txtQ11.value =="")
		{
			 missinginfo += "Please answer question 11";
			 alert(missinginfo);
			 document.generalform.txtQ11.focus();
			 return false;
		 }
		 if (document.generalform.resume.value ==""){
		missinginfo += "Please create your own text resume";
		alert(missinginfo);
		document.generalform.resume.focus();
		return false;
	}
		if (document.layers||document.all)
		{
			return checkemail()
		}else
		{
		return true
		}
DoubleClickTrapperAction();
}

function textLimit(field, maxlen) {
if (field.value.length > maxlen + 1)
alert('You have exceeding the text limit, Your resume has been truncated!');
if (field.value.length > maxlen)
field.value = field.value.substring(0, maxlen);
}
