// JavaScript Document
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
var menuimg = new Image;
menuimg.src = "images/menu.gif";
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function logo() {
	menulayer.style.background = "url(images/menuBack_wo.gif) no-repeat";
	nav.style.display = "none";
	movingmenu.style.left = 291;
	movingmenu.style.top = 14;
	//movingmenu.style.filter = "FlipV";
	movingmenu.style.display = "block";
	logomove2(2, 10);
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function logomove2(x, y) {
	movingmenu.style.top = 14 + x;
	x2 = -x;
	y2 = (y * 1.15);
	if(y < 120) {
		setTimeout("logomove2(x2, y2)", y2);
	} else {
		movingmenu.style.display = "none";
		menulayer.style.background = "url(images/menuBack.gif) no-repeat";
		nav.style.display = "block";
	}
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function logomove(y, time) {
	if(time == -4) {
		time2 = time;
		y2 = y;
		if(y > 14) {
			if(y > 120) {
				y2 = y2-2;
			}
			if(y > 90) {
				y2 = y2-2;
			}
			if(y > 60) {
				y2 = y2-2;
			}
			if(y > 30) {
				y2 = y2-2;
			}
			if(y > 0) {
				y2 = y2-2;
			}
			movingmenu.style.top = y2;
			setTimeout("logomove(y2, time2)", 15);
		} else {
			movingmenu.style.display = "none";
			menulayer.style.background = "url(images/menuBack.gif) no-repeat";
			nav.style.display = "block";
		}			
	} else {
		y2 = y;
		y2 += 48 / time;
		time2 = time;
		movingmenu.style.top = y2;
		if(((y2 > (mainlayer.offsetHeight + document.body.offsetTop + 100)) && (time > 0)) || ((y2 < -(document.body.offsetTop + 100 + 74)) && (time < 0))) {
			if(time > 0) {
				time2++;
				movingmenu.style.filter = "";
			} else {
				time2--;
				movingmenu.style.filter = "FlipV";
			}
			time2 = -time2;
			setTimeout("logomove(y2, time2)", 15);
		} else {
			setTimeout("logomove(y2, time2)", 15);
		}
	}
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
var x = 0;
var y = 0;
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function dialogbox(mydiv) {
	document.getElementById(mydiv).style.display = "block";
	document.getElementById(mydiv).style.top = (screen.availHeight - document.getElementById(mydiv).offsetHeight)/2;
	document.getElementById(mydiv).style.left = (screen.availWidth - document.getElementById(mydiv).offsetWidth)/2;
	if(mydiv == "loading_div") {
		document.body.style.background = "";
		mainlayer.style.filter = "Alpha(Opacity=30)";
	}
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function fillinput(mydiv, myid) {
	mydiv2 = mydiv;
	new_title.location.assign("new_title.php?ID=" + myid);
	dialogbox(mydiv2);
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function stbg() {
	window.setInterval("movebg(x++,y--)", 30);
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function movebg(x, y) {
	document.body.style.backgroundPositionX = x;
	document.body.style.backgroundPositionY = y;
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function startList() {
	var navRoot = document.getElementById('nav');
	for (var i=0; i<navRoot.childNodes.length; i++) {
		var node = navRoot.childNodes[i];
		if (node.nodeName=='LI') {
			node.onmouseover = function() {
				var mop = eval(document.getElementById("u" + this.id).getAttribute("op"));
				document.getElementById("u" + this.id).setAttribute("op", (mop+100));
			}
			node.onmouseout = function() {
				var mop = eval(document.getElementById("u" + this.id).getAttribute("op"));
				document.getElementById("u" + this.id).setAttribute("op", (mop-100));
			}
		}
	}
	fading();
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function fading() {
	var navRoot = document.getElementById('nav');
	for (var i=0; i<navRoot.childNodes.length; i++) {
		var node = navRoot.childNodes[i];
		if (node.nodeName=='LI') {
			var op = eval(document.getElementById("u" + node.id).getAttribute("op"));
			if(op > 0) {
				op -= 10;
				document.getElementById("u" + node.id).style.filter = "Alpha(Opacity=100, FinishOpacity=" + (100 - op) + ", Style=1, StartY=0, FinishY=" + (100 - op) + ", StartX=0, FinishX=0)";
				document.getElementById("u" + node.id).style.MozOpacity = (100 - op)/100;
				document.getElementById("u" + node.id).style.display = "block";
				document.getElementById("u" + node.id).setAttribute("op", op);
				if(op == 100) {
					document.getElementById("u" + node.id).style.MozOpacity = 1;
					document.getElementById("u" + node.id).style.filter = "";
				}
			}
			if(op < 0) {
				op += 10;
				document.getElementById("u" + node.id).style.filter = "Alpha(Opacity=100, FinishOpacity=" + (0 - op) + ", Style=1, StartY=0, FinishY=" + (0 - op) + ", StartX=0, FinishX=0)";
				document.getElementById("u" + node.id).style.MozOpacity = (0 - op)/100;
				document.getElementById("u" + node.id).setAttribute("op", op);
				if(op == 0) {
					document.getElementById("u" + node.id).style.MozOpacity = 0;
					document.getElementById("u" + node.id).style.filter = "";
					document.getElementById("u" + node.id).style.display = "none";
				}
			}			
		}
	}
	setTimeout("fading()", 50);	
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function show_link(ID, evt) {
	if(	window.document.getElementById(ID).style.display != "block") {
		fadein(ID, 0);
		window.document.getElementById(ID).style.display = "block";
		window.document.getElementById(ID).style.top = evt.clientY + document.body.scrollTop;
		window.document.getElementById(ID).style.left = evt.clientX + document.body.scrollLeft;
	}
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function hide(ID) {
	ID2 = ID;
	fadeout(ID2, 100);
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function hide2(ID) {
	ID.style.display = "none";
}
function ad() {
	clearTimeout(x);
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function fadein(ID, val) {
	window.document.getElementById(ID).style.filter = "Alpha(Opacity=" + val + ")";
	if(val < 100) {
		val2 = val+10;
		ID2 = ID;
		setTimeout("fadein(ID2, val2)", 15);
	} else if(val == 100) {
		window.document.getElementById(ID).style.filter = "";
	}
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function fadeout(ID, val) {
	window.document.getElementById(ID).style.filter = "Alpha(Opacity=" + val + ")";
	if(val > 0) {
		val2 = val-10;
		ID2 = ID;
		setTimeout("fadeout(ID2, val2)", 15);
	} else if(val == 0) {
		window.document.getElementById(ID).style.display = "none";
		window.document.getElementById(ID).style.filter = "";
	}
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function follow(ID, evt) {
	window.document.getElementById(ID).style.top = evt.clientY + document.body.scrollTop;
	window.document.getElementById(ID).style.left = evt.clientX + document.body.scrollLeft;
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function blink0(val, dir) {
	for(var i = 0; i < document.images.length; i++) {
		if(document.images[i].id == "blinkpic") {
			document.images[i].style.filter = "Alpha(Opacity=" + val + ")";
		}
	}
	if(val == 0) {
		dir2 = "u";
	} else if(val == 100) {
		dir2 = "d";
	} else {
		dir2 = dir;
	}
	if(dir2 == "d") {
		val2 = val-100;
	} else if(dir2 == "u") {
		val2 = val+100;
	}
	window.setTimeout("blink0(val2, dir2)", 400);
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function checkform(myform, mytext) {
	if(myform.new_pic.value == "") {
		alert(mytext);
		return false;
	} else {
		dialogbox("loading_div");
		return true;
	}
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function checkform2(myform, mytext) {
	if(myform.choose[0].checked == true) {
		if((myform.new_title.value == "") || (myform.new_name.value == "")) {
			alert(mytext);
			return false;
		} else {
			dialogbox("loading_div");
			return true;
		}
	} else {
		dialogbox("loading_div");
		return true;
	}
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function checkcontact(conform) {
	var war = "";
	if(contactform.firstname.value == "") {
		war += "'Vorname'\n";
	}
	if(conform.lastname.value == "") {
		war += "'Nachname'\n";
	}
	if(conform.text.value == "") {
		war += "'Text'\n";
	}
	if((conform.email.value == "") && (conform.phone.value == "")) {
		war += "'E-mail' oder 'Telefonnummer'\n";
	}
	if(war != "") {
		alert("Bitte füllen Sie folgende(n) Feld(er) aus:\n" + war);
		return false;
	} else {
		return true;
	}
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function submitform(myform, mytext) {
	if(myform.dir_title.value == "") {
		alert(mytext);
		return false;
	} else {
		dialogbox("loading_div");
		return true;
	}
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function submitform2(myform, mytext) {
	if((myform.dir_title.value == "") || (myform.dir_name.value == "")) {
		alert(mytext);
		return false;
	} else {
		dialogbox("loading_div");
		return true;
	}
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function cha(type) {
	if(type == "ext") {
		for(var i = 1; i <= 5; i++) {
			document.getElementById("new_dir_" + i).className = "rows_act";
		}
		for(var j = 1; j <= 3; j++) {
			document.getElementById("ext_dir_" + j).className = "rows_emp";
			document.root_pic.status[j - 1].disabled = true;
		}
		document.root_pic.action = "pro_gal.php?dothis=root_to_ext";
		document.root_pic.new_title.disabled = true;
		document.root_pic.new_name.disabled = true;
		document.root_pic.ext_dir.disabled = false;
	} else if(type == "new") {
		for(var i = 1; i <= 5; i++) {
			document.getElementById("new_dir_" + i).className = "rows_emp";
		}
		for(var j = 1; j <= 3; j++) {
			document.getElementById("ext_dir_" + j).className = "rows_act";
			document.root_pic.status[j - 1].disabled = false;
		}
		document.root_pic.action = "pro_gal.php?dothis=root_to_new";
		document.root_pic.new_title.disabled = false;
		document.root_pic.new_name.disabled = false;
		document.root_pic.ext_dir.disabled = true;
	}
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function makegal(gThumbs, gFull, gT, gF, evt) {
	if(evt) {
		thumb_holder.style.top = evt.clientY + contentlayer.scrollTop - 260;
		thumb_holder.style.display = "block";
	}
	var TG = "";
	for(var num in gFull) {
		if(gThumbs[num] != undefined) {
			TG += "<div id='aThumb'><img src='" + gThumbs[num] + "' id='aImg'><div id='aText'>" + num + "</div><div id='del_pic'><a href=\"javascript: del_pic(" + gT + ", " + gF + ", '" + num + "', '" + gT + "', '" + gF + "')\">X</a></div></div>";
		} else if(gFull[num] != undefined) {
			TG += "<div id='aThumb2'><img src='../images/nopic.jpg' id='aImg'><div id='aText'>" + num + "</div><div id='del_pic'><a href=\"javascript: del_pic(" + gT + ", " + gF + ", '" + num + "', '" + gT + "', '" + gF + "')\">X</a></div></div>";
		}
	}
	thumb_area.innerHTML = TG;
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
var deletes = 0;
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function del_pic(gThumbs, gFull, num, gT, gF) {
	if(confirm("Bild sicherlich löschen (" + num + ")?")) {
		window.open("pro_gal.php?dothis=del_pic&del_pic=" + gFull[num], "process");
		dialogbox("loading_div");
		gThumbs[num] = undefined;
		gFull[num] = undefined;
		deletes = 1;
		makegal(gThumbs, gFull, gT, gF);
	}
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function close_gal() {
	if(deletes == 1) {
		top.location.reload();
	}
	thumb_holder.style.display = "none";
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function close_mail(x) {
	if(x == "n") {
		top.location.reload();
	}
	mail_holder.style.display = "none";
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function del_link(ID, level, ID2) {
	if(level == 2) {
		if(confirm("Willst du wirklich Menüpunkt und ALLE LINKS DARUNTER löschen?")) {
			window.open("edit.php?window=del&ID=" + ID + "&target=" + ID2, "process");
		}
	} else if(level == 3) {
		if(confirm("Links sicherlich löschen?")) {
			window.open("edit.php?window=del&ID=" + ID + "&target=" + ID2, "process");
		}
	}
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function del_mail(ID) {
	if(confirm("Mail sicherlich löschen?")) {
		dialogbox("loading_div");
		window.open("pro_mail.php?dothis=del&ID=" + ID, "process");
	}
}
