// FORM - Hides an item.
function toggle(ID){var id = eval("document.all."+ ID);if (id.style.display == "none"){id.style.display = "";if (ID == "Solutions"){document.getElementById("solutionsButton").value = "Hide Solutions";}}else{id.style.display = "none";if (ID == "Solutions"){document.getElementById("solutionsButton").value = "Show Solutions";}}}
// Display - Similar to toggle, but changes the values of icons and text items. USAGE: Glossaries or Table of Contents.
function collapse(ID,IMAGE){var id = eval("document.all."+ ID +"_1");var image = eval("document.all."+ ID + IMAGE);if (id.style.display == "none"){id.style.display = "";image.src = "../../resourcesmain/images/icons/tree_Collapse.png";image.alt = "Collapse";}else{id.style.display = "none";image.src = "../../resourcesmain/images/icons/tree_Expand.png";image.alt = "Expand";}}
// Will make element visible.
function show(ID) {var id = eval("document.all."+ ID);{id.style.display = "";}}
function ShowAll(ID){document.all(ID).style.display = "";}
// Will make element IN-visible.
function hide(ID) {var id = eval("document.all."+ ID);{id.style.display = "none";}}
function HideAll(ID){document.all(ID).style.display = "none";}

// FORM - Using starting and ending values, you can increment values. USAGE: Times, dates, anything that is set of repeatable sets of numbers.
function increment(STARTING, ENDING, INCREMENT) {for (var i = STARTING; i <= ENDING; i=i+INCREMENT)document.write('<OPTION VALUE="' + i + '">' + i + '\n');}
// FORM - Character Counter
function textcounter(field, countfield, maxlimit) {
	if (field.value.length > maxlimit) // if too long...trim it!
	field.value = field.value.substring(0, maxlimit);
	// otherwise, update 'characters left' counter
	else 
	countfield.value = maxlimit - field.value.length;
	}
// FORM - Check All boxes, with toggle.
function checkAll(checkname, exby) {
  for (i = 0; i < checkname.length; i++)
  checkname[i].checked = exby.checked? true:false}
/* <form name ="mylist">
  <input type="checkbox" name="checkGroup" value ="first">First<br>
  <input type="checkbox" name="checkGroup" value ="second">Second<br>
  <input type="checkbox" name="checkGroup" value ="third">Third<br>
  <input type="checkbox" name="checkGroup" value ="fourth">Fourth<br>
  <input type="checkbox" name="all" onClick="checkAll(document.mylist.checkGroup,this)">Check/Uncheck All<br>
</form>

Check by group
http://javascript.internet.com/forms/check-by-group.html

Check box validation
http://javascript.internet.com/forms/check-form.html

Table of Contents
http://javascript.internet.com/navigation/build-toc.html
*/

// FORM - Dropdown listbox show/hide DIV. Make sure you increment the <div ID="X"> and <SELECT value"X">
function swap(selObj,inputId)
{
	var optionVal = selObj[selObj.selectedIndex].value;
	if (optionVal == "0")
	{
		document.getElementById(inputId).style.display = "";
		document.getElementById('1').style.display = "none";
		document.getElementById('2').style.display = "none";
		document.getElementById('3').style.display = "none";
		document.getElementById('4').style.display = "none";		
	}
	else if (optionVal == "1")
	{
		document.getElementById(inputId).style.display = "none";
		document.getElementById('1').style.display = "";
		document.getElementById('2').style.display = "none";
		document.getElementById('3').style.display = "none";
		document.getElementById('4').style.display = "none";		
	}
	else if (optionVal == "2")
	{
		document.getElementById(inputId).style.display = "none";
		document.getElementById('1').style.display = "none";
		document.getElementById('2').style.display = "";
		document.getElementById('3').style.display = "none";
		document.getElementById('4').style.display = "none";		
	}
	else if (optionVal == "3")
	{
		document.getElementById(inputId).style.display = "none";
		document.getElementById('1').style.display = "none";
		document.getElementById('2').style.display = "none";
		document.getElementById('3').style.display = "";
		document.getElementById('4').style.display = "none";		
	}
	else if (optionVal == "4")
	{
		document.getElementById(inputId).style.display = "none";
		document.getElementById('1').style.display = "none";
		document.getElementById('2').style.display = "none";
		document.getElementById('3').style.display = "none";
		document.getElementById('4').style.display = "";		
	}
	else
	{
		document.getElementById(inputId).style.display = "none";
	}
}
//Filtering with search
function RemoveAllFilters(){for (var i = 2; i <= 8; i++){var filter = "filter"+ i;document.all(filter).style.display = "none";}}
function RemoveFilter(ID){var filter = "filter"+ ID;document.all(filter).style.display = "none";}
function AddFilter(){var count = 8;var id = "filter";for (var i=2; i <= count; i++){if (document.all(id+i).style.display == "none"){document.all(id+i).style.display = "";return;}}alert("You can add at most 8 filters.");}


// DISPLAY - Hides multiple items USAGE: Reports pages
function showHide(){
	var count = 50;
	var display = (document.all.showHide1.style.display == "") ? "none" : "";
	for (var i=1; i <= count; i++){
		var toggle = eval("document.all.showHide"+ i);
		showHide.style.display = display;
	}
}
// FORM - Disables fields
function enable(ID,BOOL){
	var field = document.all(ID);
	if(BOOL)field.disabled = "";
	else		field.disabled = "true";return
}
// Goto next HTML file
function goNext(input)
{var directory = "HTML/";var webURL = "http://www.superunit5000.com/";
  string = input;//"http://www.superunit5000.com/" + directory + 
  location.href = string;
}
// Goto previous HTML file
function goPrev(input)
{var directory = "HTML/";var webURL = "http://www.superunit5000.com/";
  string = input;//"http://www.superunit5000.com/" + directory + 
  location.href = string;
}








// Alternating row colors for list Renders.
function hasClass(obj){
	 var result = false;
	 if (obj.getAttributeNode("class") != null) {
			 result = obj.getAttributeNode("class").value;
	 }
	 return result;
}
function stripe(id){
// the flag we'll use to keep track of whether the current row is odd or even
var even = false;
// if arguments are provided to specify the colours of the even & odd rows, then use the them, otherwise use the following defaults:
var evenColor = arguments[1] ? arguments[1] : "#fff";
var oddColor = arguments[2] ? arguments[2] : "#eee";
// obtain a reference to the desired table if no such table exists, abort
var table = document.getElementById(id);
if (! table) { return; }
// by definition, tables can have more than one tbody element, so we'll have to get the list of child tbody
var tbodies = table.getElementsByTagName("tbody");
// and iterate through them...
for (var h = 0; h < tbodies.length; h++) {
 // find all the &lt;tr&gt; elements... 
	var trs = tbodies[h].getElementsByTagName("tr");
	// ... and iterate through them
	for (var i = 0; i < trs.length; i++) {
		// avoid rows that have a class attribute or backgroundColor style
		if (! hasClass(trs[i]) &&
				! trs[i].style.backgroundColor) {
			// get all the cells in this row...
			var tds = trs[i].getElementsByTagName("td");
			// and iterate through them...
			for (var j = 0; j < tds.length; j++) {
				var mytd = tds[j];
				// avoid cells that have a class attribute or backgroundColor style
				if (! hasClass(mytd) &&
						! mytd.style.backgroundColor) {
					mytd.style.backgroundColor = even ? evenColor : oddColor;
				}
			}
		}
		// flip from odd to even, or vice-versa
		even =  ! even;
	}
}
}



// Alternate row colors for list items. USAGE: Dashboards
function zebra_OL(id){
	var even = false;
	var evenColor = arguments[1] ? arguments[1] : "#FFFFFF";
	var oddColor = arguments[2] ? arguments[2] : "#DDD";
	// obtain a reference to the desired list
	// if no such list exists, abort
	var ul = document.getElementById(id);
	if (! ul) { return; }
	var lis = ul.getElementsByTagName("li");
// and iterate through them...
	for (var h = 0; h < lis.length; h++) {
		var list = lis[h];  
	list.style.backgroundColor = even ? evenColor : oddColor;
			// flip from odd to even, or vice-versa
			even =  ! even; 
	}
}



// Opens "Pattern Library" in a totally useless, but cool way. Using MM_openBrWindow is probably a better way to do this.
function windowExpand(WEBSITE) {
	var heightspeed = 60; // vertical scrolling speed (higher = faster)
	var widthspeed = 60;  // horizontal scrolling speed (higher = faster)
	var leftdist = 0;    // distance to left edge of window
	var topdist = 0;     // distance to top edge of window
	if (document.all) 
		{
			var winwidth = window.screen.availWidth - leftdist;
			var winheight = window.screen.availHeight - topdist;
			var sizer = window.open("","","left=" + leftdist + ",top=" + topdist + ",width=1,height=1,scrollbars=yes");
			for (sizeheight = 1; sizeheight < winheight; sizeheight += heightspeed) {
			sizer.resizeTo("1", sizeheight);
		}
	for (sizewidth = 1; sizewidth < winwidth; sizewidth += widthspeed) 
		{
			sizer.resizeTo(sizewidth, sizeheight);
		}
	sizer.location = WEBSITE;
	}
	else
		window.location = WEBSITE;
}





// Solutions Panel
function onClick_SolutionsLink(FILENAME){
launchHelp('solutions/'+ FILENAME);
}
function onClick_Solutions(ID){
	if (ID != "") // hide
		{
		if (ID == "1")
			SWITCH = "1";
		else if (ID == "0")
			SWITCH = "";
		}
	else
		{
		SWITCH = document.all("solutionsBar").style.display;
		}
	toggleSolutions(SWITCH);
}
function toggleSolutions(SWITCH){
	if (SWITCH == "") // hide
		{
		document.all("solutionsBar").style.display = "none";
		document.all("solutionsButton").value = "Show Solutions";
		setCookie("ID","0",90);
		}
	else //show
		{
		document.all("solutionsBar").style.display = "";
		document.all("solutionsButton").value = "Hide Solutions";
		setCookie("ID","1",90);
		}
}
function initSolutions(){//deleteCookie("ID");
	onClick_Solutions(getCookie("ID"));
}







/***********************************************
* Ajax Rotating Includes script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

//To include a page, invoke ajaxinclude(files_array, "ROTATETYPE") in the BODY of page.
//* file_array is the name of the array containing your list of files to include.
//* For "ROTATETYPE", valid values are "dailyw", "dailym", and "random", for each day of the week, each day of the month, and random, respectively.
//* Included file MUST be from the same domain as the page displaying it.

//Enter path to list of files to display.
//For rotatetype="dailyw", there must be 7 files, and for "dailym", 31 files. Otherwise, no restriction:


var mailinglist=["includes/mailinglist.htm", "includes/mailinglist.htm"]
var newsbox=["includes/newsbox.htm"]
var reviews=["includes/reviews/reviews.htm"]
var archive=["includes/archive.htm"]
var dailyw=["includes/newsbox_MONDAY.htm", "includes/newsbox_TUESDAY.htm", "includes/newsbox_WEDNESDAY.htm", "includes/newsbox_THURSDAY.htm", "includes/newsbox_FRIDAY.htm", "includes/newsbox_SATURDAY.htm", "includes/newsbox.htm"]
var rootdomain="http://"+window.location.hostname

function ajaxinclude(files_array, rotatetype){
var page_request = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP")
} 
catch (e){
try{
page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false
var url=choosefile(files_array, rotatetype)
if (typeof files_array[url]=="undefined"){
document.write("Error: No file for this day has been found.")
return
}
else
url=files_array[url]
page_request.open('GET', url, false) //get page synchronously 
page_request.send(null)
writecontent(page_request)
}

function writecontent(page_request){
if (window.location.href.indexOf("http")==-1 || page_request.status==200)
document.write(page_request.responseText)
}

function choosefile(files_array, rotatetype){
var today=new Date()
var selectedfile=(rotatetype=="dailyw")? today.getDay() : rotatetype=="dailym"? today.getDate() : Math.floor(Math.random()*files_array.length)
if (rotatetype=="dailyw" && selectedfile==0) //if display type=="week days" and today is Sunday 
selectedfile=7
if (rotatetype=="dailyw" || rotatetype=="dailym")
selectedfile--  //remove 1 to sync with array index
return selectedfile
}

