/*
 *  Copyright 2009
 *
 *  MAGIX AG
 *  Friedrichstraße 200
 *  10117 Berlin
 *
 *  Tel +49-30-29392-0
 *  Fax +49-30-29392-400
 *
 *  http://www.magix.net
 *
 *  All rights reserved
 *
 */
 
function getSystemInfo() {
    return "Browser Name : " + navigator.appName + "\nUser Agent : " + navigator.userAgent;
}

function reloadWindow() {
    window.location.reload();
}

function closeWindow() {
    window.close();
}

function showWindow(url, target, params) {
    if (params != undefined) {
        window.open(url, target, params);
    } else if (target != undefined) {
        window.open(url, target);
    } else {
        window.open(url);
    }
}

function openWindow(url, target, params) {
    var callString = "showWindow('" + url + "'";
    if (target != undefined) {
        callString += ",'" + target + "'";
    }
    if (params != undefined) {
        if (target == undefined) {
            callString += ",'_blank'";
        }
        callString += ",'" + params + "'";
    }
    callString += ")";
    window.setTimeout(callString, 10);
}

function createFlashTag(id, src, width, height, menu, bgcolor, version, style) {
    var str = "";
    if (navigator.plugins.length > 0 || ( navigator.plugins.toString && navigator.plugins.toString() == "[object PluginArray]" ) ) {
        str += "<embed salign=\"TL\" src=\"" + src 
            + "\" width=\"" + width 
            + "\" height=\"" + height 
            + "\" pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" "
            + " id=\"" + id 
            + "\" name=\"" + id 
            + "\" style=\"" + style 
            + "\" menu=\"" + menu
            + "\" bgcolor=\"" + bgcolor
            + "\" version=\"" + version
            + "\"></embed>";
        
    } else {
        str += "<object salign=\"TL\" classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab"
            +  "#version=" + version 
            + "\" width=\"" + width 
            + "\" height=\"" + height 
            + "\" id=\"" + id
            + "\" style=\"" + style + "\">"
            + "<param name=\"menu\" value=\"" + menu + "\" />"
            + "<param name=\"bgcolor\" value=\"" + bgcolor + "\" />"
            + "<param name=\"movie\" value=\"" + src + "\" />"
            + "</object>";
    }
    return str;
}

function appendTag(doc, tag, code) {
    if (!doc) {
        doc = document;
    }
    if (!tag) {
        tag = doc.getElementsByTagName("body")[0];
    }
    var nn = doc.createElement("div");
    nn.innerHTML += code;
    tag.appendChild(nn);
    return nn;
}

function createSoundTag(file, bgcolor) {
    var code = createFlashTag(
        "player_sound",
        file,
        1,
        1,
        false,
        bgcolor,
        "7.0.0.0",
        "position:absolute; top:0px; left:0px; padding:0px; margin:0px;"
    );
    appendTag(document, null, code);
}







function viewport() {
    w = 0;
    h = 0;
    if (self.innerHeight) { // IE
        if(document.documentElement.clientWidth){
            w = document.documentElement.clientWidth; 
        } else {
            w = self.innerWidth;
        }
        h = self.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) { // IE Strict Mode
            w = document.documentElement.clientWidth;
            h = document.documentElement.clientHeight;
    } else if (document.body) { // Andere Explorer
            w = document.body.clientWidth;
            h = document.body.clientHeight;
    }
    return {
        w:w,
        h:h
    };
}

function getFlashObj(movie){
    if (window.document[movie]) {
        return window.document[movie];
    }
    if (navigator.appName.indexOf("Microsoft Internet")==-1) {
        if (document.embeds && document.embeds[movie]) {
            return document.embeds[movie]; 
        }
    } else {
        return document.getElementById(movie);
    }
}

var ow = 0;
var oh = 0;

function initSizeCheck() {
    var v = viewport();
    setInterval(function(){
        v = viewport();
        if ( v.w != ow || v.h != oh ) {
            fo = getFlashObj('oma_ppa');
            if ( fo ) {
                ow = v.w;
                oh = v.h;
                fo.height= v.h - 140 + 'px';
            }
        }
    }, 50)
}