var timer1;
function get_div_opacity(elem)
{
	if (elem.filters && elem.filters[0]) //IE syntax
	{
		if (typeof elem.filters[0].opacity=="number") //IE6
			return elem.filters[0].opacity/100;
		else //IE 5.5
			return 0;
	}
	else
	if (typeof elem.style.MozOpacity!="undefined") //Old Mozilla syntax
		return elem.style.MozOpacity
	else
	if (typeof elem.style.opacity!="undefined") //Standard opacity syntax
		return elem.style.opacity;
	return 0;
}

function set_div_opacity(elem,value)
{
	if (elem.filters && elem.filters[0]) //IE syntax
	{
		if (typeof elem.filters[0].opacity=="number") //IE6
			elem.filters[0].opacity=value*100
		else //IE 5.5
			elem.style.filter="alpha(opacity="+value*100+")"
	}
	else
	if (typeof elem.style.MozOpacity!="undefined") //Old Mozilla syntax
		elem.style.MozOpacity=value
	else
	if (typeof elem.style.opacity!="undefined") //Standard opacity syntax
		elem.style.opacity=value
	else //Non of the above, stop opacity animation
		this.stopanimation()
}

function fade_animation(elem,opacity)
{
	set_div_opacity(elem,opacity);
	if(opacity<0.5)
		timer1=setTimeout(function() {fade_animation(elem, (opacity+0.02))},1);
	else
		timer1=null;
}

function popupdiv(name)
{
var wwidth=(window.innerWidth)?window.innerWidth:
    ((document.all)?document.body.offsetWidth:null);
var wheight=(window.innerHeight)?window.innerHeight:
    ((document.all)?document.body.offsetHeight:null);

var fullheight=(document.body.scrollHeight > document.body.offsetHeight)?document.body.scrollHeight:document.body.offsetHeight;
var scrolltop=self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop);
	var el=document.getElementById(name);
	if(el)
	{
		el.style['left']=(wwidth-parseInt(el.style['width']))/2;
		el.style['top']=(wheight-parseInt(el.clientHeight))/2+scrolltop;
		el.style['visibility']='visible';
		var el=document.getElementById('block_fade');
		if(el)
		{
			el.style['display']='';
			el.style['height']=parseInt(fullheight);
			var op=get_div_opacity(el);
			if(op=='') op=0;
			fade_animation(el,op);
		}
		var el=document.getElementById('main_body');
		if(el)
		{
			el.style['overflow']='visible';
		}
	}
	var el=document.getElementById('block_fade');
	if(el)
	{
		el.onclick=function (){bodyclick(name);};
	}
}

function bodyclick(name)
{
	if(timer1!=null) clearTimeout(timer1);
	var el=document.getElementById(name);
	if(el)
	{
		el.style['visibility']='hidden';
		
		var el=document.getElementById('block_fade');
		if(el)
		{
			el.style['display']='none';
		}
		var el=document.getElementById('main_body');
		if(el)
		{
			el.style['overflow']='';
		}
	}
}
