window.addEvent('domready', function () {

    var h = $('content_main').getStyle('height');

    if (!$('content_main').hasClass('fullscreen')) {

        $$('#content_main h2').addEvent('click', function () {

            if ($('content_main').getStyle('height').toInt() <= 11) {
                $('content_main').set('morph', { onComplete: function () { $$('#content_main p').setStyle('display', 'block'); } })
                $('content_main').morph({ height: h });
                $$('#content_main h2').setStyle('background-image', 'url(/templates/hotelLidoLimone2010/images/close.gif)');
            }

            else {
                $('content_main').set('morph', { onComplete: function () { } })
                $('content_main').morph({ height: 11, overflow: 'hidden' });
                $$('#content_main p').setStyle('display', 'none');
                $$('#content_main h2').setStyle('background-image', 'url(/templates/hotelLidoLimone2010/images/open.gif)');
            }
        })

        $$('#thumbs h2').addEvent('click', function () {

            if ($('thumbs').getStyle('height').toInt() <= 20) {
                $('thumbs').set('morph', { onComplete: function () { $$('#thumbs ul').setStyle('display', 'block'); } })
                $('thumbs').morph({ height: 56 });
                $$('#thumbs h2').setStyle('background-image', 'url(/templates/hotelLidoLimone2010/images/close.gif)');
                $$('#content_main h2').setStyle('background-image', 'url/templates/hotelLidoLimone2010/(images/close.gif)');
                $('content_main').set('morph', { onComplete: function () { $$('#content_main p').setStyle('display', 'block'); } })
                $('content_main').morph({ height: h, bottom: 75 });
            }

            else {
                $('thumbs').set('morph', { onComplete: function () { } })
                $('thumbs').morph({ height: 20, overflow: 'hidden' });
                $$('#thumbs ul').setStyle('display', 'none');
                $$('#thumbs h2').setStyle('background-image', 'url(/templates/hotelLidoLimone2010/images/open.gif)');
                $$('#content_main h2').setStyle('background-image', 'url(/templates/hotelLidoLimone2010/images/open.gif)');
                $('content_main').set('morph', { onComplete: function () { } })
                $('content_main').morph({ height: 11, bottom: 35, overflow: 'hidden' });
                $$('#content_main p').setStyle('display', 'none');
            }
        })
    }

    if ($('gallery').hasClass('home')) {
        var fw = false;
        var myFx = new Fx.Scroll('gallery', { duration: 5500, onComplete: function () {
            if (fw) {
                myFx.toRight();
                fw = false;
            }
            else {
                myFx.toLeft();
                fw = true;
            }
        }
        });
        myFx.toRight();
    }

    // Chiusura del DOMREADY
});
