/* 	Site Page Libary 5.4
	Copyright © 2001 - 2007 Darren Blackley, Simplify iT Innovations.
	Last Updated: 22 September 2007 
-------------------------------------------------------------------	*/ 
	
/* User variables */

/* these settings are for the strip colors used on tables. */
tabColor = '#f0b83a'; 
altTabColor = '#eee';

/* define site type extension - eg. HTM, PHP, ASP etc
   MUST BE IN LOWER CASE */
siteType = 'php';

/* You can use the following code as a href to give you a centralised
Pop-up Window: 
NewWindow('theURL','windowName','600','500','no','no',10); 
theURL - is the location of the site/page that you want to load in the Pop-up
windowName -  can be anything you like
The 600 and 500 value is the width and height (in that order) of the pop-up window
The next value is YES or NO to if you want a scroll bar in the pop-up window
The next value is YES or NO to if you want an address bar in the pop-up window
The final value is a timeout - if you want to have the window open for say 10 second
*/

/* do not edit beong this point or the script will not function 	
   ------------------------------------------------------------ */
   
/* print friendly popup */
function printFriendly(w, h, scroll, loc) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable=1,location='+loc+',status=1,toolbar=0,menubar=1'
printReady = window.open(self.location, 'printReady', winprops)
if (parseInt(navigator.appVersion) >= 4) { printReady.window.focus(); }
}
if (self.name == 'printReady') {
document.write('<link href="includes/printready.css" rel="stylesheet" type="text/css" />');
window.print();
setTimeout("self.close()",5 * 1000);
	}

/* New Window Popup in Centre */
function NewWindow(mypage, myname, w, h, scroll, loc, timeoutval) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable=no,location='+loc+',status=no'
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
//document.location = ('index.php');
if (timeoutval > 0) {
setTimeout('win.close()',timeoutval * 1000); 
}
}
/*NewWindow('theURL','windowName','600','500','no');*/
/* End Window PopUp Script */ 

/* Load this function once the page fully loads using the window.onload
   function.  Check all links and if external load in disclaimer window. */
function mOver() {
self.status='Click here now to visit this site'; return true;
}
function mOut() {
self.status=''; return true;
}


/* clear form fields on click */
function clearText(thefield){
if (thefield.defaultValue==thefield.value)
thefield.value = ""
} 



// Table Striping option
  // this function is needed to work around 
  // a bug in IE related to element attributes
  function hasClass(obj) {
     var result = false;
     if (obj.getAttributeNode("class") != null) {
         result = obj.getAttributeNode("class").value;
     }
     return result;
  }   

 function stripeTables(id) {

    // the flag we'll use to keep track of 
    // whether the current row is odd or even
    var even = false;
  
	// Set the alternate color in the method call arguments
	var evenColor; 
	
	
	
	
	
	// hard coded here and applies to all tables.
	/*
	*********
	*********
	*/
	
    var oddColor = altTabColor;
	
    /*
	*********
	*********
	*/ 
	// hard coded here and applies to all tables.
	
	
	
	
	 
	 // Populate 2 arrays with the arguments,
	 // separating the colors from the ID's.
	 var colorArray = new Array();
	 var cArrayCount = 0;
	 
	 var IdArray = new Array();
	 var IdArrayCount = 0;
	 
	 // This script assumes that the arguements always
	 // come in pairs: ID / evenColor. So the first
	 // argument will always be the ID.
	 for (i_id = 0; i_id < arguments.length; i_id++) {
	 	
		// Since the function arguments are formatted in ID/color pairs,
		// and the first argument is an ID, when %2 == 0 
		// it will be a element ID and not a color.
		if (i_id%2 == 0) {
			IdArray[IdArrayCount] = arguments[i_id];
			IdArrayCount++;
		}
		else {
			colorArray[cArrayCount] = arguments[i_id];
			cArrayCount++;			
		}
	 }
	 // Populate 2 arrays with arguments
	 
	 
	 
	 
	 /*
	 // Testing code for the arrays
	 alert("Color Array has: "+ colorArray.length);
	 alert("ID Array has: "+IdArray.length);
	 
	 for (a = 0; a < colorArray.length; a++) {
	 	alert(colorArray[a]);	 	
	 }
	 
	  for (a = 0; a < IdArray.length; a++) {
	 	alert(IdArray[a]);	 	
	 }
	 // Testing code for the arrays
	 */
	 
	
	
	 // color the rows for each table as defined in the function arguments
	 for (a = 0; a < IdArray.length; a++) {	 	 
		  		 
		 	     evenColor = colorArray[a]; 		
		 			 
		 		// obtain a reference to the desired table
				// if no such table exists, abort
				var table = document.getElementById(IdArray[a]);
				if (! table) { return; }		 
				
				
				// by definition, tables can have more than one tbody
				// element, so we'll have to get the list of child
				// &lt;tbody&gt;s 
				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;
				  }
				}
		} // for loop		
  }