/*
	Autore: Danilo Cicognani
	Script: head.js
	Applicazione: www.strapper.it
	Versione: 1.03
	Data: 13/11/2009
	Scopo: Animazioni JavaScript
	Copyright (c) 2009 Danilo Cicognani
*/
intScrolledSize = 0;

$(window).load(function() {
	intScrollerSize = $('#fixed').height();
	intScrolledSize = $('#scroller table').height();
	intNoScrollSize = $('#noscroll').height();
	if (intScrolledSize + intNoScrollSize > intScrollerSize) {
		$('#scroller').height(intScrollerSize - intNoScrollSize);
		$('#scroller table').append($('#scroller table').html().replace(/prettyPhoto\[gallery\]/g, 'prettyPhoto[duplicated]'));
		$("a[rel^='prettyPhoto']").prettyPhoto({theme: 'dark_rounded', hideflash: true, showTitle: false, allowresize: false});
		window.setTimeout("startScroll('#scroller table')", 1000);
	}
	else
		$('#scroller').height(intScrolledSize);
});

$('document').ready(function() {
	$('div.box').hover(function(){
		$(this).fadeTo(50, 0.75);
	},function(){
		$(this).fadeTo(500, 1);
	});

	$("a[rel^='prettyPhoto']").prettyPhoto({theme: 'dark_rounded', hideflash: true, showTitle: false, allowresize: false});
});

function newsScroll(strScrollSelector) {
	var $objScroll = $(strScrollSelector);
	var intTop = parseInt($objScroll.css("top"));
	if (isNaN(intTop))
		intTop = 0;
	if (intTop == -intScrolledSize)
		intTop = 0;
	else
		intTop--;
	$objScroll.css("top", intTop + 'px');
}

function startScroll(strScrollSelector) {
	var $objScroll = $(strScrollSelector);
	$objScroll.attr("interval", window.setInterval("newsScroll('" + strScrollSelector + "')", 30));
	$objScroll.mouseover(function() {
		window.clearInterval($(this).attr("interval"));
	});
	$objScroll.mouseout(function() {
		$(this).attr("interval", window.setInterval("newsScroll('" + strScrollSelector + "')", 30));
	});
}