
	// javascript stuff
	
	var numb = '0123456789';
	var numbdash = '0123456789-';
	var numbdec = '0123456789.';
	var lwr = 'abcdefghijklmnopqrstuvwxyz .,—-"\'';
	var upr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ .,—-"\'';


function ltrim(str) { 
	for(var k = 0; k < str.length && isWhitespace(str.charAt(k)); k++);
	return str.substring(k, str.length);
}
function rtrim(str) {
	for(var j=str.length-1; j>=0 && isWhitespace(str.charAt(j)) ; j--) ;
	return str.substring(0,j+1);
}
function trim(str) {
	return ltrim(rtrim(str));
}
function isWhitespace(charToCheck) {
	var whitespaceChars = " \t\n\r\f";
	return (whitespaceChars.indexOf(charToCheck) != -1);
}


	//////////////////////////////////////////////////
	//
	// Functions to handle opacity for image fade-ins
	//
	function opacity(id, opacStart, opacEnd, millisec) 
	{
	    //speed for each frame
		var speed = Math.round(millisec / 100);
		var timer = 0;	

		//determine the direction for the blending, if start and end are the same nothing happens
		if(opacStart > opacEnd) {
			for(i = opacStart; i >= opacEnd; i--) {
            	setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
	            timer++;
    	    }
    	} else if(opacStart < opacEnd) {
    	    for(i = opacStart; i <= opacEnd; i++)
			{
				setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
				timer++;
			}
		}
	}

	//change the opacity for different browsers
	function changeOpac(opacity, id) 
	{
		//alert(id);
		var object = document.getElementById(id).style;
		object.opacity = (opacity / 100);
		object.MozOpacity = (opacity / 100);
		object.KhtmlOpacity = (opacity / 100);
		object.filter = "alpha(opacity=" + opacity + ")";
	}
	//
	// Functions to handle opacity for image fade-ins
	//
	//////////////////////////////////////////////////


	function trimAll(sString)
	{
		while (sString.substring(0,1) == ' ')
		{
			sString = sString.substring(1, sString.length);
		}
		while (sString.substring(sString.length-1, sString.length) == ' ')
		{
			sString = sString.substring(0,sString.length-1);
		}
		return sString;
	}


	function rightTrim(sString)
	{
		while (sString.substring(sString.length-1, sString.length) == ' ')
	{
		sString = sString.substring(0,sString.length-1);
	}
		return sString;
	}

	
	function leftTrim(sString)
	{
		while (sString.substring(0,1) == ' ')
		{
			sString = sString.substring(1, sString.length);
		}
		return sString;
	}	
	
	function isValid(parm,val) 
	{
		if (parm == "") return true;
		for (i=0; i<parm.length; i++) 
		{
			if (val.indexOf(parm.charAt(i),0) == -1) 
			{
				return false;
			}
		}
		return true;
	}

	function isNum(parm) 		{ return isValid(parm,numb); }
	function isNumDash(parm)	{ return isValid(parm,numbdash); }
	function isNumDec(parm)		{ return isValid(parm,numbdec); }
	function isLower(parm) 		{ return isValid(parm,lwr); }
	function isUpper(parm) 		{ return isValid(parm,upr); }
	function isAlpha(parm) 		{ return isValid(parm,lwr+upr); }
	function isAlphanum(parm) 	{ return isValid(parm,lwr+upr+numb); }


	function CheckEmoryID(theForm) 
	{

		emid = new String(document.matchToDiffID.EMORY_ID.value);
		if(emid == "")
		{
			alert("You must enter a EmoryID before clicking the [Match to this EmoryID] button");
			return false;
		}
		emid_length = emid.length;
		if(emid_length > 6)
		{
			alert("The entered EmoryID is invalid");
			return false;
		}
		for(x = 0; x < emid_length; ++x)
		{
			currchar = emid.charAt(x);
			if(currchar < "0" || currchar > "9")
			{
				alert("The EmoryID id  " + emid + "  is invalid (problem character: "+currchar+").  EmoryIDs are numeric with no spaces or other punctuation.");
				return false;
			}
		}
	}

	function OpenWindowPrint(url) 
	{
		popupWin = window.open(url, 'print', 'menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=no,dependent,width=750, height=500,left=240,top=240')

	}
	function OpenWindow(url) 
	{
		popupWin = window.open(url, 'popup', 'menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=no,dependent,width=500, height=500,left=140,top=140')

	}
	function OpenWindowFancy(url,window_id,window_width,window_height,window_left,window_top) 
	{
		popupWin = window.open(url, window_id, 'menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=no,dependent,width=window_width, height=window_height,left=window_left,top=window_top')

	}


function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
} 	