function gebi(s){
	return document.getElementById(s);
}
function acessoriosDisplay(s){
	gebi(s).className = (gebi(s).className == "conjunto")?"conjunto-ativo":"conjunto";
}
function trocaURL(u){
	document.location = u;
}

// Função Popups: <a href="arquivo.ext" onclick="popups(this.href,'360','535','1'); return false;"></a>
function popups(pg,nome,fs,w,h,rolagem) {
	if(fs) { // fullscreen
		var w=screen.availWidth,h=screen.availHeight;
		var winObj = window.open(pg,nome,'width='+w+',height='+h+',directories=0,location=0,menubar=0,resizable=0,scrollbars='+rolagem+',status=0,toolbar=0,marginleft=0,margintop=0,left=0,top=0');
		with(winObj) { moveTo(0,0); resizeTo(w,h); focus(); }
	} else { // popup normal
		var winObj=window.open(pg,nome,'width='+w+',height='+h+',directories=0,location=0,menubar=0,resizable=0,scrollbars='+rolagem+',status=0,toolbar=0,marginleft=0,margintop=0,left='+(((screen.width-w)/2)+-10)+',top='+(((screen.height-h)/2)+-30));
		winObj.focus();
	}
}

function trocaLocEstado(campo1,campo2,txtcampo2){
	var camposel= document.getElementById(campo1).selectedIndex;
	var pick = document.getElementById(campo1).options[camposel].value;
	if (pick == "0"){
		document.getElementById(campo2).disabled = true;
		document.getElementById(txtcampo2).className = "inativo";
	}else{
		document.getElementById(campo2).disabled = false;
		document.getElementById(txtcampo2).className = "";
	}
}

function trocaLocEstado2(campo2,btncampos){
	if (campo2.options[campo2.selectedIndex].value == '0'){
		document.getElementById(btncampos+"on").style.display = "none";
		document.getElementById(btncampos+"off").style.display = "block";
	}else{
		document.getElementById(btncampos+"off").style.display = "none";
		document.getElementById(btncampos+"on").style.display = "block";
	}
}
function  hidebtns(campo,btn1,btn2){
	//alert(document.getElementById("btncontmodelos"));
	if(campo.options[campo.selectedIndex].value != '0'){

		document.getElementById("btncontmodelos").style.display = "block";
		document.getElementById("btnespecificacoes").style.display = "block";
	}else{
		document.getElementById("btncontmodelos").style.display = "none";
		document.getElementById("btnespecificacoes").style.display = "none";
		}
}
function mostratabela(tabela,linkativo){
	if ((document.getElementById(tabela).style.display == "") || (document.getElementById(tabela).style.display == "none")){
		document.getElementById(tabela).style.display = "block";
		document.getElementById(linkativo).className = "lnkescmodeloativo";
	}else{
		document.getElementById(tabela).style.display = "none";
	}
}

function mudadivcont(lnkativo,ativo){
	var as = document.getElementsByTagName('A');
	for(var no=0;no<as.length;no++){
		if(as[no].className=='lnkmod'){
			as[no].style.textDecoration = "underline";
			as[no].style.fontWeight = "normal";
		}
	}
	document.getElementById(lnkativo).style.textDecoration = "none";
	document.getElementById(lnkativo).style.fontWeight = "bold";
	
	var divs = document.getElementsByTagName('div');
	for(var no=0;no<divs.length;no++){
		if(divs[no].className=='dincont'){
			divs[no].style.display = "none";
		}	
	}
	document.getElementById(ativo).style.display = "block";
}

function trocabtn(btnon,btnoff){
		document.getElementById("btnverresumoon").style.display = "block";
		document.getElementById("btnverresumooff").style.display = "none";
}

function CommaFormatted(amount)
{
	// Always the value should be in fraction
	var delimiter = "."; // replace comma if desired
	if(isNaN(amount)) { return ''; }
	var minus = '';
	if(amount < 0) { minus = '-'; }
	amount = Math.abs(amount);
	var n = new String(amount);
	var a = [];
	while(n.length > 3)
	{
		var nn = n.substr(n.length-3);
		a.unshift(nn);
		n = n.substr(0,n.length-3);
	}

	if(n.length > 0) { a.unshift(n); }
	n = a.join(delimiter);
	//alert(n.length);
	var amt="R$";
	for (i=0;i<7-n.length;i++)
	{
		amt = amt + '&nbsp;';
	}
	amount = amt + n + ',00'; 
	amount = minus + amount;
	//alert(amount)
	//document.write(amount);
	return amount;

}