﻿
//-------------------------------------------------------- ** Starting Of UI Media Player ** --------------------------------------------------------------------------------//
    /*
    Volume- global variable to hold the volume
    swf-swf player id
    typ-event type
    pr1-property1
    pr2-property2
    type of events are item,load,time,volume,size etc.
    */
    var volume=100;
    var isDefault=true;
    var isStop=true;
    var isClick=true ;

//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

    mute = new Boolean(false);
    function sendEvent(swf,typ) {
        thisMovie(swf).sendEvent(typ);
    };

//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------//


    function getUpdate(typ,pr1,pr2,swf) {
    if(typ=='volume'){
        volume=pr1;
    }
    }

//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

function fnStop(isStop){
    if(isStop){
        if(document.getElementById('eduplayer'))
        thisMovie('eduplayer').sendEvent('stop');
    }
}

//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------//


    function fnSetDefault(){
        isDefault=false;
    }

//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------//


    function thisMovie(movieName) {
        return document.getElementsByName(movieName)[0];
    };

//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------//


    function LoadPlayers(Filename,isStop){
    
        var location=document.location.href.toLowerCase();
        var width=582;var height=367;
        if(location.indexOf('admin/')>0){width=435;height=345;}
        if(location.indexOf('embedplayer')>0) {width="100%";height="100%";}
        if(location.indexOf('embedplayerwskin')>0) {width=435;height=345;}
        if(location.indexOf('watchlive')>0) {width="600px";height="400px";}
         if(location.indexOf('viewvideo')>0) {width="735px";height="552px";}
        var Path=(location.indexOf('admin/')>0 && location.indexOf('watchlive')<=0)?'../':'';
        var SWF = new SWFObject(Path+"includes/Swf/player-licensed-viral.swf","eduplayer",width,height,"9","#FFFFFF");
        SWF.addParam("allowscriptaccess","always");
        SWF.addParam("allowfullscreen","false");
        SWF.addVariable('usefullscreen','false');
        Filename = Filename+"&menu=false;";
        SWF.addVariable('file',Filename);
        
        SWF.addVariable('icons','false');
        
        
        SWF.addVariable('type', 'video');
        SWF.addVariable('javascriptid','eduplayer');
        SWF.addVariable('enablejs','true');
        SWF.addParam("wmode", "transparent");
        SWF.addVariable('type','highwinds');
        //SWF.addVariable('plugins','');
        SWF.addVariable('stretching','uniform');
        SWF.addVariable('plugins', 'gapro-1,captions-1');
        SWF.addVariable('gapro.accountid', 'UA-9885177-1');
        SWF.addVariable('gapro.trackstarts','true');
        SWF.addVariable('gapro.trackpercentage','true');
        SWF.addVariable('gapro.tracktime','true');
	 SWF.addVariable('plugins', 'captions-1');
        
        // SWF.addVariable("logo","http://www.eduvisiontest.info/Images/modern/logoEduVision.png");
        // SWF.addVariable('image','http://www.eduvisiontest.info/Images/modern/logoEduVision.png');
        if(!isStop)
        SWF.addVariable('autostart','true');
        if(location.indexOf("schoolid")> 0 && location.indexOf("filename")>0)isDefault=false;
        if(document.getElementById("hidCurrentRole"))
        {
            var role=document.getElementById("hidCurrentRole").value;
            if(role.toString()=="True" && $("#hidisDefault").val().toString()=="false" )
            { 
                SWF.addVariable('autostart','false');
            }
            else SWF.addVariable('autostart','true');
        }
        SWF.addVariable('repeat','true');
        if(mute == false)
        SWF.addVariable('volume',volume);
        else   SWF.addVariable('mute','true');
        SWF.addVariable('abouttext','JDL Horizons');
        SWF.addVariable('aboutlink','http://www.jdlhorizons.com');
        SWF.write("flashbanner");
    }

//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------//


    function playerReady(obj) {//function gets called each and every time when the player is initialized    
        var id = obj['id'];
        var version = obj['version'];
        var client = obj['client'];

        var player = document.getElementById(id);	
        player.addControllerListener("MUTE","muteTracker");
        player.addControllerListener("VOLUME","RetainVolume");
        player.addModelListener("TIME","GetTIMEToRedirect");
        player.addModelListener("ERROR", "errorMonitor");
    }


    function errorMonitor(obj)
    {
        if(obj.message)
        {
            FindURL('http://hwcdn.net/n4j4y5x8/fms/jdlstate_jdlcity_jdlHighSchool_jdlHighSchool_-1/Video_Not_Available_Mssg_b8c2e36cb1664bbab9368ef8693ee5cf.flv.xml'); 
            //setTimeout('StartPlayer()',8000); 
            //commented by ramesh,because the video is stoped after 8000ms 
        }
    }

//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

    function muteTracker(obj) {
        mute = obj.state;
    }

//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------//


    function RetainVolume(obj) {
        if(mute == false) currentVolume = obj.percentage;
    }   

//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------//


    function GetDefaultFileName(title,isstop,filename) {
        isStop=isstop;
        document.getElementById("playtitle").innerHTML=title;
        ClientServices.GetVideoUrl(filename,oncomplete,ontimeout,onerror);
    } 

//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------//


    function GetFileName(id,isstop,replaceObj,filename) {
        isDefault=false;
        isStop=isstop;
        if(document.getElementById("playtitle"))
        document.getElementById("playtitle").innerHTML=document.getElementById(id.replace(replaceObj,"lblTitle")).innerHTML;
        ClientServices.GetVideoUrl(document.getElementById(id.replace(replaceObj,"hidVideoName")).value,oncomplete,ontimeout,onerror);
    }

//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

    function GetFLVFileName(isstop,filename) {

        isStop=isstop;
        ClientServices.GetVideoUrl(filename,oncomplete,ontimeout,onerror);
    }

//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------//


    function oncomplete(returnvalue){
        if(document.location.href.toLowerCase().indexOf('admin/')<0)
        isStop=false
        LoadPlayers(returnvalue,isStop);
    }

    function ontimeout(){
    }

    function onerror(){
    }

//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------//


    var sys=function(){ 
        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
        function EndRequestHandler(sender, args)
        {
        if (args.get_error() != null)args.set_errorHandled(true);
        } 
    } 

//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

    function FindURL(filename)
    {
        if((filename)=="") ClientServices.GetVideoUrl('default',oncomplete,ontimeout,onerror);
        else  ClientServices.GetVideoUrl(filename,oncomplete,ontimeout,onerror);
    }

//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------//


    function AlreadyPreviewed1(paymenturl){ 
        setTimeout("CallAlready("+paymenturl+"),500");
    }

//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------//



    function VideoAlreadyPreviewed(paymenturl,IsLiveCheck){
        if (confirm("You have already previewed the Video. Please click OK to pay"))
        window.location.href = paymenturl; 
        else  document.location.href= document.location.pathname + "?q=" + IsLiveCheck;
    }

//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------//


    function StopPlayer(){
        thisMovie('eduplayer').sendEvent('stop');
    }

//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------//


    function StartPlayer(){
        thisMovie('eduplayer').sendEvent('play');
    }

//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

