var Stil = "Standard";
var Keks = "wvbahnLayout";
// Ablauftage des cookies
var Tage = 30;
var csstext = new Array(
	// " A ","<em>B</em>","<strong> C </strong>");
	'<img src= "http://www.waldviertelbahn.at/wvbahn2006/pic/A8.gif" with="14" hight="14" border="0">',
	'<img src= "http://www.waldviertelbahn.at/wvbahn2006/pic/A10.gif" with="14" hight="14" border="0">',
	'<img src= "http://www.waldviertelbahn.at/wvbahn2006/pic/A12.gif" with="14" hight="14" border="0">'
	);
var csslink = new Array(
	"Standard","wvbahn2","wvbahn3");

var picver = "http://www.waldviertelbahn.at/wvbahn2006/pic/top-pic/"
var bilder1 = new Array(
picver+ 'top1.jpg',
picver+'top2.jpg',
picver+'top3.jpg',
picver+'top4.jpg',
picver+ 'top5.jpg',
picver+'top6.jpg',
picver+'top7.jpg',
picver+'top8.jpg',
picver+ 'top9.jpg',
picver+'top10.jpg',
picver+'top11.jpg'
);



 // suchtext = '<form name=suche action=http://www.resy.waldsoft.at/darstellen.asp method=post>
//					<input type=hidden name=id value=2004052484057>
  //					<input name=resy_suchfeld type=text class=input_css id="search_form">
	//            	<input type=submit name=resy_suche_submit class=input_css value="&raquo;" id="search_go">
	//			</form>';

suchtext ='<form name=suche action=http://www.resy.waldsoft.at/darstellen.asp method=post><input type=hidden name=id value=2006052684931><id="text_01" width="40">';
suchtext1='<input name=resy_suchfeld type=text class=input_css id="search_form"> <input type=submit name=resy_suche_submit class=input_css value="&raquo;" id="search_go"></form>';

// Style Switcher

window.onload = fensteropen;

//test!!
var storage = new function () {
	/* --------- Private Properties --------- */

	var dataContainer = {};

	/* --------- Private Methods --------- */

	function linearize () {
		var string = "", name, value;
		for (name in dataContainer) {
			name = encodeURIComponent(name);
			value = encodeURIComponent(dataContainer[name]);
			string += name + "=" + value + "&";
		}
		if (string != "") {
			string = string.substring(0, string.length - 1);
		}
		return string;
	}

	function read () {
		if (window.name == '' || window.name.indexOf("=") == -1) {
			return;
		}
		var pairs = window.name.split("&");
		var pair, name, value;
		for (var i = 0; i < pairs.length; i++) {
			if (pairs[i] == "") {
				continue;
			}
			pair = pairs[i].split("=");
			name = decodeURIComponent(pair[0]);
			value = decodeURIComponent(pair[1]);
			dataContainer[name] = value;
		}
	}

	function write () {
		window.name = linearize();
	}

	/* --------- Public Methods --------- */

	this.set = function (name, value) {
		dataContainer[name] = value;
		write();
	};

	this.get = function (name) {
		var returnValue = dataContainer[name];
		return returnValue;
	};

	this.getAll = function () {
		return dataContainer;
	};

	this.remove = function (name) {
		if (typeof(dataContainer[name]) != undefined) {
			delete dataContainer[name];
		}
		write();
	};

	this.removeAll = function () {
		dataContainer = {};
		write();
	};

	/* --------- Construction --------- */

	read();
};
//ende Test!!

function fensteropen() {
         var liste=storage.getAll();
         if (storage.get("cssart") == "") {

		loadStyle();
		storage.set("cssart",Stil);
		} else {
			if (storage.get("cssart") == "wvbahn2") { Stil = "wvbahn2"; storage.set("cssart", Stil); } else {
				if (storage.get("cssart") == "wvbahn3") { Stil = "wvbahn3"; storage.set("cssart", Stil); } else {Stil = "Standard"; storage.set("cssart", Stil); }};
			Stil = storage.get("cssart");
			setStyleCookie();
			switchStyle(Stil);
		};

}





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;
	// Martin eingefügt somit speichert er style permanent
	//window.name=s;
         storage.set("cssart", s);
	setStyleCookie()

  }
}




// 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 anzeig(text) {
	// <li class="bm"><a href="javascript:setStyle('Standard')">Standard Layout</a></li>
	// <li class="bm"><a href="javascript:setStyle('leithner1')">Leithner1</a></li>
	// <li class="bm"><a href="javascript:setStyle('leithner2')">Leitner2</a></li>

	 // var Homepage = "<a3>AAAAAAAAAAAAAAAAAAAA</a3>";
	 //document.write(Homepage.link("javascript:setStyle('leithner2')"));
	  document.write(text);
	  for (var i = 0; i < csslink.length; i++ ) {
		// var Homepage = "AAAAAAAAAAAAAAAAAAAA";

		varli = "javascript:setStyle('"+csslink[i]+"')";
		document.write(csstext[i].link(varli)+"  ");
		// document.write(csstext[i].link("javascript:setStyle(csslink[i])"));
		// automatischer aufruf für normalseite

    }
}


function suchfeld(text) {

		document.write(suchtext+text+suchtext1);

 }



function bildanzeig() {
	var anzahl = bilder1.length;
	var nr = Math.floor(Math.random()*anzahl);
	document.write('<p><img src="'+bilder1[nr]+'" width="780" height="120" alt="" />');

}

function setStyleCookie() {
  setCookie(Keks, Stil, Tage);
}

function getStyleCookie() {
  return getCookie(Keks);
}

function delStyleCookie() {
  delCookie(Keks);
}


// Stylesheet für Netscape 4

//if(document.layers)
//  document.writeln("<link rel='stylesheet' type='text/css' href='/nn4.css' />");