function openWin( URL, windowName, width, height ) {
	windowName = typeof( windowName ) != 'undefined' ? windowName : "popupWin";
	width = typeof( width ) != 'undefined' ? width : '550';
	height = typeof( height ) != 'undefined' ? height : '550';

	var windowOptions = "height=" + height + ",width" + width;
	newWindow = window.open( URL, windowName, windowOptions );
	return false;
}
function setupField( field, defaultText ) {
	if( field.value == defaultText ) {
		field.value = '';
		field.style.color = '#000000';
	}
}
function clearField( field ) {
	var clearThisField = document.getElementById( field ); 
	clearThisField.value = '';
	return false;
}
function clearRadios( radioSet ) {
	var lb = "\x5B"; // [
	var rb = "\x5D"  // ]
	var elements = document.getElementsByTagName('input');
	var elnum;
	for( elnum=0; elnum<elements.length; elnum++ ) {
		var el = eval( "elements" + lb + "elnum" + rb );
		if( el.type == 'radio' && el.name == radioSet ) {
			el.checked = false;
		}
	}
}
function clearMasterCheckbox( masterCheckbox ) {
	document.getElementById( masterCheckbox ).checked = false;
}

function clearCheckboxes( checkSet ) {
	var lb = "\x5B"; // [
	var rb = "\x5D"  // ]
	var elements = document.getElementsByTagName('input');
	var elnum;
	// uncheck all the checkboxes
	for( elnum=0; elnum<elements.length; elnum++ ) {
		var el = eval( "elements" + lb + "elnum" + rb );
		if( el.type == 'checkbox' && el.name == checkSet ) {
			el.checked = false;
		}
	}
	// ...and check the master checkbox
	var pieces = checkSet.split("[");
	var master = document.getElementById( pieces[0] + "_XXX" );
	master.checked = true;
}

function applyInputStylesIE( checkSet ) {
	var lb = "\x5B"; // [
	var rb = "\x5D"  // ]
	var elements = document.getElementsByTagName('input');
	var elnum;
	for( elnum=0; elnum<elements.length; elnum++ ) {
		var el = eval( "elements" + lb + "elnum" + rb );
		if( el.type == 'checkbox' || el.type == 'radio' ) {
			el.className = 'noBorder';
		}
	}
}


function addLoadEvent( func ) { 
	var oldonload = window.onload;		// store the previous onload function 
	if( typeof window.onload != 'function' ) {
		window.onload = func; 			// set the onload type to be function
	} else { 
		window.onload = function() { 	
			if( oldonload ) { 			
				oldonload(); 			// if previous onload function existed, run it
			}
			func();						// run the given onload function
		}
	}
}
function addResizeEvent( func ) { 
	var oldonresize = window.onresize;		// store the previous onload function 
	if( typeof window.onresize != 'function' ) {
		window.onresize = func; 			// set the onload type to be function
	} else { 
		window.onresize = function() { 	
			if( oldonresize ) { 			
				oldonresize(); 			// if previous onload function existed, run it
			}
			func();						// run the given onload function
		}
	}
}


/* whitespace trimming for JS */
function trim(str, chars) {
	return ltrim(rtrim(str, chars), chars);
}
 
function ltrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
 
function rtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}

function checkAvailableWidth() {
	var container = document.getElementById("container");
	container.style.width = ( document.body.clientWidth < 900 ) ? "900px" : "auto";
}

function setMaxWidth() {
	var oneColumn = document.getElementById("oneColumn");
	oneColumn.style.width = document.body.clientWidth - 200 + "px";
}

//addLoadEvent( checkAvailableWidth );
//addLoadEvent( setMaxWidth );
//addResizeEvent( checkAvailableWidth );
//addResizeEvent( setMaxWidth );

