var res			= screen.height;
var last		= '';
var reDate		= /^((0?[1-9]|[12]\d)\/(0?[1-9]|1[0-2])|30\/(0?[13-9]|1[0-2])|31\/(0?[13578]|1[02]))\/(19|20)?\d{2}$/;
var _HTTP_PATH_	= "http://" + document.domain + "/";

switch (document.domain) {
	case 'www.magicwebdesign.com.br':
		_HTTP_PATH_ += "dev/cts/";
		break;
	case '192.168.0.200':
		_HTTP_PATH_ += "dev/ctsconsultoria.com.br/";
		break;
}

function mostraResposta ( el )
{
	var el = document.getElementById( el );

	if( el.style.display == 'none' )
		el.style.display = '';
	else
		el.style.display = 'none';

	return false;
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function validaemail(email) {
  var objRegExp  = /^[A-Za-z0-9]([\w\.\-\_]*)@([A-Za-z0-9\.]*)\.(([A-Za-z]{3}\.[A-Za-z]{2}$)|([A-Za-z]{3}$)|([a-z]{2}$))/i ;
  return objRegExp.test(email);
}

function envia(param) {
  if (param == 1) {
    if (document.f1.nome.value.length < 3) {
      alert("Preencha o campo NOME!");
      document.f1.nome.focus();
    }
    else {
      if (!validaemail(document.f1.emai.value)) {
        alert("Preencha o campo E-MAIL!");
              document.f1.emai.focus();
      }
      else {
        document.f1.submit();
      }
    }
  }
  else if (param == 2) {
    if (!validaemail(document.f2.emai.value)) {
      alert("Preencha o campo E-MAIL!");
      document.f2.emai.focus();
    }
    else {
      document.f2.submit();
    }
  }
  else if ( param == 3 ) {
    if (document.f1.nome.value.length < 3) {
      alert("Preencha o campo NOME!");
      document.f1.nome.focus();
    }
    else {
      if (!validaemail(document.f1.email.value)) {
        alert("Preencha o campo E-MAIL!");
              document.f1.email.focus();
      }
      else {
        if ( document.f1.comentario.value.length < 3 )
        {
            alert("Preencha o campo MENSAGEM!");
        } else {
            document.f1.submit();
        }
      }
    }
  } else if ( param == 4 ) {
    if (document.f1.nome.value.length < 3) {
      alert("Preencha o campo NOME!");
      document.f1.nome.focus();
    }
    else {
      if (!validaemail(document.f1.emai.value)) {
        alert("Preencha o campo E-MAIL!");
              document.f1.emai.focus();
      }
      else if ( document.f1.operadora.value.length < 3 )
        {
            alert("Preencha o campo NOME DA OPERADORA!");
        }
		else if ( document.f1.endereco.value.length < 3 )
        {
            alert("Preencha o campo ENDEREÇO!");
        } 
		else if ( document.f1.cidade.value.length < 3 )
        {
            alert("Preencha o campo CIDADE!");
        }
		else if ( document.f1.bairro.value.length < 3 )
        {
            alert("Preencha o campo BAIRRO!");
        }
		else if ( document.f1.cep.value.length < 9 )
        {
            alert("Preencha o campo CEP!");
        }
		else if ( document.f1.fone.value.length < 14 )
        {
            alert("Preencha o campo TELEFONE!");
        }
		else if (document.f1.florianopolis.checked==false && 
				 document.f1.curitiba.checked==false && 
				 document.f1.maringa.checked==false && 
				 document.f1.bauru.checked==false && 
				 document.f1.porto_alegre.checked==false && 
				 document.f1.recife.checked==false && 
				 document.f1.sao_paulo.checked==false && 
				 document.f1.belo_horizonte.checked==false)
		{
			alert("Selecione ao menos uma cidade onde deseja assistir a palestra.");
		}
		else {
            document.f1.submit();
        }
      }
  }
    if (param == 5) {
    if (document.f1.anexo1.value.length < 3) {
      alert("Selecione algum arquivo para enviar!");
      document.f1.anexo1.focus();
    }
      else {
        document.f1.submit();
      }

} else {
    if (document.f1.nome.value.length < 3) {
      alert("Preencha o campo NOME!");
      document.f1.nome.focus();
    }
    else {
      if (!validaemail(document.f1.email.value)) {
        alert("Preencha o campo E-MAIL!");
              document.f1.email.focus();
      }
      else {
        document.f1.submit();
      }
    }
  }
}

function doDate(pStr)
{
	if (reDate.test(pStr)) {
		return true;
	} else if (pStr != null && pStr != "") {
		return false;
	}
}

function VerificaData(cData) {
    var data = cData;
    var tam = data.length;

    if (tam != 10) {
        return false;
    }

    var dia = data.substr(0,2)
    var mes = data.substr (3,2)
    var ano = data.substr (6,4)

    if (ano < 1980)    {
        return false;
    }

    if (ano > 2010)    {
        return false;
    }

    switch (mes) {
        case '01':
            if  (dia <= 31)
                return (true);
        break;
        case '02':
            if  (dia <= 29)
                return (true);
        break;
        case '03':
            if  (dia <= 31)
                return (true);
        break;
        case '04':
            if  (dia <= 30)
                return (true);
        break;
        case '05':
            if  (dia <= 31)
        return (true);
        break;
        case '06':
            if  (dia <= 30)
                return (true);
        break;
        case '07':
            if  (dia <= 31)
                return (true);
        break;
        case '08':
            if  (dia <= 31)
                return (true);
        break;
        case '09':
            if  (dia <= 30)
                return (true);
        break;
        case '10':
            if  (dia <= 31)
                return (true);
        break;
        case '11':
            if  (dia <= 30)
                return (true);
        break;
        case '12':
            if  (dia <= 31)
                return (true);
        break;
        default:
            return (false);
    }
    return true;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_showHideLayers2() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers2.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_showHideLayers3() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers3.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_showHideLayers4() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers4.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function abre_popup(foto) {
  window.open('foto.htm?'+foto,'imagem','width=100, height=100, status=yes');
}

function tour() {
  window.open('tour.htm','tour','width=650, height=350, status=no');
}

function formataCampo ( tecla, obj, tipo )
{
	var key;
	var keyNum;
	if (navigator.userAgent.indexOf("MSIE") > 0) key = tecla.keyCode;
	if (navigator.userAgent.indexOf("Gecko") > 0) key = tecla.which;
	if ((key == 8) || (key == 0)) return true;

	keyNum = key;
	key = String.fromCharCode(key);
	if ( tipo == 'numero' || tipo == 'dotnum' )
		var erNum = /[0-9\,\.]/i;
	else if ( tipo == 'minifone' )
		var erNum = /[0-9\-]/i;
	else
		var erNum = /[0-9]/i;

	if (erNum.test(key))
	{
		/**** CEP ****/
		if (tipo == 'cep')
		{
			if (obj.value.length == 4) { obj.value = obj.value + key + '-'; return false; }
			else return true;
		}

		/**** CPF ****/
		else if (tipo == 'cpf')
		{
			if ((obj.value.length == 2) || (obj.value.length == 6)) { obj.value = obj.value + key + '.'; return false; }
			else if (obj.value.length == 10) { obj.value = obj.value + key + '-'; return false; }
			else if (obj.value.length > 13) return false;
			else return true;
		}

		/**** Fone ****/
		else if (tipo == 'fone')
		{
			if ((obj.value.length == 0)) { obj.value = '(' + key; return false; }
			else if (obj.value.length == 2) { obj.value = obj.value + key + ') '; return false; }
			else if (obj.value.length == 8) { obj.value = obj.value + key + '-'; return false; }
			else return true;
		}

		/**** CNPJ ****/
		else if (tipo == 'cnpj')
		{
			if ((obj.value.length == 1) || (obj.value.length == 5)) { obj.value = obj.value + key + '.'; return false; }
			else if (obj.value.length == 9) { obj.value = obj.value + key + '/'; return false; }
			else if (obj.value.length == 14) { obj.value = obj.value + key + '-'; return false; }
			else return true;
		}

		/**** NÚMERO COM SEPARADOR ESTILO PONTO "." ****/
		else if (tipo == 'dotnum')
		{
			if ( key == "." || key == "," )
			{
				if ( strpos ( obj.value, '.') !== false )
					return false;
				else
				{
					obj.value += ".";
					return false;
				}
			}
			return true;
		}

		/**** MOEDA ****/
		else if (tipo == 'moeda')
		{
			objTextBox = obj ;
			SeparadorMilesimo = '' ;
			SeparadorDecimal = '.' ;
			e = tecla ;
			//-----------------------------------------------------
			//Funcao: MascaraMoeda
			//Autor: Gabriel Fróes
			//-----------------------------------------------------
			var sep = 0;
			var key = '';
			var i = j = 0;
			var len = len2 = 0;
			var strCheck = '0123456789';
			var aux = aux2 = '';
			var whichCode = (window.Event) ? e.which : e.keyCode;
			if (whichCode == 13) return true;
			key = String.fromCharCode(whichCode); // Valor para o código da Chave
			if (strCheck.indexOf(key) == -1) return false; // Chave inválida
			len = objTextBox.value.length;
			for(i = 0; i < len; i++)
				if ((objTextBox.value.charAt(i) != '0') && (objTextBox.value.charAt(i) != SeparadorDecimal)) break;
			aux = '';
			for(; i < len; i++)
				if (strCheck.indexOf(objTextBox.value.charAt(i))!=-1)
					aux += objTextBox.value.charAt(i);
			aux += key;
			len = aux.length;
			if (len == 0) objTextBox.value = '';
			if (len == 1) objTextBox.value = '0'+ SeparadorDecimal + '0' + aux;
			if (len == 2) objTextBox.value = '0'+ SeparadorDecimal + aux;
			if (len > 2) {
				aux2 = '';
				for (j = 0, i = len - 3; i >= 0; i--) {
					if (j == 3) {
						aux2 += SeparadorMilesimo;
						j = 0;
					}
					aux2 += aux.charAt(i);
					j++;
				}
				objTextBox.value = '';
				len2 = aux2.length;
				for (i = len2 - 1; i >= 0; i--)
					objTextBox.value += aux2.charAt(i);
				objTextBox.value += SeparadorDecimal + aux.substr(len - 2, len);
			}
			return false;
		}

		/**** DATA ****/
		else if (tipo == 'data')
		{
			if ((obj.value.length == 1) || (obj.value.length == 4)) { obj.value = obj.value + key + '/'; return false; }
			else return true;
		}

		/**** MES/ANO ****/
		else if (tipo == 'mes_ano')
		{
			if (obj.value.length == 1) { obj.value = obj.value + key + '/'; return false; }
			else return true;
		}

		else { return false; }
	}

	else if ( keyNum == 13 ) { return true; }
	else return false;
}

function hide(id){
	var obj = document.getElementById(id);
	obj.style.display=(obj.style.display=='none')?'':'none';
}

function confere_senha ()
{
	if ($('assoc_senha').value == '' && $('assoc_senha_conf').value == '')
	{
    	$('img_ok').hide();
    	$('img_erro').hide();
	}
    else if ($('assoc_senha').value == $('assoc_senha_conf').value)
    {
    	$('img_ok').show();
    	$('img_erro').hide();
    }
    else
    {
    	$('img_erro').show();
    	$('img_ok').hide();
    }
}

/*
COMO USAR
EX: onkeypress="return Mascaras ( event, 'FONE', 'nome_id' );"
*/
function Mascaras ( e, formato, objeto )
{
    var key;

    if ( window.event ) keyPressed = window.event.keyCode; // IE hack
    else keyPressed = e.which; // <B>standard method</B>

    if ( keyPressed >= 48 && keyPressed <= 57 )
    {
        var campo = document.getElementById(objeto);

        /*
            DATA
            FORMATO: 00/00/0000
        */
        if ( formato == 'DATA' )
        {
            separador = '/';
            conjunto1 = 2;
            conjunto2 = 5;
            if ( campo.value.length == conjunto1 )
                campo.value = campo.value + separador;

            if ( campo.value.length == conjunto2 )
                campo.value = campo.value + separador;

            return true;
        }

        /*
            HORA
            FORMATO: 00:00
        */
        if (formato == 'HORA')
        {
            separador = ':';
            conjunto1 = 2;
            if ( campo.value.length == conjunto1 )
                campo.value = campo.value + separador;

            return true;
        }

        /*
            CEP
            FORMATO: 00000-000
        */
        if (formato == 'CEP')
        {
            separador = '-';
            conjunto1 = 5;
            if (    campo.value.length == conjunto1 )
                campo.value = campo.value + separador;

            return true;
        }

        /*
            CPF
            FORMATO: 000.000.000-00
        */
        if (formato == 'CPF')
        {
            separador = '.';
            separador1 = '-';
            conjunto1 = 3;
            conjunto2 = 7;
            conjunto3 = 11;
            if ( campo.value.length == conjunto1 )
                campo.value = campo.value + separador;

            if ( campo.value.length == conjunto2 )
                campo.value = campo.value + separador;

            if ( campo.value.length == conjunto3 )
                campo.value = campo.value + separador1;

            return true;
        }

        /*
            CNPJ
            FORMATO: 00.000.000/0000-00
        */
        if (formato == 'CNPJ')
        {
            separador1 = '.';
            separador2 = '/';
            separador3 = '-';
            conjunto1 = 2;
            conjunto2 = 6;
            conjunto3 = 10;
            conjunto4 = 15;
            if ( campo.value.length == conjunto1 )
                campo.value = campo.value + separador1;

            if ( campo.value.length == conjunto2 )
                campo.value = campo.value + separador1;

            if ( campo.value.length == conjunto3 )
                campo.value = campo.value + separador2;

            if ( campo.value.length == conjunto4 )
                campo.value = campo.value + separador3;

            return true;
        }

        /*
            FONE
            FORMATO: (00) 0000-0000
        */
        if ( formato == 'FONE' )
        {
            separador1 = '(';
            separador2 = ') ';
            separador3 = '-';
            conjunto1 = 0;
            conjunto2 = 3;
            conjunto3 = 9;
            if ( campo.value.length == conjunto1 )
                campo.value = campo.value + separador1;

            if ( campo.value.length == conjunto2 )
                campo.value = campo.value + separador2;

            if ( campo.value.length == conjunto3 )
                campo.value = campo.value + separador3;

            return true;
        }

        /*
            FONE2
            FORMATO: 0000-0000
        */
        if ( formato == 'FONESIMPLES' )
        {
            separador1 = '-';
            conjunto1 = 4;
            if ( campo.value.length == conjunto1 )
                campo.value = campo.value + separador1;

            return true;
        }
    }
    else if ( keyPressed == 8 || keyPressed == 13 || keyPressed == 0 )
        return true;
    else
        return false;
}

/*
COMO USAR
EX: onkeypress="return Numeros ( event );"
*/
function Numeros ( e, pontuacao )
{
	if ( window.event ) keyPressed = window.event.keyCode; // IE hack
	else keyPressed = e.which; // <B>standard method</B>

	if ( keyPressed == 8 || keyPressed == 13 || keyPressed == 0 ) return true;
	else if ( keyPressed >= 48 && keyPressed <= 57 ) return true;
	else if ( pontuacao && (keyPressed == 47 || keyPressed == 46 || keyPressed == 45) ) return true;

	return false;
}

function enviaFormulario(tipo)
{
	provisao = ($('provisao'))	?	parseInt($('provisao').value)	:	0;
	despesas = ($('despesas'))	?	parseInt($('despesas').value)	:	0;
	lucro    = ($('lucro'))		?	parseInt($('lucro').value)		:	0;

	total = provisao + despesas + lucro;

	if (total < 100)
	{
		if (tipo == 'simulacao')
		{
			$('f1').action = 'imprimir.php';
			$('f1').target = '_blank';
			$('f1').submit();
		}
		else if (tipo == 'linear')
		{
			$('f1').action = 'sistema4.php';
			$('f1').target = '';
			$('f1').submit();
		}
		else if (tipo == 'acumulada')
		{
			$('f1').action = 'sistema5.php';
			$('f1').target = '';
			$('f1').submit();
		}
	}

	return false;
}

function somaTotalVidas()
{
	var total = 0;
	var cont  = 1;
	var total_valor = 0;

	while (true)
	{
		if ($('v'+cont))
		{
			total += parseFloat($('v'+cont).value ? $('v'+cont).value : 0);
			cont++;
		}
		else
		{
			break;
		}
	}

	$('total_vidas').update(total);

	var valor_total = 0;
	for (var x=1; x<11; x++)
	{
		if ($('v'+x).value != '' && $('v'+x).value != 0)
		{
			total_valor = parseInt($('simulacao_'+x).innerHTML.replace(/[^\d]/g, ""));
			total_valor *= parseInt($('v'+x).value);
			valor_total += parseFloat(total_valor/100);
		}
	}

	$('total_valor').update("R$ " + number_format(valor_total,2,",","."));
}

function valorLinear()
{
	var total_vidas = $('total_vidas').innerHTML;
	var total_valor = 0;
	var valor_linear = 0;

	if (total_vidas != '0')
	{
		total_valor = parseInt($('total_valor').innerHTML.replace(/[^\d]/g, ""));
		valor_linear = parseInt(total_valor) / parseInt(total_vidas);
		valor_linear = valor_linear/100;
		$('valor_linear').update("R$ " + number_format(valor_linear,2,",","."));
	}
	else
	{
		$('valor_linear').update("R$ 0,00");
	}
}

function number_format( number, decimals, dec_point, thousands_sep ) {
    // Format a number with grouped thousands
    //
    // +    discuss at: http://kevin.vanzonneveld.net/techblog/article/javascript_equivalent_for_phps_number_format/
    // +       version: 809.522
    // +   original by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +     bugfix by: Michael White (http://crestidg.com)
    // +     bugfix by: Benjamin Lupton
    // +     bugfix by: Allan Jensen (http://www.winternet.no)
    // +    revised by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
    // +     bugfix by: Howard Yeend
    // *     example 1: number_format(1234.5678, 2, '.', '');
    // *     returns 1: 1234.57

    var n = number, c = isNaN(decimals = Math.abs(decimals)) ? 2 : decimals;
    var d = dec_point == undefined ? "." : dec_point;
    var t = thousands_sep == undefined ? "," : thousands_sep, s = n < 0 ? "-" : "";
    var i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0;

    return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");

}

function valorAcumuladas(grupo)
{
	var i = grupo;
	var valor_grupo = 0;
	var total_vidas = 0;

	while (true)
	{
		var simulacao = 0;
		if ($('vidas_'+grupo+'_'+i))
		{
			if ($('vidas_'+grupo+'_'+i).value != "" && $('vidas_'+grupo+'_'+i).value != 0)
			{
				total_vidas += parseFloat($('vidas_'+grupo+'_'+i).value);

				simulacao = parseFloat($('simulacao_'+grupo+'_'+i).innerHTML.replace(/[^\d]/g, ""));
				simulacao *= parseFloat($('vidas_'+grupo+'_'+i).value);
				valor_grupo += parseFloat(simulacao/100);
			}
			i++;
		}
		else
		{
			break;
		}
	}

	total_grupo = valor_grupo / total_vidas;
	$('grupo_'+grupo).update("R$ " + number_format(total_grupo,2,",","."));


	var total_vidas = 0;
	var valor_total = 0;
	var total_valor = 0;

	for (var x=1; x<11; x++)
	{
		var y=x;
		while(true)
		{
			vidas     = "vidas_"+x+"_"+y;
			simulacao = "simulacao_"+x+"_"+y;

			if ($(vidas))
			{
				if ($(vidas).value != "" && $(vidas).value != 0)
				{
					total_vidas += parseFloat($(vidas).value);

					total_valor = parseFloat($(simulacao).innerHTML.replace(/[^\d]/g, ""));
					total_valor *= parseFloat($(vidas).value);
					valor_total += parseFloat(total_valor/100);
				}

				y++;
			}
			else
			{
				break;
			}
		}
	}

	$('total_vidas').update(total_vidas);
	$('total_valor').update("R$ " + number_format(valor_total,2,",","."));
}

function verificaSenha()
{
	if (document.getElementById('senha').value == "")
	{
		document.getElementById('imagem_senha').src = _HTTP_PATH_+'simulador/img/ico-erro.gif';
		document.getElementById('imagem_senha').style.display = 'none';
	}
	else if (document.getElementById('senha').value == document.getElementById('senha_conf').value)
	{
		document.getElementById('imagem_senha').src = _HTTP_PATH_+'simulador/img/ico-sucesso.gif';
		document.getElementById('imagem_senha').style.display = '';
	}
	else
	{
		document.getElementById('imagem_senha').src = _HTTP_PATH_+'simulador/img/ico-erro.gif';
		document.getElementById('imagem_senha').style.display = '';
	}
}

function validaMesAno (valor)
{
	var data	= valor.split('/');
	var msg		= '';

	if (data[0] < 1 || data[0] > 12)
	{
		return false;
	}

	if (data[1].length < 4 || data[1].length > 4)
	{
		return false;
	}

	return true;
}

function validaSimulacao (param)
{
	var msg = '';
	if (param == 1)
	{
		if (!validaMesAno($('mes_ano_ref').value))
			msg += '	- Data de referência inválida\n';

		if (!validaMesAno($('mes_ano_inicio').value))
			msg += '	- Data de início inválida\n';

		if ($('classificacao').value == 0)
			msg += '	- Deve ser selecionada uma classificação\n';

		if ($('segmentacao').value == 0)
			msg += '	- Deve ser selecionada uma segmentação\n';

		if ($('regiao').value == 0)
			msg += '	- Deve ser selecionada uma região\n';

		if ($('social').value == '')
			msg += '	- Deve ser preenchido um valor para o patrimônio social\n';
		else if ($('social').value.length > 14)
			msg += '	- O valor do patrimônio social deve ser menor que 100.000.000,00\n';

		if ($('deducoes').value.length > 13)
			msg += '	- O valor de deduções deve ser menor que 10.000.000,00\n';

		if ($('adicoes').value.length > 13)
			msg += '	- O valor de adições deve ser menor que 10.000.000,00\n';
	}

	if (msg != '')
	{
		alert('Foram encontrados os seguintes erros: \n'+msg);
		return false;
	}

	return true;
}

function calculaPatrimonioLiquido ()
{
	var social	= $('social').value.replace(/[^\d]/g, "");
	var deducao	= $('deducoes').value.replace(/[^\d]/g, "");
	var adicao	= $('adicoes').value.replace(/[^\d]/g, "");

	social	= parseFloat(social);
	deducao	= parseFloat(deducao);
	adicao	= parseFloat(adicao);

	var liquido	= ((social + adicao) - deducao) / 100;

	if (liquido > -0.01)
	{
		$('liquido').update(number_format(liquido,2,",","."));
	}
	else
	{
		$('liquido').update('('+number_format(liquido,2,",",".")+')');
	}
}

if (res <= 600)
{
	document.write('<style type="text/css">#geral{min-height:90%;_height:90%;}<\/style>')
}
else if ( res == 768 )
{
	document.write('<style type="text/css">#geral{min-height:94%;_height:94%;}<\/style>')
}
else if ( res == 864 )
{
	document.write('<style type="text/css">#geral{min-height:94%;_height:94%;}<\/style>')
}
else if ( res == 1024 )
{
	document.write('<style type="text/css">#geral{min-height:94%;_height:94%;}<\/style>')
}
else if ( res == 1200 )
{
	document.write('<style type="text/css">#geral{min-height:95%;_height:95%;}<\/style>')
}
else
{
	document.write('<style type="text/css">#geral{min-height:96%;_height:96%;}<\/style>')
}
