function changephoto(id, foto) {
	//$('#a_foto_top_'+id).attr('href', foto+'.jpg');
	$('#img_foto_top_'+id).attr('src', foto+'_little.jpg');
}

function changephoto_scheda(id, foto) {
	$('#a_foto_top_'+id).attr('href', foto+'.jpg');
	$('#img_foto_top_'+id).attr('src', foto+'.jpg');
}

function showAllComment() {
	var comment = $('#box_show_comment');
	var show = $('#show_comment');
	var hide = $('#hide_comment');
	if (comment.css('display') == 'none') {
		hide.slideDown(300, function() { comment.slideDown(300, function() { show.slideUp(300, function() {
			newalt = comment.height();
			oldalt = $('#colonnaCentrale').height();
			altok2 = newalt + oldalt;
			document.getElementById('colonnaSx').style.height = altok2 + 'px';
			document.getElementById('colonnaCentrale').style.height = altok2 + 'px';
			document.getElementById('colonnaDx').style.height = altok2 + 'px';
			document.getElementById('ombraSx').style.height = altok + 'px';
			document.getElementById('cornice').style.height = altok + 'px';
			document.getElementById('ombraDx').style.height = altok + 'px';

		}) } ); });
		
	} else {
		show.slideDown(300, function() { comment.slideUp(300, function() { hide.slideUp(300, function() {
			newalt = comment.height();
			oldalt = $('#colonnaCentrale').height();
			altok2 = oldalt - newalt;
			document.getElementById('colonnaSx').style.height = altok2 + 'px';
			document.getElementById('colonnaCentrale').style.height = altok2 + 'px';
			document.getElementById('colonnaDx').style.height = altok2 + 'px';
			document.getElementById('ombraSx').style.height = altok + 'px';
			document.getElementById('cornice').style.height = altok + 'px';
			document.getElementById('ombraDx').style.height = altok + 'px';
		}) } ); });
	}
	return false;
}

function showCommentBox() {
	var targetContent = $('#comment');
	if (targetContent.css('display') == 'none') {
		targetContent.slideDown(300);
		//$(this).html('[-]');
	} else {
		targetContent.slideUp(300);
		//$(this).html('[+]');
	}
	return false;
}


function showSmile(id)
{
	var targetContent = $('#smiles_'+id);
	if (targetContent.css('display') == 'none') {
		targetContent.slideDown(300);
		//$(this).html('[-]');
	} else {
		targetContent.slideUp(300);
		//$(this).html('[+]');
	}
	return false;
};

function addsmile(text,id) {
	var range = $('#textarea_'+id).getSelection();
	$('#textarea_'+id).replaceSelection(text, true);

	showSmile(id);
}

function posteditor(code) {
	var range = $('#textarea_0').getSelection();
	$('#textarea_0').replaceSelection('['+code+']'+range.text+'[/'+code+']', true);
}

function posteditorOut(code,text) {
	var range = $('#textarea_0').getSelection();
	$('#textarea_0').replaceSelection('['+code+']'+text+'[/'+code+']', true);

	tb_remove();
}

function add_comment(id) {
	var text = $("#textarea_0").val();
	var nome = $("#nome_comment").val();
	$(".buttonSubmit").attr('disabled','disabled');
	$.ajax({
	   type: "POST",
	   url: "/ajax_addcomment.php",
	   data: 'id='+id+'&text='+text+'&nome='+nome,
	   success: function(html){
			   //$('.text_comment_content').css("display","none");
			   $('#comment').html("Commento Inserito con Successo");
			   //$('.buttonSubmit').css("display","none");
	   }
	 });
}

function openCateg(id) {
	var targetContent = $('#articoli_'+id);
	if (targetContent.css('display') == 'none') {		
		$('#categ_'+id).addClass("menuVertApe");
		targetContent.slideDown(300, function() {
			newalt = targetContent.height();
			oldalt = $('#colonnaCentrale').height();
			altok2 = newalt + oldalt;
			document.getElementById('colonnaSx').style.height = altok2 + 'px';
			document.getElementById('colonnaCentrale').style.height = altok2 + 'px';
			document.getElementById('colonnaDx').style.height = altok2 + 'px';
			document.getElementById('ombraSx').style.height = altok + 'px';
			document.getElementById('cornice').style.height = altok + 'px';
			document.getElementById('ombraDx').style.height = altok + 'px';
		});
		//$(this).html('[-]');
	} else {
		$('#categ_'+id).removeClass("menuVertApe");
		targetContent.slideUp(300, function() {
			newalt = targetContent.height();
			oldalt = $('#colonnaCentrale').height();
			altok2 = oldalt - newalt;
			document.getElementById('colonnaSx').style.height = altok2 + 'px';
			document.getElementById('colonnaCentrale').style.height = altok2 + 'px';
			document.getElementById('colonnaDx').style.height = altok2 + 'px';
			document.getElementById('ombraSx').style.height = altok + 'px';
			document.getElementById('cornice').style.height = altok + 'px';
			document.getElementById('ombraDx').style.height = altok + 'px';
		});
		
		//$(this).html('[+]');
	}
	return false;
}

function openWish() {
	var targetContent = $('#wishboxBot');
	if (targetContent.css('display') == 'none') {
		targetContent.slideDown(300);
		$('#wishFrecciaSu').attr("id","wishFrecciaGiu");
		$.ajax({
		   type: "POST",
		   url: "/ajax_wishbox.php",
		   data: 'open=1',
		   success: function(html){
		   }
		 });

	} else {
		targetContent.slideUp(300);
		$('#wishFrecciaGiu').attr("id","wishFrecciaSu");
		$.ajax({
		   type: "POST",
		   url: "/ajax_wishbox.php",
		   data: 'open=0',
		   success: function(html){
		   }
		 });
	}
	return false;
}
