// used by the drop-down form elements that redirect to another page
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
// preload images in body tag
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function switchFont(id, color) {
	document.getElementById(id).style.color = color;
}
function switchImg(id, image) {
	document.getElementById(id).src = image;
}
// this function will (a) show a table if it was hidden or (b) hide a table if it was visible
function showTable(table) {
	if (document.getElementById(table)) {
		if (document.getElementById(table).style.display == '')
			document.getElementById(table).style.display = 'none';
		else
			document.getElementById(table).style.display = '';
	}
}
function clearText(id, text) {
	if (document.getElementById(id).value == text) {
		// change input type to password
		if (text == "Enter Password Here") {
			var replace	= document.getElementById(id);
			var parent	= replace.parentNode;
			var sibling	= replace.nextSibling;
			var newel	= document.createElement('input');
			newel.setAttribute('type',		'password');
			newel.setAttribute('id',		id);
			newel.setAttribute('name',		id);
			newel.setAttribute('tabIndex',	'2');
			newel.setAttribute("onFocus",	"clearText('Password', 'Enter Password Here');");
			newel.setAttribute("onBlur", 	"resetText('Password', 'Enter Password Here');");

			parent.removeChild(replace);
			parent.insertBefore(newel, sibling);
			document.getElementById(id).select()
			document.getElementById(id).focus()
		}
		document.getElementById(id).value = '';
		document.getElementById(id).style.color = '#000000';
	}
}
function resetText(id, text) {
	if (document.getElementById(id).value == "") {
		// change input type back to text
		if (text == "Enter Password Here") {
			var replace	= document.getElementById(id);
			var parent	= replace.parentNode;
			var sibling	= replace.nextSibling;
			var newel	= document.createElement('input');
			newel.setAttribute('type',		'text');
			newel.setAttribute('id',		id);
			newel.setAttribute('name',		id);
			newel.setAttribute('tabIndex', '2');
			newel.setAttribute("onFocus",	"clearText('Password', 'Enter Password Here')");
			newel.setAttribute("onBlur",	"resetText('Password', 'Enter Password Here')");

			parent.removeChild(replace);
			parent.insertBefore(newel, sibling);
		}
		document.getElementById(id).value		= text;
		document.getElementById(id).style.color	= '#666';
	}
}
function checkEnter(e) {			//e is event object passed from function invocation
	var characterCode;				// literal character code will be stored in this variable
	if (e && e.which) {				//if which property of event object is supported (NN4)
		e = e;
		characterCode = e.which; 	//character code is contained in NN4's which property
	} else {
		e = event;
		characterCode = e.keyCode;	//character code is contained in IE's keyCode property
	}
	if (characterCode == 13) {		//if generated character code is equal to ascii 13 (if enter key)
		// Put code here to do what I want to happen when enter is pressed.
	}
}
function intOnly(i) {
	if (i.value != "Enter Zipcode") {
		// only allow integers
		if (i.value.length > 0)
			i.value = i.value.replace(/[^\d]+/g, ''); 
	}
}
function setCharCount(id,value){
	// set max value: ShortDescr = 200; Descr = 5000
	var maxValue = id == "ShortDescr" ? 200 : 5000;

	// if value > maxValue, only return the first maxValue characters
	if (value >= maxValue)
		document.getElementById(id).value = document.getElementById(id).value.substring(0,maxValue);

	// set the count display
	document.getElementById('Count'+id).value = '['+document.getElementById(id).value.length+' of '+maxValue+' characters]';
}
// this function will only hide a table
function hideOneTable(id) {
	if (document.getElementById(id))
		document.getElementById(id).style.display = 'none';
}
// this function will only show a table
function showOneTable(id) {
	if (document.getElementById(id))
		document.getElementById(id).style.display = '';
}
// show/hide X num of hour fields (depends on how the datestart and dateend span)
function showTimeFields() {
	if (document.getElementById('DateStart') && document.getElementById('DateStart').value != '' && document.getElementById('DateEnd') && document.getElementById('DateEnd').value != '') {
		var TempStart	= document.getElementById('DateStart').value;
		var TempEnd		= document.getElementById('DateEnd').value;
		var DateStart	= new Date(TempStart.substring(6,10), TempStart.substring(0,2)-1, TempStart.substring(3,5));
		var DateEnd		= new Date(TempEnd.substring(6,10),   TempEnd.substring(0,2)-1,   TempEnd.substring(3,5));
		var one_day		= 1000*60*60*24	// set 1 day in milliseconds
		var NumDays		= Math.ceil((DateEnd.getTime()-DateStart.getTime())/(one_day)) + 1;	// add 1 because this returns the # of days btw

		// show the hour fields or show err msg
		if (NumDays >= 1 && NumDays <= 7) {
			// first hide all the tables incase this was already used (because in that case, fields would be visible)
			document.getElementById('HourError').value					= '';
			document.getElementById('HourErrorTable').style.display 	= 'none';
			for (idx=1;idx<=7;idx++)
				document.getElementById('HourTable'+idx).style.display	= 'none';

			// now show the neccessary amount of hour tables
			for (idx=1;idx<=NumDays;idx++) {
				document.getElementById('StartTime'+idx).value			= new Date(DateStart.getTime() + (idx-1)*24*60*60*1000).toDateString();
				document.getElementById('HourTable'+idx).style.display	= '';
			}
		} else {
			// first hide all the tables incase this was already used (because in that case, fields would be visible)
			for (idx=1;idx<=7;idx++)
				document.getElementById('HourTable'+idx).style.display	= 'none';

			// now show the error msg
			if (NumDays <= 0)
				document.getElementById('HourError').value				= "Oops! Date span cannot be negative.";
			else
				document.getElementById('HourError').value				= "Oops! Date span can only be 1 week.";
			document.getElementById('HourErrorTable').style.display		= '';
		}
	} else {
		// if datestart && dateend fields exist, show err msg
		if (document.getElementById('DateStart') && document.getElementById('DateEnd')) {		
			// first hide all the tables incase this was already used (because in that case, fields would be visible)
			for (idx=1;idx<=7;idx++)
				document.getElementById('HourTable'+idx).style.display	= 'none';
	
			// now show the error msg
			document.getElementById('HourError').value					= "First select a Start Date & End Date.";
			document.getElementById('HourErrorTable').style.display		= '';
		}
	}
}
// when the first start & end times are set, change the rest to match
function setTimeFields(type, value) {
	for (idx=1;idx<=7;idx++) {
		document.getElementById(type+idx).value = value;
	}
}

//*********************************************************************************
//left nav stuff
//*********************************************************************************



















