// expand div for galleries
 
   var x=50;
function expand() {
   document.getElementById("li").style.width=x+'px';
if(x>658) { 
   clearTimeout(t);
   return;
}
   x=x+10;
t=setTimeout('expand()',1/1000); 
 }
 
// StyleSwitcher functions written by Paul Sowden
// http://www.idontsmoke.co.uk/ss/
// http://www.alistapart.com/stories/alternate/
function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

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 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;
}

window.onload = function(e) {
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);

// http://www.maratz.com/blog/archives/2006/05/22/smart-back-to-top-link/
// top-scroll-link wird nur sichtbar, wenn das browser-fenster zu klein ist...
var d = document;
function topLinksichtbar(){
	var viewport_height = (self.innerHeight) ? self.innerHeight : (document.documentElement && document.documentElement.clientHeight) ? document.documentElement.clientHeight : (document.body) ? document.body.clientHeight : 0;
	var page_height = d.getElementsByTagName('body')[0].offsetHeight;
	var ttl = d.getElementById('scrollTop');
	if (page_height < viewport_height) ttl.style.visibility = 'hidden';
}
addLoadEvent(topLinksichtbar);

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

// dom scripting. s.200
function classeAendern(element, wert){
	if (!document.getElementById) return false;
	if (!document.getElementById(element)) return false;
	var el= document.getElementById(element);
	el.className = wert;
}

// image fadeIn
// http://clagnut.com/sandbox/imagefades/
document.write("<style type='text/css'>#thephoto {visibility:hidden;} </style>");

function initImage() {
	imageId = 'thephoto';
	if (!document.getElementById(imageId)) return false;
	image = document.getElementById(imageId);
	setOpacity(image, 0);
	image.style.visibility = 'visible';
	fadeIn(imageId,0);
}

function setOpacity(obj, opacity) {
	opacity = (opacity == 100)?99.999:opacity;
  
	// IE/Win
	obj.style.filter = "alpha(opacity:"+opacity+")";
	
	// Safari<1.2, Konqueror
	obj.style.KHTMLOpacity = opacity/100;
	
	// Older Mozilla and Firefox
	obj.style.MozOpacity = opacity/100;
	
	// Safari 1.2, newer Firefox and Mozilla, CSS3
	obj.style.opacity = opacity/100;
}

function fadeIn(objId,opacity) {
	if (document.getElementById) {
		obj = document.getElementById(objId);
		if (opacity <= 100) {
			  setOpacity(obj, opacity);
			  opacity += 10;
			  window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 100); //umso kuerzer, um so schneller
		}
	}
}

addLoadEvent(initImage);