window.$=function(id)
{
	return document.getElementById(id);
}

function openWindow(link, id, w, h)
{
	window.open(link, id, 'HEIGHT='+h+',resizable=no,scrollbars=yes,WIDTH='+w);
}

function getEvent(e)
{
	return window.event ? window.event : e;
}

function getTarget(e)
{
	return window.event ? window.event.srcElement : e.currentTarget;
}

function getEvent(e)
{
	return window.event ? window.event : e;
}

function show(id)
{
	var el=id;
	if (typeof id=='string')	el=$(id);
	
	if (el.tagName.toLowerCase()=='span')	el.style.display='inline';
	else	el.style.display='block';
}

function hide(id)
{
	var el=id;
	if (typeof id=='string')	el=$(id);
	
	el.style.display='none';
}

function toggle(id)
{
	var el=id;
	if (typeof id=='string')	el=$(id);

	if (el.offsetWidth)	hide(el);
	else	show(el);
}

function preloadImage(url)
{
	var pre;
	
	if (typeof url=='object')
	{
		for (var i=0; i<url.length; i++)
		{
			pre=new Image();
			pre.src=url[i];
			if (this.imgs)	this.imgs.push(pre);
			else	this.imgs=[];
		}
	}
	else
	{
		pre=new Image();
		pre.src=url;
		if (this.imgs)	this.imgs.push(pre);
		else	this.imgs=[];
	}
}

function offGalleryImg()
{
	var isIE=navigator.appName=='Microsoft Internet Explorer' && navigator.userAgent.indexOf('Opera') < 1 ? 1 : 0;
	if (isIE) isIE=document.namespaces ? 1 : 0;
	
	if (isIE)
	{
		var imgs=document.getElementsByTagName('img');
		if (imgs && imgs.length)	for (var i=0; i<imgs.length; i++)	imgs[i].galleryImg='no';
	}
}

function preloadImages(urls)
{
	preloadImage(urls);
}

function existsClass(id, clname)
{
	var el=id;
	if (typeof id=='string')	el=$(id);
	
	var cl=el.className;
	
	var reg=new RegExp('(^| )'+clname+'( |$)', 'gi');
	
	if (reg.test(cl))	return true;
	else	return false;	
}

function addClass(id, clname)
{
	var el=id;
	if (typeof id=='string')	el=$(id);
	
	if(!existsClass(el, clname))
	{
		var cl=el.className;
		var sp=' ';
		if (cl=='')	sp='';
		
		el.className+=sp+clname;
	}
}

function delClass(id, clname)
{
	var el=id;
	if (typeof id=='string')	el=$(id);
	
	if(existsClass(el, clname))
	{
		var cl=el.className;
		
		var reg=new RegExp('(^| )'+clname+'( |$)', 'gi');
		cl=cl.replace(reg, '$1');
		cl=cl.replace(/  /, ' ');
		if (cl==' ')	cl='';
		
		el.className=cl;
	}
}

function getTop(id)
{
	var el=id;
	if (typeof id=='string')	el=$(id);

	var il=0;

	while(el.tagName!='BODY' && el.tagName!='HTML')
	{
		il+=el.offsetTop;
		el=el.offsetParent;
	}
	il+=el.offsetTop;
	
	return il;
}

function getLeft(id)
{
	var el=id;
	if (typeof id=='string')	el=$(id);

	var il=0;

	while(el.tagName!='BODY' && el.tagName!='HTML')
	{
		il+=el.offsetLeft;
		el=el.offsetParent;
	}
	il+=el.offsetLeft;

	return il;
}

function setOpacity(id, value)
{
	var el=id;
	if (typeof id=='string')	el=$(id);
	
	el.style.filter='alpha(opacity='+value+')';
	el.style.opacity=value/100;
}