// JavaScript Document

/**
* Submit the admin form
*/
function submitform(pressbutton){
	document.adminForm.task.value=pressbutton;
	if (typeof document.adminForm.onsubmit == "function") {
		document.adminForm.onsubmit();
	}
	document.adminForm.submit();
}

function writeEmail( name, domain ) {
	var mail = name + "&#064;" + domain;
	document.write( '<a href="#" onclick="javascript:window.location=\'&#109;&#097;&#105;&#108;&#116;&#111;:' + mail + '\'">' + mail + '</a>' );
}

var allChecked = false;
/**
 * Marca todas a checkboxes 'cid[]'
 */
function checkAll() {
	var inputs = document.getElementsByName('cid[]');
	allChecked = !allChecked;
	for (var i=0; i < inputs.length; i++) {
		inputs[i].checked = allChecked;
	}
	return false;
}


/**
 * Alterna cores das linhas em uma tabela
 */
function alterCellsColor(tag_id) {
	var rows = document.getElementById(tag_id).tBodies[0].rows;
		for (x in rows) {
			if((x%2) == 0) {
				rows[x].className = "dif";
			}
		}
}

/**
 * Javascript-EAI do BlaxxunContact3D
 * setNodeEventIn() - Set the value for the specified eventIn of the named node converting  value to the type of the eventIn
 * getNodeEventOut() - Returns the value of the eventOut converted to a string
 *
 * @function setNodeEventIn  (String nodeName, String eventInName, String value)
 * @function getNodeEventOut (String nodeName, String eventOutName)
 *
 */
 
 function lastmod(){
		var data, mes, dia, ano;
		data = new String(document.lastModified);
		mes = data.substr(0, 2);
		dia = data.substr(3, 2);
		ano = data.substr(8, 2);
		return "Atualizado em " + dia + "/" + mes + "/" + ano;
		}
		
function getCurrentDate() {
	var d = new Date();
	var str = d.getFullYear() + "-" + (d.getMonth() + 1)  + "-" + d.getDate();
	return str;
}
function assignDate(id) {
	document.getElementById(id).value=getCurrentDate();
}

/**
 * Abre janela
 */
function open_win(nome){
		var h = screen.availHeight - 140;
		var v = screen.availWidth - 20;
		eval('window.open(\"' + nome + '\", \"\",\"width=' + v + ',height=' + h + ',top=0,left=0,resizable=yes,location=yes,menubar=yes,status=yes,directories=yes,titlebar=yes,toolbar=yes\");');
		}
		
/**
 * Identifica o navegador web
 */
function detectBrowser(){
	var navi;
	var browser=navigator.appName;
	var b_version=navigator.appVersion;
	var version=parseFloat(b_version);
	if (browser=="Microsoft Internet Explorer") {
		navi = "IE";
	} else if (browser=="Netscape")	{
		navi = "NS";
	} else {
		navi = "ND"; // Undefined
	}
	return navi;
}

function setIframeHeight(h) {
	var pTag1 = document.getElementById('main');
	var navi = detectBrowser();
	var h = h;
	
	if ( navi != "IE" ) {
		
		h_nieh = screen.availHeight - 240;
		h_default = 500;
		h_max = Math.max( h_nieh, h_default);
		
		if ( h < h_max ) {
			h = h_max;
		}
		
		pTag1.scrolling="yes";
		if ( document.getElementById("top") ) {
			document.getElementById("top").style.display = "none";
		}
		
	} else {
		pTag1.scrolling="no";		
	}
	pTag1.setAttribute('height', h);
	window.scrollTo(0,0);
}

function setIframeHeightNoScroll(h) {
	var pTag1 = document.getElementById('main');
	var navi = detectBrowser();
	var h = h;
	
	if ( navi != "IE" ) {
		
		h_nieh = screen.availHeight - 240;
		h_default = 500;
		h_max = Math.max( h_nieh, h_default);
		
		if ( h < h_max ) {
			h = h_max;
		}

		pTag1.scrolling="yes";
	} 
	pTag1.setAttribute('height', h);	
}