/*
	NAVIGATION ANIMATION (Anfang)
*/

var test;

$(document).ready(function(){	
	$("li.head").click(function () { 

		$("li").next("ul").slideUp();
		
		if ($(this).next("ul").css("display")=="block"){
			$(this).next("ul").slideUp();
			
			test = $(this).children("a").attr("href");
			setTimeout('nextsite();', 400);
		} else {
			$(this).next("ul").slideDown();
			
			test = $(this).children("a").attr("href");
			setTimeout('nextsite();', 400);	
		}
	});
	
	///////////////
	
	$("#newssel").change(function () {
		location.href = "index.php?module=news&mode=edit&id=" + $("#newssel>option:selected").val();
	});
	
	$("#controls").hide();
	$("#new_menitem").hide();
	
	$("li.sortable, li.above").bind("click", function() {
		$("#controls").css({position:"absolute"});
		$("#controls").css({left:($(this).position().left+$(this).width())+"px"});
		$("#controls").css({top:($(this).position().top) + "px"});
		
		$("#controls").show();
		$("#butt_del").show();
		$("#butt_add").hide();
		
		if ($(this).attr("class") == "above") {
			$("#butt_del").hide();
			$("#butt_add").show();
		}
		
		var li = $(this);
		
		$("#butt_edit").click(function() {
			location.href = "index.php?module=sites&mode=edit&id=" + li.attr("name");
		});
		$("#butt_del").click(function() {
			location.href = "index.php?module=sites&mode=del&id=" + li.attr("name");
		});
		$("#butt_add").click(function() {
			$("#new_menitem").show();
			$("#tiny_mce").hide();
			
			$("input[name=men_parent]").attr("value", li.attr("name"));
		});
	});
	
	////////////////
	
	$("ul.userList").sortable({ 

	});
	
	$("#hierarchy_saver").click(function() {
		var hierarchy = "";		

		$("li.above").each(function() {
			hierarchy += $(this).attr("name");
			hierarchy += "["
			
			$(this).next("ul").children("li.sortable").each(function () {
				hierarchy += $(this).attr("name");
				if (!$(this).is(":last-child")) {
					hierarchy += ",";
				}
			});
			
			hierarchy += "];";
		});
		hierarchy = hierarchy.substring(0, hierarchy.length - 1);
		
		$("#hir").attr("value", hierarchy);
		$("#hirfom").submit();
	});
	
	//// tiny mce
	
	/*$('textarea').tinymce({
			// Location of TinyMCE script
			script_url : '../style/js/tiny_mce/tiny_mce.js',
 
			// General options
	//mode : "textareas",
	//language : "de",
	theme : "advanced",
plugins:  "safari,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,imagemanager,filemanager",
	// Theme options
	theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,blockquote,pagebreak,|,insertfile,insertimage",
	theme_advanced_toolbar_location : "top",
	theme_advanced_toolbar_align : "left",
	theme_advanced_statusbar_location : "bottom",
	theme_advanced_resizing : true,

	relative_urls : false,
	// Example content CSS (should be your site CSS)
	content_css : "../../css/style.css",

	// Drop lists for link/image/media/template dialogs
	//template_external_list_url : "lists/template_list.js",
	//external_link_list_url : "lists/link_list.js",
	external_image_list_url : "../includes/tinymce_imagelist.php",
	//media_external_list_url : "lists/media_list.js",
		});*/
});

function nextsite() {
	location.href = test;
}
/*
	NAVIGATION ANIMATION (Ende)
*/

function slf(f) {
	if (f.password.value == "") {
		f.adm_password.value = "";	
	} else {
		f.adm_password.value = MD5(f.password.value);
	}
	return true;
}

function adduploadfield() {
	document.getElementById("uploadfields").innerHTML += "<input type='file' name='f" + Math.random(10) + "' /><br />";
}	

