// Copyright (c) 1999-2006 Cyber-dynamics International Inc. All Rights Reserved
// CDforms.js version 5.10 (mod 11)

function bookM(){if (document.all){var uRL=self.location.href,txt=self.document.title;window.external.AddFavorite(uRL,txt);}else{alert("Please click OK then press CTRL-D");}}
function bookmarkForm(sURL, sCaption) {if (window.external) {window.external.AddFavorite(sURL,sCaption);} else{alert('Sorry, your browser does not support dynamic bookmarks. Please print the page or make a note of the reference number.');}}

function clickClear(oMe,sVal) {if (oMe.value==sVal){oMe.value='';}}
function sStatus(sStr) {window.status=sStr;document.returnValue=true;}
function badEmail(str){if (isBlank(str)||(str.indexOf("@")==-1)||(str.indexOf(".")==-1)||(str.length<6)){return true}else{return false}}	 
function badField(str,minlength){if(isBlank(str)||(str.length<minlength)){return true}else{return false}}	 
function isBlank(str){if(str.length==0){return true};for(i=0;i<=str.length-1;i++){if(str.charAt(i)!=" "){return false}}return true;}

function checkForm(oForm){var err = "",f;if (oForm) {f=oForm} else {if (document.inquiry){f=document.inquiry;}else{if(document.admanager){f=document.admanager;}}}
var i,s,fE=f.elements,iFound=0;
	for(i=0;i<fE.length;i++){ 
		if  (!((fE[i].name.substr(0,1) == '_') || (fE[i].name.substr(1,1) == '_'))) {
			if  ( ((fE[i].value.indexOf('>') > -1) || (fE[i].value.indexOf('<') > -1)) || (fE[i].value.indexOf('|') > -1) ) {
				alert('Please do not use special characters such as  < > or |\nNote to spammers: you cannot use this form for spamming');iFound = 1;fE[i].focus();break;
		}	}
		if (iFound == 0) {
			var aEmails = new Array(); aEmails = fE[i].value.split("@");if (aEmails.length > 4) {
				alert('Too many @ signs. Please use a + instead if necessary.\nNote to spammers: you cannot use this form for spamming');
				iFound = 1;fE[i].focus();break;	
		}	} 
		if (iFound == 0) {
			var aHTTP = new Array(); aHTTP = fE[i].value.split(/http\:\/\//);if (aHTTP.length > 4) {
				alert('Too many URLs. Please amend.\nNote to spammers: you cannot use this form for spamming or posting links.');
				iFound = 1;fE[i].focus();break;	
	}	}	} 
if(iFound==0){
	iFields = new Array;if(f._required){iFields = f._required.value.split(",");}
	else if(f.i_required){iFields = f.i_required.value.split(",");}
	for (var i=0;i<iFields.length;i++){if(iFields[i].length>1){
if(iFields[i].indexOf("Email")>-1){if(badEmail(f[iFields[i]].value)) {err+=", "+iFields[i];}}else{if (badField(f[iFields[i]].value,2)){err+=", "+iFields[i];}}}}
if(err){alert("Please check the following entries and then submit this form:\n"+err.substr(2));return false;}else{
	if ((f.i_antiSpamDevice) && (cdAntiSpamCheck(f) == 0)) {
		alert('Please confirm the security code.');
		f.i_antiSpamCheck.focus();
	} else {	
		f.title.value=document.title;
		f.submit();
	}}}
	return false;
}

function cdSwapAntiSpam(sImage,sSRC1,sSRC2) {
	if (document.getElementById){
		var img = document.getElementById(sImage);
		if(img.src.indexOf(sSRC1)>-1) {
				document.getElementById(sImage).src=sSRC2;				
			}else {
				document.getElementById(sImage).src=sSRC1;
}	}	}	

function cdAntiSpamCheck(sFormID){
	var i=0,j=0,k=4,s = sFormID.i_antiSpamCheck.value;
	if (s.length==5) {
		for (j=0;j<4;j++){i = i + (k * s.charAt(j));k--;}
		if ((i%11) == s.charAt(4)) {
			return(1);
	}	}
		return(0);
}
