// Muda a cor do campo selecionado
function changeColor(oField, iAcao){
	if (iAcao == 0){
		oField.style.backgroundColor = '#F5F5F5';
	} else if (iAcao == 1){
		oField.style.backgroundColor = '#efefef';
	}
}

lib = new Object();

lib = {
	Import: function(File){
		document.write('<script src="../includes/js/'+File+'" type="text/javascript"></script>\n');
	}
}

lib2 = new Object();

lib2 = {
	Import2: function(File){
		document.write('<script src="admin/includes/js/'+File+'" type="text/javascript"></script>\n');
	}
}


lib3 = new Object();

lib3 = {
	Import3: function(File){
		document.write('<script src="../admin/includes/js/'+File+'" type="text/javascript"></script>\n');
	}
}

function calcula_preco_real(preco)
{
		preco = preco.replace(".","");
		preco = preco.replace(",",".");
		
		preco = parseFloat(preco);
		preco = ((45 * preco)/100)+preco;
		
		return formata_valor_pt(preco);
}

function formata_valor_pt(num)
{
	x = 0;
	
	if(num<0) {
		num = Math.abs(num);
		x = 1;
	}
	
	if(isNaN(num)) num = "0";
		cents = Math.floor((num*100+0.5)%100);

	num = Math.floor((num*100+0.5)/100).toString();
	
	if(cents < 10) cents = "0" + cents;
      for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
         num = num.substring(0,num.length-(4*i+3))+'.'
               +num.substring(num.length-(4*i+3));
	 ret = num + ',' + cents;
	 
	 if (x == 1) ret = ' - ' + ret;return ret;
}

var msg = new Object();
msg = {
	
	showMessageBlock : function(text){		
		jQuery.blockUI({ message: text });
		
		setTimeout(function(){
				$('#msg').remove();
		},3000);
		
	},	
	show : function(text){
		
		$('#msg').remove();
			
			$('body').prepend("<div align='center' class='msg' id='msg'>"+text+"</div>");
							
			setTimeout(function(){
				$('#msg').remove();
			},3000);
	},
	remove : function(){
		$('#msg').remove();
		jQuery.unblockUI();
	}	
}


function hide(){
	document.getElementById('mensagem').style.display  = 'none';
}

function DesabilitaForm( ){
    var inputFocus = null;
	var inputs = document.getElementsByTagName( 'input' );
    $x=0;
	$x2=0;
    while( $x < inputs.length ){
	   inputs[$x].setAttribute('disabled', 'disable');
	   if($x2 == 0){
		   inputFocus =  inputs[$x];
		   $x2++;
	   }
       $x++;
    }
	
	var inputs = document.getElementsByTagName( 'select' );
    $x=0;
	$x2=0;
    while( $x < inputs.length ){
	   inputs[$x].setAttribute('disabled', 'disable');
	   if($x2 == 0){
		   inputFocus =  inputs[$x];
		   $x2++;
	   }
       $x++;
    }
}

