// setStyleByClass: given an element type and a class selector,
// style property and value, apply the style.
// args:
//  t - type of tag to check for (e.g., SPAN)
//  c - class name
//  p - CSS property
//  v - value
var ie = (document.all) ? true : false;

function setStyleByClassFRAME(t,c,p,v){
	var elements;
	if(t == '*') {
		// '*' not supported by IE/Win 5.5 and below
		elements = (ie) ? document.all : top.head.document.getElementsByTagName('*'); // top.head ADDED FOR FRAME!
	} else {
		elements = top.head.document.getElementsByTagName(t); // top.head ADDED FOR FRAME!
	}
	for(var i = 0; i < elements.length; i++){
		var node = elements.item(i);
		for(var j = 0; j < node.attributes.length; j++) {
			if(node.attributes.item(j).nodeName == 'class') {
				if(node.attributes.item(j).nodeValue == c) {
					eval('node.style.' + p + " = '" +v + "'");
				}
			}
		}
	}
}

// getStyleByClass: given an element type, a class selector and a property,
// return the value of the property for that element type.
// args:
//  t - element type
//  c - class identifier
//  p - CSS property
function getStyleByClassFRAME(t, c, p) {
	// first loop over elements, because if they've been modified they
	// will contain style data more recent than that in the stylesheet
	var elements;
	if(t == '*') {
		// '*' not supported by IE/Win 5.5 and below
		elements = (ie) ? document.all : top.head.document.getElementsByTagName('*'); // top.head ADDED FOR FRAME!
	} else {
		elements = top.head.document.getElementsByTagName(t); // top.head ADDED FOR FRAME!
	}
	for(var i = 0; i < elements.length; i++){
		var node = elements.item(i);
		for(var j = 0; j < node.attributes.length; j++) {
			if(node.attributes.item(j).nodeName == 'class') {
				if(node.attributes.item(j).nodeValue == c) {
					var theStyle = eval('node.style.' + p);
					if((theStyle != "") && (theStyle != null)) {
						return theStyle;
					}
				}
			}
		}		
	}
	// if we got here it's because we didn't find anything
	// try styleSheets
	var sheets = top.head.document.styleSheets; // top.head ADDED FOR FRAME!
	if(sheets.length > 0) {
		// loop over each sheet
		for(var x = 0; x < sheets.length; x++) {
			// grab stylesheet rules
			var rules = sheets[x].cssRules;
			if(rules.length > 0) {
				// check each rule
				for(var y = 0; y < rules.length; y++) {
					var z = rules[y].style;
					// selectorText broken in NS 6/Mozilla: see
					// http://bugzilla.mozilla.org/show_bug.cgi?id=51944
					ugly_selectorText_workaround();
					if(allStyleRules) {
						if((allStyleRules[y] == c) ||
						   (allStyleRules[y] == (t + "." + c))) {
							return z[p];
						}			
					} else {
						// use the native selectorText and style stuff
						if(((z[p] != "") && (z[p] != null)) &&
						   ((rules[y].selectorText == c) ||
						    (rules[y].selectorText == (t + "." + c)))) {
							return z[p];
						}
					}
				}
			}
		}
	}
	return null;
}

// SET COLORS

var colorOut = '#111111';
var colorOut2 = 'rgb(17, 17, 17)';

var colorOver = '#990033';
var colorOver2 = 'rgb(153, 0, 51)';

var colorSelect = '#666666';
var colorSelect2 = 'rgb(102, 102, 102)';

var colorSelectOver = '#990034';
var colorSelectOver2 = 'rgb(153, 0, 52)';

// ROLLOVER FUNCTIONS

function tabOver(tabNum) {
	getTab = getStyleByClassFRAME('td', 'tab' + tabNum, 'backgroundColor');
	if(getTab == colorOut || getTab == colorOut2) {
		setStyleByClassFRAME('td', 'tab' + tabNum, 'backgroundColor', colorOver);
	} else if(getTab == colorSelect || getTab == colorSelect2) {
		setStyleByClassFRAME('td', 'tab' + tabNum, 'backgroundColor', colorSelectOver);
	}
	return;
}

function tabOut(tabNum) {
	getTab = getStyleByClassFRAME('td', 'tab' + tabNum, 'backgroundColor');
	if(getTab == colorOver || getTab == colorOver2) {
		setStyleByClassFRAME('td', 'tab' + tabNum, 'backgroundColor', colorOut);
	} else if(getTab == colorSelectOver || getTab == colorSelectOver2) {
		setStyleByClassFRAME('td', 'tab' + tabNum, 'backgroundColor', colorSelect);
	}
	return;
}

function tabClick(tabNum, link, limit) {
	limit = limit + 1;
	for(i = 1; i < limit; i++) {
		setStyleByClassFRAME('td', 'tab' + i, 'backgroundColor', colorOut);
	}
	setStyleByClassFRAME('td', 'tab' + tabNum, 'backgroundColor', colorSelect);
	top.body.document.location = link;
	return;
}

function tabSet(tabNum, limit) {
	limit = limit + 1;
	for(i = 1; i < limit; i++) {
		setStyleByClassFRAME('td', 'tab' + i, 'backgroundColor', colorOut);
	}
	setStyleByClassFRAME('td', 'tab' + tabNum, 'backgroundColor', colorSelect);
	return;
}

