if(window.attachEvent)
	window.attachEvent("onload",LoadPage);
else if(window.addEventListener)
	window.addEventListener("load",LoadPage,false);
else
	onload = function() { LoadPage() };
function LoadPage(){
MENUGOD("topnav");
MENUGOD("awt-leftside");
MENUGOD("awt-topNav-links");
MENUGOD("awt-topNav-search");
stripe ('tbstriped');
stripe ('tbstriped2');
stripe ('tbstriped3');
}

//for IE 5 thank you Microsoft for making us code more.  we love ya!!
function Array_shift() {
  var A_s = 0
  var response = this[0]
  for (A_s = 0; A_s < this.length-1; A_s++) {
   this[A_s] = this[A_s + 1]
   }
  this.length--
  return response
  }
 
if (typeof Array.prototype.shift == "undefined") {
  Array.prototype.shift = Array_shift
  }
  
function Array_push() {
  var A_p = 0
  for (A_p = 0; A_p < arguments.length; A_p++) {
   this[this.length] = arguments[A_p]
   }
  return this.length
  }

if (typeof Array.prototype.push == "undefined") {
  Array.prototype.push = Array_push
  }
  
function Array_pop() {
  var response = this[this.length - 1]
  this.length--
  return response
  }

if (typeof(Array.prototype.pop) == "undefined") {
  Array.prototype.pop = Array_pop
  }
  
function Array_splice(index, delTotal) {
  var temp = new Array()
  var response = new Array()
  var A_s = 0
  for (A_s = 0; A_s < index; A_s++) {
   temp[temp.length] = this[A_s]
   }
  for (A_s = 2; A_s < arguments.length; A_s++) {
   temp[temp.length] = arguments[A_s]
   }
  for (A_s = index + delTotal; A_s < this.length; A_s++) {
   temp[temp.length] = this[A_s]
   }
  for (A_s = 0; A_s < delTotal; A_s++) {
   response[A_s] = this[index + A_s]
   }
  this.length = 0
  for (A_s = 0; A_s < temp.length; A_s++) {
   this[this.length] = temp[A_s]
   }
  return response
  }

if (typeof Array.prototype.splice == "undefined") {
  Array.prototype.splice = Array_splice
  }
  
  
function Array_unshift() {
  var A_u = 0
  for (A_u = this.length-1; A_u >= 0; A_u--) {
   this[A_u + arguments.length] = this[A_u]
   }
  for (A_u = 0; A_u < arguments.length; A_u++) {
   this[A_u] = arguments[A_u]
   }
  return this.length
  }

if (typeof Array.prototype.unshift == "undefined") {
  Array.prototype.unshift = Array_unshift
  }      
  
//for IE 5 thank you Microsoft for making us code more.  we love ya!!
  

function array_search(recordSet,key){
var found=0;
var regx=new RegExp('^'+key,'i');
 for (i=0;i<recordSet.length;i++){
   if (regx.test(recordSet[i])) return(1);
   }
    return(0);
} 

function MENUGOD(id){

var URL=window.location.href.split("/");

if(!/\/$/.exec(window.location.href)) URL[URL.length-1] = "";
else if(URL[URL.length-1] != "") URL[URL.length] = "";

var base = URL.join("/");
	
if(!/\/$/.exec(base))
	base = base+"/";
	
var curpath = window.location.pathname;
var completepath = window.location.protocol+"//"   + window.location.host  + window.location.pathname;
var content = "";
URL=window.location.href;


if (document.getElementById && document.getElementById(id)) content = document.getElementById(id).innerHTML;
	else if (document.all && document.all[id]) content = document.all[id].innerHTML;
	else if (document.layers && document.layers[id]) content = document.layers[id];
	else return;


if(document.getElementsByTagName("base")[0]){
	basex = document.getElementsByTagName("base")[0].href;		
		if(!/\/$/.exec(basex))
			basex = basex+"/"
	}else{
	basex = base;
	}

	content = bulk_make_abs(content, basex);


	if(!content) return;
//if the url ends with /
if(/\/$/.exec(URL)){
	//try to find default
	if(content.indexOf(base+"index.html") > 0) URL = base+"index.html";
	else if(content.indexOf(base+"index.htm") > 0) URL = base+"index.htm";
	else if(content.indexOf(base+"index.shtml") > 0) URL = base+"index.shtml";
	else if(content.indexOf(base+"default.html") > 0) URL = base+"default.html";
	else if(content.indexOf(base+"default.htm") > 0) URL = base+"default.htm";
	else if(content.indexOf(base+"homepage.htm1") > 0) URL = base+"homepage.html";
	else if(content.indexOf(base+"homepage.htm") > 0) URL = base+"homepage.htm";
	else URL = base;
	
}

//index.html default with a /
if(/index\.html$/.exec(URL)){
	if(content.indexOf(base+"index.html") > 0) URL = URL;
		else URL = base;
}

//index.htm default with a /
if(/index\.htm$/.exec(URL)){
	if(content.indexOf(base+"index.htm") > 0) URL = URL;
		else URL = base;
}

//index.shtm default with a /
if(/index\.shtml$/.exec(URL)){
	if(content.indexOf(base+"index.shtml") > 0) URL = URL;
		else URL = base;
}

//default.html default with a /
if(/default\.html$/.exec(URL)){
	if(content.indexOf(base+"default.html") > 0) URL = URL;
		else URL = base;
}

//default.htm default with a /
if(/default\.htm$/.exec(URL)){
	if(content.indexOf(base+"default.htm") > 0) URL = URL;
		else URL = base;
}

//homepage.html default with a /
if(/homepage\.html$/.exec(URL)){
	if(content.indexOf(base+"homepage.html") > 0) URL = URL;
		else URL = base;
	
}


//homepage.htm default with a /
if(/homepage\.htm$/.exec(URL)){
	if(content.indexOf(base+"homepage.htm") > 0) URL = URL;
		else URL = base;
}

	origURL = URL;
	if(origURL == "")
		origURL = curpath+'"';	
		
	origURL = origURL.replace(/\//g, '\\\/');

/*********** PREPARE URL ARRAY  ************/	
	URLS = new Array();
	
	//remove of nl space  (white space)
	tempcontent = content;
	tempcontent = tempcontent.replace(/\r\n/g, '');
	tempcontent = tempcontent.replace(/\s/g, '');
	//curpath = curpath.replace(/\//g, '\\\/');
	//completepath = completepath.replace(/\//g, '\\\/');
	
	//now go through tempcontent and look for instances of </a><ul> //case sensitive for SAFARI
//</a><ul>  means there is a parent menu that needs hilights
	index = tempcontent.search(/<\/A><UL>/ig);

	cnt=1;
		//while found
	 while (index != -1) {
	  cnt++;
  if(cnt > 100)  break;
  
    curcontent = tempcontent.slice(0,index+8);
  	tempcontent = tempcontent.slice(index+8,tempcontent.length);	
	curURLS = curcontent.split(/<Ahref="/ig);
	theURL = curURLS[curURLS.length-1].slice(0,curURLS[curURLS.length-1].indexOf('"'));

if(theURL != ""){
		theURL = theURL.replace(/\//g, '\\\/');
		if(!array_search(URLS,theURL)) URLS.push(theURL);
 }
  index = tempcontent.search(/<\/A><UL>/ig);
	}


	if(!array_search(URLS,origURL))
		URLS.push(origURL);
		
		URLS.reverse();

/*********** PREPARE URL ARRAY  ************/

/************* Create Content ****************/
 var arraycnt = URLS.length-1;
 index = eval("content.search(/"+URLS[arraycnt]+"\"/ig)");
 var newcontent = "";
 cnt=1;

  while (index != -1 && arraycnt >=0) {
  cnt++;
  if(cnt > 100)  break;
URLS[arraycnt] = URLS[arraycnt].replace(/\\\//g, '\/');
	
newcontent += content.slice(0,parseInt(index)+parseInt(URLS[arraycnt].length)+1) + 'class="on" ';
content = content.slice(parseInt(index)+parseInt(URLS[arraycnt].length)+1,content.length);  	arraycnt--;
    index = eval("content.search(/"+URLS[arraycnt]+"/ig)");
	// start search after last match found 
	}
	 newcontent += content;
 newcontent = newcontent.replace(/"\s"/g, '"');	 	 
/************* Create Content ****************/

/************* Write Content ****************/

if (document.getElementById)	document.getElementById(id).innerHTML = newcontent;
	else if (document.all)	document.all[id].innerHTML = newcontent;
	else if (document.layers)
	{
		document.layers[id].document.open();
		document.layers[id].document.write(newcontent);
		document.layers[id].document.close();
	}	
/************* Write Content ****************/	
}	
	
	
	
	
function bulk_make_abs(content, base) {
 cnt=0;
// alert(content);
//regs = content.match(/href="([^"]+)"/gi);
 regs = content.match(/href=(("[^"]+)|([^>]+))/gi);
if(!regs) return;
for(x=0;x<regs.length;x++){
 cnt++;
 if(cnt > 50) break;
  input_uri = regs[x].replace(/href=/g,"");
  input_uri = input_uri.replace(/"/g,"");
	//return;
//  input_uri = regs[x].split(/href="?"/gi);
//  if(input_uri[1])  input_uri = input_uri[1];

  if(input_uri == "#") continue;

  output_uri = make_abs(input_uri, base);
  input_uri = regs[x];
  output_uri = 'href="'+output_uri+'"';
  input_uri = input_uri.replace(/\//g,"\\\/");
  output_uri = output_uri.replace(/\//g,"\\\/");
content = eval("content.replace(/"+input_uri+"/,'"+output_uri+"')");
 }
 return(content);
} 


function make_abs(rel_uri, base) { 

//if(/^http:/.exec(rel_uri) || /^https:/.exec(rel_uri) || /^ftp:/.exec(rel_uri))	 return rel_uri;
if(/^([^:]+:\/\/)/.exec(rel_uri))	 return rel_uri;

var m = /^([^:]+:\/\/[^\/]+)\//i.exec(base);
base_start = m[1];
if(/^\//.exec(rel_uri))	 return base_start + rel_uri;

base = base.replace(/{[^\/]+$}/,'');
base += rel_uri;

//base = base.replace(/{^[^:]+:\/\/[^\/]+}/,'');
temp = m[1].replace(/\//g ,'\\\/');
base = eval("base.replace(/"+temp+"/,'')");
base_array = base.split('/'); 

if (base_array.length && !base_array[0].length)   base_array.shift(); 
i = 1; 
while (i < base_array.length) { 
  if (base_array[i - 1] == ".") { 
  base_array.splice(i - 1, 1);
   if (i > 1) i--; 
  } else if (base_array[i] == ".." && base_array[i - 1]!= "..") { 
   base_array.splice(i - 1, 2);
   if (i > 1) { 
i--; 
if (i == base_array.length) base_array.push("");
   } 
  } else { 
   i++; 
  } 
 } 
 if (base_array.length && base_array[-1] == ".") 
  base_array[-1] = ""; 
  while (base_array.length && /^\.\.?$/.exec(base_array[0]) ){ 
   base_array.shift();
  } 
  return(base_start + '/' + base_array.join('/') );
}


function stripe(id) {
if (document.getElementById && document.getElementById(id)) 
	table = document.getElementById(id);
	else if (document.all && document.all[id]) table = document.all[id];
	else if (document.layers && document.layers[id]) table = document.layers[id];
	else return;
     if (!table) return;
     var trs = table.getElementsByTagName("tr");
     for (var i = 0; i < trs.length; i += 2) 
       trs[i].className += " even";
   }
