//onload=function(){
//document.getElementsByTagName('body')[0].onload=attachHandler;
//}

function attachHandler() {
	
	//adjustHeight();
	
	var navlist = document.getElementById('maintoplinks').getElementsByTagName('li');
	for( var i=0;i<navlist.length;i++)
	{
		navlist[i].onmouseover= function() { hoverNav(this); };
		navlist[i].onmouseout= function() { hoverNav(this); };
	}
	

}

function adjustHeight()
{
	var h1 = document.getElementById('sidebar').offsetHeight;
	var h2= document.getElementById('content').offsetHeight;
	if( parseInt(h1) > parseInt(h2) )
		document.getElementById('content').style.height = parseInt(h1)+'px';
}

function hoverNav(li)
{
	if(li.className.indexOf("hover")>=0 )
	{
		li.className = li.className.replace(new RegExp(" hover\\b"), "");
		// li.className = li.className.replace("hover","");
	}
	
	else if(li.className.indexOf("hover")==-1 )
	{
	   li.className += 'hover';
	}
}


function getElementsByClassName(className, tag, elm){
        var testClass = new RegExp("(^|\\\\s)" + className + "(\\\\s|$)");
        var tag = tag || "*";
        var elm = elm || document;
        var elements = (tag == "*" && elm.all)? elm.all : elm.getElementsByTagName(tag);
        var returnElements = [];
        var current;
        var length = elements.length;
        for(var i=0; i<length; i++){
               current = elements[i];
               if(testClass.test(current.className)){
                       returnElements.push(current);
               }
        }
        return returnElements;
}



function ToggleMenu(e,list)
{
	 citem = list.getElementsByTagName('a')[0];
	 
	 if(list.className=='open' )
	 {
	   
	   list.className = '';
	   citem.className='';
	      
	 }
	 else if(list.className=='' )
	 {
	   
	    var activechnls = getElementsByClassName("open" , "li", document.getElementById('nav')); 
		for(i=0;i<activechnls.length;i++)
		{
			activechnls[i].className='';
			activechnls[i].getElementsByTagName('a')[0].className=''
		}
		
		var activeitem = list.parentNode;
		var topparent  = document.getElementById('sidebarnav').getElementsByTagName('ul')[0];
		while (activeitem!= topparent)
		{
			activeitem.className='open';
			activeitem.getElementsByTagName('a')[0].className='on';
			activeitem = activeitem.parentNode;
		}
		
		list.className = 'open';
	 	citem.className='on';
		
		
	 }
	 
	 
	if( typeof( e ) == "undefined" && typeof( window.event ) != "undefined" ) 
	e = window.event;

	 // do things....

	if (typeof( window.event ) != "undefined" )
	{
		// IE
		e.cancelBubble=true;
		
	}
	else 
	{
		// Firefox
		e.stopPropagation();
	}
	
}
		  
		  
		 
		 
function openPrintWindow()
{

	newWin=window.open('carrier-branded-print-template.html','','height=600,width=800,toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes,resizable =yes'); 

}


function sort(item)
{
	if(item.getElementsByTagName('img')[0].src.indexOf('arrow_asc.gif')!=-1)
	{
		item.getElementsByTagName('img')[0].src = item.getElementsByTagName('img')[0].src.replace('_asc','_desc');	
		item.getElementsByTagName('img')[0].title = "sort descending";
		
	}
		

	else if(item.getElementsByTagName('img')[0].src.indexOf('arrow_desc.gif')!=-1)
	{
		item.getElementsByTagName('img')[0].src = item.getElementsByTagName('img')[0].src.replace('_desc','_asc');	
		item.getElementsByTagName('img')[0].title = "sort ascending";
	}

}
