$(document).ready(function(){
    $("#column .countys li .level1 a").click(function(){
			before = $(this).parent().next("ul").css("display");
			$("#column .countys li ul").slideUp("normal");
			if(before == "none")	$(this).parent().next("ul").slideDown("normal");
			return false;
    })
});

function changePicTitle(picid, element){
    $.get(path+"ajax.php?action=getPicTitle", {picid: picid}, function(ans){
        newTitle = prompt('Bitte geben Sie einen neuen Titel ein', ans);
        if(newTitle !== null){
	        $.post(path+"ajax.php?action=setPicTitle", {picid: picid, newTitle: newTitle}, function(ans){
	            if(ans == '1') {
	            	alert("Der Titel wurde erfolgreich geändert!");
	            	$(element).parent().find("img").attr("title", newTitle);
	            }
	            else alert("Der Titel konnte nicht geändert werden ...");
	        });
        	
        }
    });
}
function deletePic(picid, element){
	if(confirm('Möchten Sie dieses Bild wirklich löschen?') == true){
	    $.post(path+"ajax.php?action=deletePic", {picid: picid}, function(ans){
	        if(ans == '1') {
	        	alert("Das Bild wurde erfolgreich gelöscht!");
	        	$(element).parent().fadeOut("slow");
	        }
	        else alert("Das Bild konnte nicht gelöscht werden ...");
	    });
		
	}
}

function changePic(picid, element){
	url = $(".bigone img").attr('src');
	slash = url.lastIndexOf('/');
	title = $(element).attr('title');
	
	$(".bigone img").attr('src', url.substr(0, slash+1) + '' + picid + '_mid.jpg'); 
	$(".bigone a")
	 .attr('href', url.substr(0, slash+1) + '' + picid + '_normal.jpg')
	 .attr('title', title);
}
