var id=2;
var ban=2;
$(document).ready(function() {

 //Show Banner
 $(".main_image .desc").show(); //Show Banner
 $(".main_image .block").animate({ opacity: 0.85 }, 1 ); //Set Opacity
 //$("#aba").animate({ opacity: 0.85 }, 1 ); //Set Opacity

 //Click and Hover events for thumbnail list
 $(".image_thumb ul li:first").addClass('active');
 $(".image_thumb ul li").click(function(){
 //Set Variables
 //var imgAlt = $(this).find('img').attr("alt"); //Get Alt Tag of Image
 var imgTitle = $(this).find('a').attr("href"); //Get Main Image URL
 var imgDesc = $(this).find('.block').html(); //Get HTML of block
 var linkli = $(this).find('.caminho').attr("href");
 var imgDescHeight = $(".main_image").find('.block').height(); //Calculate height of block
 str = $(this).attr("id").split("_");
 id = str[1];
 if ($(this).is(".active")) { //If it's already active, then...
 return false; // Don't click through
 } else {
 //Animate the Teaser
 //$(".main_image .block").animate({ opacity: 0, marginBottom: -imgDescHeight }, 250 , function() {
 $(".main_image .block").html(imgDesc).animate({ opacity: 0.85, marginBottom: "0" }, 250 );
 $("#prifot").attr({ src: imgTitle });
 /*$("#loadgalery").css("display","block");
 var objImagePreloader = new Image();
 objImagePreloader.onload = function() {
 				$("#loadgalery").css("display","none");
				$("#prifot").attr({ src: imgTitle });			
				//	clear onLoad, IE behaves irratically with animated gifs otherwise
				objImagePreloader.onload=function(){};
  };
 objImagePreloader.src = imgTitle;*/
 $("#linkli").attr({href: linkli});
 if(id>3){ 	
	bol = id-3;
	$("#bola"+bol).attr({src: "images/"+bol+"b.png"});
	if(bol==2){
		$("#bola1").attr({src: "images/1.png"});
		$("#bola3").attr({src: "images/3.png"});
	}else if(bol==3){
		$("#bola1").attr({src: "images/1.png"});
		$("#bola2").attr({src: "images/2.png"});
	}else {
		$("#bola2").attr({src: "images/2.png"});
		$("#bola3").attr({src: "images/3.png"});
	}
	
 }else {
 	$("#bola"+id).attr({src: "images/"+id+"b.png"});
	if(id==2){
		$("#bola1").attr({src: "images/1.png"});
		$("#bola3").attr({src: "images/3.png"});
	}else if(id==3){
		$("#bola1").attr({src: "images/1.png"});
		$("#bola2").attr({src: "images/2.png"});
	}else {
		$("#bola2").attr({src: "images/2.png"});
		$("#bola3").attr({src: "images/3.png"});
	}
 }
 //});
 }

 $(".image_thumb ul li").removeClass('active'); //Remove class of 'active' on all lists
 $(this).addClass('active'); //add class of 'active' on this list only
 return false;

 }) .hover(function(){
 $(this).addClass('hover');
 }, function() {
 $(this).removeClass('hover');
 });

 //Toggle Teaser
 $("a.collapse").click(function(){
 $(".main_image .block").slideToggle();
 $("a.collapse").toggleClass("show");
});


});//Close Function

setInterval('passa()',10000);
//setInterval('mudaBan()',15000);
function passa(){
	$("#li_"+id).click();
	if(id==3){
		id=1;
	}else if(id==6){
		id=4;
	}else {
		id++;
	}
}
function mudaBan(){
		if(ban==1){
			$("#flasPrp").html('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="429" height="124" title="expans&atilde;o"><param name="movie" value="pics/1.swf"><param name="quality" value="high"><embed src="pics/1.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="429" height="124"></embed></object>');
			ban+=1;
		}else if(ban==2){
			$("#flasPrp").html('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="429" height="124" title="expans&atilde;o"><param name="movie" value="pics/2.swf"><param name="quality" value="high"><embed src="pics/2.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="429" height="124"></embed></object>');
			ban+=1;
		}else {
			$("#flasPrp").html('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="429" height="124" title="expans&atilde;o"><param name="movie" value="pics/3.swf"><param name="quality" value="high"><embed src="pics/3.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="429" height="124"></embed></object>');
			ban=1;
		}
}
function mudali(){
	if(id>3){
		$("#botoes").html('<img src="images/1b.png" alt="" style="position:absolute;margin-top:40px;margin-left:20px;cursor:pointer" onclick="$(\'#li_4\').click()" id="bola1"/><img src="images/2.png" alt="" style="position:absolute;margin-top:70px;margin-left:20px;cursor:pointer" onclick="$(\'#li_5\').click()" id="bola2"/><img src="images/3.png" alt="" style="position:absolute;margin-top:100px;margin-left:20px;cursor:pointer" onclick="$(\'#li_6\').click()" id="bola3"/>');
		//$("#imageaba").attr({src:"images/locacao.jpg"});
		$("#aba").html('<img src="images/locacao.jpg" name="imageaba" border="0" usemap="#imageabaMap" id="imageaba"/><map name="imageabaMap" id="imageabaMap"><area shape="rect" coords="5,4,247,30" href="javascript:void(0);" onClick="$(\'#li_1\').click(); mudali();"/><area shape="rect" coords="247,5,491,27" href="javascript:void(0);" onClick="$(\'#li_4\').click(); mudali();"/></map>');
	}else {
		$("#botoes").html('<img src="images/1b.png" alt="" style="position:absolute;margin-top:40px;margin-left:20px;cursor:pointer" onclick="$(\'#li_1\').click()" id="bola1"/><img src="images/2.png" alt="" style="position:absolute;margin-top:70px;margin-left:20px;cursor:pointer" onclick="$(\'#li_2\').click()" id="bola2"/><img src="images/3.png" alt="" style="position:absolute;margin-top:100px;margin-left:20px;cursor:pointer" onclick="$(\'#li_3\').click()" id="bola3"/>');
		//$("#imageaba").attr({src:"images/vende.jpg"});
		$("#aba").html('<img src="images/vende.jpg" name="imageaba" border="0" usemap="#imageabaMap" id="imageaba"/><map name="imageabaMap" id="imageabaMap"><area shape="rect" coords="5,4,247,30" href="javascript:void(0);" onClick="$(\'#li_1\').click(); mudali();"/><area shape="rect" coords="247,5,491,27" href="javascript:void(0);" onClick="$(\'#li_4\').click(); mudali();"/></map>');
	}
} 