var ie = /MSIE/.test(navigator.userAgent);


function initScreen()
{
	if(screen.height <= 1024)
	{
		document.getElementById("Form1").style.height = document.getElementById("masterPanel").clientHeight+100+"px";
		document.getElementById("masterPanel").style.height = document.getElementById("Form1").style.height;
	}
	AttachDBclickEvent();
}

function AttachDBclickEvent()
{
    if(ie)
	    document.getElementById("videoListe").attachEvent("ondblclick",playVideo);
	else
	    document.getElementById("videoListe").addEventListener("dblclick",playVideo,true);
}

function playVideo()
{
	var videolst = document.getElementById("videoListe");
	if(videolst.selectedIndex != -1)
	{
		var obj = document.getElementById("myPlayer");
		obj.controls.stop();
		var video = document.getElementById("videoserver").value + videolst.options[videolst.selectedIndex].value + ".wmv";
		obj.URL = video;
		if(!ie)
		    obj.data = video;
		obj.controls.play();
		Chapter();
	}else
		alert(err1);
}


//génére le code necessaire en fonction du navigateur, renvoie vraie si le lien de telechargement doit etre affiché
function initVideoPlayer()
{ 
    if(ie)
    {
        document.write('<OBJECT ID="myPlayer" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" width="430" height="323">');
        document.write('<PARAM NAME="uiMode" VALUE="full">');
        document.write('<PARAM NAME="playCount" VALUE="1">');
        document.write('<PARAM NAME="stretchToFit" VALUE="-1">');
        document.write('<PARAM NAME="_cx" VALUE="11377">');
        document.write('<PARAM NAME="_cy" VALUE="8546">');
        document.write('</OBJECT>');
    }
    else{
        document.write('<OBJECT ID="myPlayer" type="video/x-ms-wmv" width="430" height="323">');
        document.write('<PARAM NAME="uiMode" VALUE="full">');
        document.write('<param name="showstatusbar" value="1">');
        document.write('<param name="showcontrols" value="1">');
	    document.write('<param name="enableContextMenu" value="1">');
        document.write('<PARAM NAME="playCount" VALUE="1">');
        document.write('<PARAM NAME="stretchToFit" VALUE="0">');
        document.write('<PARAM NAME="autoStart" VALUE="1"');
        document.write('</OBJECT>');
        
    }
}

//verifie la presence du plugin WMP pour FF et safari
function LinkWMPPlugin()
{
    var lLink;
    
    if (navigator.platform == "Win32")
    {
        if (document.all) 
        { 
            lLink = false;
        }
        else if (document.layers) 
        {
            lLink = false;
        } 
        else if (document.getElementById) 
        {
            lLink = true;
	        for (var i1 = 0 ; i1 < navigator.plugins.length ; i1++)
            {
                var n = navigator.plugins[i1].name;
                if ( n != null && n.indexOf("Windows Media") >= 0 && n.indexOf("Microsoft") >= 0 ) 
                { lLink = false; break; }
            }
        } 
    }
    else
    {
        lLink = false;  
    }
    return lLink;
}

function Chapter()
{   
    var obj = document.getElementById("videoListe");
    var prompt = obj.options[obj.selectedIndex].text;
    document.getElementById("promptChapter").firstChild.nodeValue = prompt;
}

function affHelp(val)
{
   document.getElementById("help").style.display = val;
}