function getViewportSize()
{
    var size = [0, 0];
    if (typeof window.innerWidth != "undefined") 
    {
        size = [window.innerWidth, window.innerHeight];
    }
    else 
        if (typeof document.documentElement != "undefined" && typeof document.documentElement.clientWidth != "undefined" && document.documentElement.clientWidth != 0) 
        {
            size = [document.documentElement.clientWidth, document.documentElement.clientHeight];
        }
        else 
        {
            size = [document.getElementsByTagName("body")[0].clientWidth, document.getElementsByTagName("body")[0].clientHeight];
        }
    return size;
}

function createFullBrowserFlash()
{
    swfobject.createCSS("html", "height:100%;");
    swfobject.createCSS("body", "height:100%;");
    swfobject.createCSS("#wrapper", "width:100%; height:100%; min-width:770px; min-height:390px; overflow:hidden;");
    window.onresize = function()
    {
        var el = document.getElementById("wrapper");
        var size = getViewportSize();
        el.style.width = size[0] < 1024 ? "1024px" : "100%";
        el.style.height = size[1] < 580 ? "580px" : "100%";
    };
    window.onresize();
}


if (swfobject.hasFlashPlayerVersion("6.0.65")) 
{
    var flashvars = {
        lang: lang
    };
    var params = {
      bgcolor: "#b9aa9c",
      allowfullscreen: 'true',
      menu: 'true'  
    };
    var attributes = {
    	id: "flashContent"    	
    };
    var ei = {
        location: 'cpflash/expressInstall.swf', 
        width: '214',
        height: '137',
        params: {
            wmode: 'transparent'
        },
        expressInstallInit: expressInstallInit,
        expressInstallError: errorCallback
    };
    swfobject.embedSWF("ff2010.swf", "flashContent", "100%", "100%", "9.0.115", ei, flashvars, params, attributes); 
    if (swfobject.hasFlashPlayerVersion("9.0.115")) 
    {
        swfobject.addDomLoadEvent(createFullBrowserFlash);
    }
} 
else 
{
    window.addEvent('domready', function(){
    	makeFlashAlternative();
    });
}

/**
 * Callback-Function from swfobject, when the expressInstall feature didn`t finished properly
 * @param error {String} errorCode
 */
function errorCallback(error) 
{
   makeFlashAlternative();
}

function makeFlashAlternative()
{
    var textSwitch = $('textSwitch');    
    textSwitch.setProperty('class', 'text_flash');
    textSwitch.setHTML(noFlashText);
    new Element('a', {
        'class': 'flashLink',
        'href': 'http://www.adobe.com/go/getflashplayer',
        'target': '_blank'
    }).injectAfter(textSwitch).setHTML(noFlashLink);
    if ($defined($('expressinstall')) == true )
    {
        $('expressinstall').remove();
    }
    $E('html').setStyle('height', 'auto');
    $E('body').setStyle('height', 'auto');
    $('flashContent').setStyle('display', 'block'); //ie-Bug: leaves display 'none'
    $('alternateText').setProperty('class', 'alternativ_text_flash').setHTML(noFlashAlternateText);
    $('alternateLink').setProperties({
        'class': 'alternativ_link_flash',
        'href': alternateTarget
    }).setHTML(noFlashAlternateLink);
}

function expressInstallInit() {
    var isPC = navigator.platform.indexOf('Win') > -1;
    $('wrapper').setStyle('position', 'relative');
    var expressInstall = new Element('div', {
        'id': 'expressinstall'
    }).injectBefore('wrapper');
    var top = new Element('p', {'class': 'expressinstallTop'}).injectInside(expressInstall);
    
    if (!window.ie && (isPC==true) ) {
        var bottom = new Element('p', {'class': 'expressinstallBottom'}).injectInside(expressInstall);             
    }
    var failure = new Element('p', {'class': 'expressinstallFailure'}).injectInside(expressInstall);
    new Element('a', {
        'class': 'flashLinkSmall',
        'href': 'http://www.adobe.com/go/getflashplayer',
        'target': '_blank'
    }).injectInside(expressInstall).setHTML(noFlashLink);
    
    var alternativ_text_flash = new Element('p', {'class': 'alternativ_text_flash'}).injectInside(expressInstall).setHTML(noFlashAlternateText);
    if (window.ie || (isPC==false)) {
        failure.setStyle('margin-top' , 62);             
    }       
    
    new Element('a', {
        'class': 'alternativ_link_flash',
        'href': alternateTarget
    }).injectInside(expressInstall).setHTML(noFlashAlternateLink);
}


/*
var playerVersion = swfobject.getFlashPlayerVersion(); // returns a JavaScript object
var majorVersion = playerVersion.major;
var minor = playerVersion.minor;
var release = playerVersion.release;
alert("Flash Version " + majorVersion + "." + minor + "." + release);
*/


