$(document).ready(function(){
	$('#addRemoveImovel').click(function(){
		$(this).toggleClass('removeImovel');
	});

	$('#thumb1 span').animate({opacity:0},1000,function(){
		$(this).css({display:'none'});
	});
	$('#thumb1').hover(function(){
		$('span', this).css({display:'block'}).stop().animate({opacity:1},500);
	}, function(){
		$('span', this).stop().animate({opacity:0},500,function(){
		$(this).css({display:'none'});
	});
	});

});

hs.graphicsDir = '/highslide/graphics/';
hs.align = 'center';
hs.transitions = ['expand', 'crossfade'];
hs.outlineType = 'rounded-white';
hs.fadeInOut = true;
hs.dimmingOpacity = 0.75;
// define the restraining box
hs.useBox = true;
hs.width = 800;
hs.height = 600;
// Add the controlbar
hs.addSlideshow({
    //slideshowGroup: 'group1',
    interval: 5000,
    repeat: false,
    useControls: true,
    fixedControls: 'fit',
    overlayOptions: {
        opacity: 1,
        position: 'bottom center'
        //hideOnMouseOut: true
    }
});

function centralizaDiv(id, vel)
{
    var left = ((parseInt($(document.body).width()) - parseInt($(id).width()))/2)-15;
		//var documento = $('body').height();
		//var janela = $(window).height();
		//if(documento > janela){
		//	var dif = (documento - janela);
			//var top = ((parseInt($('body').height()) - parseInt($('#'+id).height()))/2)-15;
		//}else{
			var top = ((parseInt($(window).height()) - parseInt($(id).height()))/2)-15;
		//}


    $(id).stop().animate({
        'left': left<0?0:left,
        'top': top<0?0:top
        }, vel, 'swing');
}

function setFundoSize(id){
	if($('body').height() <= $(window).height()){
		altura = $(window).height();
	}else{
		altura = $('body').outerHeight();
	}

	$(id).height(altura);
}

function ModalWindow(dados,metodo,titulo,width,height){
	//var conteudo = $(dados).html();
	//tipos = normal, ajax, iframe;
	var metodo = metodo || 'normal';
	var conteudo = '';

	//cria o objeto #fundo
	$('<div/>',{
		id:'fundo'
	}).appendTo('body');

	//cria o objeto #window
	$('<div/>',{
		id:'window'
	}).appendTo('body');

	//seta o tamanho de #fundo
	setFundoSize('#fundo');

	//seta os tamanhos da janela SE houver...
	(width)?$('#window').css({'width':width}):'';
	(height)?$('#window').css({'height':height}):'';

	$('#window').html('<p>'+titulo+'<a class="close" href="javascript:void(0);"><img src="/images/close.png" /></a></p><div id="content"></div>');
	centralizaDiv('#window',300);

	//verifica o tipo de metodo usado
	if(metodo == 'normal'){
			conteudo = $(dados).html();
			$('#window #content').html(conteudo);
			$('#content').width($('#window').width()).height($('#window').height()-25).css({overflow:'auto'});
		}else if(metodo == 'ajax'){
			$.get(dados,function(data){
				$('#window #content').html(data);
			});
			$('#content').width($('#window').width()).height($('#window').height()-25).css({overflow:'auto'});
		}else if(metodo == 'iframe'){
			$('#window #content').html('<iframe src='+dados+' frameborder="0"></iframe>');
			$('#window #content iframe').width($('#window').width()).height($('#window').height()-25).attr('src',dados);
		}

	//faz a animação para exibir #fundo e #window
	$('#fundo').slideDown();
	$('#window').slideDown();

	//metodo de fechar do botao CLOSE
	$('.close').click(function(){
		$('#fundo').slideUp().remove();

		$('#window').slideUp().remove();
	});

	return false;
}



$(window).bind('resize', function(){
    centralizaDiv('#window', 300);
		setFundoSize('#fundo')
});



$(document).ready(function(){
		$('#botao').click(function(){
			ModalWindow('http://www.google.com.br','iframe','título da janela');
		})



});
