/* General purpose javascript routines */



//------------------------------------------------------------------------------
// Email obfuscation functions - generate "mailto" links that can't be
// harvested easily
//------------------------------------------------------------------------------

function emailto(acctname) {
    document.write ("<a href=\"mailto:" + acctname + "@interfaceguru.com\">" + acctname + "@interfaceguru.com</a>");
}

function emailto_str(acctname, text) {
    document.write ("<a href=\"mailto:" + acctname + "@interfaceguru.com\">" + text + "</a>");
}




//------------------------------------------------------------------------------
// add_onload - add a function to the list of things done onload
//------------------------------------------------------------------------------

function add_onload(function_to_add) {

	// alert("entering add_onload(" + function_to_add + ")");


	//setup onload function
	if(typeof window.addEventListener != 'undefined') {
		//.. gecko, safari, konqueror and standard
		window.addEventListener('load', function_to_add, false);
		// alert("window.addEventListener");
	}
	else if(typeof document.addEventListener != 'undefined') {
		//.. opera 7
		document.addEventListener('load', function_to_add, false);
		// alert("document.addEventListener");
	}
	else if(typeof window.attachEvent != 'undefined') {
		//.. win/ie
		window.attachEvent('onload', function_to_add);
		// alert("window.attachEvent");
	}
	else {
		//.. mac/ie5 and anything else that gets this far
		// alert("window.onload");

		//if there's an existing onload function

		if(typeof window.onload == 'function') {
			//store it
			var existing = onload;

			//add new onload handler
			window.onload = function()
			{
				//call existing onload function
				existing();

				//call function to add
				function_to_add();
			};
		}
		else {
			// no onload function yet
			window.onload = function_to_add;
		}
	}


}



//------------------------------------------------------------------------------
// alternate_rows - for a table with given id, give rows alternating classes
//
// For Right Now, assumes TRs don't have classes already
// (could eventually color TDs if they don't have a class, etc etc)
//------------------------------------------------------------------------------

function label_alternate_rows(table_id) {

	table_to_label = document.getElementById(table_id);
	// should check to see if it's a table...
	if (table_to_label) {
		rows_to_label = table_to_label.getElementsByTagName("tr");
		if (rows_to_label) {
			for (i=0; i<rows_to_label.length; i++) {
				if (i%2 == 0) {
					newClassName = "even_row";
				} else {
					newClassName = "odd_row";
				}
				rows_to_label[i].className = newClassName;
			}
		} else {
		}
	} else {
	}


}


