<!--
/*


      (c) 2006 kreativrot.de
      
      
*/


function zeve(uid)
{
    var divs = document.getElementsByName("Tab");
    for(var i=0; i < divs.length; i++)
    {
      var div = divs[i];
      var id = div.id;
      if (id != uid)
      {
        div.style.display = "none";
      }
    }
	if (document.getElementById(uid).style.display == 'none')
	{
		document.getElementById(uid).style.display = 'block';
	}
	else
	{
		document.getElementById(uid).style.display = 'none';
	}
}

function zehe(uid)
{
	if (document.getElementById(uid).style.visibility == 'hidden')
	{
		document.getElementById(uid).style.visibility = 'visible';
	}
	else
	{
		document.getElementById(uid).style.visibility = 'hidden';
	}
}




function show(img,width,height)
{
  status = 'no';
	var popupname = 'Zoomy';
	if (img && width && height)
	{
		posx = screen.width/2-width/2;
		posy = screen.height/2-height/2;
    popUp = window.open('zoom.php?img='+img,popupname,"toolbar=no,location=no,directories=no,status=" + status + ",scrollbars=yes,resizable=yes,width=" + width + ",height=" + height + ",screenX=" + posx + ",screenY=" + posy + ",left=" + posx + ",top=" + posy);
	}
	return;
}


function druck(img,width,height)
{
        width = width*1+10;
        height = height*1+60;
        status = 'no';
	var popupname = Math.round(Math.random() * 1000);
	if (img && width && height)
	{
		posx = screen.width/2-width/2;
		posy = screen.height/2-height/2;
		var popUp = window.open('print.php?img='+img,popupname,"menubar=yes,toolbar=no,location=no,directories=no,status=" + status + ",scrollbars=yes,resizable=yes,width=" + width + ",height=" + height + ",screenX=" + posx + ",screenY=" + posy + ",left=" + posx + ",top=" + posy);
	}
	return;
}

function little(source,width,height)
{
  status = 'no';
	var popupname = Math.round(Math.random() * 1000);
	if (source && width && height)
	{
		posx = screen.width/2-width/2;
		posy = screen.height/2-height/2;
    popUp = window.open(source,popupname,"toolbar=no,location=no,directories=no,status=" + status + ",scrollbars=yes,resizable=yes,width=" + width + ",height=" + height + ",screenX=" + posx + ",screenY=" + posy + ",left=" + posx + ",top=" + posy);
	}
	return;
}

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("olsenmoebel");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("olsenmoebel", title, 365);
}

var cookie = readCookie("olsenmoebel");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);





/* SEARCHHI */

function highlightWord(node,word) {
	// Iterate into this nodes childNodes
	if (node.hasChildNodes) {
		var hi_cn;
		for (hi_cn=0;hi_cn<node.childNodes.length;hi_cn++) {
			highlightWord(node.childNodes[hi_cn],word);
		}
	}
	
	// And do this node itself
	if (node.nodeType == 3) { // text node
		tempNodeVal = node.nodeValue.toLowerCase();
		tempWordVal = word.toLowerCase();
		if (tempNodeVal.indexOf(tempWordVal) != -1) {
			pn = node.parentNode;
			if (pn.className != "searchword") {
				// word has not already been highlighted!
				nv = node.nodeValue;
				ni = tempNodeVal.indexOf(tempWordVal);
				// Create a load of replacement nodes
				before = document.createTextNode(nv.substr(0,ni));
				docWordVal = nv.substr(ni,word.length);
				after = document.createTextNode(nv.substr(ni+word.length));
				hiwordtext = document.createTextNode(docWordVal);
				hiword = document.createElement("span");
				hiword.className = "searchword";
				hiword.appendChild(hiwordtext);
				pn.insertBefore(before,node);
				pn.insertBefore(hiword,node);
				pn.insertBefore(after,node);
				pn.removeChild(node);
			}
		}
	}
}

function googleSearchHighlight() {
	if (!document.createElement) return;
	ref = window.location.href;
	if (ref.indexOf('?') == -1) return;
	qs = ref.substr(ref.indexOf('?')+1);
	qsa = qs.split('&');
	for (i=0;i<qsa.length;i++) {
		qsip = qsa[i].split('=');
	        if (qsip.length == 1) continue;
        	if (qsip[0] == 'q' || qsip[0] == 'p') { // q= for Google, p= for Yahoo
			words = unescape(qsip[1].replace(/\+/g,' ')).split(/\s+/);
	                for (w=0;w<words.length;w++) {
				highlightWord(document.getElementById("content_in"),words[w]);
                	}
	        }
	}
}

window.onload = googleSearchHighlight;

//-->
