function resultadoBusca(form){
	if(form.nome.value==''){
		alert('Digite algum nome para busca');
		form.nome.focus();
		return false;
	}
	if(form.busca[0].checked==true){
		form.action='resultado_pessoa.html';
		return true;
	}
	if(form.busca[1].checked==true){
		form.action='resultado_lugar.html';
		return true;
	}
	else{
		alert('Selecione um tipo de busca')
		return false;
	}
}



function addMinhaLista(id_lugar,id_visitante,nomelugar,doclocal){
	var vUsuario = ""
	vUsuario = id_visitante;
	if(vUsuario==0){
	  alert("Apenas para usuarios logados!");
	  window.location.href="login.aspx";
	  return false;
	}
	else{	

		document.getElementById("add_local").user_logado_post.value=id_visitante;
		document.getElementById("add_local").cod_local_post.value=id_lugar;

	    //botao.parentNode.innerHTML = '<form onSubmit="return addMinhaListaOK(this)" class="qdAddMinhaLista"><div><p>Para adicionar este lugar, selecione uma categoria.</p><select><option>Quero ir!</option><option>Vou sempre</option><option>Ja fui</option><option>Fui e nao gostei</option><option>Nunca mais vou</option></select><label class="coment">Comentario</label><textarea></textarea><label class="tags">Tags<a href="tags.html">O que sao tags?</a></label><input type="text" class="campo" /><input type="submit" class="botao btAdicionar" value="Adicionar" /></div></form>';
		var box_Add = '<br/>';
		box_Add += '<div ID="qdAddMinhaLista"><div><p>Para adicionar este lugar, selecione uma categoria.</p>';
		box_Add += '<select name="TipoComentario" id="TipoComentario">';
		box_Add += '<option value="1">Quero ir!</option>';
		box_Add += '<option value="2">Vou sempre</option>';
		box_Add += '<option value="3">J&aacute; fui</option>';
		box_Add += '<option value="4">Fui e n&atilde;o gostei</option>';
		box_Add += '<option value="5">Nunca mais vou</option>';
		box_Add += '</select>';
		box_Add += '<label class="coment">Coment&aacute;rio</label><textarea id="comentario"></textarea><label class="tags">Tags<a href="tags.aspx">O que sao tags?</a></label><input type="text" class="campo" id="tags_add"/>';
		box_Add += '<input value="" style="border:none;float:left;background-image: url(css/img/bt_voltar.gif);width: 60px;height: 30px;text-decoration: none;" onclick="javascript:window.location.reload()" type="button">'
		box_Add += '<p class="obs">(Separe suas tags por v&iacute;rgula)</p>'
		box_Add += '<input type="submit" onclick="return GM_Valida(document.getElementById(&quot;comentario&quot;).value,document.getElementById(&quot;TipoComentario&quot;).value,document.getElementById(&quot;tags_add&quot;).value,document.getElementById(&quot;add_local&quot;).cod_local_post.value);" class="botao btAdicionar" value="Adicionar" /></div></div>';

	    document.getElementById(doclocal).parentNode.innerHTML = box_Add;
    } 

	return false;
}



function AlterarMinhaLista(id_lugar,id_visitante,nomelugar,doclocal,id_comentario){
var vUsuario = ""
vUsuario = id_visitante;
if(vUsuario==0){
  alert("Apenas para usuarios logados!");
  window.location.href="login.aspx";
  return false;
}
else{
	

    document.getElementById("add_local").user_logado_post.value=id_visitante;
    document.getElementById("add_local").cod_local_post.value=id_lugar;
    document.getElementById("add_local").id_comentario_edicao.value=id_comentario;

	    //botao.parentNode.innerHTML = '<form onSubmit="return addMinhaListaOK(this)" class="qdAddMinhaLista"><div><p>Para adicionar este lugar, selecione uma categoria.</p><select><option>Quero ir!</option><option>Vou sempre</option><option>Ja fui</option><option>Fui e nao gostei</option><option>Nunca mais vou</option></select><label class="coment">Comentario</label><textarea></textarea><label class="tags">Tags<a href="tags.html">O que sao tags?</a></label><input type="text" class="campo" /><input type="submit" class="botao btAdicionar" value="Adicionar" /></div></form>';
	    var box_Add = '<br/>';
	    box_Add += '<div ID="qdAddMinhaLista"><div><p>&Aacute;rea de altera&ccedil;&atilde;o de coment&aacute;rio.</p>';
	    box_Add += '<select name="TipoComentario" id="TipoComentario">';
      var tipo = document.getElementById("add_local").tipo_comentario_post.value;
      var select_1 = '';
      var select_2 = '';
      var select_3 = '';
      var select_4 = '';
      var select_5 = '';
      if(tipo==1){
        var select_1 = 'selected=selected';
        var select_2 = '';
        var select_3 = '';
        var select_4 = '';
        var select_5 = '';
      }
      if(tipo==2){
        var select_1 = '';
        var select_2 = 'selected=selected';
        var select_3 = '';
        var select_4 = '';
        var select_5 = '';
      }

      if(tipo==3){
        var select_1 = '';
        var select_2 = '';
        var select_3 = 'selected=selected';
        var select_4 = '';
        var select_5 = '';
      }

      if(tipo==4){
        var select_1 = '';
        var select_2 = '';
        var select_3 = '';
        var select_4 = 'selected=selected';
        var select_5 = '';
      }

      if(tipo==5){
        var select_1 = '';
        var select_2 = '';
        var select_3 = '';
        var select_4 = '';
        var select_5 = 'selected=selected';
      }

      
      box_Add += '<option value="1" '+select_1+'>Quero ir!</option>';
      box_Add += '<option value="2" '+select_2+'>Vou sempre</option>';
      box_Add += '<option value="3" '+select_3+'>J&aacute; fui</option>';
      box_Add += '<option value="4" '+select_4+'>Fui e n&atilde;o gostei</option>';
      box_Add += '<option value="5" '+select_5+'>Nunca mais vou</option>';
      
      
      box_Add += '</select>';
      box_Add += '<label class="coment">Coment&aacute;rio</label><textarea id="comentario"></textarea><label class="tags">Tags<a href="tags.aspx">O que s&atilde;o tags?</a></label><input type="text" class="campo" id="tags_add"/>';
	    box_Add += '<input value="" style="border:none;float:left;background-image: url(css/img/bt_voltar.gif);width: 60px;height: 30px;text-decoration: none;" onclick="javascript:window.location.reload()" type="button">'
		box_Add += '<p class="obs">(Separe suas tags por v&iacute;rgula)</p>'
	    box_Add += '<input type="submit" onclick="return GM_Valida_2(document.getElementById(&quot;comentario&quot;).value,document.getElementById(&quot;TipoComentario&quot;).value,document.getElementById(&quot;tags_add&quot;).value,document.getElementById(&quot;add_local&quot;).cod_local_post.value,document.getElementById(&quot;add_local&quot;).id_comentario_edicao.value);" class="botao btAdicionar" value="Alterar" title="Alterar"/></div></div>';
	    document.getElementById(doclocal).parentNode.innerHTML = box_Add;
	    document.getElementById("comentario").innerHTML = document.getElementById("add_local").comentario_post.value;
	    document.getElementById("tags_add").value = document.getElementById('add_local').tags_post.value
	    
    } 

return false;
}










function GM_Valida(texto,categoria,tags,id_lugar){

  if(texto==""){
    alert("Preencha o campo comentario");
    return false;
  }
  else{
      document.getElementById("add_local").tipo_comentario_post.value=categoria;
      document.getElementById("add_local").comentario_post.value=texto;
      document.getElementById("add_local").tags_post.value=tags;
      document.getElementById("add_local").controle_add_post.value="1";
      document.getElementById("add_local").action="add_local_lista.aspx";
      document.getElementById("add_local").submit();
      window.location.href="add_local_lista.aspx?controle=1&user_logado_post="+document.getElementById("add_local").user_logado_post.value+"&cod_local_post="+id_lugar+"&tipo_comentario_post="+categoria+"&comentario_post="+texto+"&tags_post="+tags;
      alert("Comentario adicionado com sucesso!");
      window.location.reload();

  }
}



function GM_Valida_2(texto,categoria,tags,id_lugar,id_comentario){

  if(texto==""){
    alert("Preencha o campo comentario");
    return false;
  }
  else{
      document.getElementById("add_local").tipo_comentario_post.value=categoria;
      document.getElementById("add_local").comentario_post.value=texto;
      document.getElementById("add_local").tags_post.value=tags;
      document.getElementById("add_local").controle_add_post.value="2";
      document.getElementById("add_local").action="add_local_lista.aspx";
      document.getElementById("add_local").submit();
      window.location.href="add_local_lista.aspx?controle=2&id_comentario="+id_comentario+"&user_logado_post="+document.getElementById("add_local").user_logado_post.value+"&cod_local_post="+id_lugar+"&tipo_comentario_post="+categoria+"&comentario_post="+texto+"&tags_post="+tags;
      alert("Comentario alterado com sucesso!");
      window.location.reload();

  }
}




function addMinhaListaOK(form){
	form.className = '';
	form.innerHTML = '<p>Este estabelecimento foi add à sua lista</p><a href="minhas_listas_favoritas.html" class="link">clique e veja sua lista</a>';
	return false;
}




var formEnviaMsg
function enviaMsg(){
  //var botao = document.getElementById("qdEnviarMsg");
	//formEnviaMsg = botao.parentNode.innerHTML;
	var DivForm = "";
	DivForm += "<div id='FormMensagem'>";
	DivForm += "<h6>Enviar mensagem</h6>";
	DivForm += "<p>Voc&ecirc; pode enviar uma mensagem para esta pessoa. ";
	DivForm += "A mensagem ser&aacute; enviada para o e-mail que ela cadastrou.</p>";
	DivForm += "<textarea></textarea>";
	DivForm += "<input type='button' class='botao btVoltar' value='Voltar' onclick='GM_FechaFormulario_Mensagem()' />";
	DivForm += "<input type='button' class='botao btEnviar' value='Enviar' onClick='javascript:history.back()' />";
	DivForm += "</div>";
	document.getElementById("qdEnviarMsg").innerHTML = DivForm;




}

function GM_FechaFormulario_Mensagem(){
window.location.reload()
  //document.getElementById("qdEnviarMsg").innerHTML = "<input type='button' value='Enviar mensagem' class='botao btEnviarMsg' onClick='enviaMsg()' />";
}


function enviaMsgNG(form){
	form.innerHTML = formEnviaMsg;
}
function enviaMsgOK(form){
	form.innerHTML = '<p class="alerta">mensagem enviada com sucesso.</p>';
	return false;
}





var formRecado
function deixarRecado(botao){
	if (!formRecado){
		formRecado = botao.parentNode.innerHTML;
	}
	botao.parentNode.className = 'qdRecado';
	botao.parentNode.innerHTML = 'Fa&ccedil;a seu coment&aacute;rio sobre este lugar. Os internautas poder&atilde;o avaliar seu coment&aacute;rio e ele ficar&aacute; em destaque por n&iacute;vel de relev&acirc;ncia. <textarea></textarea><p class="obs">M&aacute;x. de 200 caracteres</p><input type="submit" class="botao btEnviar" value="Enviar" />'
}
function recadoOk(form){
	form.className = '';
	form.innerHTML = formRecado + '<p class="alerta">Comentário inserido com sucesso.</p>';
	return false;
}



function votar(botao){
	botao.className = 'oculto';
	botao.parentNode.parentNode.innerHTML = '<p class="alerta">Nota atribuida com sucesso.</p>' + botao.parentNode.parentNode.innerHTML
}



var formScrap;
function denunciar(botao){
	formConteudo = botao.parentNode.innerHTML;
	botao.parentNode.innerHTML = '<div class="qdMsg"><h6>DENUNCIAR ESTE COMENT&Aacute;RIO </h6><p>Coment&aacute;rios de conte&uacute;do impr&oacute;prio ser&atilde;o apagados do site.</p><p>Tem certeza que deseja denunciar este coment&aacute;rio para que seja avaliado pelo administrador do site?</p><p><b>Motivo da den&uacute;ncia</b> (por que voc&ecirc; acha que esse coment&aacute;rio deve ser exclu&iacute;do?)</p><textarea>M&aacute;x [1000]</textarea><input type="reset" class="botao btVoltar" value="Voltar"  /><input type="submit" class="botao btEnviar" value="Enviar" /></div>'
}

function denunciaOK(form){
	form.innerHTML = '';
	form.parentNode.innerHTML = form.parentNode.innerHTML + '<p class="alerta">Você fez uma denúncia. O comentário será analisado.</p>'
}
function denunciaNG(form){
	form.className = '';
	form.innerHTML = formConteudo;
}



function excluirFavorito(botao){
	botao.parentNode.innerHTML = '<p class="alerta">a lista foi excluída com sucesso.</p>';
}


function deletarComentario(botao){
	botao.parentNode.parentNode.innerHTML = '<p class="alerta">o comentátio foi excluído com sucesso.</p>';
}

function addMaisAmigo(a){
	a.parentNode.getElementsByTagName('div')[1].innerHTML = a.parentNode.getElementsByTagName('div')[1].innerHTML+'<label class="nome">Nome do amigo</label> <label class="email">E-mail do amigo</label><input type="text" name="amigoNome1" id="amigoNome1" class="campo nome" /> <input type="text" name="amigoEmail1" id="amigoEmail1" class="campo email" />';
  return false;
}


function addMaisAmigo_INDIQUE(a){
	a.parentNode.getElementsByTagName('div')[1].innerHTML = a.parentNode.getElementsByTagName('div')[1].innerHTML+'<label class="nome" style="width:250px;">Nome do amigo</label> <label class="email" style="width:250px;">E-mail do amigo</label><input type="text" name="amigoNome1" id="amigoNome1" class="campo nome" style="width:250px;"/> <input type="text" name="amigoEmail1" id="amigoEmail1" class="campo email" style="width:350px;"/>';
  return false;
}



function GM_BloqueiaScrap(vConta,vCampo){
  if(vConta>200){
    alert("Foi atingido o numero maximo de caracteres");
    //document.getElementById(vCampo).readOnly = true;
  }
  



}






















function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function hide(lyr)
{
  var x = document.getElementById(lyr);
  x.style.visibility = (hide) ? 'hidden' : 'visible';
}

function setLyr(obj,lyr, vTop, vLeft,CodLugar)
{
  var coors = findPos(obj);
  var x = document.getElementById(lyr);
  x.style.top = eval(coors[1]+vTop) + 'px';
  x.style.left = eval(coors[0]+vLeft) + 'px';
  P7_autoLayers(0,lyr);
  //P7_autoHide(lyr);
  document.getElementById("Codigo_Estabelecimento").value=CodLugar;
  return false;
}

function setLyr_2(obj,lyr, vTop, vLeft,CodLugar)
{
  var coors = findPos(obj);
  var x = document.getElementById(lyr);
  x.style.top = eval(coors[1]+vTop) + 'px';
  x.style.left = eval(coors[0]+vLeft) + 'px';
  P7_autoLayers(0,lyr);
  //P7_autoHide(lyr);
  //document.getElementById("Codigo_Estabelecimento").value=CodLugar;
  return false;
}


function setLyr_Denuncia(obj,lyr, vTop, vLeft,CodLugar){

  if(navigator.appName=="Microsoft Internet Explorer"){
    //vLeft = -754;
  }
  //alert(vLeft+"\n"+navigator.appName);

  
  var coors = findPos(obj);
  var x = document.getElementById(lyr);
  x.style.top = eval(coors[1]+vTop) + 'px';
  x.style.left = eval(coors[0]+vLeft) + 'px';
  P7_autoLayers(0,lyr);
  //P7_autoHide(lyr);
  document.getElementById("id_scrap").value=CodLugar;
  return false;
}


function findPos(obj)
{
  var curleft = curtop = 0;
  if (obj.offsetParent) {
    curleft = obj.offsetLeft
    curtop = obj.offsetTop
    while (obj = obj.offsetParent) {
      curleft += obj.offsetLeft
      curtop += obj.offsetTop
    }
  }
  return [curleft,curtop];
}

function P7_autoHide() { //v1.3 by PVII
 var i,g,args=P7_autoHide.arguments;
 for(i=0;i<args.length;i++){if((g=MM_findObj(args[i]))!=null){
  g.p7aHide=true;if(document.layers){
  g.captureEvents(Event.MOUSEOUT);}g.onmouseout=P7_hideDiv;g.p7ahD=true;}}
}

function P7_hideDiv(evt) { //v1.3 by PVII
 var b,relT,mT=false; 
 if(document.layers){b=evt.target;if(b.p7aHide){
  b.visibility="hidden";}else{routeEvent(evt);}
 }else if(document.all&&!window.opera){b=event.srcElement;
  while(b!=null){if(b.tagName=="DIV" && b.p7ahD){mT=true;break;}b=b.parentElement;}
  if(!b.contains(event.toElement)){b.style.visibility="hidden";}
 }else if(document.getElementById){b=evt.currentTarget;relT=evt.relatedTarget;
  while(relT!=null){if(b==relT){mT=true;break;}
  relT=relT.parentNode;}if(!mT){b.style.visibility="hidden";}}
}

function P7_autoLayers() { //v1.4 by PVII
 var g,b,k,f,args=P7_autoLayers.arguments;a=parseInt(args[0]);if(isNaN(a))a=0;
 if(!document.p7setc){p7c=new Array();document.p7setc=true;for(var u=0;u<10;u++){
 p7c[u]=new Array();}}for(k=0;k<p7c[a].length;k++){if((g=MM_findObj(p7c[a][k]))!=null){
 b=(document.layers)?g:g.style;b.visibility="hidden";}}for(k=1;k<args.length;k++){
 if((g=MM_findObj(args[k]))!=null){b=(document.layers)?g:g.style;b.visibility="visible";f=false;
 for(var j=0;j<p7c[a].length;j++){if(args[k]==p7c[a][j]) {f=true;}}
 if(!f){p7c[a][p7c[a].length++]=args[k];}}}
}

function OcultaForm(form){
  document.getElementById(form).style.visibility="hidden";
}


var conteudo;
function oqSaoTags(tagLink,tagWindow){
	if (!conteudo){
		conteudo=tagLink.parentNode.innerHTML;
	
		if (tagWindow == 1){
		  tagLink.parentNode.innerHTML = tagLink.parentNode.innerHTML + '<div id="TagsQuadro" class="quadro"><span class="fecharTags"><a href="javascript:void(0)" onclick="OcultaForm(\'TagsQuadro\')" title="Fechar">Fechar</a></span><h3>O que s&atilde;o Tags?</h3><p>Tags s&atilde;o palavras-chave que outros usu&aacute;rios atribuem a lugares quando os incluem em suas listas.<br />Por exemplo, ao incluir um restaurante &agrave; sua lista, voc&ecirc; pode atribuir a ele as tags: "italiano", "jardins", "vinhos" e "m&uacute;sica".</p><p>As tags aparecem em pain&eacute;is na coluna da direita ou como links nas listas de lugares e scrapbooks.</p><p>Ainda est&aacute; com d&uacute;vidas? <a href="fale_conosco.aspx">Fale conosco</a>.</p></div>'
		}
	}
	if (tagWindow == 0){
		tagLink.parentNode.innerHTML=conteudo;
		conteudo = '';
	}
	
}