




/*FUNÇÃO PARA REDIMENSIONAR O IFRAME
function RedimensionaIframe() {
	var ifr = document.getElementById('home');
	var altura = ifr.contentWindow.document.body.scrollHeight;
	if(altura > 700) {
		ifr.style.height = altura;
	} else {
		ifr.style.height = 700;
	}
}
*/
var newwindow;
function poptastic(url)
{
	newwindow=window.open(url,'name','scrollbars=no,resizable=yes,height=1024,width=768');
	if (window.focus) {newwindow.focus()}
}
function imprimir(arq){
    window.open("imprimir.php?arq="+arq, "Iamar", "height = 800, width = 600");
}

function validaLogin(campo){
	if (campo.value.length !=0){	
	   if (campo.value.length <6 ){
				alert('Seu login tem quer ter pelo menos 6 digitos');
				campo.focus();
				return false;
		}
		return true;
	}
	return true;
}

function validaSenha(campo){
	if (campo.value.length !=0){
		if (campo.value.length <6 ){
				alert('Sua senha tem quer ter pelo menos 6 digitos');
				campo.focus();
				return false;
			}else{
			   
			  if (isSenha(campo.value)){  
			   return true;
			   }else{
				alert('A senha deve ter pelo menos 3 letras e 3 numeros.')
				campo.focus();
			   
			   }
			}
	}
	return true;
}


function isSenha(pVal){
	var reTipo = /^([0-9]*[a-zA-Z]+){3,}[0-9]*$/; 	
	if (reTipo.test(pVal)) {
		reTipo = /^([a-zA-Z]*[0-9]+){3,}[a-zA-Z]*$/; 	
		return reTipo.test(pVal);
	}
	return false;
}



function Tecla(e)
{
	if (document.all) // Internet Explorer
		var tecla = event.keyCode;
	else if(document.layers) // Nestcape
		var tecla = e.which;
		if (tecla > 47 && tecla < 58) // numeros de 0 a 9
			return true;
		else
			{
				if (tecla != 8) // backspace
					event.keyCode = 0;
					//return false;
				else
					return true;
			}
}

function autotab(original,destination){
if (original.getAttribute&&original.value.length==original.getAttribute("maxlength"))
destination.focus()
}

//MASCARA CAMPO DE DATA
  function criaMascara(_RefObjeto, _Modelo){
  
    var valorAtual = _RefObjeto.value;        
    var valorNumerico = '';
    var nIndexModelo = 0;
    var nIndexString = 0;
    var valorFinal = '';
    var adicionarValor = true;
    
     
      // limpa a string valor atual para verificar 
      // se todos os caracteres são números
      for (i=0;i<_Modelo.length;i++){
        if (_Modelo.substr(i,1) != '#'){
          valorAtual = valorAtual.replace(_Modelo.substr(i,1),'');
      }}
      
      // verifica se todos os caracteres são números
      for (i=0;i<valorAtual.length;i++){
        if (!isNaN(parseFloat(valorAtual.substr(i,1)))){
          valorNumerico = valorNumerico + valorAtual.substr(i,1);
      }}
      
      // aplica a máscara ao campo informado usando
      // o modelo de máscara informado no script
      for (i=0;i<_Modelo.length;i++){
        
        if (_Modelo.substr(i,1) == '#'){
          if (valorNumerico.substr(nIndexModelo,1) != ''){
            valorFinal = valorFinal + valorNumerico.substr(nIndexModelo,1);
            nIndexModelo++;nIndexString++;
          } 
            else {
              adicionarValor = false;
        }}
          
          else {
            if (adicionarValor && valorNumerico.substr(nIndexModelo,1) != ''){
            valorFinal = valorFinal + _Modelo.substr(nIndexString,1)
            nIndexString++;
          }}
      }
    
      //alert(valorFinal)
      _RefObjeto.value = valorFinal 

  }
  
	function bindField(field, value) {
		obj = document.getElementById(field);
		if (obj != null)
			obj.value = value;
	}
	
	function colorField(field) {
		obj = document.getElementById(field);
		if (obj != null)
			obj.style.background = '#ffebc7';
	}

function Mascara (formato, objeto)
{
campo = eval (objeto);
  if (formato=='CPF'){
   	  caracteres = '01234567890';
	  separacoes = 3;
	  separacao1 = '.';
	  separacao2 = '-';
	  conjuntos = 4;
	  conjunto1 = 3;
	  conjunto2 = 7;
	  conjunto3 = 11;
	  conjunto4 = 14;
	  if ((caracteres.search(String.fromCharCode (window.event.keyCode))!=-1) && campo.value.length < (conjunto4)){
		  if (campo.value.length == conjunto1) 
			  campo.value = campo.value + separacao1;
		  else if (campo.value.length == conjunto2) 
			  campo.value = campo.value + separacao1;
		  else if (campo.value.length == conjunto3) 
			  campo.value = campo.value + separacao2;
	  }
	  else 
		event.returnValue = false;
  }  
}

function tent(a, txt_login, txt_pass) {
     var Key = a.keyCode || a.which;
     if(Key == "13"){
     
	 	if (txt_login == "")
	{
		alert('Campo Login Obrigatório');
		frm_login.txt_login.focus();
	}
	else if(txt_pass == "")
	{
		alert('Campo Senha Obrigatória');
		frm_login.txt_pass.focus();
	}
	else
	{
		frm_login.submit();

	}
	
     }
     return false;
}
//FUNÇÃO PARA VALIDAR O FORMULARIO DE LOGIN
function lgValida(txt_login, txt_pass){
	if (txt_login == "")
	{
		alert('Campo Login Obrigatório');
		frm_login.txt_login.focus();
	}
	else if(txt_pass == "")
	{
		alert('Campo Senha Obrigatória');
		frm_login.txt_pass.focus();
	}
	else
	{
		frm_login.submit();

	}
	
}

function lgFocus(){
	frm_login.txt_login.focus();
}

 function troca(campo){
		campo.value = campo.value.toUpperCase();
		var estranha = "ÁÉÍÓÚÀÈÌÒÙÂÊÎÔÛÄËÏÖÜÃÕ@#$%^&*()_+=-~` Ç";
		var correta = "AEIOUAEIOUAEIOUAEIOUAO_______________ C";
		var retorno = "";
		for(i=0;i<estranha.length;i++){
			for(j=0;j<campo.value.length;j++){
				retorno = campo.value.replace(estranha.substr(i,1),correta.substr(i,1));
				retorno = retorno.replace("_","");
				campo.value = retorno;
			}
		} 
	} 
	
	
function LimparValores(valor, validos) {
	// retira caracteres invalidos da string
	var result = "";
	var aux;
	for (var i=0; i < valor.length; i++) {
		aux = validos.indexOf(valor.substring(i, i+1));
		if (aux>=0) {
			result += aux;
		}
	}
	return result;
}

//Formata número tipo moeda usando o evento onKeyDown

function Formata(campo,tammax,teclapres,decimal) {
	
	var tecla = teclapres.keyCode;
	vr = LimparValores(campo.value,"0123456789");
	tam = vr.length;
	dec = decimal
	
	if (tam < tammax && tecla != 8){ 
		tam = vr.length + 1 ; 
	}
	
	if (tecla == 8 ){ 
		tam = tam - 1 ; 
	}
	
	if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ){

		if ( tam <= dec ){
			campo.value = vr ; 
		}
	
		if ( (tam > dec) && (tam <= 5) ){
			campo.value = vr.substr( 0, tam - 2 ) + "," + vr.substr( tam - dec, tam ) ; 
		}
		
		if ( (tam >= 6) && (tam <= 8) ){
			campo.value = vr.substr( 0, tam - 5 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - dec, tam ) ; 
		}
		
		if ( (tam >= 9) && (tam <= 11) ){
			campo.value = vr.substr( 0, tam - 8 ) + "." + vr.substr( tam - 8, 3 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - dec, tam ) ; 
		}
		
		if ( (tam >= 12) && (tam <= 14) ){
			campo.value = vr.substr( 0, tam - 11 ) + "." + vr.substr( tam - 11, 3 ) + "." + vr.substr( tam - 8, 3 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - dec, tam ) ; 
		}
		
		if ( (tam >= 15) && (tam <= 17) ){
			campo.value = vr.substr( 0, tam - 14 ) + "." + vr.substr( tam - 14, 3 ) + "." + vr.substr( tam - 11, 3 ) + "." + vr.substr( tam - 8, 3 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - 2, tam ) ;
		}
	} 

}

function maskin(tipo,str,textbox,delim, delim2, delim3){
	if(tipo == 'cpf'){
		var loc = '3,7';
		var loc2 = '11';
		
		var locs = loc.split(',');
	
				for (var k = 0; k <= str.length; k++){
					
					for (var i = 0; i <= locs.length; i++){	
						if (k == locs[i]){
							  if (str.substring(k, k+1) != delim){
								str = str.substring(0,k) + delim + str.substring(k,str.length)
							  }
						}
					}	
					
				if (k == loc2){
					  if (str.substring(k, k+1) != delim2){
						str = str.substring(0,k) + delim2 + str.substring(k,str.length)
					  }
				}
			}	 
	}
if(tipo == 'cnpj'){
		var loc = '2,6';
		var loc2 = '10';
		var loc3 = '15';
		var locs = loc.split(',');
	
				for (var k = 0; k <= str.length; k++){
					
					for (var i = 0; i <= locs.length; i++){	
						if (k == locs[i]){
							  if (str.substring(k, k+1) != delim){
								str = str.substring(0,k) + delim + str.substring(k,str.length)
							  }
						}
					}	
					
				if (k == loc2){
					  if (str.substring(k, k+1) != delim3){
						str = str.substring(0,k) + delim3 + str.substring(k,str.length)
					  }
				}
				
				if (k == loc3){
					  if (str.substring(k, k+1) != delim2){
						str = str.substring(0,k) + delim2 + str.substring(k,str.length)
					  }
				}
			}	 
	}	
	textbox.value = str;
}
	
	
	
//FUNÇÃO PARA ESCREVER OS ARQUIVOS SWF.
function banner(imagemTop){
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="775" height="205"> <param name="movie" value="./img/menuIamarTop.swf?imgtop='+imagemTop+'" /> <param name="quality" value="high" /> <embed src="./img/menuIamarTop.swf?imgtop='+imagemTop+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="775" height="205"></embed></object>');
}

function menu(){
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="210" height="215"><param name="movie" value="./img/menuIamarEsquerdo.swf" /><param name="wmode" value="transparent" /><param name="quality" value="high" /><embed src="./img/menuIamarEsquerdo.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="210" height="215"  wmode="transparent" ></embed></object>');
}

function enquete(){
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="210" height="235"> <param name="movie" value="./img/enquete.swf" /><param name="wmode" value="transparent" /> <param name="quality" value="high" /> <embed src="./img/enquete.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="210" height="235"  wmode="transparent"></embed></object>');
}

function bottomSide(){
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="210" height="326"> <param name="movie" value="./img/bottomSide.swf" /><param name="wmode" value="transparent" /> <param name="quality" value="high" /> <embed src="./img/bottomSide.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="210" height="326"  wmode="transparent"></embed></object>');
}

function galeria(cod_evento){
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="544" height="345"> <param name="movie" value="./img/galeria_iamar.swf?cod_evento='+cod_evento+'" /><param name="wmode" value="transparent" /> <param name="quality" value="high" /> <embed src="./img/galeria_iamar.swf?cod_evento='+cod_evento+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="544" height="345"></embed></object>');
}

function grafico(cod_projeto){
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="270" height="230"> <param name="movie" value="./img/grafico.swf?cod_projeto='+cod_projeto+'" /><param name="wmode" value="transparent" /> <param name="quality" value="high" /> <embed src="./img/grafico.swf?cod_projeto='+cod_projeto+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="270" height="230"></embed></object>');
}