var Seite = 0; var Farbe = 9; var Start = true;

function initCSS() {
  var Param = self.location.search;
  if(!Param) Param=Keks();
  if(!Param) {
    Farbe = (new Date().getTime() %4) + 6;
    Seite = new Date().getTime() %6;
  }
  else {
    if(Param.indexOf("blau",0)!=-1) Farbe = 9;
    if(Param.indexOf("braun",0)!=-1) Farbe = 6;
    if(Param.indexOf("violett",0)!=-1) Farbe = 7;
    if(Param.indexOf("sw",0)!=-1) Farbe = 8;
    if(Param.indexOf("links",0)!=-1) Seite = 0;
    if(Param.indexOf("rechts",0)!=-1) Seite = 1;
    if(Param.indexOf("imtext",0)!=-1) Seite = 2;
    if(Param.indexOf("oben",0)!=-1) Seite = 3;
    if(Param.indexOf("760px",0)!=-1) Seite = 4;
    if(Param.indexOf("integriert",0)!=-1) Seite = 5;
  }
  Wechsel(Seite)
}

function deepLink() {
  var f = ""; var s = "";
  if(Farbe == 9) f = "blau";
  if(Farbe == 6) f = "braun";
  if(Farbe == 7) f = "violett";
  if(Farbe == 8) f = "sw";
  if(Seite == 0) s = "links";
  if(Seite == 1) s = "rechts";
  if(Seite == 2) s = "imtext";
  if(Seite == 3) s = "oben";
  if(Seite == 4) s = "760px";
  if(Seite == 5) s = "integriert";
  if(f != "" && s != "") {
    var fs = f + "-" + s
    document.getElementById("Kombination").firstChild.nodeValue = fs;
    document.links[19].href = "http://www.1ngo.de/web/css-layout.html?" + fs;
    if(Start) Start = false; else Keks(fs);
  }
}

function Wechsel(Layout) {
  if (Layout == -1) {
    for (i=0; i<11; i++) document.getElementsByTagName("style")[i].disabled = true;
  }
  else {
    document.getElementsByTagName("style")[0].disabled = false;
    document.getElementsByTagName("style")[10].disabled = true;
    if (Layout < 6) Seite = Layout; else Farbe = Layout;
    deepLink();
    if (Seite) document.getElementById("w0").style.fontWeight = "normal";
    else document.getElementById("w0").style.fontWeight = "bold";
    for (i=1; i<6; i++) {
      if (Seite == i) {
        document.getElementsByTagName("style")[i].disabled = false;
        document.getElementById("w"+i).style.fontWeight = "bold"
      }
      else {
        document.getElementsByTagName("style")[i].disabled = true;
        document.getElementById("w"+i).style.fontWeight = "normal"
      }
    }
    for (i=6; i<10; i++) {
      if (Farbe == i) {
        document.getElementsByTagName("style")[i].disabled = false;
        document.getElementById("w"+i).style.fontWeight = "bold";
      }
      else {
        document.getElementById("w"+i).style.fontWeight = "normal";
        document.getElementsByTagName("style")[i].disabled = true;
      }
    }
    var Style = new Array(41);
    if (Farbe == 9) {
      Style[0] = "background:#069;";
      Style[3] = "background:#069;";
      Style[5] = "border-color:#6cf;";
      Style[13] = "color:black;"; Style[14] = "color:black;";
      Style[26] = "background:#39c;";
      Style[27] = "border-color: #5bd #035 #068 #6cf;";
      Style[28] = "border-left: 1em solid #fc0;";
      Style[29] = "border-color: #069 #6cf #5bd #f30;";
      Style[30] = "background:#069;";
      Style[31] = "border-color: #5bd #035 #068 #f30;";
      Style[32] = "border-color: #069 #6cf #5bd #fc0;";
      Style[33] = "background:#28b;";
      Style[34] = "border-color: #069 #6cf #5bd white;";
      Style[35] = "background:#069;";
    }
    if (Farbe == 8) {
      Style[0] = "background:silver;";
      Style[3] = "background:gray;";
      Style[5] = "border-color:white;";
      Style[13] = "color:black;"; Style[14] = "color:black;";
      Style[26] = "background:gray;";
      Style[27] = "border-color:white black black #999;";
      Style[28] = "border-left:1em solid #999;";
      Style[29] = "border-color: #333 black #ccc #069;";
      Style[30] = "background:#666;";
      Style[31] = "border-color: #333 black #ccc #39c;";
      Style[32] = "border-color: #333 black #ccc white;";
      Style[33] = "background:#666;";
      Style[34] = "border-color: #333 #000 #ccc #666;";
      Style[35] = "background:#333;";
      Style[38] = "color:black;";
    }
    else {
      Style[38] = "color:white;";
    }
    if (Farbe == 7) {
      Style[0] = "background:#947;";
      Style[3] = "background:#a06;";
      Style[5] = "border-color:white;";
      Style[13] = "color:teal;"; Style[14] = "color:teal;";
      Style[26] = "background:#b69;";
      Style[27] = "border-color: #d9b #715 #715 #ecd;";
      Style[28] = "border-left: 1em solid #a58;";
      Style[29] = "border-color: #715 #ecd #d9b #ecd;";
      Style[30] = "background:#a06;";
      Style[31] = "border-color: #d9b #715 #715 #ecd;";
      Style[32] = "border-color: #715 #ecd #d9b #947;";
      Style[33] = "background:#a58;";
      Style[34] = "border-color: #715 #ecd #d9b white;";
      Style[35] = "background:#a06;";
    }
    if (Farbe == 6) {
      Style[0] = "background:#800;";
      Style[3] = "background:#c40;";
      Style[5] = "border-color:#fc0;";
      Style[13] = "color:black;"; Style[14] = "color:black;";
      Style[26] = "background:#900;";
      Style[27] = "border-color: #f70 #300 #600 #e60;";
      Style[28] = "border-left: 1em solid #fc0;";
      Style[29] = "border-color: #600 #f70 #e60 #f70;";
      Style[30] = "background:#c40;";
      Style[31] = "border-color: #f70 #300 #600 #f70;";
      Style[32] = "border-color: #600 #f70 #e60 #fc0;";
      Style[33] = "background:#a20;";
      Style[34] = "border-color: #600 #f70 #e60 white;";
      Style[35] = "background:#c40;";
    }
    if (Seite < 4) Style[1] = "width:auto;"; else Style[1] = "width:760px;";
    if (Seite < 3) Style[2] = "margin: 0 0 2em;"; else Style[2] = "margin:0;";
    if (Seite == 5) {
      Style[4] = "border: 3px solid white;";
      Style[5] = "border-right-color:#999; border-bottom-color:#999;";
      document.getElementsByTagName("h1")[0].style.borderColor = "white";
      document.getElementsByTagName("h1")[0].style.borderRightColor = "#999";
      document.getElementsByTagName("h1")[0].style.borderBottomColor = "#999";
      Style[9] = "margin:0;";
      Style[10] = "border-top-width:0; border-bottom-width:0;";
      Style[12] = "margin:0;";
      Style[15] = "float:right;";
      Style[17] = "margin: 2em 1em 1em 2em;";
      Style[22] = "margin-right:2em;";
      Style[36] = "text-align:center;";
      Style[37] = "margin:0;";
      Style[39] = "border-left: 3px solid white;";
      Style[40] = "border-bottom: 3px solid #999; border-right: 3px solid #999;";
      Style[41] = "margin-top:0;";
    }
    else {
      Style[4] = "border-width:1px; border-style:solid;";
      var x = Style[5].slice(Style[5].indexOf(":")+1,Style[5].indexOf(";"));
      document.getElementsByTagName("h1")[0].style.borderColor = x;
      Style[10] = "border-top-width:3px; border-bottom-width:3px;";
      Style[36] = "text-align:right;";
      Style[37] = "margin: -3.5em 0 0 0;";
      Style[39] = "border-left: 0 none;";
      Style[40] = "border-bottom: 0 none; border-right: 0 none;";
      Style[41] = "margin-top:1em;";
    }
    if (Seite) {
      Style[6] = "float:none;";
      Style[8] = "width:auto;";
      Style[11] = "width:auto;";
    }
    else {
      Style[6] = "float:left;";
      Style[8] = "width:73%;";
      Style[9] = "margin: 0 0 1em 3em;";
      Style[11] = "width:69%;";
      Style[12] = "margin: 0 0 1em 3em;";
      Style[15] = "float:left;";
      Style[17] = "margin: 3em 0;";
      Style[22] = "margin-right:0;";
    }
    if (Seite == 3 || Seite == 4) {
      Style[7] = "clear:left;";
      Style[16] = "width:auto;";
      Style[23] = "float:left;";
      Style[24] = "width:12em;";
    }
    else {
      Style[7] = "clear:none;";
      Style[16] = "width:12em;";
      Style[23] = "float:none;";
      Style[24] = "width:auto;";
      Style[25] = "margin:0;";
    }
    if (Seite == 1) {
      Style[9] = "margin: 2em 12em 4em 2em;";
      Style[12] = "margin: 2em 12em 0 2em;";
      Style[15] = "float:right;";
      Style[17] = "margin: 2em 0.5em 2em 0;";
      Style[22] = "margin-right:0.5em;";
    }
    if (Seite == 2) {
      Style[9] = "margin: 2em 2em 4em 2em;";
      Style[12] = "margin: 2em 2em 0 2em;";
      Style[15] = "float:right;";
      Style[17] = "margin: 2em 2em 1em 2em;";
      Style[22] = "margin-right:4em;";
    }
    if (Seite == 3) {
      Style[9] = "margin: 2em 2em 5em;";
      Style[12] = "margin: 3em 2em 2em;";
      Style[15] = "float:none;";
      Style[17] = "margin:2em;";
      Style[22] = "margin: 2em 0 4em 2em;";
      Style[25] = "margin: 0 0.5em 0 0.5em;";
    }
    if (Seite == 4) {
      Style[9] = "margin: 1px 0 5em;";
      Style[12] = "margin: 1px 0 2em;";
      Style[15] = "float:none;";
      Style[17] = "margin: 1px 0 0;";
      Style[18] = "padding: 0 3em;";
      Style[19] = "height:6em;";
      if (Farbe == 9) {
        Style[20] = "background-color:#069;";
        document.getElementById("imenu").style.backgroundColor = "#069";
        Style[21] = "border:1px solid #6cf;";
        document.getElementById("imenu").style.border = "1px solid #6cf";
      }
      if (Farbe == 8) {
        Style[20] = "background-color:#069;";
        document.getElementById("imenu").style.backgroundColor = "#069";
        Style[21] = "border:1px solid white;";
        document.getElementById("imenu").style.border = "1px solid white";
      }
      if (Farbe == 7) {
        Style[20] = "background-color:#a58;";
        document.getElementById("imenu").style.backgroundColor = "#a58";
        Style[21] = "border:1px solid white;";
        document.getElementById("imenu").style.border = "1px solid white";
      }
      if (Farbe == 6) {
        Style[20] = "background-color:#a00;";
        document.getElementById("imenu").style.backgroundColor = "#a00";
        Style[21] = "border:1px solid #fc0;";
        document.getElementById("imenu").style.border = "1px solid #fc0";
      }
      Style[22] = "margin-right:0;";
      Style[25] = "margin: 0 1em 0 0;";
    }
    else {
      Style[18] = "padding: 0 1px;";
      Style[19] = "height:auto;";
      Style[20] = "background-color:transparent;";
      document.getElementById("imenu").style.backgroundColor = "transparent";
      Style[21] = "border: 0 none;";
      document.getElementById("imenu").style.border = "0 none";
    }
    for (i=0; i<42; i++) document.getElementById("Style"+i).firstChild.nodeValue = Style[i];
  }
}

function Keks (Param) {
  if (Param) {
    var d = new Date(new Date().getTime()+(1000*86400*365));
    document.cookie = "csslayout=" + Param + "; expires=" + d.toGMTString() + ";";
  }
  else if(document.cookie) {
    var k = document.cookie;
    return k.slice(k.indexOf("=")+1);
  }
}