// JavaScript Document
// Author: Mikel Wohlschlegel
// www.crash-freiburg.de

aktivbullet = "data/bullet_over.gif"  
normalbullet = "data/bullet.gif"

aktivbutton = "data/login_click.gif"
normalbutton = "data/login.gif"

homeaktiv = "data/home_over.gif"
homenormal = "data/home_normal.gif"

impressumaktiv = "data/impressum_over.gif"
impressumnormal = "data/impressum_normal.gif"

voteaktiv = "../../data/vote_button_over.gif"
votenormal = "../../data/vote_button.gif"

ticketsnormal = "../data/tickets_normal.gif"
ticketsover = "../data/tickets_over.gif"

function bildwechsel(imgname, imgsrc){
	imgname.src = imgsrc;
}

function BilderVorladen()
{
	document.Vorladen = new Array();
	if(document.images)
	{
		for(var i=0; i<BilderVorladen.arguments.length; i++)
		{
			document.Vorladen[i] = new Image();
			document.Vorladen[i].src = BilderVorladen.arguments[i];
		}
	}
}

function popUpWindow(URL, size) {
	myWindow=window.open(URL, "", size);
}

function popUpWindowNamed(URL, name, size) {
      day = new Date();
      id = day.getTime();
      eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1," + size + ",left = 10,top = 10');");
      }

function openpic(image) {
	var image;
        var win;
        win=window.open(image,"image","height=600,width=800,left=0,top=0,scrollbars=yes");
}      	   

function open_page(page) {
	var page;
	var win;
	win=window.open(page,"page","scrollbars=yes,resizable=yes,left=20,top=20,height=650,width=940");
}

function checkIEVersion() {
	if (browser.isIE && !browser.isIE6up) {
		alert('Dein Internet Explorer ist zu alt! Bitte installiere eine neue Version.');
	}
}

// Login Routines
// Author: A. Maunz

function open_login() {
	var benutzername;
	var passwort;
	
	benutzername=document.forms.login.benutzername.value;
	passwort=document.forms.login.passwort.value;
	passwort=hex_md5(passwort);
	
	setCookie('benutzername', benutzername, 365);
	setCookie('passwort', passwort, 365);
	location.href='quickstart.php';
	top.content.location.href='whatsnew.php';
}


function logout() {
	delCookie('benutzername');
	delCookie('passwort');
	delCookie('PHPSESSID');
	delCookie('cpg132_uid');
	delCookie('cpg132_pass');
	delCookie('cpg132_data');
	location.href='quickstart.php';
	top.content.location.href='whatsnew.php';
}

// Cookie Routines
// Author: A. Maunz

function getCookie(NameOfCookie) {
	// First we check to see if there is a cookie stored.
	// Otherwise the length of document.cookie would be zero.
	if (document.cookie.length > 0) {

		// Second we check to see if the cookie's name is stored in the
		// "document.cookie" object for the page.
		// Since more than one cookie can be set on a
		// single page it is possible that our cookie
		// is not present, even though the "document.cookie" object
		// is not just an empty text.
		// If our cookie name is not present the value -1 is stored
		// in the variable called "begin".
		begin = document.cookie.indexOf(NameOfCookie+"=");
		if (begin != -1) {

			// Our cookie was set.
			// The value stored in the cookie is returned from the function.
			begin += NameOfCookie.length+1;
			end = document.cookie.indexOf(";", begin);
			if (end == -1) {
				end = document.cookie.length;
			}
			return unescape(document.cookie.substring(begin, end)); }
		}

	// Our cookie was not set.
	// The value "null" is returned from the function.
	return null;
}

function setCookie(NameOfCookie, value, expiredays) {

	// Three variables are used to set the new cookie.
	// The name of the cookie, the value to be stored,
	// and finally the number of days until the cookie expires.
	// The first lines in the function convert
	// the number of days to a valid date.
	var ExpireDate = new Date ();
	ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));

	// The next line stores the cookie, simply by assigning
	// the values to the "document.cookie" object.
	// Note the date is converted to Greenwich Mean time using
	// the "toGMTstring()" function.
	document.cookie = NameOfCookie + "=" + escape(value) + ((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());
}


function delCookie (NameOfCookie) {

	// The function simply checks to see if the cookie is set.
	// If so, the expiration date is set to Jan. 1st 1970.
	if (getCookie(NameOfCookie)) {
		document.cookie = NameOfCookie + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}

