// JavaScript Document
/*
This first section will set a default style sheet, and an override style sheet for browser extensions

setActiveStyleSheet()  
looks at a group of stylesheets and will flag them as active or alternative, depending on which browser the client is running. 
*/
var moz = (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined');
var browser = navigator.appName;
var b_version = navigator.appVersion;
var version = parseFloat(b_version);
var stylesheet = "";

function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
		if(a.getAttribute("title") == "ss_" + title) a.disabled = false;
      if(a.getAttribute("title") == "default") a.disabled = false;
		if(a.getAttribute("title") == "ss_default") a.disabled = false;
    }
  }
}

function initDocStyle() {
	if (moz) { 
		styleSheet = "moz";
	} else if (window.XMLHttpRequest) {
		styleSheet = "ie7";
	} else if (browser=="Microsoft Internet Explorer") {
		styleSheet = "ie";
	}

	setActiveStyleSheet(styleSheet);
}

function positionNav() {
	var clientWidth = getClientWidth();
	// contentWidth should be defined in the /js/ss.js file
	var padding = (clientWidth - contentWidth) / 2;
	document.getElementById("navigation").style.paddingLeft = padding + "px";
}
// ---- END OF Dynamic Style branching -------

/*
	General  util functions for client & screen
*/
//determine what the client's screen width is. Independant of maximized or partial
function getClientWidth() {
	if (typeof(window.innerWidth) == 'number') { //mozilla
		return (window.innerWidth); 
	} else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
		return document.documentElement.clientWidth; //IE
	} else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
		return document.body.clientWidth; //Legacy
	}
}

//  ----- END CLIENT UTIL 

/*
	functions for controlling tabbed boxes 
		- General Information
*/
	function activateTab(containerName, relatedContainerName, element) {
		var parent = document.getElementById(containerName);
		var relatedContainer = document.getElementById(relatedContainerName);
		if (element.className != "mod_tab_active") {
			resetAllClassName(parent);
			element.className = "mod_tab_active";
			
			flipRelatedContent(relatedContainer);
		}
	}
	
	function resetAllClassName(element) {
		for (i = 0; i < element.childNodes.length; i++) {
			element.childNodes[i].className = "mod_tab";
		}
	}
	
	function flipRelatedContent(element) {
		for (i = 0; i < element.childNodes.length; i++) {
			if (element.childNodes[i].className == "mod_data_active") {
				element.childNodes[i].className = "mod_data";
			} else if (element.childNodes[i].className == "mod_data") {
				element.childNodes[i].className = "mod_data_active";
			}
		}
	}

// -------- End of tabbed box code ------