//  Sanitaetshaus-Herberhold.de - GLOBAL JS Data   --------------------------------- 

//  (C) 2008 joern-fester.de ------------------------------------------------------- 







// B R E A K  F R A M E S E T   -----------------------------------------------------



if (top.frames.length > 0)

  {

  top.location.href = self.location.href;

  }





// F O R M  C H E C K -------------------------------------------------------------



function formcheck () {

	if (document.forms[0].Name.value == '') {

	document.forms[0].Name.style.border='1px solid red';

	document.forms[0].Name.focus();

	return false;

}

	if (document.forms[0].Mail.value == '') {

	document.forms[0].Mail.style.border='1px solid red';

	document.forms[0].Mail.focus();

	return false;

}

	var str = document.forms[0].Mail.value;

	if (document.forms[0].Mail.value.indexOf ('@', 0) == -1 || str.length < 6 || document.forms[0].Mail.value.indexOf ('.',0) == -1){

	document.forms[0].Mail.style.border='1px solid red';

	document.forms[0].Mail.focus();

	return false;

}

	if (document.forms[0].Mitteilung.value == '') {

	document.forms[0].Mitteilung.style.border='1px solid red';

	document.forms[0].Mitteilung.focus();

	return false;

}

	return true;

}





// L I N K  E X T E R N --------------------------------------------------------

// by J. E. Hellbusch, J. Hofer & S. Heller - www.barrierefreies-webdesign.de



function newwindow() {

  neuesFenster = window . open(this . href);

  neuesFenster . focus();

  return false;

}



function searchnewwindows() {

  var externerLinkText = "Externer Link";

  var textNeuesFenster = " - öffnet in einem neuen Fenster";

  if (!document . getElementsByTagName) { return } ;

  var links = document . getElementsByTagName("a");

  for (i = 0; i < links . length; i++) {

        textAlt = links[i] . getAttribute("title");

        if (textAlt && (textAlt . indexOf(externerLinkText) != -1)) {

            textZusatz = textAlt . substring((textAlt . indexOf(externerLinkText)) + externerLinkText . length, textAlt . length);

            links[i] . setAttribute("title", externerLinkText + " " + textNeuesFenster + textZusatz);

      links[i] . onclick = links[i] . onkeypress = newwindow;

      links[i] . style . borderBottom = "0";

    }

  }

}





// S W I T C H E R -------------------------------------------------------------



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);





// Tooltip ---------------------------------------------------------------

// by Alessandro Fulciniti - http://pro.html.it 



function enableTooltips(id){

var links,i,h;

if(!document.getElementById || !document.getElementsByTagName) return;

AddCss();

h=document.createElement("span");

h.id="btc";

h.setAttribute("id","btc");

h.style.position="absolute";

document.getElementsByTagName("body")[0].appendChild(h);

if(id==null) links=document.getElementsByTagName("a");

else links=document.getElementById(id).getElementsByTagName("a");

for(i=0;i<links.length;i++){

    Prepare(links[i]);

    }

}



function Prepare(el){

var tooltip,t,b,s,l;

t=el.getAttribute("title");

if(t==null || t.length==0) return false;

el.removeAttribute("title");

tooltip=CreateEl("span","tooltip");

s=CreateEl("span","top");

s.appendChild(document.createTextNode(t));

tooltip.appendChild(s);

b=CreateEl("b","bottom");

/*

l=el.getAttribute("href");

if(l.length>28) l=l.substr(0,25)+"...";

b.appendChild(document.createTextNode(l));

*/

tooltip.appendChild(b);

setOpacity(tooltip);

el.tooltip=tooltip;

el.onmouseover=showTooltip;

el.onmouseout=hideTooltip;

el.onmousemove=Locate;

}



function showTooltip(e){

document.getElementById("btc").appendChild(this.tooltip);

Locate(e);

}



function hideTooltip(e){

var d=document.getElementById("btc");

if(d.childNodes.length>0) d.removeChild(d.firstChild);

}



function setOpacity(el){

el.style.filter="alpha(opacity:85)";

el.style.KHTMLOpacity="0.85";

el.style.MozOpacity="0.85";

el.style.opacity="0.85";

}



function CreateEl(t,c){

var x=document.createElement(t);

x.className=c;

x.style.display="block";

return(x);

}



function AddCss(){

}



function Locate(e){

var posx=0,posy=0;

if(e==null) e=window.event;

if(e.pageX || e.pageY){

    posx=e.pageX; posy=e.pageY;

    }

else if(e.clientX || e.clientY){

    if(document.documentElement.scrollTop){

        posx=e.clientX+document.documentElement.scrollLeft;

        posy=e.clientY+document.documentElement.scrollTop;

        }

    else{

        posx=e.clientX+document.body.scrollLeft;

        posy=e.clientY+document.body.scrollTop;

        }

    }

document.getElementById("btc").style.top=(posy+10)+"px";

document.getElementById("btc").style.left=(posx-20)+"px";

}





// Preload ------------------------------------------------------------------



var preload_images =

[

"/images/design/tooltip/tooltip2.gif",

"/images/design/imagelink/zoom.png",

"/images/design/load/bar.gif",

"/images/design/load/load.gif"

]

var load_next = 500 // Zeit in ms zwischen zwei Ladevorgaengen

var pos_array = 0



function preload()

{

var new_image = new Image()

new_image.src = preload_images[pos_array]

// Noch Bilder zu laden?

pos_array++

if(pos_array < preload_images.length)

setTimeout('preload()', load_next)

}



function preload_start()

{

if(preload_images.length == 0)

return

setTimeout('preload()', load_next)

}





// A D D  E V E N T S -----------------------------------------------------



window.onload=function() { searchnewwindows(); enableTooltips('main'); preload_start(); } 

