// Projektspezifische JS-Funktionen
function openPopup(url, ID, mediaID){
	//der array 'IstrListboxTargetPopupstyle' wird in der methode
	//MainOutputClass.GetClientJSPopupTargets() gefuellt...

	if ((mediaID > 0) && (ID == 197)) {
		url = "/main.aspx/G/" + GroupID + "/L/" + LangID + "/A/" + AreaID + "/ID/" + mediaID + "/V/media";
		window.open(url, "ePilotPopup"+ID, IstrListboxTargetPopupstyle[ID]);
	} else {
		//url += "/V/popup/PM/1";
		window.open(url, "ePilotPopup"+ID, IstrListboxTargetPopupstyle[ID]);
	}
}

function openContent(url,ID){
	switch(ID){
		case 4:
			parent.location.href = url;
			break;
		case 5:
			parent.window.opener.location.href = url;
			break;
	}
}

function RunSearch(lngPopupMode) {

  var queryval = encodeURI(document.forms["suche"].elements["Z"].value);
  
  // Die Auswahl des Suchbereiches erfolgt über die Radiobuttons
  var ID = -1;
  
    if(document.forms["suche"].elements["ID"][0].checked == true)
        ID = document.forms["suche"].elements["ID"][0].value;
    else
        ID = document.forms["suche"].elements["ID"][1].value;
  
  if (lngPopupMode > 0) {
    var strLink = IstrPopupLink;
	  strLink += "/ID/" + ID + "/Z/" + queryval;
    openPopup(strLink, lngPopupMode);
  }
  else {
    var strLink = IstrBaseLink;
	  strLink += "/ID/" + ID + "/Z/" + queryval;
	  
    document.location.href = strLink;
  }
}




function runSiteSearch( folderPath, navID, langID, restrictedMode, zValue ) {
    if(zValue) {
        var path = folderPath + navID + ',' + langID + ',' + navID + ',' + restrictedMode + ',(' + zValue + '),0,0,0.aspx';
    }
    else {
        var path = folderPath + navID + ',' + langID + ',' + navID + ',' + restrictedMode + ',0,0,0,0.aspx';
    }
    
    window.location = path;
    return false;
}

function setFieldValue( zValue, fieldID ) {
    document.getElementById(fieldID).value = zValue;
}


// FlashScript
function OpenPopupFlash(id, width, height)
{
    var popup = window.open('', '', 'width=' + width +',height=' + height);
    var object = encodeURI('/mstream.ashx?id=' + id);
    var output = ShowFlash('headillu', object, 708, 510, 'high','#EAEBEC', 'transparent', 'middle', null, true);
    popup.document.write(output);    
    
}
function ShowFlash(controlID, src, width, height, quality, bgcolor, wmode, align, params, popup) {
	
    if (!align)
        align = "middle";
    if (!bgcolor)
        bgcolor = "#ffffff";
    if (!quality)
        quality = "high";
    if(!wmode)
        wmode = "transparent";

    var output = "";

    output += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0"';

		
    if (width)
        output += ' width="' + width + '"';
    if (height)
        output += ' height="' + height + '"';
		
    output += ' id="' + controlID + '" align="' + align + '">';

    output += '<param name="allowScriptAccess" value="sameDomain" />';
    output += '<param name="movie" value="' + src + '" />';
    output += '<param name="quality" value="' + quality + '" />';
    output += '<param name="bgcolor" value="' + bgcolor + '" />';
    output += '<param name="wmode" value="' + wmode + '" />';


    var embedVars = "";
        if (params) {
        for(var i = 0; i < params.length; i++) {
            output += '<param name="' + params[i]['Key'] + '" value="' + params[i]['Value'] + '" />';
            embedVars += params[i]['Key'] + "=\"" + params[i]['Value'] + "\"";
        }
    }

    output += '<embed src="' + src + '" quality="' + quality + '"';
		
    if (width)
        output += ' width="' + width + '"';
    if (height)
        output += ' height="' + height + '"'
		
    output += '"wmode="' + wmode + '" bgcolor="' + bgcolor + '" name="' + controlID + '" align="' + align + '" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" ' + embedVars + '></embed>';

    output += '</object>';
    if(popup)
        return output;
    //alert(output);
    //document.write('<textarea>'+output+'</textarea>');
    document.write(output);
}


function show_flash(src, movie, width, height, quality, wmode, menu, bgcolor, flashvars)
{
	document.write("<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\" width=\"" +width+ "\" height=\"" +height+ "\" id=\"" +movie+ "\">");
	document.write("<param name=\"movie\" value=\"" +src+ "\" />");
	document.write("<param name=\"FlashVars\" value=\"" +flashvars+ "\">");
	document.write("<param name=\"quality\" value=\"" +quality+ "\" />");
	document.write("<param name=\"wmode\" value=\"" +wmode+ "\" />");	
	document.write("<param name=\"menu\" value=\"" +menu+ "\" />");
	document.write("<param name=\"bgcolor\" value=\"" +bgcolor+ "\" />");
	document.write("<embed src=\"" +src+ "\" swLiveConnect=\"true\" menu=\"" +menu+ "\" FlashVars=\"" +flashvars+ "\" quality=\"" +quality+ "\" wmode=\"" +wmode+ "\" bgcolor=\"" +bgcolor+ "\" width=\"" +width+ "\" height=\"" +height+ "\" name=\"" +movie+ "\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" />");
	document.write("</object>");
}

function ShowAppletIPIX(width, high, src ,javaparam )
{
    var applet = window.open('', '', 'width=' + width +',height=' + high);
    var file = '/mstream.ashx?id=' + javaparam;

    var output = '<applet code=\"IpixViewer.class\" ' +
                'width=\"'+ width + '\" height=\"' + high + '\" ' +
                'codebase=\"http://westspiel.dev'+ src +'/ipixbin\" archive=\"IpixViewer.jar\"> ' +
                '<param name=\"URL\" value=\"http://westspiel.dev/dwd/_111327/' + javaparam + '\">'+
                '<param name=\"Toolbar\" value=\"small\">' +
                '<param name=\"BackgroundColor\" value=\"#ffffff\">' +
                '<param name=\"HelpURL\" value=\"help\/viewalways_java3_1\/index.html\">' +
                '<param name=\"SpinSpeed\" value=\"-3\">' +
                '<param name=\"SpinStyle\" value=\"flat\"></applet>';                    

    applet.document.write(output);

}

function resizeWindow(w, h) {
    // resize current window...
       window.resizeTo(w,h);       
    if(document.all){

    } else {
    // window.innerHeight = h;
    // window.innerWidth = w;
    }
}
function changeHeight(div, hoehe) {
//    alert(div + '-' + hoehe);
//    document.getElementById("menu").style.height = hoehe + "px";
    resizeMenu(hoehe);
}

function resizeMenu( hoehe ){
    if( useFlash == undefined || !useFlash )
        return;
    var menu = document.embeds["menu"];
    if( menu ){
        menu.height = hoehe + "px";
    }
    else{
        menu = document.getElementById("menu");
        if( menu ){
            menu.height = hoehe + "px";
        }
    }

}

function openGallery(mfID) {
	var width="100%";
	var height = "100%";
	var flashvars = "xmlsource=/flashhandler.ashx?ver%3D1%26pid%3D" + mfID;
	creatediv("gal1", "0px", "0px", "100%", "100%", "transparent", null, 1000);
	if(document.getElementById && document.getElementById("gal1")) {
		flhtml = "<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"https://www.adobe.com/go/getflashplayer\" width=\"" +width+ "\" height=\"" +height+ "\" id=\"gal1flash\" align=\"middle\">";
		flhtml += "<param name=\"FlashVars\" value=\"" + flashvars + "\">";
		flhtml += "<param name=\"movie\" value=\"/skins/_111327/1001001003/flash/galerie_12.swf\" />";
		flhtml += "<param name=\"allowScriptAccess\" value=\"sameDomain\" />";
		flhtml += "<param name=\"allowFullScreen\" value=\"false\" />";
		flhtml += "<param name=\"quality\" value=\"high\" />";
		flhtml += "<param name=\"wmode\" value=\"transparent\" />";
		flhtml += "<param name=\"bgcolor\" value=\"#000000\" />";
		flhtml += "<embed swLiveConnect=\"true\" src=\"/skins/_111327/1001001003/flash/galerie_12.swf\" wmode=\"transparent\" FlashVars=\"" + flashvars + "\" quality=\"high\" bgcolor=\"#000000\" width=\"" +width+ "\" height=\"" +height+ "\" align=\"middle\" allowScriptAccess=\"sameDomain\" allowFullScreen=\"false\" name=\"gal1flash\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.adobe.com/go/getflashplayer\" />";
		flhtml += "</object>";
		document.getElementById("gal1").innerHTML = flhtml;
	}
}
function closeGallery() {
	if(document.getElementById && document.getElementById("gal1")) {
		var d = document.getElementById("gal1");
		d.parentNode.removeChild(d);
	}
}

function creatediv(id,L,T,W,H,bgColor,visible,zIndex) {
	if (document.getElementById) {
		if (document.getElementById(id)) {
			return;
		}
		var ST;
		if(document.all&&document.compatMode&&getInternetExplorerVersion()<7) {
			ST= 'position:absolute;top:0;right:0;width:100%;height:100%';
		} else {
			ST= 'position:fixed;top: 0; right: 0;width:100%;height:100%';
		}
		
		ST += '; visibility:'+(null==visible || 1==visible ? 'visible':'hidden')
		+(null==zIndex  ? '' : '; z-index:'+zIndex)
		+(null==bgColor ? '' : '; background-color:'+bgColor)

		var LR= '<DIV id='+id+' style="'+ST+'"></DIV>'

		if (document.body) {
			if (document.body.insertAdjacentHTML) {
				document.body.insertAdjacentHTML("BeforeEnd",LR);
			} else if (document.createElement && document.body.appendChild) {
				var newNode = document.createElement('div');
				newNode.setAttribute('id',id);
				newNode.setAttribute('style',ST);
				document.body.appendChild(newNode);
			}
		}
	}
}

function getInternetExplorerVersion() {
    var rv = -1; 
    // Return value assumes failure.    
    if (navigator.appName == 'Microsoft Internet Explorer') {
		var ua = navigator.userAgent;
		var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
		if (re.exec(ua) != null)
			rv = parseFloat(RegExp.$1);
	}
	return rv;
}