<!--




//Submete o formulário
// form : referencia do formulario
// acao :str contendo o comando desejado
function doAction(formName,acao){
	frm = document.getElementById(formName)
	frm.p_action.value = acao
	frm.submit()
	}

// Préload das imagens
// Exemplo:  preloadImages( '01.gif', '02.gif' ); 
function preloadImages()
{ 
  var args = preloadImages.arguments;
  document.imageArray = new Array(args.length);
  for(var i=0; i<args.length; i++)
  {
    document.imageArray[i] = new Image;
    document.imageArray[i].src = args[i];
  }
}

// Troca imagem
// Exemplo: swapImage(this,'imagens/home_v.gif')
function swapImage(obj,strImage){
	var img = new Image();
	img.src = strImage;
	obj.src = img.src;
	}
	
// Seta a propriedate display do objeto
// Exemplo 1: setDisplay('box1','block');
// Exemplo 2: setDisplay('box1','none'); 
//--
// Possiveis valores para strParam:
// block,compact,inherit,inline,inline-table, list-item, marker, none, run-in, table, 
// table-caption, table-cell, table-column, table-column-group, table-column-group, 
// table-footer-group, table-header-group, table-row, table-row-group
//--
function setDisplay(objId,strParam){
	var obj= document.getElementById(objId)
	    obj.style.display=strParam;
	}

/* **************************
 Mostra ou esconde um objeto
 - Se o objeto estiver sendo exibido então ele será escondido
    caso contrário ele será exibido
   Parametro: objId : Id do objeto a ser escondido ou mostrado
   Ex.1: mostraEsconde('box1');
**************************** */


function mostraEsconde(objManipuladorRef,objManipuladoId,imgMostra,imgEsconde){
	
	var objManipulado= document.getElementById(objManipuladoId)
	
	    if (objManipulado.style.display == 'block'){
			objManipulado.style.display = 'none';
		    if ((imgMostra != null) && (imgEsconde!= null)){
			    //Chamada da função externa
				swapImage(objManipuladorRef,imgMostra)
			}			
			return;
		}
	    if (objManipulado.style.display == 'none'){
			objManipulado.style.display = 'block';
		    if ((imgMostra!= null) && (imgEsconde!= null)){
			    //Chamada da função externa
				swapImage(objManipuladorRef,imgEsconde)
			}						
			return;
		}
		

		
	}


// Gera numeros randomicos
//  Parametro: Limite do internalo
//  Exemplo:randomNumber(10) -> Retonará um numero entre 0 e 10
function randomNumber(limit){
  return Math.floor(Math.random()*limit);
}

// Escreve Cookie
// armazena a string "my name" no cookie "myCookie"  expirando em 24 Hrs.
// Exemplo: writeCookie("myCookie", "my name", 24);
function writeCookie(name, value, hours)
{
  var expire = "";
  if(hours != null)
  {
    expire = new Date((new Date()).getTime() + hours * 3600000);
    expire = "; expires=" + expire.toGMTString();
  }
  document.cookie = name + "=" + escape(value) + expire;
}
// Ler Cookie
// Exemplo:
// alert( readCookie("myCookie") );
function readCookie(name)
{
  var cookieValue = "";
  var search = name + "=";
  if(document.cookie.length > 0)
  { 
    offset = document.cookie.indexOf(search);
    if (offset != -1)
    { 
      offset += search.length;
      end = document.cookie.indexOf(";", offset);
      if (end == -1) end = document.cookie.length;
      cookieValue = unescape(document.cookie.substring(offset, end))
    }
  }
  return cookieValue;
}

// Abre Janela Popup centralizado na tela
  function openIT(url,w,h){
  try{
      jan.close();
      }
   catch(e){
     null;
   }
   finally{
	   jan = window.open(url,null,'left='+(screen.width - w)/2 +',top='+(screen.height - h)/2 +',height='+ h +',width='+ w +',status=no,toolbar=no,menubar=no,location=no');
	   jan.focus();
   }
  }

// Valida email
function validaEmail(mail)

{	
		var value = String(mail);
		if (value==""){
			alert("O campo e-mail deve ser preenchido");
			return false;
		}

		var emailOption, tipoEmailOption;	
		var reMail = '^[a-zA-Z][\\w\\.-_]*[a-zA-Z0-9]@[a-zA-Z0-9][\\w\\.-]*[a-zA-Z0-9]$';				
		reMail = new RegExp(reMail,'gi');

		if(!reMail.test(value)) {
			alert("Preencha corretamente o campo e-mail");
			return false;

		}

	return true;

}

// Valida email
function isEmail(mail)

{	
		var value = String(mail);
		if (value==""){
			return false;
		}

		var emailOption, tipoEmailOption;	
		var reMail = '^[a-zA-Z][\\w\\.-_]*[a-zA-Z0-9]@[a-zA-Z0-9][\\w\\.-]*[a-zA-Z0-9]$';				
		reMail = new RegExp(reMail,'gi');

		if(!reMail.test(value)) {
			return false;
		}
	return true;
}


//-->
