//window.onerror = erros;
window.onload = focar;

var W = function(lnk,w,h) {
	var aleat = "W" + parseInt(Math.random()*100000);
	var janela = window.open(lnk,aleat,"width="+w+",height="+h+",top="+(((screen.height-h)/2)-30)+",left="+((screen.width-w)/2)+",status=yes,scrollbars=yes,menubar=no,toolbar=no,titlebar=no,location=no,fullscreen=no,directories=no,resizable=yes");
	janela.focus();
}

var WM = function(lnk,w,h) { var modal = window.showModalDialog(lnk, "", "Resizable:yes; DialogHeight:" + h + "px; DialogWidth:" + w + "px; Edge:raised; Help:no; Scroll:yes; Status:no; Center:yes;"); }

var S = function(txt) { window.status = txt; }

var E = function(obj) { return document.getElementById(obj); }

var I = function(fr,it) { return document.forms[fr][it]; }

var L = function(lnk,alvo) { window.parent.frames[alvo].location.href = lnk; }

var R = function(alvo) { window.parent.frames[alvo].location.reload(); }

function focar() {
	if (document.forms.length>0) {
		try { I(0,0).focus(); } catch(e) {}
	}
}

var h = {
	classe: "",
	lastid: "",
	on: function(id) {
		this.classe = E(id).className;
		this.lastid = id;
		E(id).className = "MenuHover";
	},

	off: function() { E(this.lastid).className = this.classe; },

	v: function(id) { if (E(id).style.display==="none") { E(id).style.display = "" } else { E(id).style.display = "none" } }
}

var inText = {
	gett: function(id) {
		if (document.all) {	return E(id).innerText; }
		else { return E(id).textContent; }
	},
	
	putt: function(id,valor) {
		if (document.all) {	E(id).innerText = valor; }
		else { E(id).textContent = valor }
	}
}

var Ajuda = function(id) { W("gerAjuda.asp?contexto=" + escape(id),700,500); }

var oClock = function(formato){
	
	now = new Date();
	
	ds = new Date();
	DD = ds.getDay();
	MM = ds.getMonth();
	AA = ds.getYear();
	(DD<=9) ? DD = "0" + DD : "";
	(MM<=9) ? MM = "0" + MM : "";

	hs = new Date();
	hh = hs.getHours();
	mm = hs.getMinutes();
	ss = hs.getSeconds();
	(mm<=9) ? mm = "0" + mm : "";
	(ss<=9) ? ss = "0" + ss : "";
	
	//formato.replace("AAAA","AA");
	//alert(formato);
	//if (formato.search("AAAA")==-1) { 
	aa = AA.toString().substring(2,4);
	
	retorno = formato.replace(/DD/,DD).replace(/MM/,MM).replace(/AAAA/,AA).replace(/AA/,aa).replace(/hh/,hh).replace(/mm/,mm).replace(/ss/,ss);
	return retorno
	//return DD + "/" + MM + "/" + AA + " " + hh + ":" + mm + ":" + ss;
	//E("relogio").value = horas;
	//var temp = setTimeout( "oClock()", 500);
}

function erros(){
	alert("Ocorreu um erro de execução JavaScript. Isto pode fazer com que o sistema comporte-se de maneira irregular. Contate o administrador do FUTSite para informar o problema, informando também onde ele ocorreu.");
	return false;
}

