
	/************************************************
	
	
		IET Javascript Utilities
	
	
	*************************************************/
	
	
	/* Get all elements in 'node' (optionally that are 'tag') that use 'searchClass' */
	
	function getElementsByClass(searchClass,node,tag) {

		var classElements = new Array();
		if ( node == null )
			node = document;
		if ( tag == null )
			tag = '*';
		var els = node.getElementsByTagName(tag);
		var elsLen = els.length;
		var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
		for (i = 0, j = 0; i < elsLen; i++) {
			if ( pattern.test(els[i].className) ) {
				classElements[j] = els[i];
				j++;
			}
		}
		return classElements;
	}

	
	/* Trim leading and trailing spaces from a string */

	function trim(stringToTrim) {
		return stringToTrim.replace(/^\s+|\s+$/g,"");
	}


	/* Trim leading spaces from a string */

	function ltrim(stringToTrim) {
		return stringToTrim.replace(/^\s+/,"");
	}


	/* Trim trailing spaces from a string */

	function rtrim(stringToTrim) {
		return stringToTrim.replace(/\s+$/,"");
	}

/*
	function toggleDisplay(el) {
	
		//alert(el.className);
		
		if (displayed(el)) {
		
			undisplay(el);
		}
		else {
		
			display(el);
		}
	}	
*/

	function parseDim(dim) {
	
		var idx = dim.indexOf("px");
		
		return parseInt(dim.substring(0,idx));
	}
	

	function displayed(el) {
	
		var isdisp = false;
	
		if ((el.className.indexOf("display") >= 0) ||
		    (el.className.indexOf("not_disp") < 0 )    ) {
	
			isdisp = true;
		}
	
		return isdisp;
	}

	function toggleTwisty(image) {

		//alert("toggleTwisty start");

	    //alert(image.src);

	    if (image.src.indexOf("rightArrow") >= 0) {
	    
	    	image.src = image.src.replace("rightArrow","downArrow");
	    }
	    else if (image.src.indexOf("downArrow") >= 0) {
	    
	    	image.src = image.src.replace("downArrow","rightArrow");
	    }
	    
	    //alert("toggleTwisty end");
	}
	
	/* Toggle the display of an element */

	function toggleDisplay(element) {

	//alert("toggleDisplay start");

		if (element.className.indexOf("not_disp") >= 0) {

			element.className = element.className.replace("not_disp","display");
		}
		else if (element.className.indexOf("display") >= 0) {

			element.className = element.className.replace("display","not_disp");
		}
		else {

			element.className = element.className + " not_disp";
		}

		//alert("toggleDisplay end");	
	}	

	function visible(el) {
	
		var isvis = false;
	
		if ((el.className.indexOf("visible") >= 0) ||
		    (el.className.indexOf("hidden") < 0 )    ) {
	
			isvis = true;
		}
	
		return isvis;
	}

	/* If not displayed, display the element */

	function display(el) {

		var elclass = el.className;


		// If the element is hidden

		if (elclass.indexOf("not_disp") >= 0) {

			el.className = elclass.replace("not_disp","display");
		}

		// Else if its not already visible

		else if (elclass.indexOf("display") < 0) {
		
			el.className = elclass + " display";
		}
		
	}


	/* If displayed, undisplay the element */

	function undisplay(el) {

		var elclass = el.className;


		// If the element is visible

		if (elclass.indexOf("display") >= 0) {

			el.className = elclass.replace("display","not_disp");
		}

		// Else if its not already hidden

		else if (elclass.indexOf("not_disp") < 0) {
		
			el.className = elclass + " not_disp";
		}
	}

	function openSmallWin(theURL) {
	
		openWin(theURL,450,200);
	}

	function openMedWin(theURL) {
	
		openWin(theURL,600,400);
	}	
	
	function openLrgWin(theURL) {
	
		openWin(theURL,1014,710);
	
	}
	
	function openWin(theURL, width, height) {
	
		if (!width) width=1014;
		if (!height) height=710;
	
		var windowHandle = window.open(theURL,'newwin','left=50,top=50,width='+width+',height='+height+',menubar=0,toolbar=0,location=0,resizable=1,scrollbars=0,status=1,titlebar=no,left=0,top=0');

		if (!windowHandle) {
			windowHandle.opener = self;
		}
		windowHandle.focus();
	}	
	
	function showHover(text) {

		return overlib(text, DELAY,600, BGCOLOR, '#000000', FGCOLOR,'#FFFFE7');
	}

	function hideHover() {

		return nd();
	}		

	/* Get the value of a radio set */

	function getRadioValue(radio) {
	
		var radVal = "";
	
		for (var i=0; i < radio.length; i++) {
		
			if (radio[i].checked) {

				var radVal = radio[i].value;
			}
		}
		
		return radVal;
	}
	
/*	
	var IE = document.all?true:false;

	if (!IE) document.captureEvents(Event.MOUSEMOVE)

	document.onmousemove = getMouseXY;

	var tempX = 0;
	var tempY = 0;
	function getMouseXY(e) {
		if (IE) { // grab the x-y pos.s if browser is IE
			tempX = event.clientX + document.body.scrollLeft;
			tempY = event.clientY + document.body.scrollTop;
		}
		else {  // grab the x-y pos.s if browser is NS
			tempX = e.pageX;
			tempY = e.pageY;
		}  
		
		if (tempX < 0){tempX = 0;}
		if (tempY < 0){tempY = 0;}  
		
		//document.Show.MouseX.value = tempX;
		//document.Show.MouseY.value = tempY;
		var tmpstr = "Left: " + tempX + "   Top: " + tempY;
		
		window.status = tmpstr;
		
		return true;
	}
	*/
	
/*

	Cookie functions

*/
	
	
	function createCookie(name,value,days) {
		if (days) {
			var date = new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			var expires = "; expires="+date.toGMTString();
		}
		else var expires = "";
		document.cookie = name+"="+value+expires+"; path=/";
	}


	function readCookie(name) {
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++) {
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
		return null;
	}

	function eraseCookie(name) {
		createCookie(name,"",-1);
	}	
	
	
/*

    Date functions 
    
*/
    
    var DAYS_OF_WEEK = new Array();
    
    DAYS_OF_WEEK[0] = "Sunday";
    DAYS_OF_WEEK[1] = "Monday";
    DAYS_OF_WEEK[2] = "Tuesday";
    DAYS_OF_WEEK[3] = "Wednesday";
    DAYS_OF_WEEK[4] = "Thursday";
    DAYS_OF_WEEK[5] = "Friday";
    DAYS_OF_WEEK[6] = "Saturday";

    
    var MONTHS_OF_YEAR = new Array();
    
    MONTHS_OF_YEAR[0] = "January";
    MONTHS_OF_YEAR[1] = "February";
    MONTHS_OF_YEAR[2] = "March";
    MONTHS_OF_YEAR[3] = "April";
    MONTHS_OF_YEAR[4] = "May";
    MONTHS_OF_YEAR[5] = "June";
    MONTHS_OF_YEAR[6] = "July";
    MONTHS_OF_YEAR[7] = "August";
    MONTHS_OF_YEAR[8] = "September";
    MONTHS_OF_YEAR[9] = "October";
    MONTHS_OF_YEAR[10] = "November";
    MONTHS_OF_YEAR[11] = "December";
    
	function getCurrentDate() {
	
		// Format: Friday Feburary 20, 2009
	
		var thisdate = new Date();
		
		var dayofweek = DAYS_OF_WEEK[thisdate.getDay()];
		
		var month = MONTHS_OF_YEAR[thisdate.getMonth()];
		
		var monthday = thisdate.getDate();
		
		var year = thisdate.getFullYear();
		
		var currentDate = dayofweek + " " + month + " " + monthday + ", " + year;
		
		return currentDate;
	
	}	

