// JavaScript Document

function changecss(theClass,element,value) {
	//Last Updated on May 21, 2008
	//documentation for this script at
	//http://www.shawnolson.net/a/503/altering-css-class-attributes-with-javascript.html
	var cssRules;
	if (document.all) {
		cssRules = 'rules';
	} else if (document.getElementById) {
		cssRules = 'cssRules';
	}
	var added = false;
	for (var S = 0; S < document.styleSheets.length; S++){
		for (var R = 0; R < document.styleSheets[S][cssRules].length; R++) {
			if (document.styleSheets[S][cssRules][R].selectorText == theClass) {
				if(document.styleSheets[S][cssRules][R].style[element]){
					document.styleSheets[S][cssRules][R].style[element] = value;
					added=true;
					break;
				}
			}
		}
	
		if(!added){
			if(document.styleSheets[S].insertRule){
				document.styleSheets[S].insertRule(theClass+' { '+element+': '+value+'; }',document.styleSheets[S][cssRules].length);
			} else if (document.styleSheets[S].addRule) {
				document.styleSheets[S].addRule(theClass,element+': '+value+';');
			}
		}
	}
} // function changecss(theClass,element,value) {


function chooseColorGraphic( color, graphic ) {
	// assumes color dropdown menu has id "color"
	// assumes graphic dropdown menu has id "graphic"
	document.getElementById("color").value = color;
	document.getElementById("graphic").value = graphic;
	tb_remove();
}

function chooseColorBorderGraphic( color, border, graphic ) {
	// assumes color dropdown menu has id "color"
	// assumes border dropdown menu has id "border"
	// assumes graphic dropdown menu has id "graphic"
	document.getElementById("color").value = color;
	document.getElementById("border").value = border;
	document.getElementById("graphic").value = graphic;
	tb_remove();
}

function changeInnerHTML ( theID, theContent ) {
	document.getElementById( theID ).innerHTML = theContent;
}


function GetWidth() {
	var x = 0;
	if (self.innerWidth) {
		x = self.innerWidth;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		x = document.documentElement.clientWidth;
	} else if (document.body) {
		x = document.body.clientWidth;
	}
	return x;
} //function GetWidth() {

function GetHeight() {
	var y = 0;
	if (self.innerHeight) {
		y = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		y = document.documentElement.clientHeight;
	} else if (document.body) {
		 y = document.body.clientHeight;
	}
	return y;
} //function GetHeight() {

function hideBlacks() {
	// if black background is chosen, this hides all 
	// graphics that are mostly black. These
	// will be invisible on a black background anyway
	//alert("hiding dark graphics");
	var totalGraphics = 52;
	for ( var i = 0; i < 52; i++ ) {
		if ( document.getElementById("hideBlack" + i) ) {
			document.getElementById("hideBlack" + i).style.display = "none";
		}
	}
}

function showBlacks() {
	// shows all graphics that are mostly black
	//alert("unhiding dark graphics");
	var totalGraphics = 52;
	for ( var i = 0; i < 52; i++ ) {
		if ( document.getElementById("hideBlack" + i) ) {
			document.getElementById("hideBlack" + i).style.display = "";
		}
	}
}

function hideLights() {
	// if light background is chosen, this hides all 
	// graphics that are mostly light. These
	// will be invisible on a light background anyway
	//alert("hiding dark graphics");
	var totalGraphics = 52;
	for ( var i = 0; i < 52; i++ ) {
		if ( document.getElementById("hideLight" + i) ) {
			document.getElementById("hideLight" + i).style.display = "none";
		}
	}
}

function showLights() {
	// shows all graphics that are mostly light
	//alert("unhiding dark graphics");
	var totalGraphics = 52;
	for ( var i = 0; i < 52; i++ ) {
		if ( document.getElementById("hideLight" + i) ) {
			document.getElementById("hideLight" + i).style.display = "";
		}
	}
}