// F1 front-end/back-end toggle
	if (document.all) {
		document.onhelp = function() {
			location.href = 'admin/';
			return false;
		}
	} else {
		document.onkeydown = function (evt) {
			if (evt.keyCode == '112') {
				location.href = 'admin/';
				return false;
			}
		}
	}

// jQuery
$(document).ready(function(){
		
	$("#commentAdd").click(function() {
		var aid = $("#commentText").attr('rel');
		$.getJSON("/frontend/ajax_comment_add?article_id=" + aid + "&comment=" + $('#commentText').val(),
		function(data) {
			if(data.res == 'ok') {
				$('#lasciaComm').html(data.msg);	
			} else {
				alert(data.msg);	
			}
		});
	});
	

	//ALLINEO IMMAGINI IN VERTICALE
	$('.fotoInList div img').each(function(){
		daSinistra = $(this).parent().parent().width()/2 - $(this).width()/2;
		$(this).css({ display: 'block', marginLeft: daSinistra });
	});
	
	// COLOR BOX
	$("a[rel*='foto']").colorbox({
		transition:"elastic"
		, width:"80%"
		, height:"90%"
		, slideshow: true
	});

	$("a[rel*='galleria']").colorbox({
		transition:"elastic"
		, width:"80%"
		, height:"90%"
		, slideshow: false
	});

	$("a[rel*='video']").colorbox({
		transition:"elastic"
		, width:"550px"
		, height:"500px"
		, slideshow: false
	});

	$("a[rel*='magazine']").colorbox({
		transition:"elastic"
		, width:"500px"
		, height:"400px"
		, slideshow: true
	});
	
	$(".videoYouTube").colorbox({
		iframe:true
		, innerWidth:500
		, innerHeight:400
	});
	
	$(".outsidehtml").colorbox({
		iframe:true
		, height:"80%"
		, width:"80%"
	});
	
	
	// NEWSLETTER HOME: validation
	$('#newsletterHome :image[src*="iscriviti"]').click(function(){
		if ( $(this).parent().siblings(':text').val() != "" ){ //email
			} else {
				alert('Inserire un indirizzo email.');
				return false;
			};
		if ($(this).parent().siblings(':checkbox').is(':checked')){ // privacy
			} else {
				alert('E\' necessario approvare l\'informativa sulla privacy.');
				return false;
			};
	});
	
	
	// BETA VERSION
	$('.wrapper:first').before('<img src="/images/versione-beta.png" style="display: block; margin: -26px auto 0 auto">');

});
