
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_section2").innerHTML = error_msg;
    }
    else if (document.all) {
        // Microsoft DOM code
        document.all["error_section"].innerHTML = error_msg;
		document.all["error_section2"].innerHTML = error_msg;
    }
    else if (document.layers) {
        // Netscape DOM code
        document.layers["error_section"].innerHTML = error_msg;
		document.layers["error_section2"].innerHTML = error_msg;
    }
    }
    else {
        $error_msg = replace($error_msg, "<br>", "\n");
        alert($error_msg);
    }

}

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;
}
