
// relógio e cronometro
var date = new Date();
var segundos = date.getSeconds();
var minutos = date.getMinutes();
var hora = date.getHours();
var min;
var sec;
function processTimer()
{
	//prepare output format
	sec = segundos;
	min = minutos;
	hor = hora;
	if (hora<10) {hor="0"+hor}
	if (segundos<10) {sec="0"+segundos}
	if (minutos<10) {min="0"+minutos}
	//render timer value
	if (document.all) {
		if (document.all('hora')) {
		document.all('hora').innerHTML=hor+":"+min+":"+sec+"";
		}
	} else if (document.getElementById) {
		if (document.getElementById('hora')) {
		document.getElementById('hora').innerHTML=hor+":"+min+":"+sec+"";
		}
	}
	//next second
	if (segundos==60) {
	minutos++;
	segundos = 0
	}
	if (minutos==60) {
	hora++;
	minutos = 0;
	}
	if (hora==24) {
	hora = 0;
	}
	segundos++
}

setInterval('processTimer()',1000);
	
	


	var popUpWin=0;
	function safeOpenWindow(URLStr)
	{
		var height;
		var width;
		var left ='';
		var top = '';
		var centermode = 1;
		
		height = 540;
		width  = 800;
		
		if ( screen.availHeight < height ) 
		{
			centermode = 0;
			height = screen.availHeight - 30;
		}	
		if ( screen.availWidth < width ) 
		{
			centermode = 0;
			width = screen.availWidth - 10;
		}	

		if ( !centermode )
		{
			left = 0;
			top = 0;
		}
		else
		{
			left = (screen.availWidth-10 - width) / 2;
			top = (screen.availHeight-20 - height) / 2;
		}
		
		if(popUpWin)
		{
			//if(!popUpWin.closed) popUpWin.close();
		}
		popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
	}	


function matchelement( k )
{
	var i, n, c;
	
	for (i=0; i<=document.forms(0).elements.length; i ++)
	{
		try
		{
			n = document.forms(0).elements(i).name;
			if (n.length >= k.length )
			{
				c = n.substr ( n.length - k.length, k.length );
				if ( c == k ) return document.forms(0).elements(i);
				
			}
		}
		catch (e) {}
	}
	
	return "undefined";
}


//changes application image
//obj = image object name or id
//imagefile = image file
function changeImage(obj, imagefile)
{
	if (ie4) 
	{
	    document.all(obj).scr=imagefile;
	} 
	else 
	{
	
    	obj.src=imagefile;
	    
	}
}

	

