function init(){
	
	/**sub_madeira**/
	document.getElementById("btMad").onmouseover = function(){document.getElementById("sub_mad").style.display = 'block';}; 
	document.getElementById("btMad").onmouseout = function(){document.getElementById("sub_mad").style.display = 'none';}; 
	document.getElementById("sub_mad").onmouseout = function(){document.getElementById("sub_mad").style.display = 'none';}; 
	document.getElementById("sub_mad").onmouseover = function(){document.getElementById("sub_mad").style.display = 'block';};
	
	/**sub_materiais**/
	document.getElementById("btMat").onmouseover = function(){document.getElementById("sub_mat").style.display = 'block';}; 
	document.getElementById("btMat").onmouseout = function(){document.getElementById("sub_mat").style.display = 'none';}; 
	document.getElementById("sub_mat").onmouseout = function(){document.getElementById("sub_mat").style.display = 'none';}; 
	document.getElementById("sub_mat").onmouseover = function(){document.getElementById("sub_mat").style.display = 'block';};
	
	/**sub_tintas**/
	document.getElementById("btTintas").onmouseover = function(){document.getElementById("sub_tintas").style.display = 'block';}; 
	document.getElementById("btTintas").onmouseout = function(){document.getElementById("sub_tintas").style.display = 'none';}; 
	document.getElementById("sub_tintas").onmouseout = function(){document.getElementById("sub_tintas").style.display = 'none';}; 
	document.getElementById("sub_tintas").onmouseover = function(){document.getElementById("sub_tintas").style.display = 'block';};
	
	/**sub_cozinhas**/
	document.getElementById("btCozinhas").onmouseover = function(){document.getElementById("sub_cozinhas").style.display = 'block';}; 
	document.getElementById("btCozinhas").onmouseout = function(){document.getElementById("sub_cozinhas").style.display = 'none';}; 
	document.getElementById("sub_cozinhas").onmouseout = function(){document.getElementById("sub_cozinhas").style.display = 'none';}; 
	document.getElementById("sub_cozinhas").onmouseover = function(){document.getElementById("sub_cozinhas").style.display = 'block';};
	
	/**sub_portas**/
	document.getElementById("btPortas").onmouseover = function(){document.getElementById("sub_portas").style.display = 'block';}; 
	document.getElementById("btPortas").onmouseout = function(){document.getElementById("sub_portas").style.display = 'none';}; 
	document.getElementById("sub_portas").onmouseout = function(){document.getElementById("sub_portas").style.display = 'none';}; 
	document.getElementById("sub_portas").onmouseover = function(){document.getElementById("sub_portas").style.display = 'block';};
	
	/**sub_portas**/
	document.getElementById("btHid").onmouseover = function(){document.getElementById("sub_hid").style.display = 'block';}; 
	document.getElementById("btHid").onmouseout = function(){document.getElementById("sub_hid").style.display = 'none';}; 
	document.getElementById("sub_hid").onmouseout = function(){document.getElementById("sub_hid").style.display = 'none';}; 
	document.getElementById("sub_hid").onmouseover = function(){document.getElementById("sub_hid").style.display = 'block';};
	
	/**sub_pisos**/
	document.getElementById("btPisos").onmouseover = function(){document.getElementById("sub_pisos").style.display = 'block';}; 
	document.getElementById("btPisos").onmouseout = function(){document.getElementById("sub_pisos").style.display = 'none';}; 
	document.getElementById("sub_pisos").onmouseout = function(){document.getElementById("sub_pisos").style.display = 'none';}; 
	document.getElementById("sub_pisos").onmouseover = function(){document.getElementById("sub_pisos").style.display = 'block';};
	
	/**sub_ferramentas**/
	document.getElementById("btFer").onmouseover = function(){document.getElementById("sub_fer").style.display = 'block';}; 
	document.getElementById("btFer").onmouseout = function(){document.getElementById("sub_fer").style.display = 'none';}; 
	document.getElementById("sub_fer").onmouseout = function(){document.getElementById("sub_fer").style.display = 'none';}; 
	document.getElementById("sub_fer").onmouseover = function(){document.getElementById("sub_fer").style.display = 'block';};
	
	/**sub_metais**/
	document.getElementById("btMetais").onmouseover = function(){document.getElementById("sub_metais").style.display = 'block';}; 
	document.getElementById("btMetais").onmouseout = function(){document.getElementById("sub_metais").style.display = 'none';}; 
	document.getElementById("sub_metais").onmouseout = function(){document.getElementById("sub_metais").style.display = 'none';}; 
	document.getElementById("sub_metais").onmouseover = function(){document.getElementById("sub_metais").style.display = 'block';};
	

}
function convertform(form){
    var firstvalue = 0;
    for (var i = 1; i <= form.count; i++) {
       if (form.elements[i].value != null && form.elements[i].value.length != 0) {
	  if (i == 1 && form.elements[2].value != "") return false;
	  firstvalue = form.elements[i].value / form.elements[i].factor;
	  break;
       }
    }
    if (firstvalue == 0) {
       clearform(form);
       return false;
    }
    for (var i = 1; i <= form.count; i++)
       form.elements[i].value = formatvalue((firstvalue * form.elements[i].factor), form.rsize);
    return true;
}
function formatvalue(input, rsize) {
   var invalid = "**************************";
   var nines = "999999999999999999999999";
   var strin = "" + input;
   var fltin = parseFloat(strin);
   if (strin.length <= rsize) return strin;
   if (strin.indexOf("e") != -1 ||
       fltin > parseFloat(nines.substring(0,rsize)+".4"))
      return invalid.substring(0, rsize);
   var rounded = "" + (fltin + (fltin - parseFloat(strin.substring(0, rsize))));
   return rounded.substring(0, rsize);
}
function resetform(form) {
    clearform(form);
    form.elements[1].value = 1;
    convertform(form);
    return true;
}
function clearform(form) {
    for (var i = 1; i <= form.count; i++) form.elements[i].value = "";
    return true;
}
function limpa(){
	base=document.getElementById("termos").getElementsByTagName("p");
	for(i=0;i<=base.length;i++){
		if(document.getElementById("sub"+[i])){
			document.getElementById("sub"+[i]).style.display="none";
		};
	}
}

function mostra(obj){
	limpa();
	document.getElementById(obj.id.replace("cat","")).style.display="block";
}

window.onload=init
