/**
 * Code by Giancarlo "GM" Moschitta (info@myphp.it) and Simone "negatyve" Auteritano (negatyve@negatyve.com)
 * Powered by jQuery (http://jquery.com))
**/
/**
 * Avvia tutti gli script necessari alle pagine di immagini di ManagerOnline.it
**/
function initGallery()
{
	setGalleryImagesRollover();
}

/**
 * Imposta il rollover sulle immagini della galleria
**/
function setGalleryImagesRollover()
{
	var isIE6 = $.browser.msie && Number( $.browser.version.split('.')[0] ) <= 6;
	if( !isIE6 )
	{
		getFadedDiv()
			.css( {background:'#ffffff', opacity:'0.7'} )
			.appendTo( $( '.gallery-images li.selected' ) )
		;
		$( '.gallery-images li a' ).each
		(
			function()
			{
				var li = $( this ).parent();
				var div = getFadedDiv();
				div.appendTo( li );
				li
					.hover
					(
						function(){ div.css( 'background', SHADE_COL ); },
						function(){ div.css( 'background', 'none' ); }
					).click
					(
						function()
						{
							gotoSelectedPage( $( 'a', li ).attr( 'href' ) );
							return false;
						}
					)
					.css( 'cursor', 'pointer' )
				;
			}
		);
	} else {
 		$( '.gallery-images li.selected img' ).css( 'border-color', '#ff0000' ); 
		$( '.gallery-images li a' ).each
		(
			function()
			{
				var img = $( 'img', $( this ) );
				$( this ).hover
				(
					function(){ img.css( 'border-color', SHADE_COL ); },
					function(){ img.css( 'border-color', '#787878' ); }
				);
			}
		);
	}
}

/**
 * Restituisce il div per il rollover
**/
function getFadedDiv()
{
	return $( '<div />' )
		.css( 'width', '123px' )
		.css( 'height', '70px' )
		.css( 'opacity', '0.5' )
		.css( 'position', 'absolute' )
		.css( 'top', '0' )
		.css( 'z-index', '2' )
	;
}

/**
 * Associa la funzione initGallery all'evento onload della pagina
**/
$( document ).ready( initGallery );