// Liste der Bilder 
var preload_images = 
[ 
"img/layout/bgr_h_15.jpg", 
"img/layout/bgr_12_h.jpg", 
"img/layout/bgr_11a_h.jpg",
"img/layout/bgr_11b_h.jpg",
] 

var load_next = 500 // Zeit in ms zwischen zwei Ladevorgaengen 
var pos_array = 0 
// Ladefunktion 
function preload() { 
// Naechstes Bild laden 
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() { 
// Bilder vorhanden? 
if(preload_images.length == 0) 
return 
// Pruefroutine starten 
setTimeout('preload()', load_next) 
}




function openWindow(URL, winName, features)
    {
        window.open(URL, winName, features); 
    }

function submitspkategoriefilter(month, year) {
         if(document.suchform.suchtext.value=='Suchtext hier eintragen'){document.suchform.suchtext.value='';}
                document.suchform.method = "post";
                document.suchform.action = "index.php?id=18,0,0,1,0,0&str=2&monat=" + month + "&jahr=" + year + "&textfilter=" + document.suchform.suchtext.value + "&suchtext=" + document.suchform.suchtext.value;
                document.suchform.submit();
}

function submitsearch() {
        /* if(document.suchform.suchtext.value=='Suchtext hier eintragen'){document.suchform.suchtext.value='';}*/
                document.suchform2.method = "post";
                document.suchform2.action = "index.php?id=117,146,0,0,1,0&str=1";
                document.suchform2.submit();
}

function evalKeyForSubmit3(event) {

   if (event && event.keyCode == 13) {// FF: ...event.which...
   	  document.getElementById('preload_suche').style.visibility = 'visible';
   	  preload_suche_Height(); 
      // ENTER gedrückt, also Formular abschicken
      document.suchform2.method = "post";
      //document.suchform.txtDummy.value="?id=18,0,0,1,0,0&monat=" + month + "&jahr=" + year + "&textfilter=" + document.suchform.suchtext.value
      document.suchform2.action="index.php?id=117,146,0,0,1,0&str=1";
      document.suchform2.submit();}
   else {
     // return true;
     }
}

function evalKeyForSubmit(event, month, year) {

   if (event && event.keyCode == 13) {// FF: ...event.which...
      // ENTER gedrückt, also Formular abschicken
      document.getElementById('preload_suche').style.visibility = 'visible';
      preload_suche_Height(); 
      document.suchform.method = "post";
      //document.suchform.txtDummy.value="?id=18,0,0,1,0,0&monat=" + month + "&jahr=" + year + "&textfilter=" + document.suchform.suchtext.value
      document.suchform.action="index.php?id=18,0,0,1,0,0&str=2&monat=" + month + "&jahr=" + year + "&textfilter=" + document.suchform.suchtext.value + "&suchtext=" + document.suchform.suchtext.value;
      document.suchform.submit();}
   else {
     // return true;
     }
}


function postMessage(day, month, year) {
                eval("page" + day + " = window.open('admin_spielplan_formular.php?d=" + day + "&m=" + month + "&y=" + year + "', 'postScreen', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=400,height=520,top=100,left=100');");
}
        
function openPosting2(pId) {
          var breite = 400;
          var hoehe = 500;
          var positionX=((screen.availWidth / 2) - breite / 2);
          var positionY=((screen.availHeight / 2) - hoehe / 2);
          popup = window.open('admin_spielplan_popup.php?id=" + pId + "', 'mssgDisplay','toolbar=,location=,directories=,status=,menubar=,scrollbars=,resizable=,fullscreen=,width='+breite+',height='+hoehe+',top='+positionY+',left='+positionX);
          popup.resizeTo(breite,hoehe);
          popup.moveTo(positionX,positionY);
}

function openPosting(pId) {
                eval("page" + pId + " = window.open('admin_spielplan_popup.php?id=" + pId + "', 'mssgDisplay', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=400,height=500,top=100,left=100');");
}

function loginPop(month, year) {
          var breite = 280;
          var hoehe = 154;
          var positionX=((screen.availWidth / 2) - breite / 2);
          var positionY=((screen.availHeight / 2) - hoehe / 2);
          popup = window.open('lib/login.inc.php?month=" + month + "&year=" + year + "','mssgDisplay','toolbar=,location=,directories=,status=,menubar=,scrollbars=,resizable=,fullscreen=,width='+breite+',height='+hoehe+',top='+positionY+',left='+positionX);
          popup.resizeTo(breite,hoehe);
          popup.moveTo(positionX,positionY);
}
        





//Bilder einblenden
var fadeTargetId = 'dia'; /* change this to the ID of the fadeable object */
var	fadeTarget;
var preInitTimer;
if (document.getElementById(fadeTargetId)) {preInit();}

/* functions */

function preInit() {
	/* an inspired kludge that - in most cases - manages to initially hide the image
	   before even onload is triggered (at which point it's normally too late, and a nasty flash
	   occurs with non-cached images) */
	if ((document.getElementById)&&(fadeTarget=document.getElementById(fadeTargetId))) {
		fadeTarget.style.visibility = "hidden";
		if (typeof preInitTimer != 'undefined') clearTimeout(preInitTimer); /* thanks to Steve Clay http://mrclay.org/ for this small Opera fix */
	} else {
		preInitTimer = setTimeout("preInit()",2);
	}
}

function fadeInit() {
	if (document.getElementById) {
		/* get a handle on the fadeable object, to make code later more manageable */
		preInit(); /* shouldn't be necessary, but IE can sometimes get ahead of itself and trigger fadeInit first */
		/* set the initial opacity in a (hopefully) cross browser way
		   notice that because of the way the image is in front, and not obfuscated
		   by another object we need to "fade out", i don't need a fallback mechanism
		   to show/hide the covering object...the image is just there, full stop */
		if (fadeTarget.style.MozOpacity!=null) {  
			/* Mozilla's pre-CSS3 proprietary rule */
			fadeTarget.style.MozOpacity = 0;
		} else if (fadeTarget.style.opacity!=null) {
			/* CSS3 compatible */
			fadeTarget.style.opacity = 0;
		} else if (fadeTarget.style.filter!=null) {
			/* IE's proprietary filter */
			fadeTarget.style.filter = "alpha(opacity=0)";
		}
		/* make the object visible again */
		fadeTarget.style.visibility = 'visible';
		window.setTimeout("fadeIn(0)", 500);
	}
}

function fadeIn(opacity) {
	if (fadeTarget) {
		if (opacity <= 100) {
			if (fadeTarget.style.MozOpacity!=null) {
				/* Mozilla's pre-CSS3 proprietary rule */
				fadeTarget.style.MozOpacity = (opacity/100)-.001;
				/* the .001 fixes a glitch in the opacity calculation which normally results in a flash when reaching 1 */
			} else if (fadeTarget.style.opacity!=null) {
				/* CSS3 compatible */
				fadeTarget.style.opacity = (opacity/100)-.001;
			} else if (fadeTarget.style.filter!=null) {
				/* IE's proprietary filter */
				fadeTarget.style.filter = "alpha(opacity="+opacity+")";
				/* worth noting: IE's opacity needs values in a range of 0-100, not 0.0 - 1.0 */ 
			}
			opacity += 10;
			window.setTimeout("fadeIn("+opacity+")", 30);
		}
	}
}


/* initialise fader by hiding image object first */
if (document.getElementById(fadeTargetId)) {addEvent (window,'load',fadeInit);}


/* 3rd party helper functions */

/* addEvent handler for IE and other browsers */
function addEvent(elm, evType, fn, useCapture) 
// addEvent and removeEvent
// cross-browser event handling for IE5+,  NS6 and Mozilla
// By Scott Andrew
{
 if (elm.addEventListener){
   elm.addEventListener(evType, fn, useCapture);
   return true;
 } else if (elm.attachEvent){
   var r = elm.attachEvent("on"+evType, fn);
   return r;
 }
} 

function iFrameHeight() {
if(document.getElementById && !(document.all)) {
h = document.getElementById('iframename').contentDocument.body.scrollHeight;
document.getElementById('iframename').style.height = h;
}
else if(document.all) {
h = document.frames('iframename').document.body.scrollHeight;
document.all.iframename.style.height = h;
}
}
/*	
function PopUp(datei,hoehe,breite,win_name) {
 // Position errechnen
 new_left = (screen.width-breite)/2;
 new_top  = (screen.height-hoehe)/2;
 // Fenster öffnen
 var PopUp = window.open(datei,win_name,"height=" + hoehe +",width=" + breite + ",top=" + new_top + ",left=" + new_left +
 ",resizeable=no,status=yes,scrollbars=auto");
 // Fenster in Fokus
 PopUp.focus();
}
*/