function cidades(){
winC = new Window('cidades', {className: "bluelighting", title: "Cidades", width:150, height:90, top:80, left:130});
winC.setAjaxContent('bcidades.aspx',{asynchronous:false},false,false);
winC.show();
}

var lastColorUsed;
function mudac(row, highlight){
  if (highlight)
  {
    lastColorUsed = row.style.backgroundColor;
    row.style.backgroundColor = '#FFFFCF';
    corfonte =  row.style.color;
    row.style.color = '#000000';

  }
  else
    {
    row.style.backgroundColor = lastColorUsed;
    row.style.color = corfonte;

    }
}
function seltroca(txt,val)
{
  if (txt == "")
    return;
    winB.setTitle('Buscando em '+ txt);
    winB.setAjaxContent('hbusca.ashx?b='+val,{asynchronous:true,onCreate:abrino,onSuccess:aberto},false,false);
    setCookie('cidade',document.forms['fcidades'].selcidade.selectedIndex,365)

}
function selsectroca(sec)
{
   if (sec == "")
    return;
    var bd = document.forms['fcidades'].selcidade.options[document.forms['fcidades'].selcidade.selectedIndex].value;
    var cid = document.forms['fcidades'].selcidade.options[document.forms['fcidades'].selcidade.selectedIndex].text;
    winR.setTitle(sec+ ' em '+cid);
    winR.setAjaxContent('rsecoes.aspx?b='+bd+'&s='+sec,{asynchronous:true,onCreate:abrino,onSuccess:aberto},false,false);

}

function procura()
{
var cli = document.getElementById('nc').value;
document.getElementById('nc').value = '';
document.getElementById('ss').selectedIndex = 0;
    if (cli.blank())
      {
      alert('Insira Algum texto em: Procurar');
      return;
      }
    var bd = document.forms['fcidades'].selcidade.options[document.forms['fcidades'].selcidade.selectedIndex].value;
    var cid = document.forms['fcidades'].selcidade.options[document.forms['fcidades'].selcidade.selectedIndex].text;
    winR.setTitle(cli+ ' em '+cid);
   winR.setAjaxContent('localiza.aspx?b='+bd+'&c='+Url.encode(cli),{asynchronous:true,onCreate:abrino,onSuccess:aberto},false,false);

try {
var pageTracker = _gat._getTracker("UA-11182597-1");
pageTracker._trackPageview("/ajaxProcura");
} catch(err) {}


}

function arruma()
{
winP.setLocation(205,340);
winB.setLocation(90,315);
winR.setLocation(240,70);
winC.setLocation(80,130);
winP.setSize(400,250);
winB.setSize(400,55);
winR.setSize(240,140);
winC.setSize(150,90);
winP.show();
winB.show();
winR.show();
winC.show();

}

function banner()
{
try {
var pageTracker = _gat._getTracker("UA-11182597-1");
pageTracker._trackPageview("/topBanner");
} catch(err) {}
       
}

function mostraMapa(url){
var win = new Window({className: "bluelighting",  width:530, height:330, zIndex: 100, title: "MAPA"})
win.setURL(url);
win.showCenter(); 
pageTracker._trackPageview("/aMapa");       
          
}
var timeoutID = null;
function loadLytebox(id) {
    if (typeof myLytebox != 'undefined') {
        myLytebox.start(document.getElementById(id));
    } else {
        if (timeoutID) { clearTimeout(timeoutID); }
        timeoutID = setTimeout('loadLytebox("'+id+'")', 100);
    }
pageTracker._trackPageview("/aFotos");
}

function arra(teste){
	var kct = teste;
var div = document.getElementById("fotos");
div.innerHTML ='';
 for (var i =0;i<kct.length - 1 ;i++)
{
div.innerHTML +='<a href="'+kct[i]+'" id="'+i+'" rel="lytebox[vacation]" title="">test</a><br>';
}
loadLytebox('0');
}

 function guia(){
var win = new Window({className: "bluelighting",  width:620, height:430, zIndex: 100,  title: "MAPA",recenterAuto:false})
win.setURL('guia.aspx');
win.showCenter();
pageTracker._trackPageview("/aGuia");
          
}

function setCookie(c_name,value,expiredays)
{
var exdate=new Date()
exdate.setDate(exdate.getDate()+expiredays)
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString())
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=")
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1 
    c_end=document.cookie.indexOf(";",c_start)
    if (c_end==-1) c_end=document.cookie.length
    return unescape(document.cookie.substring(c_start,c_end))
    } 
  }
return ""
}
function checkCookie()
{
cidade=getCookie('cidade')
if (cidade!=null && cidade!="")
document.forms['fcidades'].selcidade.selectedIndex= cidade;
else
  {
  document.getElementById('selcidades').selectedIndex=0;
  cidade = 0;
  if (cidade!=null && cidade!="")
    {
    setCookie('cidade',cidade,365)
    }
  }
 seltroca(document.forms['fcidades'].selcidade.options[document.forms['fcidades'].selcidade.selectedIndex].text,document.forms['fcidades'].selcidade.options[document.forms['fcidades'].selcidade.selectedIndex].value);
document.getElementById('nc').focus();
}

 function clickButton(e, buttonid)
 {
   var bt = document.getElementById(buttonid);
	  if (typeof bt == 'object')
      {
		 if(navigator.appName.indexOf("Netscape")>(-1))
		     {
			 if (e.keyCode == 13)
			    {
				  bt.click();
				  return false;
			    }
		     }
      if (navigator.appName.indexOf("Microsoft Internet Explorer")>(-1))
		 {
		   if (event.keyCode == 13)
			 {
			   bt.click();
			   return false;
			 }
		 }
      }
 }

var aberto = function(t) {
 //hidediv('loadi');
 winP.setTitle('');
 pageTracker._trackPageview("/ajaxAberto");
}

var abrino =  function(t){
 //showdiv('loadi')
winP.setTitle('<div  style=" color:#666666; background-image:url(images/spinner_mac.gif); background-position:left; background-repeat:no-repeat; background-attachment:scroll; padding-left:20px; text-align:left;color:#999999 ">Carregando...</div>');
}
function fmail(){
winP.setAjaxContent('contato.aspx',{asynchronous:true,onCreate:abrino,onSuccess:aberto},false,false);
}

function mmail(){
$('fmail').request({method:'GET', onComplete: function(){alert('Mensagem Enviada')}});
$('fmail').reset();
}
	function stAba(menua,conteudo)
	{
		this.menua = menua;
		this.conteudo = conteudo;
	}

	var arAbas = new Array();
	arAbas[0] = new stAba('td_busca','div_busca');
	arAbas[1] = new stAba('td_mapa','div_mapa');


	function AlternarAbas(menua,conteudo)
	{
		for (i=0;i<arAbas.length;i++)
		{
			m = document.getElementById(arAbas[i].menua);
			m.className = 'menua';
			c = document.getElementById(arAbas[i].conteudo)
			c.style.display = 'none';
		}
		m = document.getElementById(menua)
		m.className = 'menu-sel';
		c = document.getElementById(conteudo)
		c.style.display = '';
	}

 function abreRua()
{
var rua = document.getElementById('nr').value;
rua += ' - ';
rua += document.forms['fcidades'].selcidade.options[document.forms['fcidades'].selcidade.selectedIndex].text;
document.getElementById('nr').value= '';
var win = new Window({className: "bluelighting",  width:620, height:430, zIndex: 100,  title: "MAPA",recenterAuto:false})
win.setURL('guia.aspx?r='+rua);
win.showCenter();
}

var Url = {

    // public method for url encoding
    encode : function (string) {
        return escape(this._utf8_encode(string));
    },

    // public method for url decoding
    decode : function (string) {
        return this._utf8_decode(unescape(string));
    },

    // private method for UTF-8 encoding
    _utf8_encode : function (string) {
        string = string.replace(/\r\n/g,"\n");
        var utftext = "";

        for (var n = 0; n < string.length; n++) {

            var c = string.charCodeAt(n);

            if (c < 128) {
                utftext += String.fromCharCode(c);
            }
            else if((c > 127) && (c < 2048)) {
                utftext += String.fromCharCode((c >> 6) | 192);
                utftext += String.fromCharCode((c & 63) | 128);
            }
            else {
                utftext += String.fromCharCode((c >> 12) | 224);
                utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                utftext += String.fromCharCode((c & 63) | 128);
            }

        }

        return utftext;
    },

    // private method for UTF-8 decoding
    _utf8_decode : function (utftext) {
        var string = "";
        var i = 0;
        var c = c1 = c2 = 0;

        while ( i < utftext.length ) {

            c = utftext.charCodeAt(i);

            if (c < 128) {
                string += String.fromCharCode(c);
                i++;
            }
            else if((c > 191) && (c < 224)) {
                c2 = utftext.charCodeAt(i+1);
                string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
                i += 2;
            }
            else {
                c2 = utftext.charCodeAt(i+1);
                c3 = utftext.charCodeAt(i+2);
                string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
                i += 3;
            }

        }

        return string;
    }

}


