// ************************************** gallery icon functions ***************
$("a.icon").click(function(){
	id = $(this).attr("rel");
	href = $(this).attr("href");

	// ************************** add to favorites
	if ($(this).is(".iheart")){
		$("#uidialog").html('<div class="ajax_loader"><img src="_/style/images/ajax_loader.gif" /></div>').dialog({
	    	resizable: false, modal: true, show: "drop", hide: "drop",
	    	height: 140,
	    	width: 320,
	    	title: "Füge das Bild zu Deinen Favoriten hinzu",
	    	buttons: {
	        	"Hinzufügen": function(){
					var text = $("#uidialog .hg_message_comment").val();
					var len = (text) ? text.length : 0;

					$.post('/_ajax/ajax.gallery.php', {
						add_to_favorites : href.substring(1),
						comment : text
					}, function(ret){
						if (ret == 'true'){
							$("#uidialog").html('<p class="success_message">Bild wurde zu Deinen Favoriten hinzugefügt.</p>');
							setTimeout('$("#uidialog").dialog("close");', 1500);
						}else{
							display_error_dialog(ret, 100);
						}
					});
	        	},
	        	"Nee, doch nicht!": function(){
	            	$(this).dialog("close");
	        	}
	    	}
		});

		$("#uidialog").html('<div class="width_gap_top"></div><p class="gb">Hier kannst Du zusätzlich eine Bildüberschrift oder ein Kommentar eingeben. Dieser erscheint dann in Deinem Profil mit dem Bild zusammen.</p><input type="text" name="hg_message_comment" class="hg_message_comment" value="" style="width: 303px;" />');

		return false;
	}
});





// ************************************** write comment message functions ***************
$("#comment_write_trigger").click(function(){
	$(this).fadeOut('fast', function(){
		$("#comment_write").slideDown();
	});
	return false;
});

$("#comment_write button[type='reset']").click(function(){
	$("#comment_write").slideUp('', function(){
		$("#comment_write_trigger").fadeIn('fast');
	});
	return false;
});

$("#comment_write button[type='submit']").click(function(){
	var text = $("#comment_write textarea").val();
	var len = (text) ? text.length : 0;

	if (len === 0){
		display_error_dialog('<p class="error_message">Du musst einen Text eingeben bevor Du ihn abschickst.</p>', 100);
		return false;
	}

	return true;
});
