﻿function createOpenedCorner(webSource, width, height, fVersion, link, cornerid) {
    var pnlCorner2 = document.getElementById('bigCornerLoader');
    var pnlCorner = pnlCorner2.parentNode;
    pnlCorner.removeChild(pnlCorner2);
    swfobject.embedSWF("" + webSource + "", 'ecke_opened', "" + width + "", "" + height + "", "" + fVersion + "", false, {link_ziel:"" + link + ""}, {wmode:"transparent"}, {});
    document.getElementById('divOpenedCorner').style.visibility = 'visible';
    document.getElementById('ecke_opened').style.visibility = 'visible';

    sendStatistic(cornerid);
}

function openCorner() {
    document.getElementById('divClosedCorner').style.visibility = 'hidden';
    document.getElementById('ecke_closed').style.visibility = 'hidden';
    document.getElementById('divOpenedCorner').style.visibility = 'visible';
    document.getElementById('ecke_opened').style.visibility = 'visible';
}

function closeCorner() {
    document.getElementById('divClosedCorner').style.visibility = 'visible';
    document.getElementById('ecke_closed').style.visibility = 'visible';
    document.getElementById('divOpenedCorner').style.visibility = 'hidden';
    document.getElementById('ecke_opened').style.visibility = 'hidden';
}

function sendStatistic(cornerid) {
    var rand_no = Math.random();
    var imgFlash = new Image();
    imgFlash.src = 'Images/cornerOpen.gif?Num=' + rand_no + '&ID=' + cornerid + '';
}

function setAdsVisibility(visible) {
    if (visible == false)
        document.getElementById('anzeigendiv').style.display = 'none';
    else
        document.getElementById('anzeigendiv').style.display = 'inline';
}

/*Newsticker*/
function decodeColorString(s) {
    result = 0;
    i = s.indexOf("#");
    if (i >= 0) {
        r = s.substr(i + 1, 2);
        g = s.substr(i + 3, 2);
        b = s.substr(i + 5, 2);
        result = eval("0x" + r + "*65536+0x" + g + "*256+0x" + b);
    }
    else {
        i = s.indexOf("(");
        s = s.substr(i + 1, s.length);
        i = s.indexOf(",");
        r = parseInt(s.substr(0, i));

        s = s.substr(i + 1, s.length);
        i = s.indexOf(",");
        g = parseInt(s.substr(0, i));

        s = s.substr(i + 1, s.length);
        i = s.indexOf(")");
        b = parseInt(s.substr(0, i));
        result = r * 65536 + g * 256 + b;
    }
    return result;
}

function devideColor(i) {
    result = new Array(3);
    result[0] = parseInt(i / 65536);
    i = i % 65536;
    result[1] = parseInt(i / 256);
    i = i % 256;
    result[2] = parseInt(i);
    return result;
}

function fadeTo(targetColor, run) {
    startColorArr = devideColor(decodeColorString(startColor));
    targetColorArr = devideColor(decodeColorString(targetColor));
    colorAdditionArr = new Array(3);
    colorAdditionArr[0] = parseInt((targetColorArr[0] - startColorArr[0]) / maxrun);
    colorAdditionArr[1] = parseInt((targetColorArr[1] - startColorArr[1]) / maxrun);
    colorAdditionArr[2] = parseInt((targetColorArr[2] - startColorArr[2]) / maxrun);
    currentColorArr = devideColor(decodeColorString(currentColor));
    currentColorArr[0] = currentColorArr[0] + colorAdditionArr[0];
    currentColorArr[1] = currentColorArr[1] + colorAdditionArr[1];
    currentColorArr[2] = currentColorArr[2] + colorAdditionArr[2];
    currentColor = "rgb(" + currentColorArr[0] + "," + currentColorArr[1] + "," + currentColorArr[2] + ")"
    document.getElementById(controlname).style.color = currentColor;
    if (run < maxrun) setTimeout("fadeTo(\"" + targetColor + "\"," + (run + 1) + ")", parseInt(fadetime / maxrun));
    if (run == maxrun) fadeDone(targetColor);
}

function fadeDone(targetColor) {
    startColor = targetColor;
    if (targetColor == colorFadeOut) {
        document.getElementById(controlname).innerHTML = "+++ " + news[currentNews] + " +++";
        currentNews++;
        if (currentNews > news.length - 1) currentNews = 0;
        fadeTo(colorFadeIn, 0);
    } else {
        setTimeout("fadeTo(colorFadeOut,0)", newsTime);
    }
}
/*Newsticker*/

/*Zeitanzeige*/
function setTime() {
    var weekday = new Array("Sonntag", "Montag", "Dienstag", "Mittwoch",
                                "Donnerstag", "Freitag", "Samstag");
    var month = new Array("Januar", "Februar", "M&auml;rz", "April", "Mai", "Juni",
                              "Juli", "August", "September", "Oktober", "November", "Dezember");
    now = new Date(now.getTime() + 1000);

    if (timeText) {
        var ho = now.getHours().toString();
        var mi = now.getMinutes().toString();
        var se = now.getSeconds().toString();

        if (ho.length == 1) ho = '0' + ho;
        if (mi.length == 1) mi = '0' + mi;
        if (se.length == 1) se = '0' + se;

        timeText.innerHTML = ho + ':' +
                                 mi + ':' +
                                 se;
    }

    if (dateText) {
        if ((now.getSeconds() == 0) && (now.getMinutes() == 0)) {
            dateText.innerHTML = weekday[now.getDay()].slice(0, 2) + ', ' +
                                     now.getDate() + '. ' +
                                     month[now.getMonth()] + ' ' +
                                     now.getFullYear();
        }
    }

    setTimeout('setTime()', 1000);
}
/*Zeitanzeige*/

/*
Copyright (c) Copyright (c) 2007, Carl S. Yestrau All rights reserved.
Code licensed under the BSD License: http://www.featureblend.com/license.txt
Version: 1.0.2
*/
var FlashDetect = new function() {
    var self = this;
    self.installed = false;
    self.major = -1;
    self.minor = -1;
    self.revision = -1;
    self.revisionStr = "";
    self.activeXVersion = "";
    var activeXDetectRules = [
		{
		    "name": "ShockwaveFlash.ShockwaveFlash.7",
		    "version": function(obj) {
		        return getActiveXVersion(obj);
		    }
		},
		{
		    "name": "ShockwaveFlash.ShockwaveFlash.6",
		    "version": function(obj) {
		        var version = "6,0,21";
		        try {
		            obj.AllowScriptAccess = "always";
		            version = getActiveXVersion(obj);
		        } catch (err) { }
		        return version;
		    }
		},
		{
		    "name": "ShockwaveFlash.ShockwaveFlash",
		    "version": function(obj) {
		        return getActiveXVersion(obj);
		    }
		}
	];
    var getActiveXVersion = function(activeXObj) {
        var version = -1;
        try {
            version = activeXObj.GetVariable("$version");
        } catch (err) { }
        return version;
    };
    var getActiveXObject = function(name) {
        var obj = -1;
        try {
            obj = new ActiveXObject(name);
        } catch (err) { }
        return obj;
    };
    var parseActiveXVersion = function(str) {
        var versionArray = str.split(","); //replace with regex
        return {
            "major": parseInt(versionArray[0].split(" ")[1], 10),
            "minor": parseInt(versionArray[1], 10),
            "revision": parseInt(versionArray[2], 10),
            "revisionStr": versionArray[2]
        };
    };
    var parseRevisionStrToInt = function(str) {
        return parseInt(str.replace(/[a-zA-Z]/g, ""), 10) || self.revision;
    };
    self.majorAtLeast = function(version) {
        return self.major >= version;
    };
    self.FlashDetect = function() {
        if (navigator.plugins && navigator.plugins.length > 0) {
            var type = 'application/x-shockwave-flash';
            var mimeTypes = navigator.mimeTypes;
            if (mimeTypes && mimeTypes[type] && mimeTypes[type].enabledPlugin && mimeTypes[type].enabledPlugin.description) {
                var desc = mimeTypes[type].enabledPlugin.description;
                var descParts = desc.split(' '); //replace with regex
                var majorMinor = descParts[2].split('.');
                self.major = parseInt(majorMinor[0], 10);
                self.minor = parseInt(majorMinor[1], 10);
                self.revisionStr = descParts[3];
                self.revision = parseRevisionStrToInt(self.revisionStr);
                self.installed = true;
            }
        } else if (navigator.appVersion.indexOf("Mac") == -1 && window.execScript) {
            var version = -1;
            for (var i = 0; i < activeXDetectRules.length && version == -1; i++) {
                var obj = getActiveXObject(activeXDetectRules[i].name);
                if (typeof obj == "object") {
                    self.installed = true;
                    version = activeXDetectRules[i].version(obj);
                    if (version != -1) {
                        var versionObj = parseActiveXVersion(version);
                        self.major = versionObj.major;
                        self.minor = versionObj.minor;
                        self.revision = versionObj.revision;
                        self.revisionStr = versionObj.revisionStr;
                        self.activeXVersion = version;
                    }
                }
            }
        }
    } ();
};
FlashDetect.release = "1.0.2";


//////////////////////////////////////////////////////////////////
// http: //www.apijunkie.com/APIJunkie/blog/post/2009/04/How-to-programmatically-detect-Silverlight-version.aspx
// get major Silverlight version 

// Return values: 
// 0 -> Silverlight not installed (at least not properly). 
// 1 -> Silverlight 1 installed 
// 2-> Silverlight 2 installed 
// 2-> Silverlight 3 installed 

//////////////////////////////////////////////////////////////////
getSilverlightVersion = function() {

    var SLVersion;

    try {
        try {

            var control = new ActiveXObject('AgControl.AgControl');

            if (control.IsVersionSupported("3.0"))
                SLVersion = 3;
            else
                if (control.IsVersionSupported("2.0"))
                SLVersion = 2;
            else
                SLVersion = 1;
            control = null;
        }

        catch (e) {
            var plugin = navigator.plugins["Silverlight Plug-In"];

            if (plugin) {
                if (plugin.description === "1.0.30226.2")
                    SLVersion = 2;
                else
                    SLVersion = parseInt(plugin.description[0]);
            }
            else
                SLVersion = 0;

        }

    }

    catch (e) {
        SLVersion = 0;
    }
    return SLVersion;
}
