/* -------------  */
  // Scrool do fundo 
  var scrollSpeed = 70;
  var scrollDirection = 'v';
  var scrollCurrent = 0;
  var slideAtual = null;
/* - - - - - - - - */

$(document).ready( function(){

    (function($){
	 $.fn.extend({
	   webtoolkitMenu: function(options) {
	      return this.each(function() {
		var obj = $(this);
		$("li ul", obj).each(function(i) {
			$(this).css("top", $(this).parent().outerHeight());
		})
		$("li", obj).hover(
		   function () { $(this).addClass("over"); },
		   function () { $(this).removeClass("over"); }
		);
	      });
	   }
	 });
    })(jQuery);
	$("#menu1").webtoolkitMenu();
     
	if ( $("#slide-destaques").length> 0 ) {
		$(".slide-box").each(function(){
			var box = $(this);
			box.wrap("<div class='slide-box2' style='background-image: url(" + sURLBase+ "/esquema_imob/"+sCodModelo+"/"+sCodSubModelo+"/slide-papel.png)' />");
		});
		$(".slide-box-destaque a").before("<img src='"+sURLBase+"esquema_imob/"+sCodModelo+"/"+sCodSubModelo+"/slide-selo-destaque.png' />");
		$(".slide-box-lancamento a").before("<img src='"+sURLBase+"esquema_imob/"+sCodModelo+"/"+sCodSubModelo+"/slide-selo-lancamento.png' />");
		$('#slide-destaques').cycle({
			   before: function(atual, proximo, opcoes, avancando) {
			   scrollCurrent=0;
			   slideAtual = $(proximo).find('.slide-box');
			   return false;
			},
			random: 1,
			timeout: 8000
		});
		var init = setInterval("bgscroll()", scrollSpeed); 
    	$(".slide-box").css("display","block");
	}

    if ( $("#carousel").length> 0 ) {
		$("#seta-esquerda").attr("src",sURLBase+"esquema_imob/005/images/imagem1.gif");
		$("#seta-direita").attr("src",sURLBase+"esquema_imob/005/images/imagem2.gif");
		$("#carousel").jCarouselLite({
			   btnNext: "#seta-direita",
			   btnPrev: "#seta-esquerda",
			   visible: 6,
			   scroll: 1,
			   vertical: false,
			   speed: 700,
			   circular: false
		});
		if  ( !bIE6 ) {
			$("#carousel ul a").lightBox({
			   imageLoading: sURLBase+"esquema_imob/images/jqlbLoading.gif",
			   imageBtnClose: sURLBase+"esquema_imob/images/jqlbClose.gif",
			   imageBtnPrev: sURLBase+"esquema_imob/images//jqlbPrev.gif",
			   imageBtnNext: sURLBase+"esquema_imob/images/jqlbNext.gif",
			   txtImage: "Imagem",
			   txtOf: "de"
			});
		} else { 
			var sImgStatus = $("#img-status").attr("value");
			var sImgPadrao = $("#img-padrao").attr("value");
			if (sImgStatus != null && sImgStatus.length > 0){
				$('body').append("<div id='slide-fotos'></div><iframe id='slide-fotos-iframe'></iframe>");  
				$("#imagens-lista li a").attr({"href" :"javascript:abreImagem(0)"}); 
				inicFotos(sImgPadrao,sImgStatus);
			}     
		} 
	}
	
    if ( $("#carousel-lancamento").length> 0 ) {
	   $('img.preload').hide();
	   $(window).bind('load', function() {
			var i = 1;
			var imgs = $('img.preload').length;
			var int = setInterval(function() { 
				//console.log(i); check to make sure interval properly stops
				if(i >= imgs) clearInterval(int);
				$('img.preload:hidden').eq(0).fadeIn(500);
				i++;
			}, 500);	
	   });

		$("#carousel-lancamento").jCarouselLite({
			   visible: 2,
			   scroll: 1,
			   vertical: false,
			   auto: 5000,
			   speed: 1500,
			   circular: true
		});
	}

    if ( !bIE ) {
	   $(".imovel").corner();
	   $("#conteudo").corner();
	}    

});
function bgscroll() {
     scrollCurrent -= 1;
     if ( scrollCurrent < -120 ) {
        scrollCurrent = 0;
     }
	 if ( slideAtual != null) {
	    $(slideAtual).css("backgroundPosition", (scrollDirection == 'h') ? scrollCurrent+"px 0" : "160px " + scrollCurrent+"px");
	 }
}

