// 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) {
    if (ID < 3)
        location.href = url;
    if (ID == 3)
        window.open(url, "ePilotPopup" + ID);
    else if (ID == 4)
        parent.location.href = url;
    else if (ID == 5)
        parent.window.opener.location.href = url;
    else if (ID > 5)
        openPopup(url, ID);
}

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 ShowFlash(controlID, src, width, height, quality, bgcolor, align, params) {

    if (!align)
        align = "middle"
    if (!bgcolor)
        bgcolor = "#ffffff"
    if (!quality)
        quality = "high"

    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 + '" />';



    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 += ' bgcolor="' + bgcolor + '" name="' + controlID + '" align="' + align + '" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="https://www.macromedia.com/go/getflashplayer" ' + embedVars + '></embed>';

    output += '</object>';

    //alert(output);
    //document.write('<textarea>'+output+'</textarea>');
    document.write(output);
}


function schnellnavigation() {
    var linkid = document.glossarselection.glossar.value;
    var link = linkid;
    location.href = link;
}


function Telefonnummern() {
    var linkid = document.Telefonnummernselection.telefon.value;
    var link = linkid;
    location.href = link;
}

function Oeffnungszeiten() {
    var linkid = document.Oeffnungszeitenselection.oeffnungszeiten.value;
    var link = linkid;
    location.href = link;
}

function Adressen() {
    var linkid = document.Adressenselection.adressenvalue.value;
    var link = linkid;
    location.href = link;
}

function formularcenterChange() {
    var objid = document.forms["formularcenter"].formularcenterselect.value;

    if (isNaN(objid)) {
        var frags = objid.split("_");

        if (frags[0] == 1)
            location.href = frags[1];
        else if (frags[0] == 3)
            window.open(frags[1]);
        else
            openPopup(frags[1], frags[0]);
    } else {
        var newlink = objid + ",1031,131155,-1,0,0,0,0,0,0,0,0,0," + objid + ".aspx";
        location.href = newlink;
    }
}