// here's a list of the functions in this .js file
//function isInteger(sDate)
//function isCurrency(sDate)
//function checkPassword(str)
//function checkEmail(str)
//function isLetterOrNumber(str)
//function Hyphen(str)
//function isNull(str)
//function isLetter(str)
//function charSetStr()
//function CurrencySetStr()
//function containSpace(str)
//function isSpace(str)
//function validateUpload()
//function trim(str)

browser = navigator.appName;
ie = "Microsoft Internet Explorer";
netscape = "Netscape";
os = navigator.platform;
mac = 'MacPPC'
if (browser == netscape && os != mac) {
	document.write('<link rel="stylesheet" type="text/css" href="./library/mgNetscape.css" title="NetscapePC">');
	}
else if (browser == ie && os != mac) {
	document.write('<link rel="stylesheet" type="text/css" href="./library/mgIE.css" title="IEPC">');
	}
else if (browser == netscape && os == mac) {
	document.write('<link rel="stylesheet" type="text/css" href="./library/mgNetscape.css" title="NetscapePC">');
	}
else if (browser == ie && os == mac) {
	document.write('<link rel="stylesheet" type="text/css" href="./library/mgIE.css" title="IEPC">');
	}
else {
	document.write('<link rel="stylesheet" type="text/css" href="./library/mgIE.css" title="IEPC">');
	}

function trim(str)
	{
	while(str.charAt(0)==" "){str=str.substring(1)};
	while(str.charAt(str.length-1)==" "){str=str.substr(0,str.length-1)};
	return str;
	}

function validateUpload(){
	with(window.document.forms[1])
	{	if (isNull(file1.value)){
			alert("Please enter a path for the file to upload!");
			return false;}};
	document.forms[1].action="../common/upload.asp"
	return true;}

function isSpace(str)
{
j=0;
a=str.length;
	for(i=0;i<a;i++){
		ch=str.charAt(i);
		if(ch==" ") j+=1;
		else j=j;
	};
return(j==a);
};

function isPOBox(str)
{
	var isPO;
	a=str.length;
	isPO = false;
	str = str.toUpperCase();
	
	for(i=0;i<a;i++){
		if (str.charAt(i)=="P") {	//check for ".O. BOX", ".O BOX", "O BOX" part
			if ( ( ( str.charAt(i+1) == "." ) && ( str.charAt(i+2) == "O" ) && ( str.charAt(i+3) == "." ) && ( str.charAt(i+4) == " " ) && ( str.charAt(i+5) == "B" ) && ( str.charAt(i+6) == "O" ) && ( str.charAt(i+7) == "X" ) ) || ( ( str.charAt(i+1) == "." ) && ( str.charAt(i+2) == "O" )  && ( str.charAt(i+3) == " " ) && ( str.charAt(i+4) == "B" ) && ( str.charAt(i+5) == "O" ) && ( str.charAt(i+6) == "X" ) ) || ( ( str.charAt(i+1) == "O" )  && ( str.charAt(i+2) == " " ) && ( str.charAt(i+3) == "B" ) && ( str.charAt(i+4) == "O" ) && ( str.charAt(i+5) == "X" ) ) )
				isPO = true;
		};
	};
	return(isPO);
};

function charSetStr()
{
	var str
	str = ' !"#$%&' + "'" + '()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~'
	return str
};

function containSpace(str)
{
	if(str.indexOf(" ")>-1){
		return true;
	};
	return false;
};

function isNull(str)
{
	if ((str.length<=0)||(str==null)) return true;
	return false;
};

function isLetter(str)
{
j=0;
tempStr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
a=str.length;
	for(i=0;i<a;i++){
		ch=str.charAt(i);
		if(tempStr.indexOf(ch.toUpperCase())>-1) j+=1;
		else j=0;
	};
return(j!=0);
};

function Hyphen(str)
{
	while(str.indexOf("-")>-1){str=str.substring(0,str.indexOf("-")) + str.substring(str.indexOf("-")+1)};
	return str;
};
 
function isLetterOrNumber(str)
{
a=str.length;
for(i=0;i<a;i++){
	ch=str.charAt(i);
	if (!isLetter(ch) && !isInteger(ch)) {
		return false;
	};
};
return true;
};

//specific to the email in PWD
function checkEmail(str)
{
	if (str.length<=0) return false;
	if(str.indexOf("@")<0) return false;
	if(str.indexOf(".")<0) return false; 
	if(str.indexOf(" ")!=-1) return false; 
	return true;	
};

function checkMultiEmail(str)
{
	// get the first @ location
	loc = str.indexOf("@");
	tempStr = str.substring(loc+1,str.length);
	if(tempStr.indexOf("@")>0) return true;
	if(str.indexOf(",")!=-1) return true; 
	if(str.indexOf(";")!=-1) return true; 
	return false;	
};


//specific to the password in PWD
function checkPassword(str)
{
	if(!isLetterOrNumber(str) || str.length<6){
		return false;
	};
	return true;
};

function isInteger(sDate)
{
	var new_msg = true;
	inputStr = sDate.toString()
	for (var i = 0; i < inputStr.length; i++)
		{
		var oneChar = inputStr.charAt(i)			
		if (oneChar < "0" || oneChar > "9") new_msg = false;
		}
	return (new_msg)
};

function isCurrency(sDate)
{
	var new_msg = true;
	tempStr = '.1234567890'
	a=sDate.length;
	for(i=0;i<a;i++){
		ch=sDate.charAt(i);
		if(tempStr.indexOf(ch)<0) new_msg = false;
	}
	return (new_msg)
};

