
function onlinecounter() {
    //var TimezoneOffset = -8  // adjust for time zone
    var localTime = new Date();
    var ms = localTime.getTime()
                 + (localTime.getTimezoneOffset() * 60000)
                 + TimezoneOffset * 3600000;
    var time = new Date(ms);

    var localDay = localTime.getDate();
    var localMonth = localTime.getMonth() + 1;
    var localYear = localTime.getFullYear();
    var hours = time.getHours();
    var minutes = time.getMinutes();
    var seconds = time.getSeconds();

    if (localMonth.toString().length == 1) {
        localMonth = "0" + localMonth;
    }

    if (localDay.toString().length == 1) {
        localDay = "0" + localDay;
    }
    if (hours.toString().length == 1) {
        hours = "0" + hours;
    }
    if (minutes.toString().length == 1) {
        minutes = "0" + minutes;
    }
    if (seconds.toString().length == 1) {
        seconds = "0" + seconds;
    }

    if (starttime_month.length == 1) {
        starttime_month = "0" + starttime_month;
    }
    if (starttime_day.length == 1) {
        starttime_day = "0" + starttime_day;
    }
    if (starttime_hour.length == 1) {
        starttime_hour = "0" + starttime_hour;
    }
    if (starttime_minute.length == 1) {
        starttime_minute = "0" + starttime_minute;
    }

    var startnow = false;
    if (localYear == starttime_year) {
        if (localMonth == starttime_month) {
            if (localDay == starttime_day) {
                if (hours >= starttime_hour) {
                    if (hours > starttime_hour) {
                        document.getElementById("counter").innerHTML = "";
                        document.getElementById("lbl_csAdTitle").innerHTML = event_title;
                        startnow = true;
                    }
                    if (hours == starttime_hour && minutes >= starttime_minute) {
                        document.getElementById("counter").innerHTML = "";
                        document.getElementById("lbl_csAdTitle").innerHTML = event_title;
                        startnow = true;
                    }
                }
            }
        }
    }
    if (startnow == false) {
        window.location.href = redirectpage;
    }
}

function offlinecounter() 
{
    if (offline_schevent.toLowerCase() != "off") {
        //var TimezoneOffset = -8  // adjust for time zone
        var localTime = new Date();
        var ms = localTime.getTime()
                     + (localTime.getTimezoneOffset() * 60000)
                     + TimezoneOffset * 3600000;
        var time = new Date(ms);
        
        var localDay = localTime.getDate();
        var localMonth = localTime.getMonth() + 1;
        var localYear = localTime.getFullYear();
        var hours = time.getHours();
        var minutes = time.getMinutes();
        var seconds = time.getSeconds();
        
        if (localMonth.toString().length == 1) {
            localMonth = "0" + localMonth;
        }

        if (localDay.toString().length == 1) {
            localDay = "0" + localDay;
        }
        if (hours.toString().length == 1) {
            hours = "0" + hours;
        }
        if (minutes.toString().length == 1) {
            minutes = "0" + minutes;
        }
        if (seconds.toString().length == 1) {
            seconds = "0" + seconds;
        }

        if (starttime_month.length == 1) {
            starttime_month = "0" + starttime_month;
        }
        if (starttime_day.length == 1) {
            starttime_day = "0" + starttime_day;
        }
        if (starttime_hour.length == 1) {
            starttime_hour = "0" + starttime_hour;
        }
        if (starttime_minute.length == 1) {
            starttime_minute = "0" + starttime_minute;
        }
       
        
        if(localYear == starttime_year)
        {
            if(localMonth == starttime_month)
            {
                if(localDay == starttime_day)
                {
                    if(hours >= starttime_hour)
                    {
                        if(minutes >= starttime_minute)
                        {
                            window.location.href = "FADVideoTVLive.htm";
                        }
                    }
                }
            }
        }

        document.getElementById("nexteventtitle").innerHTML = event_title;


        var curTime = "<br />Broadcasting Live On: <span class=\"broadcastcounter\">" + starttime_month + "/" + starttime_day + "/" + starttime_year +
                    " @ " + starttime_hour + ":" + starttime_minute +  
                    "<br />Current date/time is: " + localMonth + "/" + localDay + "/" + localYear + " @ " + hours + ":" + minutes + ":" + seconds + "</span><br />";

        document.getElementById("counter").innerHTML = curTime;
        document.getElementById("lbl_csAdTitle").innerHTML = playlist_title;
        setTimeout("offlinecounter()", 1000);
    }
}

function embed_onlinecounter() {
    //var TimezoneOffset = -8  // adjust for time zone
    var localTime = new Date();
    var ms = localTime.getTime()
                 + (localTime.getTimezoneOffset() * 60000)
                 + TimezoneOffset * 3600000;
    var time = new Date(ms);

    var localDay = localTime.getDate();
    var localMonth = localTime.getMonth() + 1;
    var localYear = localTime.getFullYear();
    var hours = time.getHours();
    var minutes = time.getMinutes();
    var seconds = time.getSeconds();

    if (localMonth.toString().length == 1) {
        localMonth = "0" + localMonth;
    }

    if (localDay.toString().length == 1) {
        localDay = "0" + localDay;
    }
    if (hours.toString().length == 1) {
        hours = "0" + hours;
    }
    if (minutes.toString().length == 1) {
        minutes = "0" + minutes;
    }
    if (seconds.toString().length == 1) {
        seconds = "0" + seconds;
    }

    if (starttime_month.length == 1) {
        starttime_month = "0" + starttime_month;
    }
    if (starttime_day.length == 1) {
        starttime_day = "0" + starttime_day;
    }
    if (starttime_hour.length == 1) {
        starttime_hour = "0" + starttime_hour;
    }
    if (starttime_minute.length == 1) {
        starttime_minute = "0" + starttime_minute;
    }

    var startnow = false;
    if (localYear == starttime_year) {
        if (localMonth == starttime_month) {
            if (localDay == starttime_day) {
                if (hours >= starttime_hour) {
                    if (hours > starttime_hour) {
                        document.getElementById("counter").innerHTML = "";
                        document.getElementById("lbl_csAdTitle").innerHTML = event_title;
                        startnow = true;
                    }
                    if (hours == starttime_hour && minutes >= starttime_minute) {
                        document.getElementById("counter").innerHTML = "";
                        document.getElementById("lbl_csAdTitle").innerHTML = event_title;
                        startnow = true;
                    }
                }
            }
        }
    }
    if (startnow == false) {
        window.location.href = redirectpage + "?" + xmlfile + "&" + cssfilename + "&" + pagesize ;
    }
}


function embed_offlinecounter() 
{
    if (offline_schevent.toLowerCase() != "off") {
        //var TimezoneOffset = -8  // adjust for time zone
        var localTime = new Date();
        var ms = localTime.getTime()
                     + (localTime.getTimezoneOffset() * 60000)
                     + TimezoneOffset * 3600000;
        var time = new Date(ms);
        
        var localDay = localTime.getDate();
        var localMonth = localTime.getMonth() + 1;
        var localYear = localTime.getFullYear();
        var hours = time.getHours();
        var minutes = time.getMinutes();
        var seconds = time.getSeconds();
        
        if (localMonth.toString().length == 1) {
            localMonth = "0" + localMonth;
        }

        if (localDay.toString().length == 1) {
            localDay = "0" + localDay;
        }
        if (hours.toString().length == 1) {
            hours = "0" + hours;
        }
        if (minutes.toString().length == 1) {
            minutes = "0" + minutes;
        }
        if (seconds.toString().length == 1) {
            seconds = "0" + seconds;
        }

        if (starttime_month.length == 1) {
            starttime_month = "0" + starttime_month;
        }
        if (starttime_day.length == 1) {
            starttime_day = "0" + starttime_day;
        }
        if (starttime_hour.length == 1) {
            starttime_hour = "0" + starttime_hour;
        }
        if (starttime_minute.length == 1) {
            starttime_minute = "0" + starttime_minute;
        }
       
        
        if(localYear == starttime_year)
        {
            if(localMonth == starttime_month)
            {
                if(localDay == starttime_day)
                {
                    if(hours >= starttime_hour)
                    {
                        if(minutes >= starttime_minute)
                        { 
                            window.location.href = "MyFADVideoTvLive_embed.htm?" + xmlfile + "&" + cssfilename + "&" + pagesize;
                        }
                    }
                }
            }
        }

        document.getElementById("nexteventtitle").innerHTML = event_title;


        var curTime = "<br />Broadcasting Live On: <span class=\"broadcastcounter\">" + starttime_month + "/" + starttime_day + "/" + starttime_year +
                    " @ " + starttime_hour + ":" + starttime_minute +  
                    "<br />Current date/time is: " + localMonth + "/" + localDay + "/" + localYear + " @ " + hours + ":" + minutes + ":" + seconds + "</span><br />";

        document.getElementById("counter").innerHTML = curTime;
        document.getElementById("lbl_csAdTitle").innerHTML = playlist_title;
        setTimeout("embed_offlinecounter()", 1000);
    }
}



function load_channel_logo() {
    document.getElementById("channel_logo").setAttribute("src", channel_logo);

}

function embed_LiveCastStream(){    switch (pagesize)    {        case "small":            var so = new SWFObject("jw/player-viral.swf", "mpl", "400", "350", "9");            break;        case "medium":            var so = new SWFObject("jw/player-viral.swf", "mpl", "520", "450", "9");            break;                    case "full":            var so = new SWFObject("jw/player-viral.swf", "mpl", "600", "540", "9");            break;    }    so.addParam("allowscriptaccess","never");    so.addParam("allowfullscreen", "true");    so.addParam("type", "rtmp");    so.addParam("file", xmlfile + ".flv");    so.addParam("stream", "rtmp://fml.lax.0A90.edgecastcdn.net/200A90/");    so.addParam("flashvars", "&file=" + xmlfile + ".flv&streamer=rtmp://fml.lax.0A90.edgecastcdn.net/200A90/&image=banners/adcast_wait.jpg&autostart=true&skin=jw/skins/stylish/stylish.swf");    so.write("swfobject");
}
