var tmptext = '';
$(document).ready(function() { 
	$('#fondoimg').cycle('fade');
	$('#bottomimg1').cycle('fade');
	$('#bottomimg2').cycle('fade');
	$('#bottomimg3').cycle('fade');
	$('#subemail').addClass('inputHint');
	$('#subemail').focus(function() { 
		if( $(this).hasClass('inputHint') ) {
			tmptext = $(this).val();
			$(this).val('');
			$(this).removeClass('inputHint');
		}
	});
	$('#subemail').blur(function() { 
		if( $.trim($(this).val()) == '' ) {
			$('#subemail').addClass('inputHint');
			$(this).val(tmptext);
		}
	});
	$('#subscribenews').click(function() { 
		var se = $('#subemail');
		if( $.trim(se.val()) != '' && !se.hasClass('inputHint') ) {
			return true;
		}
		return false;
	});
	$('a.fotopiccola').click(function() { 
		var src = $(this).children('img').attr('src').toString();
		//var nsrc= src.replace( '/p_', '/g_');
		var nsrc= src.replace( '/p_', '/');
		
		var img = new Image();
		img.onload = function() {
			var imgw = img.width;
			var imgh = img.height;
			var cliw = $(window).width();
			var clih = $(window).height();
			var ofsl = 0;
			var ofst = 0;
			
			if( imgw < cliw ) ofsl = Math.floor((cliw - imgw) / 2);
			if( imgh < clih ) ofst = Math.floor((clih - imgh) / 2);
			$('#displayBigImg').attr('src',nsrc);
			/*$('#closeBigImg img').css({ position: "absolute",
						marginLeft: 0, marginTop: 0,
						top: ofst+'px', left: '10px' });*/
			$.blockUI.defaults.css = {};
			$.blockUI({ 
				message: $('div#displayBox'), 
				css: { 
					left: ofsl+'px',
					top:  ofst+'px', 
					width: imgw+'px' ,
					border: 'none',
					backgroundColor:'',
					margin: 'auto'
				} 
			}); 
		}
		img.src = nsrc;
		return false;
	});
	$('#closeBigImg').click(function() {
		$.unblockUI();
		return false;
	});
	$("div.scrollable").scrollable({
		vertical: true,
		interval: 2000,
		loop: true, 
		speed: 600,
		size: 3
	});	
});

