function checkBrowser(funcNew, funcOld) {
	if (typeof document.body.style.maxHeight != "undefined") {
		return funcNew;
	} else {
		return funcOld;
	}
}

function hideSelects(){
	//checkBrowser();
	if (typeof document.body.style.maxHeight != "undefined") {
		
	} else {
		var elementSelect = document.getElementsByTagName("select");
	    for(var i = 0; i < elementSelect.length; i++) {
			elementSelect[i].style.visibility = "hidden";
		}
	}
}
function showSelects(){
	if (typeof document.body.style.maxHeight != "undefined") {
		
	} else {
		var elementSelect = document.getElementsByTagName("select");
	    for(var i = 0; i < elementSelect.length; i++) {
			elementSelect[i].style.visibility = "visible";
		}
	}
}
function hideAll(){
	hideSelects();
}
function showAll(){
	showSelects();
}
function hide(){
	hideSelects();
}
function show(){
	showSelects();
}


function wait() {
	$('wait').style.display = 'block';
}
function startWait() {
	$('wait').style.display = 'none';
}
function stopWait() {
	$('wait').style.display = 'none';
}


/** Função para log-off */
function Optar() {
	if (confirm("Deseja sair?")) {
		document.location = 'logoff.do';
	}
}

podeSubmeterVar = true;

function podeSubmeter() {
	if (podeSubmeterVar) {
		podeSubmeterVar = false;
		return true;
	} else {
		alert('Você não pode re-enviar seus dados, eles já estão sendo enviados.');
		return false;
	}
}

function submitForm(formul) {
	if (podeSubmeter())
		formul.submit();
}

// Relatórios
function executeReport(form, path) {
	form.submit();
	window.waitReportDone.delay(0.2, form.name, path);
	wait();
}

function waitReportDone(key, path) {
	new Ajax.Request(path + "/ajax_report_progress.do", {
		method: 'get',
		asynchronous: true,
		parameters: {
			reportId: key, 
			ts: new Date().getTimestamp()
		},
		onComplete: function(response) {
			stopWait();
		}
	});
}
// +++

Date.prototype.getTimestamp = function() {
	return 
		this.getFullYear() + "" +
		this.getMonth()+ "" +
		this.getDay() + "" + 
		this.getHours() + "" + 
		this.getMinutes() + "" + 
		this.getSeconds();
};

