// (C) 2001 alle Rechte bei PODIUM Berlin Brandenburg GbR (10247 Berlin)



// ssettings

var MP3_PAGE = "de_mp3.html"; 

var LOAD_PAGE = "";

var MAX_LOAD_TIME = 25; // sekunden

var START_TIME = 0;

var MIN_NUM_IMAGES = 120; // anzahl von bildern auf der mp3 seite (nie zuviel angeben, eher zu wenig)



// globale variablen

var mp3Window = null;

var NAV = "";



// browserbestimmung

if ( navigator.appName == "Microsoft Internet Explorer" ) {

	NAV = "IE";

} else if ( navigator.appCodeName == "Mozilla" && parseInt( navigator.appVersion ) >= 5 ) {

	NAV = "MOZ5";

} else if ( navigator.appName == "Netscape" ) {

	NAV = "NSC";

}







// funktion zum anzeigen von mp3s und ankern

function showMp3( name )

{

	START_TIME = (new Date()).getTime();

	

	LOAD_PAGE = MP3_PAGE + "#" + name;



	if ( mp3Window == null || mp3Window.closed ) {

		launchMp3Window ();

		

		waitForDocument ();

		

	} else {



		if (mp3Window.innerHeight < 200) {

			mp3Window.resizeTo(500,400);

		}



		displayMp3Anchor ();

	}



	

}





// laden des mp3 fensters

function launchMp3Window()

{

	var xPos = screen.availWidth - 530;

	var yPos = 10;



	mp3Window = open( LOAD_PAGE, "mp3", "width=500,height=400,screenX=" + xPos + ",screenY=" + yPos + "dependent=yes,scrollbars=yes,resizable=yes");



	if ( NAV == "IE" )

		mp3Window.moveTo( xPos, yPos );

}





// anzeigen des mp3 fensters mit anker

function displayMp3Anchor()

{



	mp3Window.location.href = LOAD_PAGE;



	mp3Window.focus();



}





function waitForDocument()

{



	var timeDiff = (new Date()).getTime() - START_TIME;



	// testen, ob dokument geladen ist und alle bilder bekannt sind

	if ((mp3Window == null || mp3Window.closed || mp3Window.document == null || 

		 mp3Window.document.images == null || mp3Window.document.images.length < MIN_NUM_IMAGES) &&

		(timeDiff < MAX_LOAD_TIME * 1000)) {

		// alert ("wait" + mp3Window + ", " + mp3Window.closed + ", " + mp3Window.document + ", " + 

		// 	   mp3Window.document.images + ", " + mp3Window.document.images.length);

		window.setTimeout( "waitForDocument()", 1000 );



		return;

	}



	// testen, ob auch alle bilder geladen sind

	for (var idx = 0; idx < mp3Window.document.images.length; idx++) {

		

		// alert (idx + "/" + mp3Window.document.images.length + " testing");

		

		if ((mp3Window.document.images[idx] == null || 

			(NAV != "IE" && (mp3Window.document.images[idx].height + mp3Window.document.images[idx].width == 0))) && 

			(timeDiff < MAX_LOAD_TIME * 1000)) {



			// alert (idx + " ist noch null");

			window.setTimeout( "waitForDocument()", 1000 );

			return;



		}

	}



	// alert ("geladen" + timeDiff + ", " + START_TIME);



	// und bild groesser machen

	// mp3Window.resizeTo(500,400);



	// jetzt anker anzeigen

	displayMp3Anchor ();







}





