/* 	Site Page Libary 5.3
	Copyright © 2001 - 2007 Darren Blackley, Simplify iT Innovations.
	Last Updated: 18 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 	
   ------------------------------------------------------------ */
   
/*Browsercheck object*/
function cm_bwcheck(){
	//In theory we should use object detection, but this script needs work-arounds for almost every browser...
	this.ver=navigator.appVersion
	this.agent=navigator.userAgent.toLowerCase()
	this.dom=document.getElementById?1:0
	this.ns4=(!this.dom && document.layers)?1:0;
	this.op=window.opera 
	this.moz=(this.agent.indexOf("gecko")>-1 || window.sidebar)
	this.ie=this.agent.indexOf("msie")>-1 && !this.op
	if(this.op){
		this.op5=(this.agent.indexOf("opera 5")>-1 || this.agent.indexOf("opera/5")>-1)
		this.op6=(this.agent.indexOf("opera 6")>-1 || this.agent.indexOf("opera/6")>-1)
		this.op7=this.dom&&!this.op5&&!this.op6 //So all higher opera versions will use it
	}else if(this.moz) this.ns6 = 1
	else if(this.ie){
		this.ie4 = !this.dom && document.all
  	this.ie5 = (this.agent.indexOf("msie 5")>-1)
  	this.ie55 = (this.ie5 && this.agent.indexOf("msie 5.5")>-1)
  	this.ie6 = this.dom && !this.ie4 && !this.ie5 && ! this.ie55
	}
	this.mac=(this.agent.indexOf("mac")>-1)
	this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.op5 || this.op6 || this.op7)
  this.usedom= this.ns6||this.op7//Use dom creation
  this.reuse = this.ie||this.op7||this.usedom //Reuse layers
  this.px=this.dom&&!this.op5?"px":""
	return this
}
var bw=new cm_bwcheck()

/* show/hide elements by id block*/
function showhide(id) {
	current = (document.getElementById(id).style.display == 'block') ? 'none' : 'block'
		document.getElementById(id).style.display = current;
	}

/* show/hide elements by id inline*/
function showhide_b(id) {
	current = (document.getElementById(id).style.display == 'inline') ? 'none' : 'inline'
		document.getElementById(id).style.display = current;
}
	
/* 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);
	}

/* 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;
}

window.onload = function() {
/* automatically set all external links to use link frameset */
d = document.links; f = "file:"; j = "javascript:"; m = "mailto:"; t = "extLinks"; s = "www.simplify-i-t.com";
for (i = 0; i < (d.length); i++)
if (d[i].protocol != f && d[i].protocol != j && d[i].protocol != m && d[i].hostname != document.domain && d[i].hostname != s) {
	d[i].title = "External link to " + d[i].href;
	d[i].onmouseover = mOver
	d[i].onmouseout = mOut
	d[i].href = 'lnkframe.'+siteType+'?url=' + escape(d[i].href);
	d[i].target = t;
	}
  if (document.getElementById('table0') != null && self.name != 'printReady') {
	stripeTables('table0',tabColor,'table1',tabColor,'table2',tabColor,'table3',tabColor,'table4',tabColor,'table5',tabColor,'table6',tabColor,'table7',tabColor,'table8',tabColor,'table9',tabColor);
	}  
}

/* Tab content navigation function */
function switchid(id){
     ids = document.getElementById('content').getElementsByTagName('div');    
     hideallids();
     showdiv(id);
}

function hideallids(){
     //loop through the array and hide each element by id
     for (var i=0;i<ids.length;i++){
          hidediv(ids[i].id);    
     }            
}

function hidediv(id) {
     //safe function to hide an element with a specified id
     if (document.getElementById) { // DOM3 = IE5, NS6
          document.getElementById(id).style.display = 'none';
     }
     else {
          if (document.layers) { // Netscape 4
               document.id.display = 'none';
          }
          else { // IE 4
               document.all.id.style.display = 'none';
          }
     }
}

function showdiv(id) {
for (var i=0;i<ids.length;i++){
         divname=ids[i].id;
        if(id!=divname) {document.getElementById(divname + 'tab').className = 'notselected';  
        				 document.getElementById(divname + 'btab').className = 'notselected';} 
          else {document.getElementById(divname + 'tab').className = 'selected'; 
          		document.getElementById(divname + 'btab').className = 'selected'; }
     }  
     //safe function to show an element with a specified id
     if (document.getElementById) { // DOM3 = IE5, NS6
          document.getElementById(id).style.display = 'block';
     }
     else {
          if (document.layers) { // Netscape 4
               document.id.display = 'block';
          }
          else { // IE 4
               document.all.id.style.display = 'block';
          }
     }
}  

/* start last modified date code */
var lutext;
	var lutime;
	var ludm;
	var ludd;
	var ludy;
	function sstr(a,b){ //extract substrings
		ret=lutime.substring(a,b);
		if (ret=="Jan" || ret=="01") ret="1";
		if (ret=="Feb" || ret=="02") ret="2";
		if (ret=="Mar" || ret=="03" || ret=="Mrz") ret="3";
		if (ret=="Apr" || ret=="04") ret="4";
		if (ret=="May" || ret=="05" || ret=="Mai") ret="5";
		if (ret=="Jun" || ret=="06") ret="6";
		if (ret=="Jul" || ret=="07") ret="7";
		if (ret=="Aug" || ret=="08") ret="8";
		if (ret=="Sep" || ret=="09") ret="9";
		if (ret=="Oct" || ret=="Okt") ret="10";
		if (ret=="Nov") ret="11";
		if (ret=="Dec" || ret=="Dez") ret="12";
		return ret;
	}
	lutime = unescape(document.lastModified);
	if (lutime.length == 17) { // Netscape 3 and higher, Internet Explorer 4
	ludm = sstr(0,2);
	ludd = sstr(3,5);
	ludy = sstr(6,8);
	}

        if (lutime.length == 19) { // Netscape 3 and higher, Internet Explorer 4 and higher, 4-digit year
        ludm = sstr(0,2);       
        ludd = sstr(3,5);       
        ludy = sstr(6,10);
        }

	if (lutime.length == 25 || lutime.length == 24) { // Netscape 2
	ludm = sstr(4,7);
	ludd = sstr(8,10);
	ludy = sstr(20,24);
	}
	if (lutime.length == 29) { // Opera 3
	ludm = sstr(8,11);
	ludd = sstr(5,7);
	ludy = sstr(12,16);
	}
	if (lutime.length == 23) { // Internet Explorer 3
	ludm = sstr(3,6);
	ludd = sstr(7,9);
	ludy = sstr(19,23);
	}
	lutext = "";

	monthName = new Array(12)
	monthName[1] = 'January'
	monthName[2] = 'February'
	monthName[3] = 'March'
	monthName[4] = 'April'
	monthName[5] = 'May'
	monthName[6] = 'June'
	monthName[7] = 'July'
	monthName[8] = 'August'
	monthName[9] = 'September'
	monthName[10] = 'October'
	monthName[11] = 'November'
	monthName[12] = 'December'
	yearNow = null
	if (ludy.length==2) {
	if (ludy >= 90) {
	yearNow = 19
	}
	else {
	yearNow = 20
	}
	}
	else yearNow=""
	lutext += ludd+" "+ monthName[ludm] +" "+ yearNow + ludy +" ";

/* end last modified date code */

/* 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 */ 


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

/* email validation */
function isEmailAddr(email) {
  var result = false
  var theStr = new String(email)
  var index = theStr.indexOf("@");
  if (index > 0)   {
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
	result = true;
  }
  return result;
}

function FormValidator(theForm) {
  if (theForm.email.value == "") {
    alert("Please enter a value for the \"Email\" field.");
    theForm.email.focus();
    return (false);
  }

  if (!isEmailAddr(theForm.email.value)) {
    alert("Please enter a complete email address in the form: yourname@yourdomain.com");
    theForm.email.focus();
    return (false);
  }
   
  if (theForm.email.value.length < 3) {
    alert("Please enter at least 3 characters in the \"Email\" field.");
    theForm.email.focus();
    return (false);
  }
  return (true);
}

/* Cookie generator */
function setCookie(NameOfCookie, value, expiredays, path, domain, secure)
{
//the first lines in the function converts the number of days to a valid date.

var ExpireDate = new Date();
ExpireDate.setTime(ExpireDate.getTime() + (expiredays*24*3600*1000));

//The next line stores the cookie, simple by assigning
//the values to the document.cookie-object
//Note the date is converted to Greenwich Meantime using
//the 'toGMTstring()'-function

document.cookie = NameOfCookie +"="+ escape(value) + 
((expiredays == null)? "": ";expires="+ ExpireDate.toGMTString()) +
((path == null)? "": (";path=" + path)) +
((domain == null) ? "" : (";domain=" + domein)) +
((secure == true) ?";secure":"");
}

function getCookie(NameOfCookie)
{
if(document.cookie.length > 0)
{
begin = document.cookie.indexOf(NameOfCookie+"=");
if(begin != -1)
{
// our cookie was set.
// The value stored in the cookie is returned from the function
begin += NameOfCookie.length + 1;
end = document.cookie.indexOf(";",begin);
if(end == -1) end = document.cookie.length;
return unescape(document.cookie.substring(begin,end));
}
}
return null;
// Our cookie was not set.
// The value "null" is returned from the function
}

function delCookie(NameOfCookie)
{
// The function simply checks if the cookie is set.
// If so expiredate is set to Jan. 1st 1970
if(getCookie(NameOfCookie)){
document.cookie = NameOfCookie +"=" +
";expires= Thu, 01-Jan-70 00:00:01 GMT";
}
}

// 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		
  }