function ExibiPagCarregando(){
	$("#abreConteudo").load("pag_carregando.asp");
}

function CarregaPagina(url)
{
    $("#abreConteudo").load(url);
}

/*
 * Cria Div com o Fundo Preto
 * Autor: Roberto Vieira
 * Data: 14/10/2008
 */
function divFundo(){
	var bodyPage = document.getElementsByTagName("body")[0];
	arrayPageSize = getPageSize();
	if (document.createElement){
		var	novaDiv = document.createElement('div');	  
		novaDiv.setAttribute("id","fundoPreto");		
		novaDiv.style.height = arrayPageSize[1] + "px";
		bodyPage.appendChild(novaDiv);
	}
}

function divConteudo(w,h,fundo){
	var bodyPage = document.getElementsByTagName("body")[0];
	arrayPageSize = getPageSize();
	if (document.createElement){
		var	novaDiv = document.createElement('div');	  
		novaDiv.setAttribute("id","abreConteudo");		
		novaDiv.style.width = w;
		novaDiv.style.height = h;
		if(fundo){novaDiv.style.background=fundo;}
		
		novaDiv.style.left = "50%";	
		novaDiv.style.top = "50%";			
		//novaDiv.style.left = Left(w,arrayPageSize[1]) + 'px';
		//novaDiv.style.top = Top(h,arrayPageSize[3]) + 'px';
		bodyPage.appendChild(novaDiv);
	}
}


function abreDiv(url,fechaClique,w,h,fundo)
{
	    escondeSelect();
	    divFundo();//Cria a Div com fundo Preto;
	    divConteudo(w,h,fundo);//Cria a Div onde vai o conteudo;
	    ExibiPagCarregando();//Exibi carregando até a pagina carregar;
	    
	    //Exibi as Divs
	    //$("#fundoPreto").show();
	    document.getElementById("fundoPreto").style.display="block";
	    document.getElementById("abreConteudo").style.display="block";
	    $("#abreConteudo").css("margin-top","-"+(h/2)+"px");
	    $("#abreConteudo").css("margin-left","-"+(w/2)+"px");
	    
	    $("#abreConteudo").load(url);
	    document.getElementById("fundoPreto").onclick =  (fechaClique) ? escondeDivs : '';	    
}

function escondeDivs()
{
	$("#abreConteudo").fadeOut("fast");
	$("#fundoPreto").fadeOut("fast");
	escondeSelect();		
}

/*
 * 
 * ESCONDE OS SELECTS
 *
 */
function escondeSelect(){
	selects = document.getElementsByTagName("select");
	for(i=0; i!=selects.length;i++){
		selects[i].style.visibility = (selects[i].style.visibility == "hidden") ? "visible" : "hidden";
	}
}
/*
 * 
 * FUNÇÕES PARA ALINHAR A DIV
 *
 */
function Left(w,tablePx){
	var NS = (navigator.appName=="Netscape" || navigator.appName=="Opera")?true:false;
	var iWidth = (NS)?window.innerWidth:document.body.clientWidth;
	var iHeight = (NS)?window.innerHeight:document.body.clientHeight;
	
	var TamTable 	= tablePx;
    var TamPage 	= iWidth;	
	var DimTam  	= (TamPage - TamTable) / 2;
	var PosTable 	= (TamTable - w)/2;
	
	return PosTable + DimTam;
}

function Top(h,tablePx){
	var NS = (navigator.appName=="Netscape"  || navigator.appName=="Opera")?true:false;
	var iWidth = (NS)?window.innerWidth:document.body.clientWidth;
	var iHeight = (NS)?window.innerHeight:document.body.clientHeight;
	
	var TamTable 	= tablePx;
	var TamPage 	= iHeight;
	var DimTam  	= (TamPage - TamTable) / 2;
	var PosTable 	= (TamTable - h)/2;
	
	return PosTable + DimTam;
}

/**
 * Pega informacoes de resolucao do browser
 * 
 * @return array
 */
function getPageSize(){		
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.availWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}
	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}




////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// VALIDA SENHA SEGURA
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

var numeros="0123456789";
var letras="abcdefghyjklmnñopqrstuvwxyz";
var letras_mayusculas="ABCDEFGHYJKLMNÑOPQRSTUVWXYZ";
var letras_mayusculas="*@#$%&çÇ";

function tiene_numeros(texto){
   for(i=0; i<texto.length; i++){
      if (numeros.indexOf(texto.charAt(i),0)!=-1){
         return 1;
      }
   }
   return 0;
} 

function tiene_letras(texto){
   texto = texto.toLowerCase();
   for(i=0; i<texto.length; i++){
      if (letras.indexOf(texto.charAt(i),0)!=-1){
         return 1;
      }
   }
   return 0;
} 

function tiene_minusculas(texto){
   for(i=0; i<texto.length; i++){
      if (letras.indexOf(texto.charAt(i),0)!=-1){
         return 1;
      }
   }
   return 0;
} 

function tiene_mayusculas(texto){
   for(i=0; i<texto.length; i++){
      if (letras_mayusculas.indexOf(texto.charAt(i),0)!=-1){
         return 1;
      }
   }
   return 0;
} 

function tiene_caracter(texto){
   for(i=0; i<texto.length; i++){
      if (letras_mayusculas.indexOf(texto.charAt(i),0)!=-1){
         return 1;
      }
   }
   return 0;
} 

function seguridad_clave(clave){
	var seguridad = 0;
	if (clave.length!=0){
		if (tiene_numeros(clave) && tiene_letras(clave)){
			seguridad += 30;
		}
		
		if (tiene_caracter(clave)){
			seguridad += 30;
		}
				
		if (tiene_minusculas(clave) && tiene_mayusculas(clave)){
			seguridad += 30;
		}
		if (clave.length >= 6 && clave.length <= 10){
			seguridad += 10;
		}else{
			if (clave.length >= 11 && clave.length <= 18){
				seguridad += 10;
			}else{
				if (clave.length > 18 && clave.length <= 20){
					seguridad += 10;
				}
			}
		}
	}
	return seguridad				
}	

function muestra_seguridad_clave(clave,formulario){
	seguridad=seguridad_clave(clave);
	if(seguridad>=0 && seguridad <= 33){
		document.getElementById("vlrSeguranca").innerHTML = "Baixo";
	}
	else if(seguridad>=34 && seguridad <= 66)
	{
		document.getElementById("vlrSeguranca").innerHTML = "Médio";
	}
	else if(seguridad>=67 && seguridad <= 100)
	{
		document.getElementById("vlrSeguranca").innerHTML = "Alto";
	}
	else
	{
		document.getElementById("vlrSeguranca").innerHTML = "Baixo";
	}
	document.getElementById("senhaSegura").style.width = seguridad>100?100:seguridad + "%";
}


function selecionaCampo(obj)
{
    alert(obj);
    obj.focus();
}