function ExcluirRegisto(reg){
//	alert(document.getElementById("Item"));
	//if (document.getElementById("Item").checked == false){
	//	alert('Selecione um item para ser excluido');
	//}else{
	form1.submit();
	//}
}

function AtivaFeira(id,tipo){
	if(confirm('Deseja realmente ativar essa Feira?')){
	document.form1.action = '?strCaminho=feiras/controle&intConteudo=0&txtCod='+id+'&Tipo='+tipo;
	document.form1.submit();
	}
}

function AtivarEnquete(valor){
	if(confirm('Deseja realmente ativar essa Enquete?')){
	document.form1.action = '?strCaminho=enquete/controle&intConteudo=0&valor='+valor;
	document.form1.submit();
	}
}
function DesativaEnquete(valor){
	if(confirm('Deseja realmente Desativar essa Enquete?')){
	document.form1.action = '?strCaminho=enquete/controle&intConteudo=0&valor='+valor;
	document.form1.submit();
	}
}


function ExcluiFoto(id,codigo){
	if(confirm('Deseja realmente Excluir essa Foto?')){
	document.form.action = '?strCaminho=galeria/controle&intConteudo=6&id='+codigo+'&txtFoto='+id;
	document.form.submit();
	}
}

function ExcluiFotos(){
	if(confirm('Deseja realmente Excluir essa(s) Foto(s)?')){
	//document.form.action = '?strCaminho=galeria/controle&intConteudo=6&id='+codigo+'&txtFoto='+id;
	document.form.submit();
	}
}

function Contato(){
	
	var C = document.Form1;
	if(C.txtNome.value==""){
		alert("Por favor!\nPreencha seu Nome.");
		C.txtNome.focus();
		return false;
	}
	if(C.txtEmail.value==""){
		alert("Por favor!\nPreencha seu E-mail.");
		C.txtEmail.focus();
		return false;
	}	
	if(C.txtEmail.value.indexOf("@") ==-1 || C.txtEmail.value.indexOf(".") == -1){
		alert("Endereço de E-mail inválido!");
		C.txtEmail.focus();
		return false;
	}		
	if(C.txtDdd.value==""){
		alert("Por favor!\nPreencha seu Ddd.");
		C.txtDdd.focus();
		return false;
	}	
	if(C.txtDdd.value.length < 2 ){
		alert("Atenção!\nO Ddd deve conter 2 dígitos.");
		C.txtDdd.focus();
		return false;
	}	
	if(C.txtTelefone.value==""){
		alert("Por favor!\nPreencha seu Telefone.");
		C.txtTelefone.focus();
		return false;
	}		
	if(C.txtTelefone.value.length < 9 ){
		alert("Atenção!\nO Telefone deve conter 8 dígitos.");
		C.txtTelefone.focus();
		return false;
	}		
	if(C.txtDestino.value==""){
		alert("Por favor!\nSelecione a Área desejada.");
		C.txtDestino.focus();
		return false;
	}			
	if(C.txtMensagem.value==""){
		alert("Por favor!\nPreencha sua Mensagem.");
		C.txtMensagem.focus();
		return false;
	}		
	
}


function Numeros(onde){
	var valid = "0123456789-";
	var situa = true;
		for(i=0;i<onde.value.length;i++){
			if(valid.indexOf(onde.value.charAt(i))== -1){
			situa = false;
			}
		}
	if (!situa){
	alert("Digite somente Números!");
	onde.focus();
	onde.select();
	}
}


function Fone(onde,qual){
			if(onde.value.length == 4){
				onde.value += qual;
			}
}


function Ceps(onde,qual){
			if(onde.value.length == 5){
				onde.value += qual;
			}
}

function ConvertAlta(onde){
	onde.value = onde.value.toUpperCase();	
}


function Logar(){
	if(document.form.login.value.indexOf("@") ==-1 || document.form.login.value.indexOf(".") == -1){
		alert("Endereço de E-mail inválido!");
		document.form.login.focus();
	}		
	else if(document.form.senha.value==""){
		alert("Por favor!\nPreencha sua Senha.");
		document.form.senha.focus();
	}	
	else{
		document.form.submit();
	}
}

function EscondeReferencia(){
	document.getElementById("referencia").style.display = "none";
}

function MostraReferencia(){
	document.getElementById("referencia").style.display = "block";
}


var arrInput = new Array(0);
  var arrInputValue = new Array(0);

function adicionar_resp() {
   arrInput.push(arrInput.length);
  //arrInputValue.push(arrInputValue.length);
  arrInputValue.push("");
  
  document.getElementById('n_res').value = (parseInt(document.getElementById('n_res').value)+1);
  display();
}

function display() {
  document.getElementById('resp').innerHTML="";
  for (intI=0;intI<arrInput.length;intI++) {
    document.getElementById('resp').innerHTML+=createInput(arrInput[intI], arrInputValue[intI]);
  }
}

function saveValue(intId,strValue) {
  arrInputValue[intId]=strValue;
}  

function createInput(id,value) {
  return "<input type='text' name='resp"+id+"'  id='Resposta "+(parseInt(id)+1)+"' onChange='javascript:saveValue("+id+",this.value)' value='"+ value +"'><br>";
}

function deletar_resp(){
  if (arrInput.length > 2) { 
     if (arrInput.length > 0) { 
     arrInput.pop(); 
     arrInputValue.pop();
  }
  display();  
  }
  else {alert('A Enquete deve conter pelo menos 2 respostas!');}
//alert(arrInput.length);
 
}

// Função para contar os caracteres dos campos
function getObject(obj) {
  var theObj;
  if(document.all) {
    if(typeof obj=="string") {
      return document.all(obj);
    } else {
      return obj.style;
    }
  }else{
	  if(document.getElementById) {
		if(typeof obj=="string") {
		  return document.getElementById(obj);
		} else {
		  return obj.style;
		}
	  }
  }
  return null;
}


//Contador de caracteres.
function Contar(entrada,salida,texto,caracteres) {
  var entradaObj=getObject(entrada);
  var salidaObj=getObject(salida);
  var longitud = caracteres - entradaObj.value.length;
  if(longitud <= 0) {
    longitud=0;
    texto='<span id=mostra> '+texto+' </span>';
    entradaObj.value=entradaObj.value.substr(0,caracteres); 
	alert('Número máximo de caracteres atingido.');
  }

  salidaObj.innerHTML = texto.replace("{CHAR}",longitud);
}


//Atualiza com refresh
function VerificaRegistros(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}


//Pop Up de fotos redimecionável
function ExibirGaleria(id,caminho){
	objPopUp = window.open('/include_global/asp/pop.asp?id='+id+'&caminho='+caminho,'PopUP','width=200,height=200,left=100,top=100');
	objPopUp.focus();
}


//Atualiza COmbo de curso dinamicamente
atual = 0
function CarregaCurso(id,iniciaem,destino,inicia){
    var conteudo=document.getElementById(destino)
    conteudo.innerHTML='<select><option>carregando...</option></select>'
    try{
		xmlhttp = new XMLHttpRequest();
	}
	catch(ee){
		try{
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		}catch(e){
			try{
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			}catch(E){
				xmlhttp = false;
			}
		}
	}
    //Abre a url
    xmlhttp.open("GET", "../../../include_global/asp/cursos.asp?id_Instituicao="+id+"&inicia="+inicia,true);
 
	 //Executada quando o navegador obtiver o código
    xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4){
            //Lê o texto
            var texto=xmlhttp.responseText
            //Desfaz o urlencode
            texto=texto.replace(/\+/g," ")
            texto=unescape(texto)
            //Exibe o texto no div conteúdo
            var conteudo=document.getElementById(destino)
            conteudo.innerHTML=texto
        }
    }
    xmlhttp.send(null)
}

// Exibe e esconde as respostas das dúvidas
function OcultarExibir(obj){
	if(document.getElementById){
	var el = document.getElementById(obj);
	var ar = document.getElementById("contScrollDuvidas").getElementsByTagName("h1"); //DynamicDrive.com change
		if(el.style.display != "block"){ //DynamicDrive.com change
			for (var i=0; i<ar.length; i++){
				if (ar[i].className=="submenu") //DynamicDrive.com change
				ar[i].style.display = "none";
			}
			el.style.display = "block";
		}else{
			el.style.display = "none";
		}
	}
}

//Tipo de cadastro Visitante ou empresa
function TipoCadastro(id,idd){
	if(id==1){
		window.location.href='?strConteudo=visitante.asp&id_menu='+idd;
	}
	else if(id==2){
		window.location.href='?strConteudo=noivas_noivos.asp&id_menu='+idd;
	}
	else{
		window.location.href='?strConteudo=empresa.asp&id_menu='+idd;	
	}
}

// Pop Solicita senha
function SolicitaSenha(Tipo){
	objPopUp = window.open('/include_global/asp/senha.asp?Tipo='+Tipo,'Senha','width=250,height=180,left=100,top=100');
	objPopUp.focus();
}


//Função para alterar Stand
function RelacionaStand(Id,Feira){
	objPopUp = window.open('/admin/planta/controle/relacionar.asp?Stand='+Id+'&Feira='+Feira,'Stand','width=400,height=350,left=100,top=100,scrollbars=no');
	objPopUp.focus();
}


//Excluir Empresas relacionadas a stand 
function ExcluiStand(stand,feira){
	if(confirm('Deseja realmente Excluir essa Empresa?')){
	document.form.action = '?Excluir=Sim&Stand='+stand+'&Feira='+feira;
	document.form.submit();
	}
}

function AtualizaStant(tipo,Codigo){
	if(tipo==1){//admin
		window.opener.parent.location.href='/admin/main.asp?strCaminho=planta/controle&id='+Codigo+'&IntConteudo=6';
	}
	else{//Site
		window.location.href='/pt_br/expositores/planta/default.asp?id_menu=2&Codigo='+Codigo;
	}
}
// Pop Solicita senha
function Janela(pagina,w,h){
	objPopUp = window.open(pagina,'Janela','width='+w+',height='+h+',left=100,top=100,resizable=yes');
	objPopUp.focus();
}
//Visualização de Foto Ampliada
function VerFoto(imagem){
	if (imagem.length>0) {
			abretag="<"
			janela=window.open("","verfoto","width=110,height=30,tollbars=no,scrollbars=no,status=0,resizable=0");
			janela.focus();
			x=(screen.width-110)/2;
			y=(screen.height-30)/2;
			janela.moveTo(x,y);
			
			janela.document.write();

			janela.document.write(abretag+'HTML>'+abretag+'HEAD>'+abretag+'TITLE>'+abretag+'/TITLE>'+abretag+'/HEAD>'+abretag+'BODY leftmargin="5" topmargin="5">\n');


			janela.document.write(abretag+'script language="JavaScript">\n');

			janela.document.write('function VerFoto_amplia(){\n');
			janela.document.write('	x=document.images[0].width+30;\n');
			janela.document.write('	y=document.images[0].height+58;\n');


			janela.document.write('	x1=(screen.width-x)/2;\n');
			janela.document.write('	y1=(screen.height-y)/2;\n');

			janela.document.write(' self.moveTo(x1,y1);\n');
			janela.document.write('	self.resizeTo(x,y);\n');
			janela.document.write('	imagem.style.visibility="visible";\n');
			janela.document.write('	carregando.style.visibility="hidden";\n	}\n');

			janela.document.write(abretag+'/script>');


			janela.document.write('<div id="carregando" style="visibility:visible;top:20px;left:23;position:absolute" align=center><font face=arial,verdana size=2><B>AGUARDE</B><br><br>Carregando <BR>imagem</font></div>');

			janela.document.write('<div id="imagem" style="visibility:hidden">');
			janela.document.write('<a href="javascript:self.close()"><img border=0 src="'+imagem+'" onload=javascript:VerFoto_amplia();></a>');
			janela.document.write('</div>'+abretag+'/body>'+abretag+'/html>');


	} else alert("Atenção:\n Nenhuma arquivo de imagem foi definido para abrir!");
}
