

// recebe o nome do frame e redimenciona
function change_height(pFrame) {

	//internet explorer
	if (navigator.appName == "Microsoft Internet Explorer")
	{
		if(document.getElementById && !(document.all)) {
		  height = document.getElementById(pFrame).contentDocument.body.scrollHeight;
		  height = 1.3*height;
		  document.getElementById(pFrame).style.height = height;
		}
		else {
			if(document.all) {
  				height = document.frames(pFrame).document.body.scrollHeight;
  				height = 1.3*height;
				document.getElementById(pFrame).style.height = height;
		    }
		}
	}
	//firefox / nestcape
	else
	{
		if (document.getElementById && !(document.all)) {
			height = "1px";
			document.getElementById(pFrame).style.height = height;
			height = document.getElementById(pFrame).contentDocument.body.scrollHeight;
			height = 1.3*height;
			document.getElementById(pFrame).style.height = height;
		}
		else if(document.all) {
			alert('teste');
			height = "1px";
			document.getElementById(pFrame).style.height = height;
			height = document.frames(pFrame).document.body.scrollHeight;
			height = 1.3*height;
			document.getElementById(pFrame).style.height = height;
		}
	}
}


function redimensiona(pFrame) {

	//internet explorer
	if (navigator.appName == "Microsoft Internet Explorer")
	{
		if(document.getElementById && !(document.all)) {
		  height = document.getElementById(pFrame).contentDocument.body.scrollHeight;
		  height = 1.3*height;
		  document.getElementById(pFrame).style.height = height;
		}
		else {
			if(document.all) {
  				height = document.frames(pFrame).document.body.scrollHeight;
  				height = 1.3*height;
				document.getElementById(pFrame).style.height = height;
		    }
		}
	}
	//firefox / nestcape
	else
	{
		if (document.getElementById && !(document.all)) {
			height = "1px";
			document.getElementById(pFrame).style.height = height;
			height = document.getElementById(pFrame).contentDocument.body.scrollHeight;
			height = 1.3*height;
			document.getElementById(pFrame).style.height = height;
		}
		else if(document.all) {
			alert('teste');
			height = "1px";
			document.getElementById(pFrame).style.height = height;
			height = document.frames(pFrame).document.body.scrollHeight;
			height = 1.3*height;
			document.getElementById(pFrame).style.height = height;
		}
	}
}



function na_open_window(name, url, left, top, width, height, toolbar, menubar, statusbar, scrollbar, resizable)
{
  toolbar_str = toolbar ? 'yes' : 'no';
  menubar_str = menubar ? 'yes' : 'no';
  statusbar_str = statusbar ? 'yes' : 'no';
  scrollbar_str = scrollbar ? 'yes' : 'no';
  resizable_str = resizable ? 'yes' : 'no';
  window.open(url, name, 'left='+left+',top='+top+',width='+width+',height='+height+',toolbar='+toolbar_str+',menubar='+menubar_str+',status='+statusbar_str+',scrollbars='+scrollbar_str+',resizable='+resizable_str);
}


function FormatNumber(pnumber,decimals){
	if (isNaN(pnumber)) { return 0};
	if (pnumber=='') { return 0};
	
	var snum = new String(pnumber);
	var sec = snum.split('.');
	var whole = parseFloat(sec[0]);
	var result = '';
	
	if(sec.length > 1){
		var dec = new String(sec[1]);
		dec = String(parseFloat(sec[1])/Math.pow(10,(dec.length - decimals)));
		dec = String(whole + Math.round(parseFloat(dec))/Math.pow(10,decimals));
		var dot = dec.indexOf('.');
		if(dot == -1){
			dec += '.'; 
			dot = dec.indexOf('.');
		}
		while(dec.length <= dot + decimals) { dec += '0'; }
		result = dec;
	} else{
		var dot;
		var dec = new String(whole);
		dec += '.';
		dot = dec.indexOf('.');		
		while(dec.length <= dot + decimals) { dec += '0'; }
		result = dec;
	}	
	return result;
}

function SomenteNumeros(e){
    var tecla=(window.event)?event.keyCode:e.which;
    if (tecla == 0) return true;
    if ((tecla > 47 && tecla < 58)) return true;
    else {
		if (tecla != 8) return false;
		else return true;
    }
}

// Função para criar o cookie.
// Para que o cookie seja destruído quando o brawser for fechado, basta passar 0 no parametro lngDias.
function GerarCookie(strCookie, strValor, lngDias)
{
    var dtmData = new Date();

    if(lngDias)
    {
        dtmData.setTime(dtmData.getTime() + (lngDias * 24 * 60 * 60 * 1000));
        var strExpires = "; expires=" + dtmData.toGMTString();
    }
    else
    {
        var strExpires = "";
    }
    document.cookie = strCookie + "=" + strValor + strExpires + "; path=/";
}

// Função para ler o cookie.
function LerCookie(strCookie)
{
    var strNomeIgual = strCookie + "=";
    var arrCookies = document.cookie.split(';');

    for(var i = 0; i < arrCookies.length; i++)
    {
        var strValorCookie = arrCookies[i];
        while(strValorCookie.charAt(0) == ' ')
        {
            strValorCookie = strValorCookie.substring(1, strValorCookie.length);
        }
        if(strValorCookie.indexOf(strNomeIgual) == 0)
        {
            return strValorCookie.substring(strNomeIgual.length, strValorCookie.length);
        }
    }
    return null;
}

// Função para excluir o cookie desejado.
function ExcluirCookie(strCookie)
{
    GerarCookie(strCookie, '', -1);
}
