// 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 = "register";
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.register.contactemail.value
 var filter=/^.+@.+\..{2,3}$/

 if (filter.test(str))
    testresults=true
 else {
    alert("Please enter a valid contactemail address!")
	document.register.contactemail.value="";
	document.register.contactemail.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.register.txtQ4.disabled=false;
		document.register.txtQ4.focus();
}

function cronicFieldNo()
{
		document.register.txtQ4.disabled=true;
		document.register.txtQ4.value="";
}

function checkinfo(form)
{

	missinginfo="";
	
		if (document.register.compname.value =="")
		{
			 missinginfo += "Please enter your company name";
			 alert(missinginfo);
			 document.register.compname.focus();
			 return false;
		 }
		 
		 if (document.register.comptel.value =="")
		{
			 missinginfo += "Please enter your company general number";
			 alert(missinginfo);
			 document.register.comptel.focus();
			 return false;
		 }else if (cronicAllDigit(document.register.comptel.value) == false)
		{
			alert("Please enter a valid phone number!");
			document.register.comptel.value="";
			document.register.comptel.focus();
			return false;
		}
			if (document.register.compfax.value =="")
		{
			 missinginfo += "Please enter your company fax number";
			 alert(missinginfo);
			 document.register.compfax.focus();
			 return false;
		 }else if (cronicAllDigit(document.register.compfax.value) == false)
		{
			alert("Please enter a valid fax number!");
			document.register.compfax.value="";
			document.register.compfax.focus();
			return false;
		}
		if (document.register.compaddress.value =="")
		{
			 missinginfo += "Please enter your company address";
			 alert(missinginfo);
			 document.register.compaddress.focus();
			 return false;
		 }
		 if (document.register.compbusiness.value =="")
		{
			 missinginfo += "Please enter your business sector";
			 alert(missinginfo);
			 document.register.compbusiness.focus();
			 return false;
		 }
		////////////////////////////////////////////////////////////////////////////////////
		 if (document.register.contactname.value =="")
		{
			 missinginfo += "Please enter your name";
			 alert(missinginfo);
			 document.register.contactname.focus();
			 return false;
		 }
		 
		if (document.register.contactjobtitle.value =="")
		{
			 missinginfo += "Please enter your job title";
			 alert(missinginfo);
			 document.register.contactjobtitle.focus();
			 return false;
		 } 
		 
		 if (document.register.contacttel.value =="")
		{
			 missinginfo += "Please enter your contact number";
			 alert(missinginfo);
			 document.register.contacttel.focus();
			 return false;
		 }else if (cronicAllDigit(document.register.contacttel.value) == false)
		{
			alert("Please enter a valid phone number!");
			document.register.contacttel.value="";
			document.register.contacttel.focus();
			return false;
		}
			if (document.register.contactfax.value =="")
		{
			 missinginfo += "Please enter your fax number";
			 alert(missinginfo);
			 document.register.contactfax.focus();
			 return false;
		 }else if (cronicAllDigit(document.register.contactfax.value) == false)
		{
			alert("Please enter a valid fax number!");
			document.register.contactfax.value="";
			document.register.contactfax.focus();
			return false;
		} 
		 
		 if (document.register.contactemail.value =="")
		{
			 missinginfo += "Please enter your e-mail";
			 alert(missinginfo);
			 document.register.contactemail.focus();
			 return false;
		 }
		 
		 //////////////////////////////////////////////////////////////
		  if (document.register.delname.value =="")
		{
			 missinginfo += "Please enter the delegate name";
			 alert(missinginfo);
			 document.register.delname.focus();
			 return false;
		 }
		  if (document.register.deljobtitle.value =="")
		{
			 missinginfo += "Please enter the delegate job title";
			 alert(missinginfo);
			 document.register.deljobtitle.focus();
			 return false;
		 }
		 	 if (document.register.deltel.value =="")
		{
			 missinginfo += "Please enter the delegate contact number";
			 alert(missinginfo);
			 document.register.deltel.focus();
			 return false;
		 }else if (cronicAllDigit(document.register.deltel.value) == false)
		{
			alert("Please enter a valid phone number!");
			document.register.deltel.value="";
			document.register.deltel.focus();
			return false;
		}
		/////////////////
		if (document.register.delmobile.value =="")
		{
			 missinginfo += "Please enter the delegate mobile number";
			 alert(missinginfo);
			 document.register.delmobile.focus();
			 return false;
		 }else if (cronicAllDigit(document.register.delmobile.value) == false)
		{
			alert("Please enter a valid mobile number!");
			document.register.delmobile.value="";
			document.register.delmobile.focus();
			return false;
		}
		//////////////////
			if (document.register.delfax.value =="")
		{
			 missinginfo += "Please enter the delegate fax number";
			 alert(missinginfo);
			 document.register.delfax.focus();
			 return false;
		 }else if (cronicAllDigit(document.register.delfax.value) == false)
		{
			alert("Please enter a valid fax number!");
			document.register.delfax.value="";
			document.register.delfax.focus();
			return false;
		}  
		 
		 if (document.register.delemail.value =="")
		{
			 missinginfo += "Please enter the delegate email";
			 alert(missinginfo);
			 document.register.delemail.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);
}
