$(document).ready(function() {

    //$('#TVDVRLoadingDiv').css('display', 'block');

});
var BnrId = 1, BnrTC, BTimer;
function initBanner(cnt) {
    $('#BannerContainer div:first-child').css('left', '0px');
    $('#BannerContainer div:first-child').addClass('current');
    BnrTC = cnt;
    BTimer = setInterval('LoopBanner()', 5000);
}
var isBanAnimate = 0;
function ShowBanner(id, stat) {
    if (!isBanAnimate) {
        isBanAnimate = 1;
        var stat = typeof stat == 'undefined' ? 'normal' : stat;
        if (stat == 'normal') clearInterval(BTimer);
        $('#Banner_dots_' + BnrId).removeClass('Act');
        //document.getElementById('Banner_dots_'+BnrId).className = document.getElementById('Banner_dots_'+BnrId).className.replace('on','off');
        BnrId = id;
        $('.current').animate({ 'left': '-607px' }, 900, function() { $(this).removeClass('current'); $(this).css('left', '607px'); isBanAnimate = 0; });
        $('#Banner_' + id).animate({ 'left': '0px' }, 900, function() { $(this).addClass('current') });
        document.getElementById('Banner_' + id).style.display = 'block';
        $('#Banner_dots_' + id).addClass('Act');
        //document.getElementById('Banner_dots_'+id).className = document.getElementById('Banner_dots_'+BnrId).className.replace('off','on');
        if (stat == 'normal') document.getElementById('SSPlayIco').className = document.getElementById('SSPlayIco').className.replace('SSPause', 'SSPlay');
    }
}
function MoveToBanner(mode, stat) {
    var stat = typeof stat == 'undefined' ? 'normal' : stat;
    if (stat == 'normal') clearInterval(BTimer);
    var ref = 1;
    if (mode == 'prev') {
        ref = BnrId - 1 <= 0 ? BnrTC : BnrId - 1;
    } else {
        ref = BnrId + 1 > BnrTC ? 1 : BnrId + 1
    }
    ShowBanner(ref, stat);
}
function LoopBanner() {
    MoveToBanner('next', 'slideshow');
}

function ToggleSlideshow(obj, count) {
    if (document.getElementById('SSPlayIco').className.match('SSPause')) {
        clearInterval(BTimer); document.getElementById('SSPlayIco').className = document.getElementById('SSPlayIco').className.replace('SSPause', 'SSPlay');
    }
    else {
        document.getElementById('SSPlayIco').className = document.getElementById('SSPlayIco').className.replace('SSPlay', 'SSPause');
        BTimer = setInterval('LoopBanner()', 5000);
    }

}




function TVToggleHLRc(obj, type, showLoadingDiv) {
    var loadingDiv = typeof showLoadingDiv != 'undefined' ? showLoadingDiv : false;
    var tabNo = $(obj).attr('rel');
    if (document.getElementById(type + '_Active')) {
        var prevTabNo = $('#' + type + '_Active').find('a').attr('rel');
        $('#' + type + '_Active').removeClass('Act');
        $('#' + type + '_Active').next().removeClass('NBdr');
        document.getElementById(type + '_Active').setAttribute('id', '');
        $('#' + type + 'Cont_' + prevTabNo).hide();
    }
    $(obj).parent().attr('id', type + '_Active');
    $(obj).parent().addClass('Act');
    $(obj).parent().next().addClass('NBdr');
    $(obj).parent().unbind('click');
    $(obj).parent().bind('click', function() {
        if ($(obj).parent().find('a').html() == "SCHEDULED RECORDING") {
            $('#divSchedule').empty();
            //TVGetSchedule_widget($('#DVR-popup-CaptionID1').text());
            TVGetSchedule_widget($('#DVR-popup-CaptionID1').attr('DeviceSerialNumber'));
        }
        else if ($(obj).parent().find('a').html() == "RECORDED SHOWS") {
            // $('#DVR-popup-CaptionID1').attr("DeviceSerialNumber", $(obj).attr('DeviceSerialNumber'));
            //$('#DVR-popup-CaptionID2').attr("DeviceSerialNumber", $(obj).attr('DeviceSerialNumber'));
            $('#divRecordings').empty();
            //TVGetRecord_widget($('#DVR-popup-CaptionID2').text());
            TVGetRecord_widget($('#DVR-popup-CaptionID2').attr('DeviceSerialNumber'));
        }
    });


    if ($(obj).parent().is(':last-child'))
        $('#' + type + 'RC').addClass('RCOn')
    else
        $('#' + type + 'RC').removeClass('RCOn')

    if ($(obj).parent().is(':first-child'))
        $('#' + type + 'LC').addClass('LCOn')
    else
        $('#' + type + 'LC').removeClass('LCOn');

    if (loadingDiv) {
        $('#' + type + 'LoadingDiv').show();
        setTimeout(function() { $('#' + type + 'LoadingDiv').hide(); $('#' + type + 'Cont_' + tabNo).show(); }, 200);
    } else {
        $('#' + type + 'Cont_' + tabNo).fadeIn(0);
    }

}
function ToggleHLRc(obj, type, showLoadingDiv, fadeNeed) {
    var loadingDiv = typeof showLoadingDiv != 'undefined' ? showLoadingDiv : false;
    var fadeNeed = typeof fadeNeed != 'undefined' ? fadeNeed : true;
    var tabNo = $(obj).attr('rel');
    if (document.getElementById(type + '_Active')) {
        var prevTabNo = $('#' + type + '_Active').find('a').attr('rel');
        $('#' + type + '_Active').removeClass('Act');
        $('#' + type + '_Active').next().removeClass('NBdr');
        document.getElementById(type + '_Active').setAttribute('id', '');
        $('#' + type + 'Cont_' + prevTabNo).hide();
    }
    $(obj).parent().attr('id', type + '_Active');
    $(obj).parent().addClass('Act');
    $(obj).parent().next().addClass('NBdr');


    $(obj).parent().bind('click', function() {
        if ($(obj).parent().find('a').html() == "SCHEDULED RECORDING") {
            $('#divSchedule').empty();
            //  TVGetSchedule_widget($('#DVR-popup-CaptionID1').text());
            TVGetSchedule_widget($('#DVR-popup-CaptionID1').html($(obj).attr('DeviceSerialNumber')));
        }
        else if ($(obj).parent().find('a').html() == "RECORDED SHOWS") {
            $('#divRecordings').empty();
            //TVGetRecord_widget($('#DVR-popup-CaptionID2').text());
            TVGetSchedule_widget($('#DVR-popup-CaptionID1').html($(obj).attr('DeviceSerialNumber')));
        }
    });

    if ($(obj).parent().is(':last-child'))
        $('#' + type + 'RC').addClass('RCOn')
    else
        $('#' + type + 'RC').removeClass('RCOn')
    if ($(obj).parent().is(':first-child'))
        $('#' + type + 'LC').addClass('LCOn')
    else
        $('#' + type + 'LC').removeClass('LCOn');
    resetDVRDDCont();
    if (fadeNeed) {
        //Commented to resolve fading issue
        //if (document.all) $('#' + type + 'Cont_' + tabNo).children().find(':not(.NoBlur)').css('opacity', '1');
        $('#' + type + 'Cont_' + tabNo).fadeIn(1200);
    } else {
        $('#' + type + 'Cont_' + tabNo).show();
    }
    if (loadingDiv) {
        $('#' + type + 'LoadingDiv' + tabNo).show();
        setTimeout(function() { $('#' + type + 'LoadingDiv' + tabNo).hide(); if (tabNo == '1') { $('#DVRSchedContent').show(); } else { $('#DVRRecContent').show(); } }, 2000);
    }
}
function doShowCombo(id) {
    var listDiv = document.getElementById(id);
    var contDiv = id + '-Main';
    var aPos = getPosition(contDiv);
    listDiv.style.top = aPos.top + document.getElementById(contDiv).offsetHeight + 'px';
    listDiv.style.left = aPos.left + 'px';
    listDiv.style.zIndex = '90000';
    document.body.appendChild(listDiv);
    listDiv.style.display = 'block';
}
function DD_Mouseout(e, id) {
    var id = typeof (id) == 'undefined' ? 'DVR-popup' : id;
    if (!trackMouseOnDiv(e, [id, id + '-Main'])) {
        document.getElementById(id).style.display = 'none';
    }
}
function selectComboItem(obj, id) {
    document.getElementById(id + '-Caption').innerHTML = obj.innerHTML;
    document.getElementById(id).style.display = 'none';
}
function showdvr() {
    jQuery('#loading').css('display', 'block');
    $.ajax({
        url: strDomainName + strSiteName + "/Members/Handlers/sw.ashx",
        type: "POST",
        dataType: "html",
        ifModified: false,
        async: true,
        time: 5000,
        crossDomain: false,
        data:
        {
            Action: "GetSuperWidgetsAccountDetails"
        },
        success: ShowDvr_Success,
        error: ShowDvr_Error
    });
}
function ShowDvr_Success(oResponse) {
    if (oResponse != null && oResponse != "") {
        showDVRInner_widget(oResponse);
    }
}

function ShowDvr_Error(oResponse) {

}


function showDVRInner_widget(AccountId) {
    DVRInnerHide();
    switch (AccountId) {
        case "0":
            $('#TVDVRLoadingDiv').css('display', 'none');
            $('#widget_common')[0].style.display = "none";
            $('#divDVRPromo')[0].style.display = "block";
            break;
        case "1":
            $('#TVDVRLoadingDiv').css('display', 'none');
            $('#widget_common')[0].style.display = "none";
            $('#FiOSDVRActi')[0].style.display = "block";
            break;
        case "2":
            $('#TVDVRLoadingDiv').css('display', 'none');
            $('#widget_common')[0].style.display = "none";
            $('#FiOSDVRActi')[0].style.display = "block";
            break;
        case "3":
            $('#TVDVRLoadingDiv').css('display', 'none');
            $('#widget_common')[0].style.display = "none";
            $('#FiOSDVRActi')[0].style.display = "block";
            break;
        case "4":
            LoadSTB();
            GetSchedule_widget();
            GetRecord_widget();
            jQuery('#widget_common')[0].style.display = "block";
            jQuery('#divRec').addClass('divRecRemove');
            break;
        case "5":
            $('#widget_common')[0].style.display = "none";
            $('#FiOSDVRActiStatus')[0].style.display = "block";
            break;
        case "6":
            $('#widget_common')[0].style.display = "none";
            $('#divDVRPromo')[0].style.display = "block";
            break;
        default:
            break;
    }
}

function doWidgetShowCombo(id) {
    var listDiv = document.getElementById(id);
    var contDiv = id + '-Main';
    var aPos = getPosition(contDiv);
    listDiv.style.top = aPos.top + document.getElementById(contDiv).offsetHeight + 'px';
    listDiv.style.left = aPos.left + 'px';
    listDiv.style.zIndex = '90000';
    document.body.appendChild(listDiv);
    listDiv.style.display = 'block';
}

/*function selectValueToDDNew(obj) {
try {
$('#divRecordings').empty();
$('#divSchedule').empty();
$('#TVDVRLoadingDiv').css('display', 'block');
$('#DVR-popup-Caption').html($(obj).attr('DeviceSerialNumber'));
$('#DVR-popup-Caption').attr('DeviceSerialNumber', $(obj).attr('DeviceSerialNumber'));
TVGetSchedule_widget($(obj).attr('DeviceSerialNumber'));
TVGetRecord_widget($(obj).attr('DeviceSerialNumber'));
}
catch (e) {
// alert(e);
}

}*/

function ToggleTabDD(obj, ddId) {
    $('#' + ddId).css('top', $(obj).height() + 18);
    $('#' + ddId).toggle();
}

function getPosition(element) {
    var l = t = 0;
    while (element != null) {
        l += element.offsetLeft;
        t += element.offsetTop;
        element = element.offsetParent
    }
    return { left: l, top: t };
}


function TVGetRecord_widget(sID) {
    $('#TVDVRLoadingDiv2').css('display', 'block');
    $('#TVDVRLoadingDiv').css('display', 'block');
    $.ajax({
        url: strDomainName + strSiteName + "/Members/Handlers/sw.ashx",
        type: "POST",
        dataType: "html",
        ifModified: false,
        async: true,
        time: 5000,
        crossDomain: false,
        data:
                {
                    Action: "GetRecordings_ENT",
                    STBID: sID

                },
        success: TVShowRecordings_Success,
        error: TVShowRecordings_Error
    });

}
function TVShowRecordings_Success(objResponse) {
    var strRecStorageSpace = '';
    $('#divRecSpacePx').css('display', 'block');
    $('#divRecSpace').css('display', 'block');

    if (objResponse != null && objResponse == "No recordings found." || objResponse != null && objResponse == "") {
        $('#TVDVRLoadingDiv').css('display', 'none');
        $('#TVDVRLoadingDiv2').css('display', 'none');
        $('#divRecSpace').css('display', 'none');
        $('#divRecSpacePx').html('');
        $('#divRecordings').html("<div class='DVR_Error'><div class='ErrCont'><div class='Icon'><div class='ErrIco Big'></div></div><div class='Txt'><h2>No recordings found.</h2></div></div>");
    }
    else if (objResponse != null && objResponse != "") {
        var objRecordings = eval('(' + objResponse + ')');
        var intNumber = 0;
        var totalreccnt = 0;
        var i = 0;
        if (objRecordings != null) {
            var objContentDetails = objRecordings.NewDataSet.Table1;
            totalreccnt = objContentDetails.length;
            if (typeof totalreccnt == "undefined" && objContentDetails != null) {

                var strStartTimeFirst = "";
                var strStartTimeSecond = "";
                var strEndTime = "";
                try {
                    if (objContentDetails.StartTime.split(' ')[3] != " ") {
                        strStartTimeFirst = objContentDetails.StartTime.split(' ')[3];
                        strStartTimeSecond = objContentDetails.StartTime.split(' ')[4];
                    }
                    if (objContentDetails.EndTime != " ") {
                        strEndTime = objContentDetails.EndTime;
                    }
                }
                catch (ex)
                    { }

                strRecordingsHTML = '<ul class="WOB1">';
                strRecordingsHTML += '<li class="F">';
                strRecordingsHTML += '<div class="ChnLogo"><span class="' + objContentDetails.LogoCSS + '"></span></div>';
                strRecordingsHTML += '<div class="ShowDesc">';
                strRecordingsHTML += '<h6>' + objContentDetails.ProgName + '</h6>';
                if (strStartTimeFirst != '') {
                    strRecordingsHTML += '<div class="TimeStmp">' + strStartTimeFirst + ' ' + strStartTimeSecond + ' - ' + strEndTime + '</div>';
                }
                strRecordingsHTML += '</div></li>';
                strRecordingsHTML += '</ul>';
                strRecStorageSpace = objContentDetails.OccupiedSpace;
                //$('#divRecSpace').html("<span>" + strRecStorageSpace + "% Used</span>");
                var strSpaceval = strRecStorageSpace;
                strRecStorageSpace = strRecStorageSpace + "%";
                $('#divRecSpacePx').html("<div class='UsageCount'>" + strSpaceval + "% Used</div><div class='GreenBar' id='divRecSpacePx' style=width:" + strRecStorageSpace + "></div>");

                $('#divRecordings').html(strRecordingsHTML);
            }
            else {
                strRecordingsHTML = '<ul class="WOB1">';
                var strStartTimeFirst = "";
                var strStartTimeSecond = "";
                var strEndTime = "";
                var count = objContentDetails.length;
                if (count > 5) {
                    count = 5;
                }

                for (i = 0; i < count; i++) {
                    try {
                        if (objContentDetails[i].StartTime.split(' ')[3] != " ") {
                            strStartTimeFirst = objContentDetails[i].StartTime.split(' ')[3];
                            strStartTimeSecond = objContentDetails[i].StartTime.split(' ')[4];
                        }

                        if (objContentDetails[i].EndTime != " ") {
                            strEndTime = objContentDetails[i].EndTime;
                        }
                    }
                    catch (ex)
                    { }

                    strRecordingsHTML += '<li class="F">';
                    strRecordingsHTML += '<div class="ChnLogo"><span class="' + objContentDetails[i].LogoCSS + '"></span></div>';
                    strRecordingsHTML += '<div class="ShowDesc">';
                    strRecordingsHTML += '<h6>' + objContentDetails[i].ProgName + '</h6>';
                    if (strStartTimeFirst != "" && strStartTimeSecond != "") {
                        strRecordingsHTML += '<div class="TimeStmp">' + strStartTimeFirst + ' ' + strStartTimeSecond + ' - ' + strEndTime + '</div>';
                    }
                    strRecordingsHTML += '</div></li>';
                    strRecStorageSpace = objContentDetails[i].OccupiedSpace;

                }
                strRecordingsHTML += '</ul>';

                //$('#divRecSpace').html("<span>" + strRecStorageSpace + "% Used</span>");
                var strSpaceval = strRecStorageSpace;
                strRecStorageSpace = strRecStorageSpace + "%";
                $('#divRecSpacePx').html("<div class='UsageCount'>" + strSpaceval + "% Used</div><div class='GreenBar' id='divRecSpacePx' style=width:" + strRecStorageSpace + "></div>");

                $('#divRecordings').html(strRecordingsHTML);

            }

        }
    }
    $('#TVDVRLoadingDiv').css('display', 'none');
    $('#TVDVRLoadingDiv2').css('display', 'none');
}

function TVShowRecordings_Error(data) {
    $('#TVDVRLoadingDiv').css('display', 'none');
    $('#TVDVRLoadingDiv2').css('display', 'none');
    $('#divRecSpace').css('display', 'none');
    $('#divRecSpacePx').html('');
    if (data.status == 999 && data.responseText.indexOf("OpenPortMapping") > -1 || data.responseText.indexOf("Unavailable") > 0) {
        $('#divRecordings').html("<div class='DVR_Error'><div class='ErrCont'><div class='Icon'><div class='ErrIco Big'></div></div><div class='Txt'><h2>We have encountered a problem connecting to your Set Top Box.</h2></div></div>");
    }
    else {
        $('#divRecordings').html("<div class='DVR_Error'><div class='ErrCont'><div class='Icon'><div class='ErrIco Big'></div></div><div class='Txt'><h2>" + data.responseText + "</h2></div></div>");
    }



}



function TVGetSchedule_widget(sID) {
    $('#TVDVRLoadingDiv1').css('display', 'block');
    $('#TVDVRLoadingDiv').css('display', 'block');
    $.ajax({
        url: strDomainName + strSiteName + "/Members/Handlers/sw.ashx",
        type: "POST",
        dataType: "html",
        ifModified: false,
        async: true,
        time: 5000,
        crossDomain: false,
        data:
                {
                    Action: "GetSchedule_ENT",
                    STBID: sID
                },
        success: TVShowSchedule_Success,
        error: TVShowSchedule_Error
    });

}

function TVShowSchedule_Success(objResponse) {
    var strStorageSpace = '';
    $('#divPrgsBar').css('display', 'block');
    $('#divSchGreenBar').css('display', 'block');
    if (objResponse != null && objResponse == "No schedules found." || objResponse != null && objResponse == "") {
        $('#TVDVRLoadingDiv').css('display', 'none');
        $('#TVDVRLoadingDiv1').css('display', 'none');
        $('#divPrgsBar').css('display', 'none');
        $('#divSchGreenBar').html('');
        $('#divSchedule').html("<div class='DVR_Error'><div class='ErrCont'><div class='Icon'><div class='ErrIco Big'></div></div><div class='Txt'><h2>No schedules found.</h2></div></div>");
    }
    else if (objResponse != null && objResponse != "") {
        var objSchedule = eval('(' + objResponse + ')');
        var intNumber = 0;
        var totalreccnt = 0;
        var i = 0;
        if (objSchedule != null) {
            var objContentDetails = objSchedule.NewDataSet.Table1;
            totalreccnt = objContentDetails.length;
            if (typeof totalreccnt == "undefined" && objContentDetails != null) {

                var strStartTimeFirst = "";
                var strStartTimeSecond = "";
                var strEndTime = "";
                try {
                    if (objContentDetails.starttime.split(' ')[3] != " ") {
                        strStartTimeFirst = objContentDetails.starttime.split(' ')[3];
                        strStartTimeSecond = objContentDetails.starttime.split(' ')[4];
                        strEndTime = objContentDetails.Endtime;
                    }
                }
                catch (ex)
                    { }

                strScheduleHTML = '<ul class="WOB1">';
                strScheduleHTML += '<li class="F">';
                strScheduleHTML += '<div class="ChnLogo"><span class="' + objContentDetails.LogoCSS + '"></span></div>';
                strScheduleHTML += '<div class="ShowDesc">';
                strScheduleHTML += '<h6>' + objContentDetails.progname + '</h6>';
                if (strStartTimeFirst != '') {
                    strScheduleHTML += '<div class="TimeStmp">' + strStartTimeFirst + ' ' + strStartTimeSecond + ' - ' + strEndTime + '</div>';
                }
                strScheduleHTML += '</div></li>';
                strScheduleHTML += '</ul>';
                strStorageSpace = objContentDetails.OccupiedSpace;
                var spaceval = '';
                //$('#divPrgsBar').html("<span>" + strStorageSpace + "% Used</span>");
                spaceval = strStorageSpace;
                strStorageSpace = strStorageSpace + "%";
                $('#divSchGreenBar').html("<div class='UsageCount'>" + spaceval + "% Used</div><div class='GreenBar' id='divSchGreenBar' style=width:" + strStorageSpace + "></div>");
                $('#divSchedule').html(strScheduleHTML);

            }
            else {
                strScheduleHTML = '<ul class="WOB1">';

                var count = objContentDetails.length;
                if (count > 5) {
                    count = 5;
                }


                for (i = 0; i < count; i++) {
                    var strStartTimeFirst = "";
                    var strStartTimeSecond = "";
                    var strEndTime = "";
                    try {
                        if (objContentDetails[i].starttime.split(' ')[3] != " ") {
                            strStartTimeFirst = objContentDetails[i].starttime.split(' ')[3];
                            strStartTimeSecond = objContentDetails[i].starttime.split(' ')[4];
                        }
                    }
                    catch (ex)
                    { }

                    if (objContentDetails[i].EndTime != " ") {
                        strEndTime = objContentDetails[i].Endtime;
                    }

                    strScheduleHTML += '<li class="F">';
                    strScheduleHTML += '<div class="ChnLogo"><span class="' + objContentDetails[i].LogoCSS + '"></span></div>';
                    strScheduleHTML += '<div class="ShowDesc">';
                    strScheduleHTML += '<h6>' + objContentDetails[i].progname + '</h6>';
                    if (strStartTimeFirst != '') {
                        strScheduleHTML += '<div class="TimeStmp">' + strStartTimeFirst + ' ' + strStartTimeSecond + ' - ' + strEndTime + '</div>';
                    }
                    strScheduleHTML += '</div></li>';
                    strStorageSpace = objContentDetails[i].OccupiedSpace;

                }
                strScheduleHTML += '</ul>';
                var spaceval = '';
                //$('#divPrgsBar').html("<span>" + strStorageSpace + "% Used</span>");
                spaceval = strStorageSpace;
                strStorageSpace = strStorageSpace + "%";
                $('#divSchGreenBar').html("<div class='UsageCount'>" + spaceval + "% Used</div><div class='GreenBar' id='divSchGreenBar' style=width:" + strStorageSpace + "></div>");
                $('#divSchedule').html(strScheduleHTML);

            }

        }
    }


    $('#TVDVRLoadingDiv').css('display', 'none');
    $('#TVDVRLoadingDiv1').css('display', 'none');

}
function TVShowSchedule_Error(data) {
    $('#TVDVRLoadingDiv').css('display', 'none');
    $('#TVDVRLoadingDiv1').css('display', 'none');
    $('#divPrgsBar').css('display', 'none');
    $('#divSchGreenBar').html('');
    if (data.status == 999 && data.responseText.indexOf("OpenPortMapping") > -1 || data.responseText.indexOf("Unavailable") > 0) {
        $('#divSchedule').html("<div class='DVR_Error'><div class='ErrCont'><div class='Icon'><div class='ErrIco Big'></div></div><div class='Txt'><h2>We have encountered a problem connecting to your Set Top Box.</h2></div></div>");
    }
    else {
        $('#divSchedule').html("<div class='DVR_Error'><div class='ErrCont'><div class='Icon'><div class='ErrIco Big'></div></div><div class='Txt'><h2>" + data.responseText + "</h2></div></div>");
    }
}
function DVRInnerHide() {
    $('#divDVRPromo')[0].style.display = "none";
    $('#FiOSDVRActi')[0].style.display = "none";
    $('#FiOSDVRActiStatus')[0].style.display = "none";
    $('#divGotoFiosTv')[0].style.display = "none";
    $('#TVDVRLoadingDiv').css('display', 'none');
    $('#widget_common')[0].style.display = "none";
}

function edeskTrack(sID) {

    switch (sID) {
        case "STNT1":
            trackLogin("Recorded", "FiosTvWidgets");
            break;
        case "STNT2":
            trackLogin("Scheduled", "FiosTvWidgets");
            break;
        case "STNT3":
            trackLogin("Manage DVR", "FiosTvWidgets");
            break;
        default:
            trackLogin("Recorded", "FiosTvWidgets");
    }

}

function trackLogin(YourTitle, YourAppname) {
    var imgData = Math.random() + "";
    var imgDataVal = imgData * 10000000000000;
    var img = new Image(0, 0);
    evntData = "Type=2|Button&requestUrl=" + escape(window.location.href) + "&referrer=&Title=" + YourTitle;
    img.src = "https://www22.verizon.com/vztracker/vzTracker.aspx?appName=" + YourAppname + "&" + evntData + "&id=" + imgDataVal;
}

var YourTitle_Ftv = '';
var YourAppname_Ftv = '';
function SubNavClick(obj) {
    YourTitle_Ftv = jQuery(obj).attr('YourTitle');
    YourAppname_Ftv = jQuery(obj).attr("YourAppname");
    trackLoginSubNav();
    window.location.href = jQuery(obj).attr("url");
}

function ShowDDCombo(obj, id) {
    if (!document.getElementById('Combo_' + id)) {
        $(obj).attr({ 'id': 'ComboHead_' + id });
        var ddbody = $("." + id + "DDBody");
        $(ddbody).show();
        $(ddbody).attr('id', 'Combo_' + id);
        var toL = $(obj).offset().left;
        var toT = $(obj).offset().top + $(obj).height();
        var toW = $(obj).width();
        $(ddbody).css({ 'position': 'absolute', 'left': toL, 'top': toT, 'width': toW, 'display': 'block', 'z-index': 5000 })
        $('body').append(ddbody);
        $('#Combo_' + id + ' li a').bind('click', function() {
            $('#divRecSpacePx').css('display', 'none');
            $('#divSchGreenBar').css('display', 'none');
            //  $('#ComboHead_' + id + ' a').html($(this).html());
            $('#DVR-popup-CaptionID1').html($(this).html());
            $('#DVR-popup-CaptionID2').html($(this).html());

            $('#DVR-popup-CaptionID1').attr("DeviceSerialNumber", $(this).attr('DeviceSerialNumber'));
            $('#DVR-popup-CaptionID2').attr("DeviceSerialNumber", $(this).attr('DeviceSerialNumber'));
            //$('#ComboHead_' + id + ' a').html($(this).html());
            $('#Combo_' + id).hide();
            showSTBCont();
        });
    } else {
        if (document.getElementById('Combo_' + id).style.display == 'block')
            $('#Combo_' + id).hide();
        else {
            var toL = $(obj).offset().left;
            var toT = $(obj).offset().top + $(obj).height();
            var toW = $(obj).width();
            $('#Combo_' + id).css({ 'left': toL, 'top': toT, 'width': toW, 'display': 'block' })
        }
    }
}

function showSTBCont() {
    $('#divRecordings').empty();
    $('#divSchedule').empty();
    $('#TVDVRLoadingDiv').show();
    if (document.getElementById('TVDVRCont_1').style.display == 'block') {
        // TVGetSchedule_widget($('#DVR-popup-CaptionID1').text());
        TVGetSchedule_widget($('#DVR-popup-CaptionID1').attr('DeviceSerialNumber'));
    }
    else if (document.getElementById('TVDVRCont_2').style.display == 'block') {
        //TVGetRecord_widget($('#DVR-popup-CaptionID2').text());
        TVGetRecord_widget($('#DVR-popup-CaptionID2').attr('DeviceSerialNumber'));
    }
}

function resetDVRDDCont() {
    $('#DVRRecContent').hide();
    $('#DVRSchedContent').hide();
    $('#DVRSchedError').hide();
    $('#DVRRecError').hide();
    $('#DVRSchedNoRec').hide();
    $('#DVRRecNoRec').hide();
}
function ProgramDetailsPage_NL(FiosID, ChannelID, StartTime, StationID, SeriesID) {
    //Here we will create a new form and will post it in to the ProgramDetails.aspx page.
    var progDetailsForm = document.createElement("form");
    progDetailsForm.method = "GET";
    if (IsUserLoggedIn == 'False') {
        progDetailsForm.action = strDomainName + strSiteName + "/unprotected/ProgramDetails.aspx";
    }
    else {
        progDetailsForm.action = strDomainName + strSiteName + "/members/ProgramDetails.aspx";
    }

    document.body.appendChild(progDetailsForm);

    //Create input element for DCAction and add to form
    var dcActionElement = document.createElement("input");
    dcActionElement.setAttribute('name', 'DCAction');
    dcActionElement.setAttribute('type', 'hidden');
    dcActionElement.value = escape(FiosID) + ',' + escape(ChannelID) + ',' + escape(StartTime) + ',' + escape(StationID) + ',' + escape(SeriesID);
    progDetailsForm.appendChild(dcActionElement);

    progDetailsForm.submit();
}

var VZ_IsIE = document.all ? 1 : 0;
var bIsFloatSignInValidationDone = false;


var winProps = {
    Width: function() {
        return self.innerWidth || (document.documentElement.clientWidth || document.body.clientWidth);
    },
    Height: function() {
        return self.innerHeight || (document.documentElement.clientHeight || document.body.clientHeight);
    },
    Size: function() {
        return { width: this.Width(), height: this.Height() };
    }
};

function FloatshowDivPopup() {

    DivX = (document.body.clientWidth) / 2 - 140;


    $('#FloatEmptyDiv').css('height', document.body.scrollHeight + 'px');
    $('#FloatEmptyDiv').css('width', document.body.offsetWidth + 'px');


    document.getElementById('FloatEmptyDiv').style.display = "block";

    document.getElementById('FloatDivPopUp').style.width = '737px';


    document.getElementById('FloatDivPopUp').style.display = "block";
    document.getElementById('FloatDivPopUpM').style.display = "block";

    document.getElementById('FloatDivPopUpM').className = 'DVRPopUpMSA';

    document.getElementById('FloatEmptyDiv').className = 'EmptyDivAct';
    document.getElementById('FloatDivPopUp').className = 'SigninPopup';
    document.getElementById('FloatDivPopUp').innerHTML = '<div class="PopUpTop"><div class="PopupHeader LH32 Fl"><b>Please Sign In</b></div><div class="CloseBtn Fr LH32"><span class="Fl"><a style="cursor:pointer;" class="BlueLnkpop" onClick="FloathideDivPopup1();">Close</a></span><span class="CloseButn Fl" title="Close" onClick="FloathideDivPopup1()";></span></div><div class="CB"></div></div><div class="PopupContent_New" style="height:386px;" id="FloatDivPopUpM"></div>';


    if (isSSOEnabled.toLowerCase() == "true" && IsiFrameSignin.toLowerCase() == "true") {
        document.getElementById('FloatDivPopUpM').innerHTML = '<div class="W452 Fl"><div class="PadTL"><div class="B_Float">In order to access the page you requested, please sign in.</div><div class="MarT23"><iframe src="' + BaseIframeSRC + BaseGotoURL + '" frameborder="0" marginheight="0" marginwidth="0" scrolling="no" width="350" height="300"> </iframe></div></div></div> <div class="W286 Fr"><div class="PadT233"><div class="Txtclo3"><p>FiOS TV gives you 100% fiber-optic reliability, 130+ HD channels and access to over 25,000 On Demand titles per month.</p><p class="MarTB10">Plus, get  over 2,500 Flex View titles available on TV, PC, Web or Smartphone.</p><p>Get  America&#039;s fastest, most consistent and most reliable Internet.</p></div><div style="margin:28px 0px 0px 112px;width:82px;height:16px;"><a href="https://www22.verizon.com/ForYourHome/GoFlow/NationalBundles/BundleQualify.aspx?getstarted=FTBU" title="Get FiOS"><img src="' + baseImagePath + '/BgImages/GetFiOSBtn.jpg" alt="Get FiOS" border="0" /></a></div></div></div>';

    } else {
        document.getElementById('FloatDivPopUpM').innerHTML = '<div class="W452 Fl"><div class="PadTL"><div class="B_Float">In order to access the page you requested, please sign in.</div><div class="MarT23"><table width="390" border="0" cellspacing="0" cellpadding="0"><tr><td width="19%" height="30" valign="top"><div class="Txtclo4">User ID</div></td><td width="81%" valign="top"><input id="UserId_Popup" name="UserId_Popup" onkeydown="FloatSignInOnEnter(this,event);" tabindex="20" type="text" style="width: 200px;font-size:12px;border:solid 1px #7f9db9" value="" /></td></tr><tr><td valign="top"><div class="Txtclo4">Password</div></td><td valign="top"><input id="Password_Popup" name="Password_Popup" tabindex="21" style="width: 200px;font-size:12px;border:solid 1px #7f9db9" type="password" value="" onkeydown="FloatSignInOnEnter(this,event);" /><div class="PadT10 TxtClo1">(Passwords are case sensitive)<div class="PadT22" style="display: none;"><input name="" type="checkbox" value="" />&nbsp;&nbsp;Keep me signed in for 2 weeks unless I sign out.<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(Do not choose for public computers. <a href="javascript:;" class="BlueLnkInner">Learn More</a>)</div><div class="PadT22"><div class="Fl PadL10"><a class="RedBtn" href="#" onfocus="setSpacebarFlag();" tabindex="22" onkeydown="FloatSignInOnEnter(this,event);" onclick="FloatsubmitDocument(1,0);"><span>Sign In</span></a></div><div class="Fl PadL10"><a class="RedBtn" onclick="FloathideDivPopup1()" href="#"><span>Cancel</span></a></div><div class="CB"></div></div><div class="Txtcolo2 PadT27" ><a tabindex="23" href="javascript:ForgotId();" class="BlueLnkInner">Forgot your User ID or password?</a>&nbsp; |&nbsp; <a tabindex="24" href="javascript:RegisterMe();" class="BlueLnkInner">Register Now</a></div></div></td></tr></table></div></div></div><!--popup Content LHS End--><!--popup Content RHS start--><div class="W286 Fr"><div class="PadT233"><div class="Txtclo3"><p>FiOS TV gives you 100% fiber-optic reliability, 130+ HD channels and access to over 25,000 On Demand titles per month.</p><p class="MarTB10">Plus, get  over 2,500 Flex View titles available on TV, PC, Web or Smartphone.</p><p>Get  America&#039;s fastest, most consistent and most reliable Internet.</p></div><div style="margin:28px 0px 0px 112px;width:82px;height:16px;"><a href="https://www22.verizon.com/ForYourHome/GoFlow/NationalBundles/BundleQualify.aspx?getstarted=FTBU" title="Get FiOS"><img src="' + baseImagePath + '/BgImages/GetFiOSBtn.jpg" alt="Get FiOS" border="0" /></a></div></div></div>';

    }

    //    document.getElementById('FloatDivPopUp').style.left = (document.body.clientWidth - document.getElementById('FloatDivPopUp').offsetWidth) / 2;
    $('#FloatDivPopUp').css('left', ((document.body.clientWidth - document.getElementById('FloatDivPopUp').offsetWidth) / 2) + 'px');

    document.getElementById('FloatDivPopUp').style.top = ((document.body.clientHeight / 5) + document.body.scrollTop).toString() + "px";


    var strSetRecURL = document.location.href.split('?');
    if (strSetRecURL[0].toLowerCase().indexOf("signin.aspx") != -1) {
        document.getElementById('FloatDivPopUp').style.top = "240px";

    }

    $('FloatEmptyDiv').css('top', '0px');
    $('FloatEmptyDiv').css('left', '0px');

    $('#UserId_Popup').value = "";
    $('#Password_Popup').value = "";
    if ($('#UserId_Popup')) {
        $('#UserId_Popup').select();
        //setFocus("UserId_Popup");
    }

    if (VZ_IsIE) {
        window.onscroll = reLoginPopup;
        window.onresize = reLoginPopup;
    } else {
        window.addEventListener("scroll", reLoginPopup, false);
        window.addEventListener("resize", reLoginPopup, false);
    }

    return bIsFloatSignInValidationDone;
}


function reLoginPopup() {
    if (document.getElementById('FloatDivPopUp')) {
        if (document.getElementById('FloatDivPopUp').style.display == 'block') {
            var winSize = winProps.Size();
            if (VZ_IsIE) {
                document.getElementById('FloatEmptyDiv').style.height = document.body.scrollHeight + 'px';
                document.getElementById('FloatEmptyDiv').style.width = document.body.clientWidth + 'px';
            } else {
                document.getElementById('FloatEmptyDiv').style.height = document.body.scrollHeight + 'px';
                document.getElementById('FloatEmptyDiv').style.width = document.body.offsetWidth + 'px';
            }
            document.getElementById('FloatDivPopUp').style.left = (winSize.width - document.getElementById('FloatDivPopUp').offsetWidth) / 2 + 'px';
            var pgScrollTop = document.body.scrollTop > 0 ? document.body.scrollTop : document.documentElement.scrollTop;
            document.getElementById('FloatDivPopUp').style.top = pgScrollTop + (winSize.height - document.getElementById('FloatDivPopUp').offsetHeight) / 2 + 'px';
        }
    }
}


function Divshow() {
    if ($('SFP')) {
        if ($('SFP').style.display == "block")
            document.getElementById('SFP').style.display = "none";
        else
            document.getElementById('SFP').style.display = "block";
    }
}

function FloathideDivPopup1() {
    document.getElementById('FloatDivPopUp').style.display = "none";
    document.getElementById('FloatEmptyDiv').style.display = "none";
    document.getElementById('FloatDivPopUpM').style.display = "none";
}

var IsFloatSignInFocus;
function setSpacebarFlag() {
    IsFloatSignInFocus = true;
}

function ForgotId() {
    window.open(strForgot);
}
function RegisterMe() {
    window.open('https://www22.verizon.com/foryourhome/registration/Reg/RegisterBTN.aspx');
}
function Buy() {
    window.open('https://www22.verizon.com/ForYourHome/GoFlow/NationalBundles/BundleQualify.aspx?getstarted=FTBU');
}

function FloatSignInOnEnter(field, evt) {
    var key;
    key = (window.event) ? event.keyCode : evt.which;
    if (key == 13) {
        FloatsubmitDocument(1, 0);
        return;
    }
    if (IsFloatSignInFocus == true && key == 32) {
        if (bIsFloatSignInValidationDone == false) setFocus("UserId");
        FloatsubmitDocument(1, 0);
        return;
    }
}



function SignIn() {

    if (isSSOEnabled == "True") {
        document.getElementById("IDToken1").value = document.getElementById("UserId_Popup").value;
        document.getElementById("IDToken2").value = document.getElementById("Password_Popup").value;
    }
    FloatSignForm.submit();
    //window.document.forms["aspnetForm"].submit();
    return true;
    showOverlay();

    DivX = (document.body.clientWidth) / 2 - 140;
    document.getElementById('FloatEmptyDiv').style.display = "none";
    document.getElementById('FloatDivPopUp').style.top = ((document.body.clientHeight / 5) + document.body.scrollTop).toString() + "px";
    document.getElementById('FloatDivPopUp').style.left = DivX;
    document.getElementById('FloatDivPopUp').style.width = "380px";
    document.getElementById('FloatDivPopUp').innerHTML = '<div id="divLoading" style="z-index: 200; position: absolute;background-color: #ffffff;">' +
                        '<table id="tblLoading" border="0" cellpadding="2" cellspacing="5">' +
                        '    <tr>' +
                        '        <td align="left">' +
                        '            <img src=' + BaseImagePath + '/Icons/anim-loader.gif />' +
                        '        </td>' +
                        '        <td>' +
                        '            <div id="divRecording" style="background-color: #ffffff; font-weight: bold; font-size: 13px; color: #747476;">Please wait while we retrieve your information...</div>' +
                        '        </td>' +
                        '    </tr>' +
                        '</table></div>';
    document.getElementById('FloatEmptyDiv').style.display = "block";

}

function showOverlay() {
    if ($('overlay') == null) {
        createOverlay();
    }
    var arrayPageSize = getPageSize();
    //$('overlay').setStyle({ width: arrayPageSize[0] });
    //$('overlay').setStyle({ height: arrayPageSize[1] });
    $('overlay').width = arrayPageSize[0];
    $('overlay').height = arrayPageSize[1];
    //new Effect.Appear('overlay', { duration: overlayDuration, from: 0.0, to: overlayOpacity });
}

function getPageSize() {

    var xScroll, yScroll;

    if (window.innerHeight && window.scrollMaxY) {
        xScroll = window.innerWidth + window.scrollMaxX;
        yScroll = window.innerHeight + window.scrollMaxY;
    } else if (document.body.scrollHeight > document.body.offsetHeight) { // all but Explorer Mac
        xScroll = document.body.scrollWidth;
        yScroll = document.body.scrollHeight;
    } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
        xScroll = document.body.offsetWidth;
        yScroll = document.body.offsetHeight;
    }

    var windowWidth, windowHeight;

    if (self.innerHeight) {	// all except Explorer
        if (document.documentElement.clientWidth) {
            windowWidth = document.documentElement.clientWidth;
        } else {
            windowWidth = self.innerWidth;
        }
        windowHeight = self.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
        windowWidth = document.documentElement.clientWidth;
        windowHeight = document.documentElement.clientHeight;
    } else if (document.body) { // other Explorers
        windowWidth = document.body.clientWidth;
        windowHeight = document.body.clientHeight;
    }

    // for small pages with total height less then height of the viewport
    if (yScroll < windowHeight) {
        pageHeight = windowHeight;
    } else {
        pageHeight = yScroll;
    }


    // for small pages with total width less then width of the viewport
    if (xScroll < windowWidth) {
        pageWidth = xScroll;
    } else {
        pageWidth = windowWidth;
    }

    arrayPageSize = new Array(pageWidth, pageHeight, windowWidth, windowHeight)
    return arrayPageSize;
}
