// -------------------------------------------------------------------------------------------------------//
// browserindependant window opener
function launchCenter(url, name, height, width, params) {
  var str = "height=" + height + ",innerHeight=" + height;
  str += ",width=" + width + ",innerWidth=" + width;
  if (window.screen) {
    var ah = screen.availHeight - 30;
    var aw = screen.availWidth - 10;

    var xc = (aw - width) / 2;
    var yc = (ah - height) / 2;

    str += ",left=" + xc + ",screenX=" + xc;
    str += ",top=" + yc + ",screenY=" + yc;
  }
  if (params != ""){
  	str += "," + params ;
  }
  newindow = window.open(url, name, str);
}

// -------------------------------------------------------------------------------------------------------//
// JS function for uncrypting spam-protected emails:
function UnCryptMailto(s) {	//
	var n=0;
	var r="";
	for(var i=0; i < s.length; i++) {
		n=s.charCodeAt(i);
		if (n>=8364) {n = 128;}
		r += String.fromCharCode(n-(2));
	}
	return r;
}
  // JS function for uncrypting spam-protected emails:
function linkTo_UnCryptMailto(s)	{	//
	location.href="mailto:"+UnCryptMailto(s);
}


// -------------------------------------------------------------------------------------------------------//
// Datum (deutsch)
				var now = new Date();
				var yr = now.getYear();
				var mName = now.getMonth() + 1;
				var dName = now.getDay() + 1;
				var dayNr = ((now.getDate()<10) ? "0" : "")+ now.getDate();
				if(dName==1) Day = "Sonntag";
				if(dName==2) Day = "Montag";
				if(dName==3) Day = "Dienstag";
				if(dName==4) Day = "Mittwoch";
				if(dName==5) Day = "Donnerstag";
				if(dName==6) Day = "Freitag";
				if(dName==7) Day = "Samstag";
				if(mName==1) Month="01";
				if(mName==2) Month="02";
				if(mName==3) Month="03";
				if(mName==4) Month="04";
				if(mName==5) Month="05";
				if(mName==6) Month="06";
				if(mName==7) Month="07";
				if(mName==8) Month="08";
				if(mName==9) Month="09";
				if(mName==10) Month="10";
				if(mName==11) Month="11";
				if(mName==12) Month="12";
				if(yr<2000) yr += 1900;
				// String to display current date.
				var todaysDate =(" "
				+ Day
				+ ", "
				+ dayNr
				+ "."
				+ Month
				+ "."
				+ yr);
				
// This function checks the url and compares it with a specific HREF set
function returnLocationMatch(hrefData,urlData){
	thisHref = hrefData.split('/');
	lenHref = thisHref.length;
	thisUrl = urlData.split('/');
	lenUrl = thisUrl.length;
	if ((thisHref[lenHref - 1] == thisUrl[lenUrl - 1])||(thisHref[lenHref - 1] == 'index.php')&&(thisUrl[lenUrl - 1] == '')){
			return true;
		}else{
			return false;
	}
}				
				
// JQuery bindings
	$(document).ready(function(){
		$('#mainnavi li a').each(function(){
			if(returnLocationMatch(this.href,window.location.pathname) == true){
					$(this).parent().addClass('aktiv');
				};
			});
	});
