var Stil = "Standard";
var Keks = "Layout";
var Tage = 30;

// Style Switcher

function switchStyle(s) {
  if (!document.getElementsByTagName) return;
  var el = document.getElementsByTagName("link");
  for (var i = 0; i < el.length; i++ ) {
    if (el[i].getAttribute("rel").indexOf("style") != -1 && el[i].getAttribute("title")) {
      el[i].disabled = true;
      if (el[i].getAttribute("title") == s) el[i].disabled = false;
    }
  }
}

function loadStyle() {
  var c = getStyleCookie();
  if (c && c != Stil) {
    switchStyle(c);
    Stil = c;
  }
}

function setStyle(s) {
  if (s != Stil) {
    switchStyle(s);
    Stil = s;
  }
}

window.onload = loadStyle;


// Cookie-Funktionen

function setCookie(name, value, expdays) {   // gültig expdays Tage
  var now = new Date();
  var exp = new Date(now.getTime() + (1000*60*60*24*expdays));
  document.cookie = name + "=" + escape(value) + ";" +
                    "expires=" + exp.toGMTString() + ";" +
                    "path=/";
}

function delCookie(name) {   // expires ist abgelaufen
  var now = new Date();
  var exp = new Date(now.getTime() - 1);
  document.cookie = name + "=;" +
                    "expires=" + exp.toGMTString() + ";" +
                    "path=/";
}

function getCookie(name) {
  var cname = name + "=";
  var dc = document.cookie;
  if (dc.length > 0) {
    var start = dc.indexOf(cname);
    if (start != -1) {
      start += cname.length;
      var stop = dc.indexOf(";", start);
      if (stop == -1) stop = dc.length;
      return unescape(dc.substring(start,stop));
    }
  }
  return null;
}

function setStyleCookie() {
  setCookie(Keks, Stil, Tage);
}

function getStyleCookie() {
  return getCookie(Keks);
}

function delStyleCookie() {
  delCookie(Keks);
}






/*
    dw_fontsizer.js  version date: Jan 2004
    requires dw_cookies.js

    This code manipulates document.body.style.fontSize.
    Other elements sized using relative measures (em's or %)
    in style sheets will adjust accordingly.
    Exclude elements (i.e., selectors) by using pixels, points or
    constants (small, medium, etc.) to set their font-size in style sheets.
*/



var dw_fontSizer = {
  // sizeUnit and defaultSize for body.style.fontSize
  sizeUnit: "px",
  defaultSize: 14,
  // numbers (same unit as sizeUnit)
  maxSize:     24,
  minSize:     10,

  init: function() {
    if ( !document.body || !document.getElementById ) return;
    var size = window.location.search? window.location.search.slice(1): getCookie("fontSize");
    size = !isNaN( parseFloat(size) )? parseFloat(size): this.defaultSize;
    // in case default unit changed or size passed in url out of range
    if ( size > this.maxSize || size < this.minSize ) size = this.defaultSize;
    var sizerEl = document.getElementById('sizer');
    if (sizerEl) sizerEl.style.display = "block";
    document.body.style.fontSize = size + this.sizeUnit;
  },

  adjust: function(inc) {
    var size = parseFloat( document.body.style.fontSize );
    size += inc;
    // Test against max and min sizes
    if (inc > 0) size = Math.min(size, this.maxSize);
    else size = Math.max(size, this.minSize);
    setCookie( "fontSize", size, 180, "/" );
    document.body.style.fontSize = size + this.sizeUnit;
    location.reload()
  },

  reset: function() {
    document.body.style.fontSize = this.defaultSize + this.sizeUnit;
    deleteCookie("fontSize", "/");
  }

}






/*********************************************************************************
  dw_cookies.js - cookie functions for www.dyn-web.com
  Recycled from various sources
**********************************************************************************/

// Modified from Bill Dortch's Cookie Functions (hidaho.com)
// (found in JavaScript Bible)
function setCookie(name,value,days,path,domain,secure) {
  var expires, date;
  if (typeof days == "number") {
    date = new Date();
    date.setTime( date.getTime() + (days*24*60*60*1000) );
                expires = date.toGMTString();
  }
  document.cookie = name + "=" + escape(value) +
    ((expires) ? "; expires=" + expires : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}

// Modified from Jesse Chisholm or Scott Andrew Lepera ?
// (found at both www.dansteinman.com/dynapi/ and www.scottandrew.com/junkyard/js/)
function getCookie(name) {
  var nameq = name + "=";
  var c_ar = document.cookie.split(';');
  for (var i=0; i<c_ar.length; i++) {
    var c = c_ar[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameq) == 0) return unescape( c.substring(nameq.length, c.length) );
  }
  return null;
}

// from Bill Dortch's Cookie Functions (hidaho.com)
function deleteCookie(name,path,domain) {
  if (getCookie(name)) {
    document.cookie = name + "=" +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}







