//===============================================================================================================================
// Verifica browser
//
function isCurrentBrowser(browserName) {	
	if(navigator.userAgent.search(browserName) != -1)
		return true;
	else
		return false;
}

//===============================================================================================================================
// Monta os flashs no site
//
function flash(piWid, piHei, psSrc, psId, psTitulo, psMode) {
	var strSwf;
	if (isCurrentBrowser("MSIE")) {
		strSwf = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\" id="+psId+" width="+piWid+" height="+piHei+">";
		strSwf += "<param name=\"movie\" value="+psSrc+" />";
		strSwf += "<param name=\"allowScriptAccess\" value=\"sameDomain\" />";
		strSwf += "<param name=\"quality\" value=\"high\" />";
		strSwf += "<param name=\"wmode\" value="+psMode+"  />";
		if (psTitulo != "")
			strSwf += "<param name=\"FlashVars\" value=\"titulo="+psTitulo+"\" />";
		strSwf += "<embed id="+psId+" name="+psId+" allowScriptAccess=\"sameDomain\" swLiveConnect=\"true\" src="+psSrc+" quality=\"high\" wmode=\"transparent\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width="+piWid+" height="+piHei+"></embed></object>";
	} else {
		strSwf = "<object type=\"application/x-shockwave-flash\" data="+psSrc+" width="+piWid+" height="+piHei+" />";
		strSwf += "<param name=\"quality\" value=\"high\" />";
		strSwf += "<param name=\"wmode\" value="+psMode+"  />";
		strSwf += "<param name=\"allowScriptAccess\" value=\"sameDomain\" />";
		if (psTitulo != "")
			strSwf += "<param name=\"FlashVars\" value=\"titulo="+psTitulo+"\" />";
	}
	this.document.write(strSwf);
} 

//===============================================================================================================================
// Funcao usada para autocompletar
//
function upperCase(event) { 
   var keynum; 

   // IE 
   if (window.event) { 
	  keynum = event.keyCode; 
   } 
   // Netscape/Firefox/Opera 
   else if (event.which) { 
	  keynum = event.which; 
   } 

   if ((keynum >= 97 && keynum <= 122) || (keynum >= 224 && keynum <= 255)) { 
	  // converte de acordo com o valor decimal da tecla na tabela ascii    
	  keynum = keynum - 32; 
	   
	  // IE 
	  if (window.event) { 
		 window.event.keyCode = keynum; 
	  } 
	  // firefox e outros que usam o Gecko 
	  else if (event.which) { 
		 var newEvent = document.createEvent("KeyEvents"); 
		 newEvent.initKeyEvent("keypress", true, true, document.defaultView, 
				  event.ctrlKey, event.altKey, event.shiftKey, 
				  event.metaKey, 0, keynum); 
		 event.preventDefault(); 
		 event.target.dispatchEvent(newEvent); 
	  } 
   } 
	
   return true; 
}

function MascaraCEP (keypress, objeto)
{
	campo = eval (objeto);
	caracteres = '01234567890';
	separacoes = 1;
	separacao1 = '-';
	conjuntos = 2;
	conjunto1 = 5;
	conjunto2 = 3;
	if ((caracteres.search(String.fromCharCode (keypress))!=-1) && campo.value.length < (conjunto1 + conjunto2 + 1))
	{
		if (campo.value.length == conjunto1) 
			campo.value = campo.value + separacao1;
	}
	else 
		event.returnValue = false;
}

function formatadata(obj, tecla)
{
   if (tecla.keyCode == 8)
      return true; 
   var continuar = false;	  
   if ((tecla.keyCode >= 48) && (tecla.keyCode <= 57)) { continuar = true; }
   if ((tecla.keyCode >= 96) && (tecla.keyCode <= 105)) { continuar = true; }
   if ((tecla.keyCode == 46) || (tecla.keyCode == 8)) { continuar = true; }
   if (continuar == false)
     return false;

   vlr = obj.value;
   vlr2 = "";
   vlr = vlr.replace("/","");
   vlr = vlr.replace("/","");
   vlr2 = vlr2 + vlr.substr(0,2);
   if (vlr.length >= 2) 
     vlr2 = vlr2 + "/";
   vlr2 = vlr2 + vlr.substr(2,2);
   if (vlr.length >= 4) 
     vlr2 = vlr2 +"/";
   vlr2 = vlr2 + vlr.substr(4,4);
   obj.value = vlr2;
   return true;
}
function sonumero(mobjeto, mevento)
{
  if ((mevento.keyCode >= 48) && (mevento.keyCode <= 57)) { return true; }
  //if ((mevento.keyCode >= 96) && (mevento.keyCode <= 105)) { return true; }
  if ((mevento.keyCode == 46) || (mevento.keyCode == 8)) { return true; }
  return false;
}  

function Abre(endereco, largura, altura)  
{
   popup = window.open(endereco,"Detalhes","toolbar=0,scrollbars=0,location=0,directories=0,copyhistory=0,status=0,menubar=0,resizable=0,width="+largura+",height="+altura+",z-lock,screenX=150,screenY=100, Left=180, Top=100"); 
}

function Abre_Curriculo(endereco, largura, altura)  
{
   popup = window.open(endereco,"Detalhes","toolbar=0,scrollbars=1,location=0,directories=0,copyhistory=0,status=0,menubar=0,resizable=0,width="+largura+",height="+altura+",z-lock,screenX=10,screenY=10, Left=10, Top=10"); 
}

function SomenteNumero(e) {
    var tecla = (window.event) ? event.keyCode : e.which;
    if ((tecla > 47 && tecla < 58)) return true;
    else {
        if (tecla != 8) return false;
        else return true;
    }
}