/*Redimensionar fonte*/
function sizeFont(elem, acao){
	var tamInic = 12;	
	var tamMin = 12;
	var tamMax = 16;

	if (document.getElementById(elem).style.fontSize == "") {
		var tamFonte = tamInic;		
	}else{
		var tamFonte = parseInt(document.getElementById(elem).style.fontSize);
	}
	
	switch (acao){
		case '+':
			if (tamFonte < tamMax)
				document.getElementById(elem).style.fontSize = (tamFonte + 2) + "px";
		break;
		case '-':
			if (tamFonte > tamMin)
				document.getElementById(elem).style.fontSize = (tamFonte - 2) + "px";
		break;
	}
}

function expandir_formulario(){
	if (document.formulario.edicoesano.value == "Ano"){
		xDisplay('2010', 'none');
		xDisplay('2009', 'none');
		xDisplay('2008', 'none');
		xDisplay('2007', 'none');
		xDisplay('2006', 'none');
		xDisplay('2006_est', 'none');
		xDisplay('2004_est', 'none');
		xDisplay('fake', 'block');
	}
	if (document.formulario.edicoesano.value == "abre2010"){
		xDisplay('2010', 'block');
		xDisplay('2009', 'none');
		xDisplay('2008', 'none');
		xDisplay('2007', 'none');
		xDisplay('2006', 'none');
		xDisplay('fake', 'none');
	}
	if (document.formulario.edicoesano.value == "abre2009"){
		xDisplay('2010', 'none');
		xDisplay('2009', 'block');
		xDisplay('2008', 'none');
		xDisplay('2007', 'none');
		xDisplay('2006', 'none');
		xDisplay('fake', 'none');
	}
	if (document.formulario.edicoesano.value == "abre2008"){
		xDisplay('2010', 'none');
		xDisplay('2009', 'none');
		xDisplay('2008', 'block');
		xDisplay('2007', 'none');
		xDisplay('2006', 'none');
		xDisplay('fake', 'none');
	 }
	if (document.formulario.edicoesano.value == "abre2007"){
		xDisplay('2010', 'none');
		xDisplay('2009', 'none');
		xDisplay('2008', 'none');
		xDisplay('2007', 'block');
		xDisplay('2006', 'none');
		xDisplay('fake', 'none');
	 }
	 if (document.formulario.edicoesano.value == "abre2006"){
		xDisplay('2010', 'none');
		xDisplay('2009', 'none');
		xDisplay('2008', 'none');
		xDisplay('2007', 'none');
		xDisplay('fake', 'none');
		xDisplay('2006', 'block');
	 }
	  if (document.formulario.edicoesano.value == "abre2012_est"){
		xDisplay('2012_est', 'none');
		xDisplay('2011_est', 'none');
		xDisplay('2010_est', 'none');
		xDisplay('2009_est', 'none');
		xDisplay('2006_est', 'none');
		xDisplay('2004_est', 'none');
		xDisplay('fake', 'none');
	 }
	  if (document.formulario.edicoesano.value == "abre2011_est"){
		xDisplay('2012_est', 'none');
		xDisplay('2011_est', 'none');
		xDisplay('2010_est', 'none');
		xDisplay('2009_est', 'none');
		xDisplay('2006_est', 'none');
		xDisplay('2004_est', 'none');
		xDisplay('fake', 'none');
	 }
	  if (document.formulario.edicoesano.value == "abre2010_est"){
		xDisplay('2012_est', 'none');
		xDisplay('2011_est', 'none');
		xDisplay('2010_est', 'none');
		xDisplay('2009_est', 'none');
		xDisplay('2006_est', 'none');
		xDisplay('2004_est', 'none');
		xDisplay('fake', 'none');
	 }
	 if (document.formulario.edicoesano.value == "abre2009_est"){
		xDisplay('2012_est', 'none');
		xDisplay('2011_est', 'none');
		xDisplay('2010_est', 'none');
		xDisplay('2009_est', 'block');
		xDisplay('2006_est', 'none');
		xDisplay('2004_est', 'none');
		xDisplay('fake', 'none');
	 }
	 if (document.formulario.edicoesano.value == "abre2006_est"){
		xDisplay('2012_est', 'none');
		xDisplay('2011_est', 'none');
		xDisplay('2010_est', 'none');
		xDisplay('2009_est', 'none');
		xDisplay('2006_est', 'block');
		xDisplay('2004_est', 'none');
		xDisplay('fake', 'none');
	 }
	 if (document.formulario.edicoesano.value == "abre2004_est"){
		xDisplay('2012_est', 'none');
		xDisplay('2011_est', 'none');
		xDisplay('2010_est', 'none');
		xDisplay('2009_est', 'none');
		xDisplay('2006_est', 'none');
		xDisplay('2004_est', 'block');
		xDisplay('fake', 'none');
	 }
}

/* Valida formulário */

function MM_validateForm() {
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
      if (val) { nm=val.name; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' não é válido.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' precisa ser um número.\n';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' precisa ser um número entre '+min+' e '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+';\n'; }
    } if (errors) alert('Os seguintes campos são de preenchimento obrigatório:\n'+errors);
    document.MM_returnValue = (errors == '');
} }

/* Mostra campo oculto do form ASSOCIE-SE */

function MM_showHideLayers() {
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  if(document.getElementById('natureza_juridica').value == 'outra'){
	  for (i=0; i<(args.length-2); i+=3) 
	  with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
		if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
		obj.visibility=v; }
  }else{ document.getElementById('campo_outra').style.visibility = 'hidden'; }
}

/* Abre Popup WP-PRINT*/

function openPop(url, name, w, h)
{
  // Fudge factors for window decoration space.
  // In my tests these work well on all platforms & browsers.
  w += 32;
  h += 96;
  wleft = (screen.width - w) / 2;
  wtop = (screen.height - h) / 2;
  // IE5 and other old browsers might allow a window that is
  // partially offscreen or wider than the screen. Fix that.
  // (Newer browsers fix this for us, but let's be thorough.)
  if (wleft < 0) {
    w = screen.width;
    wleft = 0;
  }
  if (wtop < 0) {
    h = screen.height;
    wtop = 0;
  }
  var win = window.open(url,
    name,
    'width=' + w + ', height=' + h + ', ' +
    'left=' + wleft + ', top=' + wtop + ', ' +
    'location=no, menubar=no, ' +
    'status=no, toolbar=no, scrollbars=no, resizable=no');
  // Just in case width and height are ignored
  win.resizeTo(w, h);
  // Just in case left and top are ignored
  win.moveTo(wleft, wtop);
  win.focus();
}
