// JavaScript Document


var OSname = 'WIN';
if (navigator.appVersion.indexOf("Win") > 0) OSname = "WIN";
if (navigator.appVersion.indexOf("Mac") > 0) OSname = "MAC";

var visible = "show";
var hidden  = "hide";

function getObj(name)
{
	if (document.layers)
	{
		visible = "show";
		hidden  = "hide";
	}else
	{
		visible = "visible";
		hidden  = "hidden";
	}
	
	if (document.getElementById)
	{
		this.obj = document.getElementById(name);
		this.style = document.getElementById(name).style;
	}
	else if (document.all)
	{
		this.obj = document.all[name];
		this.style = document.all[name].style;
	}
	else if (document.layers)
	{
		this.obj = document.layers[name];
		this.style = document.layers[name];
	}
}

function getDocumentProperty(property)
{
	
	if (property == "clientWidth"){
		if (document.layers) return ((window.innerWidth)-16);
		if (document.all) return (document.body.clientWidth);
		if (document.getElementById) return ((window.innerWidth)-16);
	}
	if (property == "clientHeight"){
		if (document.layers) return (window.innerHeight);
		if (document.all) return (document.body.clientHeight);
		if (document.getElementById) return (window.innerHeight);
	}
	if (property == "scrollTop"){
		if (document.layers) return (window.pageYOffset);
		if (document.all) return (document.body.scrollTop);
		if (document.getElementById) return (window.pageYOffset);
	}
	return (-1);
}

function layerWrite(lay,txt)
{
	var layerRef = new getObj(lay);
	
	if (!layerRef) alert("Objektfehler:"+lay);
	
	if (document.layers)
	{
		layerRef.obj.document.open();
		layerRef.obj.document.write(txt);
		layerRef.obj.document.close();
	}else if (document.all || document.getElementById)
	{
		if (OSname == "MAC" && document.all) txt += "<br>"; // ie mac layer write last tag problem
		layerRef.obj.innerHTML=txt;
	}
}

// -------------------------------------------------------------------------------------------------------------------

function resize()
{
	if (document.layers) self.location.href = self.location.href;
}


// -------------------------------------------------------------------------------------------------------------------

function makeWinObj(name,url,posx,posy,width,height,extra)
{
	if (extra == 'toolbar') extra = 'scrollbars=yes,toolbar=yes';
	else if (extra == 'empty') extra = 'scrollbars=no,toolbar=no';
	else extra = 'scrollbars=yes,toolbar=no' + extra;
		
	this.name=name;
	this.url=url;
	this.obj=window.open(url,name,'width='+width+',height='+height+', ' + extra);

	// alert("x: "+posx+" | posy: "+posy);

	this.obj.moveTo(posx,posy);
	this.obj.focus();

	return this;
}

function closeAll()
{
	for(i=0;i<=winObjCounter;i++)
	{
		if(winObj[i]) winObj[i].obj.close();
	} 
}

var extlink = "";

function extLink(lnk){

	extlink = lnk;
	newWindow('gotoExtern', '../extLink.html', 400, 200, '');	
	// gotoExtern.document.getElementById("derlink").write(lnk);
	
}

function popupLink(link)
{
 window.open(link,'popupWindow');
 self.close();
}

function popupLinkIntern(link)
{
 window.open(link,'popupWindow');
}

var mhostname = document.location.host;
// Develop Server 1
if (mhostname == "imigran" || mhostname == "migraene") {
	var patientenlink	= "http://imigran/home/index.html";
	var fachbereichlink	= "http://imigran/login/index.html";
	var doccheckkeynumber	= "1010511944";
}
else if (mhostname == "www.subunity.com" || mhostname == "subunity.com") {
	var patientenlink	= "http://www.subunity.com/home/index.html";
	var fachbereichlink	= "http://www.subunity.com/login/index.html";
	var doccheckkeynumber	= "1010511944";
}
// Testserver 1
else if (mhostname == "test.imigran.de" || mhostname == "test.migraene-info.de") {
	var patientenlink	= "http://test.imigran.de/home/index.html";
	var fachbereichlink	= "http://test.imigran.de/login/index.html";
	var doccheckkeynumber	= "1010511944";
}
// Statging Server 1
else if (mhostname == "staging.imigran.de" || mhostname == "staging.migraene-info.de") {
	var patientenlink	= "http://staging.imigran.de/home/index.html";
	var fachbereichlink	= "http://staging.imigran.de/login/index.html";
	var doccheckkeynumber	= "1041671351";
}
else {
	var patientenlink	= "http://www.imigran.de/home/index.html";
	var fachbereichlink	= "http://www.imigran.de/login/index.html";
	var doccheckkeynumber	= "1392853190";
}

function Patienten(){
	
	window.document.location.href  = patientenlink;
	
}

function Fachbereich(){

	window.document.location.href = fachbereichlink;
	
}

function newWindow(name,link,width,height,type)
{
	if (width==0) width=550;
	if (height==0) height=400;
	
	if (type == 'scrollbars')
	{
		extra = 'toolbar';
	}else if (type == 'empty')
	{
		extra = 'empty';
	}else
	{
		extra = '';	
	}
	
	if (type=="nav")
	{
		posx = parseInt(screen.width/2)-390;
		posy = parseInt(screen.height/2) - 24 - 290;
		width= 320;
		height=580;
	}else if (type=="content")
	{
		posx = parseInt(screen.width/2) - 390 + 330;
		posy = parseInt(screen.height/2) - 24 - 290;
		width= 470;
		height=580;
	}else
	{
		posx = parseInt((screen.width-width)/2);
		posy = parseInt((screen.height-height)/2) - 24;
	}
	
	
	
	winObjCounter++;
	winObj[winObjCounter]=new makeWinObj(name,link,posx,posy,width,height,extra);
}

winObj=new Array();

var winObjCounter = -1;

// <body onload=self.focus(); onunload=closeAll();>

// -------------------------------------------------------------------------------------------------------------------

function fdirekteinstieg()
{
	var sel  = document.direkteinstieg.linkto.selectedIndex;
	var link = document.direkteinstieg.linkto[sel].value;
	if (link != 0 && link != "") document.location.href = link;
		
}

// -------------------------------------------------------------------------------------------------------------------

var timer;

function showInfo(txt)
{
	if (txt != "" && pageloaded)
	{
		if (timer) clearTimeout(timer); 
		if (document.layers){ bgcolor = "#eeeeee"; }else{ bgcolor = "#ffffff"; }
		txt = "<table cellpadding=0 cellspacing=0 border=0 bgcolor=#000000><tr><td colspan=3><img src=../pics/black.gif width=1 height=1></td></tr><tr><td><img src=../pics/black.gif width=1 height=1></td><td bgcolor=#ffffff><table bgcolor=#ffffff cellpadding=3 cellspacing=0 border=0><tr><td align=center class=info>&nbsp;"+txt+"&nbsp;</td></tr></table></td><td><img src=../pics/black.gif width=1 height=1></td></tr><tr><td colspan=3><img src=../pics/black.gif width=1 height=1></td></tr></table>";
		
		layerWrite('info',txt);
		var x = new getObj('info');
		x.style.top = mouseY+10;
		x.style.left = mouseX+10;
		x.style.visibility = visible;
		timer = window.setTimeout("hideInfo()",1000);
	} 
}

function hideInfo()
{
    	var x = new getObj('info');
    	x.style.visibility = hidden;
}


