/*
'<!--$$Revision: 8 $-->
'<!--$$Author: Errol $-->
'<!--$$Date: 9/04/09 11:40a $-->
'<!--$$Logfile: /4.0 Arts Hub/shared/js/bn.js $-->
'<!--$$NoKeywords: $-->
*/
/*#################################################################
//	Name	: Errol Willenberg 
//	Purpose	: Bubbanoosh validation
##################################################################*/
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//			Form Validation
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//Global Array for use with Validating Manditory fields
var arrData = new Array();
var error_intro = "The follow fields are required .. \n__________________________________\n\n";

/* _________________________________________________________________________________________________________________________________ */
//	Name 		- fnIsValidFormData ------------------------------------------------------------------------------------------------
//  Purpose		- Fully Generic Form Validation
//	Args 		- form as Object, arrElements containg field names 
//	Consumes 	- fnIsNullOrEmptyFld
//  ** Note	**	- Only for validating Text, not Numeric or Date data
/* ________________________________________________________________________________________________________________________________ */
function fnIsValidFormData(frm, arrElements, tConfirmationMsg){//, bIsUplMsg, uplFld
	
	var fcsCtl; var bPost = false;
	var msg = "", tSect = "", fcsField = "";
	var tFakedFldName = "", tRealFldName = ""
	//resetBorder(frm);
	if ( typeof(arrElements) != "object" ) {											// If arrElements is not an Object validate entire form
		if (arrElements != "NoValidation" && arrElements == "") {						//Only validate if empty arg											
			for (var i=0 ; i<frm.length ; i++) {
				fcsField = "" ;
				msg += fnFormatFriendlyMessage( fnHandleDataType( frm.elements[i] ), "" );
				fcsField = fnHandleDataType( frm.elements[i], "" );
				if ( fcsField != "" ) {
					if ( typeof(fcsCtl) == "undefined" ) { fcsCtl = frm.elements[i] ; }
				}
			}
		}
	// onsubmit="return fnIsValidFormData(this, arrElements=['tLinkType','tLinkName','tLinkDesc','tLinkHref'], 'Link', 'Edit');"
	} else {																	// if arrElements is not null or empty
		for (var i=0 ; i<arrElements.length ; i++) {							// Then it is assumed to be an Array That was passed in containing only
				fcsField = "" ;
				if (arrElements[i].indexOf("|") > 0 ) {
					// 'real_Fld_Name|fld_Name_To_Display'
				//window.alert(arrElements[i]);	
					tRealFldName = eval("frm." + arrElements[i].substring(0, arrElements[i].indexOf("|")));
					//tRealFldName = arrElements[i].substring(0, arrElements[i].indexOf("|"));
				//window.alert(tRealFldName);	
					tFakedFldName = arrElements[i].substring(arrElements[i].indexOf("|")+1, arrElements[i].length );
				//window.alert(tFakedFldName);	
					msg += fnFormatFriendlyMessage( fnHandleDataType(tRealFldName , tFakedFldName) );		// form componant names. Loop through these fields only							
					fcsField = fnHandleDataType( tRealFldName, tFakedFldName );	// Here we find out Which field to focus
					if ( fcsField != "" ) {
						if ( typeof(fcsCtl) == "undefined" ) { fcsCtl = tRealFldName ; }
					}
				} else {
					msg += fnFormatFriendlyMessage( fnHandleDataType( eval("frm." + arrElements[i]), "" ) );		// form componant names. Loop through these fields only							
					fcsField = fnHandleDataType( eval("frm." + arrElements[i]), "" );	// Here we find out Which field to focus
					if ( fcsField != "" ) {
						if ( typeof(fcsCtl) == "undefined" ) { fcsCtl = eval("frm." + arrElements[i]) ; }
					}
				}
		}
	}
	if (msg != "") {
		window.alert("The follow fields are required .. \n__________________________________\n\n" + msg);
		if ( typeof(fcsCtl) != "undefined" ) {
			fcsCtl.focus() ; 
		}
		return false;
	} else {
		
		if (tConfirmationMsg != "") {
			bPost = window.confirm(tConfirmationMsg);
		} else { bPost = true; }
		if (typeof(bUseProgressMeter) != "undefined") {
			//function dispProgress() in printed in php page
			//and bUseProgressMeter init and set to true
			if (bPost && bUseProgressMeter) {  
				dispProgress();
			}
		}
		return bPost
	}
}
/* _________________________________________________________________________________________________________________________________ */
//	Name 		- fnHandleDataType ------------------------------------------------------------------------------------------------
//  Purpose		- Determine Datatype of Fld and handle appropriately
//	Args 		- Form field as Object, fldNameToDisplay if ACTUAL field name is obscure like M_sCatLevel0 (pass in 't_sCatLevel|Business_segment' from onsubmit array)
//	Consumes 	- Other Generic validation functions dependant on datatype
//  Returns 	- An Appropriate Error message to fnIsValidFormData for final output 
//  ** Note	**	- This function takes the 1st Char of the Fld name to determine datatype
/* ________________________________________________________________________________________________________________________________ */
function fnHandleDataType(obj, fldNameToDisplay) {
	var fld = "", fldName = "", retMsg = "";
	var fldNameDisplay = "";
	
	if (fnIsNullOrEmptyValue(obj)) { 
		return fld;
	} else {
		fld = obj.name;
		if (fldNameToDisplay == "") {
			fldName = fld.substring(1, fld.length);								//Get field name minus the first char
			fld = fld.charAt(0);												//Get the 1st char to find datatype
			fldNameToDisplay = fldName;
		} else {
			fldName = fld.substring(1, fld.length);								//Get field name minus the first char
			fld = fld.charAt(0);												//Get the 1st char to find datatype
			fldNameToDisplay = fldNameToDisplay;
		}
	}
	switch (fld) {
		case "a"://ABN number
			if ( fnIsInvalidABNNumber( obj, false ) ) { 
			return "\n * " + fldNameToDisplay + " - must be a valid ABN number" ;
			} else {return "";}
			break;
		case "t"://text
			if ( fnIsNullOrEmptyFld( obj ) ) { 
			return "\n * " + fldNameToDisplay + " - must be entered correctly" ;
			} else {return "";}
			break;
		case "M"://text for M_fieldname fields hack as MG uses -2 for empty values in some cases in classifieds
			if ( fnIsNullOrEmptyFldOrMinus2( obj ) ) { 
			return "\n * " + fldNameToDisplay + " - must be entered or chosen" ;
			} else {return "";}
			break;
		case "e"://email
			return fnIsInvalidEmail( obj, fldName ); 
			break;
		case "w"://url
			return fnIsInvalidURL( obj, fldName ); 
			break;
		case "n"://general number
			if ( fnIsInvalidNum( obj ) ) { 
				return "\n * " + fldNameToDisplay + " - must be a Valid Number";
			} else {return "";}
			break;
		case "x"://general number (but txt to the user)
			if ( fnIsInvalidNum( obj ) ) { 
				return "\n * " + fldNameToDisplay + " - must be Valid";
			} else {return "";}
			break;
		case "i"://integer
			if ( fnIsInvalidInt( obj ) ) { 
				return "\n * " + fldNameToDisplay + " - must be a Valid Number with no \'.\'";
			} else {return "";}
			break;
		case "f"://float
			if ( fnIsInvalidFloat( obj ) ) { 
				return "\n * " + fldNameToDisplay + " - must be a Valid Decimal point number";
			} else {return "";}
			break;
		case "r", "c"://radio button checkbox, only single check box val
			if ( ! fnIsChecked( obj ) ) { 
				return "\n * " + fldNameToDisplay + " - must be Chosen";
			} else {return "";}
			break;
		default:
			if ( fnIsNullOrEmptyFld( obj ) ) { 
				return "\n * " + fldNameToDisplay + " - must be entered correctly";
			} else {return "";}
			break;
	}
}
/* _________________________________________________________________________________________________________________________________ */
//	Name 		- fnFormatFriendlyMessage ------------------------------------------------------------------------------------------------
//  Purpose		- Formats Error messages, replaces _ in element names with " "
//	Args 		- Text String Error Message
/* ________________________________________________________________________________________________________________________________ */
function fnFormatFriendlyMessage( tErrorString ){
	if ( tErrorString != "" ) {
		var ret = "";
		ret = tErrorString.split("_");
		ret = ret.join(" ");
		if ( ret.indexOf("", 0) ) {
			
		}
		return ret;
	} else {
		return "";
	}	
}
/* _________________________________________________________________________________________________________________________________ */
//	Name 		- fnFormatFriendlyMessage ------------------------------------------------------------------------------------------------
//  Purpose		- Formats Error messages, replaces _ in element names with " "
//	Args 		- Text String Error Message
//  Reference	- http://www.ato.gov.au/businesses/content.asp?doc=/content/13187.htm&pc=001/003/021/002/001&mnu=610&mfp=001/003&st=&cy=1
/* ________________________________________________________________________________________________________________________________ */
function fnIsInvalidABNNumber(obj, bFromFieldCheck) {
	var bRet = true;
	var retABN = '';
	var trueABN = '';
	var abn = '';
	var i = 0;
	var sum = 0;
	var remainder = '';
	var weightFactor = 0;
	var fullAmt = 0;
	var pos1 = '', firstDigit = '', otherDigits = '', testAbn = '';
	var nTrueLength = 0;
	var c = 0;
	
	if (obj.disabled == false) {
		abn = obj.value;
		if (abn != "") {
			for (i = 0 ; i < abn.length ; i++) {
				//remove non numeric chars to test the actual abn
				if (! isNaN(parseInt(abn.charAt(i)))) {
					retABN += "" + abn.charAt(i);
				}
			}
		}
		if (retABN != "") {
			bRet = true;
			pos1 = retABN.charAt(0);					//first number
			firstDigit = parseInt(pos1) - 1;			//..
			trueABN = retABN.substring(0, 11); 			//11 digits
			otherDigits = retABN.substring(1, 11); 		//11 digits, get the last 10
			testAbn = firstDigit + "" + otherDigits;	//put the new first number with the last 10
			//window.alert("testAbn:"+testAbn+"\nlength:"+testAbn.length);
			for (i=0 ; i <testAbn.length ; i++) {
				c += 1;
				//Multiply each digit by it's weight factor
				if (i==0) {
					weightFactor = 10;
				} else if (i==1) {
					weightFactor = 1;	
				} else {
					weightFactor += 2; //go up by odd numbers for weight factor	
				}
				fullAmt = (parseInt(testAbn.charAt(i)) * weightFactor);
				sum += fullAmt;
				//window.alert("count:" +c+ "\nresult:"+ parseInt(testAbn.charAt(i)) +"* " + weightFactor + " = " + fullAmt + "\nSum="+ sum +"");
			}
			nTrueLength = testAbn.length;
			remainder = sum%89; //divide resulting sum by 89... mod should be zero
			if (remainder ===0) { bRet = false; }
		}
		/*window.alert("i:"+i);
		window.alert("bFromFieldCheck:"+bFromFieldCheck);
		window.alert("bRet:"+bRet);
		window.alert("abn:"+abn);
		window.alert("nTrueLength:"+nTrueLength);
		window.alert("sum:"+sum);
		window.alert("remainder:"+remainder);
		window.alert("retAbn:"+retAbn);*/
	}
	
	if (bFromFieldCheck && bRet==true && (abn == "" || abn == " ")) {
		window.alert("Your ABN is blank!");
	} else if (bFromFieldCheck && isNaN(trueABN)) { //length was taken from count of i which should be 1 less than 11 (ten)
		window.alert("Your ABN (" + trueABN + ") is not numeric!");
	} else if (bFromFieldCheck && nTrueLength != 11) { //length was taken from count of i which should be 1 less than 11 (ten)
		window.alert("Your ABN (" + abn + ") is (" +nTrueLength+ ") digits in length\nABN's should be 11 digits long!");
	} else if (bFromFieldCheck && bRet!=true && abn != "" && nTrueLength == 11) {
		window.alert("Your ABN (" + abn + ") Validates");
	} else if (bFromFieldCheck && bRet==true && abn != "") {
		window.alert("Sorry, your ABN (" + abn + ") did not validate");
	} else {
		return bRet;
	}
}
/* _________________________________________________________________________________________________________________________________ */
//	Name 		- fnIsNullOrEmptyFld ------------------------------------------------------------------------------------------------
//  Purpose		- Tests for invalid, empty, null values
//	Args 		- Form element as Object
/* ________________________________________________________________________________________________________________________________ */
function fnIsNullOrEmptyFld(obj) {
	var bRet = false;
	if (obj.disabled == false) {
		if (obj.value == "undefined" || obj.value == null || obj.value == "" ) {
			bRet = true;
		}
	}
	return bRet;
}
/* _________________________________________________________________________________________________________________________________ */
//	Name 		- fnIsNullOrEmptyFldOrMinus2 ------------------------------------------------------------------------------------------------
//  Purpose		- Tests for invalid, empty, null, -2 values
//	Args 		- Form element as Object
/* ________________________________________________________________________________________________________________________________ */
function fnIsNullOrEmptyFldOrMinus2(obj) {
	var bRet = false;
	if (obj.disabled == false) {
		if (obj.value == "undefined" || obj.value == null || obj.value == "" || obj.value == "-2" ) {
			bRet = true;
		}
	}
	return bRet;
}
/* _________________________________________________________________________________________________________________________________ */
//	Name 		- fnIsNullOrEmptyValue ------------------------------------------------------------------------------------------------
//  Purpose		- Tests for invalid, empty, null values
//	Args 		- text, number
/* ________________________________________________________________________________________________________________________________ */
function fnIsNullOrEmptyValue(x) {
	var bRet = false;
	if (x == "undefined" || x == null || x == "") {
		bRet = true;
	}
	return bRet;
}
/* _________________________________________________________________________________________________________________________________ */
//	Name 		- fnIsInvalidInt ------------------------------------------------------------------------------------------------
//  Purpose		- Check if is a valid postive integer
//	Args 		- Form element as Object
/* ________________________________________________________________________________________________________________________________ */
function fnIsInvalidInt(obj) {
	var bRet = false ;
	if (obj.disabled == false) {
		if (obj.value=="" || isNaN(obj.value) || obj.value < 0 || obj.value == null || obj.value.indexOf(".",0) != -1) {
			bRet = true;
		}
	}
	return bRet;
}
/* _________________________________________________________________________________________________________________________________ */
//	Name 		- fnIsInvalidFloat ------------------------------------------------------------------------------------------------
//  Purpose		- Check if is a valid postive integer
//	Args 		- Form element as Object
/* ________________________________________________________________________________________________________________________________ */
function fnIsInvalidFloat(obj) {
	var bRet = false ;
	if (obj.value=="" || isNaN(obj.value) || obj.value < 0 || obj.value == null || obj.value.indexOf(".",0) == -1) {
		bRet = true;
	}
	return bRet;
}
/* _________________________________________________________________________________________________________________________________ */
//	Name 		- fnIsInvalidFloat ------------------------------------------------------------------------------------------------
//  Purpose		- Check if is a valid postive integer
//	Args 		- Form element as Object
/* ________________________________________________________________________________________________________________________________ */
function fnIsInvalidNum(obj) {
	var bRet = false ;
	if (obj.disabled == false) {
		if (obj.value=="" || isNaN(obj.value) || obj.value < 0 || obj.value == "0" || obj.value == null) {
			bRet = true;
		}
	}
	return bRet;
}
/* _________________________________________________________________________________________________________________________________ */
//	Name 		- fnIsInvalidEmail ------------------------------------------------------------------------------------------------
//  Purpose		- Tests for invalid emails, empty, null values
//	Args 		- Form element as Object, Field name for msg
/* ________________________________________________________________________________________________________________________________ */
function fnIsInvalidEmail(obj, tField) {
	var bRet = "";
	if (obj.disabled == false) {
		if (!fnIsNullOrEmptyFld(obj)) {
			if (obj.value.indexOf('@',0)==-1||obj.value.indexOf('@',0)==0||obj.value.indexOf('.',0)==-1||obj.value.indexOf(',',0)!=-1||obj.value.indexOf(' ',0)!=-1) {
				bRet = "\n * " + tField + " - must be a VALID Email address containing an @ and 1 or more dots " ;
			} 
		} else {
			bRet = "\n * " + tField + " - cannot be blank " ;;
		}
	}
	return bRet;
}
/* _________________________________________________________________________________________________________________________________ */
//	Name 		- fnIsInvalidURL ------------------------------------------------------------------------------------------------
//  Purpose		- Tests for invalid url, empty, null values
//	Args 		- Form element as Object
/* ________________________________________________________________________________________________________________________________ */
function fnIsInvalidURL(obj) {
	var bRet = "", bSelect = false;
	if (obj.disabled == false) {
		if (!fnIsNullOrEmptyFld( eval(obj) )) {
			if (obj.value.indexOf("http://", 0) == -1 && obj.value.indexOf("https://", 0) == -1) {
				bRet = "\n * A valid url must begin with either \'http:\/\/\' OR \'https:\/\/\'" ;
				bSelect = true;
			}
		} else {
				bRet = "\n * Web address cannot be blank";
		}
		if (bRet != "") {
			if (bSelect) { obj.select();} else { obj.focus(); }
		} return bRet;
	}
}
/* _________________________________________________________________________________________________________________________________ */
//	Name 		- fnIsChecked ------------------------------------------------------------------------------------------------
//  Purpose		- Check if checkbox or radio is checked
//	Args 		- Form element as Object (Array of radios or checks)
/* ________________________________________________________________________________________________________________________________ */
function fnIsChecked(obj) {
	var bRet = false;
	if (obj.type == "hidden" || obj.disabled == true) {
		bRet = true;
	} else {
		bRet = obj.checked;
	}
	return bRet;
}

function fnIsInvalidPrice(obj) {
	var bRet = false, msg = "", fld = "", fldName = "";
	var tCents = "", nDecimalPlaces = 0;
	fld = obj.name;  										
	fldName = fld.substring(1, fld.length);								//Get field name minus the first char
	tCents = obj.value;
	if ( obj.value.indexOf(".", 0) != -1 ) {
		nDecimalPlaces = tCents.substring(obj.value.indexOf(".")+1, obj.value.length);
	}
	if(obj.value != ""){
		if ( isNaN(obj.value) ) {
			msg += " - " + fldName + " cannot contain non-numeric characters.\n"
		}
		if ( nDecimalPlaces.length > 2 ) {
			msg += " - Price\'s cannot have more than 2 Decimal places."
		}
		if ( msg != "" ) { window.alert("* Pricing Error __________________\n\n" + msg); obj.select(); return false; } else { return true; }
	} else {
		return true;
	}
}

/* _________________________________________________________________________________________________________________________________ */
//	Name 		- fnIsValidURL ------------------------------------------------------------------------------------------------
//  Purpose		- Used in onchange call, not used within main call
//	Args 		- Form element as Object
/* ________________________________________________________________________________________________________________________________ */
function fnIsValidURL(obj) {
	var error_intro = "The following errors occured .. \n__________________________________\n\n";
	var msg = "", bSelect = false;
	if (fnIsNullOrEmptyFld( eval(obj) )) {
		msg += error_intro + "\n * Web address cannot be blank";
	} else {
		if (obj.value.indexOf("http://", 0) == -1 && obj.value.indexOf("https://", 0) == -1) {
			msg += error_intro + "\n * A valid Web address must begin with either \'http:\/\/\' OR \'https:\/\/\'" ;
			obj.value = "";
			//bSelect = true;
		}
	}
	if (msg != "") {
		window.alert(msg);
		//if (bSelect) { obj.select();} else { obj.focus(); }
		obj.focus();
	}
}
//========================================================================================================//
function fnCheckBoxes(theForm){
	var i, toBoxesLen, ccBoxesLen, toAmt=0, ccAmt=0;
	var strMess="The following errors occured >_<\n\n";
	toBoxesLen = document.frmPeople.chTo.length; ccBoxesLen = document.frmPeople.chCC.length;
	for(i=0 ; i<toBoxesLen ; i++){
		//increment toAmt if more than 1 To is checked
		if(document.frmPeople.chTo[i].checked){toAmt++;}
		if(document.frmPeople.chTo[i].checked && document.frmPeople.chCC[i].checked){document.frmPeople.chTo[i].checked = false; strMess += "* To and CC ?? - " + document.frmPeople.chTo[i].value + "\n";}
	}
	if (toAmt < 1){strMess += "\n* There is no TO email address.\n\n"}
	if (toAmt > 1){strMess += "\n* To was checked " + toAmt +" times.\n"; }
	if (strMess != "The following errors occured >_<\n\n"){window.alert(strMess); return false;}
}
/* _________________________________________________________________________________________________________________________________ */
//	Name 		- fnEnableDisable ------------------------------------------------------------------------------------------------
//  Purpose		- To Enable or Disable fields
//	Args 		- tFieldVal (Value of Field Yes|No)
//                frm (Form as object)
//                arrElements (Array of Fields to be affected)
/* ________________________________________________________________________________________________________________________________ */
function fnEnableDisable(tFieldVal ,frm ,arrElements){
	var fieldName = "", bDisable;
	if ( !fnIsNullOrEmptyValue(tFieldVal) || typeof(arrElements) != "object" ) {
		(tFieldVal == "Yes")? bDisable = true : bDisable = false; 
		for (var i=0 ; i<arrElements.length ; i++ ) {
			fieldName = arrElements[i];
			eval("document."+frm+"."+fieldName+".disabled="+bDisable+";")
			if (bDisable == false){ eval("document."+frm+"."+fieldName+".value=''"); }
			else { eval("document."+frm+"."+fieldName+".value='Disabled'"); } 	
		}	
	} else {
		return ;	
	}
}

function t(){
		if (tFieldVal == "Yes") {//disable
			for (var i=0 ; i<arrElements.length ; i++ ) {
				fieldName = arrElements[i];
				eval("document."+frm+"."+fieldName+".disabled=true;")	
			}	
		} else {
			for (var i=0 ; i<arrElements.length ; i++ ) {
				fieldName = arrElements[i];
				eval("document."+frm+"."+fieldName+".disabled=false;")
			}	
		}
}
function fnFirstElementFocus(){
	if (typeof(document.forms[0].elements[0]) != "undefined" && document.forms[0].elements[0].type != "hidden") {
		document.forms[0].elements[0].focus();
	}
}

/* _________________________________________________________________________________________________________________________________ */
//	Name 		- fnTextLength ------------------------------------------------------------------------------------------------
//  Purpose		- Only allow certain amount of text into field
//	Args 		- Form element as Object, max length allowed
/* ________________________________________________________________________________________________________________________________ */
function fnTextLength(obj, len){
	var data = "";
	if (obj && len > 1) {
		if (obj.value.length > len) {
			window.alert(error_intro + "You have exceeded the allowed data length..");
			data = obj.value;
			data = data.substring(0, len);
			obj.value = data;
			return false;
		} return;
	} else {
		return;
	}
}
/* _________________________________________________________________________________________________________________________________ */
//	Name 		- fnPleaseWait ------------------------------------------------------------------------------------------------
//  Purpose		- Show message please wait while data is posting
//	Args 		- NA
/* ________________________________________________________________________________________________________________________________ */
function fnPleaseWait(uplFld) {
	if ( !fnIsNullOrEmptyFld(uplFld) ) {
		if (navigator.appName  == "Microsoft Internet Explorer"){
			document.all.loading.style.pixelTop = (document.body.scrollTop + 50);
			document.all.loading.style.visibility="visible";
		} else {
			if (navigator.appName  == "Netscape") {
				document.loading.pixelTop = (document.body.scrollTop + 50);
				document.loading.visibility="visible";
			}
		}
	}
}
//========================================================================================================//
function errorBorder(theId){
	if(navigator.appName.indexOf("Netscape")== -1){
		if(document.getElementById){var curStyle=document.getElementById(theId); curStyle.style.border="1px solid #FF0000";	return true;}
	}
}
//========================================================================================================//
function resetBorder(frm){
	if(document.getElementById){
		window.alert(document.frm.elements.length);
		for(var i=0 ; i<document.frm.elements.length ; i++){curStyle=document.getElementById(document.frm.elements[i].name); curStyle.style.border="1px solid #666699";}	
		//return true;
	}
}
//========================================================================================================//
function fnGetAntiBotMailtoLinkForAdmin(objEmail, objSubject, objLinkText){
	var tCodeOutput = "";
	var tEmail = objEmail.value;
	var tSubject = objSubject.value;
	var tLinkText = objLinkText.value;
	var tThisMsg = "";
	
	if(tEmail.indexOf('@',0)==-1||tEmail.indexOf('@',0)==0||tEmail.indexOf('.',0)==-1||tEmail.indexOf(',',0)!=-1||tEmail.indexOf(' ',0)!=-1){
		tThisMsg += "\n* Email address is not valid to get the Anti Spam Bot html mailto link code";	
	}
	if (tLinkText == "") {
		tThisMsg += "\n * You must supply link text";	
	} else {
		if(tLinkText.indexOf(tEmail,0)!=-1){
			tThisMsg += "\n* Due to spam bots, email addresses are not permitted in the Link text";	
		}
	}
	
	if (tThisMsg == "") {
		tCodeOutput = "<a href=\"javascript:void(0);\" onclick=\"javascript:fnAntiBotMailer('<antispamemail>" + tEmail + "</antispamemail>','";
		if (tSubject != "") {
			tCodeOutput +=  "" + tSubject + "" ;
		}
		tCodeOutput +=  "');\">" + tLinkText + "</a>";
		window.prompt("Please Copy this html into the editor in HTML MODE", tCodeOutput);
	} else {
		window.alert(error_intro + tThisMsg);	
	}
}




