var _flashPlugin = null;
function embedFlash(width, height, id, align, path, bgcolor, trans, flashvar, altImg) {
    if (_flashPlugin === null) {
        var getActiveXObject = function(name) {
            var obj = -1; try { obj = new ActiveXObject(name); } catch (err) { obj = { activeXError: true }; } return obj;
        };

        _flashPlugin = false;
        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 version = mimeTypes[type].enabledPlugin.description;
                _flashPlugin = true;
            }
        } else if (navigator.appVersion.indexOf("Mac") == -1 && window.execScript) {
            var version = -1;

	    var getActiveXVersion = function(activeXObj){var version = -1;try{version = activeXObj.GetVariable("$version");}catch(err){}return version;};

	    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);}}];
            for (var i = 0; i < activeXDetectRules.length && version == -1; i++) {
                var obj = getActiveXObject(activeXDetectRules[i].name);
                if (!obj.activeXError) {
                    _flashPlugin = true;
                    version = activeXDetectRules[i].version(obj);
                }
            }
        }

    }
    if (_flashPlugin === true) {
        if (flashvar == "undefined") flashvar = "";
        var wmode1 = "", wmode2 = "";
        document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,65,0" width=' + width + ' height=' + height + ' name="' + id + '" id="' + id + '_i" align=' + align + wmode1 + '><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value=' + path + ' /><param name="wmode" value="transparent" /><param name="quality" value="high" /><param name="bgcolor" value=' + bgcolor + ' />' + wmode2 + '<param name="flashvars" value="' + flashvar + '"  /><param name="menu" value="false" /><embed src="' + path + '" quality="high" bgcolor="' + bgcolor + '" width="' + width + '" height="' + height + '" wmode="transparent" id="' + id + '" align="' + align + '" FlashVars="' + flashvar + '"  menu="false" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>');
    } else if (typeof (altImg) != "undefined" && altImg !== null && altImg.length) {
        document.write('<img alt="" src="' + altImg + '" />');
    }
}


function epixVideo(sig,options){

if(typeof(options)=="undefined")options={autostart:false};
var autostart="false";
if(typeof(options.autostart)!="undefined")
{ if(options.autostart===true)autostart="true";
  if(options.autostart===false)autostart="false";
}
var width=600;
var height=337;
if(typeof(options.width)!="undefined")width=options.width;
if(typeof(options.height)!="undefined")height=options.height;

var mbody=document.createElement("div");
mbody.className="modalWindow";
var closeIcon =document.createElement("div");
closeIcon.className="closeIcon";
closeIcon.style.marginBottom="5px";
closeIcon.style.marginLeft="auto";
mbody.appendChild(closeIcon);

var div=document.createElement("div");
div.innerHTML='<div class="containerEpix" style="position: relative;width:'+width+'px;height:'+height+'px"><div id="kwg_'+sig+'" class="kwg_pr" name="kwg_'+sig+'" ></div><div id="flash_epix_'+sig+'" class="flash_epix" name="flash_epix" ><object id="'+sig+'" type="application/x-shockwave-flash" data="http://s.kewego.com/swf/p3/epix.swf" width="'+width+'" height="'+height+'">  <param name="flashVars" value="language_code=fr&playerKey=c4b9011f051d&skinKey=1906e3d3ef76&sig='+sig+'&autostart='+autostart+'&advertise=1" />  <param name="movie" value="http://s.kewego.com/swf/p3/epix.swf" />  <param name="allowFullScreen" value="true" />  <param name="allowscriptaccess" value="always" />  <param name="wmode" value="Opaque" /></object></div></div>';
mbody.appendChild(div);

var modal = new Control.Modal(null, {bodyContent:mbody});
modal.open();
Event.observe(closeIcon,'click', modal.close.bind(modal));
}

function KplayerVideo(sig,options){

if(typeof(options)=="undefined")options={autostart:false};
var autostart="false";
if(typeof(options.autostart)!="undefined")
{ if(options.autostart===true)autostart="true";
  if(options.autostart===false)autostart="false";
}
var width=600;
var height=337;
if(typeof(options.width)!="undefined")width=options.width;
if(typeof(options.height)!="undefined")height=options.height;

var mbody=document.createElement("div");
mbody.className="modalWindow";
var closeIcon =document.createElement("div");
closeIcon.className="closeIcon";
closeIcon.style.marginBottom="5px";
closeIcon.style.marginLeft="auto";
mbody.appendChild(closeIcon);

var div=document.createElement("div");
div.innerHTML='<div class="containerKplayer" style="position: relative;width:'+width+'px;height:'+height+'px"><div id="kwg_'+sig+'" class="kwg_pr" name="kwg_'+sig+'" ></div><div id="flash_kplayer_'+sig+'" class="flash_kplayer" name="flash_kplayer" ><object width="'+width+'" height="'+height+'" type="application/x-shockwave-flash" data="http://s.kewego.com/swf/kp.swf" name="kplayer_'+sig+'" id="kplayer_'+sig+'"><param name="bgcolor" value="0x000000" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" />  <param name="flashVars" value="language_code=fr&playerKey=c4b9011f051d&configKey=7e3604869648&suffix=&sig='+sig+'&autostart='+autostart+'&advertise=1" />  <param name="movie" value="http://s.kewego.com/swf/p3/kp.swf" />  <param name="wmode" value="Opaque" /></object></div></div>';
mbody.appendChild(div);

var modal = new Control.Modal(null, {bodyContent:mbody});
modal.open();
Event.observe(closeIcon,'click', modal.close.bind(modal));
}
