
sfHover = function() {
	var sfEls = document.getElementById("nav1").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}	
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

matchColumns=function(className){ 

     var divs,contDivs,maxHeight,divHeight,d; 
	
     // get all <div> elements in the document      
     divs=document.getElementsByTagName("div"); 

     contDivs=[]; 

     // initialize maximum height value 
     maxHeight=0; 

     // iterate over all <div> elements in the document 
     for(var i=0;i<divs.length;i++){ 

          // make collection with <div> elements with class attribute 'container' 
          if(/\bcolumn\b/.test(divs[i].className)){ 

                d=divs[i]; 
                contDivs[contDivs.length]=d; 
                // determine height for <div> element 
                if(d.offsetHeight){ 
                     divHeight=d.offsetHeight; 					
                } 
                else if(d.style.pixelHeight){ 
                     divHeight=d.style.pixelHeight;					 
                } 

                // calculate maximum height 
                maxHeight=Math.max(maxHeight,divHeight); 
          } 
     } 

     // assign maximum height value to all of container <div> elements 
     for(var i=0;i<contDivs.length;i++){
     	var height = maxHeight; 
     	/*if( i == 1 )
     		height -= 10;*/
          contDivs[i].style.height=height + "px"; 
     } 
} 

// Runs the script when page loads 
window.onload=function(){ 
     if(document.getElementsByTagName){ 
          matchColumns();			 
     } 
} 

function displayAddress( strName, strServer )
{
  var e=strName;
  e+= '@';
  e+= strServer;
  
  document.write( e );
}

function protectMail( strName, strServer, strDisplay)
{
  var e=strName;
  e+= '@';
  e+= strServer;
  if( strDisplay == null || strDisplay == undefined )
  	strDisplay = e;
  
  document.write( '<A href="mailto:' + e + '">' + strDisplay + '</a>');  	 	
}

function checkEmail(form) {
	if (form.email.value != form.confirmemail.value || form.email.value == '') {
		alert("Email addresses did not match.")
		return false;
	}
}

function processForm(formName)
{
	var form = document[formName];	
	if( form.onsubmit == undefined || form.onsubmit == null ){}
	else
	{
		if( form.onsubmit() == false )
			return( false );
	}
	
	return( form.submit() );
}

function createArticleTree()
{
	createArticleTreeMenu("nav3");
	createArticleTreeMenu("nav3a");
}

function createArticleTreeMenu(id)
{
	var links = document.getElementById(id).getElementsByTagName('a');
	for( var i=0; i<links.length; i++)
	{			
		var page = links[i].innerHTML.replace(/ /g,"_").toLowerCase();
		page = page.replace(/\?/g,"");
		page = page.replace(/\,/g,"");
		page = page.replace(/\'/g,"");
		page = page.replace(/\+/g,"");
		page = page.replace(/\./g,"");
		page = page.replace(/\(/g,"");
		page = page.replace(/\)/g,"");
		
		var href = location.pathname+"?article="+page; 
		if( links[i].parentNode.parentNode.parentNode.nodeName.toLowerCase() == "li" ) // is it an article
		{		
			links[i].onmouseover = (function(href){return function(){this.href=href;}})(href); // preserve with block scoping
			links[i].onclick = (function(href){return function(){window.location=href;}})(href); // preserve with block scoping
		}
		else // its a category
		{
			links[i].onmouseover = (function(href,page){return function(){this.href=page;}})(href,page); // preserve with block scoping
			links[i].onclick = function() 
			{ 
				ar = this.parentNode.parentNode.getElementsByTagName('ul'); //hide open level
				for(var k=0;k<ar.length;k++) ar[k].style.display="none"; 
					
				var ul = this.parentNode.getElementsByTagName('ul');
				if( ul.length > 0 ) ul[0].style.display='block';
				
				ar = this.parentNode.parentNode.getElementsByTagName('ul');
				document.getElementById("debug").innerHTML="";		
				return false;			
			};
		}				
	}		
}

function addToOnLoad( func )
{
	var onLoad = window.onload;
	window.onload = function() { onLoad(); func() };
}


/**
* Function : dump()
* Arguments: The data - array,hash(associative array),object
*    The level - OPTIONAL
* Returns  : The textual representation of the array.
* This function was inspired by the print_r function of PHP.
* This will accept some data as the argument and return a
* text that will be a more readable version of the
* array/hash/object that is given.
*/
function dump(arr,level) {
var dumped_text = "";
if(!level) level = 0;

//The padding given at the beginning of the line.
var level_padding = "";
for(var j=0;j<level+1;j++) level_padding += "    ";

if(typeof(arr) == 'object') { //Array/Hashes/Objects
 for(var item in arr) {
  var value = arr[item];
 
  if(typeof(value) == 'object') { //If it is an array,
   dumped_text += level_padding + "'" + item + "' ...<br/>\n";
   dumped_text += dump(value,level+1);
  } else {
   dumped_text += level_padding + "'" + item + "' => \"" + value + "\"<br/>\n";
  }
 }
} else { //Stings/Chars/Numbers etc.
 dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
}
	


return dumped_text;
} 





