
if (document.getElementById) document.write('<link rel="stylesheet" type="text/css" href="styles/hand.css">')

/* 
	Javascript to style odd/even table rows
	Derived from 'Zebra Tables' by David F. Miller (http://www.alistapart.com/articles/zebratables/)
	
	Modified by Jop de Klein, february 2005
	jop at validweb.nl
	http://validweb.nl/artikelen/javascript/better-zebra-tables/
	
	Modified by Peter Nemec, september 2006
*/

	var stripe = function() {
	  		trs = new Array;
			var tables = document.getElementsByTagName("table");	
	
			for (var x = 0; x < tables.length; x++) {
				var table = tables[x];
				if (!table) return;
				
				var tbodies = table.getElementsByTagName("tbody");
				
				for (var h = 0; h < tbodies.length; h++) {
					var trsh = tbodies[h].getElementsByTagName("tr");
					for (var i=0; i<trsh.length; i++) {
					  trs[trs.length] = trsh[i];
					}
				}
			}

				var odd = false;
				var h1odd = false;
				var h2odd = false;
				var a = -1; var b = -1; var c = -1; var d = -1; th1 = -1; th2 = -1; rS = -1; rS1 = -1; rS2 = -1;
				tds = new Array;
			for (var i = 0; i < trs.length; i++) {
					
				if (trs[i].className!="headline" && trs[i].className!="subheadline" && trs[i].className!="headings" && trs[i].className!="info") {
					var trlinks = trs[i].getElementsByTagName("a");
					if (trlinks[0]) {
						trs[i].trlink = trlinks[0].href;
						trs[i].onclick = function() {
							document.location.href = this.trlink;
							return false;
							}
					}
				  tds[i] = trs[i].childNodes;
				  trs[i].th1X = a;
				  trs[i].th2X = b;
				  trs[i].th1Y = c;
				  trs[i].th2Y = d;
				  
				  p=0;
				  trs[i].cS = false;
				  
				  if (rS > 0) {
								trs[i].cS = true;
								rS = rS - 1;
				  }
				  
				if (rS1 < 1) {
					for (var f = 0; f < tds[i].length; f++) {
					  if (tds[i][f].nodeName.toLowerCase()=="th") {
						th1 = f;
						p = f + 1;
						if (tds[i][f].colSpan>1) trs[i].cS = true;
						if (tds[i][f].colSpan>1 && tds[i][f].rowSpan>1) rS = tds[i][f].rowSpan-1;
						break;
					  }
					}
				}
				
		  
				if (rS2 < 1 && !trs[i].cS) {
					for (var g = p; g < tds[i].length; g++) {
						 if (tds[i][g].nodeName.toLowerCase()=="th") {
							th2 = g;
							break;
						 }
					}
				}
          			  
				  if (th1 != -1) {
					if (rS1 > 0) {
					  rS1 = rS1 - 1;
					}
					else if(tds[i][th1].nodeName.toLowerCase()=="th" && tds[i][th1].rowSpan>1) {
					  trs[i].th1X = th1;
					  a = th1;
					  trs[i].th1Y = i;
					  c = i;
					  rS1 = tds[i][th1].rowSpan - 1;
					  if(h1odd && trs[i].className!="new") {
						  if (tds[i][th1].className.lastIndexOf("prvy")!=-1)
						  tds[i][th1].className += " iny";
					  }
					  h1odd = !h1odd;
					}
					else if(tds[i][th1].nodeName.toLowerCase()=="th") {
					  trs[i].th1X = th1;
					  a = th1;
					  trs[i].th1Y = i;
					  c = i;
					  if(h1odd && trs[i].className!="new") {
						  if (tds[i][th1].className.lastIndexOf("prvy")!=-1)
						  tds[i][th1].className += " iny";
					  }
					  h1odd = !h1odd;
					}
				  }
				  if (th2 != -1) {
					if (rS2 > 0) {
					  rS2 = rS2 - 1;
					}
					else if(tds[i][th2].nodeName.toLowerCase()=="th" && tds[i][th2].rowSpan>1) {
					  trs[i].th2X = th2;
					  b = th2;
					  trs[i].th2Y = i;
					  d = i;
					  rS2 = tds[i][th2].rowSpan - 1;
					  if(h2odd && trs[i].className!="new") tds[i][th2].className += " odd";
					  h2odd = !h2odd;
					}
					else if(tds[i][th2].nodeName.toLowerCase()=="th") {
					  trs[i].th2X = th2;
					  b = th2;
					  trs[i].th2Y = i;
					  d = i;
					  if(h2odd && trs[i].className!="new") tds[i][th2].className += " odd";
					  h2odd = !h2odd;
					}
				  }
				
					trs[i].onmouseover=function(){
						this.className += " ruled";
            			rowOn(this);
            			return false
					}
					trs[i].onmouseout=function(){
						this.className = this.className.replace("ruled", "");
            			rowOff(this);
            			return false
					}
					
					if(odd) trs[i].className += " odd";
					
					odd = !odd;
				}
			}

	}

function rowOn(whichRow) {
  if (th1 != -1) tds[whichRow.th1Y][whichRow.th1X].className += " multi";
  if (th2 != -1 && !whichRow.cS) tds[whichRow.th2Y][whichRow.th2X].className += " multi";
  return;
}

function rowOff(whichRow) {
  if (th1 != -1) tds[whichRow.th1Y][whichRow.th1X].className = tds[whichRow.th1Y][whichRow.th1X].className.replace("multi", "");
  if (th2 != -1 && !whichRow.cS) tds[whichRow.th2Y][whichRow.th2X].className = tds[whichRow.th2Y][whichRow.th2X].className.replace("multi", "");
  return;
}

window.onload = stripe;

