window.addEvent('domready', function() {
	// Navegacao do scroller (imoveis)
	window.scrollImovelTo = function(direction) {
		var ul = $E('#thumbs div.scroll ul');
		var pos = ul.getStyle('margin-left').toInt();
		if ((direction == 'left') && (pos <= -20)) {
			ul.setStyle('margin-left', pos + 20);
		} else if ((direction == 'right') && (pos >= -window.scrollImovelMax)) {
			ul.setStyle('margin-left', pos - 20);
		}
	};

	var nav_left = $E('#thumbs div.nav_left');
	var nav_right = $E('#thumbs div.nav_right');
	var scroll = $E('#thumbs div.scroll');
	window.scrollImovelMax = $$('#thumbs div.scroll ul li').length * 90 - scroll.getStyle('width').toInt() - 10;

	if ($defined(nav_left)) {
		nav_left.addEvent('mouseenter', function(e) {
			window.scrollImovel = scrollImovelTo.periodical(50, window, 'left');
		});
		nav_left.addEvent('mouseleave', function(e) {
			$clear(window.scrollImovel);
		});
	}

	if ($defined(nav_right)) {
		nav_right.addEvent('mouseenter', function(e) {
			window.scrollImovel = scrollImovelTo.periodical(50, window, 'right');
		});
		nav_right.addEvent('mouseleave', function(e) {
			$clear(window.scrollImovel);
		});
	}

	// Imprimir
	$('imprimir').addEvent('click', function(e) {
		e = new Event(e);
		e.stop();
		var ul = $E('#thumbs div.scroll ul');
		ul.setStyle('margin-left', 0);
		window.print();
	});
});