﻿// JScript File

// some variables to save for JW PLAYER
var currentPosition = 0;
var currentBuffer = 0; 
var currentVolume = 80; 
var currentState = 'IDLE';
var currentLoad = 0;
var plyValue;
var plyVideo;
var sfileName;
var globalPayRate = 0;
 
// variable for MM PLAYER
var filePatches;

// VARIABLE FOR JW YOUTUBE PLAYER
var currentPositionYT = 0; 
var currentVolumeYT = 0; 
var playerYT = null;

//window.onbeforeunload = unloadPage;

function unloadPage(){
    
   if(document.getElementById("hidEndUserID").value != "0") 
    {
         LogoutWindow();
   }
}


function LogoutWindow()
{  
     if (document.getElementById("hidSyndicationID").value == "-1")
     {
        window.parent.location="../Logout.aspx?endUserID=" + document.getElementById("hidEndUserID").value; 
     }
     else
     {  
        window.location.assign("../Logout.aspx?endUserID=" + document.getElementById("hidEndUserID").value); 
        window.location = window.location.href;       
     }
}

function PrivateAccess_PageLoad()
{   
    // check whether page loaded with no URL does not exist message
    //if (lblMessage != "")
       // return;
        
    // Load the Private access page
    if (document.getElementById("hidLineUpAccess").value != "0" && document.getElementById("VideoDesc_hidLineUpID").value != "0")
    {
        // Un-Play the Selected Video (otherwise audio will play on background)
        //LoadPlayer('');  
            
        // Hide the Player Div tag
        document.getElementById("divPlayerContainer").style.display = "none";
        
        var oWindow = window.radopen("Login_Private.aspx?accessType=" + document.getElementById("hidLineUpAccess").value + "&accountID=" + document.getElementById("hidAccountID").value + "&LineUpID=" + document.getElementById("VideoDesc_hidLineUpID").value,"rwWindow");
        //Using the reference to the window its clientside methods can be called  
        oWindow.SetSize(700,500);
        oWindow.center();
        oWindow.add_close(OnLoginClose);
        return false;
    }
}

// --------------------------------- OVERALL TEMPLATE FUNCTIONS -------------------------------------------

function PageLoad()
{    
   // HIDE THE BUTTONS
   document.getElementById("VideoDesc_btnVideo").style.display = "none"; 
   document.getElementById("VideoDesc_btnRating").style.display = "none"; 
        
   if (document.getElementById("hidTemplateID").value > 2)
   {  
       document.getElementById("VOD_btnGoPage").style.display = "none";   
   }
   
   if (document.getElementById("hidTemplateID").value > 1)
   {  
       document.getElementById("Header_btnLogin").style.display = "none"; 
        
       // Hide the loggedin infor div
       document.getElementById("divLoggedInInfo").style.display = "none";
       document.getElementById("lnkMyAccount").style.display = "none";  
       document.getElementById("lnkMyPayment").style.display = "none";  
       document.getElementById("divPreLogin").style.display = "block"; 
              
        if (document.getElementById("hidTemplateID").value != 8)
        {
            // Logged In Date    
            var d = new Date()
            var weekday=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
            var monthname=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
            var dateValue = weekday[d.getDay()] + ", "
            dateValue += d.getDate() + " "
            dateValue += monthname[d.getMonth()] + " "
            dateValue += d.getFullYear();
            if (document.getElementById("Date_hidDateObject").value == 'Date')
                document.getElementById("Date_lblDate").innerHTML = dateValue; 
        }
   }   
   
   if ((parseInt(document.getElementById("hidTemplateID").value) >= 5) && (parseInt(document.getElementById("hidTemplateID").value) <= 6))
   {  
        if (document.getElementById("hidTemplateID").value == 5)  // super template with big player
        {
            // Top Banner with playerID
            document.getElementById("iTopBanner").src = "../adDisplay.aspx?item=topBanner&PlayerID=" + document.getElementById("hidPlayerID").value;  
            
            // Square Banner with playerID
            document.getElementById("iSquareBanner").src = "../adDisplay.aspx?item=squareBanner&PlayerID=" + document.getElementById("hidPlayerID").value;  
            
            // Bottom Banner with playerID
            document.getElementById("iBottomBanner").src = "../adDisplay.aspx?item=bottomBanner&PlayerID=" + document.getElementById("hidPlayerID").value;  
        }
        
        if (document.getElementById("hidTemplateID").value == 6)     // super template with small player
        {               
            // Top Banner with playerID
            document.getElementById("iTopBanner_SSP").src = "../adDisplay.aspx?item=topBanner&PlayerID=" + document.getElementById("hidPlayerID").value;  
            
            // Square Banner with playerID
            document.getElementById("iSquareBanner_SSP").src = "../adDisplay.aspx?item=squareBanner&PlayerID=" + document.getElementById("hidPlayerID").value;  
            
            // Bottom Banner with playerID
            document.getElementById("iBottomBanner_SSP").src = "../adDisplay.aspx?item=bottomBanner&PlayerID=" + document.getElementById("hidPlayerID").value;  
        }
        
        // HIDE WEB 2.0 FEATURES
        document.getElementById("Web_btnShare").style.display = "none";
        
        // hide the nofeature tab    
        document.getElementById("noFeature").style.display = "none"; 
            
        // Display the no feature available tab
        if ((document.getElementById("hidEnableShare").value == "False") && (document.getElementById("hidEnableChat").value == "False") && (document.getElementById("hidEnableComment").value == "False"))    
        {
            document.getElementById("noFeature").style.display = "block"; 
            document.getElementsByClassName("nofeatureclass")[0].style.color =  document.getElementById("hidFontColor").value; 
            document.getElementsByClassName("nofeatureclass")[0].style.fontFamily = document.getElementById("hidFontName").value;        
        }
            
        if (document.getElementById("hidTemplateID").value == 5)  // super template with big player
        { 
            // SHOW/ HIDE THE WEB 2.0 FEATURES (CHAT)
            if (document.getElementById("hidEnableChat").value == "False")
            {
                document.getElementById("Web_spanChat").style.display = "none";    
                document.getElementById("chatTab").style.display = "none";  
                
                // enable the share tab as default (if chat is disabled)
                chattab.expandit(1);     
                
                document.getElementById("lnkShare").style.color = document.getElementById("hidFontColor").value; 
                document.getElementById("lnkShare").style.fontFamily = document.getElementById("hidFontName").value; 
                document.getElementById("lnkShare").style.backgroundColor = document.getElementById("hidForeColor").value; 
            }
        }  
        
        if (document.getElementById("hidTemplateID").value == 6)  // super template with small player
        { 
            // SHOW/ HIDE THE WEB 2.0 FEATURES (CHAT)
            if (document.getElementById("hidEnableChat").value == "True")
            {
                // Chat Window 
                document.getElementById("frameChat").src = "../ChatNameSmall.aspx?UserID=" + document.getElementById("hidAccountID").value + "&foreColor=" + document.getElementById("hidForeColor").value.replace("#", "") + "&font=" + document.getElementById("hidFontName").value + "&fontColor=" + document.getElementById("hidFontColor").value.replace("#", "");  
            }     
            else
                document.getElementById("divFrameChat").innerHTML = "No Chat Available";
                       
            document.getElementById("Web_spanChat").style.display = "none";    
            document.getElementById("chatTab").style.display = "none";  
            
            // enable the share tab as default (if chat is disabled)
            chattab.expandit(1);     
            
            document.getElementById("lnkShare").style.color = document.getElementById("hidFontColor").value; 
            document.getElementById("lnkShare").style.fontFamily = document.getElementById("hidFontName").value; 
            document.getElementById("lnkShare").style.backgroundColor = document.getElementById("hidForeColor").value; 
        }  
          
        // SHOW/ HIDE THE WEB 2.0 FEATURES (SHARE)
        if (document.getElementById("hidEnableShare").value == "False")
        {
            document.getElementById("Web_spanShare").style.display = "none";    
            document.getElementById("shareTab").style.display = "none"; 
            
            // enable the share tab as default (if chat & share is disabled)
            chattab.expandit(2);     
            
            document.getElementById("lnkComment").style.color = document.getElementById("hidFontColor").value; 
            document.getElementById("lnkComment").style.fontFamily = document.getElementById("hidFontName").value; 
            document.getElementById("lnkComment").style.backgroundColor = document.getElementById("hidForeColor").value;  
        }
        
        // SHOW/ HIDE THE WEB 2.0 FEATURES (COMMENT)
        if (document.getElementById("hidEnableComment").value == "False")
        {
            document.getElementById("Web_spanComment").style.display = "none";   
            document.getElementById("commentTab").style.display = "none";             
        }
       
    }   
    
     // HIDE THE REGISTRATION PANELS
    if ((document.getElementById("hidLineUpAccess").value == "0") && (document.getElementById("hidRegistrationAccess").value == "False"))
    { 
        document.getElementById("divPreLogin").style.display = "none";  
        document.getElementById("lnkRegister").style.display = "none";   
    }       
    
}

function ReloadVideoDesc(theTitle,theDesc,theTags,thePath,theStatus,thePayRate,thePayStatus,theRating,theViews,theDuration)
{
    if (parseInt(document.getElementById("hidTemplateID").value) <= 5)
    {
       var viewObj = "<table style='width: 575px'><tr>"
           
        // HIDE THE RATING FEATURE
        if (document.getElementById("hidEnableRating").value == "True")     
            viewObj += "<td class='playing'><div id='divRating'></div><td>" // this div will have the values for rating (DynamicRatingStars)
        else
            viewObj += "<td></td>"
            
        viewObj += "<td align='right' class='playing'>" + theViews + " views</td></tr></table>";
        
        document.getElementById("divVideoDetail").innerHTML = viewObj;   
       
       // HIDE THE RATING FEATURE
        if (document.getElementById("hidEnableRating").value == "True") 
            DynamicRatingStars(theRating); // FOR ABOVE "DIVRATING" TAG..

        // Load the selected video description
            var descObj = "<table style='height: 65px'><tr><td style='padding: 5px 0px 5px 0px; height: 20px; border: 1px solid #686868'><table><tr><td style='width: 500px;' class='MovieTxt'>"
                          + theTitle.substring(0,15) + "</td>"                      
                          + "</tr></table></td></tr><tr><td style='height: 45px; border: 1px solid #686868; padding: 0px 0px 0px 10px'>"
                          + "&nbsp;" + theDesc.substring(0,100) + "<br/>"
                          //+ "Tags: <span class='playing'>" + theTags + "</span>"
                          
                   descObj += "</td></tr></table>";
        
        document.getElementById("divVideoDesc").innerHTML = descObj;  
     }
     
    if (document.getElementById("hidTemplateID").value >= 6)
    {               
        // Load the selected video description                            
        var descObj =  "<table><tr><td style='padding: 5px 0px 5px 0px;'>"
                      + "<span class='MovieTitle'><b>" + theTitle.substring(0,15) + "</b></span><br/>"                                               
                      + theDesc.substring(0,100) + "<br/>"
                      + "Tags: <span class='playing'>" + theTags + "</span><br/>"
                      + "Views: " + theViews
               
        
         // HIDE THE RATING FEATURE
        if (document.getElementById("hidEnableRating").value == "True")     
               descObj += "<div id='divRating' class='playing'></div>" // this div will have the values for rating (DynamicRatingStars)
                                           
        descObj += "</td></tr></table>";   
        
        // alert(descObj);    
        document.getElementById("divVideoDesc").innerHTML = descObj;  
                    
       // HIDE THE RATING FEATURE
        if (document.getElementById("hidEnableRating").value == "True") 
            DynamicRatingStars(theRating); // FOR ABOVE "DIVRATING" TAG..
    } 
        
    // CODE STARTS FOR SET PLAYER DESCRIPTION CSS
    //document.getElementsByClassName("border1px")[0].style.border = '1px solid ' + document.getElementById("hidForeColor").value;
        
    // PLAYER DESCRIPTION TITLE & ADDED
    document.getElementsByClassName("MovieTitle")[0].style.color = document.getElementById("hidForeColor").value; 
    document.getElementsByClassName("MovieTitle")[0].style.fontFamily = document.getElementById("hidFontName").value;
    //document.getElementsByClassName("MovieTxt")[1].style.color = document.getElementById("hidForeColor").value; 
    //document.getElementsByClassName("MovieTxt")[1].style.fontFamily = document.getElementById("hidFontName").value;
    
    // PLAYER'S VIEWS & RATINGS
    document.getElementsByClassName("playing")[0].style.color =  document.getElementById("hidFontColor").value; 
    document.getElementsByClassName("playing")[0].style.fontFamily = document.getElementById("hidFontName").value;
    
    if (document.getElementById("hidEnableRating").value == "true")
    {
        document.getElementsByClassName("playing")[1].style.color =  document.getElementById("hidFontColor").value; 
        document.getElementsByClassName("playing")[1].style.fontFamily = document.getElementById("hidFontName").value;
    }
    //document.getElementsByClassName("playing")[2].style.color =  document.getElementById("hidFontColor").value; 
    //document.getElementsByClassName("playing")[2].style.fontFamily = document.getElementById("hidFontName").value;
    
   // CODE ENDS FOR SET PLAYER DESCRIPTION CSS
        
    // Hide the buttons
    // Hide THE btnVideo BUTTON
    if (document.getElementById("VideoDesc_btnVideo").style.display == "block")
        document.getElementById("VideoDesc_btnVideo").style.display = "none";
        
    // Hide THE btnRating BUTTON
    if (document.getElementById("VideoDesc_btnRating").style.display == "block")
        document.getElementById("VideoDesc_btnRating").style.display = "none";
}

function LoadVideoDesc(theTitle,theDesc,theTags,thePath,thePreRollPath,theRealPath,theStatus,thePayRate,thePayStatus,theRating,theViews,theDuration)
{             
    // 
    
    // Un-Play the Selected Video (otherwise audio will play on background)
    LoadPlayer('','','');    
      
   // THIS VIDEO DESCRIPTION IS NOT APPLICABLE FOR THUMBSIZE PLAYER
   if (document.getElementById("hidTemplateID").value == 0)    
     document.getElementById("VideoDesc_radPanelVideoDesc").style.display = "none";
   else 
   {    
       if (parseInt(document.getElementById("hidTemplateID").value) <= 5)
       {
           var viewObj = "<table style='width: 575px'><tr>"
           
            // HIDE THE RATING FEATURE
            if (document.getElementById("hidEnableRating").value == "True")     
                viewObj += "<td class='playing'><div id='divRating'></div></td>" // this div will have the values for rating (DynamicRatingStars)
            else
                viewObj += "<td></td>"
            
            //if (thePayRate != '0.00' && document.getElementById("hidLoginStatus").value == 'Logged-In')
            //    viewObj += "<td align='center'><a id='lnkPayNow' href='javascript://' onclick='OpenPaymentWindow(" + thePayRate + ");'><span id='spanLnkPayNow' style='color:" + document.getElementById("hidFontColor").value + "' onmouseover='javascript:ApplyHref(this.id);' onmouseout='javascript:UnloadHref(this.id);'><u>Click Here To Pay</u></span></td>"
                                                  
            viewObj += "<td align='right' class='playing'>" + theViews + " views</td></tr></table>";
            
            document.getElementById("divVideoDetail").innerHTML = viewObj;   
       
            // HIDE THE RATING FEATURE
            if (document.getElementById("hidEnableRating").value == "True") 
                DynamicRatingStars(theRating); // FOR ABOVE "DIVRATING" TAG..
                
            // Load the selected video description                            
            var descObj =  "<table style='height: 65px;'><tr><td style='padding: 5px 0px 5px 0px; height: 20px; border: 1px solid #686868'><table><tr><td style='width:500px;' class='MovieTxt'>"
                          + theTitle.substring(0,15) + "</td>"                     
                          + "</tr></table></td></tr><tr><td style='height: 45px; border: 1px solid #686868; padding: 0px 0px 0px 10px'>"
                          + "&nbsp;" + theDesc.substring(0,100) + "<br/>"
                        //  + "Tags: <span class='playing'>" + theTags + "</span>"
                   descObj += "</td></tr></table>";
            
            document.getElementById("divVideoDesc").innerHTML = descObj;  
           
            // PLAYER DESCRIPTION TITLE & ADDED
            document.getElementsByClassName("MovieTxt")[0].style.color = document.getElementById("hidForeColor").value; 
            document.getElementsByClassName("MovieTxt")[0].style.fontFamily = document.getElementById("hidFontName").value;
           
       }    
         
       if (document.getElementById("hidTemplateID").value >= 6)
       {               
            // Load the selected video description                            
            var descObj =  "<table><tr><td style='padding: 5px 0px 5px 0px;'>"
                          + "<span class='MovieTitle'><b>" + theTitle.substring(0,15) + "</b></span><br/>"                                               
                          + theDesc.substring(0,100) + "<br/>"
                          + "Tags: <span class='playing'>" + theTags + "</span><br/>"
                          + "Views: " + theViews
                   
            
             // HIDE THE RATING FEATURE
            if (document.getElementById("hidEnableRating").value == "True")     
                   descObj += "<div id='divRating' class='playing'></div>" // this div will have the values for rating (DynamicRatingStars)
                                               
            descObj += "</td></tr></table>";   
            
            // alert(descObj);    
            document.getElementById("divVideoDesc").innerHTML = descObj;  
                        
           // HIDE THE RATING FEATURE
            if (document.getElementById("hidEnableRating").value == "True") 
                DynamicRatingStars(theRating); // FOR ABOVE "DIVRATING" TAG..
                
            // PLAYER DESCRIPTION TITLE & ADDED
            document.getElementsByClassName("MovieTitle")[0].style.color = document.getElementById("hidForeColor").value; 
            document.getElementsByClassName("MovieTitle")[0].style.fontFamily = document.getElementById("hidFontName").value;
           
        }        
               
        // CODE STARTS FOR SET PLAYER DESCRIPTION CSS
        //document.getElementsByClassName("border1px")[0].style.border = '1px solid ' ;
            
        //document.getElementsByClassName("MovieTxt")[1].style.color = document.getElementById("hidForeColor").value; 
        //document.getElementsByClassName("MovieTxt")[1].style.fontFamily = document.getElementById("hidFontName").value;
        
        // PLAYER'S VIEWS & RATINGS
        document.getElementsByClassName("playing")[0].style.color =  document.getElementById("hidFontColor").value; 
        document.getElementsByClassName("playing")[0].style.fontFamily = document.getElementById("hidFontName").value;
        
        if (document.getElementById("hidEnableRating").value == "true")
        {
            document.getElementsByClassName("playing")[1].style.color =  document.getElementById("hidFontColor").value; 
            document.getElementsByClassName("playing")[1].style.fontFamily = document.getElementById("hidFontName").value;
        }
        //document.getElementsByClassName("playing")[2].style.color =  document.getElementById("hidFontColor").value; 
        //document.getElementsByClassName("playing")[2].style.fontFamily = document.getElementById("hidFontName").value;
        
        // HIDE THE VIDEO DESCRIPTION SECTION (FOR PLAYER TEMPLATE 8)
        if (document.getElementById("hidTemplateID").value == 8)    
             document.getElementById("divVideoDesc").style.display = "none";
         
        // CODE ENDS FOR SET PLAYER DESCRIPTION CSS
        
   }
   
   
   // ***** CODE STARTS FOR CHECK FOR THE VIDEO PAYMENT / FREE INFORMATION
   
    //// ******* FREE VIDEO *******///////
    if (thePayRate == '0.00')   
    {  
        // Hide the payment info Div tag
        document.getElementById("divVideo").style.display = "none";               
        
        // set flag as free video (for you tube & flash video)
        document.getElementById("hidFlashVideoPaid").value = "false"; 
           
        // Play the Selected Video
        LoadPlayer(thePath,thePreRollPath,theRealPath); 
        
         // Refresh the schedule part (for payment information)
        var selectedPage = 1; 
        GoSchedulerPage(selectedPage);   
                   
        return;           
    }
    //// ******* ALREADY PAID VIDEO *******///////    
    else if (theStatus == 'paid') 
    {                
        // set flag as already paid video (for you tube & flash video)
        document.getElementById("hidFlashVideoPaid").value = "false"; 
               
        // Hide the Player Div tag
        document.getElementById("divPlayerContainer").style.display = "none";        
        // Hide the payment info Div tag
        document.getElementById("divVideo").style.display = "block";
        
        // CHANGE THE IMAGE SIZE FOR THUMBSIZE PLAYER
        if (document.getElementById("hidTemplateID").value == 0)
            document.getElementById("divVideo").innerHTML = "<div style='background: url(../images/Index_Custom/smallPlayerImage.jpg) repeat-x top left #101010; font-family: Verdana; font-size: x-small; color: Black; width: 234px; height: 192px;'><br /><br /><br /><br /><br />" + thePayStatus + "</div>";                 
        else            
        {
            if (document.getElementById("hidPlayerTypeID").value == 1)  // JW PLAYER OBJECT
            {
                if (document.getElementById("hidTemplateID").value <= 5)
                    document.getElementById("divVideo").innerHTML = "<div style='background: url(../images/Index_Custom/playerImageJW.jpg) repeat-x top left #101010; font-family: Verdana; font-size: smaller; color: Black; width: 620px; height: 400px;'><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />" + thePayStatus + "</div>";                 
                else if ((parseInt(document.getElementById("hidTemplateID").value) >= 6) && (parseInt(document.getElementById("hidTemplateID").value) <= 7))
                    document.getElementById("divVideo").innerHTML = "<div style='background: url(../images/Index_Custom/playerImageJW_450.jpg); font-family: Verdana; font-size: smaller; color: Black; width: 450px; height: 350px;'><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />" + thePayStatus + "</div>";                                    
                else if (document.getElementById("hidTemplateID").value >= 8)
                    document.getElementById("divVideo").innerHTML = "<div style='background: url(../images/Index_Custom/playerImage_400.jpg); font-family: Verdana; font-size: smaller; color: Black; width: 400px; height: 330px;'><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />" + thePayStatus + "</div>";                                    
            }
            else if (document.getElementById("hidPlayerTypeID").value == 2)  // OPEN VIDEO PLAYER OBJECT
            {
                if (document.getElementById("hidTemplateID").value <= 5)
                    document.getElementById("divVideo").innerHTML = "<div style='background: url(../images/Index_Custom/playerImage.jpg) repeat-x top left #101010; font-family: Verdana; font-size: smaller; color: Black; width: 620px; height: 400px;'><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />" + thePayStatus + "</div>";                 
                else if ((parseInt(document.getElementById("hidTemplateID").value) >= 6) && (parseInt(document.getElementById("hidTemplateID").value) <= 7))
                    document.getElementById("divVideo").innerHTML = "<div style='background: url(../images/Index_Custom/playerImage_450.jpg); font-family: Verdana; font-size: smaller; color: Black; width: 450px; height: 350px;'><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />" + thePayStatus + "</div>";                 
                else if (document.getElementById("hidTemplateID").value >= 8)
                    document.getElementById("divVideo").innerHTML = "<div style='background: url(../images/Index_Custom/playerImage_400.jpg); font-family: Verdana; font-size: smaller; color: Black; width: 400px; height: 330px;'><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />" + thePayStatus + "</div>";                                    
            }
            else if (document.getElementById("hidPlayerTypeID").value == 3)  // WINDOWS MEDIA PLAYER OBJECT
            {
                if (document.getElementById("hidTemplateID").value <= 5)
                    document.getElementById("divVideo").innerHTML = "<div style='background: url(../images/Index_Custom/playerImageWM.jpg) repeat-x top left #101010; font-family: Verdana; font-size: smaller; color: Black; width: 620px; height: 400px;'><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />" + thePayStatus + "</div>";                 
                else if ((parseInt(document.getElementById("hidTemplateID").value) >= 6) && (parseInt(document.getElementById("hidTemplateID").value) <= 7))
                    document.getElementById("divVideo").innerHTML = "<div style='background: url(../images/Index_Custom/playerImageWM_450.jpg); font-family: Verdana; font-size: smaller; color: Black; width: 450px; height: 350px;'><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />" + thePayStatus + "</div>";                 
                else if (document.getElementById("hidTemplateID").value >= 8)
                    document.getElementById("divVideo").innerHTML = "<div style='background: url(../images/Index_Custom/playerImage_400.jpg); font-family: Verdana; font-size: smaller; color: Black; width: 400px; height: 330px;'><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />" + thePayStatus + "</div>";                                    
            }
            else if (document.getElementById("hidPlayerTypeID").value == 4)  // MONETIZE MEDIA PLAYER OBJECT
            {
                if (document.getElementById("hidTemplateID").value <= 5)
                    document.getElementById("divVideo").innerHTML = "<div style='background: url(../images/Index_Custom/playerImageMM.jpg) repeat-x top left #101010; font-family: Verdana; font-size: smaller; color: Black; width: 620px; height: 400px;'><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />" + thePayStatus + "</div>";                 
                else if ((parseInt(document.getElementById("hidTemplateID").value) >= 6) && (parseInt(document.getElementById("hidTemplateID").value) <= 7))
                    document.getElementById("divVideo").innerHTML = "<div style='background: url(../images/Index_Custom/playerImageMM_450.jpg); font-family: Verdana; font-size: smaller; color: Black; width: 450px; height: 350px;'><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />" + thePayStatus + "</div>";                 
                else if (document.getElementById("hidTemplateID").value >= 8)
                    document.getElementById("divVideo").innerHTML = "<div style='background: url(../images/Index_Custom/playerImage_400.jpg); font-family: Verdana; font-size: smaller; color: Black; width: 400px; height: 330px;'><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />" + thePayStatus + "</div>";                                    
            }
        }
        
        // Refresh the schedule part (for payment information)
        var selectedPage = 1; 
        GoSchedulerPage(selectedPage);   
        
        return;          
    }     
    //// ******* PAID VIDEO (BEFORE LOGIN) *******///////
    else if (thePayRate != '0.00' && document.getElementById("hidLoginStatus").value == 'Not-Logged-In')   // check for paid video + Not logged in 
    {   
     
    // *********************** CODE STARTS FOR PLAY THE FIRST 10 SECONDS VIDEO ********************************
    
        // CODE STARTS HERE TO CHECK FOR THE YOU TUBE & FLASH VIDEO
        var checkFlash;
        
        if (theRealPath.match("www.youtube"))
            checkFlash = theRealPath.match("www.youtube");
        else if (theRealPath.match(".flv.smil"))
            checkFlash = theRealPath.match(".flv.smil");
               
        if (checkFlash != null)
        {            
           document.getElementById("hidFlashVideoPaid").value = "true"; // set flag to check the paid video
           
           PlayYouTubeSampleVideo(theRealPath);   // play the first 10 sec video from you tube
        }
        
        else if (theStatus == 'archived')
            PlaySampleVideo(theRealPath);    // play the first 10 seconds video
        else if (theStatus == 'live')
        {
           // Hide the Player Div tag
           document.getElementById("divPlayerContainer").style.display = "none";         
           // Hide the payment info Div tag
           document.getElementById("divVideo").style.display = "block";
        } 
        
    // *********************** CODE ENDS FOR PLAY THE FIRST 10 SECONDS VIDEO ********************************
    
    // ******************* CODE STARTS NEEDS TO COMMENT, IF WE ARE NOT GOING TO USE THE 10 SECONDS VIDEO ******************
    
//           // Hide the Player Div tag
//           document.getElementById("divPlayerContainer").style.display = "none";         
//           // Hide the payment info Div tag
//           document.getElementById("divVideo").style.display = "block";
           
    // ******************* CODE ENDS NEEDS TO COMMENT, IF WE ARE GOING TO USE THE 10 SECONDS VIDEO ******************
                     
               
        // CHANGE THE IMAGE SIZE FOR THUMBSIZE PLAYER
        if (document.getElementById("hidTemplateID").value == 0)
        {
            if (theStatus == 'archived')
                document.getElementById("divVideo").innerHTML = "<div style='background: url(../images/Index_Custom/smallPlayerImage.jpg) repeat-x top left #101010; font-family: Verdana; font-size: xx-small; color: Black; width: 234px; height: 192px;'><br /><br /><br /><br /><br /><br /><span style=\"color: White;\">THE <b><i>" + theTitle + "</i></b> IS A PAY VIDEO.<br/><a href=\"javascript://\" onclick=\"OpenLoginWindow()\" style=\"color:White;\">Click Here</a> TO LOGIN & PROCEED</span></div>";               
            if (theStatus == 'live')
                document.getElementById("divVideo").innerHTML = "<div style='background: url(../images/Index_Custom/smallPlayerImage.jpg) repeat-x top left #101010; font-family: Verdana; font-size: xx-small; color: Black; width: 234px; height: 192px;'><br /><br /><br /><br /><br /><br /><span style=\"color: White;\">THE <b><i>" + theTitle + "</i></b> IS A PAY VIDEO.<br/><a href=\"javascript://\" onclick=\"OpenLoginWindow()\" style=\"color:White;\">Click Here</a> TO LOGIN & PROCEED</span></div>";               
        }   
        else
        {
            if (document.getElementById("hidPlayerTypeID").value == 1)  // JW PLAYER OBJECT
            {
                if (theStatus == 'archived')
                {
                    if (document.getElementById("hidTemplateID").value <= 5)
                        document.getElementById("divVideo").innerHTML = "<div style='background: url(../images/Index_Custom/playerImageJW.jpg) repeat-x top left #101010; font-family: Verdana; font-size: smaller; color: Black; width: 620px; height: 400px;'><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><span style=\"color: White;\">THE <b><i>" + theTitle + "</i></b> VIDEO IS A PAY VIDEO.<br/><a href=\"javascript://\" onclick=\"OpenLoginWindow()\" style=\"color:White;\">Click Here</a> TO LOGIN & PROCEED</span></div>";               
                    else if ((parseInt(document.getElementById("hidTemplateID").value) >= 6) && (parseInt(document.getElementById("hidTemplateID").value) <= 7))
                        document.getElementById("divVideo").innerHTML = "<div style='background: url(../images/Index_Custom/playerImageJW_450.jpg); font-family: Verdana; font-size: smaller; color: Black; width: 450px; height: 350px;'><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><span style=\"color: White;\">THE <b><i>" + theTitle + "</i></b> VIDEO IS A PAY VIDEO.<br/><a href=\"javascript://\" onclick=\"OpenLoginWindow()\" style=\"color:White;\">Click Here</a> TO LOGIN & PROCEED</span></div>";               
                    else if (document.getElementById("hidTemplateID").value >= 8)
                        document.getElementById("divVideo").innerHTML = "<div style='background: url(../images/Index_Custom/playerImage_400.jpg); font-family: Verdana; font-size: smaller; color: Black; width: 400px; height: 330px;'><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><span style=\"color: White;\">THE <b><i>" + theTitle + "</i></b> VIDEO IS A PAY VIDEO.<br/><a href=\"javascript://\" onclick=\"OpenLoginWindow()\" style=\"color:White;\">Click Here</a> TO LOGIN & PROCEED</span></div>";               
                }
                if (theStatus == 'live')
                {
                    if (document.getElementById("hidTemplateID").value <= 5)                    
                        document.getElementById("divVideo").innerHTML = "<div style='background: url(../images/Index_Custom/playerImageJW.jpg) repeat-x top left #101010; font-family: Verdana; font-size: smaller; color: Black; width: 620px; height: 400px;'><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><span style=\"color: White;\">THE <b><i>" + theTitle + "</i></b> LIVE VIDEO IS A PAY VIDEO.<br/><a href=\"javascript://\" onclick=\"OpenLoginWindow()\" style=\"color:White;\">Click Here</a> TO LOGIN & PROCEED</span></div>";               
                    else if ((parseInt(document.getElementById("hidTemplateID").value) >= 6) && (parseInt(document.getElementById("hidTemplateID").value) <= 7))
                         document.getElementById("divVideo").innerHTML = "<div style='background: url(../images/Index_Custom/playerImageJW_450.jpg); font-family: Verdana; font-size: smaller; color: Black; width: 450px; height: 350px;'><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><span style=\"color: White;\">THE <b><i>" + theTitle + "</i></b> LIVE VIDEO IS A PAY VIDEO.<br/><a href=\"javascript://\" onclick=\"OpenLoginWindow()\" style=\"color:White;\">Click Here</a> TO LOGIN & PROCEED</span></div>";               
                    else if (document.getElementById("hidTemplateID").value >= 8)
                        document.getElementById("divVideo").innerHTML = "<div style='background: url(../images/Index_Custom/playerImage_400.jpg); font-family: Verdana; font-size: smaller; color: Black; width: 400px; height: 330px;'><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><span style=\"color: White;\">THE <b><i>" + theTitle + "</i></b> VIDEO IS A PAY VIDEO.<br/><a href=\"javascript://\" onclick=\"OpenLoginWindow()\" style=\"color:White;\">Click Here</a> TO LOGIN & PROCEED</span></div>";               
                }
            }
            else if (document.getElementById("hidPlayerTypeID").value == 2)  // OPEN VIDEO PLAYER OBJECT
            {
                if (theStatus == 'archived')
                {
                    if (document.getElementById("hidTemplateID").value <= 5)
                        document.getElementById("divVideo").innerHTML = "<div style='background: url(../images/Index_Custom/playerImage.jpg) repeat-x top left #101010; font-family: Verdana; font-size: smaller; color: Black; width: 620px; height: 400px;'><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><span style=\"color: White;\">THE <b><i>" + theTitle + "</i></b> VIDEO IS A PAY VIDEO.<br/><a href=\"javascript://\" onclick=\"OpenLoginWindow()\" style=\"color:White;\">Click Here</a> TO LOGIN & PROCEED</span></div>";               
                    else if ((parseInt(document.getElementById("hidTemplateID").value) >= 6) && (parseInt(document.getElementById("hidTemplateID").value) <= 7))
                        document.getElementById("divVideo").innerHTML = "<div style='background: url(../images/Index_Custom/playerImage_450.jpg); font-family: Verdana; font-size: smaller; color: Black; width: 450px; height: 350px;'><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><span style=\"color: White;\">THE <b><i>" + theTitle + "</i></b> VIDEO IS A PAY VIDEO.<br/><a href=\"javascript://\" onclick=\"OpenLoginWindow()\" style=\"color:White;\">Click Here</a> TO LOGIN & PROCEED</span></div>";               
                    else if (document.getElementById("hidTemplateID").value >= 8)
                        document.getElementById("divVideo").innerHTML = "<div style='background: url(../images/Index_Custom/playerImage_400.jpg); font-family: Verdana; font-size: smaller; color: Black; width: 400px; height: 330px;'><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><span style=\"color: White;\">THE <b><i>" + theTitle + "</i></b> VIDEO IS A PAY VIDEO.<br/><a href=\"javascript://\" onclick=\"OpenLoginWindow()\" style=\"color:White;\">Click Here</a> TO LOGIN & PROCEED</span></div>";               
                }
                if (theStatus == 'live')
                {
                    if (document.getElementById("hidTemplateID").value <= 5)                    
                        document.getElementById("divVideo").innerHTML = "<div style='background: url(../images/Index_Custom/playerImage.jpg) repeat-x top left #101010; font-family: Verdana; font-size: smaller; color: Black; width: 620px; height: 400px;'><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><span style=\"color: White;\">THE <b><i>" + theTitle + "</i></b> LIVE VIDEO IS A PAY VIDEO.<br/><a href=\"javascript://\" onclick=\"OpenLoginWindow()\" style=\"color:White;\">Click Here</a> TO LOGIN & PROCEED</span></div>";               
                    else if ((parseInt(document.getElementById("hidTemplateID").value) >= 6) && (parseInt(document.getElementById("hidTemplateID").value) <= 7))
                         document.getElementById("divVideo").innerHTML = "<div style='background: url(../images/Index_Custom/playerImage_450.jpg); font-family: Verdana; font-size: smaller; color: Black; width: 450px; height: 350px;'><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><span style=\"color: White;\">THE <b><i>" + theTitle + "</i></b> LIVE VIDEO IS A PAY VIDEO.<br/><a href=\"javascript://\" onclick=\"OpenLoginWindow()\" style=\"color:White;\">Click Here</a> TO LOGIN & PROCEED</span></div>";               
                       else if (document.getElementById("hidTemplateID").value >= 8)
                        document.getElementById("divVideo").innerHTML = "<div style='background: url(../images/Index_Custom/playerImage_400.jpg); font-family: Verdana; font-size: smaller; color: Black; width: 400px; height: 330px;'><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><span style=\"color: White;\">THE <b><i>" + theTitle + "</i></b> VIDEO IS A PAY VIDEO.<br/><a href=\"javascript://\" onclick=\"OpenLoginWindow()\" style=\"color:White;\">Click Here</a> TO LOGIN & PROCEED</span></div>";               
                }
            }
            else if (document.getElementById("hidPlayerTypeID").value == 3)  // WINDOWS MEDIA PLAYER OBJECT
            {
               if (theStatus == 'archived')
                {
                    if (document.getElementById("hidTemplateID").value <= 5)
                        document.getElementById("divVideo").innerHTML = "<div style='background: url(../images/Index_Custom/playerImageWM.jpg) repeat-x top left #101010; font-family: Verdana; font-size: smaller; color: Black; width: 620px; height: 400px;'><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><span style=\"color: White;\">THE <b><i>" + theTitle + "</i></b> VIDEO IS A PAY VIDEO.<br/><a href=\"javascript://\" onclick=\"OpenLoginWindow()\" style=\"color:White;\">Click Here</a> TO LOGIN & PROCEED</span></div>";               
                    else if ((parseInt(document.getElementById("hidTemplateID").value) >= 6) && (parseInt(document.getElementById("hidTemplateID").value) <= 7))
                        document.getElementById("divVideo").innerHTML = "<div style='background: url(../images/Index_Custom/playerImageWM_450.jpg); font-family: Verdana; font-size: smaller; color: Black; width: 450px; height: 350px;'><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><span style=\"color: White;\">THE <b><i>" + theTitle + "</i></b> VIDEO IS A PAY VIDEO.<br/><a href=\"javascript://\" onclick=\"OpenLoginWindow()\" style=\"color:White;\">Click Here</a> TO LOGIN & PROCEED</span></div>";               
                    else if (document.getElementById("hidTemplateID").value >= 8)
                        document.getElementById("divVideo").innerHTML = "<div style='background: url(../images/Index_Custom/playerImage_400.jpg); font-family: Verdana; font-size: smaller; color: Black; width: 400px; height: 330px;'><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><span style=\"color: White;\">THE <b><i>" + theTitle + "</i></b> VIDEO IS A PAY VIDEO.<br/><a href=\"javascript://\" onclick=\"OpenLoginWindow()\" style=\"color:White;\">Click Here</a> TO LOGIN & PROCEED</span></div>";               
                }
                if (theStatus == 'live')
                {
                    if (document.getElementById("hidTemplateID").value <= 5)                    
                        document.getElementById("divVideo").innerHTML = "<div style='background: url(../images/Index_Custom/playerImageWM.jpg) repeat-x top left #101010; font-family: Verdana; font-size: smaller; color: Black; width: 620px; height: 400px;'><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><span style=\"color: White;\">THE <b><i>" + theTitle + "</i></b> LIVE VIDEO IS A PAY VIDEO.<br/><a href=\"javascript://\" onclick=\"OpenLoginWindow()\" style=\"color:White;\">Click Here</a> TO LOGIN & PROCEED</span></div>";               
                    else if ((parseInt(document.getElementById("hidTemplateID").value) >= 6) && (parseInt(document.getElementById("hidTemplateID").value) <= 7))
                         document.getElementById("divVideo").innerHTML = "<div style='background: url(../images/Index_Custom/playerImageWM_450.jpg); font-family: Verdana; font-size: smaller; color: Black; width: 450px; height: 350px;'><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><span style=\"color: White;\">THE <b><i>" + theTitle + "</i></b> LIVE VIDEO IS A PAY VIDEO.<br/><a href=\"javascript://\" onclick=\"OpenLoginWindow()\" style=\"color:White;\">Click Here</a> TO LOGIN & PROCEED</span></div>";               
                    else if (document.getElementById("hidTemplateID").value >= 8)
                        document.getElementById("divVideo").innerHTML = "<div style='background: url(../images/Index_Custom/playerImage_400.jpg); font-family: Verdana; font-size: smaller; color: Black; width: 400px; height: 330px;'><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><span style=\"color: White;\">THE <b><i>" + theTitle + "</i></b> VIDEO IS A PAY VIDEO.<br/><a href=\"javascript://\" onclick=\"OpenLoginWindow()\" style=\"color:White;\">Click Here</a> TO LOGIN & PROCEED</span></div>";               
                }
            }
            else if (document.getElementById("hidPlayerTypeID").value == 4)  // monetize MEDIA PLAYER OBJECT
            {
                if (theStatus == 'archived')
                {
                    if (document.getElementById("hidTemplateID").value <= 5)
                        document.getElementById("divVideo").innerHTML = "<div style='background: url(../images/Index_Custom/playerImageMM.jpg) repeat-x top left #101010; font-family: Verdana; font-size: smaller; color: Black; width: 620px; height: 400px;'><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><span style=\"color: White;\">THE <b><i>" + theTitle + "</i></b> VIDEO IS A PAY VIDEO.<br/><a href=\"javascript://\" onclick=\"OpenLoginWindow()\" style=\"color:White;\">Click Here</a> TO LOGIN & PROCEED</span></div>";               
                    else if ((parseInt(document.getElementById("hidTemplateID").value) >= 6) && (parseInt(document.getElementById("hidTemplateID").value) <= 7))
                        document.getElementById("divVideo").innerHTML = "<div style='background: url(../images/Index_Custom/playerImageMM_450.jpg); font-family: Verdana; font-size: smaller; color: Black; width: 450px; height: 350px;'><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><span style=\"color: White;\">THE <b><i>" + theTitle + "</i></b> VIDEO IS A PAY VIDEO.<br/><a href=\"javascript://\" onclick=\"OpenLoginWindow()\" style=\"color:White;\">Click Here</a> TO LOGIN & PROCEED</span></div>";               
                    else if (document.getElementById("hidTemplateID").value >= 8)
                        document.getElementById("divVideo").innerHTML = "<div style='background: url(../images/Index_Custom/playerImage_400.jpg); font-family: Verdana; font-size: smaller; color: Black; width: 400px; height: 330px;'><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><span style=\"color: White;\">THE <b><i>" + theTitle + "</i></b> VIDEO IS A PAY VIDEO.<br/><a href=\"javascript://\" onclick=\"OpenLoginWindow()\" style=\"color:White;\">Click Here</a> TO LOGIN & PROCEED</span></div>";               
                }
                if (theStatus == 'live')
                {
                    if (document.getElementById("hidTemplateID").value <= 5)                    
                        document.getElementById("divVideo").innerHTML = "<div style='background: url(../images/Index_Custom/playerImageMM.jpg) repeat-x top left #101010; font-family: Verdana; font-size: smaller; color: Black; width: 620px; height: 400px;'><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><span style=\"color: White;\">THE <b><i>" + theTitle + "</i></b> LIVE VIDEO IS A PAY VIDEO.<br/><a href=\"javascript://\" onclick=\"OpenLoginWindow()\" style=\"color:White;\">Click Here</a> TO LOGIN & PROCEED</span></div>";               
                    else if ((parseInt(document.getElementById("hidTemplateID").value) >= 6) && (parseInt(document.getElementById("hidTemplateID").value) <= 7))
                         document.getElementById("divVideo").innerHTML = "<div style='background: url(../images/Index_Custom/playerImageMM_450.jpg); font-family: Verdana; font-size: smaller; color: Black; width: 450px; height: 350px;'><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><span style=\"color: White;\">THE <b><i>" + theTitle + "</i></b> LIVE VIDEO IS A PAY VIDEO.<br/><a href=\"javascript://\" onclick=\"OpenLoginWindow()\" style=\"color:White;\">Click Here</a> TO LOGIN & PROCEED</span></div>";               
                    else if (document.getElementById("hidTemplateID").value >= 8)
                        document.getElementById("divVideo").innerHTML = "<div style='background: url(../images/Index_Custom/playerImage_400.jpg); font-family: Verdana; font-size: smaller; color: Black; width: 400px; height: 330px;'><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><span style=\"color: White;\">THE <b><i>" + theTitle + "</i></b> VIDEO IS A PAY VIDEO.<br/><a href=\"javascript://\" onclick=\"OpenLoginWindow()\" style=\"color:White;\">Click Here</a> TO LOGIN & PROCEED</span></div>";               
                }
            }
        }            
        return;
    }    
    //// ******* PAID VIDEO (AFTER LOGIN) *******///////
    else if (thePayRate != '0.00' && document.getElementById("hidLoginStatus").value == 'Logged-In')  // check for paid video + logged in Success
    {       
       
    // *********************** CODE STARTS FOR PLAY THE FIRST 10 SECONDS VIDEO ********************************
    
        // CODE STARTS HERE TO CHECK FOR THE YOU TUBE OR FLASH VIDEO
        var checkFlash;
        
        if (theRealPath.match("www.youtube"))
            checkFlash = theRealPath.match("www.youtube");
        else if (theRealPath.match(".flv.smil"))
            checkFlash = theRealPath.match(".flv.smil");
               
        if (checkFlash != null)
        { 
           document.getElementById("hidFlashVideoPaid").value = "true"; // set flag to check the paid video
           PlayYouTubeSampleVideo(theRealPath);   // play the first 10 sec video from you tube
        }
        else if (theStatus == 'archived')
            PlaySampleVideo(theRealPath);    // play the first 10 seconds video
        else if (theStatus == 'live')
        {
           // Hide the Player Div tag
           document.getElementById("divPlayerContainer").style.display = "none";         
           // Hide the payment info Div tag
           document.getElementById("divVideo").style.display = "block";
        } 
        
    // *********************** CODE ENDS FOR PLAY THE FIRST 10 SECONDS VIDEO ********************************
    
    // ******************* CODE STARTS NEEDS TO COMMENT, IF WE ARE GOING TO USE THE 10 SECONDS VIDEO ******************
    
//           // Hide the Player Div tag
//           document.getElementById("divPlayerContainer").style.display = "none";         
//           // Hide the payment info Div tag
//           document.getElementById("divVideo").style.display = "block";
           
    // ******************* CODE ENDS NEEDS TO COMMENT, IF WE ARE GOING TO USE THE 10 SECONDS VIDEO ******************
       
                
        // CHANGE THE IMAGE SIZE FOR THUMBSIZE PLAYER
        if (document.getElementById("hidTemplateID").value == 0)
            document.getElementById("divVideo").innerHTML = "<div style='background: url(../images/Index_Custom/smallPlayerImage.jpg) repeat-x top left #101010; font-family: Verdana; font-size: x-small; color: Black; width: 234px; height: 192px;'><br /><br /><br /><br /><br />" + thePayStatus  + "</div>"; 
        else
        {
            if (document.getElementById("hidPlayerTypeID").value == 1)  // JW PLAYER OBJECT
            {
                if (document.getElementById("hidTemplateID").value <= 5)
                    document.getElementById("divVideo").innerHTML = "<div style='background: url(../images/Index_Custom/playerImageJW.jpg) repeat-x top left #101010; font-family: Verdana; font-size: smaller; color: Black; width: 620px; height: 400px;'><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />" + thePayStatus  + "</div>";                 
                else if ((parseInt(document.getElementById("hidTemplateID").value) >= 6) && (parseInt(document.getElementById("hidTemplateID").value) <= 7))
                    document.getElementById("divVideo").innerHTML = "<div style='background: url(../images/Index_Custom/playerImageJW_450.jpg); font-family: Verdana; font-size: smaller; color: Black; width: 450px; height: 350px;'><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />" + thePayStatus  + "</div>";                 
                else if (document.getElementById("hidTemplateID").value >= 8)
                    document.getElementById("divVideo").innerHTML = "<div style='background: url(../images/Index_Custom/playerImage_400.jpg); font-family: Verdana; font-size: smaller; color: Black; width: 400px; height: 330px;'><br /><br /><br /><br /><br /><br /><br /><br />" + thePayStatus  + "</div>";                 
            }
            else if (document.getElementById("hidPlayerTypeID").value == 2)  // OPEN VIDEO PLAYER OBJECT
            {
                if (document.getElementById("hidTemplateID").value <= 5)
                    document.getElementById("divVideo").innerHTML = "<div style='background: url(../images/Index_Custom/playerImage.jpg) repeat-x top left #101010; font-family: Verdana; font-size: smaller; color: Black; width: 620px; height: 400px;'><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />" + thePayStatus  + "</div>";                 
                else if ((parseInt(document.getElementById("hidTemplateID").value) >= 6) && (parseInt(document.getElementById("hidTemplateID").value) <= 7))
                    document.getElementById("divVideo").innerHTML = "<div style='background: url(../images/Index_Custom/playerImage_450.jpg); font-family: Verdana; font-size: smaller; color: Black; width: 450px; height: 350px;'><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />" + thePayStatus  + "</div>";                 
                else if (document.getElementById("hidTemplateID").value >= 8)
                    document.getElementById("divVideo").innerHTML = "<div style='background: url(../images/Index_Custom/playerImage_400.jpg); font-family: Verdana; font-size: smaller; color: Black; width: 400px; height: 330px;'><br /><br /><br /><br /><br /><br /><br /><br />" + thePayStatus  + "</div>";                 
            }
            else if (document.getElementById("hidPlayerTypeID").value == 3)  // WINDOWS MEDIA PLAYER OBJECT
            {
                if (document.getElementById("hidTemplateID").value <= 5)
                    document.getElementById("divVideo").innerHTML = "<div style='background: url(../images/Index_Custom/playerImageWM.jpg) repeat-x top left #101010; font-family: Verdana; font-size: smaller; color: Black; width: 620px; height: 400px;'><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />" + thePayStatus  + "</div>";                 
                else if ((parseInt(document.getElementById("hidTemplateID").value) >= 6) && (parseInt(document.getElementById("hidTemplateID").value) <= 7))
                    document.getElementById("divVideo").innerHTML = "<div style='background: url(../images/Index_Custom/playerImageWM_450.jpg); font-family: Verdana; font-size: smaller; color: Black; width: 450px; height: 350px;'><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />" + thePayStatus  + "</div>";                 
                else if (document.getElementById("hidTemplateID").value >= 8)
                    document.getElementById("divVideo").innerHTML = "<div style='background: url(../images/Index_Custom/playerImage_400.jpg); font-family: Verdana; font-size: smaller; color: Black; width: 400px; height: 330px;'><br /><br /><br /><br /><br /><br /><br /><br />" + thePayStatus  + "</div>";                 
            }
            else if (document.getElementById("hidPlayerTypeID").value == 4)  // MONETIZE MEDIA PLAYER OBJECT
            {
                 if (document.getElementById("hidTemplateID").value <= 5)
                    document.getElementById("divVideo").innerHTML = "<div style='background: url(../images/Index_Custom/playerImageMM.jpg) repeat-x top left #101010; font-family: Verdana; font-size: smaller; color: Black; width: 620px; height: 400px;'><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />" + thePayStatus  + "</div>";                 
                else if ((parseInt(document.getElementById("hidTemplateID").value) >= 6) && (parseInt(document.getElementById("hidTemplateID").value) <= 7))
                    document.getElementById("divVideo").innerHTML = "<div style='background: url(../images/Index_Custom/playerImageMM_450.jpg); font-family: Verdana; font-size: smaller; color: Black; width: 450px; height: 350px;'><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />" + thePayStatus  + "</div>";                 
                else if (document.getElementById("hidTemplateID").value >= 8)
                    document.getElementById("divVideo").innerHTML = "<div style='background: url(../images/Index_Custom/playerImage_400.jpg); font-family: Verdana; font-size: smaller; color: Black; width: 400px; height: 330px;'><br /><br /><br /><br /><br /><br /><br /><br />" + thePayStatus  + "</div>";                 
            }
        }       
        
        // Refresh the schedule part (for payment information)
        var selectedPage = 1; 
        GoSchedulerPage(selectedPage);   
         
        return;      
    }    
}


// ****************CODE STARTS HERE TO PLAY THE FIRST 10 SECONDS VIDEO ON THE JW PLAYER **************


// PLAY VIDEO IN JW PLAYER (FOR FIRST 10 SECONDS)
function PlaySampleVideo(thePath) 
{   
   // Hide the Player Div tag
   document.getElementById("divPlayerContainer").style.display = "block";         
   // Hide the payment info Div tag
   document.getElementById("divVideo").style.display = "none";
   
   var heightValue = 400;
   var widthValue = 620;
   
   if (document.getElementById("hidTemplateID").value == 0)
   {        
       heightValue = 192;
       widthValue = 234;
   }
   
   if ((parseInt(document.getElementById("hidTemplateID").value) >= 6) && (parseInt(document.getElementById("hidTemplateID").value) <= 7))
   {
       heightValue = 350;
       widthValue = 450;   
   }
   
   if (document.getElementById("hidTemplateID").value >= 8)
   {        
       heightValue = 330;
       widthValue = 400;
   }
   
    //alert(thePath);
    var sCnt = document.getElementById("divPlayerContainer");
    var sSrc = '../wmvplayer.xaml';
    var sCfg = {
	    file: thePath,
	    autostart: 'true',
	    repeat: 'false',
	    height: heightValue,
	    width: widthValue,
	    backcolor:'000000',
	    frontcolor:'cccccc',
	    lightcolor:'660000',
	    shownavigation: 'false'
    };
	
    plyVideo = new jeroenwijering.Player(sCnt,sSrc,sCfg);
    
    addVideoListeners(); // play the sample video 
    
}
       
function addVideoListeners() 
{
	if(plyVideo.view) 
		plyVideo.addListener('TIME', setVideoDuration);
	else 
		setTimeout("addVideoListeners()",100);
}

function setVideoDuration(pos,dur) 
{ 
	currentPosition = pos;
	
//	if (parseInt(dur) < 50)
//	    currentPosition = parseInt(dur) / 2;
//	else
//	    currentPosition = pos;
	    
//	var tmp = document.getElementById("time"); 
//	if (tmp) 
//	{ tmp.innerHTML = "<b>Position:</b> "+pos+", <b>duration:</b> "+dur;  }

    // CONDITION FOR 10 SEC STOP
    if (parseInt(pos) > 10)
    {
       plyVideo.sendEvent('stop');
	   
       // Hide the Player Div tag
       document.getElementById("divPlayerContainer").style.display = "none";         
       // Hide the payment info Div tag
       document.getElementById("divVideo").style.display = "block";
       
       // Open Login Page
       if (document.getElementById("hidLoginStatus").value == "Not-Logged-In" && parseInt(globalPayRate) > 0)
       {   
            OpenLoginWindow();
       }
       
       // Open Payment Page
       if ((document.getElementById("hidLoginStatus").value == "Logged-In") && (document.getElementById("VideoDesc_hidPaymentStatus").value == "notpaid") && parseInt(globalPayRate) > 0)
       {   
            OpenPaymentWindow(globalPayRate);
       }
    }
    
}

// ****************CODE ENDS HERE TO PLAY THE FIRST 10 SECONDS VIDEO ON THE JW PLAYER **************


// ****************CODE STARTS HERE TO PLAY THE 10 SEC VIDEO ON YOU TUBE JW PLAYER *******************

// PLAY VIDEO IN YOU TUBE & FLASH JW PLAYER (FOR FIRST 10 SECONDS)
function PlayYouTubeSampleVideo(thePath) 
{   
   // Hide the Player Div tag
   document.getElementById("divPlayerContainer").style.display = "block";         
   // Hide the payment info Div tag
   document.getElementById("divVideo").style.display = "none";
   
   var heightValueYT = 400;
   var widthValueYT = 620;
   
   if (document.getElementById("hidTemplateID").value == 0)
   {        
       heightValueYT = 192;
       widthValueYT = 234;
   }
   if ((parseInt(document.getElementById("hidTemplateID").value) >= 6) && (parseInt(document.getElementById("hidTemplateID").value) <= 7))
   {
       heightValueYT = 350;
       widthValueYT = 450;   
   }
   
   if (document.getElementById("hidTemplateID").value >= 8)
   {        
       heightValueYT = 330;
       widthValueYT = 400;
   }
   
   // Load player to play sample video
    var so = new SWFObject('../JWFlashPlayer/player.swf','ply',widthValueYT,heightValueYT,'9');
    so.addParam('allowscriptaccess','always');
    so.addParam('allowfullscreen','true');
    so.addParam('controlbar','none'); 
    
    if (thePath.match("www.youtube"))            
        so.addParam('flashvars','&file=' + thePath + '&autostart=true'); 
    else if (thePath.match(".flv.smil"))
        so.addParam('flashvars','&file=' + thePath + '&autostart=true&type=highwinds'); 
    
    so.write('divPlayerContainer');  
                
    window.scrollTo(0,document.getElementById('divPlayerContainer').scrollTop);
    return;
}

function playerReady(thePlayer) {
	playerYT = window.document[thePlayer.id];
	if (document.getElementById("hidFlashVideoPaid").value == "true")
	    addListenersYT();
}

function addListenersYT() 
{   
	if (playerYT) { 
		playerYT.addModelListener("TIME", "positionListenerYT");
		//playerYT.addViewListener("VOLUME", "volumeListenerYT");
	} else {
		setTimeout("addListenersYT()",100);
	}
}


function positionListenerYT(obj) { 
	currentPositionYT = obj.position; 
	
	// CONDITION FOR 10 SEC STOP
	if (parseInt(currentPositionYT) > 10)
    { 
       playerYT.sendEvent('stop');
       
       // Hide the Player Div tag
       document.getElementById("divPlayerContainer").style.display = "none";         
       // Hide the payment info Div tag
       document.getElementById("divVideo").style.display = "block";
       
       // Open Login Page
       if (document.getElementById("hidLoginStatus").value == "Not-Logged-In" && parseInt(globalPayRate) > 0)
       {   
            OpenLoginWindow();
       }
       
       // Open Payment Page
       if ((document.getElementById("hidLoginStatus").value == "Logged-In") && (document.getElementById("VideoDesc_hidPaymentStatus").value == "notpaid") && parseInt(globalPayRate) > 0)
       {   
            OpenPaymentWindow(globalPayRate);
       }
       
    }
    
	//var tmp = document.getElementById("posId");
	//if (tmp) { tmp.innerHTML = "position: " + currentPosition; }
}


function volumeListenerYT(obj) { 
	currentVolumeYT = obj.percentage; 
	var tmp = document.getElementById("volId");
	if (tmp) { tmp.innerHTML = "volume: " + currentVolume; }
}


// ****************CODE ENDS HERE TO PLAY THE 10 SEC VIDEO ON YOU TUBE JW PLAYER *******************


function LoadPlayer(filePath,preRollPath,realPath)
{  
    // Show the Player Div tag
    document.getElementById("divPlayerContainer").style.display = "block";
    
    // HIDE THE btnVideo BUTTON
    document.getElementById("VideoDesc_btnVideo").style.display = "none";   
    // HIDE THE btnRating BUTTON
    document.getElementById("VideoDesc_btnRating").style.display = "none";    
     
    // FOR THUMBSIZE PLAYER
    if (document.getElementById("hidTemplateID").value == 0)
    {          
        // CODE STARTS HERE TO CHECK FOR THE YOU TUBE / FLASH VIDEO
        var checkFlash;
        
        if (realPath.match("www.youtube"))
            checkFlash = realPath.match("www.youtube");
        else if (realPath.match(".flv.smil"))
            checkFlash = realPath.match(".flv.smil");
        else if (realPath.match(".smil"))
            checkFlash = realPath.match(".smil"); /// for live stream url
        else if (document.getElementById("hidContentTypeID").value == 2)
            checkFlash = realPath; /// for flash alternative source url

               
        if (checkFlash != null)
        { 
          var so = new SWFObject('../JWFlashPlayer/player.swf','ply','234','192','9');
          so.addParam('allowscriptaccess','always');
          so.addParam('allowfullscreen','true'); 
          
          if (realPath.match("www.youtube")) 
          {           
            so.addParam('id','ytPlayer');
            so.addParam('flashvars','&file=' + realPath + '&autostart=true&skin=../JWFlashPlayer/Skins/' + document.getElementById("hidPlayerSkin").value + '.swf&plugins=sharing-1&sharing.link=' + window.location.href + '&dock=true');  
          }
          else if (realPath.match(".flv.smil")) // for flash ondemand video
            /////// **** CODE STARTS FOR EMBED CODE (JUST ADD BELOW CODE IN THE 'flashvars' PARAM) **********
            // &sharing.code=<body><div id=%22mediaspace%22></div><script type=%22text/javascript%22 src=%22http://localhost:52659/MMediaPlatform/js/embed.js%22 language=%22javascript%22></script><script type=%22text/javascript%22>var param = new Array();/**DO NOT EDIT THESE CONFIG ITEMS**/ param[%22uniquekey%22] = %22vd-' + document.getElementById("hidAccountName").value + '-' + document.getElementById("VideoDesc_hidClickedVideoID").value + '-' + document.getElementById("hidPlayerSkin").value + '%22;/**EDIT THESE CONFIGURATION**/ param[%22playerwidth%22] = %22620%22;   /**the width the player(Need to be in pixels)**/ param[%22playerheight%22] = %22400%22;  /**the height the player    (Need to be in pixels)**/ document.getElementById(%22mediaspace%22).innerHTML = getEmbed(param);</script></body>');  
            /////// **** CODE ENDS FOR EMBED CODE **********
            so.addParam('flashvars','&file=' + realPath + '&autostart=true&type=highwinds&skin=../JWFlashPlayer/Skins/' + document.getElementById("hidPlayerSkin").value + '.swf&plugins=sharing-1&sharing.link=' + window.location.href + '&dock=true');  
          else if (realPath.match(".smil")) /// for live stream url
            so.addParam('flashvars','&file=' + realPath + '&autostart=true&type=highwinds&skin=../JWFlashPlayer/Skins/' + document.getElementById("hidPlayerSkin").value + '.swf&plugins=sharing-1&sharing.link=' + window.location.href + '&dock=true');  
          else if (document.getElementById("hidContentTypeID").value == 2) /// for flash alternative source
            so.addParam('flashvars','&file=' + realPath + '&autostart=true&skin=../JWFlashPlayer/Skins/' + document.getElementById("hidPlayerSkin").value + '.swf&plugins=sharing-1&sharing.link=' + window.location.href + '&dock=true');  
                                      
          so.write('divPlayerContainer');   
                   
          window.scrollTo(0,document.getElementById('divPlayerContainer').scrollTop);
          return;
        }
        // CODE ENDS HERE TO CHECK FOR THE YOU TUBE VIDEO
              
        // Create a player object
        if (document.getElementById("hidPlayerTypeID").value == 1)  // JW PLAYER OBJECT
        {    
            sfileName = 'empty-1';    
            sfileName = realPath; // Assign the file 
            
            // PLAY THE PRE ROLL VIDEO
            if (preRollPath == "")
                SetVideo(sfileName, 'true', 1, 192, 234);    // Loads the Player    
            else
                SetVideo(preRollPath, 'false', 0, 192, 234);    // Loads the JW Player    
        }
        else if (document.getElementById("hidPlayerTypeID").value == 2) // OPEN VIDEO PLAYER OBJECT
        {    
            var playerObj = "<object data='data:application/x-silverlight-2,' type='application/x-silverlight-2' width='234px' height='192px' id='slp' style='z-index:-1' >"
                + "<param name='source' value='../OVP.xap'/>"
                + "<param name='minRuntimeVersion' value='2.0.30923.0' />"
                + "<param name='onerror' value='onSilverlightError' />"
                + "<param name='MaxFrameRate' value='30' />"
                + "<param name='Windowless' value='True' />"
                + "<param name='initparams' value='theme=../OVPThemes/" + document.getElementById("hidPlayerSkin").value + ".xaml,"
                + "showstatistics=false, autoplay=true, muted=false, playlistoverlay=false, stretchmode=Fit, stretchmodefullscreen=Fit,"
                + "playlist=" + filePath + "' />"
                + "<a href='http://go.microsoft.com/fwlink/?LinkID=124807' style='text-decoration: none;'>"
                + "<img src='http://go.microsoft.com/fwlink/?LinkId=108181' alt='Get Microsoft Silverlight' style='border-style: none'/></a>"
                + "</object>";
                
            // Place the object in div tag
            document.getElementById("divPlayerContainer").innerHTML = playerObj; 
        }
        else if (document.getElementById("hidPlayerTypeID").value == 3) // WINDOWS MEDIA PLAYER OBJECT
        {            
            var playerObj = '<OBJECT ID="WMPlayer"  CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" WIDTH="234" HEIGHT="192" showstatusbar="True">'
                +'<PARAM NAME="AutoStart" VALUE="True" >'
                +'<PARAM NAME="stretchToFit" VALUE="True">'
                +' <PARAM NAME="URL" VALUE="'+ realPath +'">'
                +'<PARAM NAME="enableContextMenu" VALUE="False">'                   
                 +'<EMBED TYPE="application/x-mplayer2" '
                +'SRC="'+ realPath +'" '
                +'NAME="WMPlayer"'
                +'WIDTH="234"'
                +'HEIGHT="192"'
                +'EnableContextMenu="False"'
                +'AUTOSTART="True" showstatusbar="True" stretchToFit="True" ' 
                +'SHOWCONTROLS="False">'
                +'</EMBED>'
                +'</OBJECT>'; 
                
            
            // Place the object in div tag
            document.getElementById("divPlayerContainer").innerHTML = playerObj; 
        }         
        else if (document.getElementById("hidPlayerTypeID").value == 4) // MM PLAYER OBJECT
        {      
             // CODE STARTS TO DISPLAY THE CHAPTERS     
//            if (realPath == 'http://vbricksys.edgeboss.net/wmedia/vbricksys/vbrick/vboss_temp_phase2/wbirchett_4049/snowtrainhigh.wvx')
//            {
//                //filePath = overallPath;
//                filePatches = {"mediaUrl": realPath,
//                           "placeholderImage": "http://www.vbossengage.com/EngageData//1612_Thumb_Edmonton_skyline.jpg",
//                           "chapters": [
//                           {"time": 12.1597653, "imageUrl": "http://www.vbossengage.com/EngageData//1204_Thumb_Burton4.jpg"},
//                           {"time": 36.1597653, "imageUrl": "http://www.vbossengage.com/EngageData//1204_Thumb_Hailer3.jpg"},
//                           {"time": 40.1597653, "imageUrl": "http://www.vbossengage.com/EngageData//1204_Thumb_Koontz.jpg"}                         
//                           ]};
//            }
            // CODE ENDS TO DISPLAY THE CHAPTERS     
            
             filePatches = {"mediaUrl": realPath,
                           "placeholderImage": "",
                           "chapters": []};

            var playerObj =  new StartPlayer_0();
            // Scroll to Top
            window.scrollTo(0,document.getElementById('divPlayerContainer').scrollTop);
            return playerObj;
        
//            // Place the object in div tag
     //       document.getElementById("divPlayerContainer").innerHTML = playerObj; 
        }      
    }
    else if ((parseInt(document.getElementById("hidTemplateID").value) > 0) && (parseInt(document.getElementById("hidTemplateID").value) <= 5))
    {     
        
       
        // CODE STARTS HERE TO CHECK FOR THE YOU TUBE (or) FLASH VIDEO
        var checkFlash;
        
        if (realPath.match("www.youtube"))
            checkFlash = realPath.match("www.youtube");
        else if (realPath.match(".flv.smil"))
            checkFlash = realPath.match(".flv.smil");
        else if (realPath.match(".smil"))
            checkFlash = realPath.match(".smil"); /// for live stream url
        else if (document.getElementById("hidContentTypeID").value == 2)
            checkFlash = realPath; /// for flash alternative source url
              
               
        if (checkFlash != null)
        { 
          var so = new SWFObject('../JWFlashPlayer/player.swf','ply','620','400','9');
          so.addParam('allowscriptaccess','always');
          so.addParam('allowfullscreen','true');
                  
          if (realPath.match("www.youtube")) 
          {           
            so.addParam('id','ytPlayer');
            so.addParam('flashvars','&file=' + realPath + '&autostart=true&skin=../JWFlashPlayer/Skins/' + document.getElementById("hidPlayerSkin").value + '.swf&plugins=sharing-1&sharing.link=' + window.location.href + '&dock=true');  
          }
          else if (realPath.match(".flv.smil")) // for flash ondemand video
            /////// **** CODE STARTS FOR EMBED CODE (JUST ADD BELOW CODE IN THE 'flashvars' PARAM) **********
            // &sharing.code=<body><div id=%22mediaspace%22></div><script type=%22text/javascript%22 src=%22http://localhost:52659/MMediaPlatform/js/embed.js%22 language=%22javascript%22></script><script type=%22text/javascript%22>var param = new Array();/**DO NOT EDIT THESE CONFIG ITEMS**/ param[%22uniquekey%22] = %22vd-' + document.getElementById("hidAccountName").value + '-' + document.getElementById("VideoDesc_hidClickedVideoID").value + '-' + document.getElementById("hidPlayerSkin").value + '%22;/**EDIT THESE CONFIGURATION**/ param[%22playerwidth%22] = %22620%22;   /**the width the player(Need to be in pixels)**/ param[%22playerheight%22] = %22400%22;  /**the height the player    (Need to be in pixels)**/ document.getElementById(%22mediaspace%22).innerHTML = getEmbed(param);</script></body>');  
            /////// **** CODE ENDS FOR EMBED CODE **********
            so.addParam('flashvars','&file=' + realPath + '&autostart=true&type=highwinds&skin=../JWFlashPlayer/Skins/' + document.getElementById("hidPlayerSkin").value + '.swf&plugins=sharing-1&sharing.link=' + window.location.href + '&dock=true');  
          else if (realPath.match(".smil")) /// for live stream url
            so.addParam('flashvars','&file=' + realPath + '&autostart=true&type=highwinds&skin=../JWFlashPlayer/Skins/' + document.getElementById("hidPlayerSkin").value + '.swf&plugins=sharing-1&sharing.link=' + window.location.href + '&dock=true');  
          else if (document.getElementById("hidContentTypeID").value == 2) /// for flash alternative source
            so.addParam('flashvars','&file=' + realPath + '&autostart=true&skin=../JWFlashPlayer/Skins/' + document.getElementById("hidPlayerSkin").value + '.swf&plugins=sharing-1&sharing.link=' + window.location.href + '&dock=true');  
            
                                                
          so.write('divPlayerContainer');  
                   
          window.scrollTo(0,document.getElementById('divPlayerContainer').scrollTop);
          return;
        }
        // CODE ENDS HERE TO CHECK FOR THE YOU TUBE VIDEO
        
        // Create a player object
        if (document.getElementById("hidPlayerTypeID").value == 1)  // JW PLAYER OBJECT
        {  
            sfileName = 'empty-1';    
            sfileName = realPath; // Assign the file 
            
            // PLAY THE PRE ROLL VIDEO
            if (preRollPath == "")
                SetVideo(sfileName, 'true', 1, 400, 620);    // Loads the Player    
            else
                SetVideo(preRollPath, 'false', 0, 400, 620);    // Loads the JW Player   
        }
        else if (document.getElementById("hidPlayerTypeID").value == 2) // OPEN VIDEO PLAYER OBJECT
        {    
            var playerObj = "<object data='data:application/x-silverlight-2,' type='application/x-silverlight-2' width='620px' height='400px' id='slp' style='z-index:-1' >"
                + "<param name='source' value='../OVP.xap'/>"
                + "<param name='minRuntimeVersion' value='2.0.30923.0' />"
                + "<param name='onerror' value='onSilverlightError' />"
                + "<param name='MaxFrameRate' value='30' />"
                + "<param name='Windowless' value='True' />"
                + "<param name='background' value='black' />"

                + "<param name='initparams' value='theme=../OVPThemes/" + document.getElementById("hidPlayerSkin").value + ".xaml,"
                + "showstatistics=false, autoplay=true, muted=false, playlistoverlay=false, stretchmode=Fit, stretchmodefullscreen=Fit,"
                + "playlist=" + filePath + "' />"
                + "<a href='http://go.microsoft.com/fwlink/?LinkID=124807' style='text-decoration: none;'>"
                + "<img src='http://go.microsoft.com/fwlink/?LinkId=108181' alt='Get Microsoft Silverlight' style='border-style: none'/></a>"
                + "</object>";
                //alert(playerObj);
            // Place the object in div tag
            document.getElementById("divPlayerContainer").innerHTML = playerObj; 
        }
        else if (document.getElementById("hidPlayerTypeID").value == 3) // WINDOWS MEDIA PLAYER OBJECT
        {            
            var playerObj = '<OBJECT ID="WMPlayer"  CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" WIDTH="620" HEIGHT="400" showstatusbar="True">'
                +'<PARAM NAME="AutoStart" VALUE="True" >'
                +'<PARAM NAME="stretchToFit" VALUE="True">'
                +' <PARAM NAME="URL" VALUE="'+ realPath +'">'
                +'<PARAM NAME="enableContextMenu" VALUE="False">'                   
                 +'<EMBED TYPE="application/x-mplayer2" '
                +'SRC="'+ realPath +'" '
                +'NAME="WMPlayer"'
                +'WIDTH="620"'
                +'HEIGHT="400"'
                +'EnableContextMenu="False"'
                +'AUTOSTART="True" showstatusbar="True"' 
                +'SHOWCONTROLS="True">'
                +'</EMBED>'
                +'</OBJECT>'; 
                
            // Place the object in div tag
            document.getElementById("divPlayerContainer").innerHTML = playerObj; 
        }
        else if (document.getElementById("hidPlayerTypeID").value == 4) // MM PLAYER OBJECT
        {      
             // CODE STARTS TO DISPLAY THE CHAPTERS     
//            if (realPath == 'http://vbricksys.edgeboss.net/wmedia/vbricksys/vbrick/vboss_temp_phase2/wbirchett_4049/snowtrainhigh.wvx')
//            {
//                //filePath = overallPath;
//                filePatches = {"mediaUrl": realPath,
//                           "placeholderImage": "http://www.vbossengage.com/EngageData//1612_Thumb_Edmonton_skyline.jpg",
//                           "chapters": [
//                           {"time": 12.1597653, "imageUrl": "http://www.vbossengage.com/EngageData//1204_Thumb_Burton4.jpg"},
//                           {"time": 36.1597653, "imageUrl": "http://www.vbossengage.com/EngageData//1204_Thumb_Hailer3.jpg"},
//                           {"time": 40.1597653, "imageUrl": "http://www.vbossengage.com/EngageData//1204_Thumb_Koontz.jpg"}                         
//                           ]};
//            }
            // CODE ENDS TO DISPLAY THE CHAPTERS     
            
             filePatches = {"mediaUrl": realPath,
                           "placeholderImage": "",
                           "chapters": []};

            var playerObj =  new StartPlayer_0();
            // Scroll to Top
            window.scrollTo(0,document.getElementById('divPlayerContainer').scrollTop);
            return playerObj;
        
//            // Place the object in div tag
     //       document.getElementById("divPlayerContainer").innerHTML = playerObj; 
        }                  
    }  
    else if ((parseInt(document.getElementById("hidTemplateID").value) >= 6) && (parseInt(document.getElementById("hidTemplateID").value) <= 7))
    {        
        // CODE STARTS HERE TO CHECK FOR THE YOU TUBE / FLASH VIDEO
        var checkFlash;
        
        if (realPath.match("www.youtube"))
            checkFlash = realPath.match("www.youtube");
        else if (realPath.match(".flv.smil"))
            checkFlash = realPath.match(".flv.smil");
        else if (realPath.match(".smil"))
            checkFlash = realPath.match(".smil"); /// for live stream url        
        else if (document.getElementById("hidContentTypeID").value == 2)
            checkFlash = realPath; /// for flash alternative source url
       
        if (checkFlash != null)
        { 
          var so = new SWFObject('../JWFlashPlayer/player.swf','ply','450','350','9');
          so.addParam('allowscriptaccess','always');
          so.addParam('allowfullscreen','true');
          
         if (realPath.match("www.youtube")) 
          {           
            so.addParam('id','ytPlayer');
            so.addParam('flashvars','&file=' + realPath + '&autostart=true&skin=../JWFlashPlayer/Skins/' + document.getElementById("hidPlayerSkin").value + '.swf&plugins=sharing-1&sharing.link=' + window.location.href + '&dock=true');  
          }
          else if (realPath.match(".flv.smil")) // for flash ondemand video
            /////// **** CODE STARTS FOR EMBED CODE (JUST ADD BELOW CODE IN THE 'flashvars' PARAM) **********
            // &sharing.code=<body><div id=%22mediaspace%22></div><script type=%22text/javascript%22 src=%22http://localhost:52659/MMediaPlatform/js/embed.js%22 language=%22javascript%22></script><script type=%22text/javascript%22>var param = new Array();/**DO NOT EDIT THESE CONFIG ITEMS**/ param[%22uniquekey%22] = %22vd-' + document.getElementById("hidAccountName").value + '-' + document.getElementById("VideoDesc_hidClickedVideoID").value + '-' + document.getElementById("hidPlayerSkin").value + '%22;/**EDIT THESE CONFIGURATION**/ param[%22playerwidth%22] = %22620%22;   /**the width the player(Need to be in pixels)**/ param[%22playerheight%22] = %22400%22;  /**the height the player    (Need to be in pixels)**/ document.getElementById(%22mediaspace%22).innerHTML = getEmbed(param);</script></body>');  
            /////// **** CODE ENDS FOR EMBED CODE **********
            so.addParam('flashvars','&file=' + realPath + '&autostart=true&type=highwinds&skin=../JWFlashPlayer/Skins/' + document.getElementById("hidPlayerSkin").value + '.swf&plugins=sharing-1&sharing.link=' + window.location.href + '&dock=true');  
          else if (realPath.match(".smil")) /// for live stream url
            so.addParam('flashvars','&file=' + realPath + '&autostart=true&type=highwinds&skin=../JWFlashPlayer/Skins/' + document.getElementById("hidPlayerSkin").value + '.swf&plugins=sharing-1&sharing.link=' + window.location.href + '&dock=true');  
          else if (document.getElementById("hidContentTypeID").value == 2) /// for flash alternative source
            so.addParam('flashvars','&file=' + realPath + '&autostart=true&skin=../JWFlashPlayer/Skins/' + document.getElementById("hidPlayerSkin").value + '.swf&plugins=sharing-1&sharing.link=' + window.location.href + '&dock=true');  
                           
          so.write('divPlayerContainer');  
                    
          window.scrollTo(0,document.getElementById('divPlayerContainer').scrollTop);
          return;
        }
        // CODE ENDS HERE TO CHECK FOR THE YOU TUBE VIDEO
        
        // Create a player object
        if (document.getElementById("hidPlayerTypeID").value == 1)  // JW PLAYER OBJECT
        {  
            sfileName = 'empty-1';    
            sfileName = realPath; // Assign the file 
            
            // PLAY THE PRE ROLL VIDEO
            if (preRollPath == "")
                SetVideo(sfileName, 'true', 1, 350, 450);    // Loads the Player    
            else
                SetVideo(preRollPath, 'false', 0, 350, 450);    // Loads the JW Player   
        }
        else if (document.getElementById("hidPlayerTypeID").value == 2) // OPEN VIDEO PLAYER OBJECT
        {    
            var playerObj = "<object data='data:application/x-silverlight-2,' type='application/x-silverlight-2' width='450px' height='350px' id='slp' style='z-index:-1' >"
                + "<param name='source' value='../OVP.xap'/>"
                + "<param name='minRuntimeVersion' value='2.0.30923.0' />"
                + "<param name='onerror' value='onSilverlightError' />"
                + "<param name='MaxFrameRate' value='30' />"
                + "<param name='Windowless' value='True' />"
                + "<param name='background' value='black' />"

                + "<param name='initparams' value='theme=../OVPThemes/" + document.getElementById("hidPlayerSkin").value + ".xaml,"
                + "showstatistics=false, autoplay=true, muted=false, playlistoverlay=false, stretchmode=Fit, stretchmodefullscreen=Fit,"
                + "playlist=" + filePath + "' />"
                + "<a href='http://go.microsoft.com/fwlink/?LinkID=124807' style='text-decoration: none;'>"
                + "<img src='http://go.microsoft.com/fwlink/?LinkId=108181' alt='Get Microsoft Silverlight' style='border-style: none'/></a>"
                + "</object>";
                //alert(playerObj);
            // Place the object in div tag
            document.getElementById("divPlayerContainer").innerHTML = playerObj; 
        }
        else if (document.getElementById("hidPlayerTypeID").value == 3) // WINDOWS MEDIA PLAYER OBJECT
        {            
            var playerObj = '<OBJECT ID="WMPlayer"  CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" WIDTH="450" HEIGHT="350" showstatusbar="True">'
                +'<PARAM NAME="AutoStart" VALUE="True" >'
                +'<PARAM NAME="stretchToFit" VALUE="True">'
                +' <PARAM NAME="URL" VALUE="'+ realPath +'">'
                +'<PARAM NAME="enableContextMenu" VALUE="False">'                   
                 +'<EMBED TYPE="application/x-mplayer2" '
                +'SRC="'+ realPath +'" '
                +'NAME="WMPlayer"'
                +'WIDTH="450"'
                +'HEIGHT="350"'
                +'EnableContextMenu="False"'
                +'AUTOSTART="True" showstatusbar="True"' 
                +'SHOWCONTROLS="True">'
                +'</EMBED>'
                +'</OBJECT>'; 
                
            // Place the object in div tag
            document.getElementById("divPlayerContainer").innerHTML = playerObj; 
        }
        else if (document.getElementById("hidPlayerTypeID").value == 4) // MM PLAYER OBJECT
        {      
             // CODE STARTS TO DISPLAY THE CHAPTERS     
//            if (realPath == 'http://vbricksys.edgeboss.net/wmedia/vbricksys/vbrick/vboss_temp_phase2/wbirchett_4049/snowtrainhigh.wvx')
//            {
//                //filePath = overallPath;
//                filePatches = {"mediaUrl": realPath,
//                           "placeholderImage": "http://www.vbossengage.com/EngageData//1612_Thumb_Edmonton_skyline.jpg",
//                           "chapters": [
//                           {"time": 12.1597653, "imageUrl": "http://www.vbossengage.com/EngageData//1204_Thumb_Burton4.jpg"},
//                           {"time": 36.1597653, "imageUrl": "http://www.vbossengage.com/EngageData//1204_Thumb_Hailer3.jpg"},
//                           {"time": 40.1597653, "imageUrl": "http://www.vbossengage.com/EngageData//1204_Thumb_Koontz.jpg"}                         
//                           ]};
//            }
            // CODE ENDS TO DISPLAY THE CHAPTERS     
            
             filePatches = {"mediaUrl": realPath,
                           "placeholderImage": "",
                           "chapters": []};

            var playerObj =  new StartPlayer_0();
            // Scroll to Top
            window.scrollTo(0,document.getElementById('divPlayerContainer').scrollTop);
            return playerObj;
        
//            // Place the object in div tag
     //       document.getElementById("divPlayerContainer").innerHTML = playerObj; 
        }                  
    }  
    else if (parseInt(document.getElementById("hidTemplateID").value) >= 8)
    {            
        
        // CODE STARTS HERE TO CHECK FOR THE YOU TUBE / FLASH VIDEO
        var checkFlash;
        
        if (realPath.match("www.youtube"))
            checkFlash = realPath.match("www.youtube");
        else if (realPath.match(".flv.smil"))
            checkFlash = realPath.match(".flv.smil");
        else if (realPath.match(".smil"))
            checkFlash = realPath.match(".smil"); /// for live stream url        
        else if (document.getElementById("hidContentTypeID").value == 2)
            checkFlash = realPath; /// for flash alternative source url
       
        if (checkFlash != null)
        { 
          var so = new SWFObject('../JWFlashPlayer/player.swf','ply','400','330','9');
          so.addParam('allowscriptaccess','always');
          so.addParam('allowfullscreen','true');
          
         if (realPath.match("www.youtube")) 
          {           
            so.addParam('id','ytPlayer');
            so.addParam('flashvars','&file=' + realPath + '&autostart=true&skin=../JWFlashPlayer/Skins/' + document.getElementById("hidPlayerSkin").value + '.swf&plugins=sharing-1&sharing.link=' + window.location.href + '&dock=true');  
          }
          else if (realPath.match(".flv.smil")) // for flash ondemand video
            /////// **** CODE STARTS FOR EMBED CODE (JUST ADD BELOW CODE IN THE 'flashvars' PARAM) **********
            // &sharing.code=<body><div id=%22mediaspace%22></div><script type=%22text/javascript%22 src=%22http://localhost:52659/MMediaPlatform/js/embed.js%22 language=%22javascript%22></script><script type=%22text/javascript%22>var param = new Array();/**DO NOT EDIT THESE CONFIG ITEMS**/ param[%22uniquekey%22] = %22vd-' + document.getElementById("hidAccountName").value + '-' + document.getElementById("VideoDesc_hidClickedVideoID").value + '-' + document.getElementById("hidPlayerSkin").value + '%22;/**EDIT THESE CONFIGURATION**/ param[%22playerwidth%22] = %22620%22;   /**the width the player(Need to be in pixels)**/ param[%22playerheight%22] = %22400%22;  /**the height the player    (Need to be in pixels)**/ document.getElementById(%22mediaspace%22).innerHTML = getEmbed(param);</script></body>');  
            /////// **** CODE ENDS FOR EMBED CODE **********
            so.addParam('flashvars','&file=' + realPath + '&autostart=true&type=highwinds&skin=../JWFlashPlayer/Skins/' + document.getElementById("hidPlayerSkin").value + '.swf&plugins=sharing-1&sharing.link=' + window.location.href + '&dock=true');  
          else if (realPath.match(".smil")) /// for live stream url
            so.addParam('flashvars','&file=' + realPath + '&autostart=true&type=highwinds&skin=../JWFlashPlayer/Skins/' + document.getElementById("hidPlayerSkin").value + '.swf&plugins=sharing-1&sharing.link=' + window.location.href + '&dock=true');  
          else if (document.getElementById("hidContentTypeID").value == 2) /// for flash alternative source
            so.addParam('flashvars','&file=' + realPath + '&autostart=true&skin=../JWFlashPlayer/Skins/' + document.getElementById("hidPlayerSkin").value + '.swf&plugins=sharing-1&sharing.link=' + window.location.href + '&dock=true');  
                           
          so.write('divPlayerContainer');  
                    
          window.scrollTo(0,document.getElementById('divPlayerContainer').scrollTop);
          return;
        }
        // CODE ENDS HERE TO CHECK FOR THE YOU TUBE VIDEO
        
        // Create a player object
        if (document.getElementById("hidPlayerTypeID").value == 1)  // JW PLAYER OBJECT
        {  
            sfileName = 'empty-1';    
            sfileName = realPath; // Assign the file 
            
            // PLAY THE PRE ROLL VIDEO
            if (preRollPath == "")
                SetVideo(sfileName, 'true', 1, 330, 400);    // Loads the Player    
            else
                SetVideo(preRollPath, 'false', 0, 330, 400);    // Loads the JW Player   
        }
        else if (document.getElementById("hidPlayerTypeID").value == 2) // OPEN VIDEO PLAYER OBJECT
        {    
            var playerObj = "<object data='data:application/x-silverlight-2,' type='application/x-silverlight-2' width='400px' height='330px' id='slp' style='z-index:-1' >"
                + "<param name='source' value='../OVP.xap'/>"
                + "<param name='minRuntimeVersion' value='2.0.30923.0' />"
                + "<param name='onerror' value='onSilverlightError' />"
                + "<param name='MaxFrameRate' value='30' />"
                + "<param name='Windowless' value='True' />"
                + "<param name='background' value='black' />"

                + "<param name='initparams' value='theme=../OVPThemes/" + document.getElementById("hidPlayerSkin").value + ".xaml,"
                + "showstatistics=false, autoplay=true, muted=false, playlistoverlay=false, stretchmode=Fit, stretchmodefullscreen=Fit,"
                + "playlist=" + filePath + "' />"
                + "<a href='http://go.microsoft.com/fwlink/?LinkID=124807' style='text-decoration: none;'>"
                + "<img src='http://go.microsoft.com/fwlink/?LinkId=108181' alt='Get Microsoft Silverlight' style='border-style: none'/></a>"
                + "</object>";
                //alert(playerObj);
            // Place the object in div tag
            document.getElementById("divPlayerContainer").innerHTML = playerObj; 
        }
        else if (document.getElementById("hidPlayerTypeID").value == 3) // WINDOWS MEDIA PLAYER OBJECT
        {            
            var playerObj = '<OBJECT ID="WMPlayer"  CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" WIDTH="400" HEIGHT="330" showstatusbar="True">'
                +'<PARAM NAME="AutoStart" VALUE="True" >'
                +'<PARAM NAME="stretchToFit" VALUE="True">'
                +' <PARAM NAME="URL" VALUE="'+ realPath +'">'
                +'<PARAM NAME="enableContextMenu" VALUE="False">'                   
                 +'<EMBED TYPE="application/x-mplayer2" '
                +'SRC="'+ realPath +'" '
                +'NAME="WMPlayer"'
                +'WIDTH="400"'
                +'HEIGHT="330"'
                +'EnableContextMenu="False"'
                +'AUTOSTART="True" showstatusbar="True"' 
                +'SHOWCONTROLS="True">'
                +'</EMBED>'
                +'</OBJECT>'; 
                
            // Place the object in div tag
            document.getElementById("divPlayerContainer").innerHTML = playerObj; 
        }
        else if (document.getElementById("hidPlayerTypeID").value == 4) // MM PLAYER OBJECT
        {      
             // CODE STARTS TO DISPLAY THE CHAPTERS     
//            if (realPath == 'http://vbricksys.edgeboss.net/wmedia/vbricksys/vbrick/vboss_temp_phase2/wbirchett_4049/snowtrainhigh.wvx')
//            {
//                //filePath = overallPath;
//                filePatches = {"mediaUrl": realPath,
//                           "placeholderImage": "http://www.vbossengage.com/EngageData//1612_Thumb_Edmonton_skyline.jpg",
//                           "chapters": [
//                           {"time": 12.1597653, "imageUrl": "http://www.vbossengage.com/EngageData//1204_Thumb_Burton4.jpg"},
//                           {"time": 36.1597653, "imageUrl": "http://www.vbossengage.com/EngageData//1204_Thumb_Hailer3.jpg"},
//                           {"time": 40.1597653, "imageUrl": "http://www.vbossengage.com/EngageData//1204_Thumb_Koontz.jpg"}                         
//                           ]};
//            }
            // CODE ENDS TO DISPLAY THE CHAPTERS     
            
             filePatches = {"mediaUrl": realPath,
                           "placeholderImage": "",
                           "chapters": []};

            var playerObj =  new StartPlayer_0();
            // Scroll to Top
            window.scrollTo(0,document.getElementById('divPlayerContainer').scrollTop);
            return playerObj;
        
//            // Place the object in div tag
     //       document.getElementById("divPlayerContainer").innerHTML = playerObj; 
        }                  
    }          
    //document.getElementById('divPlayerContainer').scrollIntoView();  
    window.scrollTo(0,document.getElementById('divPlayerContainer').scrollTop);
    
    //var div = document.getElementById('YOUR_DIV');
    //div.scrollTop = div.getElementById('OBJECT_TO_SCROLL_TO').scrollHeight;

}


/// Plays the mentioned playlist file.
function PlayIt(videoID, option, payRate)
{    
    //FUNCTION TO MAKE THE CLICK EVENT ON THE VOD AREA
    if (parseInt(document.getElementById("hidTemplateID").value) == 8)
    {
        if (option == 'live')
        {
            // DISABLE THE CURRENT CLICK EVENTS
            var rowCount = document.getElementById("tblCatVOD").getElementsByTagName("tr").length / 3; // 3 refers for total rows per record        
            for (var i=0;i<rowCount;i++)
            {   
                document.getElementsByClassName("trClassCatVOD")[i].style.backgroundColor = document.getElementById("hidPortalBgColor").value;
            }
            
            var trLiveValue = "trLiveCat_" + videoID;
            document.getElementById(trLiveValue).style.backgroundColor = "#686868"; 
        }
        else
        {        
            // DISABLE THE LIVE CLICK
            if (document.getElementById("hidLiveTabExists_VPC").value != 'false')
               document.getElementsByClassName("trClassCatLive")[0].style.backgroundColor = document.getElementById("hidPortalBgColor").value;
            
            // DISABLE THE CURRENT CLICK EVENTS
            var rowCount = document.getElementById("tblCatVOD").getElementsByTagName("tr").length / 3; // 3 refers for total rows per record        
            for (var i=0;i<rowCount;i++)
            {   
                document.getElementsByClassName("trClassCatVOD")[i].style.backgroundColor = document.getElementById("hidPortalBgColor").value;
            }
            
            // ENABLE THE CURRENT CLICK EVENTS
            var trValue = "trCat_" + videoID;
            document.getElementById(trValue).style.backgroundColor = "#686868";     
        }
    }
    
    document.getElementById("VideoDesc_hidClickedVideoID").value = videoID;    
    document.getElementById("VideoDesc_hidClickedVideoStatus").value = option;
        
    // DISPLAY THE btnVideo BUTTON
    document.getElementById("VideoDesc_btnVideo").style.display = "block";
    
    // CLICK THE btnVideo BUTTON
    document.frmIndex.VideoDesc_btnVideo.click();
    
    
    // *********************** CODE STARTS FOR PLAY THE FIRST 10 SECONDS VIDEO ********************************
    
//////////////////////    if ((option == 'live') || (option == 'fv_live'))
//////////////////////    {
//////////////////////        // Open Login Page
//////////////////////        if (document.getElementById("hidLoginStatus").value == "Not-Logged-In" && parseInt(payRate) > 0)
//////////////////////        {   
//////////////////////             OpenLoginWindow();
//////////////////////        }
//////////////////////    
//////////////////////        // Open Payment Page
//////////////////////        if ((document.getElementById("hidLoginStatus").value == "Logged-In") && (document.getElementById("VideoDesc_hidPaymentStatus").value == "notpaid") && parseInt(payRate) > 0)
//////////////////////        {   
//////////////////////             OpenPaymentWindow(payRate);
//////////////////////        }
//////////////////////    }
//////////////////////    else 
//////////////////////        globalPayRate = payRate;
        
    // *********************** CODE ENDS FOR PLAY THE FIRST 10 SECONDS VIDEO ********************************
    
    // ******************* CODE STARTS NEEDS TO COMMENT, IF WE ARE GOING TO USE THE 10 SECONDS VIDEO ******************
    
        // Open Login Page
        if (document.getElementById("hidLoginStatus").value == "Not-Logged-In" && parseInt(payRate) > 0)
        {   
             //OpenLoginWindow();
        }
    
        // Open Payment Page
        if ((document.getElementById("hidLoginStatus").value == "Logged-In") && (document.getElementById("VideoDesc_hidPaymentStatus").value == "notpaid") && parseInt(payRate) > 0)
        {   
             //OpenPaymentWindow(payRate);
        }
           
    // ******************* CODE ENDS NEEDS TO COMMENT, IF WE ARE GOING TO USE THE 10 SECONDS VIDEO ******************
    
       
} 

function UserLogin()
{    
    if (document.getElementById("Header_txtUserName").value == '')
    {
        alert("Enter Username");
        document.getElementById('Header_txtUserName').focus();
        return;
    }
    if (isEmail(document.getElementById('Header_txtUserName').value)==false)
    {
        alert("Please Enter a Valid Email ID and Continue !!");
        document.getElementById('Header_txtUserName').select();
        return;
    }           
    if (document.getElementById("Header_txtPassword").value == '')
    {
        alert("Enter Password");
        document.getElementById('Header_txtPassword').focus();
        return;
    }    
    document.getElementById("Header_btnLogin").style.display = "block";
    
    document.frmIndex.Header_btnLogin.click();  
}

function LoginSuccess(endUserID, userName)
{       
    if (endUserID != '' && userName != '')
    {   
        document.getElementById("hidLoginStatus").value = "Logged-In";
    }
       
    // Hide the PreLogin Div tag
    document.getElementById("divPreLogin").style.display = "none";
    document.getElementById("lnkRegister").style.display = "none";  
                    
    // UnHide the loggedin infor div
    document.getElementById("divLoggedInInfo").style.display = "block";
    document.getElementById("lnkMyAccount").style.display = "block";  
    document.getElementById("lnkMyPayment").style.display = "block";     
      
    // Set the argument values
    document.getElementById("hidEndUserID").value = endUserID;    
    document.getElementById("Header_lblLoggedIn").innerHTML = userName;
        
    // Hide the dummy button
    document.getElementById("Header_btnLogin").style.display = "none"; 
        
    // Style for welcome panel
    document.getElementsByClassName("welcome")[0].style.color = document.getElementById("hidFontColor").value; 
    document.getElementsByClassName("welcome")[0].style.fontFamily = document.getElementById("hidFontName").value;
    document.getElementsByClassName("welcomeTitle")[0].style.color = document.getElementById("hidForeColor").value; 
    document.getElementsByClassName("welcomeTitle")[0].style.fontFamily = document.getElementById("hidFontName").value;
        
    // Style for user account links (myaccount, mypayment, logout)
    document.getElementsByClassName("hrefPayment")[0].style.color = document.getElementById("hidFontColor").value; 
    document.getElementsByClassName("hrefAccount")[0].style.color = document.getElementById("hidFontColor").value;
    document.getElementsByClassName("hrefLogout")[0].style.color = document.getElementById("hidFontColor").value;
    
    // Play the Selected File
    PlayIt(document.getElementById("VideoDesc_hidClickedVideoID").value, document.getElementById("VideoDesc_hidClickedVideoStatus").value, 0);
              
}

function LoginFailure(message)
{   
   // Hide the loggedin infor div
    document.getElementById("divLoggedInInfo").style.display = "none";
    document.getElementById("lnkMyAccount").style.display = "none";  
    document.getElementById("lnkMyPayment").style.display = "none";  
    document.getElementById("divPreLogin").style.display = "block";        
    document.getElementById("Header_btnLogin").style.display = "none";       
    document.getElementById("Header_txtUserName").focus();         
    alert(message);
        
    // LOGGED IN AS + MEMBER LOGIN 
    document.getElementsByClassName("colorText")[0].style.color = document.getElementById("hidForeColor").value; 
    document.getElementsByClassName("colorText")[0].style.fontFamily = document.getElementById("hidFontName").value;    
    document.getElementsByClassName("classRemember")[0].style.color = document.getElementById("hidFontColor").value;
    document.getElementsByClassName("classRemember")[0].style.fontFamily = document.getElementById("hidFontName").value;
        
    // TEXT BOX TEXT COLOR            
    document.getElementById("Header_txtUserName").style.color = document.getElementById("hidFontColor").value;
    document.getElementById("Header_txtPassword").style.color = document.getElementById("hidFontColor").value;
            
    if (document.getElementById("hidTemplateID").value >= 5)
    {
        // LOGIN TEXT BOX (THIS APPLIES ONLY TO THIS TEMPLATE)
        document.getElementsByClassName("LoginInput")[0].style.width = "170px"; 
        document.getElementsByClassName("LoginInput")[1].style.width = "170px"; 
        
        // Forget Password + Register
        document.getElementById("Header_spForgetPwd").style.color = document.getElementById("hidFontColor").value;
        document.getElementById("Header_spRegister").style.color = document.getElementById("hidFontColor").value;
    }
}

function OpenPasswordWindow()
{  		    
    // Hide the Player Div tag
    document.getElementById("divPlayerContainer").style.display = "none";
        
    var oWindow = window.radopen("ForgotPwd.aspx","rwWindow");
    //Using the reference to the window its clientside methods can be called  
    oWindow.SetSize(450,350);
    oWindow.center();
    oWindow.add_close(OnPasswordClose);
    return false;
}

function OnPasswordClose(oUserWnd)
{       
    // Display the Player Div tag
    if (document.getElementById("divVideo").style.display == "none")
        document.getElementById("divPlayerContainer").style.display = "block";
    // Hide the payment info Div tag
    if (document.getElementById("divPlayerContainer").style.display == "block")
        document.getElementById("divVideo").style.display = "none";
}

function OpenLoginWindow()
{  		    
    // Hide the Player Div tag
    document.getElementById("divPlayerContainer").style.display = "none";
        
    var oWindow = window.radopen("Login.aspx?accountID=" + document.getElementById("hidAccountID").value,"rwWindow");
    //Using the reference to the window its clientside methods can be called  
    oWindow.SetSize(450,600);
    oWindow.MoveTo(200,200);
    //oWindow.center();
    oWindow.add_close(OnLoginClose);
    return false;
}

function OnLoginClose(oWnd)
{    
    // Display the Player Div tag
    if (document.getElementById("divVideo").style.display == "none")
        document.getElementById("divPlayerContainer").style.display = "block";
        
    // Hide the payment info Div tag
    if (document.getElementById("divPlayerContainer").style.display == "block")
        document.getElementById("divVideo").style.display = "none";
        
    //get the transferred arguments
    var endUserID = oWnd.argument.endUserID;
    var userName = oWnd.argument.userName;
        
    if (endUserID > 0 && userName != '')
    {   
        document.getElementById("hidLoginStatus").value = "Logged-In";
        
        if (document.getElementById("hidTemplateID").value > 1)
        {
            // Hide the PreLogin Div tag
            document.getElementById("divPreLogin").style.display = "none";
            document.getElementById("lnkRegister").style.display = "none";  
                            
           // UnHide the loggedin infor div
           document.getElementById("divLoggedInInfo").style.display = "block";
           document.getElementById("lnkMyAccount").style.display = "block";  
           document.getElementById("lnkMyPayment").style.display = "block";     
        }
    }
    
    // Set the argument values
    document.getElementById("hidEndUserID").value = endUserID;
         
    if (document.getElementById("hidTemplateID").value > 1)
    {
        document.getElementById("Header_lblLoggedIn").innerHTML = userName;
        
        // Style for welcome panel
        document.getElementsByClassName("welcome")[0].style.color = document.getElementById("hidFontColor").value; 
        document.getElementsByClassName("welcome")[0].style.fontFamily = document.getElementById("hidFontName").value;
        document.getElementsByClassName("welcomeTitle")[0].style.color = document.getElementById("hidForeColor").value; 
        document.getElementsByClassName("welcomeTitle")[0].style.fontFamily = document.getElementById("hidFontName").value;
        
        // Style for user account links (myaccount, mypayment, logout)
        document.getElementsByClassName("hrefPayment")[0].style.color = document.getElementById("hidFontColor").value; 
        document.getElementsByClassName("hrefAccount")[0].style.color = document.getElementById("hidFontColor").value;
        document.getElementsByClassName("hrefLogout")[0].style.color = document.getElementById("hidFontColor").value;
    }    
    
    // Play the Selected File
    if (endUserID > 0)   
    { 
        // play video
        PlayIt(document.getElementById("VideoDesc_hidClickedVideoID").value, document.getElementById("VideoDesc_hidClickedVideoStatus").value, 0);            
    }
}

function OpenUserWindow(page)
{   
    // Hide the Player Div tag
    document.getElementById("divPlayerContainer").style.display = "none";
            
    var oWindow = window.radopen("../" + page + ".aspx?UserID=" + document.getElementById("hidAccountID").value + "&endUserID=" + document.getElementById("hidEndUserID").value,"rwWindow");
    //Using the reference to the window its clientside methods can be called  
    oWindow.SetSize(650,500);
    oWindow.center();    
    oWindow.add_close(OnUserClose);
    return false;
}

function OnUserClose(oUserWnd)
{       
    // Display the Player Div tag
    if (document.getElementById("divVideo").style.display == "none")
        document.getElementById("divPlayerContainer").style.display = "block";
    // Hide the payment info Div tag
    if (document.getElementById("divPlayerContainer").style.display == "block")
        document.getElementById("divVideo").style.display = "none";
}

function OpenPaymentWindow(payRate)
{   
    var UpEventID;
    var VideoID = document.getElementById("VideoDesc_hidClickedVideoID").value;
    if ((document.getElementById("VideoDesc_hidClickedVideoStatus").value == 'playlist') || (document.getElementById("VideoDesc_hidClickedVideoStatus").value == 'fv_archived') || (document.getElementById("VideoDesc_hidClickedVideoStatus").value == 'archived'))
        UpEventID = '0';
    else
        UpEventID = document.getElementById("VideoDesc_hidClickedUpcomingEventID").value;
    
    var oWindow = window.radopen("paymentProcess.aspx?videoID="+ VideoID + "&upEventID="+ UpEventID + "&payRate=" + payRate + "&endUserID=" + document.getElementById("hidEndUserID").value + "&PlayerID=" + document.getElementById("hidPlayerID").value + "&SyndicationID=" + document.getElementById("hidSyndicationID").value,"rwWindow");
    //Using the reference to the window its clientside methods can be called  
    oWindow.SetSize(600,500);
    oWindow.center();
    oWindow.add_close(OnPaymentClose);
    return false;
}

function OnPaymentClose(oPaymentWnd)
{             
    // Display the Player Div tag
    if (document.getElementById("divVideo").style.display == "none")
        document.getElementById("divPlayerContainer").style.display = "block";
        
    // Hide the payment info Div tag
    if (document.getElementById("divPlayerContainer").style.display == "block")
        document.getElementById("divVideo").style.display = "none";
        
    //get the transferred arguments
    var videoID = oPaymentWnd.argument.videoID;
    var strEndUserID = oPaymentWnd.argument.strEndUserID;
    
    // Set the argument values
    document.getElementById("hidEndUserID").value = strEndUserID;
    
    // Play the selected video after successful payment
    PlayIt(videoID, document.getElementById("VideoDesc_hidClickedVideoStatus").value, 0);
}


function OpenSchedulePaymentWindow(payRate,VideoID,UpEventID)
{  
    // LOGIN AND PROCEED 
    if (document.getElementById("hidEndUserID").value <= 0)
    {         
        OpenLoginWindow();
        return;
    }   
    
    var oWindow = window.radopen("paymentProcess.aspx?videoID="+ VideoID + "&upEventID="+ UpEventID + "&payRate=" + payRate + "&endUserID=" + document.getElementById("hidEndUserID").value + "&PlayerID=" + document.getElementById("hidPlayerID").value + "&SyndicationID=" + document.getElementById("hidSyndicationID").value,"rwWindow");
    //Using the reference to the window its clientside methods can be called  
    oWindow.SetSize(600,500);
    oWindow.center();
    oWindow.add_close(OnSchedulePaymentClose);
    return false;
}

function OnSchedulePaymentClose(oPaymentWnd)
{             
    // Display the Player Div tag
    if (document.getElementById("divVideo").style.display == "none")
        document.getElementById("divPlayerContainer").style.display = "block";
        
    // Hide the payment info Div tag
    if (document.getElementById("divPlayerContainer").style.display == "block")
        document.getElementById("divVideo").style.display = "none";
        
    //get the transferred arguments
    //var videoID = oPaymentWnd.argument.videoID;
    var strEndUserID = oPaymentWnd.argument.strEndUserID;
    
    // Set the argument values
    document.getElementById("hidEndUserID").value = strEndUserID;  
    
    // Refresh the schedule part
    var selectedPage = 1;
    GoSchedulerPage(selectedPage);  
}

function Done(theFile)
{ 
    // Hide the payment info Div tag
    document.getElementById("divVideo").style.display = "none";
        
    // Show the Player Div tag
    document.getElementById("divPlayerContainer").style.display = "block";
    
    if (document.getElementById("hidTemplateID").value == 0)
    {
        // CODE STARTS HERE TO CHECK FOR THE YOU TUBE (OR) FLASH VIDEO
        var checkFlash;
        
        if (theFile.match("www.youtube"))
            checkFlash = theFile.match("www.youtube");
        else if (theFile.match(".flv.smil"))
            checkFlash = theFile.match(".flv.smil");
        else if (theFile.match(".smil"))
            checkFlash = theFile.match(".smil"); /// for live stream url
        else if (document.getElementById("hidContentTypeID").value == 2)
            checkFlash = theFile; /// for flash alternative source url

        if (checkFlash != null)
        { 
          var so = new SWFObject('../JWFlashPlayer/player.swf','ply','234','192','9');
          so.addParam('allowscriptaccess','always');
          so.addParam('allowfullscreen','true'); 
          
          if (theFile.match("www.youtube")) 
          {           
            so.addParam('id','ytPlayer');
            so.addParam('flashvars','&file=' + theFile + '&autostart=true&skin=../JWFlashPlayer/Skins/' + document.getElementById("hidPlayerSkin").value + '.swf&plugins=sharing-1&sharing.link=' + window.location.href + '&dock=true&sharing.code=%3Cembed%20src%3D%22http%3A%2F%2Fwww.monetizemedia.com%2Fplayer%2Ftrunk%2Fas3%2Fplayer.swf%22%20flashvars%3D%22file%3D..%2Ftesting%2Ffiles%2Fbunny.mp4%22%20width%3D%22400%22%20height%3D%22300%22%20%2F%3E');  
          }
          else if (theFile.match(".flv.smil")) // for flash ondemand video            
            so.addParam('flashvars','&file=' + theFile + '&autostart=true&type=highwinds&skin=../JWFlashPlayer/Skins/' + document.getElementById("hidPlayerSkin").value + '.swf&plugins=sharing-1&sharing.link=' + window.location.href + '&dock=true');  
          else if (theFile.match(".smil")) /// for live stream url
            so.addParam('flashvars','&file=' + theFile + '&autostart=true&type=highwinds&skin=../JWFlashPlayer/Skins/' + document.getElementById("hidPlayerSkin").value + '.swf&plugins=sharing-1&sharing.link=' + window.location.href + '&dock=true');  
          else if (document.getElementById("hidContentTypeID").value == 2) /// for flash alternative source
            so.addParam('flashvars','&file=' + theFile + '&autostart=true&skin=../JWFlashPlayer/Skins/' + document.getElementById("hidPlayerSkin").value + '.swf&plugins=sharing-1&sharing.link=' + window.location.href + '&dock=true');  
                                                
          so.write('divPlayerContainer');  
                   
          window.scrollTo(0,document.getElementById('divPlayerContainer').scrollTop);
          return;
        }
        // CODE ENDS HERE TO CHECK FOR THE YOU TUBE (OR) FLASH VIDEO
        
         // Create a player object
        if (document.getElementById("hidPlayerTypeID").value == 1)  // JW PLAYER OBJECT
        {    
            SetVideo(theFile, 'true', 1, 192, 234);    // Loads the Player  
        }
        else if (document.getElementById("hidPlayerTypeID").value == 2) // OPEN VIDEO PLAYER OBJECT
        {    
            var playerObj = "<object data='data:application/x-silverlight-2,' type='application/x-silverlight-2' width='234px' height='192px' id='slp' style='z-index:-1' >"
                + "<param name='source' value='../OVP.xap'/>"
                + "<param name='minRuntimeVersion' value='2.0.30923.0' />"
                + "<param name='onerror' value='onSilverlightError' />"
                + "<param name='MaxFrameRate' value='30' />"
                + "<param name='Windowless' value='True' />"
                + "<param name='initparams' value='theme=../OVPThemes/" + document.getElementById("hidPlayerSkin").value + ".xaml,"
                + "showstatistics=false, autoplay=true, muted=false, playlistoverlay=false, stretchmode=Fit, stretchmodefullscreen=Fit,"
                + "mediasource=" + theFile + "' />"
                + "<a href='http://go.microsoft.com/fwlink/?LinkID=124807' style='text-decoration: none;'>"
                + "<img src='http://go.microsoft.com/fwlink/?LinkId=108181' alt='Get Microsoft Silverlight' style='border-style: none'/></a>"
                + "</object>";
                
            // Place the object in div tag
            document.getElementById("divPlayerContainer").innerHTML = playerObj; 
        }
        else if (document.getElementById("hidPlayerTypeID").value == 3) // WINDOWS MEDIA PLAYER OBJECT
        {            
            var playerObj = '<OBJECT ID="WMPlayer"  CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" WIDTH="234" HEIGHT="192" showstatusbar="True">'
                +'<PARAM NAME="AutoStart" VALUE="True" >'
                +'<PARAM NAME="stretchToFit" VALUE="True">'
                +' <PARAM NAME="URL" VALUE="'+ theFile +'">'
                +'<PARAM NAME="enableContextMenu" VALUE="False">'                   
                 +'<EMBED TYPE="application/x-mplayer2" '
                +'SRC="'+ theFile +'" '
                +'NAME="WMPlayer"'
                +'WIDTH="234"'
                +'HEIGHT="192"'
                +'EnableContextMenu="False"'
                +'AUTOSTART="True" showstatusbar="True" stretchToFit="True"' 
                +'SHOWCONTROLS="True">'
                +'</EMBED>'
                +'</OBJECT>'; 
                
            // Place the object in div tag
            document.getElementById("divPlayerContainer").innerHTML = playerObj; 
        }    
        else if (document.getElementById("hidPlayerTypeID").value == 4) // MM PLAYER OBJECT
        {                  
             filePatches = {"mediaUrl": theFile,
                           "placeholderImage": "",
                           "chapters": []};

            var playerObj =  new StartPlayer_0();
            // Scroll to Top
            window.scrollTo(0,document.getElementById('divPlayerContainer').scrollTop);
            return playerObj;        
        }    
    }
    else if ((parseInt(document.getElementById("hidTemplateID").value) > 0) && (parseInt(document.getElementById("hidTemplateID").value) <= 5))
    {        
        // CODE STARTS HERE TO CHECK FOR THE YOU TUBE (OR) FLASH VIDEO
         var checkFlash;
        
        if (theFile.match("www.youtube"))
            checkFlash = theFile.match("www.youtube");
        else if (theFile.match(".flv.smil"))
            checkFlash = theFile.match(".flv.smil");
        else if (theFile.match(".smil"))
            checkFlash = theFile.match(".smil"); /// for live stream url
        else if (document.getElementById("hidContentTypeID").value == 2)
            checkFlash = theFile; /// for flash alternative source url

        if (checkFlash != null)
        { 
          var so = new SWFObject('../JWFlashPlayer/player.swf','ply','620','400','9');
          so.addParam('allowscriptaccess','always');
          so.addParam('allowfullscreen','true');
          
          if (theFile.match("www.youtube")) 
          {           
            so.addParam('id','ytPlayer');
            so.addParam('flashvars','&file=' + theFile + '&autostart=true&skin=../JWFlashPlayer/Skins/' + document.getElementById("hidPlayerSkin").value + '.swf&plugins=sharing-1&sharing.link=' + window.location.href + '&dock=true&sharing.code=%3Cembed%20src%3D%22http%3A%2F%2Fwww.monetizemedia.com%2Fplayer%2Ftrunk%2Fas3%2Fplayer.swf%22%20flashvars%3D%22file%3D..%2Ftesting%2Ffiles%2Fbunny.mp4%22%20width%3D%22400%22%20height%3D%22300%22%20%2F%3E');  
          }
          else if (theFile.match(".flv.smil")) // for flash ondemand video            
            so.addParam('flashvars','&file=' + theFile + '&autostart=true&type=highwinds&skin=../JWFlashPlayer/Skins/' + document.getElementById("hidPlayerSkin").value + '.swf&plugins=sharing-1&sharing.link=' + window.location.href + '&dock=true');  
          else if (theFile.match(".smil")) /// for live stream url
            so.addParam('flashvars','&file=' + theFile + '&autostart=true&type=highwinds&skin=../JWFlashPlayer/Skins/' + document.getElementById("hidPlayerSkin").value + '.swf&plugins=sharing-1&sharing.link=' + window.location.href + '&dock=true');  
          else if (document.getElementById("hidContentTypeID").value == 2) /// for flash alternative source
            so.addParam('flashvars','&file=' + theFile + '&autostart=true&skin=../JWFlashPlayer/Skins/' + document.getElementById("hidPlayerSkin").value + '.swf&plugins=sharing-1&sharing.link=' + window.location.href + '&dock=true');  
                             
          so.write('divPlayerContainer');  
                    
          window.scrollTo(0,document.getElementById('divPlayerContainer').scrollTop);
          return;
        }
        // CODE ENDS HERE TO CHECK FOR THE YOU TUBE (OR) FLASH VIDEO
        
        // Create a player object
        if (document.getElementById("hidPlayerTypeID").value == 1)  // JW PLAYER OBJECT
        {    
            SetVideo(theFile, 'true', 1, 400, 620);    // Loads the Player  
        }
        else if (document.getElementById("hidPlayerTypeID").value == 2) // OPEN VIDEO PLAYER OBJECT
        {    
            var playerObj = "<object data='data:application/x-silverlight-2,' type='application/x-silverlight-2' width='620px' height='400px' id='slp' style='z-index:-1' >"
                + "<param name='source' value='../OVP.xap'/>"
                + "<param name='minRuntimeVersion' value='2.0.30923.0' />"
                + "<param name='onerror' value='onSilverlightError' />"
                + "<param name='MaxFrameRate' value='30' />"
                + "<param name='Windowless' value='True' />"
                + "<param name='initparams' value='theme=../OVPThemes/" + document.getElementById("hidPlayerSkin").value + ".xaml,"
                + "showstatistics=false, autoplay=true, muted=false, playlistoverlay=false, stretchmode=Fit, stretchmodefullscreen=Fit,"
                + "mediasource=" + theFile + "' />"
                + "<a href='http://go.microsoft.com/fwlink/?LinkID=124807' style='text-decoration: none;'>"
                + "<img src='http://go.microsoft.com/fwlink/?LinkId=108181' alt='Get Microsoft Silverlight' style='border-style: none'/></a>"
                + "</object>";
                
            // Place the object in div tag
            document.getElementById("divPlayerContainer").innerHTML = playerObj; 
        }
        else if (document.getElementById("hidPlayerTypeID").value == 3) // WINDOWS MEDIA PLAYER OBJECT
        {            
            var playerObj = '<OBJECT ID="WMPlayer"  CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" WIDTH="620" HEIGHT="400" showstatusbar="True">'
                +'<PARAM NAME="AutoStart" VALUE="True" >'
                +'<PARAM NAME="stretchToFit" VALUE="True">'
                +' <PARAM NAME="URL" VALUE="'+ theFile +'">'
                +'<PARAM NAME="enableContextMenu" VALUE="False">'                   
                 +'<EMBED TYPE="application/x-mplayer2" '
                +'SRC="'+ theFile +'" '
                +'NAME="WMPlayer"'
                +'WIDTH="620"'
                +'HEIGHT="400"'
                +'EnableContextMenu="False"'
                +'AUTOSTART="True" showstatusbar="True" stretchToFit="True"' 
                +'SHOWCONTROLS="True">'
                +'</EMBED>'
                +'</OBJECT>'; 
                
            // Place the object in div tag
            document.getElementById("divPlayerContainer").innerHTML = playerObj; 
        }
        else if (document.getElementById("hidPlayerTypeID").value == 4) // MM PLAYER OBJECT
        {                  
             filePatches = {"mediaUrl": theFile,
                           "placeholderImage": "",
                           "chapters": []};

            var playerObj =  new StartPlayer_0();
            // Scroll to Top
            window.scrollTo(0,document.getElementById('divPlayerContainer').scrollTop);
            return playerObj;        
        }                    
    }
    else if ((parseInt(document.getElementById("hidTemplateID").value) >= 6) && (parseInt(document.getElementById("hidTemplateID").value) <= 7))
    {        
        // CODE STARTS HERE TO CHECK FOR THE YOU TUBE (OR) FLASH VIDEO
         var checkFlash;
        
        if (theFile.match("www.youtube"))
            checkFlash = theFile.match("www.youtube");
        else if (theFile.match(".flv.smil"))
            checkFlash = theFile.match(".flv.smil");
        else if (theFile.match(".smil"))
            checkFlash = theFile.match(".smil"); /// for live stream url
        else if (document.getElementById("hidContentTypeID").value == 2)
            checkFlash = theFile; /// for flash alternative source url

        if (checkFlash != null)
        { 
          var so = new SWFObject('../JWFlashPlayer/player.swf','ply','450','350','9');
          so.addParam('allowscriptaccess','always');
          so.addParam('allowfullscreen','true');
          
         if (theFile.match("www.youtube")) 
          {           
            so.addParam('id','ytPlayer');
            so.addParam('flashvars','&file=' + theFile + '&autostart=true&skin=../JWFlashPlayer/Skins/' + document.getElementById("hidPlayerSkin").value + '.swf&plugins=sharing-1&sharing.link=' + window.location.href + '&dock=true&sharing.code=%3Cembed%20src%3D%22http%3A%2F%2Fwww.monetizemedia.com%2Fplayer%2Ftrunk%2Fas3%2Fplayer.swf%22%20flashvars%3D%22file%3D..%2Ftesting%2Ffiles%2Fbunny.mp4%22%20width%3D%22400%22%20height%3D%22300%22%20%2F%3E');  
          }
          else if (theFile.match(".flv.smil")) // for flash ondemand video            
            so.addParam('flashvars','&file=' + theFile + '&autostart=true&type=highwinds&skin=../JWFlashPlayer/Skins/' + document.getElementById("hidPlayerSkin").value + '.swf&plugins=sharing-1&sharing.link=' + window.location.href + '&dock=true');  
          else if (theFile.match(".smil")) /// for live stream url
            so.addParam('flashvars','&file=' + theFile + '&autostart=true&type=highwinds&skin=../JWFlashPlayer/Skins/' + document.getElementById("hidPlayerSkin").value + '.swf&plugins=sharing-1&sharing.link=' + window.location.href + '&dock=true');  
          else if (document.getElementById("hidContentTypeID").value == 2) /// for flash alternative source
            so.addParam('flashvars','&file=' + theFile + '&autostart=true&skin=../JWFlashPlayer/Skins/' + document.getElementById("hidPlayerSkin").value + '.swf&plugins=sharing-1&sharing.link=' + window.location.href + '&dock=true');  
                         
          so.write('divPlayerContainer');  
                    
          window.scrollTo(0,document.getElementById('divPlayerContainer').scrollTop);
          return;
        }
        // CODE ENDS HERE TO CHECK FOR THE YOU TUBE (OR) FLASH VIDEO
        
        // Create a player object
        if (document.getElementById("hidPlayerTypeID").value == 1)  // JW PLAYER OBJECT
        {  
            SetVideo(theFile, 'true', 1, 350, 450);    // Loads the Player  
        }
        else if (document.getElementById("hidPlayerTypeID").value == 2) // OPEN VIDEO PLAYER OBJECT
        {    
            var playerObj = "<object data='data:application/x-silverlight-2,' type='application/x-silverlight-2' width='450px' height='350px' id='slp' style='z-index:-1' >"
                + "<param name='source' value='../OVP.xap'/>"
                + "<param name='minRuntimeVersion' value='2.0.30923.0' />"
                + "<param name='onerror' value='onSilverlightError' />"
                + "<param name='MaxFrameRate' value='30' />"
                + "<param name='Windowless' value='True' />"
                + "<param name='background' value='black' />"

                + "<param name='initparams' value='theme=../OVPThemes/" + document.getElementById("hidPlayerSkin").value + ".xaml,"
                + "showstatistics=false, autoplay=true, muted=false, playlistoverlay=false, stretchmode=Fit, stretchmodefullscreen=Fit,"
                + "playlist=" + theFile + "' />"
                + "<a href='http://go.microsoft.com/fwlink/?LinkID=124807' style='text-decoration: none;'>"
                + "<img src='http://go.microsoft.com/fwlink/?LinkId=108181' alt='Get Microsoft Silverlight' style='border-style: none'/></a>"
                + "</object>";
                //alert(playerObj);
            // Place the object in div tag
            document.getElementById("divPlayerContainer").innerHTML = playerObj; 
        }
        else if (document.getElementById("hidPlayerTypeID").value == 3) // WINDOWS MEDIA PLAYER OBJECT
        {            
            var playerObj = '<OBJECT ID="WMPlayer"  CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" WIDTH="450" HEIGHT="350" showstatusbar="True">'
                +'<PARAM NAME="AutoStart" VALUE="True" >'
                +'<PARAM NAME="stretchToFit" VALUE="True">'
                +' <PARAM NAME="URL" VALUE="'+ theFile +'">'
                +'<PARAM NAME="enableContextMenu" VALUE="False">'                   
                 +'<EMBED TYPE="application/x-mplayer2" '
                +'SRC="'+ theFile +'" '
                +'NAME="WMPlayer"'
                +'WIDTH="450"'
                +'HEIGHT="350"'
                +'EnableContextMenu="False"'
                +'AUTOSTART="True" showstatusbar="True"' 
                +'SHOWCONTROLS="True">'
                +'</EMBED>'
                +'</OBJECT>'; 
                
            // Place the object in div tag
            document.getElementById("divPlayerContainer").innerHTML = playerObj; 
        }
        else if (document.getElementById("hidPlayerTypeID").value == 4) // MM PLAYER OBJECT
        {                  
             filePatches = {"mediaUrl": theFile,
                           "placeholderImage": "",
                           "chapters": []};

            var playerObj =  new StartPlayer_0();
            // Scroll to Top
            window.scrollTo(0,document.getElementById('divPlayerContainer').scrollTop);
            return playerObj;
        
        }                  
    }  
    else if (parseInt(document.getElementById("hidTemplateID").value) >= 8)
    {        
        // CODE STARTS HERE TO CHECK FOR THE YOU TUBE / FLASH VIDEO
        var checkFlash;
        
        if (theFile.match("www.youtube"))
            checkFlash = theFile.match("www.youtube");
        else if (theFile.match(".flv.smil"))
            checkFlash = theFile.match(".flv.smil");
        else if (theFile.match(".smil"))
            checkFlash = theFile.match(".smil"); /// for live stream url        
        else if (document.getElementById("hidContentTypeID").value == 2)
            checkFlash = theFile; /// for flash alternative source url
       
        if (checkFlash != null)
        { 
          var so = new SWFObject('../JWFlashPlayer/player.swf','ply','400','330','9');
          so.addParam('allowscriptaccess','always');
          so.addParam('allowfullscreen','true');
          
         if (theFile.match("www.youtube")) 
          {           
            so.addParam('id','ytPlayer');
            so.addParam('flashvars','&file=' + theFile + '&autostart=true&skin=../JWFlashPlayer/Skins/' + document.getElementById("hidPlayerSkin").value + '.swf&plugins=sharing-1&sharing.link=' + window.location.href + '&dock=true');  
          }
          else if (theFile.match(".flv.smil")) // for flash ondemand video
            /////// **** CODE STARTS FOR EMBED CODE (JUST ADD BELOW CODE IN THE 'flashvars' PARAM) **********
            // &sharing.code=<body><div id=%22mediaspace%22></div><script type=%22text/javascript%22 src=%22http://localhost:52659/MMediaPlatform/js/embed.js%22 language=%22javascript%22></script><script type=%22text/javascript%22>var param = new Array();/**DO NOT EDIT THESE CONFIG ITEMS**/ param[%22uniquekey%22] = %22vd-' + document.getElementById("hidAccountName").value + '-' + document.getElementById("VideoDesc_hidClickedVideoID").value + '-' + document.getElementById("hidPlayerSkin").value + '%22;/**EDIT THESE CONFIGURATION**/ param[%22playerwidth%22] = %22620%22;   /**the width the player(Need to be in pixels)**/ param[%22playerheight%22] = %22400%22;  /**the height the player    (Need to be in pixels)**/ document.getElementById(%22mediaspace%22).innerHTML = getEmbed(param);</script></body>');  
            /////// **** CODE ENDS FOR EMBED CODE **********
            so.addParam('flashvars','&file=' + theFile + '&autostart=true&type=highwinds&skin=../JWFlashPlayer/Skins/' + document.getElementById("hidPlayerSkin").value + '.swf&plugins=sharing-1&sharing.link=' + window.location.href + '&dock=true');  
          else if (theFile.match(".smil")) /// for live stream url
            so.addParam('flashvars','&file=' + theFile + '&autostart=true&type=highwinds&skin=../JWFlashPlayer/Skins/' + document.getElementById("hidPlayerSkin").value + '.swf&plugins=sharing-1&sharing.link=' + window.location.href + '&dock=true');  
          else if (document.getElementById("hidContentTypeID").value == 2) /// for flash alternative source
            so.addParam('flashvars','&file=' + theFile + '&autostart=true&skin=../JWFlashPlayer/Skins/' + document.getElementById("hidPlayerSkin").value + '.swf&plugins=sharing-1&sharing.link=' + window.location.href + '&dock=true');  
                           
          so.write('divPlayerContainer');  
                    
          window.scrollTo(0,document.getElementById('divPlayerContainer').scrollTop);
          return;
        }
        // CODE ENDS HERE TO CHECK FOR THE YOU TUBE VIDEO
        
        // Create a player object
        if (document.getElementById("hidPlayerTypeID").value == 1)  // JW PLAYER OBJECT
        {  
            sfileName = 'empty-1';    
            sfileName = theFile; // Assign the file 
            
            // PLAY THE PRE ROLL VIDEO
            if (preRollPath == "")
                SetVideo(sfileName, 'true', 1, 330, 400);    // Loads the Player    
            else
                SetVideo(preRollPath, 'false', 0, 330, 400);    // Loads the JW Player   
        }
        else if (document.getElementById("hidPlayerTypeID").value == 2) // OPEN VIDEO PLAYER OBJECT
        {    
            var playerObj = "<object data='data:application/x-silverlight-2,' type='application/x-silverlight-2' width='400px' height='330px' id='slp' style='z-index:-1' >"
                + "<param name='source' value='../OVP.xap'/>"
                + "<param name='minRuntimeVersion' value='2.0.30923.0' />"
                + "<param name='onerror' value='onSilverlightError' />"
                + "<param name='MaxFrameRate' value='30' />"
                + "<param name='Windowless' value='True' />"
                + "<param name='background' value='black' />"

                + "<param name='initparams' value='theme=../OVPThemes/" + document.getElementById("hidPlayerSkin").value + ".xaml,"
                + "showstatistics=false, autoplay=true, muted=false, playlistoverlay=false, stretchmode=Fit, stretchmodefullscreen=Fit,"
                + "playlist=" + filePath + "' />"
                + "<a href='http://go.microsoft.com/fwlink/?LinkID=124807' style='text-decoration: none;'>"
                + "<img src='http://go.microsoft.com/fwlink/?LinkId=108181' alt='Get Microsoft Silverlight' style='border-style: none'/></a>"
                + "</object>";
                //alert(playerObj);
            // Place the object in div tag
            document.getElementById("divPlayerContainer").innerHTML = playerObj; 
        }
        else if (document.getElementById("hidPlayerTypeID").value == 3) // WINDOWS MEDIA PLAYER OBJECT
        {            
            var playerObj = '<OBJECT ID="WMPlayer"  CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" WIDTH="400" HEIGHT="330" showstatusbar="True">'
                +'<PARAM NAME="AutoStart" VALUE="True" >'
                +'<PARAM NAME="stretchToFit" VALUE="True">'
                +' <PARAM NAME="URL" VALUE="'+ theFile +'">'
                +'<PARAM NAME="enableContextMenu" VALUE="False">'                   
                 +'<EMBED TYPE="application/x-mplayer2" '
                +'SRC="'+ theFile +'" '
                +'NAME="WMPlayer"'
                +'WIDTH="400"'
                +'HEIGHT="330"'
                +'EnableContextMenu="False"'
                +'AUTOSTART="True" showstatusbar="True"' 
                +'SHOWCONTROLS="True">'
                +'</EMBED>'
                +'</OBJECT>'; 
                
            // Place the object in div tag
            document.getElementById("divPlayerContainer").innerHTML = playerObj; 
        }
        else if (document.getElementById("hidPlayerTypeID").value == 4) // MM PLAYER OBJECT
        {      
             // CODE STARTS TO DISPLAY THE CHAPTERS     
//            if (theFile == 'http://vbricksys.edgeboss.net/wmedia/vbricksys/vbrick/vboss_temp_phase2/wbirchett_4049/snowtrainhigh.wvx')
//            {
//                //filePath = overallPath;
//                filePatches = {"mediaUrl": theFile,
//                           "placeholderImage": "http://www.vbossengage.com/EngageData//1612_Thumb_Edmonton_skyline.jpg",
//                           "chapters": [
//                           {"time": 12.1597653, "imageUrl": "http://www.vbossengage.com/EngageData//1204_Thumb_Burton4.jpg"},
//                           {"time": 36.1597653, "imageUrl": "http://www.vbossengage.com/EngageData//1204_Thumb_Hailer3.jpg"},
//                           {"time": 40.1597653, "imageUrl": "http://www.vbossengage.com/EngageData//1204_Thumb_Koontz.jpg"}                         
//                           ]};
//            }
            // CODE ENDS TO DISPLAY THE CHAPTERS     
            
             filePatches = {"mediaUrl": theFile,
                           "placeholderImage": "",
                           "chapters": []};

            var playerObj =  new StartPlayer_0();
            // Scroll to Top
            window.scrollTo(0,document.getElementById('divPlayerContainer').scrollTop);
            return playerObj;
        
//            // Place the object in div tag
     //       document.getElementById("divPlayerContainer").innerHTML = playerObj; 
        }                  
    }

    // HIDE THE btnVideo BUTTON
    document.getElementById("VideoDesc_btnVideo").style.display = "none"; 
    
    // Scroll to top
    window.scrollTo(0,document.getElementById('divPlayerContainer').scrollTop);
}


function SearchVideo()
{    
    if (document.getElementById("hidTemplateID").value == 5)
    {
        if (document.getElementById("txtSearch").value == '' && document.getElementById("ddlCategories").selectedIndex == "0")
        {
            alert('Enter Keyword / Select Category');
            document.getElementById('txtSearch').focus();
            return;
        }
            
         // Set search keyword
         if (document.getElementById("txtSearch").value == '')
         {
            document.getElementById("VOD_hidKeywords").value = "-1";   // SET THE DEFAULT VALUE
         }
         else
         {
            document.getElementById("VOD_hidKeywords").value = document.getElementById("txtSearch").value;   
         }
         
         if (document.getElementById("ddlCategories").selectedIndex == "0")
         {
            document.getElementById("VOD_hidCategoryKeywords").value = "0"; // SET THE DEFAULT VALUE
         }
         else
         {
            document.getElementById("VOD_hidCategoryKeywords").value = document.getElementById("ddlCategories").value; 
         }
         
        document.getElementById("txtSearch").value = '';
        document.getElementById("ddlCategories").selectedIndex = 0;
                
        // Change the title
        document.getElementById("divTitle").innerHTML = "Searched Video";
    }
    else if (document.getElementById("hidTemplateID").value == 6)
    {
        if (document.getElementById("txtSearch_SSP").value == '' && document.getElementById("ddlCategories_SSP").selectedIndex == "0")
        {
            alert('Enter Keyword / Select Category');
            document.getElementById('txtSearch_SSP').focus();
            return;
        }
            
         // Set search keyword
         if (document.getElementById("txtSearch_SSP").value == '')
         {
            document.getElementById("VOD_hidKeywords").value = "-1";   // SET THE DEFAULT VALUE
         }
         else
         {
            document.getElementById("VOD_hidKeywords").value = document.getElementById("txtSearch_SSP").value;   
         }
         
         if (document.getElementById("ddlCategories_SSP").selectedIndex == "0")
         {
            document.getElementById("VOD_hidCategoryKeywords").value = "0"; // SET THE DEFAULT VALUE
         }
         else
         {
            document.getElementById("VOD_hidCategoryKeywords").value = document.getElementById("ddlCategories_SSP").value; 
         }
         
        document.getElementById("txtSearch_SSP").value = '';
        document.getElementById("ddlCategories_SSP").selectedIndex = 0;    
            
        // Change the title
        document.getElementById("divTitle_SSP").innerHTML = "Searched Video";
    }
    
    // Set search video as the current play list area video
    document.getElementById("VOD_hidCurrentPlaylistStatus").value = "Search";    
    document.getElementById("VOD_hidClickedVideoStatus").value = "search";    
            
    // Display the video
    GoPage(1,1);
}

function ShowRequest()
{ 
    // Hide the Player Div tag
    document.getElementById("divPlayerContainer").style.display = "none";
    
    var VideoLineUpID = document.getElementById("VideoDesc_hidLineUpID").value;
    
    var oWindow = window.radopen("../syndicationRequest.aspx?UserID=" + document.getElementById("hidAccountID").value + "&PlayerID=" + document.getElementById("hidPlayerID").value + "&VideoLineUpID=" + VideoLineUpID,"rwWindow");
    //Using the reference to the window its clientside methods can be called  
    oWindow.SetSize(500,400);
    oWindow.center();
    oWindow.add_close(OnSyndicateClose);
    return false;
}


function OnSyndicateClose(oWnd)
{           
    // Display the Player Div tag
    if (document.getElementById("divVideo").style.display == "none")
        document.getElementById("divPlayerContainer").style.display = "block";
        
    // Hide the payment info Div tag
    if (document.getElementById("divPlayerContainer").style.display == "block")
        document.getElementById("divVideo").style.display = "none";
}

function ShowFeedback()
{ 
    // Hide the Player Div tag
    document.getElementById("divPlayerContainer").style.display = "none";
        
    var oWindow = window.radopen("../feedback.aspx?UserID=" + document.getElementById("hidAccountID").value,"rwWindow");
    //Using the reference to the window its clientside methods can be called  
    oWindow.SetSize(500,450);
    oWindow.center();
    oWindow.add_close(OnFeedbackClose);
    return false;
}


function OnFeedbackClose(oWnd)
{           
    // Display the Player Div tag
    if (document.getElementById("divVideo").style.display == "none")
        document.getElementById("divPlayerContainer").style.display = "block";
        
    // Hide the payment info Div tag
    if (document.getElementById("divPlayerContainer").style.display == "block")
        document.getElementById("divVideo").style.display = "none";
}


function OpenCommentWindow()
{  		    
    // Hide the Player Div tag
    document.getElementById("divPlayerContainer").style.display = "none";
        
    var liveEvent = "false";
    if ((document.getElementById("VideoDesc_hidClickedVideoStatus").value == "live") || (document.getElementById("VideoDesc_hidClickedVideoStatus").value == "fv_live"))
        liveEvent = "true";
        
    var oWindow = window.radopen("../VideoComments.aspx?videoID=" + document.getElementById("VideoDesc_hidClickedVideoID").value + "&liveEvent=" + liveEvent,"rwWindow");
    //Using the reference to the window its clientside methods can be called  
    oWindow.SetSize(700,600);
    oWindow.center();
    oWindow.add_close(OnCommentsClose);
    return false;
}

function OnCommentsClose(oWnd)
{           
    // Display the Player Div tag
    if (document.getElementById("divVideo").style.display == "none")
        document.getElementById("divPlayerContainer").style.display = "block";
        
    // Hide the payment info Div tag
    if (document.getElementById("divPlayerContainer").style.display == "block")
        document.getElementById("divVideo").style.display = "none";
}


function RateVideo(starValue)
{
    if (document.getElementById("hidEndUserID").value <= 0)
    {
        alert('Login to rate the video');
        if (document.getElementById("hidTemplateID").value > 1)
        {
            document.getElementById('Header_txtUserName').focus();
        } 
        return;
    }
    else
    {
        document.getElementById("VideoDesc_hidHiddenStars").value = starValue;    
        document.getElementById("VideoDesc_btnRating").style.display = "block";       
        document.frmIndex.VideoDesc_btnRating.click();     
    }    
}

function BackToVOD()
{       
    // Change the title
    if (document.getElementById("hidTemplateID").value == 5)
        document.getElementById("divTitle").innerHTML = "Video on Demand";
    
    if (document.getElementById("hidTemplateID").value == 6)
        document.getElementById("divTitle_SSP").innerHTML = "Video on Demand";
     
    if (document.getElementById("hidTemplateID").value == 8)
    {   
        var link=document.getElementById("lnk_VOD_VPC");   
        link.innerHTML = "Video On Demand";
    }
     
    // Set playlist video as the current play list area video
    document.getElementById("VOD_hidCurrentPlaylistStatus").value = "Playlist";    
    document.getElementById("VOD_hidClickedVideoStatus").value = "playlist"; 
    
    // Display the playlist
    GoPage(1,1);        
}

function CreateDynamicPagingControls(totalPage, endPage, pageDesc)
{    
  if (totalPage == 0)
  {  
     document.getElementById("VOD_divPageDesc").innerHTML = '&nbsp;&nbsp;&nbsp;';   
     return;
  } 
  
  var divParent = document.getElementById('VOD_divPagingValues');
  divParent.innerHTML = "";  
  document.getElementById("VOD_divPageDesc").innerHTML = '(' + pageDesc + ')'; 
     
  if ((document.getElementById("hidTemplateID").value < 8) && (document.getElementById("VOD_hidCurrentPlaylistStatus").value == "Search"))
  {
     document.getElementById("VOD_divPageDesc").innerHTML += '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
     document.getElementById("VOD_divPageDesc").innerHTML += '<a id=\'lnkBackVOD\' onmouseover=\'javascript:ApplyForeColor(this.id);\' onmouseout=\'javascript:UnloadForeColor(this.id);\' href=\'javascript://\' onclick=\'BackToVOD()\'>Back To VOD</a>';      
  }
   
  if (totalPage == 1)
  {        
     divParent.innerHTML = "Page: 1";
     document.getElementById("VOD_btnGoPage").style.display = "none";
     return;
  }
  
  var startPage = (parseInt(endPage)-2);
  var endingPage = parseInt(endPage);  
    
  if (totalPage == 2)
  {        
     startPage = 1;
  }
  
  if (parseInt(startPage)>1)
  {     
     // document.getElementById("hidPageDisplay_4").value = (parseInt(endingPage)+3);
      // create div for next 3 button
      var newdiv = document.createElement('div_'+ (parseInt(startPage)-1));
      var divIdName = 'vod_my_'+(parseInt(startPage)-1)+'+Div';
      newdiv.setAttribute('id',divIdName);
      
      // create link with href tag
      var value = 0;// for prev button
      newdiv.innerHTML = '<a href=\'javascript://\' onclick=\'GoPage('+ (parseInt(startPage)-1) +','+ value +')\'>Prev</a>' + '&nbsp';
      
      divParent.appendChild(newdiv);
    
  }
  
  for (var i=startPage; i<=endingPage; i++) 
  {    
//      if (i==startPage)
//      {        
//         divParent.innerHTML = "Page: ";
//      }
      
      var newdiv = document.createElement('div_'+ i);
      var divIdName = 'vod_my_'+i+'+Div';
      newdiv.setAttribute('id',divIdName);
      
      // check for current page 
      var currentPage = document.getElementById("VOD_hidCurrentPageNo").value;        
      if (currentPage == i)
      {  
        // create link without href tag
        newdiv.innerHTML = i + '&nbsp';      
      }
      else
      {
        // create link with href tag
        var value = 1;// for paging button
        newdiv.innerHTML = '<a id=\'lnkVODPage_' + i + '\' onmouseover=\'javascript:ApplyForeColor(this.id);\' onmouseout=\'javascript:UnloadForeColor(this.id);\' href=\'javascript://\' onclick=\'GoPage('+ i +','+ value +')\'>' + i + '</a>' + '&nbsp';      
        
      }
      
      divParent.appendChild(newdiv);
  }
  if (parseInt(totalPage)>parseInt(endPage))
  {     
     // document.getElementById("hidPageDisplay_4").value = (parseInt(endingPage)+3);
      // create div for next 3 button
      var newdiv = document.createElement('div_'+ (parseInt(endPage)+1));
      var divIdName = 'vod_my_'+(parseInt(endPage)+1)+'+Div';
      newdiv.setAttribute('id',divIdName);
      
      // create link with href tag
      var value = 2; // for next button
      newdiv.innerHTML = '<a href=\'javascript://\' onclick=\'GoPage('+ (parseInt(endPage)+1) +','+ value +')\'>Next</a>';
      
      divParent.appendChild(newdiv);
    
  }
  
  document.getElementById("VOD_btnGoPage").style.display = "none";
}

function RemoveDynamicPagingControls(totalPage, endPage)
{   
  if (totalPage == 0)
     return;
        
  // Remove the existing Dynamic Paging COntrols
  var startPage = (parseInt(endPage)-2);
  var endingPage = parseInt(endPage);  
  var divParent = document.getElementById("VOD_divPagingValues");
  var olddiv;
        
  if (totalPage == 2)
  {        
     startPage = 1;
  }
  
    // Remove the prev button
  if (parseInt(startPage)>1)
  {           
      olddiv = document.getElementById('vod_my_'+(parseInt(startPage)-1)+'+Div');
      divParent.removeChild(olddiv);    
  }
  // Remove the paging
  for (var i=startPage; i<=endingPage; i++) 
  {   
      olddiv = document.getElementById('vod_my_'+i+'+Div');
      if (olddiv != null)
        divParent.removeChild(olddiv);
  }
  // remove for next 3 pages  
  if (parseInt(totalPage)>parseInt(endPage))
  {    
      olddiv = document.getElementById('vod_my_'+(parseInt(endingPage)+1)+'+Div');
      divParent.removeChild(olddiv);
  }
}

function GoPage(selectedPage, selectedPageStatus)
{    
    document.getElementById("VOD_hidClickedPageNo").value = selectedPage;
            
    document.getElementById("VOD_hidPageClickedStatus").value = selectedPageStatus;
        
    document.getElementById("VOD_btnGoPage").style.display = "block";
    
    document.frmIndex.VOD_btnGoPage.click();      
}


function CreateDynamicPagingControls_All(totalPage, endPage, pageDesc)
{    
  if (totalPage == 0)
  {  
     document.getElementById("AllVideo_divPageDesc").innerHTML = '&nbsp;&nbsp;&nbsp;';   
     return;
  }
  var divParent = document.getElementById('AllVideo_divPagingValues');
    
  document.getElementById("AllVideo_divPageDesc").innerHTML = '(' + pageDesc + ')'; 
     
  if (totalPage == 1)
  {        
     divParent.innerHTML = "Page: 1";
     document.getElementById("AllVideo_btnGoPage").style.display = "none";
     return;
  }
  
  var startPage = (parseInt(endPage)-2);
  var endingPage = parseInt(endPage);  
    
  if (totalPage == 2)
  {        
     startPage = 1;
  }
  
  if (parseInt(startPage)>1)
  {     
     // document.getElementById("hidPageDisplay_4").value = (parseInt(endingPage)+3);
      // create div for next 3 button
      var newdiv = document.createElement('div_'+ (parseInt(startPage)-1));
      var divIdName = 'av_my_'+(parseInt(startPage)-1)+'+Div';
      newdiv.setAttribute('id',divIdName);
      
      // create link with href tag
      var value = 0;// for prev button
      newdiv.innerHTML = '<a href=\'javascript://\' onclick=\'GoPageAll('+ (parseInt(startPage)-1) +','+ value +')\'>Prev</a>' + '&nbsp';
      
      divParent.appendChild(newdiv);
    
  }
  
  for (var i=startPage; i<=endingPage; i++) 
  {    
//      if (i==startPage)
//      {        
//         divParent.innerHTML = "Page: ";
//      }
      
      var newdiv = document.createElement('div_'+ i);
      var divIdName = 'av_my_'+i+'+Div';
      newdiv.setAttribute('id',divIdName);
      
      // check for current page 
      var currentPage = document.getElementById("AllVideo_hidCurrentPageNo").value;        
      if (currentPage == i)
      {  
        // create link without href tag
        newdiv.innerHTML = i + '&nbsp';      
      }
      else
      {
        // create link with href tag
        var value = 1;// for paging button
        newdiv.innerHTML = '<a id=\'lnkAVPage_' + i + '\' onmouseover=\'javascript:ApplyForeColor(this.id);\' onmouseout=\'javascript:UnloadForeColor(this.id);\' href=\'javascript://\' onclick=\'GoPageAll('+ i +','+ value +')\'>' + i + '</a>' + '&nbsp';      
        
      }
      
      divParent.appendChild(newdiv);
  }
  if (parseInt(totalPage)>parseInt(endPage))
  {     
     // document.getElementById("hidPageDisplay_4").value = (parseInt(endingPage)+3);
      // create div for next 3 button
      var newdiv = document.createElement('div_'+ (parseInt(endPage)+1));
      var divIdName = 'av_my_'+(parseInt(endPage)+1)+'+Div';
      newdiv.setAttribute('id',divIdName);
      
      // create link with href tag
      var value = 2; // for next button
      newdiv.innerHTML = '<a href=\'javascript://\' onclick=\'GoPageAll('+ (parseInt(endPage)+1) +','+ value +')\'>Next</a>';
      
      divParent.appendChild(newdiv);
    
  }
  
  document.getElementById("AllVideo_btnGoPage").style.display = "none";
}

function RemoveDynamicPagingControls_All(totalPage, endPage)
{  
  if (totalPage == 0)
     return;
        
  // Remove the existing Dynamic Paging COntrols
  var startPage = (parseInt(endPage)-2);
  var endingPage = parseInt(endPage);  
  var divParent = document.getElementById("AllVideo_divPagingValues");
  var olddiv;
        
  if (totalPage == 2)
  {        
     startPage = 1;
  }
  
    // Remove the prev button
  if (parseInt(startPage)>1)
  {           
      olddiv = document.getElementById('av_my_'+(parseInt(startPage)-1)+'+Div');
      divParent.removeChild(olddiv);    
  }
  // Remove the paging
  for (var i=startPage; i<=endingPage; i++) 
  {   
      olddiv = document.getElementById('av_my_'+i+'+Div');
      divParent.removeChild(olddiv);
  }
  // remove for next 3 pages  
  if (parseInt(totalPage)>parseInt(endPage))
  {    
      olddiv = document.getElementById('av_my_'+(parseInt(endingPage)+1)+'+Div');
      divParent.removeChild(olddiv);
  }
}

function GoPageAll(selectedPage, selectedPageStatus)
{    
    document.getElementById("AllVideo_hidClickedPageNo").value = selectedPage;
            
    document.getElementById("AllVideo_hidPageClickedStatus").value = selectedPageStatus;
        
    document.getElementById("AllVideo_btnGoPage").style.display = "block";
     
    document.frmIndex.AllVideo_btnGoPage.click();      
}


function CreateDynamicSchedulerPagingControls(totalPage, pageDesc)
{  
  if (totalPage == 0)
  {
     //document.getElementById("divPageDesc").innerHTML = '&nbsp;No Video Available';   
     document.getElementById("div_SchPageDesc").innerHTML = '&nbsp;&nbsp;&nbsp;'; 
     return;
  }
  var divParent = document.getElementById('divSch_PagingValues');
    
  document.getElementById("div_SchPageDesc").innerHTML = '&nbsp;(' + pageDesc + ')'; 
     
  for (var i=1; i<=totalPage; i++) 
  { 
      var newdiv = document.createElement('div_'+ i);
      var divIdName = 'mySch_'+i+'+Div';
      newdiv.setAttribute('id',divIdName);
      
      // check for current page 
      var schCurrentPage = document.getElementById("Schedule_hidSch_CurrentPageNo").value; 
                
      if (schCurrentPage == i)
      {  
        // create link without href tag
        newdiv.innerHTML = i + '&nbsp';      
      }
      else
      {
        // create link with href tag
        newdiv.innerHTML = '<a id=\'lnkSchPage_' + i + '\' onmouseover=\'javascript:ApplyForeColor(this.id);\' onmouseout=\'javascript:UnloadForeColor(this.id);\' href=\'javascript://\' onclick=\'GoSchedulerPage('+ i +')\'>' + i + '</a>' + '&nbsp';      
      }
      
      divParent.appendChild(newdiv);
  }
      
  document.getElementById("Schedule_btnSch_GoPage").style.display = "none";
    
}

function RemoveDynamicSchedulerPagingControls(totalPage)
{ 
  if (totalPage == 0)
     return;
        
  // Remove the existing Dynamic Paging COntrols
  var divParent = document.getElementById("divSch_PagingValues");
  for (var i=1; i<=totalPage; i++) 
  { 
      var olddiv = document.getElementById('mySch_'+i+'+Div');
      divParent.removeChild(olddiv);
  }
  
}

/// Plays the mentioned file from the live event for PUBLISHER
function LiveEventPlayIt(selectedUserID, selectedVideoID, option)
{      
    if (selectedUserID > 0)
    {
        document.getElementById("Schedule_hidClickedLiveEventChannelID").value = selectedUserID;
        document.getElementById("VideoDesc_hidClickedScheduleChannelID").value = document.getElementById("Schedule_hidClickedLiveEventChannelID").value;
        // Call the play it function    
        PlayIt(selectedVideoID, option, 0);
    }
    else
        alert('Live Stream Not Available');
}

function GoSchedulerPage(selectedPage)
{   
    document.getElementById("Schedule_hidSch_ClickedPageNo").value = selectedPage;
            
    document.getElementById("Schedule_btnSch_GoPage").style.display = "block";
    
    document.frmIndex.Schedule_btnSch_GoPage.click(); 
}

function DynamicRatingStars(totalRating)
{  
  var myStars=new Array("Poor","Good","VeryGood","Excellent","Awesome");
    
  var divRatingParent = document.getElementById('divRating');
              
  divRatingParent.innerHTML += "Ratings: ";
      
  // LOOP FOR TOTAL RATING DISPLAY  
  for (var i=1; i<=totalRating; i++) 
  { 
      var alreadyRatingdiv = document.createElement('div_'+ i);
      var divIdName = 'myExistingRating_'+i+'+Div';
      alreadyRatingdiv.setAttribute('id',divIdName);          
      alreadyRatingdiv.setAttribute('class','vlignm');
                 
      var imgExistingStars = "imgExistingStars" + i; 
      
      // create stars
      alreadyRatingdiv.innerHTML = "<img src=\"../Images/Index_Custom_1/star_r.png\" border=\"0\" alt=\"" + myStars[totalRating-1] + "\" name=\"" + imgExistingStars + "\">";
      divRatingParent.appendChild(alreadyRatingdiv);
  }   
  
  // CHECK FOR USER LOGGED IN OR NOT
  if (document.getElementById("hidEndUserID").value != 0)
  { 
      divRatingParent.innerHTML += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Rate this video: ";
          
      // LOOP FOR CURRENT RATING DISPLAY  
      for (var j=1; j<=5; j++) 
      { 
          var newRatingdiv = document.createElement('div_'+ j);
          var divIdName = 'myNewRating_'+j+'+Div';
          newRatingdiv.setAttribute('id',divIdName);          
          //newRatingdiv.setAttribute('class','stars');
                     
          var imgNewStars = "imgNewStars" + j; 
          
          // create stars
          newRatingdiv.innerHTML = "<a href=\"javascript://\" onclick=\"RateVideo(" + j + ")\" onmouseover=\"document." + imgNewStars + ".src='../Images/Index_Custom_1/star_g.png'\" onmouseout=\"document." + imgNewStars + ".src='../Images/Index_Custom_1/star_w.png'\"><img src=\"../Images/Index_Custom_1/star_w.png\" border=\"0\" alt=\"" + myStars[j-1] +"\" name=\"" + imgNewStars + "\"></a>";
          divRatingParent.appendChild(newRatingdiv);
      }   
  }
  else
  {
    divRatingParent.innerHTML += "&nbsp;&nbsp;&nbsp;&nbsp;<a id='lnkLoginRate' href='javascript://' onclick='OpenLoginWindow();'><span id='spanLnkLoginRate' class='hrefRateLogin' onmouseover='javascript:ApplyHref(this.id);' onmouseout='javascript:UnloadHref(this.id);'><u>Login to rate this video</u></span></a>";
    
    // HREF class  
    if (document.getElementById("hidEnableRating").value == "True")
        document.getElementsByClassName("hrefRateLogin")[0].style.color = document.getElementById("hidFontColor").value;
  }
     
}

function AlreadyRated(rating,totalRating)
{    
  var divRatingParent = document.getElementById('divRating');
              
  divRatingParent.innerHTML = "Total Rating: ";
      
  // rating    
  for (var i=1; i<=totalRating; i++) 
  { 
      var newRatingdiv = document.createElement('div_'+ i);
      var divIdName = 'myrating_'+i+'+Div';
      newRatingdiv.setAttribute('id',divIdName);          
      //newRatingdiv.setAttribute('class','stars');
                 
      var imgRatedStars = "imgRatedStars" + i; 
      
      // create stars
      newRatingdiv.innerHTML = "<img src=\"../Images/Index_Custom_1/star_r.png\" border=\"0\" alt=\"You have already rated " + rating + " stars to this video\" name=\"" + imgRatedStars + "\">";
      divRatingParent.appendChild(newRatingdiv);
  }        
  
  
  divRatingParent.innerHTML += "&nbsp;&nbsp;&nbsp;&nbsp;<b>You have already rated this video</b>";
}


function ShareVideo()
{    
    if (document.getElementById("Web_txtFromMail").value == '')
    {
        alert("Enter Your EmailID");
        document.getElementById('Web_txtFromMail').focus();
        return;
    }    
    if (isEmail(document.getElementById('Web_txtFromMail').value)==false)
    {
        alert("Please Enter a Valid Email ID and Continue !!");
        document.getElementById('Web_txtFromMail').select();
        return;
    }
      
    if (document.getElementById("Web_txtToMail").value == '')
    {
        alert("Enter Your Friend EmailID");
        document.getElementById('Web_txtToMail').focus();
        return;
    }    
    if (isEmail(document.getElementById('Web_txtToMail').value)==false)
    {
        alert("Please Enter a Valid Email ID and Continue !!");
        document.getElementById('Web_txtToMail').select();
        return;
    }
    if (document.getElementById("Web_txtMessage").value == '')
    {
        alert("Enter Message");
        document.getElementById('Web_txtMessage').focus();
        return;
    }   
    
    document.getElementById("Web_hidViewingVideoID").value = document.getElementById("VideoDesc_hidClickedVideoID").value;
    document.getElementById("Web_hidViewingLineUpID").value = document.getElementById("VideoDesc_hidLineUpID").value;
    document.getElementById("Web_hidViewingVideoStatus").value = document.getElementById("VideoDesc_hidClickedVideoStatus").value;
    
    document.getElementById("Web_btnShare").style.display = "block";
    
    document.frmIndex.Web_btnShare.click();     
}

function SendMailSuccess()
{
     // Hide the dummy button
    document.getElementById("Web_btnShare").style.display = "none";
    // Confirm Message
    document.getElementById("Web_txtFromMail").value = "";
    document.getElementById("Web_txtToMail").value = "";
    document.getElementById("Web_txtMessage").value = "";

    alert("Mail Sent Successfully");
}


function SendMailFailed()
{        
    // Hide the dummy button
    document.getElementById("Web_btnShare").style.display = "none";
    
    alert("Send mail failed, Try again.");
}

function CommentVideo()
{    
    if (document.getElementById("Web_txtComments").value == '')
    {
        alert("Enter Your Comments");
        document.getElementById('Web_txtComments').focus();
        return;
    }    
        
    document.getElementById("Web_hidViewingVideoID").value = document.getElementById("VideoDesc_hidClickedVideoID").value; 
    document.getElementById("Web_hidViewingVideoStatus").value = document.getElementById("VideoDesc_hidClickedVideoStatus").value;
    document.getElementById("Web_hidViewingUpcomingEventID").value = document.getElementById("VideoDesc_hidClickedUpcomingEventID").value;
    
    document.getElementById("Web_btnComments").style.display = "block";
    
    document.frmIndex.Web_btnComments.click();     
    
    document.getElementById("Web_btnComments").style.display = "none";
}


// ***** CODE STARTS FOR CHECKING THE COMMENT ********
function CommunityFeatures(commentExists)
{
   if ((document.getElementById("hidTemplateID").value == 5) || (document.getElementById("hidTemplateID").value == 6))
   {
       if (commentExists == "true")
       {
           //Hide & Unhide the controls
           document.getElementById("div_CommentsSignIn").style.display = "none";
           document.getElementById("div_Comments").style.display = "none";
           document.getElementById("div_CommentsDone").style.display = "block";
       }
       else
       {       
           //Hide & Unhide the controls
           if (document.getElementById("hidLoginStatus").value == 'Logged-In')
            {
                document.getElementById("div_CommentsSignIn").style.display = "none";
                document.getElementById("div_Comments").style.display = "block";
                document.getElementById("div_CommentsDone").style.display = "none";
            }
            else
            {
                document.getElementById("div_CommentsSignIn").style.display = "block";
                document.getElementById("div_Comments").style.display = "none";
                document.getElementById("div_CommentsDone").style.display = "none";        
            }
       }
          
       document.getElementById("Web_btnComments").style.display = "none";
   }
 }
 
// ***** CODE ENDS FOR CHECKING THE COMMENT *******
   
   
// PLAY THE VIDEO IN JW PLAYER
function SetVideo(fileValue, showNav, flag, pHeight, pWidth) 
{   
    
    var cnt = document.getElementById("divPlayerContainer");
    var src = '../wmvplayer.xaml';
    var cfg = {
	    file: fileValue,
	    autostart: 'true',
	    repeat: 'false',
	    height: pHeight,
	    width: pWidth,
	    backcolor:'000000',
	    frontcolor:'cccccc',
	    lightcolor:'660000',
	    shownavigation: showNav
    };
	
    plyValue = new jeroenwijering.Player(cnt,src,cfg);
    //alert(document.getElementById("divPlayerContainer").innerHTML);
    if (flag == 0) // 0 refers PRE-ROLL , 1 refers SELECTED VIDEO
    {
        addListeners(); // Check for the pre roll duration (to start the real file)
    }	
    
}


// ****************CODE STARTS HERE TO CHECK THE JW PLAYER EVENTS**************

function addListeners() 
{
	if(plyValue.view) 
	{
		plyValue.addListener('TIME',timeUpdate);
		//plyValue.addListener('VOLUME',volumeUpdate);
		//plyValue.addListener('LOAD',loadUpdate);
		plyValue.addListener('STATE',stateUpdate);
		//plyValue.addListener('BUFFER',bufferUpdate);
	} 
	else 
	{
		setTimeout("addListeners()",1000);
	}
}
// These are the event listeners

function timeUpdate(pos,dur) { 
	currentPosition = pos;
	//var tmp = document.getElementById("time"); 
	//if (tmp) { tmp.innerHTML = "<b>Position:</b> "+pos+", <b>duration:</b> "+dur; } 
}

function stateUpdate(ost,nst) {
	currentState = nst;
	//var tmp = document.getElementById("state");
	//if (tmp) { tmp.innerHTML = "<b>Old state:</b> "+ost+", <b>new state:</b> "+nst; }
	if (ost == 'Completed')
	    {
	       if (document.getElementById("hidTemplateID").value == 0)
           { 
	         // Loads the Player
	         SetVideo(sfileName, 'true', 1, 192, 234);    // PLAYS THE REAL SELECTED FILE..
	       }
	       else if (document.getElementById("hidTemplateID").value > 0)
           { 
	         // Loads the Player
	         SetVideo(sfileName, 'true', 1, 400, 620);    // PLAYS THE REAL SELECTED FILE..
	       }
	    }
} 
function bufferUpdate(pct) {
	currentBuffer = pct;
	var tmp = document.getElementById("buffer"); 
	if (tmp) { tmp.innerHTML = "<b>Buffer:</b> "+pct; }
}
function volumeUpdate(vol) {
	currentVolume = vol;
	var tmp = document.getElementById("volume"); 
	if (tmp) { tmp.innerHTML = "<b>Volume:</b> " + vol; } 
}
function loadUpdate(ldd) { 
	currentLoad = ldd;
	var tmp = document.getElementById("load"); 
	if (tmp) { tmp.innerHTML = "<b>Load:</b> " + ldd; } 
}
function printConfig() {
	var cfg = player.getConfig();
	var txt = '';
	for(var itm in cfg) { 
		txt += '<li>'+itm+': '+cfg[itm]+'</li>';
	}
	var tmp = document.getElementById("config");
	if (tmp) { tmp.innerHTML = txt; }
	
}
// ****************CODE ENDS HERE TO CHECK THE JW PLAYER EVENTS**************

// ************************ MM PLAYER CODE STARTS HERE **********************************
    

function StartPlayer_0(parentId) {  
    
    var playerWidth = "620px";
    var playerHeight = "400px";
    
    if (document.getElementById("hidTemplateID").value == 0)
    {
        playerWidth = "234px";
        playerHeight = "192px";
    }
    
    if ((parseInt(document.getElementById("hidTemplateID").value) >= 6) && (parseInt(document.getElementById("hidTemplateID").value) >= 7))
    {
        playerWidth = "450px";
        playerHeight = "350px";
    }
    
    if (document.getElementById("hidTemplateID").value == 8)
    {
        playerWidth = "400px";
        playerHeight = "330px";
    }
    
    this._hostname = EePlayer.Player._getUniqueName("xamlHost");
    Silverlight.createObjectEx( {   source: '../MMPlayer/player.xaml', 
                                        parentElement: document.getElementById("divPlayerContainer"), 
                                        id:this._hostname, 
                                        properties:{ width: playerWidth, height: playerHeight, version:'1.0', background:'#FF000000', isWindowless:'false' }, 
                                        events:{ onLoad:Function.createDelegate(this, this._handleLoad) } } );    
    //alert(document.getElementById("divPlayerContainer").innerHTML);
}
StartPlayer_0.prototype= {
    _handleLoad: function(plugIn) { 
        this._player = $create(   ExtendedPlayer.Player, 
                                  { // properties
                                    autoPlay    : true, 
                                    volume      : 1.0,
                                    muted       : false
                                  }, 
                                  { // event handlers
                                    mediaEnded: Function.createDelegate(this, this._onMediaEnded),
                                    mediaFailed: Function.createDelegate(this, this._onMediaFailed)
                                   // FullScreenChange: Function.createDelegate(this, this._onFullScreenChange)
                                  },
                                  null, $get(this._hostname)  ); 
	   //alert(filePatches);
       this._player.set_mediainfo(filePatches);    
    },

	_rollOver: function(sender, eventArgs) {
		sender.opacity=1;
   },
   
    _rollOut: function(sender, eventArgs) {
		sender.opacity=0.74;
   },     
    _onMediaEnded: function(sender, eventArgs) {
        //window.setTimeout( Function.createDelegate(this, this._playNextVideo), 1000);
    },
    _onMediaFailed: function(sender, eventArgs) {
        //alert(String.format( Ee.UI.Xaml.Media.Res.mediaFailed, this._player.get_mediaUrl() ) );
        alert(String.format( Ee.UI.Xaml.Media.Res.mediaFailed, 'Please Try Again' ) );
    }
}

//function LoadPlayers()
//{   
//    //filePath = overallPath;
//    filePath = {"mediaUrl": "http://vbricksys.edgeboss.net/wmedia/vbricksys/vbrick/vbricktv/tedgtv_638/seminar.wvx",
//               "placeholderImage": "http://www.thejamesbondmovies.com/Images/Mission1.png",
//               "chapters": [
//               {"time": 12.1597653, "imageUrl": "http://www.vbossengage.com/EngageData//jackonwhsasdsdesel1s.wmv_267.jpg"},  
//               {"time": 31.1597653, "imageUrl": "http://www.vbossengage.com/EngageData//1329_Thumb_all.png"},
//               {"time": 45.1597653, "imageUrl": "http://www.vbossengage.com/EngageData//1329_Thumb_asset_library.png"}
//               ]};
//           
//    return new StartPlayer_0();
//}
 
 
 // ************************ MM PLAYER CODE ENDS HERE **********************************
 
// ***************** CODE STATS HERE - TO CHANGE THE STYLE SHEET DYNAMICALLY  ******************

// FUNCTION TO CHANGE THE TAB STATUS (for web 2.0 features)
function changeStatus(myid)
{   
    if (myid == 'lnkChat')
    {                       
        //document.getElementById("lnkShare").style.backgroundColor = document.getElementById("hidForeColor").value;     
        document.getElementById("lnkChat").onmouseout = function(){
                 this.style.backgroundColor= document.getElementById("hidForeColor").value;    
                   };      
                   
        document.getElementById("lnkShare").style.background= "url('../../Images/PortalImages/shade1.png')";
        document.getElementById("lnkShare").onmouseout = function(){
         this.style.background= "url('../../Images/PortalImages/shade1.png')";  
           };  
                                          
        document.getElementById("lnkComment").style.background= "url('../../Images/PortalImages/shade1.png')"; 
        document.getElementById("lnkComment").onmouseout = function(){
         this.style.background= "url('../../Images/PortalImages/shade1.png')";  
           };                
    }
    else if (myid == 'lnkShare')
    {
        document.getElementById("lnkChat").style.background= "url('../../Images/PortalImages/shade1.png')";
        document.getElementById("lnkChat").onmouseout = function(){
         this.style.background= "url('../../Images/PortalImages/shade1.png')";  
           };  
           
        //document.getElementById("lnkShare").style.backgroundColor = document.getElementById("hidForeColor").value;     
        document.getElementById("lnkShare").onmouseout = function(){
                 this.style.backgroundColor= document.getElementById("hidForeColor").value;    
                   };      
                   
        document.getElementById("lnkComment").style.background= "url('../../Images/PortalImages/shade1.png')"; 
        document.getElementById("lnkComment").onmouseout = function(){
         this.style.background= "url('../../Images/PortalImages/shade1.png')";  
           };  
                            
    }
    else if (myid == 'lnkComment')
    {
       
        document.getElementById("lnkChat").style.background= "url('../../Images/PortalImages/shade1.png')";
        document.getElementById("lnkChat").onmouseout = function(){
         this.style.background= "url('../../Images/PortalImages/shade1.png')";  
           };  
                   
        document.getElementById("lnkShare").style.background= "url('../../Images/PortalImages/shade1.png')"; 
        document.getElementById("lnkShare").onmouseout = function(){
         this.style.background= "url('../../Images/PortalImages/shade1.png')";  
           };                    
           
        //document.getElementById("lnkShare").style.backgroundColor = document.getElementById("hidForeColor").value;     
        document.getElementById("lnkComment").onmouseout = function(){
                 this.style.backgroundColor= document.getElementById("hidForeColor").value;    
                   };      
           
    }
}

// FUNCTION TO CHANGE THE TAB STATUS (for top tabs)
function changeTabStatus(myid)
{   
    if (myid == 'lnkHome')
    {                      
        //document.getElementById("lnkShare").style.backgroundColor = document.getElementById("hidForeColor").value;     
        document.getElementById("lnkHome").onmouseout = function(){
                 this.style.backgroundColor= document.getElementById("hidForeColor").value;    
                   };      
                   
        if ((document.getElementById("hidLiveTabExists").value == "true") || (document.getElementById("hidLiveTabExists").value == "offair"))
        {           
            document.getElementById("lnkLive").style.background= "url('../../Images/PortalImages/shade1.png')";
            document.getElementById("lnkLive").onmouseout = function(){
             this.style.background= "url('../../Images/PortalImages/shade1.png')";  
               };  
        }
                                          
        document.getElementById("lnkSchedule").style.background= "url('../../Images/PortalImages/shade1.png')"; 
        document.getElementById("lnkSchedule").onmouseout = function(){
         this.style.background= "url('../../Images/PortalImages/shade1.png')";  
           };        
                                
        document.getElementById("lnkAllVideo").style.background= "url('../../Images/PortalImages/shade1.png')"; 
        document.getElementById("lnkAllVideo").onmouseout = function(){
         this.style.background= "url('../../Images/PortalImages/shade1.png')";  
           };                
    }
    else if (myid == 'lnkLive')
    {
        document.getElementById("lnkHome").style.background= "url('../../Images/PortalImages/shade1.png')";
        document.getElementById("lnkHome").onmouseout = function(){
         this.style.background= "url('../../Images/PortalImages/shade1.png')";  
           };  
           
        //document.getElementById("lnkShare").style.backgroundColor = document.getElementById("hidForeColor").value;     
        document.getElementById("lnkLive").onmouseout = function(){
                 this.style.backgroundColor= document.getElementById("hidForeColor").value;    
                   };      
                               
        document.getElementById("lnkSchedule").style.background= "url('../../Images/PortalImages/shade1.png')"; 
        document.getElementById("lnkSchedule").onmouseout = function(){
         this.style.background= "url('../../Images/PortalImages/shade1.png')";  
           };        
                                
        document.getElementById("lnkAllVideo").style.background= "url('../../Images/PortalImages/shade1.png')"; 
        document.getElementById("lnkAllVideo").onmouseout = function(){
         this.style.background= "url('../../Images/PortalImages/shade1.png')";  
           };       
                            
    }
    else if (myid == 'lnkSchedule')
    {
       
        document.getElementById("lnkHome").style.background= "url('../../Images/PortalImages/shade1.png')";
        document.getElementById("lnkHome").onmouseout = function(){
         this.style.background= "url('../../Images/PortalImages/shade1.png')";  
           };  
        
        if ((document.getElementById("hidLiveTabExists").value == "true") || (document.getElementById("hidLiveTabExists").value == "offair"))
        {           
            document.getElementById("lnkLive").style.background= "url('../../Images/PortalImages/shade1.png')"; 
            document.getElementById("lnkLive").onmouseout = function(){
             this.style.background= "url('../../Images/PortalImages/shade1.png')";  
               };                    
        }
           
        //document.getElementById("lnkShare").style.backgroundColor = document.getElementById("hidForeColor").value;     
        document.getElementById("lnkSchedule").onmouseout = function(){
                 this.style.backgroundColor= document.getElementById("hidForeColor").value;    
                   };      
                      
        document.getElementById("lnkAllVideo").style.background= "url('../../Images/PortalImages/shade1.png')"; 
        document.getElementById("lnkAllVideo").onmouseout = function(){
         this.style.background= "url('../../Images/PortalImages/shade1.png')";  
           };       
    }
    else if (myid == 'lnkAllVideo')
    {
       
        document.getElementById("lnkHome").style.background= "url('../../Images/PortalImages/shade1.png')";
        document.getElementById("lnkHome").onmouseout = function(){
         this.style.background= "url('../../Images/PortalImages/shade1.png')";  
           };  
        
        if ((document.getElementById("hidLiveTabExists").value == "true") || (document.getElementById("hidLiveTabExists").value == "offair"))
        {              
            document.getElementById("lnkLive").style.background= "url('../../Images/PortalImages/shade1.png')"; 
            document.getElementById("lnkLive").onmouseout = function(){
             this.style.background= "url('../../Images/PortalImages/shade1.png')";  
               };                    
        }
                                                     
        document.getElementById("lnkSchedule").style.background= "url('../../Images/PortalImages/shade1.png')"; 
        document.getElementById("lnkSchedule").onmouseout = function(){
         this.style.background= "url('../../Images/PortalImages/shade1.png')";  
           };       
           
        //document.getElementById("lnkShare").style.backgroundColor = document.getElementById("hidForeColor").value;     
        document.getElementById("lnkAllVideo").onmouseout = function(){
                 this.style.backgroundColor= document.getElementById("hidForeColor").value;    
                   };      
    }
    
    if (myid == 'lnkHome1')
    {                      
        //document.getElementById("lnkShare").style.backgroundColor = document.getElementById("hidForeColor").value;     
        document.getElementById("lnkHome1").onmouseout = function(){
                 this.style.backgroundColor= document.getElementById("hidForeColor").value;    
                   };      
                   
        if ((document.getElementById("hidLiveTabExists_SSP").value == "true") || (document.getElementById("hidLiveTabExists_SSP").value == "offair"))
        {           
            document.getElementById("lnkLive1").style.background= "url('../../Images/PortalImages/shade1.png')";
            document.getElementById("lnkLive1").onmouseout = function(){
             this.style.background= "url('../../Images/PortalImages/shade1.png')";  
               };  
        }
                                          
        document.getElementById("lnkSchedule1").style.background= "url('../../Images/PortalImages/shade1.png')"; 
        document.getElementById("lnkSchedule1").onmouseout = function(){
         this.style.background= "url('../../Images/PortalImages/shade1.png')";  
           };        
                                
        document.getElementById("lnkAllVideo1").style.background= "url('../../Images/PortalImages/shade1.png')"; 
        document.getElementById("lnkAllVideo1").onmouseout = function(){
         this.style.background= "url('../../Images/PortalImages/shade1.png')";  
           };                
    }
    else if (myid == 'lnkLive1')
    {
        document.getElementById("lnkHome1").style.background= "url('../../Images/PortalImages/shade1.png')";
        document.getElementById("lnkHome1").onmouseout = function(){
         this.style.background= "url('../../Images/PortalImages/shade1.png')";  
           };  
           
        //document.getElementById("lnkShare").style.backgroundColor = document.getElementById("hidForeColor").value;     
        document.getElementById("lnkLive1").onmouseout = function(){
                 this.style.backgroundColor= document.getElementById("hidForeColor").value;    
                   };      
                               
        document.getElementById("lnkSchedule1").style.background= "url('../../Images/PortalImages/shade1.png')"; 
        document.getElementById("lnkSchedule1").onmouseout = function(){
         this.style.background= "url('../../Images/PortalImages/shade1.png')";  
           };        
                                
        document.getElementById("lnkAllVideo1").style.background= "url('../../Images/PortalImages/shade1.png')"; 
        document.getElementById("lnkAllVideo1").onmouseout = function(){
         this.style.background= "url('../../Images/PortalImages/shade1.png')";  
           };       
                            
    }
    else if (myid == 'lnkSchedule1')
    {
       
        document.getElementById("lnkHome1").style.background= "url('../../Images/PortalImages/shade1.png')";
        document.getElementById("lnkHome1").onmouseout = function(){
         this.style.background= "url('../../Images/PortalImages/shade1.png')";  
           };  
        
        if ((document.getElementById("hidLiveTabExists_SSP").value == "true") || (document.getElementById("hidLiveTabExists_SSP").value == "offair"))
        {           
            document.getElementById("lnkLive1").style.background= "url('../../Images/PortalImages/shade1.png')"; 
            document.getElementById("lnkLive1").onmouseout = function(){
             this.style.background= "url('../../Images/PortalImages/shade1.png')";  
               };                    
        }
           
        //document.getElementById("lnkShare").style.backgroundColor = document.getElementById("hidForeColor").value;     
        document.getElementById("lnkSchedule1").onmouseout = function(){
                 this.style.backgroundColor= document.getElementById("hidForeColor").value;    
                   };      
                      
        document.getElementById("lnkAllVideo1").style.background= "url('../../Images/PortalImages/shade1.png')"; 
        document.getElementById("lnkAllVideo1").onmouseout = function(){
         this.style.background= "url('../../Images/PortalImages/shade1.png')";  
           };       
    }
    else if (myid == 'lnkAllVideo1')
    {
       
        document.getElementById("lnkHome1").style.background= "url('../../Images/PortalImages/shade1.png')";
        document.getElementById("lnkHome1").onmouseout = function(){
         this.style.background= "url('../../Images/PortalImages/shade1.png')";  
           };  
        
        if ((document.getElementById("hidLiveTabExists_SSP").value == "true") || (document.getElementById("hidLiveTabExists_SSP").value == "offair"))
        {              
            document.getElementById("lnkLive1").style.background= "url('../../Images/PortalImages/shade1.png')"; 
            document.getElementById("lnkLive1").onmouseout = function(){
             this.style.background= "url('../../Images/PortalImages/shade1.png')";  
               };                    
        }
                                                     
        document.getElementById("lnkSchedule1").style.background= "url('../../Images/PortalImages/shade1.png')"; 
        document.getElementById("lnkSchedule1").onmouseout = function(){
         this.style.background= "url('../../Images/PortalImages/shade1.png')";  
           };       
           
        //document.getElementById("lnkShare").style.backgroundColor = document.getElementById("hidForeColor").value;     
        document.getElementById("lnkAllVideo1").onmouseout = function(){
                 this.style.backgroundColor= document.getElementById("hidForeColor").value;    
                   };      
    }
}

// FUNCTION TO CHANGE THE TAB STATUS (for vod/liveevent tabs)
function changeTabMenu(myid)
{   
    if (myid == 'lnk_VOD_PWNA')
    {                       
        //document.getElementById("lnkShare").style.backgroundColor = document.getElementById("hidForeColor").value;     
        document.getElementById("lnk_VOD_PWNA").onmouseout = function(){
                 this.style.backgroundColor= document.getElementById("hidForeColor").value;    
                   };      
                   
        if ((document.getElementById("hidLiveTabExists_PWNA").value == "true") || (document.getElementById("hidLiveTabExists_PWNA").value == "offair"))
        {           
            document.getElementById("lnk_Live_PWNA").style.background= "url('../../Images/PortalImages/shade1.png')";
            document.getElementById("lnk_Live_PWNA").onmouseout = function(){
             this.style.background= "url('../../Images/PortalImages/shade1.png')";  
               };  
        }
    }
    else if (myid == 'lnk_Live_PWNA')
    {
        document.getElementById("lnk_VOD_PWNA").style.background= "url('../../Images/PortalImages/shade1.png')";
        document.getElementById("lnk_VOD_PWNA").onmouseout = function(){
         this.style.background= "url('../../Images/PortalImages/shade1.png')";  
           };  
           
        //document.getElementById("lnkShare").style.backgroundColor = document.getElementById("hidForeColor").value;     
        document.getElementById("lnk_Live_PWNA").onmouseout = function(){
                 this.style.backgroundColor= document.getElementById("hidForeColor").value;    
                   }; 
    }
    else if (myid == 'lnk_VOD_VP')
    {                       
        //document.getElementById("lnkShare").style.backgroundColor = document.getElementById("hidForeColor").value;     
        document.getElementById("lnk_VOD_VP").onmouseout = function(){
                 this.style.backgroundColor= document.getElementById("hidForeColor").value;    
                   };      
                   
        if ((document.getElementById("hidLiveTabExists_VP").value == "true") || (document.getElementById("hidLiveTabExists_VP").value == "offair"))
        {           
            document.getElementById("lnk_Live_VP").style.background= "url('../../Images/PortalImages/shade1.png')";
            document.getElementById("lnk_Live_VP").onmouseout = function(){
             this.style.background= "url('../../Images/PortalImages/shade1.png')";  
               };  
        }
    }
    else if (myid == 'lnk_Live_VP')
    {
        document.getElementById("lnk_VOD_VP").style.background= "url('../../Images/PortalImages/shade1.png')";
        document.getElementById("lnk_VOD_VP").onmouseout = function(){
         this.style.background= "url('../../Images/PortalImages/shade1.png')";  
           };  
           
        //document.getElementById("lnkShare").style.backgroundColor = document.getElementById("hidForeColor").value;     
        document.getElementById("lnk_Live_VP").onmouseout = function(){
                 this.style.backgroundColor= document.getElementById("hidForeColor").value;    
                   }; 
    }
    else if (myid == 'lnk_VOD_VPC')
    {                       
        //document.getElementById("lnkShare").style.backgroundColor = document.getElementById("hidForeColor").value;     
        document.getElementById("lnk_VOD_VPC").onmouseout = function(){
                 this.style.backgroundColor= document.getElementById("hidForeColor").value;    
                   };      
                   
        if ((document.getElementById("hidLiveTabExists_VPC").value == "true") || (document.getElementById("hidLiveTabExists_VPC").value == "offair"))
        {           
            document.getElementById("lnk_Live_VPC").style.background= "url('../../Images/PortalImages/shade1.png')";
            document.getElementById("lnk_Live_VPC").onmouseout = function(){
             this.style.background= "url('../../Images/PortalImages/shade1.png')";  
               };  
        }
    }
    else if (myid == 'lnk_Live_VPC')
    {
        document.getElementById("lnk_VOD_VPC").style.background= "url('../../Images/PortalImages/shade1.png')";
        document.getElementById("lnk_VOD_VPC").onmouseout = function(){
         this.style.background= "url('../../Images/PortalImages/shade1.png')";  
           };  
           
        //document.getElementById("lnkShare").style.backgroundColor = document.getElementById("hidForeColor").value;     
        document.getElementById("lnk_Live_VPC").onmouseout = function(){
                 this.style.backgroundColor= document.getElementById("hidForeColor").value;    
                   }; 
    }
}

function ApplyStyle(myid)
{
    var link=document.getElementById(myid);      
    link.style.color = document.getElementById("hidFontColor").value; 
    link.style.fontFamily = document.getElementById("hidFontName").value;          
    link.style.backgroundColor=document.getElementById("hidForeColor").value;
}
 
function UnloadStyle(myid)
{
    var link=document.getElementById(myid);
    //alert(link.style.backgroundColor);
    link.style.color = document.getElementById("hidFontColor").value; 
    link.style.fontFamily = document.getElementById("hidFontName").value;   
    link.style.background= "url('../../Images/PortalImages/shade1.png')";
}

function ApplyHref(myid)
{    
    var link=document.getElementById(myid);      
    link.style.color = document.getElementById("hidForeColor").value;  
}
 
function UnloadHref(myid)
{
    var link=document.getElementById(myid);
    link.style.color = document.getElementById("hidFontColor").value;  
}

function ApplyForeColor(myid)
{    
    var link=document.getElementById(myid);     
    link.style.background = document.getElementById("hidForeColor").value; 
    link.style.color = document.getElementById("hidFontColor").value; 
}
 
function UnloadForeColor(myid)
{
    var link=document.getElementById(myid);
    link.style.background = "#808080";  
    link.style.color = "#FFFFFF"; 
}

function ApplyBorderForeColor(myid)
{    
    var link=document.getElementById(myid);     
    link.style.border = '4px solid ' + document.getElementById("hidForeColor").value; 
}
 
function UnloadBorderForeColor(myid)
{
    var link=document.getElementById(myid);
    link.style.border = "4px solid #686868";  
}
// ***************** CODE ENDS HERE - TO CHANGE THE STYLE SHEET DYNAMICALLY  ******************

function changeCategory(catID,catName)
{
    var link=document.getElementById("lnk_VOD_VPC");   
    link.innerHTML = catName;
     
    document.getElementById("VOD_hidCategoryKeywords").value = catID; // SET THE SELECTED VALUE  
    document.getElementById("VOD_hidKeywords").value = "-1";   // SET THE DEFAULT VALUE            
         
    // Set search video as the current play list area video
    document.getElementById("VOD_hidCurrentPlaylistStatus").value = "Search";    
    document.getElementById("VOD_hidClickedVideoStatus").value = "search";    
            
    // Display the video
    GoPage(1,1);
    
}

function onPreviousClick()
{
    document.getElementById("hidPageIndex").value = parseInt(document.getElementById("hidPageIndex").value) - 1;
            
    document.getElementById("btnCategory").style.display = "block";
    
    document.frmIndex.btnCategory.click();     
    
    document.getElementById("btnCategory").style.display = "none";
}

function onNextClick()
{
    document.getElementById("hidPageIndex").value = parseInt(document.getElementById("hidPageIndex").value) + 1;
            
    document.getElementById("btnCategory").style.display = "block";
    
    document.frmIndex.btnCategory.click();     
    
    document.getElementById("btnCategory").style.display = "none";
}

function hideLinks(curPage, TotalPage)
{  // alert(curPage + '--' + TotalPage);
    if (TotalPage <= 1)
    {
        document.getElementById("hrefPrevCategory").style.display = "none";
        document.getElementById("hrefNextCategory").style.display = "none";
        return;
    }
    
    if (curPage == 1)
    {
        document.getElementById("hrefPrevCategory").style.display = "none";
        document.getElementById("hrefNextCategory").style.display = "block";
        document.getElementById("hrefNextCategory").style.color = document.getElementById("hidFontColor").value; 
    }
    else if (curPage < TotalPage)
    {
        document.getElementById("hrefPrevCategory").style.display = "block";
        document.getElementById("hrefNextCategory").style.display = "block";
        document.getElementById("hrefPrevCategory").style.color = document.getElementById("hidFontColor").value; 
        document.getElementById("hrefNextCategory").style.color = document.getElementById("hidFontColor").value; 
    }    
    else if (curPage == TotalPage)
    {
        document.getElementById("hrefPrevCategory").style.display = "block";
        document.getElementById("hrefNextCategory").style.display = "none";
        document.getElementById("hrefPrevCategory").style.color = document.getElementById("hidFontColor").value; 
    }
    
    
}

/// -------------------------------------------------------------------------------------------------------------


// GENERAL SCRIPT FOR TEXTBOX VALIDATION, EMAIL, WHITESPACE...

     ////****************************************************************/

        // isEmail (STRING s [, BOOLEAN emptyOK])
        // 
        // Email address must be of form a@b.c ... in other words:
        // * there must be at least one character before the @
        // * there must be at least one character before and after the .
        // * the characters @ and . are both required
        //
        // For explanation of optional argument emptyOK,
        // see comments of function isInteger.
        // ***************************************************************/


        function isEmail (ls_str)
        {   if (isEmpty(ls_str)) 
               if (isEmail.arguments.length == 1) return defaultEmptyOK;
               else return (isEmail.arguments[1] == true);
           
            // is s whitespace?
            if (isWhitespace(ls_str)) return false;
            
            // there must be >= 1 character before @, so we
            // start looking at character position 1 
            // (i.e. second character)
            var li_Cnt = 1;
            var sLength = ls_str.length;

            // look for @
            while ((li_Cnt < sLength) && (ls_str.charAt(li_Cnt) != "@"))
            { li_Cnt++
            }

            if ((li_Cnt >= sLength) || (ls_str.charAt(li_Cnt) != "@")) return false;
            else li_Cnt += 2;

            // look for .
            while ((li_Cnt < sLength) && (ls_str.charAt(li_Cnt) != "."))
            { li_Cnt++
            }

            // there must be at least one character after the .
            if ((li_Cnt >= sLength - 1) || (ls_str.charAt(li_Cnt) != ".")) return false;
            else return true;
        }



        /****************************************************************/

        // Check whether string s is empty.

        function isEmpty(ls_str)
        {   return ((ls_str == null) || (ls_str.length == 0))
        }


        // DEFINE VARIABLES

        // whitespace characters
        var whitespace = " \t\n\r";

        /****************************************************************/

        // Returns true if string s is empty or 
        // whitespace characters only.

        function isWhitespace (ls_str)

        {   var li_cnt;

            // Is ls_str empty?
            if (isEmpty(ls_str)) return true;

            // Search through string's characters one by one
            // until we find a non-whitespace character.
            // When we do, return false; if we don't, return true.

            for (li_cnt = 0; li_cnt < ls_str.length; li_cnt++)
            {   
	        // Check that current character isn't whitespace.
	        var ls_chr = ls_str.charAt(li_cnt);

	        if (whitespace.indexOf(ls_chr) == -1) return false;
            }

            // All characters are whitespace.
            return true;
        }
        
        /****************/
	 function TextBoxValidation(strfield)
    {
	    var intCt;
	    var strkey;
	    var strtext;
	    strkey=strfield.value;
	   
	    for (intCt = 0; intCt < strkey.length; intCt++)
	    {
    	
		    if (strkey.charAt(0)==" ")
		    {
    			
			    strtext = strkey.substring(1,strkey.length);	
			    strfield.value = strtext;
		    }
    		
    		if(strkey.charAt(0) == ".")
    		{
    		    strtext = strkey.substring(1,strkey.length);	
			    strfield.value = strtext;
			    
    		}
    		
    		
    		
		    if (strkey.charAt(intCt)=="'")
		    {
			    strtext = strkey.substring(0,intCt);
			    strtext = strtext + strkey.substring(intCt + 1,strkey.length);	
			    strfield.value = strtext;							
		    }
		    else if (strkey.charAt(intCt) == " ")

			    {				
				    if (strkey.charAt(intCt -1 ) == " ")
				    {				
				    strtext = strkey.substring(0,intCt);
				    strtext = strtext + strkey.substring(intCt + 1,strkey.length);	
				    strfield.value = strtext;				
				    }
			    }	
			    
			    else if (strkey.charAt(intCt)==";")
		    {
			    strtext = strkey.substring(0,intCt);
			    strtext = strtext + strkey.substring(intCt + 1,strkey.length);	
			    strfield.value = strtext;				
		    }    
			else if (strkey.charAt(intCt)==":")
		    {
			    strtext = strkey.substring(0,intCt);
			    strtext = strtext + strkey.substring(intCt + 1,strkey.length);	
			    strfield.value = strtext;				
		    } 
			    
		    else if (strkey.charAt(intCt)=="<")
		    {
			    strtext = strkey.substring(0,intCt);
			    strtext = strtext + strkey.substring(intCt + 1,strkey.length);	
			    strfield.value = strtext;				
		    }
		    else if (strkey.charAt(intCt)==">")
		    {
			    strtext = strkey.substring(0,intCt);
			    strtext = strtext + strkey.substring(intCt + 1,strkey.length);	
			    strfield.value = strtext;				
		    }		
		    else if (strkey.charAt(intCt) == "@")

			    {				
				    if (strkey.charAt(intCt -1 ) == "@")
				    {				
				    strtext = strkey.substring(0,intCt);
				    strtext = strtext + strkey.substring(intCt + 1,strkey.length);	
				    strfield.value = strtext;	
				    }
			    }	
		    else if (strkey.charAt(intCt) == ".")

			    {				
				    if (strkey.charAt(intCt -1 ) == ".")
				    {				
				    strtext = strkey.substring(0,intCt);
				    strtext = strtext + strkey.substring(intCt + 1,strkey.length);	
				    strfield.value = strtext;				
				    }
			    }
	    }
    }

