//------------------------------------------------------------------------------
var isNS4 = ( document.layers ) ? true : false;
var isIE4 = ( document.all && !document.getElementById ) ? true : false;

function getControl( id ) 
{
   var control = null;
   try 
   {
      if ( isNS4 ) control = document.layers[id];
      else if ( isIE4 ) control = document.all[id];
      else control = document.getElementById(id);      
   }
   catch ( e ) 
   {
      control = null;
   }
   
   return control;
}
//------------------------------------------------------------------------------
function onloadEvent(scrollPos)
{
	var scrollableDivControl = getControl( "scrollableDiv" );
	if ( scrollableDivControl!=null && scrollPos!=0 ) 
	{
		scrollableDivControl.scrollTop=scrollPos;
	}
}

function paginationMouseOverEvent(id,imagesPath,lowerOrTopLinks)
{
	var postfix = '';
	if (lowerOrTopLinks=='L') postfix = 'L';
	var imageControl = getControl( 'pagination'+id+postfix );
	switch (id)
	{
		case "First":
		   imageControl.src=imagesPath+"firstHLT.gif"		   
		break;
		case "Previous":
		   imageControl.src=imagesPath+"previousHLT.gif"		   
		break;
		case "Next":
		   imageControl.src=imagesPath+"nextHLT.gif"		   
		break;
		case "Last":
		   imageControl.src=imagesPath+"lastHLT.gif"		   
		break;
	}	
}

function paginationMouseOutEvent(id,imagesPath,lowerOrTopLinks)
{
	var postfix = '';
	if (lowerOrTopLinks=='L') postfix = 'L';
	var imageControl = getControl( 'pagination'+id+postfix );
	switch (id)
	{
		case "First":
		   imageControl.src=imagesPath+"first.gif"		   
		break;
		case "Previous":
		   imageControl.src=imagesPath+"previous.gif"		   
		break;
		case "Next":
		   imageControl.src=imagesPath+"next.gif"		   
		break;
		case "Last":
		   imageControl.src=imagesPath+"last.gif"		   
		break;
	}	
}

function mouseoverEvent(id)
{
	changeVisibility(id,'visible');
	addScrollPosParmToURL(id);
}

function mouseoutEvent(id)
{
	changeVisibility(id,'hidden');
	removeScrollPosParmFromURL(id);
}

function changeVisibility(divID, display) 
{
	var div = getControl( 'category'+divID );	
	div.style.visibility=display;
	if ( display=="visible") div.style.display = "inline";
	else div.style.display = "none";
}

function addScrollPosParmToURL(id)
{
	 var hyperlink = getControl( "hyperlink"+id );	 
	 var hdnScrollPosControl = getControl( "hdnScrollPos" );
	 
	 //alert( hdnScrollPosControl.value );
	 if ( hdnScrollPosControl!=null )
	 {
	    if ( hdnScrollPosControl.value.length!='' && hdnScrollPosControl.value!='0')  
	    {	 
	       hyperlink.href = hyperlink.href + "&sp=" + hdnScrollPosControl.value   
	    }
	 }
}

function removeScrollPosParmFromURL(id)
{
	 var hyperlink = getControl( "hyperlink"+id );	 
	 var pos = hyperlink.href.lastIndexOf('&sp=');
	 if (pos>-1) hyperlink.href = hyperlink.href.substring(0,pos);
}

function saveScrollPos()
{
  var scrollableDivControl = getControl( "scrollableDiv" );
  var hdnScrollPosControl = getControl( "hdnScrollPos" );
  if ( scrollableDivControl!=null && hdnScrollPosControl!=null )
  {
     hdnScrollPosControl.value = scrollableDivControl.scrollTop;
  }
}