// JavaScript Document
function closediv(){
	
	document.getElementById('d1').style.display = 'none';
	document.test.src='img/blank.gif';
	document.getElementById('d2').style.display='none';
}

function opendiv(url,w,h,n){
	
	var str=document.test.src;
	if (str.match(url)){
		return false;
	}
	
	document.cov.style.opacity = 0;
	document.cov.style.filter = 'alpha(opacity=0)';
	document.cov.style.MozOpacity = 0;
	document.cov.height=document.body.scrollHeight;
	document.cov.width=document.body.scrollWidth;
	document.getElementById('d2').style.display='';
	hide();
	
	document.getElementById('d1').style.background = '#ffffff no-repeat center url(\'img/loading.gif\')';
	document.test.style.opacity = 0;
	document.test.style.filter = 'alpha(opacity=0)';
	document.test.style.MozOpacity = 0;
	
	
	dv=document.getElementById('d1');
	if (dv.firstChild.name!='test'){
		dv.removeChild(dv.firstChild);
	}
	if (n!=''){
		a=document.createElement('div');
		a.style.backgroundColor = '#ffffff';
		a.style.padding = '5px';
		a.innerHTML = '<a href="http://' + n + '" target="_blank">' + n + '</a>';
		dv.insertBefore(a, dv.firstChild);
	}
	
	document.getElementById('d1').style.display = '';
	
	document.test.src=url;
	document.test.width=w;
	document.test.height=h;
	
	var iWidth=w;
	var iHeight=h;
	var iRealWidth = iWidth ? iWidth : 800 ;
	var iRealHeight = iHeight ? iHeight : screen.height - 30 ;
	var iLeft = Math.round ((screen.width - iRealWidth) / 2)-23;
	var iTop =  Math.round ((screen.height - iRealHeight) / 2) - 80 ;
	document.getElementById('d1').style.left= iLeft ;	
  
	if(document.all) {
		document.getElementById('d1').style.top= iTop + document.body.scrollTop;
	}
	else if(document.getElementById) {
		document.getElementById('d1').style.top= iTop + window.pageYOffset;
	}
}

function initAppear(){
	for (var i=0;i<11;i++){
		setTimeout('setOpacity('+i+')',35*i);
	}
	document.getElementById('d1').style.background = '#000000';
	return false;
}

function setOpacity(value){
	document.test.style.opacity = value/10;
	document.test.style.filter = 'alpha(opacity=' + value*10 + ')';
	document.test.style.MozOpacity = value/10;
}

function hide(){
	for (var i=0;i<4;i=i+0.1)
		setTimeout('setOpacity2('+i+')',100*i);
}

function setOpacity2(value){
	document.cov.style.opacity = value/10;
	document.cov.style.filter = 'alpha(opacity=' + value*10 + ')';
	document.cov.style.MozOpacity = value/10;
}