window.addEvent('domready',
function() {
    if ($('latest_news')) {
        $$('#latest_news .text').each(function(elem) {
            if (elem.getElement('img')) {
                var divs = new Element('div', {
                    'class': 'contentImage'
                }).inject(elem, 'top');
                elem.getElement('img').inject(divs);
            }
        });
    }
    if ($('content').getElement('a.lightbox') != null) $$(".lightbox").slimbox();
    if ($$('#box span') == "" && $('scheda')) {
        $('scheda').getElement('div.mask').setStyle('display', 'none');
        $('scheda').getElement('p.buttons').setStyle('display', 'none');
    }
    if ($$('#box span') != "") {
        var nS4 = new noobSlide({
            box: $('box'),
            items: $$('#box span'),
            size: 410,
            addButtons: {
                previous: $('prev'),
                next: $('next')
            },
            onWalk: function(currentItem) {
                var alt = currentItem.getElement('img').getProperty('alt');
                $('info').set('html', alt);
            }
        });
        if (nS4.items.length == 1) {
            $('prev').setStyle('display', 'none');
            $('next').setStyle('display', 'none');
        }
    }
    if ($('dropdown-demo')) {
        $('dropdown-demo').setStyle('display', 'block');
		//$$('#dropdown-demo ul.smenu').setStyle('display', 'none');
        $$('#seldt ul.smenu').setStyles({
            'display': 'block',
            'position': 'absolute',
            'top': 0,
            'left': 106
        });
        $$('#seldt ul.smenu li').setStyles({
            'display': 'block',
            'position': 'relative',
            'z-index': 1
        });
		var smenu = $('seldt').getProperty('rel');
		 $(smenu).setStyle('display', 'block');
    }
    if ($('latest_fiere')) {
        $$('#latest_fiere li div.text').getElement('img').each(function(el) {
            var path = el.getProperty('src');
            var newpath = path.replace('thumb', 'med');
            el.src = newpath;
        });
    }
    if ($('form_contatti')) {
        new FormCheck('form_contatti', {
            display: {
                closeTipsButton: 1,
                showErrors: 1
            }
        })
    }
    if ($('save')) {
        var metatitle = addslashes(document.title);
        $('save').setProperty('href', 'javascript:bookmarksite(\'' + metatitle + '\',\'' + document.location.href + '\')');
    }
});
function addslashes(str) {
    str = str.replace(/\\/g, '\\\\');
    str = str.replace(/\'/g, '\\\'');
    str = str.replace(/\"/g, '\\"');
    str = str.replace(/\0/g, '\\0');
    return str;
}
