function initImage(theImage) {
  imageId = theImage;
  image = document.getElementById(imageId);
  setOpacity(image, 0);
  image.style.visibility = 'visible';
  fadeIn(imageId,0);
}


function setOpacity(obj, opacity) {
  opacity = (opacity == 100)?99.999:opacity;

  // IE/Win
  obj.style.filter = "alpha(opacity:"+opacity+")";

  // Safari<1.2, Konqueror
  obj.style.KHTMLOpacity = opacity/100;

  // Older Mozilla and Firefox
  obj.style.MozOpacity = opacity/100;

  // Safari 1.2, newer Firefox and Mozilla, CSS3
  obj.style.opacity = opacity/100;
}



function fadeIn(objId,opacity) {
  if (document.getElementById) {
    obj = document.getElementById(objId);
    if (opacity <= 100) {
      setOpacity(obj, opacity);
      opacity += 10;
      window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 100);
    }
  }
}







// URL funtioncs



function goAnchor() {

var myUrl = window.location

var goUrl = myUrl + "#top"

window.location.href = goUrl

}





// Image Features (Mouseover, Restore, Preload, Random Pic for n Pics

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}



function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function rndpic(picpath,picname,picnumbers){
if(eval('document.'+picname)){
	var tempNumb = Math.ceil(10 * Math.random());
	var picArray = picpath.split(".");
	if (tempNumb > picnumbers ){
		rndpic(picpath,picname,picnumbers);
	} else {
		alert("Die Zufallsnummer lautet" + tempNumb +" "+ picArray[0]);
		 eval('document.'+picname+'.src = "'+picArray[0]+tempNumb+'.'+picArray[1]+'";');
	}
  	}


}

// END




// Several Window POPUP's

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

// PopUp Window für opener Fenster

function MM_openSetWindow(theURL,winName,launchWin,features) { //v1.0
  if (launchWin == ''){
    window.open(theURL,winName,features);
  }
  else{
    var controller = window.open(theURL,winName,features);
    if (controller.opener == null){
      controller.opener = self;
    }
    controller.opener.name = launchWin;
    return controller;
  }
}

function CloseMyWindow(){
	window.setTimeout("self.close()",500);
}


function FocusMe(){

	self.focus();
}

// END


// Window Functions (i.e. Print and Bookmark)


function printpage() {
	var iemac = ((navigator.userAgent.indexOf("Mac") != -1) && (navigator.userAgent.indexOf("MSIE") != -1)) ? 1 : 0;
	var ie4win = ((navigator.userAgent.indexOf("WIndows") != -1) && (navigator.userAgent.indexOf("MSIE 4.0") != -1)) ? 1 : 0;

	if (!iemac && !ie4win) {
	window.print();return false;

	} else if (ie4win) {

	vbPrintPage();

	} else {
	alert("Leider unterstuetzt Ihr Browser diese Funktion nicht!");
	}
}

function setBookmark(){
   var pageurl=location.href;
   var pagetitle= document.title;
   if (document.all)
    		window.external.AddFavorite(pageurl,pagetitle);
	else alert('Netscape Benutzer koennen mit CTRL-D diese Seite zu den Lesezeichen hinzufuegen.');
}

// END


//Object Finders
/*
function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i>d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}
*/
function tmt_findObj(n){
	var x,t; if((n.indexOf("?"))>0&&parent.frames.length){t=n.split("?");
	x=eval("parent.frames['"+t[1]+"'].document.getElementById('"+t[0]+"')");
	}else{x=document.getElementById(n)}return x;
}


function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

// END




// Form functions


function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function clearText(thefield){
if (thefield.defaultValue==thefield.value)
thefield.value = "";
return true;
}

function restoreText(thefield){
if (thefield.value=="")
	{
	thefield.value = thefield.defaultValue;
	return true;
	}

}

function win_swi(seite,feld) {
	if (seite == "nix") {
	eval("document.form1.subnavselect"+feld+".selectedIndex = 0");
	} else {
	top.location.href=seite;
	}
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}


function MM_jumpMenuGo(selName,targ,restore){ //v3.0
  var selObj = MM_findObj(selName); if (selObj) MM_jumpMenu(targ,selObj,restore);
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' geben Sie Bitte eine gültige E-mail Adresse an.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' muss eine Zahl beinhalten.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' muss ausgefüllt werden.\n'; }
  } if (errors) alert('Beim Übermitteln sind Fehler aufgetreten, wir bitten Sie Ihre Eingabe nochmals zu überprüfen. \n Folgende Felder müssen korrekt ausgefüllt sein:\n\n'+errors);
  document.MM_returnValue = (errors == '');
}


// END





// Layers

function MM_showHideLayers() { //v3.0A Modified by Al Sparber and Massimo Foti for NN6 Compatibility
  var i,p,v,obj,args=MM_showHideLayers.arguments;if(document.getElementById){
   for (i=0; i<(args.length-2); i+=3){ obj=tmt_findObj(args[i]);v=args[i+2];
   v=(v=='show')?'visible':(v='hide')?'hidden':v;
   if(obj)obj.style.visibility=v;}} else{
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }}
}

// END


// showhide formular for layers
function shForm(FormOrILayerName,showHide){
   DOM = (document.getElementById) ? true : false;
   IE = (document.all) ? true : false;
   NE4 = (document.layers) ? true : false;
   Mac = (navigator.appVersion.indexOf("Mac") != -1);
   Opera = (navigator.userAgent.indexOf("Opera")!=-1);
   Konqueror = (navigator.userAgent.indexOf("Konqueror")!=-1);

	shvalue = (showHide == 'show') ? 'visible' : 'hidden';
	if (NE4){
		MM_showHideLayers(FormOrILayerName,'',showHide);
	} else if(IE || Opera){
		if(document.getElementById(FormOrILayerName)){
			if(document.getElementById(FormOrILayerName).tagName.toLowerCase()=='ilayer'){
				document.getElementById(FormOrILayerName).id= 'null';
			}
			document.getElementById(FormOrILayerName).style.visibility = shvalue;
		}
		if(eval("document."+FormOrILayerName)){
			eval("document."+FormOrILayerName+".style.visibility = '"+shvalue+"'");
		}
	}
}

//END


// Toggle Panels

function togglepanel(panel)
{
if (document.getElementById(panel).style.display=="block")
	{
	document.getElementById(panel).style.display="none";
	}
else
	{
	document.getElementById(panel).style.display="block";
	}
}



function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerColor, theMarkColor)
{
    var theCells = null;

    // 1. Pointer and mark feature are disabled or the browser can't get the
    //    row -> exits
    if ((thePointerColor == '' && theMarkColor == '')
        || typeof(theRow.style) == 'undefined') {
        return false;
    }

    // 2. Gets the current row and exits if the browser can't get it
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    // 3. Gets the current color...
    var rowCellsCnt  = theCells.length;
    var domDetect    = null;
    var currentColor = null;
    var newColor     = null;
    // 3.1 ... with DOM compatible browsers except Opera that does not return
    //         valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        domDetect    = true;
    }
    // 3.2 ... with other browsers
    else {
        currentColor = theCells[0].style.backgroundColor;
        domDetect    = false;
    } // end 3

    // 4. Defines the new color
    // 4.1 Current color is the default one
    if (currentColor == ''
        || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) {
        if (theAction == 'over' && thePointerColor != '') {
            newColor              = thePointerColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
        }
    }
    // 4.1.2 Current color is the pointer one
    else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()
             && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) {
        if (theAction == 'out') {
            newColor              = theDefaultColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
        }
    }
    // 4.1.3 Current color is the marker one
    else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
        if (theAction == 'click') {
            newColor              = (thePointerColor != '')
                                  ? thePointerColor
                                  : theDefaultColor;
            marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])
                                  ? true
                                  : null;
        }
    } // end 4

    // 5. Sets the new color...
    if (newColor) {
        var c = null;
        // 5.1 ... with DOM compatible browsers except Opera
        if (domDetect) {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].setAttribute('bgcolor', newColor, 0);
            } // end for
        }
        // 5.2 ... with other browsers
        else {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].style.backgroundColor = newColor;
            }
        }
    } // end 5

    return true;
} // end of the 'setPointer()' function









