// image rollover ----------------------------------------------------------------

var doThis = false;
if(document.getElementById){doThis=true;}

function imageLoader(a) {
	if (document.images) {
		if (!document.p) document.p=new Array();
		var i, j=document.p.length;
		for (i=0; i<a.length; i++)
			if (a[i].indexOf("#")!=0) { document.p[j] = new Image; document.p[j++].src = a[i]; }
	}
}

function preloadImages() {imageLoader(preloadArray);}

var preloadArray = ["_img/nav/about_mo.gif", "_img/nav/about_mo.gif", "_img/nav/about_mo.gif"];

if (window.addEventListener) {
	window.addEventListener("load", preloadImages, true);
} else if (window.attachEvent) {
	window.attachEvent("onload", preloadImages);
} else {
	window.onload = preloadImages;
}

HOVER_X = "_mo";

function swap(i) {
	if (document.images && i.childNodes) {
		var a = swap.arguments[1], s = i.childNodes[0];
		if (a) s.src = a;
		else {
			var x = s.src.lastIndexOf('.'), xl = HOVER_X.length;
			if (s.src.substring(x-xl, x) == HOVER_X)
				s.src = s.src.substring(0,x-xl)+s.src.substring(x,s.src.length);
			else s.src = s.src.substring(0,x)+HOVER_X+s.src.substring(x,s.src.length);
		}
	}
}
// end image rollover ----------------------------------------------------------------

// POPUP --------------------------------------------------------------------------------
// 	usage: popuplink(['js-only url',] this[, w[, h[, scroll[, resizable [, extras]]]]])
// 	basic usage: <a href="popup.html" target="_blank" onclick="return(popuplink(this));">new pop</a>
// 	advanced usage: <a href="popup_nojs.html" target="_blank" onclick="return(popuplink('popup_yesjs.html', this, 200, 100, false,false));">new pop</a>

// 	site-wide defaults:
	popup_w = 600;
	popup_h = 450;
	popup_scroll = true;
	popup_resize = false;
	popup_extras = 'location=0,status=0,menubar=0';

	function popuplink() {
		var undef, i=0, args=popuplink.arguments;
		var url = (typeof(args[i])=='string') ? args[i++] : args[i].getAttribute('href');
		var target = args[i++].getAttribute('target') || '_blank';
		var w = args[i++];
		var h = args[i++];
		var s = (args[i]===undef) ? popup_scroll : args[i++];
		var r = (args[i]===undef) ? popup_resize : args[i++];
	
		//	centering: determine screen center
		var scrw=(screen.width/2)-((w || popup_w)/2);
		var scrh=(screen.height/2)-((h || popup_w)/2);
		 	if (scrh > 100) { scrh = scrh - 40; } // bump vertical pos. just above center, but only if it fits
	
		var features = 'width=' + (w || popup_w)
			 + ',height=' + (h || popup_h)
			 + ',scrollbars=' + (s ? 'yes,' : 'no,')
			 + ',resizable=' + (r ? '1,' : '0,')
			 + (args[i] || popup_extras)
			 + ',left='+scrw+',top='+scrh+',screenX='+scrw+',screenY='+scrh; // positioning for IE and NS
		var win = window.open(url, target, features);
		win.focus();
		return false;
	}
// END POP UP --------------------------------------------------------------------------------


/* show or hide layer below */

function hideLayer(divLayer) {

	if (document.getElementById) {  // the standards way
	document.getElementById(divLayer).style.visibility = "hidden";
	}
	else if (document.all) {  // the old msie way
	document.all[divLayer].style.visibility = "hidden";
	}
	else if (document.layers) {  // the nn4 way
	document.layers[divLayer].visibility = "hidden";
	}

}

function showLayer(divLayer) {

	if (document.getElementById) {  // the standards way
	document.getElementById(divLayer).style.visibility = "visible";
	}
	else if (document.all) {  // the old msie way
	document.all[divLayer].style.visibility = "visible";
	}
	else if (document.layers) {  // the nn4 way
	document.layers[divLayer].visibility = "visible";
	}

}

function handleClick(clickEvent) {

	if (clickEvent == "hideRemoveWarning") {  // onclick hides the layer
	hideLayer("removeWarning");
	}
	else if (clickEvent == "showRemoveWarning") {  // onclick shows the layer
	showLayer("removeWarning");
	}

}

/* end show or hide layer */




// === TABLE STRIPER ===
/*

USAGE:
		<table id="MyStuff">
		<tr>
			<td> One </td>
		</tr>
		<tr>
			<td> Two </td>
		</tr>
		</table>


		<script language="JavaScript" type="text/javascript">
		//<![CDATA[
			stripe('MyStuff'); // use script defaults
			// OR:  specify custom
			// stripe('MyStuff', '#fff', '#edf3fe');
		//]]>
		</script>	

*/


// required work around for IE bug
function hasClass(obj) {
   var result = false;
   if (obj.getAttributeNode("class") != null) {result = obj.getAttributeNode("class").value;}
   return result;
}   

function stripe(id) {
  var even = false;
  // set defaults - can be overridden in function call
  var evenColor = arguments[1] ? arguments[1] : "#eeeeee";
  var oddColor = arguments[2] ? arguments[2] : "#ffffff";

  var table = document.getElementById(id);
  if (! table) { return; }
  var tbodies = table.getElementsByTagName("tbody");
  for (var h = 0; h < tbodies.length; h++) {
    var trs = tbodies[h].getElementsByTagName("tr");
    for (var i = 0; i < trs.length; i++) {
   // avoid rows that have a class attribute or backgroundColor style
   if (!hasClass(trs[i]) && ! trs[i].style.backgroundColor) {
        var tds = trs[i].getElementsByTagName("td");
        for (var j = 0; j < tds.length; j++) {
          var mytd = tds[j];
          // avoid cells that have a class attribute or backgroundColor style
       		if (! hasClass(mytd) && ! mytd.style.backgroundColor) { mytd.style.backgroundColor = even ? evenColor : oddColor; }
	  } }
      even =  ! even;
} } }

// -- end table striper -------------------
