var player = null;
var currentState = "NONE"; 


function playerReady(thePlayer) 
{
    player = window.document[thePlayer.id];
    addListeners();
    //player.sendEvent("STOP");
}

function addListeners()
{
    if (player) { 
        player.addModelListener("STATE", "stateListener");
        //alert (player.state);
    } else {
        setTimeout("addListeners()",100);
    }
}

function stateListener(obj) 
{
    currentState = obj.newstate; 

    if ( currentState == "COMPLETED")
        playMovie(false);
}

function createPlayer( strUrl, strWidth, strHeight, strDivId ) 
{
	if (typeof strDivId == "undefined") strDivId = "muuvie";

	var flashvars = 
    {
            file: strUrl, 
            autostart:"true",
            width:strWidth,
            height:strHeight,
            controlbar:"bottom",
            stretching:"exactfit",
            repeat:"false",
            shownavigation:"true"
    }
    var params = 
    {
            allowfullscreen:"true", 
            allowscriptaccess:"always",
            wmode:"opaque"
    }
    var attributes = 
    {
            id:"player1",  
            name:"player1"
    }
    
    swfobject.embedSWF("mambots/editors/fckeditor/editor/plugins/flvPlayer/player.swf", strDivId, strWidth, strHeight, "7.0", false, flashvars, params, attributes);

}

function playMovie ( blnShow )
{
    if ( blnShow )
    {
        document.getElementById("projLightbox").style.visibility = "visible";	
        document.getElementById("projLightbox").style.display = "block";	
        document.getElementById("projCloseMovie").style.visibility = "visible";	
        document.getElementById("projCloseMovie").style.display = "block";	
        document.getElementById("mainImageBig").style.visibility = "hidden";
        document.getElementById("projMovieLink").style.visibility = "hidden";
    }
    else
    {
        document.getElementById("projLightbox").style.visibility = "hidden";	
        document.getElementById("projLightbox").style.display = "none";	
        document.getElementById("projCloseMovie").style.visibility = "hidden";	
        document.getElementById("projCloseMovie").style.display = "none";	
        document.getElementById("mainImageBig").style.visibility = "visible";	
        document.getElementById("projMovieLink").style.visibility = "visible";
    }
    
}

function detect_flash ( required, max )
{
    var required_version = required;
    var max_version = max;
    var available_version = 0;

    if(typeof(navigator.plugins["Shockwave Flash"]) == "object")
    {
        var description = navigator.plugins["Shockwave Flash"].description;
        available_version = description.substr(16, (description.indexOf(".", 16) - 16));
    }
    
    else if(typeof(ActiveXObject) == "function")
    {
        for(var i = 2; i < (max_version + 1); i ++)
        {
            try
            {
                if(typeof(new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + i)) == "object")
                {
                    available_version = i;
                }
            }
            catch(error)
            { }
        }
    }
    
    return [available_version, required_version];
}			
