/*
 * Flash Liveconnect
 * by Attila Simon (a.simon@systemmedien.de, http://www.systemmedien.com/)
 *
 * v1.0 - 09-02-2006
 *
 *
 * Usage:
 *
 *	myFlash = new FlashObject("path/to/swf.swf", "swfid", "width", "height", flashversion, "backgroundcolor");
 *	myFlash.write("objId");
 */
 
var isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
// Verarbeiten aller FSCommand-Meldungen in einem Flash-Film
function hmenue_DoFSCommand(command, args) {
	var hmenueObj = isInternetExplorer ? document.all.hmenue : document.hmenue;
	document.getElementById("flsmenue").style.display="inline";
}

function smenue_DoFSCommand(command, args) {
	var smenueObj = isInternetExplorer ? document.all.smenue : document.smenue;
	document.getElementById("flsmenue").style.display="none";
}

function flsmenuON(){
  document.getElementById("flsmenue").style.display="inline";
  }
  
function flsmenuOFF(){
  document.getElementById("flsmenue").style.display="none";
  
  }  
  
var blender=false;  
function flblender(w)
{
 if(!blender)
   {
   blender=true;
   document.getElementById(w).style.display='none';
   document.getElementById("modul_31all").style.display='inline';
   }
   else
   {
   blender=false;
   document.getElementById(w).style.display='inline';
   document.getElementById("modul_31all").style.display='none';
   }
 
}  

  
// Hook für Internet Explorer.
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	document.write('<script language=\"VBScript\"\>\n');
	document.write('On Error Resume Next\n');
	document.write('Sub hmenue_FSCommand(ByVal command, ByVal args)\n');
	document.write('	Call hmenue_DoFSCommand(command, args)\n');
	document.write('End Sub\n');
	document.write('Sub smenue_FSCommand(ByVal command, ByVal args)\n');
	document.write('	Call smenue_DoFSCommand(command, args)\n');
	document.write('End Sub\n');
	document.write('</script\>\n');
}

function writeswf(lizenz_dir,swfname,w,h,mode,swfid,isInternetExplorer,bgcolor,flpage){
document.getElementById(swfid).style.display="none";
document.write('<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0\" id=\"'+swfname+'\" width=\"'+w+'\" height=\"'+h+'\" align=\"middle\"\>\n');
document.write('<param name=\"allowScriptAccess\" value=\"sameDomain\" /\>\n');
document.write('<param name=\"movie\" value=\"'+lizenz_dir+'/flash/'+swfname+'.swf?FL_PAGE='+flpage+'&browser='+isInternetExplorer+'\" /\>\n');
document.write('<param name=\"quality\" value=\"high\" /\>\n');
document.write('<param name=\"scale\" value=\"noscale\" /\>\n');
document.write('<param name=\"wmode\" value=\"'+mode+'\" /\>\n');
document.write('<param name=\"bgcolor\" value=\"#'+bgcolor+'\" /\>\n');
document.write('<embed src=\"'+lizenz_dir+'/flash/'+swfname+'.swf?FL_PAGE='+flpage+'&browser='+isInternetExplorer+'\" quality=\"high\" scale=\"noscale\" wmode=\"'+mode+'\" bgcolor=\"#'+bgcolor+'\" width=\"'+w+'\" height=\"'+h+'\" swLiveConnect=true id=\"'+swfname+'\" name=\"'+swfname+'\" align=\"middle\" allowScriptAccess=\"sameDomain\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" /\>\n');
document.write('</object>\n');}  





/*
 * FlashObject embed
 * by Geoff Stearns (geoff@deconcept.com, http://www.deconcept.com/)
 *
 * v1.1.0 - 03-31-2005
 *
 * writes the embed code for a flash movie, includes plugin detection
 *
 * Usage:
 *
 *	myFlash = new FlashObject("path/to/swf.swf", "swfid", "width", "height", flashversion, "backgroundcolor");
 *	myFlash.write("objId");
 *
 * for best practices, see:
 *  http://blog.deconcept.com/2005/03/31/proper-flash-embedding-flashobject-best-practices/
 *
 */
var FlashObject = function(swf, id, w, h, ver, c, align) {
	this.swf = swf;
	this.id = id;
	this.width = w;
	this.height = h;
	this.version = ver;
	this.align = align ? align : "";

	this.params = new Object();
	this.variables = new Object();

	this.redirect = "";
	this.sq = document.location.search.split("?")[1] || "";
	this.bypassTxt = "<p>Already have Macromedia Flash Player? <a href='?detectflash=false&"+ this.sq +"'>Click here if you have Flash Player "+ this.version +" or later installed</a>.</p>";
	
	if (c) this.color = this.addParam('bgcolor', c);
	this.addParam('quality', 'high'); // default to high
	this.addParam('menu', 'false'); // hide menu by default
	//this.doDetect = getQueryParamValue('detectflash');
	this.doDetect = false;
}

var FOP = FlashObject.prototype;

FOP.addParam = function(name, value) {
	this.params[name] = value;
}

FOP.getParams = function() { return this.params; }

FOP.getParam = function(name) { return this.params[name]; }

FOP.addVariable = function(name, value) {
	if(value == null) {
		var tmp = name.split("=");
		if(tmp.length == 2) {
			name = tmp[0];
			if(name.charAt(0) == "&") {
				name = name.substring(1, name.length);
			}
			value = tmp[1];
		} else {
			return;
		}
	}
	this.variables[name] = value;
}

FOP.getVariable = function(name) { return this.variables[name]; }

FOP.getVariables = function() { return this.variables; }

FOP.getParamTags = function() {
    var paramTags = "";
    for (var param in this.getParams()) {
        paramTags += '<param name="' + param + '" value="' + this.getParam(param) + '" />';
    }
    return (paramTags == "") ? false:paramTags;
}

FOP.getHTML = function() {
    var flashHTML = "";
    if (navigator.plugins && navigator.mimeTypes.length) { // netscape plugin architecture
        flashHTML += '<embed type="application/x-shockwave-flash" src="' + this.swf + '" width="' + this.width + '" height="' + this.height + '" id="' + this.id + '" align="' + this.align + '"';
        for (var param in this.getParams()) {
            flashHTML += ' ' + param + '="' + this.getParam(param) + '"';
        }
        if (this.getVariablePairs()) {
            flashHTML += ' flashVars="' + this.getVariablePairs() + '"';
        }
        flashHTML += 'wmode="opaque"';
		flashHTML += '></embed>';
    } else { // PC IE
        flashHTML += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + this.width + '" height="' + this.height + '" id="' + this.id + '" align="' + this.align + '">';
        flashHTML += '<param name="movie" value="' + this.swf + '" />';
        flashHTML += '<param name="wmode" value="opaque" />';
		if (this.getParamTags()) {
            flashHTML += this.getParamTags();
        }
        if (this.getVariablePairs() != null) {
            flashHTML += '<param name="flashVars" value="' + this.getVariablePairs() + '" />';
        }
        flashHTML += '</object>';
    }
    return flashHTML;	
}

FOP.getVariablePairs = function() {
    var variablePairs = new Array();
    for (var name in this.getVariables()) { 
    	variablePairs.push(name + "=" + escape(this.getVariable(name))); 
    }
    return (variablePairs.length > 0) ? variablePairs.join("&"):false;
}

FOP.debug = function(out) {
	var debugWin = window.open("about:blank", "debug");
	debugWin.document.open();
	out = out.replace(/>/, "&gt;");
	out = out.replace(/</, "&lt;");
	debugWin.document.write(out);
	debugWin.document.close();
	debugWin.focus();
}

FOP.write = function(elementId) {
	if(detectFlash(this.version) || this.doDetect=='false') {
		if (elementId) {
			document.getElementById(elementId).innerHTML = this.getHTML();
		} else {
			document.write(this.getHTML() + "");
		}
	} else {
		if (this.redirect != "") {
			document.location.replace(this.redirect);
		} else if (this.altTxt) {
			if (elementId) {
				document.getElementById(elementId).innerHTML = this.altTxt +""+ this.bypassTxt;
			} else {
				document.write(this.altTxt +""+ this.bypassTxt);
			}
		}
	}		
}



/* ---- detection functions ---- */
function getFlashVersion() {
	var flashversion = 0;
	if (navigator.plugins && navigator.mimeTypes.length) {
		var x = navigator.plugins["Shockwave Flash"];
		if(x && x.description) {
			var y = x.description;
   			flashversion = y.charAt(y.indexOf('.')-1);
		}
	} else {
		result = false;
	    for(var i = 15; i >= 3 && result != true; i--){
   			execScript('on error resume next: result = IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.'+i+'"))','VBScript');
   			flashversion = i;
   		}
	}
	return flashversion;
}

function detectFlash(ver) {	return (getFlashVersion() >= ver) ? true:false; }

// get value of query string param
function getQueryParamValue(param) {
	var q = document.location.search || document.location.href.split("#")[1];
	if (q) {
		var detectIndex = q.indexOf(param +"=");
		var endIndex = (q.indexOf("&", detectIndex) > -1) ? q.indexOf("&", detectIndex) : q.length;
		if (q.length > 1 && detectIndex > -1) {
			return q.substring(q.indexOf("=", detectIndex)+1, endIndex);
		} else {
			return "";
		}
	}
}

/* add Array.push if needed */
if(Array.prototype.push == null){
	Array.prototype.push = function(item) { this[this.length] = item; return this.length; }
}
