var activeTab='TAB1';

function SelectTab(sTabName) {

	// If the selected tab is the active one, there is nothing to do
	if (sTabName==activeTab) return;

	try{
		// Check to see which "syntax" to use (allows for all browsers)
		if (document.getElementById)
		{
		// this is the way the standards work
		var style2 = document.getElementById(sTabName).style;
		style2.display = 'block';
		var style2 = document.getElementById(activeTab).style;
		style2.display = 'none';
		var oTitle = document.getElementById(sTabName + '_TITLE');
		// oTitle.attributes('class').value = 'TabNavOn';
		oTitle.className = 'TabNavOn';
		var oTitle = document.getElementById(activeTab + '_TITLE');
		// oTitle.attributes('class').value = 'TabNavOff';	
		oTitle.className = 'TabNavOff';		
		var oTitle = document.getElementById(sTabName + '_A');
		// oTitle.attributes('class').value = 'TabNavOn';
		oTitle.className = 'TabNavOn';		
		var oTitle = document.getElementById(activeTab + '_A');
		// oTitle.attributes('class').value = 'TabNavOff';		
		oTitle.className = 'TabNavOff';		
		}
		else if (document.all)
		{
		// this is the way old msie versions work
		var style2 = document.all[sTabName].style;
		style2.display = 'block';
		style2.visibility = 'visible';
		var style2 = document.all(activeTab).style;
		style2.display = 'none';
		style2.visibility = 'hidden';
		var oTitle = document.all(sTabName + '_TITLE');
		oTitle.className = 'TabNavOn';
		var oTitle = document.all(activeTab + '_TITLE');
		oTitle.className = 'TabNavOff';	
		var oTitle = document.all(sTabName + '_A');
		oTitle.className = 'TabNavOn';
		var oTitle = document.all(activeTab + '_A');
		oTitle.className = 'TabNavOff';			
		}
		else if (document.layers)
		{
		// this is the way nn4 works
		var style2 = document.layers[sTabName].style;
		style2.display = 'block';
		style2.visibility = 'visible';
		var style2 = document.layers(activeTab).style;
		style2.display = 'none';	
		style2.visibility = 'hidden';
		var oTitle = document.layers(sTabName + '_TITLE');
		oTitle.className = 'TabNavOn';
		var oTitle = document.layers(activeTab + '_TITLE');
		oTitle.className = 'TabNavOff';	
		var oTitle = document.layers(sTabName + '_A');
		oTitle.className = 'TabNavOn';
		var oTitle = document.layers(activeTab + '_A');
		oTitle.className = 'TabNavOff';		
		}
	}catch(e){
		// Do Nothing - Ignore
	}finally{
		// Save the new tab as Active
		activeTab=sTabName;
	}
}
<!-- End Tab Display/Hide -->

function escolhe_lingua(lingua_id)
{

	if (lingua_id=='English'){
		window.location.href = 'EN/index.asp'
	}

	if (lingua_id=='Español'){
		window.location.href = 'ES/index.asp'
	}


}

function escolhe_lingua_ingles(lingua_id)
{

	if (lingua_id=='Español'){
		window.location.href = '../ES/index.asp'
	}

	if (lingua_id=='Portuguese'){
		window.location.href = '../index.asp'
	}
	
		

}

function escolhe_lingua_espanhol(lingua_id)
{

	if (lingua_id=='English'){
		window.location.href = '../EN/index.asp'
	}

	if (lingua_id=='Español'){
		window.location.href = '#'
	}

}

function escolhe_lingua_paraguai(lingua_id)
{

	if (lingua_id=='English'){
		window.location.href = 'http://www.starwoodhotels.com/sheraton/property/overview/index.html?propertyID=1450'
	}

	if (lingua_id=='Español'){
		window.location.href = '../paraguay/index.asp'
	}

	if (lingua_id=='Portuguese'){
		window.location.href = '../paraguai/index.asp'
	}
	
		

}


/*
function include(arquivo){

	//By Anônimo e Micox - http://elmicox.blogspot.com
	var novo = document.createElement("<script>");
	novo.setAttribute('type', 'text/javascript');
	novo.setAttribute('src', arquivo);
	
	document.getElementsByTagName('body')[0].appendChild(novo);
	//apos a linha acima o navegador inicia o carregamento do arquivo
	//portanto aguarde um pouco até o navegador baixá-lo. :)
}
*/

function fotoSlide(n,tempo,fotoId,fotoArray){

	//Trocando a foto
	document.getElementById(fotoId).setAttribute('src',eval(fotoArray+'[n]'));
	
	//Incrementando o número da foto
	n++;
	
	//Verificando se é a última foto
	if( n == eval(fotoArray+'.length') ){n = 0};
	
	//Contando tempo e chamando novamente a função
	setTimeout(String('fotoSlide(').concat(n, ",", tempo, ",'", fotoId, "','", fotoArray, "')"), tempo * 1000);

}

//Função para exibir data e Hora
function dataHora(nomeDiv){

	arrayDia = new Array("Domingo","Segunda-feira","Terça-feira","Quarta-feira","Quinta-feira","Sexta-feira","Sábado"); 
	arrayMes = new Array("janeiro","fevereiro","março","abril","maio","junho","julho", "agosto","setembro","outubro","novembro","dezembro"); 
	
	objData = new Date(); 
	ano = objData.getFullYear(); 
	mes = objData.getMonth(); 
	data = objData.getDate(); 
	dia = objData.getDay(); 
	hora = objData.getHours(); 
	minuto = objData.getMinutes(); 
	segundo = objData.getSeconds(); 

	if (hora < 10) { hora = "0" + hora; } 
	if (minuto < 10)  { minuto = "0" + minuto; } 
	if (segundo < 10)  { segundo = "0" + segundo; } 

	//txt = arrayDia[dia]+", "+data+" de " +arrayMes[mes]+" de "+ano+" - "+hora+":"+minuto+":"+segundo;
	
	txt = +data+"/" +mes+"/"+ano+" - "+hora+":"+minuto+":"+segundo;

	document.all[nomeDiv].innerHTML = txt; 
	
	setTimeout("dataHora('"+nomeDiv+"')",1000); 
} 

function getDataAtual(){
	data = new Date();

	dia = data.getDate();
	mes = data.getMonth()+1;
	ano = data.getUTCFullYear();

	return String(dia).concat('/',mes,'/',ano);
}


//Função para verificar os itens do formulário
function verificaForm(form){
	
	//Capturando o formulário
	var formulario = document.getElementById(form);
	
	//Verificando quantos elementos tem o formulário
	var numElementos = formulario.length;
	
	//Verificando seu elementos
	for (x=0; x < numElementos; x++){
		
		//alert(x);
		
		//Verificando se o campo é requerido
		if( (formulario.elements[x].getAttribute('requerido') == "true") && (validaRequerido(formulario.elements[x])) )return false;

		//Verificando existe tamanho máximo de caracteres			
		if((formulario.elements[x].getAttribute('maxCaracteres') != "") && validaMaxCaracteres(formulario.elements[x]))return false;

		//Verificando existe tamanho mínimo de caracteres			
		if((formulario.elements[x].getAttribute('minCaracteres') != "") && validaMinCaracteres(formulario.elements[x]))return false;

		//Verificando o tipo do campo caso seja dinheiro			
		if((formulario.elements[x].getAttribute('tipo') == "dinheiro") && validaTipoDinheiro(formulario.elements[x]))return false;

		//Verificando o tipo do campo caso seja numérico			
		if((formulario.elements[x].getAttribute('tipo') == "numero") && validaTipoNum(formulario.elements[x]))return false;

		//Verificando o tipo do campo caso seja letras			
		if((formulario.elements[x].getAttribute('tipo') == "letra") && validaTipoLetra(formulario.elements[x]))return false;

		//Verificando se o campo é uma url válida			
		if((formulario.elements[x].getAttribute('tipo') == "URL") && validaTipoURL(formulario.elements[x]))return false;

		//Verificando se o e-mail é válido			
		if((formulario.elements[x].getAttribute('tipo') == "email") && validaTipoEmail(formulario.elements[x]))return false;

		//Comparando os valores dos campos		
		if((formulario.elements[x].getAttribute('comparar') != null) && (validaComparar(formulario.elements[x])))return false;

	}

}

//Exibindo o calendário
function calendario(campoNome,referencia,xPosicao,yPosicao){
	
	
	if(referencia != null){
	
		var valorRef = document.getElementById(referencia).value;
		
	}
	
	abrePop(String('../biblio/asp/calendario.asp').concat('?campo=',campoNome,'&ref=',valorRef),'divPopCalendario',xPosicao,yPosicao);
	
}

//Verificando se o campo é requerido
function validaRequerido(objeto){
	
	//alert('teste');

	if(objeto.value == ""){
		objeto.focus();

		if(objeto.readOnly){
			alert("Favor preencher o campo '"+objeto.getAttribute('nome')+"'!");		
		}else{
			alert('Favor preencher este campo!');		
		}
		
		return true;
	}
	
}



//Verificando existe tamanho máximo de caracteres
function validaMaxCaracteres(objeto){

	if(objeto.value.length > parseInt(objeto.maxCaracteres)){
		objeto.focus();
		alert('Máximo de ' + objeto.maxCaracteres + ' caracteres permitidos!');
		return true;
	}
}

//Verificando existe tamanho mínimo de caracteres
function validaMinCaracteres(objeto){

	if(objeto.value.length < parseInt(objeto.minCaracteres) ){
		objeto.focus();
		alert('Mínimo de ' + objeto.minCaracteres + ' caracteres permitidos!');
		return true;
	}
}


//Verificando o tipo do campo caso seja numérico
function validaTipoNum(objeto){

	if( isNaN(objeto.value) ){
		objeto.focus();
		alert('Favor preencher este campo somente com números!');
		return true;
	}
}

//Verificando o tipo do campo caso seja dinheiro
function validaTipoDinheiro(objeto){
	
	if(validaTipoNum(objeto)){
		return true;
	}else{
		
	}

}

//Verificando o tipo do campo caso seja numérico
function validaTipoLetra(objeto){

	for(numCont=0; numCont <= 9; numCont++){
		
		if(objeto.value.indexOf(String(numCont)) != -1){
			objeto.focus();
			alert('Favor preencher este campo somente com letras!');
			return true;
		}
	}
}

//Verificando se o campo é uma url válida
function validaTipoURL(objeto){

	if(objeto.value != ""){

		//Convertendo os caracteres para minúsculo
		objString = new String(objeto.value);
		var valor = objString.toLowerCase();
		var erro = 0;
	
		if(valor.indexOf("http://")==-1){
			erro=1;
		}else if(objeto.value.indexOf(".")==-1){
			erro=2;
		}

		if( erro != 0 ){
			alert("Por favor, preencha este campo com uma URL válida!");
			objeto.focus();
			return true;
		}
	}
}

//Verificando se o e-mail é válido
function validaTipoEmail(objeto){

	if(objeto.value != ""){

		var erro = 0;
	
		if(objeto.value.indexOf("@")==-1){
			erro = 1;		
		}else if(objeto.value.indexOf(".")==-1){
			erro = 2;
		}else if( objeto.value.indexOf("@") != objeto.value.lastIndexOf("@") ){
			erro = 3;
		}

		if( erro != 0 ){
			alert("Por favor, preencha este campo com um E-mail válido!");
			objeto.focus();
			return true;
		}
	}
}

//Comparando dois valores
function validaComparar(objeto){
	
	//Declarando a variável para conter o resultado do teste
	var teste;
	//Declarando a variável para conter o operador e os alvos
	var arrayValor = new Array();
	
	//Caso não tenha operador, automaticamente será igualdade
	if(objeto.getAttribute('comparar').indexOf(',')==-1)objeto.setAttribute('comparar',String('==,').concat(objeto.getAttribute('comparar')));
	
	//Separando o operador dos alvos da comparação
	arrayValor = objeto.getAttribute('comparar').split(',');
	var operador = arrayValor[0];
	
	//Definindo quais são os alvos da comparação
	var alvo1 = objeto.id;
	var alvo2 = arrayValor[1];
	
	//Verificando qual a operação solicitada e quias são os tipos de valores
	if(arrayValor[0].indexOf('==') != -1){
		
		teste = comparaIgual(alvo1,alvo2);
	}else if(objeto.value.indexOf(':') != -1){
		
		teste = comparaHora(alvo1,alvo2,operador);
	}else if(objeto.value.indexOf('/') != -1){
		
		teste = comparaData(alvo1,alvo2,operador);
	}else{
		
		teste = comparaNum(alvo1,alvo2,operador);
	}

	//Caso não tenha algum sinal de comparação
	if(!teste){
		objeto.focus();
		alert('Valor incorreto!');
		return true;
	}

}

//Função para comparar horas
function comparaHora(alvo1,alvo2,comparacao){
	
	//Recuperando os objetos alvo
	var objeto1 = document.getElementById(alvo1);
	var objeto2 = document.getElementById(alvo2);
	
	//Criando arrays para conter os valores
	var array1 = new Array();
	var array2 = new Array();
	
	var array1 = objeto1.value.split(':');
	var array2 = objeto2.value.split(':');	
	
	//Criando objetos para conter as horas
	var tempo1 = new Date();
	var tempo2 = new Date();
	
	tempo1.setHours(array1[0],array1[1],array1[2]);
	tempo2.setHours(array2[0],array2[1],array2[2]);
	
	return eval('tempo1 '+comparacao+' tempo2');
}

//Função para comparar datas
function comparaData(alvo1,alvo2,comparacao){
	
	//Recuperando os objetos alvo
	var objeto1 = document.getElementById(alvo1);
	var objeto2 = document.getElementById(alvo2);
	
	//Criando arrays para conter os valores
	var array1 = new Array();
	var array2 = new Array();
	
	var array1 = objeto1.value.split('/');
	var array2 = objeto2.value.split('/');	
	
	//Criando objetos para conter as datas
	var tempo1 = new Date();
	var tempo2 = new Date();
	
	tempo1.setHours(array1[2],array1[1],array1[0]);
	tempo2.setHours(array2[2],array2[1],array2[0]);
	
	return eval('tempo1 '+comparacao+' tempo2');
}

//função para comparar valores
function comparaNum(alvo1,alvo2,comparacao){

	//Recuperando os objetos alvo
	var objeto1 = document.getElementById(alvo1);
	var objeto2 = document.getElementById(alvo2);
	
	//Criando arrays para conter os números
	var valor1 = parseInt(objeto1.value);
	var valor2 = parseInt(objeto2.value);
	
	return eval('valor1 '+comparacao+' valor2');
}

//função para comparar valores
function comparaIgual(alvo1,alvo2){

	//Recuperando os objetos alvo
	var objeto1 = document.getElementById(alvo1);
	var objeto2 = document.getElementById(alvo2);
	
	//Criando arrays para conter os números
	var valor1 = objeto1.value;
	var valor2 = objeto2.value;
	
	return eval('valor1 == valor2');
}

//Abre janela pop-up
function popup(nome,url,width,height,parametros){
	
	return window.open(url,nome,'width='+width+', height='+height+','+parametros);
	
}

//Função que verifica se o objeto é do tipo Object
function isObject(objeto){
	if(typeof(objeto) == 'object')return true;
}

//Função que verifica se o objeto é do tipo Array
function isArray(objeto){
	if(isObject(objeto) && objeto.constructor == Array)return true;
}

function mascaraValor(alvo,mascara){
	
	if(typeof(alvo) == 'object'){
		var objeto = alvo;
	}else{
		var objeto = document.getElementById(alvo);
	}
	
	valorReal = new String(objeto.value);
	valorFinal  = new String();
	valorPuro = new String(objeto.value);
	caractEspeciais = new String();
	
	if(valorReal.length > mascara.length){
		valorReal = valorReal.substring(0,mascara.length)
	}
	   
	//Verificando quais são os caracteres especiais
	for(x=1; x <= mascara.length; x++){
		if(mascara.charAt(x-1) != 'x')caractEspeciais += mascara.charAt(x-1);
	}
	
	//Retirando os caracteres especiais do valor real
	for(x=0; x <= valorReal.length; x++){
		
		if( (caractEspeciais.indexOf(valorReal.charAt(x-1)) != -1) ){
			valorReal = valorReal.substring(0,x-1) + valorReal.substring(x,valorReal.length);
		}
	}
	
	var cont = 0;
	

	//Substituindo os caracteres do valor real pelos da mascara	onde forem diferentes de x
	for(x=0; x < valorReal.length; x++){
		
		if(mascara.charAt(x + cont) == 'x'){
			valorFinal += valorReal.charAt(x);
		}else{	
			if(mascara.charAt(x + cont) != valorReal.charAt(x)){
				valorFinal += mascara.charAt(x + cont) + valorReal.charAt(x);
				cont = cont + 1;
			}else{
				valorFinal += valorReal.charAt(x);
			}
		}

	}
	
	//Retornando o valor formatado
	objeto.value = valorFinal;
}

