var timerID = 0;

function showHideTimeElm(elm)
{
	//alert("Hide update = " + elm);
	document.getElementById(elm).style.display = 'none';
	//document.getElementById(elm).style.background='transparent';
	//alert('Class' + document.getElementById(elm).className);
	//document.getElementById(elm).className = "";
}

function TimerDone(elm) {
	//alert("Timer Done = " + elm);
	showHideTimeElm(elm);
}

function startTimer(seconds, elm)
{
	//alert("Start timer for " + seconds);
	timerID = setTimeout("TimerDone('" + elm + "')", seconds * 60 * 1000);
//	timerID = setTimeout("TimerDone('" + elm + "')", 1000);
}

function timeTest(day, month, year, hour, minute, elm) {
	var today = new Date();
	var dateSet = new Date(year, month, day, hour, minute, 0);
	var dateCorrection = new Date();
	
	dateCorrection = Math.floor(today - dateSet);
		
	//alert(today);
	//alert(dateSet);
	//alert(dateCorrection);
	
	var second = dateCorrection / 1000;
	//alert(second);
	var minutes = second / 60;
	//alert(minutes);
	if(minutes > 0)
	{
		var rest_minutes = Math.floor(60 - minutes);
		//alert(rest_minutes);
		if(rest_minutes < 0)
			showHideTimeElm(elm);
		else
			startTimer(rest_minutes, elm);
	}
	else
		showHideTimeElm(elm);
}

function newWindowAttach(url, size, x, y) {		
		var properties = "";
		properties += ",location=no";		
		properties += ",menubar=0";	
		properties += ",toolbar=no";
		properties += ",directories=no";		
		if(size)
		{
			properties += ",status=no";
			properties += ",scrollbars=no";
			properties += ",resizable=no";
			properties += ",top=150";
			properties += ",left=660";
			properties += ",width=" + x;
			properties += ",height=" + y;
		}
		else
		{
			properties += ",resizable=yes";
			properties += ",status=yes";
		}
			
    	var w = window.open(url, 'Article', properties);
    	w.focus();
}

function openExtWindow(url, popup_type, size_x, size_y)
{
	//alert("Start window:" + url + "/" + popup_type);
	if(popup_type == 'popup_same')
		location.href = url;
	else if(popup_type == 'popup_size')
		newWindowAttach(url, true, size_x, size_y);
	else if(popup_type == 'popup_new')
		newWindowAttach(url, false, 0, 0);
	else
		location.href = url;
}

//timeTest(4, 9, 2006, 16, 30, 'article330_time');
//showHideTimeElm('article330_time');

function openDiashowPopup(url, type) {
	//alert('URL:' + url + ", Type:" + type);
	if(type == 'edp')
		newWindowAttach(url, true, 740, 650);
	else
		newWindowAttach(url, true, 740, 550);
}

function openExtWindowInPopup(url, size_x, size_y, proc)
{
	var screenW = 640, screenH = 480;
	if (parseInt(navigator.appVersion)>3) {
		screenW = screen.width;
		screenH = screen.height;
	}
	else if (navigator.appName == "Netscape" 
	    && parseInt(navigator.appVersion)==3
	    && navigator.javaEnabled()
	   ) 
	{
		var jToolkit = java.awt.Toolkit.getDefaultToolkit();
		var jScreenSize = jToolkit.getScreenSize();
		screenW = jScreenSize.width;
		screenH = jScreenSize.height;
	}
	
	//var screenW = window.innerWidth;
	//var screenH = window.innerHeight;
	
	//alert("Screen width = "+screenW+"<br>"	+"Screen height = "+screenH);
	var popupX = Math.round(screenW / 100 * proc);
	var popupY = Math.round(screenH / 100 * proc);
	size_x = popupX;
	size_y = popupY;
	posX = Math.round((screenW  - size_x) / 2);
	posY = Math.round((screenH  - size_y) / 2);
	//alert("Window = "+posX+","+posY+" - "+size_x+","+size_y);
	
	var properties = "";
	properties += "location=no";		
	properties += ",menubar=0";	
	properties += ",toolbar=no";
	properties += ",directories=no";		
	properties += ",scrollbars=no";
	properties += ",top=" + posY;
	properties += ",left=" + posX;
	properties += ",width=" + size_x;
	properties += ",height=" + size_y;
	properties += ",resizable=yes";
	properties += ",status=yes";
		
	//alert("P=" + properties);
   	var w = window.open(url, 'Article', properties);
   	w.focus();
   	
   	return false;	
}

