E = document.all?true:false; //start  from this strat to end this works for mozilla

 function hitReturn(evt) {
IE = document.all;
	if (IE) {
	keycode = window.event.keyCode;
	} else {
	keycode = evt.which;
	}
	if (keycode == 13) {
	checkForm(); return false;
	}
return;
}


function anyMask(event, sMask) {
	//var sMask = "**?##?####";
	var KeyTyped = String.fromCharCode(getKeyCode(event));
	var targ = getTarget(event);
	
	keyCount = targ.value.length;
	//alert(sMask.charAt(keyCount));
	
	if (sMask.charAt(keyCount) == '*')
 	   	return true;
 
	if (sMask.charAt(keyCount) == KeyTyped)
    	{
		return true;
	}
	
	if ((sMask.charAt(keyCount) == '#') && isNumeric(KeyTyped)) 
	   return true; 
	
	if ((sMask.charAt(keyCount) == 'A') && isAlpha(KeyTyped))
         return true; 
    
      if ((sMask.charAt(keyCount) == '?') && isPunct(KeyTyped))
         return true; 
	if (KeyTyped.charCodeAt(0) < 32) return true;
    
    return false;	   
   
	
}

 function getTarget(e) {
  // IE5
   if (e.srcElement) {
   	return e.srcElement;
   }
    if (e.target) {
   	return e.target;
   }	
 }

  function getKeyCode(e) {
 //IE5
 if (e.srcElement) {
 	return e.keyCode
 }
  // NC5
  if (e.target) {
   return e.which
  }
 }

 function isNumeric(c)
{
	var sNumbers = "01234567890";
	if (sNumbers.indexOf(c) == -1)
		return false;
	else return true;
	
}  

function isAlpha(c)
{
	var lCode = c.charCodeAt(0);
	if (lCode >= 65 && lCode <= 122 )
 	  {	
		return true;
         }
	else 
	return false;
}  

function isPunct(c)
{
	var lCode = c.charCodeAt(0);
	if (lCode >= 32 && lCode <= 47 )
 	  {	
		return true;
         }
	else 
	return false;

}


function phoneMask(event)
  {
	var sMask = "01234567890";
	var KeyTyped = String.fromCharCode(getKeyCode(event));
	// IE only version var KeyTyped = String.fromCharCode(window.event.keyCode);
	// ** IE only var srcObject = window.event.srcElement;
	var targ = getTarget(event);
	//alert(window.event.keyCode);
	keyCount = targ.value.length;
	if (getKeyCode(event) < 15) /* del, backspace and other movement characters are okay */ {
	 	return true;		
  	} else if (sMask.indexOf(KeyTyped.toString()) == -1) {
				return false;
	}
	
    var tmpStr = "(";
    
    keyEntered = KeyTyped;
    keyCount++;
    switch (keyCount)
    {
    case 2: 
      tmpStr += targ.value;
      targ.value = tmpStr;
      break;
    case 5:
      targ.value += ")";
      break;
    case 9:
      targ.value += "-";
      break;
      }
    //return true;
 }
  

//  End -->











// Validation functions.
function Password_Check() {
	if (this.value != document.forms[0].Password.value){
	(this.value =""); return(this.xerror());
	}
return true;
}




function Email_Check() {
	if (this.value != document.forms[0].Email.value){
	(this.value =""); return(this.xerror());
	}
return true;
}

function checkForm() {
	getPopUp=0;
	if (validate_form()) {
	redo = true;
	setTimeout('submitForm()',300);
	}
}

function submitForm() {
document.forms[0].submit();
}

function showError(msgpat) {
	if (typeof(this.xerrmsg1) == "string") {
	this.xerrmsg = this.xerrmsg1 + this.value + this.xerrmsg2;
	}
alert(this.xerrmsg);
this.focus();
return false;
}

function showError_2(msgpat) {
	if (typeof(this.xerrmsg_2) == "string") {
	this.xerrmsg_2 = this.xerrmsg_2;
	}
alert(this.xerrmsg_2);
this.focus();
return false;
}

function showError_3(msgpat) {
	if (typeof(this.xerrmsg_3) == "string") {
	this.xerrmsg_3 = this.xerrmsg_3;
	}
alert(this.xerrmsg_3);
this.focus();
return false;
}

function isString() {
if (!this.value && this.xmin > 0) return(this.xerror());
	if (this.xmin > 0) {
	str = trimString(this.value);
		if (str.length < this.xmin) return(this.xerror());
	}
	if (this.value.length < this.xmin) return(this.xerror());
	if (this.value.length > this.maxLength) return(this.xerror());
return true;
}

function isNumStr() {
var str;
	if (!this.value && this.xmin > 0) return(this.xerror());
	if (this.value.match(/\D/)) return(this.xerror());
	if (this.value.length < this.xmin) return(this.xerror());
	if (this.value.length > this.maxlength) return(this.xerror());
return true;
}

function isPostal() {
code = this.value.replace(/\D/g, "");
	if (!code) return(this.xerror());
	if (code.length < this.xmin) return(this.xerror());
	if (code.length > this.xeditmax) return(this.xerror());
return true;
}


function editdomain(evt) {
IE = document.all;
var isIE = document.all?true:false; 

	if (IE) {
	var keycode = window.event.keyCode;
	var shift   = window.event.shiftKey;
	var ctrl    = window.event.ctrlKey;
	var alt     = window.event.altKey;
	var pos     = this.value.length + 1;
	var upper   = (shift && !ctrl && !alt && keycode >= 65 && keycode <= 90);
	var lower   = (!shift && !ctrl && !alt && keycode >= 97 && keycode <= 122);
	var space   = (!shift && !ctrl && !alt && keycode == 32);
	var digit   = (!shift && !ctrl && !alt && keycode >= 48 && keycode <= 57);
		if (pos <= 75 && digit) return true;
		if (keycode >= 65 && keycode <= 90 ) return true;
		if (keycode >= 97 && keycode <= 122 ) return true;
		if (keycode == 45 ) return true;
		if (keycode == 46 ) return true;
		if (keycode == 13) checkForm(); return false;
	} else {
	keycode = evt.which;
	var bs = String.fromCharCode(evt.which);
		if (keycode == 13) checkForm();
		if (keycode >= 48 && keycode <= 57) return true;
		if (keycode >= 97 && keycode <= 122) return true; //added this line to have it work with mozilla 1.4
		if (keycode == 0) return true;
		if (bs == "\b") return true;
	}
return false;
}



function editEmail(evt) {
IE = document.all;

	if (IE) {
	var keycode = window.event.keyCode;
	var shift   = window.event.shiftKey;
	var ctrl    = window.event.ctrlKey;
	var alt     = window.event.altKey;
	var pos     = this.value.length + 1;
	var upper   = (shift && !ctrl && !alt && keycode >= 65 && keycode <= 90);
	var capsupper = (!shift && !ctrl && !alt && keycode == 39 && keycode >= 65 && keycode <= 90);
	var dash	= (!shift && !ctrl && !alt && keycode == 45);
	var underscore	= (shift && !ctrl && !alt && keycode == 95);
	var lower   = (!shift && !ctrl && !alt && keycode >= 97 && keycode <= 122);
	var digit   = (!shift && !ctrl && !alt && keycode >= 48 && keycode <= 57);
	var atsign  = (shift && !ctrl && !alt && keycode == 64);
	var dot  	= (!shift && !ctrl && !alt && keycode == 46);
		if (pos <= 50 && digit) return true;
		if (pos <= 50 && lower) return true;
		if (pos <= 50 && upper) return true;
		if (pos <= 50 && dot) return true;
		if (pos <= 50 && atsign) return true;
		if (pos <= 50 && underscore) return true;
		if (pos <= 50 && dash) return true;
		//if (pos <= 50 && capsupper) return true;
		
		if (keycode == 190) return true;
		if (keycode == 13) checkForm(); return false;
	} else {
	keycode = evt.which;
	var bs = String.fromCharCode(evt.which);
		if (keycode == 13) checkForm();
		if (keycode >= 48 && keycode <= 57) return true;
		if (keycode >= 97 && keycode <= 122) return true; //added this line to have it work with mozilla 1.4
		if (keycode == 64) return true; //added this line to have it work with mozilla 1.5
		if (!shift && !ctrl && !alt && keycode == 46) return true; //added this line to have it work with mozilla 1.5
		if (keycode == 0) return true;
		if (bs == "\b") return true;
		if (bs == "-") return true;	// SOME DOMAINS HAVE DASHES IN THEM J! :D -Tom
	}
return false;
}













function isEmail() {
code = this.value.replace(/\D/g, "");
	//if (this.value == "") return true;

var pattern =/.+@.+\..+/;

	if (this.value.match(pattern)) {
	return true;
	} else {
	return this.xerror();
	}
}








function trimString (str) {
str = this != window? this : str;
return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
}





function wr4_isEmail(email) {
	if(email.indexOf('@') > -1 && email.indexOf('.') > -1) return true
	alert('Please specify a valid email address.'); return false ;
}




function wr4_isNull (str,tchar) {
	if (str.length == 0) {
	alert(friendlyName + ' can not be left blank.');return false;
	}
	while (str.indexOf(tchar) == 0 && str.length > 0) {
	str = str.substring(tchar.length);
	}
	while (str.lastIndexOf(tchar) == (str.length - (tchar.length)) && str.length > 0) {
	str = str.substring(0,(str.length - (tchar.length)));
	}
	if(str=="") {
	alert(friendlyName + ' can not be left blank.'); return false;
	}
return true;
}



function validate_form() {
	var elm, i;
	form = document.forms[0];
	for (i = 0; i < form.elements.length; i++) {
		elm = form.elements[i];
		if (elm.type == "hidden") continue;
		if (typeof(elm.xvalidate) == "function" && !elm.xvalidate()) return false;
	}

return true;
checkpost();
}

function checkpost() {
if(document.frmhosting.frmdoublechk.value != 'sent')
	{
			var msglen = document.frmhosting.comments.value
// Modified so as to accomodate the proper ones in localization..... 
			if (msglen.length > 500 ) {
				
				alert('The message cannot exceed 500 characters. '); 
				 
				return false;
			}
		document.frmhosting.frmdoublechk.value = 'sent'
		return true;
	}
else
	{
//		alert('This message was already submitted, duplicate posting is not allowed');
		alert("This page was already submitted. Processing...");
		return false;
	}
}

