////////////////////////////////////////////////////////////////////////////////////////////////////
//
//	features.js - JavaScript
//	Autor: Alrik Geselle
//	Date: 31.10.2007
//
////////////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////////////////
// Hauptfunktion
////////////////////////////////////////////////////////////////////////////////////////////////////

window.onload = function()
{
getTime();
/*
	if(document.URL=='http://www.alma2.de/alrik/index.php')
	{
		alert ("Achtung! Ich baue gerade an meiner website");
	}

fenster = window.open("www.google.de", "Bauarbeiten!", "width=600,height=400,status=yes,scrollbars=yes,resizable=yes");
fenster.focus();

	document.onkeydown = my_submit;

	if (document.layers)
	{
		document.captureEvents(Event.KEYDOWN);
	}
*/
}

////////////////////////////////////////////////////////////////////////////////////////////////////
// Höhenanpassung von Frames
////////////////////////////////////////////////////////////////////////////////////////////////////

moz=document.getElementById&&!document.all
mozHeightOffset=20

function resize_iframe()
{
	//document.getElementById("main").height="500px" // required for Moz bug, value can be "", null, or integer
	
	if (navigator.appName == "Netscape")
	{
		document.getElementById("main").height=480
		document.getElementById('main').height=window.frames["main"].document.body.scrollHeight+(moz?mozHeightOffset:0)
	}
	else
	{
		document.getElementById("main").height=500
		document.getElementById('main').height=window.frames["main"].document.body.scrollHeight+(moz?mozHeightOffset:20)
	}

}

////////////////////////////////////////////////////////////////////////////////////////////////////
// E-Mail Verschlüsselung
////////////////////////////////////////////////////////////////////////////////////////////////////

function noSpam(user,domain)
{
	openMail = "mailto:" + user + "@" + domain;
	window.location = openMail;
}

////////////////////////////////////////////////////////////////////////////////////////////////////
// Hilfefenster für TeamSpeak-Server
////////////////////////////////////////////////////////////////////////////////////////////////////

function ts_hilfe()
{
	window.open("main_content/teamspeak/scripts/ts_hilfe.php","Submit","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizeable=0,width=525,height=160");
}

////////////////////////////////////////////////////////////////////////////////////////////////////
// neues Fenster öffnen
////////////////////////////////////////////////////////////////////////////////////////////////////

function window_open(src,x,y,full)
{
	if(full)
	{
		window.open(src,"Submit","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=yes,fullscreen=yes");
	}else{
		window.open(src,"Submit","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=yes,width="+x+",height="+y+"");
	}
}

function window_open_restricted(src,x,y)
{
	window.open(src,"Submit","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width="+x+",height="+y+"");
}

////////////////////////////////////////////////////////////////////////////////////////////////////
// Umleitung
////////////////////////////////////////////////////////////////////////////////////////////////////

function seitenwechsel(code)
{
	if (code==13)
	{
		window.location.href = "http://www.google.de";
	}
}

////////////////////////////////////////////////////////////////////////////////////////////////////
// Begrenzung der Zeicheneingabe für das Gästebuch
////////////////////////////////////////////////////////////////////////////////////////////////////

var max_zeichen = "2500";
function show_chars_left()
{
	infodiv = document.getElementById("charsleft");
	messdiv = document.getElementById("message");
	if (messdiv.value.length >= max_zeichen )
	{
		messdiv.value = messdiv.value.substr(0,max_zeichen);
	}
	infodiv.innerHTML = (max_zeichen - messdiv.value.length);
}

////////////////////////////////////////////////////////////////////////////////////////////////////
// LogIn
////////////////////////////////////////////////////////////////////////////////////////////////////

function login(code,name)
{
	if (code==13)
	{
		document.login.submit();
	}
}

function my_submit(e)
{
	var keycode = document.all ? event.keyCode : e.which;

	if ((""+keycode)=="13")
	{
		if (document.styleSheets && document.all) //ie
			shiftPressed = window.event.shiftKey;
		if (document.layers) //ns4
			shiftPressed = e.modifiers & Event.SHIFT_MASK;
		if (document.getElementById && !document.all) //ns6
			shiftPressed = e['shiftKey'];
		//if (!(shiftPressed))
		//	mach_was(...);
	}
}

////////////////////////////////////////////////////////////////////////////////////////////////////
// Countdown
////////////////////////////////////////////////////////////////////////////////////////////////////

	function getTime()
	{
		now = new Date();

		y2k = new Date("July 11, 2008");

		months = (y2k - now) / 1000 / 60 / 60 / 24 / 30;
		monthsRound = Math.floor(months);

		weeks = (y2k - now) / 1000 / 60 / 60 / 24 / 7;
		weeksRound = Math.floor(weeks);

		days = (y2k - now) / 1000 / 60 / 60 / 24;
		daysRound = Math.floor(days);

		hours = (y2k - now) / 1000 / 60 / 60 - (24 * daysRound);
		hoursRound = Math.floor(hours);

		minutes = (y2k - now) / 1000 /60 - (24 * 60 * daysRound) - (60 * hoursRound);
		minutesRound = Math.floor(minutes);

		seconds = (y2k - now) / 1000 - (24 * 60 * 60 * daysRound) - (60 * 60 * hoursRound) - (60 * minutesRound);
		secondsRound = Math.round(seconds);

	/*
		sec = (secondsRound == 1) ? " Sekunde" : " Sekunden";
		min = (minutesRound == 1) ? " Minute" : " Minuten";
		hr = (hoursRound == 1) ? " Stunde" : " Stunden";
		dy = (daysRound == 1)  ? " Tag" : " Tagen";
		we = (weeksRound == 1)  ? " Woche" : " Wochen";
		mo = (monthsRound == 1)  ? " Monat" : " Monate";
		und = "und ";
		oder = "oder ";
		pl = " ";

		document.timeForm.countdowninput1.value = pl + monthsRound  + mo;
		document.timeForm.countdowninput2.value = pl + weeksRound  + we;
		document.timeForm.countdowninput3.value = pl + daysRound  + dy;
		document.timeForm.countdowninput4.value = pl + hoursRound + hr;
		document.timeForm.countdowninput5.value = pl + minutesRound + min;
		document.timeForm.countdowninput6.value = pl + secondsRound + sec;
	*/

		if(document.timeForm)
		{

		document.timeForm.countdowninput0.value = y2k.getDate() + "." + y2k.getMonth() + "." + y2k.getFullYear();
		document.timeForm.countdowninput1.value = monthsRound;
		document.timeForm.countdowninput2.value = weeksRound;
		document.timeForm.countdowninput3.value = daysRound;
		document.timeForm.countdowninput4.value = hoursRound;
		document.timeForm.countdowninput5.value = minutesRound;
		document.timeForm.countdowninput6.value = secondsRound;
		}

		//document.write("&nbsp;" + daysRound + " Tagen,<br>&nbsp;" + hoursRound + " Stunden,<br>&nbsp;" + minutesRound + " Minuten<br>&nbsp;und " + secondsRound + " Sekunden");

		newtime = window.setTimeout("getTime();", 1000);
	}

////////////////////////////////////////////////////////////////////////////////////////////////////
// Sichtbarkeit von Inhalten
////////////////////////////////////////////////////////////////////////////////////////////////////

function visi(nr)
{
	if (document.layers)
	{
		visible = (document.layers[nr].display == '') ? 'none' : '';
		document.layers[nr].display = visible;
	}
	else if (document.all)
	{
		current = (document.all[nr].style.display == '') ? 'none' : '';
		document.all[nr].style.display = current;
	}
	else if (document.getElementsByName)
	{
		for (i=0; i<anz; i++)
		{
			visible = (document.getElementById(nr).style.display == '') ? 'none' : '';
			document.getElementById(nr).style.display = visible;
		}
	}
	else if (document.getElementById)
	{
		for (i=0; i<anz; i++)
		{
			visible = (document.getElementById(nr).style.display == '') ? 'none' : '';
			document.getElementById(nr).style.display = visible;
		}
	}
}

function blocking(nr,anz)
{
	if (document.layers)
	{
		visible = (document.layers[nr].display == 'none') ? '' : 'none';
		document.layers[nr].display = visible;
	}
	else if (document.all)
	{
		current = (document.all[nr].style.display == 'none') ? '' : 'none';
		document.all[nr].style.display = current;
	}
	else if (document.getElementsByName)
	{
		for (i=0; i<anz; i++)
		{
			if(document.getElementsByName(nr)[i].style.display == 'none')
			{
				document.getElementsByName(nr)[i].style.display = '';
				if(nr=="countercontent1"){document.counter_show_btn.src = "images/icons/minus.gif";}
			}else{
				document.getElementsByName(nr)[i].style.display = 'none';
				if(nr=="countercontent1"){document.counter_show_btn.src = "images/icons/plus.gif";}
			}
		}
	}
	else if (document.getElementById)
	{
		for (i=0; i<anz; i++)
		{
			visible = (document.getElementById(nr).style.display == 'none') ? '' : 'none';
			document.getElementById(nr).style.display = visible;
		}
	}
}

////////////////////////////////////////////////////////////////////////////////////////////////////
// 
////////////////////////////////////////////////////////////////////////////////////////////////////
