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(minWidth, minHeight){

    var minWidth = parseInt(minWidth, 10);
    var minHeight = parseInt(minHeight, 10);
    
    swfobject.createCSS('html', 'height:100%;');
    swfobject.createCSS('body', 'height:100%;');
    swfobject.createCSS('#container', 'margin:0; overflow: hidden; width:100%; height:100%; min-width:' + minWidth + 'px; min-height:' + minHeight + 'px;');
    window.onresize = function(){
        var el = document.getElementById('container');
        var size = getViewportSize();
        
        if (size[0] < minWidth) {
            swfobject.createCSS('html', 'overflow-x:auto');
            el.style.width = minWidth + 'px';
        }
        else {
            swfobject.createCSS('html', 'overflow-x:hidden');
            el.style.width = '100%';
        }
        
        if (size[1] < minHeight) {
            swfobject.createCSS('html', 'overflow-y:auto');
            el.style.height = minHeight + 'px';
        }
        else {
            swfobject.createCSS('html', 'overflow-y:hidden');
            el.style.height = '100%';
        }
    };
    window.onresize();
}

function paramsToFlashvars(){

    var strReturn = "";
    var strHref = window.location.href;
    var bFound = false;
    
    if (strHref.indexOf("?") > -1) {
        var strQueryString = strHref.substr(strHref.indexOf("?") + 1);
        var aQueryString = strQueryString.split("&");
        
        for (var iParam = 0; iParam < aQueryString.length; iParam++) {
        
            var equalsPos = aQueryString[iParam].indexOf('=');
            if (equalsPos > -1) {
				
                var param = aQueryString[iParam].substr(0, equalsPos);
                var value = aQueryString[iParam].substr(equalsPos + 1);
                eval('flashvars.' + param + ' = \'' + value + '\'');
				
            }
        }
        
        bFound = true;
    }
    if (bFound == false) {
        return null;
    }
}

var screenWidth = screen.availWidth;
var screenHeight = screen.availHeight;

function openPopupWindow(targetUrl, width, height, positionX, positionY){

    var name = 'popupWindow';
    var popLocation = "no";
    var popMenubar = "no";
    var popScrollbars = "yes";
    var popStatus = "no";
    var popToolbar = "no";
    var popResize = "no";
    
    openWindow(targetUrl, name, width, height, positionX, positionY, popLocation, popMenubar, popScrollbars, popStatus, popToolbar, popResize);
    
}

function openBrowserWindow(targetUrl, width, height, positionX, positionY){

    var name = 'browserWindow';
    var popLocation = "yes";
    var popMenubar = "yes";
    var popScrollbars = "yes";
    var popStatus = "yes";
    var popToolbar = "yes";
    var popResize = "yes";
    
    openWindow(targetUrl, name, width, height, positionX, positionY, popLocation, popMenubar, popScrollbars, popStatus, popToolbar, popResize);
    
}

function openWindow(targetUrl, name, width, height, positionX, positionY, location, menubar, scrollbars, status, toolbar, resize){

    //Vars, Fallback Werte
    var popTargetUrl = "index.html";
    var popName = "popupWindow";
    
    var popWidth = "fullscreen";
    var popHeight = "fullscreen";
    
    var popPositionX = "center";
    var popPositionY = "center";
    
    var popLocation = "yes";
    var popMenubar = "yes";
    var popScrollbars = "yes";
    var popStatus = "yes";
    var popToolbar = "yes";
    var popResize = "yes";
    //
    
    if (targetUrl != null && targetUrl != undefined) {
    
        popTargetUrl = targetUrl;
        
    }
    
    if (name != null && name != undefined) {
    
        popName = name;
        
    }
    
    switch (width) {
    
        case null:
        case undefined:
            break;
            
        case "fullscreen":
            popWidth = screenWidth;
            break;
            
        default:
            popWidth = width;
            break;
            
    }
    
    switch (height) {
    
        case null:
        case undefined:
            break;
            
        case "fullscreen":
            popHeight = screenHeight;
            break;
            
        default:
            popHeight = height;
            break;
            
    }
    
    switch (positionX) {
    
        case null:
        case undefined:
        case "center":
            popPositionX = (screenWidth - popWidth) / 2;
            break;
            
        case "left":
            popPositionX = 0;
            break;
            
        case "right":
            popPositionX = screenWidth - popWidth;
            break;
            
        default:
            popPositionX = parseInt(positionX);
            break;
            
    }
    
    switch (positionY) {
    
        case null:
        case undefined:
        case "center":
            popPositionY = (screenHeight - popHeight) / 2;
            break;
            
        case "top":
            popPositionY = 0;
            break;
            
        case "bottom":
            popPositionY = screenHeight - popHeight;
            break;
            
        default:
            popPositionY = parseInt(positionY);
            break;
            
    }
    
    
    if (menubar != null && menubar != undefined) {
    
        popMenubar = menubar;
        
    }
    
    if (scrollbars != null && scrollbars != undefined) {
    
        popScrollbars = scrollbars;
        
    }
    
    if (status != null && status != undefined) {
    
        popStatus = status;
        
    }
    
    if (toolbar != null && toolbar != undefined) {
    
        popToolbar = toolbar;
        
    }
    
    if (resize != null && resize != undefined) {
    
        popResize = resize;
        
    }
    
    var popProperties;
    popProperties = "width=" + popWidth + ",height=" + popHeight;
    popProperties += ",left=" + popPositionX + ",top=" + popPositionY;
    popProperties += ",location=" + popLocation + ",menubar=" + popMenubar + ",scrollbars=" + popScrollbars + ",status=" + popStatus + ",toolbar=" + popToolbar + ",resize=" + popResize;
    
    var popupWin = window.open(popTargetUrl, popName, popProperties);
}

