function $(id) {
	return document.getElementById(id);
}
function addEvent(elm, evType, fn, useCapture) {
	if (elm.addEventListener) {
		elm.addEventListener(evType, fn, useCapture);
		return true;
	}
	else if (elm.attachEvent) {
		var r = elm.attachEvent('on' + evType, fn);
		return r;
	}
	else {
		elm['on' + evType] = fn;
	}
}
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	}
	else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}
function loadScript(src)
{
	var script = document.createElement('script');
	script.type = 'text/javascript';
	script.src = src;

	document.body.appendChild(script);
}

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 setCookie( name, value, expires, path, domain, secure ) {
	var today = new Date();
	today.setTime( today.getTime() );
	if ( expires ) {
		expires = expires * 1000;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	document.cookie = name+'='+escape( value ) +
		( ( expires ) ? ';expires='+expires_date.toGMTString() : '' ) +
		( ( path ) ? ';path=' + path : ';path=/' ) +
		( ( domain ) ? ';domain=' + domain : '' ) +
		( ( secure ) ? ';secure' : '' );
}

function deleteCookie( name, path, domain ) {
	if ( getCookie( name ) ) document.cookie = name + '=' +
			( ( path ) ? ';path=' + path : '') +
			( ( domain ) ? ';domain=' + domain : '' ) +
			';expires=Thu, 01-Jan-1970 00:00:01 GMT';
}

var core = {
	browser : {
		IE    : (document.all && !window.opera),
		Opera : (window.opera),
		FF    : (window.netscape && !window.opera)
	},
	show_bg : function (innerHTML) {
		var div = $('core_bgdiv');
		if(!div)
		{
			div = document.createElement('div');
			div.id = 'core_bgdiv';
			div.className = 'core_bgdiv';
			div = document.body.appendChild(div);
		}

		div.style.width = document.documentElement.scrollWidth+'px';
		div.style.height = document.documentElement.scrollHeight+'px';
		div.style.display = 'block';
		
		if(innerHTML)
		{
			var box = $('core_loadbox');
			if(!box)
			{
				box = document.createElement('div');
				box.id = 'core_loadbox';
				box.className = 'core_loadbox';
				box = document.body.appendChild(box);
			}
				
			box.innerHTML = innerHTML;
			box.style.display = 'block';

			box.style.top = document.documentElement.scrollTop+document.documentElement.clientHeight/2-box.clientHeight/2+'px';
			box.style.left =document.documentElement.scrollLeft+document.documentElement.clientWidth/2-box.clientWidth/2+'px';
			
			window.onscroll = function () {
				box.style.top = document.documentElement.scrollTop+document.documentElement.clientHeight/2-box.clientHeight/2+'px';
				box.style.left =document.documentElement.scrollLeft+document.documentElement.clientWidth/2-box.clientWidth/2+'px';
			};
		}
	},
	hide_bg : function () {
		if((div = $('core_bgdiv')))
		{
			div.style.display = 'none';
			var box = $('core_loadbox');
			if(box) box.style.display = 'none';
		}
	}
};