﻿var timeout	= 500;
var closetimer	= 0;
var ddmenuitem	= 0;
String.prototype.stripHTML=function(){return this.replace(/<.*?>/g,'');}						

// open hidden layer
function mopen(id)
{	
	// cancel close timer
	mcancelclosetime();

	// close old layer
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';

	// get new layer and show it
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';

}
// close showed layer
function mclose()
{
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}

// go close timer
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

function addLoadEvent(func){ 
	var oldonload = window.onload; 
	if (typeof window.onload != 'function'){
		window.onload = func;
	} else {
		window.onload = function(){oldonload();func();}
	}
}
function open_helpwindow(link,name){
	window.open(link,name,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=no,width=540,height=410');
}		
function lightup(imgName){
	try
	{
		if (document.images){
			imgOn=eval(imgName+"on.src");
			document[imgName].src=imgOn;
		}		
	}
	catch(err)	{}
}
function turnoff(imgName){
	try
	{
		if (document.images){
			imgOff=eval(imgName+"off.src");
			document[imgName].src=imgOff;
		}		
	}
	catch(err)	{}
}
function setCookie( name, value, expires, path, domain, secure ) 
{
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );

	/*
	if the expires variable is set, make the correct 
	expires time, the current script below will set 
	it for x number of days, to make it for hours, 
	delete * 24, for minutes, delete * 60 * 24
	*/
	if ( expires )
	{
	expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );

	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
	( ( path ) ? ";path=" + path : "" ) + 
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
}
function getCookie( name ) 
{		
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) )
	{
		return null;
	}
	if ( start == -1 ) return null;
	var end = document.cookie.indexOf( ";", len );
	if ( end == -1 ) end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
}
function delCookie( name, path, domain ) {
	if ( getCookie( name )!=null) document.cookie = name + "=" +
	( ( path ) ? ";path=" + path : "") +
	( ( domain ) ? ";domain=" + domain : "" ) +
	";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}
function logout()
{
	delCookie('email','/','');
	delCookie('password','/','');	
}
function login_submit()
{
  if (document.login.savelogin.checked)
  {
		setCookie('email',document.login.email.value,14,'/','','');
		setCookie('password',document.login.password.value,14,'/','','');
	}
	else
	{
		logout();
	}	
	return true;
}
function chngColor(color) 
{
		if (!document.getElementsByTagName){ return; }
		var anchors = document.getElementsByTagName('td');

		for (var i=0; i<anchors.length; i++){
			var anchor = anchors[i];
			var className = String(anchor.className);
			if (className.toLowerCase().match('chng_color')){				
				anchor.style.background = color;
			}
		}
}

function divopenclose(id) {  
	d = document.getElementById(id);	
	if (d.style.display=="") {
		d.style.display = "none";    		
	} else {
		d.style.display = "";		
	}
}
function divopen(id){
  d = document.getElementById(id);
  d.style.display = ''; 	  
}
function divclose(id){
  d = document.getElementById(id);
  d.style.display = 'none';   
}

// preload
if (document.images){
	hlon=new Image(100,48);
	hlon.src="images/hl-logo-cl.png";
	hloff=new Image(100,48);
	hloff.src="images/hl-logo-bw.png";		
}
