﻿//********************
//*** Browsercheck ***
//********************

var dom = document.getElementById ? true:false;
var nn4 = !dom && document.layers ? true:false;
var ie4 = !dom && !nn4 && document.all ? true:false;


//******************
//*** CSS WEICHE ***
//******************

document.write("<!--[if IE 5]>");
	document.write("<link href='"+startpfad_+"css/ie6.css' rel='stylesheet' type='text/css' media='all'>");
document.write("<![endif]-->");

document.write("<!--[if IE 6]>");
	document.write("<link href='"+startpfad_+"css/ie6.css' rel='stylesheet' type='text/css' media='all'>");
document.write("<![endif]-->");

function  econtact(actcon)
{
	var endcom = '.de';
	
	var domain1 = 'nexusklinik';

	
	var contact = new Array();
	
	contact["info"] = "info" +'@'+ domain1 + endcom;

	window.location = "mailto:"+contact[actcon];
}

//************************
//*** TIMER FUNKTIONEN ***
//************************

var infoLayer=null;
var TimeOutEvents=0; 


function checkInfoLayer()
{
	//var dummy=document.getElementById("infobox");
	//dummy.innerHTML=infoLayer+"  "+TimeOutEvents;
	if(infoLayer==null)
	{
		TimeOutEvents=0;
	}
	else
	{
		TimeOutEvents++;
	}

	if(TimeOutEvents==2)
	{
		infoLayer.style.visibility="visible";
	}
}


//************************
//*** MENUE FUNKTIONEN ***
//************************

// sind in "menue.js" vorhanden 

//***********************************************************
//*** JAVACRIPT BEFEHLSERWEITERUNGEN***
//***********************************************************

//-------- Variable testen

//--- Erwartet als Parameter den Namen der Variable in einem String.

isDefined = function(variable){ 
	return this[variable] === undefined ? false : true;
};


//----------- String

function strReplace(strsearch, strreplace, haystack)
{
	// Autor : Thomas B?chler
	// Erstellt : 13.04.2004
	// Beschreibung : Ersetzt alle strsearch innerhalb haystack durch strreplace

	if ((haystack == null) || (strsearch == null))
	{
		return null;
	}
   	
   	if ((haystack.length == 0) || (strsearch.length == 0))
   	{
   		return haystack;
   	}

    if ((strreplace == null) || (strreplace.length == 0))
    { 
    	strreplace = "";
    }

    var len_strsearch = strsearch.length;
    var len_strreplace = strreplace.length;
    var Pos = haystack.indexOf(strsearch, 0);

    while (Pos >= 0)
    {
    	haystack = haystack.substring(0, Pos) + strreplace + haystack.substring(Pos + len_strsearch);
    	Pos = haystack.indexOf(strsearch, Pos + len_strreplace);
    }
    
    return haystack;
}

//-------- AJAX

function createXMLHttpRequest() 
{
 var req = null;

   try 
   {
     req = new ActiveXObject("MSXML2.XMLHTTP");
   }  

   catch (err_MSXML2) {

     try
     {
       req = new ActiveXObject("Microsoft.XMLHTTP");
     }

     catch (err_Microsoft) {

       if (typeof XMLHttpRequest != "undefined")
         req = new XMLHttpRequest;
     }
   }
   return req;
}




//***************************
//*** FORMULAR FUNKTIONEN *** 
//***************************

// Autor : Andreas Jaehrling
// Erstellt : 13.07.06
// Beschreibung: Die Funktionen "FieldContentDel" (onmousedown) und "FieldContentRestore" (onblur) werden typischerweise f?r ein E-Mail Feld mit dem vorgegebenen Wert "E-Mail" verwendet. 

function FieldContentDel(obj, val)
{
	if(obj.value==val)
	{
		obj.value="";
	}
}


function FieldContentRestore(obj, val)
{
	if(obj.value=="")
	{
		obj.value=val;
	}
}


// Autor : Andreas Jaehrling
// Erstellt : 11.07.06
// Beschreibung: Schreibt den Wert "val" ind das Formularobjekt "obj". 

//-- ACHTUNG!! Im Moment muss das Formular bei verwendung von Radiobuttons zwingend "Formular" heissen
//--- Um eine unabhängige Funktion zu erhalten müsste noch eine Routine integriert werden die anhand des übergebenen Objektes den Namen eigenständig ermittelt. 

function FormWriteValue(obj, val)
{
	switch(obj.type)
	{				
		case "select-one":
			for(var f=0; f<obj.length; f++)
			{
				if(obj.options[f].value==val)
				{
					obj.options[f].selected=true;
				}
			}
		break;


		case "select-multiple":
			for(var f=0; f<obj.length; f++)
			{
				if(obj.options[f].value==val)
				{
					obj.options[f].selected=true;
				}
			}
		break;

			
		case "checkbox":
			obj.checked=true;
		break;
				
		case "radio": 
			var dummy=obj.name;
		
			popUpObj=(eval("document.Formular."+dummy));
			
			for(var f=0; f<popUpObj.length; f++)
			{
				if(popUpObj[f].value==val)
				{
					popUpObj[f].checked=true;
				}
			}
		break;			
				
							
		default:
			obj.value = val;
		break;
	}
}

//**************************
//*** FENSTER FUNKTIONEN ***  
//**************************

function winArchivShow(img, directory, infotext)
{
	// Autor : Andreas Jaehrling
	// Erstellt : 18.08.2006
	// Beschreibung: Erzeugt ein Zoom-Fenster mit einem Bild aus dem Archiv.
	// Übergeben wird das Objekt (img) oder der Name des Originalbildes, sowei das Verzeichnis in dem innerhalb von "archiv/images/" gesucht wird. 
	// Das Fenster passt sich der Größe des Bildes an.
 	// Geändert: 19.10.06 - Infotext nun möglich
 	
	if(typeof(img)=="object")
	{
		img = img.src;
	} 	
	
	var l=img.length;
	var pos=img.lastIndexOf("/");
	var fileName=img.substring(pos+1, l);
	var img=img.substring(0,pos+1);
	var newImage="archiv/images/"+directory+"/"+fileName;
	 	 
	winZoomShow(newImage, startpfad_, infotext);
}



function winBigShow(img)
{
	// Autor : Andreas Jaehrling
	// Erstellt : 09.08.2006
	// Beschreibung: Klassische Version. Erzeugt ein Zoom-Fenster mit einem Bild als Inhalt. Übergeben wird das Objekt oder der Pfad des Originalbildes.
	// Die Funktion geht davon aus dass das Bild im Verzeichnis "big" innerhalb des Verzeichnisses des Originalbildes liegt.	 	

	if(typeof(img)=="object")
	{
		img = img.src;
	} 	
	
	var l=img.length;
	var pos=img.lastIndexOf("/");
	var fileName=img.substring(pos+1, l);
	var img=img.substring(0,pos+1);
	var newImage=img+"big/"+fileName;
		
	winZoomShow(newImage, startpfad_)	
}


function winZoomShow(img, startpfad, infotext)
{
	// Autor : Andreas Jaehrling
	// Erstellt : 22.06.2006
	// Beschreibung: Erzeugt ein Zoom-Fenster mit einem Bild als Inhalt.
	// Das Fenster passt sich der Größe des Bildes an.
	// Geändert: 19.10.06 - Infotext nun möglich
 	
	open(startpfad+"zoom/index.php?image="+img+"&infotext="+infotext,"Zoom","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=150,height=150,screenX=20,screenY=20,top=20,left=20");
}


function winPageOpen(path, width, height)
{
	// Autor : Andreas Jaehrling
	// Erstellt : 23.06.2006
	// Beschreibung: Erzeugt ein Zoom-Fenster mit einer Datei als Inhalt. Die aktuelle Bildschirmaufl?sung wird dabei ber?cksichtigt.
	
	var buffer=50;
	var width= width+buffer>screen.availWidth?screen.availWidth-buffer : width;
	var height= height+buffer>screen.availHeight?screen.availHeight-buffer : height;  

	open(path,"","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width="+width+",height="+height+",screenX=10,screenY=10,top=10,left=10");
}




//- Druckversion ***


function showPrintVersion(idName)
{
	// Autor : Thomas Büchler
	// Erstellt : 01.10.2004
	// Geändert: 11.08.06 - Andreas Jährling - Neuer Aufbau der Seite
	// Kommentar : ACHTUNG Version ohne Headline-Filterung
	

	var textzelle = document.getElementById(idName);
	var text = textzelle.innerHTML;
	
	///////////////////// Links filtern		
	while (text.indexOf("href=\"") != -1)
	{
		var part0 = text.substr(text.indexOf("href=\"")+6,text.length);
		var part1 = part0.substr(0,part0.indexOf("\""));	
		
		part1 = "href=\""+part1+"\"";
		var newLnk = "";
		text = strReplace(part1, newLnk, text);
	}
	///////////////////// Links filtern
		
	
		
	if(text.length > 0)
	{
		text = strReplace("&lt;&lt; zurück", "", text);
		
		neues_fenster = window.open('', "Window", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=700,height=550,screenX=10,screenY=10,top=10,left=10");
		neues_fenster.document.open();
		
		var content ="<div id='button'><a href='javascript:self.print();'>"+item["print-window"]+"</a> <a href='javascript:self.close();'>"+item["close-window"]+"</a></div>";

			content="<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>";
			content=content+"<html>";
				content=content+"<head>";
					content=content+"<meta http-equiv='content-type' content=content+'text/html;charset=utf-8'>";
					content=content+"<meta name='generator' content=content+'Adobe GoLive'>";
					content=content+"<title>Printversion</title>";
					content=content+"<link href='"+startpfad_+"css/printversion.css' type='text/css' rel='stylesheet' media='all'>";
				content=content+"</head>";
	
				content=content+"<body bgcolor='#ffffff'>";
					content=content+"<div id='content'>";
					content=content+"<p><img id='logo' src='"+startpfad_+"images/ebene2/printlogo.gif' alt='' border='0'></p>";
						content=content+"<div id='button'><a href='javascript:self.print();'>"+item["print-window"]+"</a> <a href='javascript:self.close();'>"+item["close-window"]+"</a></div>";
						content=content+"<div id='dynamicContent'>"+text+"</div>";
						content=content+"<p><b>"+item["cus-company"]+"</b><br>"+item["cus-street"]+"</p>";
						content=content+"<p>"+item["cus-zip"]+" "+item["cus-city"]+"</p>";
						content=content+"<div class='phone'>"+item["phone"]+"</div><div class='number'>"+item["cus-phone"]+"</div>";
						content=content+"<div class='phone'>"+item["fax"]+"</div><div class='number'>"+item["cus-fax"]+"</div>";
						content=content+"<div class='phone'>E-Mail</div><div class='number'>"+item["cus-mail"]+"</div>";
					content=content+"</div>";
				content=content+"</body>";
			content=content+"</html>";

		with(neues_fenster.document)
		{
			writeln(content);
		}

		neues_fenster.document.close();
		neues_fenster.focus();
	}
}


//**************************
//*** COOKIE FUNKTIONEN ***  
//**************************




function setCookie(name, wert, domain, expires, path, secure){
	if(path==""){path="/";}
	
   //var cook = name + "=" + unescape(wert);
   var cook = name + "=" + escape(wert);
   cook += (domain) ? "; domain="+ domain : "";
   cook += (expires) ? "; expires="+expires : "";
   cook += (path) ? "; path="+path : "";
   cook += (secure) ? "; secure" : "";
   document.cookie = cook;

}



function eraseCookie(name, domain, path){
	if(path==""){path="/";}
   var cook="name=; expires=Thu, 01-Jan-70 00:00:01 GMT"
   cook += (domain) ? "domain="+domain : ""
   cook += (path) ? "path="+path : ""
   document.cookie = cook
}


function getCookie(name){
   var i=0  //Suchposition im Cookie
   var suche = name+"="
   while (i<document.cookie.length){
      if (document.cookie.substring(i, i+suche.length)==suche){
         var ende = document.cookie.indexOf(";", i+suche.length)
         ende = (ende>-1) ? ende : document.cookie.length
         var cook = document.cookie.substring(i+suche.length, ende)
         return unescape(cook)
      }
      i++
   }
   return ""
}


function checkCookie(){
   setCookie("CookieTest", "OK")
   if (!getCookie("CookieTest"))
      return false
   else{
      eraseCookie("CookieTest")
      return true
   }
}


