// JavaScript Document
var whichOne = 1; // which style do we use -- increments and rolls over
var howMany = 2; // default
var whatStyle = 'HS2'; // default
var theseRows;
var whatClass = 'greyWhite'; // for now we just make sure the style sheet is loaded before we do this
var addedThese = {}; // put them here as we add them
/*
all styles:
HS2 2 horizontal colors
VS2 2 vertical colors
*/
function stripeOn() {
	var tArray = document.getElementsByTagName("table");
	var topRow = null;
	for(var i=0;i<tArray.length;i++) {
		if (tArray[i].className.match(/^tf_/)) {
			// split it up
			var tS = tArray[i].className.split('_');
			whatStyle = tS[1];
			whatClass = tS[2];
			if (addedThese[tS[2]]) {
				// already got it
				}
			else {
				var objHead = document.getElementsByTagName('head');
				if (objHead[0]) {
					var objCSS = objHead[0].appendChild(document.createElement('link'));
					objCSS.id = tS[2];
					objCSS.rel = 'stylesheet';
					objCSS.href = window.location.protocol + '//' + window.location.hostname + '/css/'+tS[2]+'.css';
					objCSS.type = 'text/css';
					}
				}
			var theseRows = tArray[i].getElementsByTagName("tr");
			for (var j=0;j<theseRows.length;j++) {	
				if (j==0 && whatClass.match(/Top/)) {
					topRow = theseRows[j];
					// use the 'TopRow' styles
					theseRows[j].className = 'tr_'+whatClass + 'TopRow';
					var theseCels = theseRows[j].getElementsByTagName("td");
					for(var k=0;k<theseCels.length;k++) {
						if (k == 0) {
							theseCels[k].className='td_'+whatClass + 'TopRowLeft';
							}
						else if (k == theseCels.length - 1) {
							theseCels[k].className='td_'+whatClass + 'TopRowRight';
							}
						else {
							theseCels[k].className='td_'+whatClass + 'TopRow';
							}
						}
					}
				else if (j==theseRows.length - 1 && whatClass.match(/Bottom/)) {
					// use the 'BottomRow' styles
					theseRows[j].className = 'tr_'+whatClass + 'BottomRow';
					var theseCels = theseRows[j].getElementsByTagName("td");
					for(var k=0;k<theseCels.length;k++) {
						if (k == 0) {
							theseCels[k].className='td_'+whatClass + 'BottomRowLeft';
							}
						else if (k == theseCels.length - 1) {
							theseCels[k].className='td_'+whatClass + 'BottomRowRight';
							}
						else {
							theseCels[k].className='td_'+whatClass + 'BottomRow';
							}
						}
					}
				else {
					theseRows[j].className = 'tr_'+whatClass+whichOne + '';
					var theseCels = theseRows[j].getElementsByTagName("td");
					for(var k=0;k<theseCels.length;k++) {
						if (k == 0) {
							theseCels[k].className='td_'+whatClass + whichOne + 'Left';
							}
						else if (k == theseCels.length - 1) {
							theseCels[k].className='td_'+whatClass + whichOne + 'Right';
							}
						else {
							theseCels[k].className='td_'+whatClass + whichOne;
							}
						}
					whichOne++;
					if (whichOne > howMany) {
						whichOne = 1;
						}
					}
				}
			}
		}
	}

