﻿// JScript-Datei
var g_feature;
    
    function toggle(index, path, overlayheadline, overlaytext, alignment, textcolor)
    {
        setActive(index);
        replaceMedia(path, overlayheadline, overlaytext, alignment, textcolor);
    }
    
    function setActive(index)
    {
        var standard = "feature";
        var active = "activefeature";
        var container = document.getElementById("feature" + index);
        if(g_feature != null)
        {
            g_feature.className = standard;
            container.className = active;
            g_feature = container;
        }
        else
        {
           container.className = active;
           g_feature = container;
        }
    }
    
    function replaceMedia(path, overlayheadline, overlaytext, alignment, textcolor)
    {        
        var p = path.lastIndexOf('.');
        if(p>-1)
        {
            var ext = path.substring(p,path.length).toLowerCase();
            //path = "http://"+top.location.host+path;
            var container = document.getElementById("mediabox");
            if(ext == ".swf")
            {
                container.style["backgroundImage"] = "";
                var html = '<div id="SWFObjectContainer">Please update to Flash-Player Version 9 or higher</div>';
                container.innerHTML = html;
                writeSWFObject(path,"SWFObjectContainer");            

            }
            else if(ext == ".flv")
            {
                container.style["backgroundImage"] = "";
                var html = '<div id="SWFMovieContainer">Please update to Flash-Player Version 9 or higher</div>';
                container.innerHTML = html;
                writeSWFMoviePlayer(path,true,"SWFMovieContainer");
            }
            else
            {
                var html = '<div style="color:' + textcolor + ';margin-left:10px;margin-right:10px;padding-top:10px;width:576px;font-size:14px;font-weight:bold;text-align:' + alignment + ';"><h4 style="color:' + textcolor + '">' + overlayheadline + '</h4>' + overlaytext + '</div>'
                container.innerHTML = html;
                container.style["backgroundImage"] = "url('"+path+"')";
            }
        }
    }
    function writeSWFMoviePlayer(url, startplay,targetid)
    {
        var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
        var MMPlayerType = (isIE == true) ? "ActiveX" : "PlugIn";
        var MMredirectURL = window.location;
        var MMdoctitle = document.title;
        var player = new SWFObject("/Flex/Ortovox_Player.swf", "Ortovox_Player", "596", "392", "9", "#ffffff");
        player.addParam("FlashVars", "movieurl="+url+"&startplay="+startplay+"&MMredirectURL="+MMredirectURL+'&MMplayerType='+MMPlayerType+'&MMdoctitle='+MMdoctitle+"");
        player.addParam("wmode", "opaque");
        player.addParam("allowScriptAccess", "sameDomain");
        //player.addLoadEvent(forceRedraw);
        player.write(targetid);  
        /*var params = 
        {
          flashvars: "movieurl="+url+"&startplay="+startplay
        };
        swfobject.addLoadEvent(forceRedraw);
        swfobject.embedSWF("/Flex/Ortovox_Player.swf", targetid, "596", "394", "9.0.0", "false", "false", params, "false");
        */
    } 
    function writeSWFObject(url,targetid)
    {   
        var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
        var MMPlayerType = (isIE == true) ? "ActiveX" : "PlugIn";
        var MMredirectURL = window.location;
        var MMdoctitle = document.title;
        var swfo = new SWFObject(url, url+"_swfobject", "596", "392", "9", "#ffffff");
        swfo.addParam("FlashVars", "MMredirectURL="+MMredirectURL+'&MMplayerType='+MMPlayerType+'&MMdoctitle='+MMdoctitle+"");
        swfo.addParam("wmode", "opaque");
        swfo.addParam("allowScriptAccess", "sameDomain");
        swfo.write(targetid);
    }  
    function writeSWFObjectWithSize(url,targetid,w,h)
    {   
        var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
        var MMPlayerType = (isIE == true) ? "ActiveX" : "PlugIn";
        var MMredirectURL = window.location;
        var MMdoctitle = document.title;
        var swfo = new SWFObject(url, url+"_swfobject", w, h, "9", "#ffffff");
        swfo.addParam("FlashVars", "MMredirectURL="+MMredirectURL+'&MMplayerType='+MMPlayerType+'&MMdoctitle='+MMdoctitle+"");
        swfo.addParam("wmode", "opaque");
        swfo.addParam("allowScriptAccess", "sameDomain");
        swfo.write(targetid);
    }  