function centrar_contenedor ()
{
	var medidas_viewport = window.getScrollSize();
	var medidas_contenedor = $('contenedor').getScrollSize();
	if (medidas_contenedor.y < medidas_viewport.y) {
		var offset = (medidas_viewport.y - medidas_contenedor.y) / 2;
		$(document.body).setStyle('margin-top', offset);
	}
}

function thumbnails_casa ()
{
	if ($$('img.thumb')) {
		$$('img.thumb').each( function (el) {

			el.addEvent('mouseover', function () {
				this.setStyle('border', '1px solid #FBE786');
				var oldSrc = this.getProperty('src');
				$('img-principal').setProperty('src', oldSrc.replace(/w=80/g,'w=290'));
			});

			el.addEvent('mouseout', function () {
				this.setStyle('border', '1px solid #3569A5');
			});

		});
	}
}

function enlaces_externos ()
{
    $$('a').each(function(el) {
        if (el.getProperty('rel') == 'external') {
            el.addEvent('click', function(e) {
                e = new Event(e);
                e.stop();
                window.open(this.getProperty('href'));
            }.bind(el));
        }
    });
}

window.addEvent('domready', function ()  {
	centrar_contenedor();
	thumbnails_casa();
        enlaces_externos();
});