// function used for secondary navigation
function changeClass(elemId, newClass) {
	var elem = null;
	if( document.getElementById ) {
		elem = document.getElementById(elemId);
	} else if ( document.all ) {
		elem = document.all[elemId];
	}
	if(elem) elem.className = newClass;
}

function JumpToIt(list){
	var newPage = list.options[list.selectedIndex].value
	if( newPage != "" && newPage != "None")	location.href=newPage;
}

function change_country() {
	// JavaScript "Permission Denied" error occurs in such cross-domain usage. Change Country feature is disabled for now.
	window.open('http://www.xeroxscanners.com/countryselect.asp','countries','width=300, height=300,resizable=yes,scrollbars=no,location=no,toolbar=no,top=5,left=5');
}

function remove_EDI_Special_Characters( arg1 ) {
/*
	This function:
		1) removes certain forbidden characters by replacing them with spaces;
		2) replaces double-spaces with single space;
		3) removes leading and trailing spaces;

	Function can be used in two ways:
		a) when first argument is reference to text field (<input ...>) function updates the original value (in-place) and returns nothing.
		b) when first argument is string function returns modified version of it.

	Example #1:
		in HTML:	<input type="text" value="abcde^fg~hij" onBlur="remove_EDI_Special_Characters(this)">
		("this" referes to the field from which it was called. Make sure you use "this", not "this.value".)

	Example #2
	  	in HTML: <input type="text" name="FirstName" id="FirstName" value="abcde^fg~hij">

		somewhere in JavaScript block (could be your form validation function)
		var obj_firstName = document.getElementById("FirstName");
		remove_EDI_Special_Characters( obj_FirstName );

		or simply :	remove_EDI_Special_Characters(document.getElementById("FirstName"));

	Example #3
		var str_FirstName_original = "abcde^fg~hij";
		var str_FirstName_stripped = remove_EDI_Special_Characters(str_FirstName_original);
		alert(str_FirstName_stripped);
*/

	var myRe1 = /[\~\*\^\|\'\<\>]/gi;	// forbidden characters
	var myRe2 = /\s\s+/gi;				// double-space
	var myRe3 = /^\s*(\S*.*)/i;			// leading spaces
	var myRe4 = /^(.*\S)\s+$/i;			// trailing spaces

	var newstr;

	switch ( typeof(arg1) ) {
	case "object"	:
		switch ( typeof(arg1.value) ) {
		case "string" :
			if(arg1.value.length == 0) return;	// empty, so do nothing.
			newstr     = arg1.value.replace(myRe1," " );
			newstr     =     newstr.replace(myRe2," " );
			newstr     =     newstr.replace(myRe3,"$1");
			arg1.value =     newstr.replace(myRe4,"$1");
			break;
		case "undefined" :
			alert("First argument is an object but it does not have .value property.");
			break;
		default :
			alert("First argument is an object but its .value property is of '"+typeof(arg1.value)+"' type which is not supported.");
			break;
		}
		return;
		break;

	case "string"	:
		if(arg1.length == 0) return "";
		newstr =   arg1.replace(myRe1," " );
		newstr = newstr.replace(myRe2," " ); // repeat a couple of times
		newstr = newstr.replace(myRe2," " ); // repeat a couple of times
		newstr = newstr.replace(myRe2," " ); // repeat a couple of times
		newstr = newstr.replace(myRe3,"$1");
		return   newstr.replace(myRe4,"$1");
		break;

	case "undefined" :
		if( verbose ) alert("Invalid usage of remove_EDI_Special_Characters( Object | String )\nOne parameter is required.");
		break;
	default		  :
		if( verbose ) alert("Invalid usage of remove_EDI_Special_Characters( Object | String )\nParameter type is unknown.");
	}
}

