/**
 * globale variable die alle flashanimationen und ihre daten enthält
 */
var flashAnis = new Array();

/**
 * Funktion die Flashelemente zur seite hinzufügt
 *
 * @param string containerid	//id des elements das die animation enhält
 * @param string filename			//dateiname/pfad der animation
 * @param string flashid			//id des embed-elements das erzeugt wird
 * @param string width				//breite ohne px angabe bsp: "230"
 * @param string height				//hoehe ohne px angabe bsp: "230"
 * @param string bgcolor			//bgcolor von containerid (falls die animation kleiner ist als width und heigth)
 */				
function addFlash(containerid, filename, flashid, width, height, bgcolor){
	number = flashAnis.length;
	flashAnis[number] = new Object();
	flashAnis[number]['containerid'] = containerid;
	flashAnis[number]['filename'] = filename;
	flashAnis[number]['flashid'] = flashid;
	flashAnis[number]['height'] = height;
	flashAnis[number]['width'] = width;
	flashAnis[number]['bgcolor'] = bgcolor;
	var flashmovie = new SWFObject(filename, flashid, width, height, "8", bgcolor);
	flashmovie.write(containerid);
}

function bestHide(id)
{
	$("#"+id).hide();
}
						

/**
 * wird beim schliessen des modalfensters aufgerufen
 * entfernt die flashanimation im modal und blendet alle anderen animationen wieder ein
 */				
function modalClose (dialog,id) {
	$('#flashmovie').empty();	//hide flash game
	$('#'+id).show();			//show game page
	
	/*dialog.data.fadeOut('slow', function () {
		dialog.container.hide('slow', function () {
			dialog.overlay.slideUp('slow', function () {
				$.modal.close();
			});
		});
	});*/
	
	$.modal.close();
}				

/**
 * wird beim öffnen des modalfensters aufgerufen
 * erzeugt neue flashanimation im modalfenster
 * @param object dialog				//objektzeiger auf das ausführende objekt
 * @param string containerid	//id des elements das die animation enhält
 * @param string flashfile		//dateiname/pfad der animation
 * @param string flashid			//id des embed-elements das erzeugt wird
 * @param string width				//breite ohne px angabe bsp: "230"
 * @param string height				//hoehe ohne px angabe bsp: "230"
 * @param string bgcolor			//bgcolor von containerid (falls die animation kleiner ist als width und heigth) 
 */
function modalOpen (dialog, writeto, flashfile, flashid, flashwidth, flashheight){
	//iehack - flash kommt nur oben...
	if ($.browser.msie) {
		$('#toupper').click();
	}
	var so = new SWFObject(flashfile, flashid, flashwidth, flashheight, "8");
	//so.addParam("wmode", "transparent");
	so.write(writeto);
	
	dialog.overlay.fadeIn('fast', function () {
		dialog.container.fadeIn('fast', function () {
			dialog.data.hide().slideDown('fast');	 
		});
	});
}	

/**
 * ruft das modalfenster auf, blendet alle anderen flashelemente aus und zeigt eine flashanimation im modalen fenster
 * 
 * @param string toclickid							//das element mit dieser id löst das modalfenster beim click aus
 * @param string modalcontainerid				//dies ist die id des modalcontainers - in diesen alles reinpacken was modal angezeigt wird
 * @param string modalflashcontainerid	//hier wird das flashfile hineingepackt
 * @param string flashfile							//dateiname/pfad der modalenanimation
 * @param string flashid								//id des modalen-embed-elements das erzeugt wird
 * @param string width									//breite ohne px angabe bsp: "230"
 * @param string height									//hoehe ohne px angabe bsp: "230"
 * @param string bgcolor								//bgcolor von modalflashcontainerid (falls die animation kleiner ist als width und heigth) 
 */
function modalFlash(mainid, modalcontainerid, modalflashcontainerid, flashfile, flashid, flashwidth, flashheight, flashplayer){
		//bestHide(mainid);
		
		$('#'+modalcontainerid).modal ({
				onClose: function (e) {
					modalClose(e,mainid);
					flashplayer.continueTeaser();
				},
				onOpen: function (e){
					//bindet das im modalfenster anzuzeigende flash ein
					modalOpen(e, modalflashcontainerid, flashfile, flashid, flashwidth, flashheight);
				},
				overlay: 85 //setzt opacity auf 80% oder 0.8
		});
		$("#modalContainer").css({ height: flashheight , width: flashwidth});		
}

/**
 * IE Workaround for resizing
 */
function resizeBackground(){
	if ($.browser.msie) {
		$('#modalOverlay').css('height','100%');
		$('#modalOverlay').css('width','100%');
	}
}
