function browserCheck(){ 
  this.ver=navigator.appVersion
  this.agent=navigator.userAgent
  this.dom=document.getElementById?1:0
  this.opera5=this.agent.indexOf("Opera 5")>-1
  this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0; 
  this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
  this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
  this.ie=this.ie4||this.ie5||this.ie6
  this.mac=this.agent.indexOf("Mac")>-1
  this.mozilla=((this.agent.indexOf("Mozilla")>-1)&&(this.agent.indexOf("Gecko")>-1))
  this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
  this.ns4=(document.layers && !this.dom)?1:0;
  this.bw=(this.ie6||this.ie5||this.ie4||this.ns4||this.ns6||this.opera5)
  return this
}
brows=new browserCheck()

var elementID, topPosition, leftPosition;
var actLayer='welcome';
var d=5;

function getElem(p1,p2,p3) {
 var Elem;
 var byId, byName, byTag;
 switch(p1.toLowerCase()){
 case "id":byId=true;
 				break;
 case "name":byName=true;
 				break;
 case "tagname":byTag=true;
 				break;}
 if(brows.dom) {
   if(byId) {
     if (typeof document.getElementById(p2) == "object")
     Elem = document.getElementById(p2);
     else Elem = void(0);
     return(Elem);
   }
   else if(byName) {
     if (typeof document.getElementsByName(p2) == "object")
     Elem = document.getElementsByName(p2)[p3];
     else Elem = void(0);
     return(Elem);
   }
   else if(byTag) {
     if (typeof document.getElementsByTagName(p2) == "object" ||
        (OP && typeof document.getElementsByTagName(p2) == "function"))
     Elem = document.getElementsByTagName(p2)[p3];
     else Elem = void(0);
     return(Elem);
   }
   else return void(0);
 }
 else if(brows.ie4) {
   if(byId) {
     if (typeof document.all[p2] == "object")
     Elem = document.all[p2];
     else Elem = void(0);
     return(Elem);
   }
   else if(byTag) {
     if (typeof document.all.tags(p2) == "object")
     Elem = document.all.tags(p2)[p3];
     else Elem = void(0);
     return(Elem);
   }
   else if(byName) {
     if (typeof document[p2] == "object")
     Elem = document[p2];
     else Elem = void(0);
     return(Elem);
   }
   else return void(0);
 }
 else if(brows.ns4) {
   if(byId || byName) {
   if (typeof document[p2] == "object")
     Elem = document[p2];
     else Elem = void(0);
     return(Elem);
   }
   else if(p1.toLowerCase()=="index") {
    if (typeof document.layers[p2] == "object")
     Elem = document.layers[p2];
    else Elem = void(0);
     return(Elem);
   }
   else return void(0);
 }
}


function getStyle(elID){//gibt ein element.style oder layer objekt zurück
	if(!brows.ns4 && getElem('id',elID)){
		var s=getElem('id',elID).style;
	}
	else{
		var s=getElem('id',elID);
	}
	if(s!=null)return s;
	else return void(0);
}

function mailme(name,domain,subject){
    addr = "mailto:"+name+"@";
    addr+=domain;
    if(mailme.arguments.length>2){
        addr+="?subject="+subject;
    }
    window.location.href=addr;
}

var first=false;
function contact_form(){
	f = document.form2;
	if(f.name.value=="" || f.nachricht.value==""){
		if(!first){
			first=true;
		}
		else {
			alert("Es muss ein Name und eine Nachricht eingegeben werden!");
		}
		return false;
	}
	else return true;
}

function popup(u,n,s, i){
	if(popup.arguments.length>3 && i=="IE_only" && !brows.ie){
		alert("Als ich dieses Skript geschrieben habe, war Firefox/Mozilla noch nicht so verbreitet. Es nutzt proprietäre Funktionen von Internet Explorer und funktioniert daher nicht in anderen Browsern :-(");
																																	return;
	}
	window.open(u,n,s);
}

function notenspiel_popup(){
		if(screen.width<=800){
			url = "fileadmin/demo/notenspiel/notenspiel_kl.html";
		}
		else{
			url = "fileadmin/demo/notenspiel/notenspiel_gr.html";
		}
	    //window.open(url,name,'toolbar=0,menubar=0,status=0,scrollbars=0,width='+ screen.width +',height=' + screen.availHeight + '');
		window.open(url,name,'toolbar=0,menubar=0,status=0,scrollbars=0,resizable=yes,fullscreen=yes');
}

function init(){
		if(brows.ie5 && typeof getStyle('ref_table')!='undefined'){
			getStyle('ref_table').width='90%';
		}
		title = '';
		if(document.cookie){
			//alert(document.cookie);
			if(document.cookie.indexOf(";")>0){
				tmp = document.cookie.split(';');
				for(i=0;i<tmp.length;i++){
					if(tmp[i].indexOf('style')>0)title = tmp[i].substr(tmp[i].indexOf('style')+6,tmp[i].length);
				}
			}
			else {
				if(document.cookie.indexOf('style')>0)title = document.cookie.substr(tmp[i].indexOf('style')+6,document.cookie.length);	
			}
			if(title!='')setCSS(title);
		}
		//if(brows.mozilla)alert("Mozilla");
}
/*
if((navigator.userAgent.indexOf('Linux')>-1) && !(navigator.appVersion.indexOf('Konqueror')>-1)) {
	document.write('<link rel="stylesheet" type="text/css" href="style_linux.css">');
}
if(brows.mac && brows.ie) {
	document.write('<link rel="stylesheet" type="text/css" href="ie_mac.css">');
}
*/

function setCSS(title) {
   var i, a, main;
   title = title.replace(" ","");
	 old = (title == 'default') ? 'alt1' : 'default';
   for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
		 if(a.getAttribute("rel").indexOf("style") != -1){
			 	if(a.getAttribute("title")==old) {
					 a.disabled = true;
				}
				else if (a.getAttribute("title")==title) {
					 a.disabled = false;
				}
     }
   }
   document.cookie='style='+title;
}



var first = true;
function form_check(){
	if(document.form1.login.value==""){
		if(first){
			first = false;
			return false;
		}
		alert("Bitte einen Namen eingeben");
		return false;
	}
	return true;
}
