
function error_display(error_msg) {
	if (document.getElementById || document.all || document.layers) {

    	if (document.getElementById) {
        	// Level 1 DOM code
        	document.getElementById("error_section").innerHTML = error_msg;
    		document.getElementById("error_section").style.visibility = 'visible';

		}
    	else if (document.all) {
        	// Microsoft DOM code
        	document.all["error_section"].innerHTML = error_msg;
        	document.all["error_section"].style.visibility = 'visible';

		}
   	 	else if (document.layers) {
        	// Netscape DOM code
			
        	document.layers["error_section"].innerHTML = error_msg;
    		document.layers["error_section"].style.visibility = 'visible';

		}
    }
    else {
        error_msg = replace(error_msg, "<br>", "\n");
        alert(error_msg);
    }
    window.scrollTo(0,0);
}

function error_display2(error_msg) {
/*	if (document.getElementById || document.all || document.layers) {

    	if (document.getElementById) {
        	// Level 1 DOM code
        	document.getElementById("error_section").innerHTML = error_msg;
    		document.getElementById("error_section").style.visibility = 'visible';

		}
    	else if (document.all) {
        	// Microsoft DOM code
        	document.all["error_section"].innerHTML = error_msg;
        	document.all["error_section"].style.visibility = 'visible';

		}
   	 	else if (document.layers) {
        	// Netscape DOM code
			
        	document.layers["error_section"].innerHTML = error_msg;
    		document.layers["error_section"].style.visibility = 'visible';

		}
    }
    else {*/
        error_msg = replace(error_msg, "<br>", "\n");
        alert(error_msg);
//    }
//    window.scrollTo(0,0);
}

function replace(string,text,by) {
          
    strLength = string.length;
    txtLength = text.length;
    
    i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;

    newstr = string.substring(0,i) + by;

    if (i+txtLength < strLength) {
        newstr += replace(string.substring(i+txtLength,strLength),text,by);
    }
    return newstr;
}

function isValidString(inStr, charset, allowed) {
   
	result = true;
	
	if (allowed == true) {
    	for (i=0;i<inStr.length;i++) {
    		if (charset.indexOf(inStr.substr(i,1)) == -1) {
    			result = false;
    			break;
    	    }
    	}
	}
	else {
	    for (i=0;i<inStr.length;i++) {
    		if (charset.indexOf(inStr.substr(i,1)) != -1) {
    			result = false;
    			break;
    	    }
    	}
	}
	return result;
}
/*
function isValidEmail(inStr) {

	var filter='/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i';
	if (filter.test(inStr)) {
		return true;
	}
	else{
 		return false;
	}
}
*/
function isValidEmail(inStr) {
	
	var invalidChars = '\/\'\\ ";:?!()[]\{\}^|';
	
	for (i=0; i<invalidChars.length; i++) {
	
 		if (inStr.indexOf(invalidChars.charAt(i),0) > -1) {

			return false;
		}
	}

	var atPos = inStr.indexOf('@',0);
	if (atPos == -1) {

		return false;
	}
	if (atPos == 0) {
		
  		return false;
	}
	if (inStr.indexOf('@', atPos + 1) > - 1) {
		      
		return false;
	}
	if (inStr.indexOf('.', atPos) == -1) {
		      
		return false;
	}
	if (inStr.indexOf('@.',0) != -1) {
		      
		return false;
	}
	if (inStr.indexOf('.@',0) != -1){
		      
		return false;
	}
	if (inStr.indexOf('..',0) != -1) {
		      
		return false;
	}
	var suffix = inStr.substring(inStr.lastIndexOf('.')+1);
	if (suffix.length != 2 && suffix != 'com' && suffix != 'net' && suffix != 'org' && suffix != 'edu' && suffix != 'int' && suffix != 'mil' && suffix != 'gov' & suffix != 'arpa' && suffix != 'biz' && suffix != 'aero' && suffix != 'name' && suffix != 'coop' && suffix != 'info' && suffix != 'pro' && suffix != 'museum') {
		      return false;
	}
	return true;
}	
