var UserAgent = navigator.userAgent.toLowerCase();
var isIE = ((UserAgent.indexOf("msie") != -1) && (UserAgent.indexOf("opera") == -1) && (UserAgent.indexOf("webtv") == -1)); 
var isIE5 = isIE && (navigator.appVersion.indexOf("MSIE 6.0") != -1);
var isGecko = (UserAgent.indexOf("gecko") != -1);
var isOpera = (UserAgent.indexOf("Opera") != -1);
var isDesconhecido = (!(isIE || isGecko || isOpera));
function preLoadImages(imgs)
{
  aPreImagens = new Array();
  for (var i = 0; i < imgs.length; i++)
  {
    aPreImagens[i] = new Image(100,100);
    aPreImagens[i].src = imgs[i];
  }
}
function getQueryVariable(variable)
{
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++)
  {
    var pair = vars[i].split("=");
    if (pair[0] == variable)
    {
      return pair[1];
    }
  } 
    return null;
}
function getXMLHttp()
{
  if (window.XMLHttpRequest)
  {
    return new XMLHttpRequest();
  }
  else if (window.ActiveXObject)
  {
    try
    { return new ActiveXObject('Msxml2.XMLHTTP.6.0'); }
    catch(e)
    {
      try
      { return new ActiveXObject('Msxml2.XMLHTTP.5.0'); }
      catch(e)
      {
        try
        { return new ActiveXObject('Msxml2.XMLHTTP.4.0'); }
        catch(e)
        {
          try
          { return new ActiveXObject('MSXML2.XMLHTTP.3.0'); }
          catch(e)
          {
            try
            { return new ActiveXObject('Msxml2.XMLHTTP'); }
            catch(e)
            {
              try
              { return new ActiveXObject('Microsoft.XMLHTTP'); }
              catch(e)
              { return false; }
            }
          }
        }
      }
    }
  }
  return false;
}
function processHtml(txt){};
function getHtml(url)
{
    var returnGetHtml = '';
    var xmlHttp = getXMLHttp();
    if (xmlHttp)
    {
      xmlHttp.onreadystatechange=function()
      {
        if (xmlHttp.readyState == 4)
        {
          if (xmlHttp.status == 200)
          {
            returnGetHtml = unescape(xmlHttp.responseText);
            if (returnGetHtml != '')
            {
				processHtml(returnGetHtml);
            }
          }
          else
          {
			processHtml('');
            alert('Houve um problema com esta requisição\n('+xmlHttp.status+' - '+xmlHttp.statusText+')');
          }
        }
      }
      if (isGecko)
      {
        xmlHttp.open("GET", url, true);
      }
      else
      {
        xmlHttp.open("GET", url, false);
      }
      xmlHttp.send(null);
    }
    else
    {
		processHtml('');
		alert('Seu browser atual não suporta AJAX!');
    }
}

function loadScript(url) {
	var script = window.document.createElement('script');
	script.defer = true;
	script.src = url;
	window.document.getElementsByTagName('head')[0].appendChild(script);
}
function openFaleComAGente()
{
//  var url = 'co/co.php?tpl=mensagem';
  var url = 'http://ec.tropicalimoveis.com.br/co/co.php?tpl=mensagem';
  var cWidth = 540;
  var cHeight = 510;
  var cLeft = 0;
  var cTop = 0;
  if (isIE)
  {
    window.open(url,'Mensagem','width='+cWidth+'px,height='+cHeight+'px,left='+cLeft+'px,top='+cTop+'px, toolbar=no, location=no, directories=no, status=yes, menubar=no, scrollbars=no, resizable=no');
  }
  else
  {
    window.open(url,'Mensagem','width='+cWidth+'px,height='+cHeight+'px,screenX='+cLeft+'px,screenY='+cTop+'px, toolbar=no, location=no, directories=no, status=yes, menubar=no, scrollbars=no, resizable=no, titlebar("Mensagem"), modal=no');
  }
}
function openCorretorOnLine()
{
//	var url = 'co/co.php?tpl=login';
	var url = 'http://ec.tropicalimoveis.com.br/co/co.php?tpl=login';
	var cWidth = 760;
	var cHeight = 550;
	var cLeft = 0;
	var cTop = 0;
	if (isIE)
	{
		window.open(url,'CorretorOnLine','width='+cWidth+'px,height='+cHeight+'px,left='+cLeft+'px,top='+cTop+'px, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no');
	}
	else
	{
		window.open(url,'CorretorOnLine','width='+cWidth+'px,height='+cHeight+'px,screenX='+cLeft+'px,screenY='+cTop+'px, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, titlebar("Corretor On-Line"), modal=no');
	}
}
function msgTropicalImoveis()
{
	var or = '';
	var as = '';
	var ai = '';
	var ais = 'http://www.tropicalimoveis.com.br/co/cp/vd/al/sa/';
	var url = 'http://www.tropicalimoveis.com.br/co/co.php?tpl=mensagem';
	var cWidth = 540;
	var cHeight = 510;
	var cLeft = 0;
	var cTop = 0;
	if (arguments.length>0)
	{
		var arg = '';
		for (var key=0; key<arguments.length; key++)
		{
			arg = arguments[key];
			if (typeof arg == 'string')
			{
				arg = arg.replace( /^\s*/, "" );
				arg = arg.replace( /\s*$/, "" );
				if (or == '')
				{
					or = arg;
				}
				else if (as == '')
				{
					as = arg;
				}
				else if (ai == '')
				{
					ai = arg;
				}
			}
		}
		or = ((or != '') ? or : 'INDEFINIDO');
		var asKey = as.toLowerCase();
		switch (asKey)
		{
			case 'rdc' :
				cHeight = 480;
				url += '&as='+asKey;
			break;
			case 'ppa' :
				cHeight = 480;
				url += '&as='+asKey;
			break;
			case 'rai' :
				cHeight = 510;
				url += '&as='+asKey;
			break;
			case 'dvd' :
				cHeight = 480;
				url += '&as='+asKey;
			break;
			case 'sgs' :
				cHeight = 480;
				url += '&as='+asKey;
			break;
			case 'crt' :
				cHeight = 480;
				url += '&as='+asKey;
			break;
			case 'elg' :
				cHeight = 480;
				url += '&as='+asKey;
			break;
			case 'oti' :
				cHeight = 480;
				url += '&as='+asKey;
			break;
			default: ;
		}
		if ((ai != '') && (ais.indexOf(ai+'/') != -1))
		{
			url += '&ai='+ai;
			cHeight -= 20;
		}
	}
	if (isIE)
	{
		window.open(url,'TropicalImoveis','width='+cWidth+'px,height='+cHeight+'px,left='+cLeft+'px,top='+cTop+'px, toolbar=no, location=no, directories=no, status=yes, menubar=no, scrollbars=no, resizable=no');
	}
	else
	{
		window.open(url,'TropicalImoveis','width='+cWidth+'px,height='+cHeight+'px,screenX='+cLeft+'px,screenY='+cTop+'px, toolbar=no, location=no, directories=no, status=yes, menubar=no, scrollbars=no, resizable=no, titlebar("Corretor On-Line"), modal=no');
	}
}
