// pop ajax
function loadSWF(url,targetID){
	//Check for existing SWF
	if(isObject(targetID)){
		//replace object/element with a new div
		replaceSwfWithEmptyDiv(targetID);
	}
	
	//Embed SWF
	if (swfobject.hasFlashPlayerVersion("8")) {
		var attributes = { data: url, width:"100%", height:"100%" };
		var params = { wmode:"transparent", menu:"false", quality:"high" };
		var obj = swfobject.createSWF(attributes, params, targetID);
	}
	
	//Show div
	document.getElementById("pop").style.display="block";void(0);

}

function isObject(targetID){
	var isFound = false;
	var el = document.getElementById(targetID);
	if(el && (el.nodeName === "OBJECT" || el.nodeName === "EMBED")){
		isFound = true;
	}
	return isFound;
}

function replaceSwfWithEmptyDiv(targetID){
	var el = document.getElementById(targetID);
	if(el){
		var div = document.createElement("div");
		el.parentNode.insertBefore(div, el);
		//Remove the SWF
		swfobject.removeSWF(targetID);
		//Give the new DIV the old element's ID
		div.setAttribute("id", targetID);
	};
};


//abre janela nova
function popUp(theURL,winName,w,h,scroll){	
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	features = "height="+h+",width="+w+",top="+TopPosition+",left="+LeftPosition+",scrollbars="+scroll+",status=yes";
	janela=window.open(theURL,winName,features);
	janela.focus();
};

//tab imoveis home
function controlTAB(varTAB) {

   switch (varTAB) {
      case 1:
        new UI.Carousel($("carousel_imoveis")).scrollTo(0);
         break;
      case 2:
         new UI.Carousel($("carousel_imoveis")).scrollTo(4);
         break;
      case 3:
         new UI.Carousel($("carousel_imoveis")).scrollTo(8);
         break;
      case 4:
         new UI.Carousel($("carousel_imoveis")).scrollTo(12);
         break;
      case 5:
         new UI.Carousel($("carousel_imoveis")).scrollTo(16);
         break;
      case 6:
         new UI.Carousel($("carousel_imoveis")).scrollTo(20);
         break;
      default:
         new UI.Carousel($("carousel_imoveis")).scrollTo(0);
         break;
   };
};

//Equalizar colunas
columnReset = function () {
    try {
		$('conteudo').style.height = "auto";
        $('blankDir').remove();
    } catch(e) {

    }
    columnEqualizer();
}

columnEqualizer = function () {

    var colunaEsquerda, colunaDireita;

    try {
        colunaEsquerda = $('colunaEsq').getHeight();
        colunaDireita = $('colunaDir').getHeight();

        if (colunaEsquerda > colunaDireita) {
            Element.insert('colunaDir', { 'bottom': '<div class="blank" id="blankDir"><div class="top"></div><div class="bottom"></div></div>' });
            $('blankDir').style.height = colunaEsquerda - colunaDireita - 6 + "px";
        } else if (colunaEsquerda < colunaDireita) {
            $('conteudo').style.height = colunaDireita - 36 + "px";
        }
    } catch(e) {

    }

}

Event.observe(window, 'load', function() {
	columnEqualizer();
});