// JavaScript Document www.schwedenteam.de
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}


function BlurLinks(){
var lnks = document.getElementsByTagName('a');
	for(i=0;i<lnks.length;i++){
		lnks[i].onfocus=new Function("if(this.blur)this.blur()");
	}
}

/////////////// Liveclock
var sf_clock_monthnames = new Array("Januar","Februar","M&auml;rz","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember");

var sf_clock_daynames = new Array("Sonntag","Montag","Dienstag","Mittwoch","Donnerstag","Freitag","Samstag");

function sf_clock_timeSource(){
   clock_jetzt=new Date();
   clock_jetzt.setTime(clock_jetzt.getTime());
   return clock_jetzt;
}

function sf_clock_leadingZero(clock_actualtime){
  var clock_uhrzeit;
  if(clock_actualtime > 9){
  	clock_uhrzeit = clock_actualtime;
  } else {
  	clock_uhrzeit = '0'+clock_actualtime;
  }
  return clock_uhrzeit;
}

function sf_clock_displayTime(){
   document.getElementById('dynamicdate').innerHTML=eval(clock_outputTime);
   setTimeout('sf_clock_displayTime()',1000);
}

function sf_clock_fixYear(clock_actualyear){
  var clock_jahr;
  if(clock_actualyear <500){
  	clock_jahr = clock_actualyear+1900;
  } else {
  	clock_jahr = clock_actualyear;
  }
  return clock_jahr;
}

var clock_outputTime="sf_clock_daynames[sf_clock_timeSource().getDay()]+', '+sf_clock_leadingZero(sf_clock_timeSource().getDate())+'.'+' '+sf_clock_monthnames[sf_clock_timeSource().getMonth()]+' '+' '+sf_clock_fixYear(sf_clock_timeSource().getYear())+','+' '+' '+sf_clock_leadingZero(sf_clock_timeSource().getHours())+':'+sf_clock_leadingZero(sf_clock_timeSource().getMinutes())+':'+sf_clock_leadingZero(sf_clock_timeSource().getSeconds())+' Uhr'";


////////////// Keep in view
KeepInView = function(KIV_id){
	var KIV_getPageY=function(KIV_el){
		return(KIV_el==null)?0:KIV_el.offsetTop+KIV_getPageY(KIV_el.offsetParent);
	}
	
	var KIV_getScrollTop=function(){
		return document.body.scrollTop||document.documentElement.scrollTop
	}
	
	var KIV_el=document.getElementById(KIV_id);
	
	if(KIV_el==null){
		return;
	}
	
	if(KIV_el.style.position=="absolute"){
		KIV_el.startPageTop=-KIV_el.offsetTop;
		KIV_el.currentX=KIV_el.offsetLeft;
		KIV_el.currentY=KIV_el.offsetTop;
	} else{
		KIV_el.style.position="relative";
		KIV_el.startPageTop=KIV_getPageY(KIV_el);
		KIV_el.currentX=KIV_el.currentY=0;
	}
	
	KIV_el.KIV_floatInView=function(){
		var KIV_targetY=(KIV_getScrollTop()>this.startPageTop)?KIV_getScrollTop()-this.startPageTop:0;
		this.currentY+=(KIV_targetY-this.currentY)/4;
		this.style.top=this.currentY+"px";
	};
	
	setInterval('document.getElementById("'+KIV_id+'").KIV_floatInView()',40);
}
////////////////
function in_array(item,arr) {
	for(p=0;p<arr.length;p++) if (item == arr[p]) return true;
	return false;
}

function trim_string (zeichenkette) {
	return zeichenkette.replace (/^\s+/, "").replace (/\s+$/, "");
}

function no_lb (zeichenkette) {
	if(zeichenkette != "undefined"){
		return zeichenkette.replace(/[\r\n]+/g, "");
	} else {
		return false;	
	}
}

function resizeimg()
{
   if (document.getElementsByTagName)
   {
      for (i=0; i<document.getElementsByTagName('img').length; i++)
      {
         im = document.getElementsByTagName('img')[i];
         if (im.width > 400)
         {
            im.style.width = '400px';
         }
      }
   }
}

