﻿var billValueCleared = false;
var nextTab = ".pan02";
var slidesPaused = false;
var sliderTimeout = null;
var hasFocus = false;
var isPageDirty = false;
var channelDivId = "";
var channelAnchorId = "";
var termConditionCloseLink = null;
function ShowPromotionTermsAndCondPopUp(link, planName) {
    $(link).css('color', "Purple");
    $(link).bind("mouseover",
    function()
    { $(link).css('color', "Black") });

    $(link).bind("mouseout",
    function()
    { $(link).css('color', "Purple") });

    $(".b2offerDiv").remove();
    termConditionCloseLink = link;
    planName = planName.replace("_#quo#_", "'");
    planName = planName.replace("<u></u>", "");
    planName = planName.replace("<b></b>", "");
    planName = planName.replace("<i></i>", "");
    if ($.browser.msie && jQuery.browser.version.substr(0, 1) == "7") {
        $(link).parent().parent().append("<div class='b2offerDiv'>"
                 + "<div class='divFixedHeader'>"
                    + "<div style='float:left;margin-top:3px;width:89%;padding-left:8px;padding-top:6px;' >"
                        + "<div style='font-family:Helvetica, Helvetica Neue, Arial, sans-serif;font-weight:bold;font-size:11px;'><span  id='splanName' style='text-decoration:underline'>"
                             + planName + "</span><br/>Promotions Terms and Conditions<br/>"
                        + "</div>"
                    + "</div>"
                    + "<div class='divTermClose'><b>"
                        + "<a href='javascript:' style='text-decoration:none;color:#B0B0B0' onclick='CloseTermsDiv();'>x</a></b>"
                    + "</div>"
                + "</div>"
                + "<br/><br/><div class='b2offerDivText' style='padding-top:13px'>"
                + $(link).find(".spanCondition").text()
                + "</div></div>");
    }
    else {
        $(link).parent().parent().append("<div class='b2offerDiv'>"
                + "<div class='divFixedHeader'>"
                    + "<div style='float:left;width:89%;padding-left:8px;padding-top:6px;' >"
                        + "<div style='font-family:Helvetica, Helvetica Neue, Arial, sans-serif;font-weight:bold;font-size:11px'><span id='splanName' style='text-decoration:underline'>"
                         + planName + "</span><br/>Promotions Terms and Conditions<br/>"
                        + "</div>"
                    + "</div>"
                    + "<div class='divTermClose' ><b>"
                        + "<a href='javascript:' style='text-decoration:none;color:#B0B0B0' onclick='CloseTermsDiv();'>x</a></b>"
                    + "</div>"
                + "</div>"
                + "<br/><br/><div class='b2offerDivText'>"
                + $(link).find(".spanCondition").text()
                + "</div></div>");

    }
    if ($(".b2offerDivText").css("height") == "auto" && $(".b2offerDivText").text().length > 1652) {
        $(".b2offerDivText").css("height", "251px");
    }
    var height = 1 * $(".b2offerDivText").css("height").substring(0, $(".b2offerDivText").css("height").length - 2);
    if (height > 250) {
        $(".b2offerDivText").css("overflow", "auto");
        $(".b2offerDivText").css("height", "250px");
    }

}

function ShowPhoneAssistanceSavings(savings) {
    $("#savePrice").html("$" + savings + "<label style='font-size:11px'>/year</label>!");
    $("#phoneAssistanceSavings").css("display", "inline");
    //        $("#phoneAssistance").css("display", "none");
    if ($('#divBr') == null || $('#divBr').length == 0) {
        $('#phoneAssistanceSavings').after("<div id='divBr'> <br /><br /><br /><br /><br /><br /></div>");
    }
    if ($.browser.msie && jQuery.browser.version.substr(0, 1) == "7") {
        $('#header ul').css("margin-top", "5px");
    }
    else {
        $('#header ul').css("margin-top", "7px");
    }

}
function CloseTermsDiv() {

    if (termConditionCloseLink != null) {
        $(termConditionCloseLink).parent().parent().find(".b2offerDiv").css("display", "none");
        $(termConditionCloseLink).parent().parent().find(".b2offerDiv").remove();
    }
}
function CleanStringForClickTale(str) {
    return str.replace(/\s*</g, "<").replace(/>\s*/g, ">").replace(/\n/g, "").replace(/\r/g, "").replace(/\s+/g, " ").replace(/"/g, '\\"');
}

function ServiceChanged() {
    isPageDirty = true;
}

function CleanCarousel() {
    $('#divSlide').empty();
    $('#divSlide').append('<ul id="mycarousel" class="jcarousel-skin-tango" ></ul>');
}
function AddItemsCarousel(name) {
    $("#mycarousel").html($("#" + name + " ul").html());
}
function CallCarousel() {
    jQuery('#mycarousel').jcarousel({
        scroll: 1,
        moduleWidth: 78,
        rows: 2,
        animation: 'slow'
    });
}
function ChannelLabelClick(label) {
    if ($("#divAllChannels td input:checked").length > 0) {
        var name = label.id.substring(4);
        FindAndShowResources(name);
    }

    else {
        CloseChannelPopUp();

    }
}

function FindAndShowResources(resourceId) {
    var resourceName = ""
    switch (resourceId) {
        case "tv_general":
            resourceName = "divGeneralchannels";
            break;
        case "tv_Sports":
            resourceName = "divSportschannels";
            break;
        case "tv_Movies":
            resourceName = "divMovieschannels";
            break;
        case "tv_Music":
            resourceName = "divMusicEntertainmentchannels";
            break;
        case "tv_Adult":
            resourceName = "divAdult";
            break;
        case "tv_Family":
            resourceName = "divKidsFamilychannels";
            break;
        case "tv_News":
            resourceName = "divNewschannels";
            break;
        case "tv_Education":
            resourceName = "divEducationalchannels";
            break;
        case "tv_Internation":
            resourceName = "divInternationalchannels";
            break;
    }
    ShowChannelPopUp(resourceName, resourceId);
}

function ShowChannelPopUp(subDivId, aId) {
    if (typeof ClickTaleExec == 'function') ClickTaleExec('ShowChannelPopUp("' + subDivId + '", "' + aId + '")');
    //    if (channelDivId != "") {
    //        CleanCarousel();
    //        AddItemsCarousel(channelDivId);
    //        CallCarousel()
    //        //$("#" + channelDivId).html($("#divSlide").html());
    //    }
    channelAnchorId = aId;
    $("#divSlide").css("display", "");
    $("#anchClose").css("display", "");
    $("#divMainChannelList").css("display", "");
    CleanCarousel();
    AddItemsCarousel(subDivId);
    CallCarousel()
    channelDivId = subDivId;
}
function CloseChannelPopUp() {
    if (typeof ClickTaleExec == 'function') ClickTaleExec('CloseChannelPopUp()');
    //    $("#" + channelDivId).html($("#divSlide").html());
    channelDivId = "";
    channelAnchorId = "";
    $("#divSlide").css("display", "none");
    $("#divMainChannelList").css("display", "none");
}
function InactiveText() {
    if (typeof ClickTaleExec == 'function') ClickTaleExec('InactiveText()');
    if ($("#HomeAddress").val() == "" || $("#HomeAddress").val() == "(required)") {
        $("#HomeAddress").css("color", "InactiveCaptionText");
    }
    if ($("#AptCondoNo").val() == "" || $("#AptCondoNo").val() == "(optional)") {
        $("#AptCondoNo").css("color", "InactiveCaptionText");
    }
    if ($("#CityStateZip").val() == "" || $("#CityStateZip").val() == "(required)") {
        $("#CityStateZip").css("color", "InactiveCaptionText");
    }
}


$('#form4').submit(function() {
    var logObj = { prop5: $('#SubmitAddress').attr('value'), prop6: $("#HomeAddress").val(), prop7: $("#AptCondoNo").val(), prop8: $("#CityStateZip").val() };
    //console.log("LogOmnitureAddressSubmit");

    LogOmnitureAddressSubmit(logObj);
});


function ValidateRequired() {
    if (typeof ClickTaleExec == 'function') ClickTaleExec('ValidateRequired()');
    if ($("#HomeAddress").val() == "(required)") {

        $("#HomeAddress").val("");
    }


    if ($("#CityStateZip").val() == "(required)") {

        $("#CityStateZip").val("");
    }
    var logObj = { prop5: $('#SubmitAddress').attr('value'), prop6: $("#HomeAddress").val(), prop7: $("#AptCondoNo").val(), prop8: $("#CityStateZip").val() };
    //console.log("LogOmnitureAddressSubmit");
    LogOmnitureAddressSubmit(logObj);
    
}



function ValidateRequiredAddressEntry(log) {
    if (typeof ClickTaleExec == 'function') ClickTaleExec('ValidateRequiredAddressEntry()');
    if ($("#valSumContainer").find("ul").length > 0) {
        if ($("#valSumContainer").find("ul")[0].innerHTML.indexOf("City, State and/or Zip") == -1
                        && $("#valSumContainer").find("ul")[0].innerHTML.indexOf("Street Address") == -1) {
            if ($("#HomeAddress").val() == "(required)") {
                $("#HomeAddress").val("");
            }

            if ($("#CityStateZip").val() == "(required)") {

                $("#CityStateZip").val("");
            }
            if ($("#HomeAddress").val() == "(required)") {
                $("#HomeAddress").val("");
            }

            if ($("#CityStateZip").val() == "(required)") {

                $("#CityStateZip").val("");
            }
        }
        else if ($("#valSumContainer").find("ul")[0].innerHTML.indexOf("City, State and/or Zip") > -1
                        || $("#valSumContainer").find("ul")[0].innerHTML.indexOf("Street Address") > -1) {

            if ($("#valSumContainer").find("ul")[0].innerHTML.indexOf("City") > -1) {
                if ($("#CityStateZip").val() == "(required)") {
                    $("#CityStateZip").val("");
                    $("#valSumContainer").find("li:contains('City, State and/or Zip')").remove();
                }
                else if ($("#CityStateZip").val() != "") {
                    $("#valSumContainer").find("li:contains('City, State and/or Zip')").remove();
                }
            }
            else {
                if ($("#CityStateZip").val() == "(required)") {

                    $("#CityStateZip").val("");
                }
                else if ($("#CityStateZip").val() == "") {
                    $("#CityStateZip").val("(required)");
                }
            }
            if ($("#valSumContainer").find("ul")[0].innerHTML.indexOf("Street") > -1) {
                if ($("#HomeAddress").val() == "(required)") {
                    $("#HomeAddress").val("");
                    $("#valSumContainer").find("li:contains('Street Address')").remove();
                }
                else if ($("#HomeAddress").val() != "") {
                    $("#valSumContainer").find("li:contains('Street Address')").remove();
                }
            }
            else {
                if ($("#HomeAddress").val() == "(required)") {

                    $("#HomeAddress").val("");
                }
                else if ($("#HomeAddress").val() == "") {
                    $("#HomeAddress").val("(required)");
                }
            }
        }
    }
    var logObj = { prop5: $('#SubmitAddress').attr('value'), prop6: $("#HomeAddress").val(), prop7: $("#AptCondoNo").val(), prop8: $("#CityStateZip").val() };
   if(typeof(log)!='undefined')
    LogOmnitureAddressSubmit(logObj);  
}

function SetRequired() {
    if (typeof ClickTaleExec == 'function') ClickTaleExec('SetRequired()');
    if ($("#HomeAddress").val() == "" || $("#HomeAddress").val() == "(required)") {

        $("#HomeAddress").val("(required)");
        $("#HomeAddress").css("color", "InactiveCaptionText");
    }
    if ($("#AptCondoNo").val() == "" || $("#AptCondoNo").val() == "(optional)") {

        $("#AptCondoNo").val("(optional)");
        $("#AptCondoNo").css("color", "InactiveCaptionText");
    }
    if ($("#CityStateZip").val() == "" || $("#CityStateZip").val() == "(required)") {

        $("#CityStateZip").val("(required)");
        $("#CityStateZip").css("color", "InactiveCaptionText");
    }
}

function SetRequiredText(val1) {
    if (typeof ClickTaleExec == 'function') ClickTaleExec('SetRequiredText("' + val1 + '")');
    if (val1 == "1" && $("#HomeAddress").val() == "") {
        $("#HomeAddress").val("(required)");
        $("#HomeAddress").css("color", "InactiveCaptionText");
    }
    else if (val1 == "2" && $("#AptCondoNo").val() == "") {
        $("#AptCondoNo").val("(optional)");
        $("#AptCondoNo").css("color", "InactiveCaptionText");
    }
    else if (val1 == "3" && $("#CityStateZip").val() == "") {
        $("#CityStateZip").val("(required)");
        $("#CityStateZip").css("color", "InactiveCaptionText");
    }
}

function ClearRequiredText(val1) {
    if (typeof ClickTaleExec == 'function') ClickTaleExec('ClearRequiredText("' + val1 + '")');
    if (val1 == "1" && $("#HomeAddress").val() == "(required)") {
        $("#HomeAddress").val("");
        $("#HomeAddress").css("color", "Black");
    }
    else if (val1 == "1" && $("#HomeAddress").val() != "(required)"
                            && $("#HomeAddress").val() != "") {
        $("#HomeAddress").css("color", "Black");
    }

    else if (val1 == "2" && $("#AptCondoNo").val() == "(optional)") {
        $("#AptCondoNo").val("");
        $("#AptCondoNo").css("color", "Black");
    }
    else if (val1 == "2" && $("#AptCondoNo").val() != "(optional)"
                            && $("#AptCondoNo").val() != "") {
        $("#AptCondoNo").css("color", "Black");
    }
    else if (val1 == "3" && $("#CityStateZip").val() == "(required)") {
        $("#CityStateZip").val("");
        $("#CityStateZip").css("color", "Black");
    }
    else if (val1 == "3" && $("#CityStateZip").val() != "(required)"
                            && $("#CityStateZip").val() != "") {
        $("#CityStateZip").css("color", "Black");
    }
}
function AlertChanged() {
    if (typeof ClickTaleExec == 'function') ClickTaleExec('AlertChanged()');
    isPageDirty = true;
}

$(document).ready(function() {
    $(".imageLogo").error(function() { $(this).attr('src', contentBaseUrl + '/images/no-logo.gif'); });
    $("#serviceAccordion").accordion({
        active: false,
        autoHeight: false,
        navigation: true,
        collapsible: true,
        clearStyle: true,
        icons: { 'header': '', 'headerSelected': '' }
    });
    
    

   

    $('#serviceBundleAccord').addClass('ui-state-active');


    $("#RecFinderModalBg").bind("click", function() {
        $("#RecFinderModal").hide();
        $("#RecFinderModalBg").hide();

        $("#serviceAccordion").css("position", "inherit");
        $("#serviceAccordion").css("z-Index", "inherit");

    });
    $("#RecFinderModalBg2").bind("click", function() {
        $("#RecFinderModal").hide();
        $("#RecFinderModalBg").hide();       

    });

});

function ShowWirelessImage() {
    $(document).ready(function() { $("#imgWireless").css("display", ""); });
}
function InitializeCreditSliderTouch(sliderID, className, creditValue, creditScore) {
    if (creditScore != $("#creditRatings").val()) {

        if ($("#creditRatings").val() == "None") {
            creditValue = 0;
        }
        else if ($("#creditRatings").val() == "NoCredit") {
            creditValue = 70;
        }
        else if ($("#creditRatings").val() == "Poor") {
            creditValue = 140;
        }
        else if ($("#creditRatings").val() == "OK") {
            creditValue = 210;
        }
        else if ($("#creditRatings").val() == "Good") {
            creditValue = 280;
        }
        else if ($("#creditRatings").val() == "VeryGood") {
            creditValue = 350;
        }

    }

    if (creditValue == "") {
        creditValue = 0;
    }
    creditValue = parseInt(creditValue, 0);

    $(sliderID).slider({
        value: creditValue,
        from: 0,
        to: 350,
        scale: ['', '<b>No credit</b>', '<b>Poor</b><br/>(under 620)', '<b>Ok</b><br/>(620-699)', '<b>Good</b><br/>(700-749)', '<b>Excellent</b><br/>(over 750)'],
        limits: false,
        step: 70,
        dimension: '',
        smooth: false,
        onstatechange: function(value) {
            if (value == 70) {
                $("#creditRatings").val("NoCredit");
            }
            else if (value == 140) {
                $("#creditRatings").val("Poor");
            }
            else if (value == 210) {
                $("#creditRatings").val("OK");
            }
            else if (value == 280) {
                $("#creditRatings").val("Good");
            }
            else if (value == 350) {
                $("#creditRatings").val("VeryGood");
            }
            else if (value > 350) {
                $("#creditRatings").val("VeryGood");
                return false;
            }
            if (value < 70) {
                $("#creditRatings").val("None");
                return false;
            }
        }
    });
}
function InitializeCreditSlider(sliderID, className, creditValue, creditScore) {
    if (creditScore != $("#creditRatings").val()) {

        if ($("#creditRatings").val() == "NoCredit") {
            creditValue = 70;
        }
        else if ($("#creditRatings").val() == "Poor") {
            creditValue = 140;
        }
        else if ($("#creditRatings").val() == "OK") {
            creditValue = 210;
        }
        else if ($("#creditRatings").val() == "Good") {
            creditValue = 280;
        }
        else if ($("#creditRatings").val() == "VeryGood") {
            creditValue = 350;
        }

    }

    if (creditValue == "") {
        //  creditValue = 70;
    }
    $(sliderID).slider({
        value: creditValue,
        min: 0,
        max: 389,
        step: 70,
        slide: function(event, ui) {
            if (ui.value == 70) {
                $("#creditRatings").val("NoCredit");
            }
            else if (ui.value == 140) {
                $("#creditRatings").val("Poor");
            }
            else if (ui.value == 210) {
                $("#creditRatings").val("OK");
            }
            else if (ui.value == 280) {
                $("#creditRatings").val("Good");
            }
            else if (ui.value == 350) {
                $("#creditRatings").val("VeryGood");
            }
            else if (ui.value > 350) {
                $("#creditRatings").val("VeryGood");
                return false;
            }
            if (ui.value < 70) {
                $("#creditRatings").val("NoCredit");
                return false;
            }
        }
    });
    $(sliderID).removeClass('ui-widget-content').addClass(className);
    $(sliderID + " a").removeClass('ui-state-focus').removeClass('ui-corner-all').removeClass('ui-state-hover').removeClass('ui-state-hover').removeClass('ui-state-default');
    $(sliderID + " a").addClass('ui-slider-handle-default').addClass('ui-slider-state-hover').addClass('ui-InitializeSlider-state-focus');

}
function ShowHideHelper(id, isShow) {
    if (typeof ClickTaleExec == 'function') ClickTaleExec('ShowHideHelper("' + id + '", "' + isShow + '")');
    $("#" + id).css("display", isShow);
}
function HideToolTip() {
    if (typeof ClickTaleExec == 'function') ClickTaleExec('HideToolTip()');
    ShowHideHelper('internetSpeedDialContent', 'none');
    ShowHideHelper('internetSpeedLowContent', 'none');
    ShowHideHelper('internetSpeedMedContent', 'none');
    ShowHideHelper('internetSpeedFastContent', 'none');
    ShowHideHelper('internetSpeedTurboContent', 'none');
}

function InitializeSpeedSliderTouch(sliderID, className, creditValue, internetScore) {
    if (internetScore != $("#internetSpeedOption").val()) {

        if ($("#internetSpeedOption").val() == "None") {
            creditValue = 0;
        }
        else if ($("#internetSpeedOption").val() == "DialUp") {
            creditValue = 70;
        }
        else if ($("#internetSpeedOption").val() == "Low") {
            creditValue = 140;
        }
        else if ($("#internetSpeedOption").val() == "Medium") {
            creditValue = 210;
        }
        else if ($("#internetSpeedOption").val() == "Fast") {
            creditValue = 280;
        }
        else if ($("#internetSpeedOption").val() == "Turbo") {
            creditValue = 350;
        }

    }
    if (creditValue == "") {
        creditValue = 0;
    }
    creditValue = parseInt(creditValue, 0);

    $(sliderID).slider({
        from: 0,
        to: 350,
        scale: ['<div id="internetSpeedNoneHelp" onmouseover="ShowHideHelper(\'internetSpeedNoneContent\',\'\')" onmouseout="ShowHideHelper(\'internetSpeedNoneContent\',\'none\')" class="dialup hshLbl">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>',
                '<div id="internetSpeedDialHelp" onmouseover="ShowHideHelper(\'internetSpeedDialContent\',\'\')" onmouseout="ShowHideHelper(\'internetSpeedDialContent\',\'none\')" class="dialup hshLbl"> Dial&ndash;up<br />(<750 Kbps)</div>',
                '<div id="internetSpeedLowHelp" onmouseover="ShowHideHelper(\'internetSpeedLowContent\',\'\')" onmouseout="ShowHideHelper(\'internetSpeedLowContent\',\'none\')" class="lowspeed hshLbl">Low<br />(<3 Mbps)</div>',
                '<div id="internetSpeedMedHelp" onmouseover="ShowHideHelper(\'internetSpeedMedContent\',\'\')" onmouseout="ShowHideHelper(\'internetSpeedMedContent\',\'none\')" class="medspeed hshLbl">Medium<br />(3.1&ndash;6 Mbps)</div>',
                '<div id="internetSpeedFastlHelp" onmouseover="ShowHideHelper(\'internetSpeedFastContent\',\'\')" onmouseout="ShowHideHelper(\'internetSpeedFastContent\',\'none\')" class="fastspeed hshLbl">Fast<br />(6.1&ndash;12 Mbps)</div>',
                '<div id="internetSpeedTurboHelp" onmouseover="ShowHideHelper(\'internetSpeedTurboContent\',\'\')" onmouseout="ShowHideHelper(\'internetSpeedTurboContent\',\'none\')" class="turbospeed hshLbl">Turbo<br />(12.1+ Mbps)</div>'],
        limits: false,
        step: 70,
        dimension: '',
        smooth: false,
        onstatechange: function(value) {
            if (value == 70) {
                $("#internetSpeedOption").val("DialUp");
                ShowHideHelper('internetSpeedDialContent', '');
                ShowHideHelper('internetSpeedLowContent', 'none');
                ShowHideHelper('internetSpeedMedContent', 'none');
                ShowHideHelper('internetSpeedFastContent', 'none');
                ShowHideHelper('internetSpeedTurboContent', 'none');

            }
            else if (value == 140) {
                $("#internetSpeedOption").val("Low");
                ShowHideHelper('internetSpeedDialContent', 'none');
                ShowHideHelper('internetSpeedLowContent', '');
                ShowHideHelper('internetSpeedMedContent', 'none');
                ShowHideHelper('internetSpeedFastContent', 'none');
                ShowHideHelper('internetSpeedTurboContent', 'none');
            }
            else if (value == 210) {
                $("#internetSpeedOption").val("Medium");
                ShowHideHelper('internetSpeedDialContent', 'none');
                ShowHideHelper('internetSpeedLowContent', 'none');
                ShowHideHelper('internetSpeedMedContent', '');
                ShowHideHelper('internetSpeedFastContent', 'none');
                ShowHideHelper('internetSpeedTurboContent', 'none');
            }
            else if (value == 280) {
                $("#internetSpeedOption").val("Fast");
                ShowHideHelper('internetSpeedDialContent', 'none');
                ShowHideHelper('internetSpeedLowContent', 'none');
                ShowHideHelper('internetSpeedMedContent', 'none');
                ShowHideHelper('internetSpeedFastContent', '');
                ShowHideHelper('internetSpeedTurboContent', 'none');
            }
            else if (value == 350) {
                $("#internetSpeedOption").val("Turbo");
                ShowHideHelper('internetSpeedDialContent', 'none');
                ShowHideHelper('internetSpeedLowContent', 'none');
                ShowHideHelper('internetSpeedMedContent', 'none');
                ShowHideHelper('internetSpeedFastContent', 'none');
                ShowHideHelper('internetSpeedTurboContent', '');
            }
            else if (value > 350) {
                $("#internetSpeedOption").val("Turbo");
                ShowHideHelper('internetSpeedDialContent', 'none');
                ShowHideHelper('internetSpeedLowContent', 'none');
                ShowHideHelper('internetSpeedMedContent', 'none');
                ShowHideHelper('internetSpeedFastContent', 'none');
                ShowHideHelper('internetSpeedTurboContent', '');
                return false;
            }
            if (value < 70) {
                $("#internetSpeedOption").val("None");
                ShowHideHelper('internetSpeedDialContent', '');
                ShowHideHelper('internetSpeedLowContent', 'none');
                ShowHideHelper('internetSpeedMedContent', 'none');
                ShowHideHelper('internetSpeedFastContent', 'none');
                ShowHideHelper('internetSpeedTurboContent', 'none');
                return false;
            }
        }

    });


    //$("#MyServices.CreditRating").val();
    //$(sliderID).removeClass('ui-widget-content').addClass(className);
    //$(sliderID + " a").removeClass('ui-state-focus').removeClass('ui-corner-all').removeClass('ui-state-hover').removeClass('ui-state-hover').removeClass('ui-state-default');
    //$(sliderID + " a").addClass('ui-slider-handle-default').addClass('ui-slider-state-hover').addClass('ui-InitializeSlider-state-focus');

}

function InitializeSpeedSlider(sliderID, className, creditValue, internetScore) {
    if (internetScore != $("#internetSpeedOption").val()) {

        if ($("#internetSpeedOption").val() == "DialUp") {
            creditValue = 70;
        }
        else if ($("#internetSpeedOption").val() == "Low") {
            creditValue = 140;
        }
        else if ($("#internetSpeedOption").val() == "Medium") {
            creditValue = 210;
        }
        else if ($("#internetSpeedOption").val() == "Fast") {
            creditValue = 280;
        }
        else if ($("#internetSpeedOption").val() == "Turbo") {
            creditValue = 350;
        }

    }

    $(sliderID).slider({
        value: creditValue,
        min: 0,
        max: 389,
        step: 70,
        slide: function(event, ui) {

            if (ui.value == 70) {
                $("#internetSpeedOption").val("DialUp");
                ShowHideHelper('internetSpeedDialContent', '');
                ShowHideHelper('internetSpeedLowContent', 'none');
                ShowHideHelper('internetSpeedMedContent', 'none');
                ShowHideHelper('internetSpeedFastContent', 'none');
                ShowHideHelper('internetSpeedTurboContent', 'none');

            }
            else if (ui.value == 140) {
                $("#internetSpeedOption").val("Low");
                ShowHideHelper('internetSpeedDialContent', 'none');
                ShowHideHelper('internetSpeedLowContent', '');
                ShowHideHelper('internetSpeedMedContent', 'none');
                ShowHideHelper('internetSpeedFastContent', 'none');
                ShowHideHelper('internetSpeedTurboContent', 'none');
            }
            else if (ui.value == 210) {
                $("#internetSpeedOption").val("Medium");
                ShowHideHelper('internetSpeedDialContent', 'none');
                ShowHideHelper('internetSpeedLowContent', 'none');
                ShowHideHelper('internetSpeedMedContent', '');
                ShowHideHelper('internetSpeedFastContent', 'none');
                ShowHideHelper('internetSpeedTurboContent', 'none');
            }
            else if (ui.value == 280) {
                $("#internetSpeedOption").val("Fast");
                ShowHideHelper('internetSpeedDialContent', 'none');
                ShowHideHelper('internetSpeedLowContent', 'none');
                ShowHideHelper('internetSpeedMedContent', 'none');
                ShowHideHelper('internetSpeedFastContent', '');
                ShowHideHelper('internetSpeedTurboContent', 'none');
            }
            else if (ui.value == 350) {
                $("#internetSpeedOption").val("Turbo");
                ShowHideHelper('internetSpeedDialContent', 'none');
                ShowHideHelper('internetSpeedLowContent', 'none');
                ShowHideHelper('internetSpeedMedContent', 'none');
                ShowHideHelper('internetSpeedFastContent', 'none');
                ShowHideHelper('internetSpeedTurboContent', '');
            }
            else if (ui.value > 350) {
                $("#internetSpeedOption").val("Turbo");
                ShowHideHelper('internetSpeedDialContent', 'none');
                ShowHideHelper('internetSpeedLowContent', 'none');
                ShowHideHelper('internetSpeedMedContent', 'none');
                ShowHideHelper('internetSpeedFastContent', 'none');
                ShowHideHelper('internetSpeedTurboContent', '');
                return false;
            }
            if (ui.value < 70) {
                $("#internetSpeedOption").val("DialUp");
                ShowHideHelper('internetSpeedDialContent', '');
                ShowHideHelper('internetSpeedLowContent', 'none');
                ShowHideHelper('internetSpeedMedContent', 'none');
                ShowHideHelper('internetSpeedFastContent', 'none');
                ShowHideHelper('internetSpeedTurboContent', 'none');
                return false;
            }
        }

    });


    //$("#MyServices.CreditRating").val();
    $(sliderID).removeClass('ui-widget-content').addClass(className);
    $(sliderID + " a").removeClass('ui-state-focus').removeClass('ui-corner-all').removeClass('ui-state-hover').removeClass('ui-state-hover').removeClass('ui-state-default');
    $(sliderID + " a").addClass('ui-slider-handle-default').addClass('ui-slider-state-hover').addClass('ui-InitializeSlider-state-focus');

}

function InitializeRecSliderTouch(sliderID, className, initialValue) {
    var leftMargin = -10;
    $(".slides").css("position", "relative");
    $(".boxslider").css("position", "relative");
    $(sliderID).slider({
        value: initialValue,
        from: 0,
        to: 100,
        step: 1,
        limits: false,
        onstatechange: function(value) {
            if (value > 43) {
                leftMargin = -500;
                $(sliderID).slider("value", 43);
                $(".slides").css("left", leftMargin + "px");

                return false;
            }
            else {
                leftMargin = -12 * value;
                if (value == 0) {
                    leftMargin = 0;
                }
                $(".slides").css("left", leftMargin + "px");
            }
        }
    });

    if (initialValue > 0) {
        leftMargin = -12 * initialValue;
        $(".slides").css("left", leftMargin + "px");
    }
    //$(sliderID).addClass(className);
    //$(sliderID).removeClass('ui-widget-content').addClass(className);
    //$(sliderID + " a").removeClass('ui-state-focus').removeClass('ui-corner-all').removeClass('ui-state-hover').removeClass('ui-state-hover').removeClass('ui-state-default').removeClass('ui-slider-handle').removeClass('ui-slider-state-hover');
    //$(sliderID + " a").addClass('ui-rec-slider-handle');

}

function InitializeRecSlider(sliderID, className, initialValue) {
    var leftMargin = -10;
    $(".slides").css("position", "relative");
    $(".boxslider").css("position", "relative");
    $(sliderID).slider({
        value: initialValue,
        min: 0,
        max: 100,
        step: 1,
        slide: function(event, ui) {
            if (ui.value > 43) {
                leftMargin = -500;
                $(this).slider("value", 43);
                $(".slides").css("left", leftMargin + "px");

                return false;
            }
            else {
                leftMargin = -12 * ui.value;
                if (ui.value == 0) {
                    leftMargin = 0;
                }
                $(".slides").css("left", leftMargin + "px");
            }
        }
    });

    if (initialValue > 0) {
        leftMargin = -12 * initialValue;
        $(".slides").css("left", leftMargin + "px");
    }
    $(sliderID).removeClass('ui-widget-content').addClass(className);
    $(sliderID + " a").removeClass('ui-state-focus').removeClass('ui-corner-all').removeClass('ui-state-hover').removeClass('ui-state-hover').removeClass('ui-state-default').removeClass('ui-slider-handle').removeClass('ui-slider-state-hover');
    $(sliderID + " a").addClass('ui-rec-slider-handle');

}

function ShowFirstItem(displayCount) {
    if (typeof ClickTaleExec == 'function') ClickTaleExec('ShowFirstItem(' + displayCount + ')');
    if (parseInt(displayCount) > 5) {
        $("#recSlider").slider("value", 0);
        $(".slides").css("position", "relative");
        $(".slides").css("left", "0px");
    }
}

function ShowLastItem(displayCount) {
    if (typeof ClickTaleExec == 'function') ClickTaleExec('ShowLastItem(' + displayCount + ')');
    if (parseInt(displayCount) > 5) {
        $("#recSlider").slider("value", 43);
        $(".slides").css("position", "relative");
        $(".slides").css("left", "-528px");
    }
}

function ShowNext() {
    if (typeof ClickTaleExec == 'function') ClickTaleExec('ShowNext()');
    $("#slideDiv").css("left", "-110px");
    $("#leftSlider").css("display", "block");
    $("#rightSlider").css("display", "none");


}

function ShowPrevious() {
    if (typeof ClickTaleExec == 'function') ClickTaleExec('ShowPrevious()');
    $("#slideDiv").css("left", "0px");
    $("#leftSlider").css("display", "none");
    $("#rightSlider").css("display", "block");

}

function Previous_Next(serviceTypeCT, serviceType, authentification, ominutureId, previous_nextServiceType) {
    if (!$('#ConfirmationPV').is(":visible")) {
        if (typeof ClickTaleTag == 'function') ClickTaleTag("'Answered: " + serviceTypeCT + "'");
        //LogOmnitureGetRecClick(ominutureId);
        $('#RecFinderModal').hide();
        MyServicesSubmit(authentification, serviceType);
        SaveServiceNext(serviceType);
        GetRecommendationModal(previous_nextServiceType, true);
    }
}
function GetRecommendationB(serviceTypeCT, serviceType, authentification, ominutureId) {
    if (!$('#ConfirmationPV').is(":visible")) {
        if (typeof ClickTaleTag == 'function') ClickTaleTag("'Answered: " + serviceTypeCT + "'");
        //LogOmnitureGetRecClick(ominutureId);
        $('#RecFinderModal').hide();
        MyServicesSubmit(authentification, serviceType);
        $("#SubmitReady").val("true");
    }
    else {
        $("#SubmitReady").val("false");
    }
}
function checkIt() {
    return $("#SubmitReady").val() == "true";
}
/*Hes Calculator start*/

function CalculatorDisplayControl(value) {
    if (typeof ClickTaleExec == 'function') ClickTaleExec('CalculatorDisplayControl(' + value + ')');
    if (value < 2) {
        $("#dv2").css("display", "none");
        $("#dv3").css("display", "none");
    }
    if (value < 3) {
        $("#dv3").css("display", "none");
    }

    if (value >= 2) {
        $("#dv2").css("display", "block");
    }
    if (value > 2) {
        $("#dv3").css("display", "block");
    }
}

function setFuel(elem) {
    if (typeof ClickTaleExec == 'function') ClickTaleExec('setFuel("' + elem + '")');
    $("#hdnFuel").val(elem);
}

function setChangeHeatFuel(elem) {
    if (typeof ClickTaleExec == 'function') ClickTaleExec('setChangeHeatFuel("' + elem + '")');
    $("#hdnFuel").val(elem);
    showERorGR(elem);
}

function showERorGR(elem) {
    if (typeof ClickTaleExec == 'function') ClickTaleExec('setERorGR("' + elem + '")');
    if (elem == '4') {
        $("#dvElectric").css("display", "block");
        $("#dvGas").css("display", "none");
    } else {
        $("#dvElectric").css("display", "none");
        $("#dvGas").css("display", "block");
    }
}

function setTD(elem) {
    if (typeof ClickTaleExec == 'function') ClickTaleExec('setTD("' + elem + '")');
    $("#hdnTD").val(elem);
}

function setElemValue(elem, value) {
    $(elem).val(value);
    ShowAcOrHp(value);
}

function ShowAcOrHp(value) {
    if (typeof ClickTaleExec == 'function') ClickTaleExec('setAcOrHp("' + value + '")');
    if (value == '5') {
        $("#dvNU").css("display", "block");
        $("#dvSeer").css("display", "block");
        $("#dvAge").css("display", "block");
        $("#dvSize").css("display", "block");

        $("#dvSeer1").css("display", "none");
    } else {
        $("#dvNU").css("display", "none");
        $("#dvSeer").css("display", "none");
        $("#dvAge").css("display", "none");
        $("#dvSize").css("display", "none");

        $("#dvSeer1").css("display", "block");
    }

}

function InitializeCalcSlider(sliderID, min, max, step, className, targetID, initialValue, sa) {

    $(targetID).val(initialValue); //initialize starting value
    $(sliderID).slider({
        value: initialValue,
        from: min,
        to: max,
        step: step,
        limits: false,
        onstatechange: function(value) {
            $(targetID).val(value);
            if (sa == 1) CalculatorDisplayControl($(targetID).val());
        }
    });
    //$(sliderID).removeClass('ui-widget-content').addClass(className);
    //$(sliderID + " a").removeClass('ui-state-focus').removeClass('ui-corner-all').removeClass('ui-state-hover').removeClass('ui-state-hover').removeClass('ui-state-default');
    //$(sliderID + " a").addClass('ui-slider-handle-default').addClass('ui-slider-state-hover').addClass('ui-slider-state-focus');

    if (sa == 1) CalculatorDisplayControl(initialValue);

    $(targetID).keypress(function(e) {
        if (e.which != 8 && e.which != 0 && e.which != 46 && (e.which < 48 || e.which > 57)) {
            return false;
        }
    });

    $(targetID).blur(function() {
        if ($(targetID).val() > max) {
            $(targetID).val(max);
        }
        if ($(targetID).val() < min) {
            $(targetID).val(min);
        }
        if (parseInt($(sliderID).val()) > max) {
            $(sliderID).slider("option", "max", $(targetID).val());
            $(sliderID).slider("option", "value", $(targetID).val());

        }
        else {
            $(sliderID).slider("value", parseInt($(targetID).val()));
        }

        if (sa == 1) CalculatorDisplayControl($(targetID).val());
    });

}
function InitializeCalcSliderOld(sliderID, min, max, step, className, targetID, initialValue, sa) {

    $(sliderID).slider({
        value: initialValue,
        min: min,
        max: max,
        step: step,
        slide: function(event, ui) {
            $(targetID).val(ui.value);
            if (sa == 1) CalculatorDisplayControl($(targetID).val());
        }
    });
    $(sliderID).removeClass('ui-widget-content').addClass(className);
    $(sliderID + " a").removeClass('ui-state-focus').removeClass('ui-corner-all').removeClass('ui-state-hover').removeClass('ui-state-hover').removeClass('ui-state-default');
    $(sliderID + " a").addClass('ui-slider-handle-default').addClass('ui-slider-state-hover').addClass('ui-slider-state-focus');

    if (sa == 1) CalculatorDisplayControl(initialValue);

    $(targetID).keypress(function(e) {
        if (e.which != 8 && e.which != 0 && e.which != 46 && (e.which < 48 || e.which > 57)) {
            return false;
        }
    });

    $(targetID).blur(function() {
        if ($(targetID).val() > max) {
            $(targetID).val(max);
        }
        if ($(targetID).val() < min) {
            $(targetID).val(min);
        }
        if (parseInt($(sliderID).val()) > max) {
            $(sliderID).slider("option", "max", $(targetID).val());
            $(sliderID).slider("option", "value", $(targetID).val());

        }
        else {
            $(sliderID).slider("option", "value", parseInt($(targetID).val()));
        }

        if (sa == 1) CalculatorDisplayControl($(targetID).val());
    });

}

/*Hes Calculator end*/

function DetachSliderDiv() {
    if (typeof ClickTaleExec == 'function') ClickTaleExec('DetachSliderDiv()');
    $("#divTempSlider").detach();
}


function InitializeBillSliderTouch(sliderID, className, maxSliderValue, targetID, initialValue, isBundle) {


    if ($(targetID).val() != initialValue) {
        initialValue = parseInt($(targetID).val());
    }
    var maxValue = parseInt($(maxSliderValue).val());
    var toVal = (maxValue > initialValue) ? maxValue : initialValue;
    //$('#monthlyBillID').val = $("#monthlySliderTouch").val();
    //set up slider
    $(sliderID).slider({
        value: initialValue,
        from: -1,
        to: toVal,
        scale: ['|', '|', '|', '|', '|'], //could be numbers if we wanted
        limits: false,
        step: 1,
        dimension: '$', //note - I altered the plugin slightly to put the $ before the numbers
        smooth: false,

        onstatechange: function(value) {
            if (Number(value) >= 0) {
                $(targetID).val(value); //set the text input to equal the slider value
            }
            else {
                $(targetID).val(""); //set the text input to equal the slider value
            }
        }
    });

    $(targetID).keyup(function(e) {
        if (e.which == 13) {
            $(targetID).blur();
            return false;
        }
    });

    $(targetID).keypress(function(e) {
        if (e.which != 8 && e.which != 0 && e.which != 46 && (e.which < 48 || e.which > 57)) {
            return false;
        }
    });

    $(targetID).blur(function() {
        var mthlyBill = $(targetID).val();
        if (isNaN(mthlyBill) || isNaN(parseFloat(mthlyBill))) {
            mthlyBill = 0;
            $(targetID).val("0.00");
        }
        if (parseInt(mthlyBill) > parseInt($("#maxPrice").val())) {
            $(sliderID).slider("to", mthlyBill);
            $(sliderID).slider("value", mthlyBill);
        }
        else {
            $(sliderID).slider("value", parseFloat(mthlyBill));
        }
    });

    if (parseInt($("#monthlyBillID").val()) == 0) {
        billValueCleared = true;
    }
    if ($("#monthlyBillID").val() > 0 && isBundle) {
        $(".monthly-bill-slider").css("background-image", "url(" + contentBaseUrl + "/images/slider_monthly-bill-disabled.gif)");
        $(".ui-slider-handle-default").css("background-image", "url(" + contentBaseUrl + "/images/slider-disabled.gif)");
        $(".bill-details").css("display", "none");
        $(".bundle-bill-message").css("display", "block");
        $('#monthlyBillID').attr("disabled", "disabled")
        $("#disableSlider").addClass("disable-overlay");
    }
    else {
        $("#disableSlider").removeClass("disable-overlay");
    }

}

//NOTE: this will be deprecated in favor of the Touch version
function InitializeBillSlider(sliderID, className, maxSliderValue, targetID, initialValue, isBundle) {

    if ($("#monthlyBillID").val() != initialValue) {
        initialValue = $("#monthlyBillID").val();
    }

    var maxValue = $(maxSliderValue).val();

    //    if (initialValue < 10) {
    //        initialValue = 10;
    //    }
    $(sliderID).slider({
        value: initialValue,
        min: 0,
        max: maxValue,
        step: 1,
        slide: function(event, ui) {
            //            if (ui.value > maxValue - 10) {
            //                return false;
            //            }
            $(targetID).val(ui.value);
            $("#divTempSlider").detach();
            $("#br1").detach();
            $("#br2").detach();
            $("#monthlySlider A").append('<br id="br1"/><br id="br2"/><div class="slider_bill_lbl"  id="divTempSlider">' + '$' + ui.value + '</div>');
        }

    });
    $(sliderID).removeClass('ui-widget-content').addClass(className);
    $(sliderID + " a").removeClass('ui-state-focus').removeClass('ui-corner-all').removeClass('ui-state-hover').removeClass('ui-state-hover').removeClass('ui-state-default');
    $(sliderID + " a").addClass('ui-slider-handle-default').addClass('ui-slider-state-hover').addClass('ui-slider-state-focus');

    $("#monthlyBillID").keypress(function(e) {
        if (e.which != 8 && e.which != 0 && e.which != 46 && (e.which < 48 || e.which > 57)) {
            return false;
        }
    });

    $("#monthlyBillID").blur(function() {
        var mthlyBill = $("#monthlyBillID").val();
        if (isNaN(mthlyBill) || isNaN(parseFloat(mthlyBill))) {
            mthlyBill = 0;
            $("#monthlyBillID").val("0.00");
        }
        if (parseInt(mthlyBill) > parseInt($("#maxPrice").val())) {
            //            $("#monthlySlider").slider("option", "max", mthlyBill + 10);
            //            $("#monthlySlider").slider("option", "value", mthlyBill + 10);
            $("#monthlySlider").slider("option", "max", mthlyBill);
            $("#monthlySlider").slider("option", "value", mthlyBill);
        }
        else {
            //$("#monthlySlider").slider("option", "value", parseFloat(mthlyBill) + 10);
            $("#monthlySlider").slider("option", "value", parseFloat(mthlyBill));

        }
    });

    if (parseInt($("#monthlyBillID").val()) == 0) {
        billValueCleared = true;
    }
    if ($("#monthlyBillID").val() > 0 && isBundle) {
        $(".monthly-bill-slider").css("background-image", "url(" + contentBaseUrl + "/images/slider_monthly-bill-disabled.gif)");
        $(".ui-slider-handle-default").css("background-image", "url(" + contentBaseUrl + "/images/slider-disabled.gif)");
        $(".bill-details").css("display", "none");
        $(".bundle-bill-message").css("display", "block");
        $('#monthlyBillID').attr("disabled", "disabled")
        $("#disableSlider").addClass("disable-overlay");

    }
    else {
        $("#disableSlider").removeClass("disable-overlay");
    }



}
function ValidateService(elementName, errorElement) {
    if (typeof ClickTaleExec == 'function') ClickTaleExec('ValidateService("' + elementName + '", "' + errorElement + '")');
    var isChecked = $('input[name=' + elementName + ']:checked').length > 0;
    if (isChecked) {
        $("#" + errorElement).css("display", "none");
        return true;
    }
    else {
        $("#" + errorElement).css("display", "block");
        return false;
    }

}
function InitializeSlider(sliderID, className, min, max, step, defaultValue, targetID, omniture) {
    $(sliderID).slider({
        value: defaultValue,
        from: min,
        to: max,
        step: step,
        onstatechange: function(value) {
            $(targetID).text(value);
        },
        change: function(event, ui) {
            if ($('#currenttab .tabitem > a')) {
                $('#currenttab .tabitem > a').addClass("tabSelected");
            }
            FilterResults(this);
        }
    });
    //$(sliderID).removeClass('ui-widget-content').addClass(className);
    //$(sliderID + " a").removeClass('ui-state-focus').removeClass('ui-corner-all').removeClass('ui-state-hover').removeClass('ui-state-hover').removeClass('ui-state-default');
    //$(sliderID + " a").addClass('ui-slider-handle-default').addClass('ui-slider-state-hover').addClass('ui-slider-state-focus');
    if (omniture) {
        $(sliderID).attr("omniture", omniture);
    }
}

function InitializeUnlimitedSlider(sliderID, className, min, max, step, defaultValue, targetID, omniture) {
    $(sliderID).slider({
        value: defaultValue,
        from: min,
        to: max,
        step: step,
        onstatechange: function(value) {
            if (value == max) {
                $(targetID).text('Unlimited');
            }
            else {
                $(targetID).text(ui.value);
            }
        },
        change: function(event, ui) {
            if ($('#currenttab .tabitem > a')) {
                $('#currenttab .tabitem > a').addClass("tabSelected");
            }
            FilterResults(this);
        }
    });
    //$(sliderID).removeClass('ui-widget-content').addClass(className);
    //$(sliderID + " a").removeClass('ui-state-focus').removeClass('ui-corner-all').removeClass('ui-state-hover').removeClass('ui-state-hover').removeClass('ui-state-default');
    //$(sliderID + " a").addClass('ui-slider-handle-default').addClass('ui-slider-state-hover').addClass('ui-slider-state-focus');
    if (omniture) {
        $(sliderID).attr("omniture", omniture);
    }
}

function ToggleChannel(elem) {
    element = $('li[channelId=' + elem + ']');
    if (element.attr("class").indexOf("selected") == -1) {
        element.addClass('selected');

    }
    else {

        element.removeClass('selected');
        //$("#" + channelDivId).html($(element[0].parentNode).html());

    }
    //$("#" + channelDivId).html($(element[0].parentNode).html());
    //    if ($("#" + channelDivId + " li.selected").length > 0) {

    //        $("#" + channelAnchorId).attr("innerHTML", $("#" + channelDivId + " li.selected").length + " channels selected");
    //    }
    //    else {
    //        $("#" + channelAnchorId).attr("innerHTML", "(choose channels)");
    //    }
}

function CallRatingReview(ratingDivID) {
    $(ratingDivID).show();
}

function InitializeCalendar(calendarID) {
    if (typeof ClickTaleExec == 'function') ClickTaleExec('InitializeCalendar("' + calendarID + '")');
    $(calendarID).datepicker({
        showOn: 'button',
        buttonImage: contentBaseUrl + '/images/date-picker.gif',
        buttonImageOnly: true
    });

}

function ApplyRoundedButtonStyle() {
    if (typeof ClickTaleExec == 'function') ClickTaleExec('ApplyRoundedButtonStyle()');
    if (jQuery.browser.msie) {
        $('.button').each(function() {
            var me = $(this);
            if (me.is(':visible')) {
                var meclass = $(this).attr("class");
                me.css("border", "none").wrap('<div class="button-wrap ' + (meclass) + '" style="width:' + (me.innerWidth()) + 'px;">');
                $('.button-wrap').cornerz({ radius: 5 });
                $('.button-wrap .button').hover(function() {
                    $(this).parent().addClass("hover");
                }, function() {
                    $(this).parent().removeClass("hover");
                });
            }
        });
    }
}

function ShowFullPlanDescription() {
    if (typeof ClickTaleExec == 'function') ClickTaleExec('ShowFullPlanDescription()');
    $('#spnShortDescription').hide();
    $('#spnFullDescription').show();
}

function TabClick(TabClicked, TabNames) {
    $.each(
        TabNames,
        function(intIndex, objValue) {
            if (objValue == TabClicked) {
                $('#div' + objValue).show();
                $('#a' + objValue).removeClass('tab').addClass('tab active');
            }
            else {
                $('#div' + objValue).hide();
                $('#a' + objValue).removeClass('tab active').addClass('tab');
            }
        }
        );
}

function ClearFormErrors(formID) {
    if (typeof ClickTaleExec == 'function') ClickTaleExec('ClearFormErrors("' + formID + '")');
    clearForm(formID)
    $('#' + formID + ' input.input-validation-error')
                            .removeClass('input-validation-error')
                            .addClass('');


    $('#' + formID + ' .input-validation-error')
                            .removeClass('input-validation-error')
                            .addClass('input-validation-valid');

    $('#' + formID + ' .field-validation-error')
                            .removeClass('field-validation-error')
                            .addClass('field-validation-valid');

    $('#' + formID + ' .validation-summary-errors')
                            .removeClass('validation-summary-errors')
                            .addClass('validation-summary-valid');
    ResetSaveUserData();
}

function clearForm(formID) {
    if (typeof ClickTaleExec == 'function') ClickTaleExec('clearForm("' + formID + '")');
    // declare element type
    var type = null;
    var childs = $('#' + formID).get(0).elements;
    for (var y = 0; y < childs.length; y++) {
        var el = childs[y];
        // define element type
        type = el.type;
        // alert before erasing form element  
        //alert('form='+x+' element='+y+' type='+type);  
        // switch on element type  
        switch (type) {
            case "text":
            case "textarea":
            case "password":
                //case "hidden":  
                el.value = "";
                break;
            case "radio":
            case "checkbox":
                el.checked = "";
                break;
            case "select-one":
                el.options[0].selected = true;
                break;
            case "select-multiple":
                for (z = 0; z < el.options.length; z++) {
                    el.options[z].selected = false;
                }
                break;
        }
    }
}

function CheckRegisterCheckBoxes() {
    if (typeof ClickTaleExec == 'function') ClickTaleExec('CheckRegisterCheckBoxes()');
    $('#SendEmailAlerts').attr('checked', true);
    $('#SendNewsletter').attr('checked', true);
}

function ChangeBundle(elem, showDialog) {
    if ($("#bundleList").val() != "") {
        $("#IsBundle").val("true");
    }
    else {
        $("#IsBundle").val("false");
    }

    var currentlySelected = $("#ActiveBundle").val();
    var currentElementID;
    $("input[name=MyCurrentService.TypeOfBundle]").each(function() {
        if (currentlySelected == this.value) {
            currentElementID = this.id;
        }
    });

    if (!billValueCleared) {
        if (showDialog) {
            $("#dialog-confirm").dialog({
                resizable: false,
                height: 160,
                width: 400,
                modal: true,
                buttons: {
                    'Continue': function() {
                        $(this).dialog('close');
                        $("#ActiveBundle").val($(elem).value);
                        ResetBillUI();
                    },
                    Cancel: function() {
                        $(this).dialog('close');
                        $(elem).attr("checked", false);
                        $("#" + currentElementID).attr("checked", "checked");
                    }
                }
            });
        }
    }

}

function ChangeBundleAmount() {
    $("#dialog-confirm").dialog({
        resizable: false,
        height: 160,
        width: 400,
        modal: true,
        buttons: {
            'Continue': function() {
                $(this).dialog('close');
                ResetBillUI(false);
            },
            Cancel: function() {
                $(this).dialog('close');
            }
        }
    });
}

function ResetBillUI(clearValue) {
    if (clearValue == undefined) clearValue = true;
    if (typeof ClickTaleExec == 'function') ClickTaleExec('ResetBillUI(' + clearValue + ')');
    $(".monthly-bill-slider").css("background-image", "url(" + contentBaseUrl + "/images/slider_monthly-bill.gif)");
    $(".ui-slider-handle-default").css("background-image", "url(" + contentBaseUrl + "/images/slider.gif)");
    $(".bill-details").css("display", "block");
    $(".bundle-bill-message").css("display", "none");
    $('#monthlyBillID').attr("disabled", false);
    $("#fld").css("display", "none");
    $("#fldBundle").css("display", "");
    $("#fldSlider").css("display", "");
    $("#bundleViewID").css("display", "");
    $(".bundle-form").css("display", "block");
    $("#disableSlider").removeClass("disable-overlay");
    if (clearValue)
        ClearBillInformation();
}



function HideBar(id) {
    if (typeof ClickTaleExec == 'function') ClickTaleExec('HideBar("' + id + '")');
    $("div#" + id).hide('slow');
}

function ShowShoppingCart(id) {
    if (typeof ClickTaleExec == 'function') ClickTaleExec('ShowShoppingCart("' + id + '")');
    //$("div#" + id).slideDown('slow');
    $("div#" + id).toggle('slow');
    if ($("div#" + id).is(":visible")) {
        //LogOmnitureShowShoppingCart();
    }
}
function ShowCart() {
    if (typeof ClickTaleExec == 'function') ClickTaleExec('ShowCart()');
    $("#shoppingcart").css("display", "");
    if ($("#shoppingcart").is(":visible")) {
        //LogOmnitureShowShoppingCart();
    }
}

//String.prototype.trim = function() { return this.replace(/^\s*/, "").replace(/\s*$/, ""); }

function OpenProviderCopyStatement() {
    if (typeof ClickTaleExec == 'function') ClickTaleExec('OpenProviderCopyStatement()');
    var url = "http://www.allconnect.com/corporate/copyrights.html?ReferrerID=" + _referrerID + "&CID=" + _CID;
    window.open(url, 'Providercopystatements', 'toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,copyhistory=no,scrollbars=yes,width=725,height=490,Left=275,Top=150');
}
function InitializeHomePage(delay, rootUrl) {
    if (typeof ClickTaleExec == 'function') ClickTaleExec('InitializeHomePage(' + delay + ',"' + rootUrl + '")');
    tabDelay = delay;
    StartSlideShow(nextTab, rootUrl, tabDelay);
    $(document).ready(function() {
        $(".hoverpanel a").hover(
                  function() {
                      HandleTab($(this).parent(), rootUrl);
                  },
                  function() {

                  }
                );
        $(".home-slides").hover(
           function() {
               window.clearTimeout(sliderTimeout);
               slidesPaused = true;
           },
           function() {
               if (!hasFocus) {
                   StartSlideShow(nextTab, rootUrl, tabDelay);
                   slidesPaused = false;
               } else {
                   slidesPaused = false;
               }
           }
        );

        $(".home-slides input").focus(
          function() {
              hasFocus = true;
          }
        );

        $(".home-slides input").blur(
          function() {
              hasFocus = false;
              RestartSlideshow(rootUrl, tabDelay);
          }
        );

    });
}

function StartSlideShow(panelID, rootUrl, tabDelay) {
    sliderTimeout = window.setTimeout(function() {
        HandleTab($(panelID), rootUrl);
        RestartSlideshow(rootUrl, tabDelay);
    }, tabDelay);
}

function RestartSlideshow(rootUrl, tabDelay) {
    if (!slidesPaused) {
        StartSlideShow(nextTab, rootUrl, tabDelay);
    }
}

function HandleTab(tab, rootUrl) {
    $(".hoverpanel").removeClass("current");
    $(tab).addClass("current");
    if ($(tab).hasClass("pan01")) {
        nextTab = ".pan02";
        $('#mainHoverPanel').removeClass();
        $('#mainHoverPanel').addClass("panel01");
        $('#panelbackground').attr("src", rootUrl + "/images/heading-panel01.gif");
        $('.panel-message').text("Optimize your bills, get cost-saving recommendations, and setup instant alerts for savings... based on your home address!");
    }
    else if ($(tab).hasClass("pan02")) {
        nextTab = ".pan03";
        $('#mainHoverPanel').removeClass();
        $('#mainHoverPanel').addClass("panel02");
        $('#panelbackground').attr("src", rootUrl + "/images/heading-panel02.gif");
        $('.panel-message').text("Get tips to lower utility bills from your local electric & gas company, calculate savings on your water bill and trash removal services.");
    }
    else if ($(tab).hasClass("pan03")) {
        nextTab = ".pan04";
        $('#mainHoverPanel').removeClass();
        $('#mainHoverPanel').addClass("panel03");
        $('#panelbackground').attr("src", rootUrl + "/images/heading-panel03.gif");
        $('.panel-message').text("Find reviews, prices and bundle deals for your cable/satellite TV, high speed Internet, gas & electric plans and more!");
    }
    else if ($(tab).hasClass("pan04")) {
        nextTab = ".pan05";
        $('#mainHoverPanel').removeClass();
        $('#mainHoverPanel').addClass("panel04");
        $('#panelbackground').attr("src", rootUrl + "/images/heading-panel04.gif");
        $('.panel-message').text("Compare local costs for TV packages, high speed Internet, home phone, gas & electric company bills to see how much you can save!");
    }
    else if ($(tab).hasClass("pan05")) {
        nextTab = ".pan01";
        $('#mainHoverPanel').removeClass();
        $('#mainHoverPanel').addClass("panel05");
        $('#panelbackground').attr("src", rootUrl + "/images/heading-panel05.gif");
        $('.panel-message').text("Receive instant email updates when TV package deals, broadband Internet bundles, or other discounts become available.");
    }
}

function formatCurrency(num) {
    if (typeof ClickTaleExec == 'function') ClickTaleExec('formatCurrency("' + num + '")');
    num = num.toString().replace(/\$|\,/g, '');
    if (isNaN(num))
        num = "0";
    sign = (num == (num = Math.abs(num)));
    num = Math.floor(num * 100 + 0.50000000001);
    cents = num % 100;
    num = Math.floor(num / 100).toString();
    if (cents < 10)
        cents = "0" + cents;
    for (var i = 0; i < Math.floor((num.length - (1 + i)) / 3); i++)
        num = num.substring(0, num.length - (4 * i + 3)) + ',' +
num.substring(num.length - (4 * i + 3));
    return (((sign) ? '' : '-') + '$' + num + '.' + cents);
}

function setFilterNonNumericKeys(parentid, id) {
    if (typeof ClickTaleExec == 'function') ClickTaleExec('setFilterNonNumericKeys("' + parentid + '", "' + id + '")');
    var item;
    if (parentid == "") {
        item = $(id);
    }
    else {
        item = $(parentid).find(id);
    }
    item.keypress(function(e) {
        if (e.which != 8 && e.which != 0 && e.which != 46 && (e.which < 48 || e.which > 57)) {
            return false;
        }
    });
}
function setFilterNonIntegerKeys(parentid, id) {
    var item;
    if (parentid == "") {
        item = $(id);
    }
    else {
        item = $(parentid).find(id);
    }
    item.keypress(function(e) {
        if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {
            return false;
        }
    });
}
function setValidFloatRange(targetid, validationid, minRange, maxRange) {
    $(targetid).blur(function() {
        return ValidateFloatRange(targetid, validationid, minRange, maxRange);
    });
}
function ValidateFloatRange(targetid, validationid, minRange, maxRange) {
    var val = parseFloat($(targetid).val());
    if (val < minRange || val > maxRange) {
        isFormValid = false;
        $(validationid).html("Please enter a valid number between " + minRange + " and " + maxRange);
        $(targetid).focus().focus();    //IE7 workaround
        return false;
    }
    else {
        isFormValid = true;
        $(validationid).html("");
        return true;
    }
}

function ValidateDate(field, validationid) {
    var allowBlank = true;
    var minYear = 1902;
    var maxYear = (new Date()).getFullYear() + 100;

    var errorMsg = "";

    // regular expression to match required date format
    re = /^(?=\d)(?:(?:(?:(?:(?:0?[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0?[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})|(?:0?2(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))|(?:(?:0?[1-9])|(?:1[0-2]))(\/|-|\.)(?:0?[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2}))($|\ (?=\d)))?(((0?[1-9]|1[012])(:[0-5]\d){0,2}(\ [AP]M))|([01]\d|2[0-3])(:[0-5]\d){1,2})?$/;

    if (field.value != '') {
        if (regs = field.value.match(re)) {
            //valid date
        } else {
            errorMsg = "Invalid date format: " + field.value;
        }
    } else if (!allowBlank) {
        errorMsg = "Empty date not allowed!";
    }

    if (errorMsg != "") {
        $("#" + validationid).html(errorMsg);
        $("#" + validationid).removeClass("field-validation-valid");
        $("#" + validationid).addClass("field-validation-error");
        field.focus();  //IE7 workaround
        return false;
    }
    else {
        $("#" + validationid).html("");
        $("#" + validationid).removeClass("field-validation-error");
        $("#" + validationid).addClass("field-validation-valid");
        return true;
    }
}

function GetBundleTypeFromValue(bundleTypeValue) {
    if (typeof ClickTaleExec == 'function') ClickTaleExec('GetBundleTypeFromValue("' + bundleTypeValue + '")');
    var bundleType = "";
    if (bundleTypeValue == 9) {
        bundleType = 'TV-Internet-Phone';
    }
    else if (bundleTypeValue == 10) {
        bundleType = 'TV-Internet';
    }
    else if (bundleTypeValue == 11) {
        bundleType = 'TV-Phone';
    }
    else if (bundleTypeValue == 12) {
        bundleType = 'Internet-Phone';
    }
    else {
        bundleType = 'Unspecified';
    }

    return bundleType;
}

function LogOmnitureAddToShoppingCart(eId,phones,refID) {
    //console.log("LogOmnitureAddToShoppingCart");
    s.prop14 = eId;
   LogOmnitureLoadPage('Add To Cart', '', phones, refID);

}

function LogOmnitureCheckoutShoppingCart(eIds,phones,refID) {
    s.prop14 = eIds.join("|");
    //console.log("LogOmnitureCheckoutShoppingCart");
    s.pageName = 'Start Checkout';
    s.t();
}
function LogOmnitureAddressSubmit(logObj) {
    //console.log("LogOmnitureAddressSubmit");
     s.prop5 = logObj.prop5;
     s.prop6 = logObj.prop6;
     if (logObj.prop7 == "(optional)") {
         s.prop7 = " ";
     }
     else {
         s.prop7 = logObj.prop7;
     }
     s.prop8 = logObj.prop8;
     s.t();
     pausecomp(1000);
     s.prop5 = "";
     s.prop6 = "";
     s.prop7 = "";
     s.prop8 = "";
 }
 function LogOmniturePlanDetail(planID) {
     //console.log("LogOmniturePlanDetail");
     s.prop14 = planID;
     
 }

function LogOmnitureTabSelected(address, service, plans) {
    //console.log("LogOmnitureTabSelected");
    //LogOmnitureLoadPage props`
    //will be persisted for the session
    s.prop9 = address;
    s.prop12 = service;
    s.prop13 = plans;
    
        s.t();
        s.prop9 = "";
        s.prop12 = "";
        s.prop13 = "";



    }

    function LogOmnitureTabSelectedOnce(address, service, plans) {
        //console.log("LogOmnitureTabSelected");
        //LogOmnitureLoadPage props
        //will be persisted for the session
        s.prop9 = address;
        s.prop12 = service;
        s.prop13 = plans;

        s.t();
        s.prop9 = "";
        s.prop12 = "";
        s.prop13 = "";
        LogOmnitureTabSelectedOnceFlag = true;


    }

function LogOmnitureModalShow(description) {
    //console.log("LogOmnitureModalShow");
    s.prop10 = description;
    if (description != "Provider Shopping Cart") {
        s.t();
        s.prop10 = "";
    }
    //to do: need a flag to use this or loadpage
    //through load shopping cart
    
}
 function LogOmnitureLoadPage(page, pageType, phone, refid) {
     //console.log("LogOmnitureLoadPage");
    
     s.pageName = page;
     s.pageType = pageType;
     //these props are persistent 
     //accross all pages. no need to clear
     s.prop1 = ".NET";
     s.prop2 = "HSA";
     s.prop3 = phone+"|2";
     s.prop4 = refid;
     s.prop25 = "b2c";
     s.t();
    
     s.prop14 = "";
     s.prop9 = "";
     s.prop12 = "";
     s.prop13 = "";
     s.prop10 = "";
 }
 function LogOmnitureLoadPageOnce(page, pageType, phone, refid) {
     //console.log("LogOmnitureLoadPageAsync");     
     s.pageName = page;
     s.pageType = pageType;
     s.prop1 = ".NET";
     s.prop2 = "HSA";
     phone = $.trim($.trim(phone.replace(' ','').replace(")", "-")).replace("(", "1-"));
     s.prop3 = phone+"|2";
     s.prop4 = refid; 
     s.prop25 = "b2c";
     s.t();
     LogOmnitureLoadPageOnceFlag = true;
 }
 function pausecomp(millis) {
     var date = new Date();
     var curDate = null;
     do { curDate = new Date(); }
     while (curDate - date < millis);
 } 
function OptionFeatureTVCostCheck(selectedValue, optFeature) {
    //alert(selectedValue);
    var ddlid;
    var parsedResponse = (typeof optFeature) == 'string' ? eval('(' + optFeature + ')') : optFeature;
    for (var item in parsedResponse) {
        if (selectedValue == parsedResponse[item].ExternalID) {
            $("#Cost_" + parsedResponse[item].ExternalID).text("$0.00/mo");
            $("#SltdCost_" + parsedResponse[item].ExternalID).text("$0.00/mo");
            $("#Selected_" + parsedResponse[item].ExternalID).text(parsedResponse[item].Name);
            $("#NonCost_" + parsedResponse[item].ExternalID).text("0");
            ddlid = "select#ddl_" + parsedResponse[item].ExternalID;
            $(ddlid).attr("style", "width: 115px; font-size: 11px;");
            PlanDetailsFeaturePricebyMonth();
            return;
        }
    }

    for (var item in parsedResponse) {
        $("#Cost_" + parsedResponse[item].ExternalID).text(parsedResponse[item].RecurringPrice == undefined ? "$0.00/mo" : "$" + parseFloat((parsedResponse[item].RecurringPrice * (selectedValue - includeFeatureQuantities[parsedResponse[item].ExternalID]))).toFixed(2) + "/mo");
        $("#SltdCost_" + parsedResponse[item].ExternalID).text(parsedResponse[item].RecurringPrice == undefined ? "$0.00/mo" : "$" + parseFloat((parsedResponse[item].RecurringPrice * (selectedValue - includeFeatureQuantities[parsedResponse[item].ExternalID]))).toFixed(2) + "/mo");
        $("#Selected_" + parsedResponse[item].ExternalID).text(parsedResponse[item].Name + " " + selectedValue);
        $("#NonCost_" + parsedResponse[item].ExternalID).text(parsedResponse[item].NonRecurringPrice == undefined ? "0" : parseFloat((parsedResponse[item].NonRecurringPrice)));
        ddlid = "select#ddl_" + parsedResponse[item].ExternalID;
        $(ddlid).attr("style", "width: 115px; font-size: 11px;");
        PlanDetailsFeaturePricebyMonth();
        return;
    }
}


function OptFeatureTVCheck(checkBox, eid, value, desc) {
    $('input[value=' + $(checkBox).val() + ']').each(function(index) {
        $(this)[0].checked = checkBox.checked;
    });

    var totalRecurringPrice = parseFloat($('#totalRecuringprice').text());
    if (checkBox.checked) {
        $('#ddl_' + eid).attr("disabled", false);
        totalRecurringPrice += value;
        var temp = $("#summaryoptions");
        temp.show();

        var lastDisplayed = null;
        var founded = false;
        while (temp.next().attr("id").match("^Summary_") != null) {
            temp = temp.next();
            if (temp.attr("id").match("^Summary_" + eid + "$") != null) {
                founded = true;
                if (lastDisplayed == null || (lastDisplayed && lastDisplayed.attr("class") != "even"))
                    temp.attr("class", "even");
                else
                    temp.attr("class", "");

                temp.toggle();
                lastDisplayed = temp;
            } else if (!founded && temp.css("display") != "none") {
                lastDisplayed = temp;
            } else if (founded && temp.css("display") != "none") {
                lastDisplayed = temp;
                if (lastDisplayed && lastDisplayed.attr("class") == "even")
                    temp.attr("class", "");
                else
                    temp.attr("class", "even");
            }
        }
    }
    else {
        $('#ddl_' + eid).attr("disabled", true);
        $("select#ddl_" + eid).val(eid);
        $("#Cost_" + eid).text("$0.00/mo");
        $("#SltdCost_" + eid).text("$0.00/mo");
        $("#Selected_" + eid).text(desc);
        $('#ddl_' + eid).attr("style", "width: 115px; font-size: 11px;");
        totalRecurringPrice -= value;

        var temp = $("#summaryoptions");
        var lastDisplayed = null;
        var founded = false;
        while (temp.next().attr("id").match("^Summary_") != null) {
            temp = temp.next();
            if (temp.attr("id").match("^Summary_" + eid + "$") != null) {
                founded = true;
                temp.toggle();
            } else if (!founded && temp.css("display") != "none") {
                lastDisplayed = temp;
            } else if (founded && temp.css("display") != "none") {
                lastDisplayed = temp;
                if (lastDisplayed && lastDisplayed.attr("class") == "even")
                    temp.attr("class", "");
                else
                    temp.attr("class", "even");
            }
        }

        temp = $("#summaryoptions");
        founded = false;
        while (temp.next().attr("id").match("^Summary_") != null && !founded) {
            temp = temp.next();
            if (temp.css("display") != "none") {
                founded = true;
            }
        }

        if (!founded)
            $("#summaryoptions").hide();
    }
    PlanDetailsFeaturePricebyMonth();
}

function OptionFeatureInternetCostCheck(selectedValue, optFeature) {
    //alert(selectedValue);
    var parsedResponse = (typeof optFeature) == 'string' ? eval('(' + optFeature + ')') : optFeature;
    for (var item in parsedResponse) {
        if (selectedValue == parsedResponse[item].FeatureID) {
            //alert(parsedResponse[item].ExternalID + '-' + parsedResponse[item].RecurringPrice + '-' + parsedResponse[item].NonRecurringPrice);
            $("#Cost_" + parsedResponse[item].ExternalID).text(parsedResponse[item].RecurringPrice == undefined ? "$0.00/mo" : "$" + parseFloat(parsedResponse[item].RecurringPrice).toFixed(2) + "/mo");
            $("#SltdCost_" + parsedResponse[item].ExternalID).text(parsedResponse[item].RecurringPrice == undefined ? "$0.00/mo" : "$" + parseFloat(parsedResponse[item].RecurringPrice).toFixed(2) + "/mo");
            $("#Selected_" + parsedResponse[item].ExternalID).text(parsedResponse[item].ExternalDesc + " " + parsedResponse[item].Description);
            $("#NonCost_" + parsedResponse[item].ExternalID).text(parsedResponse[item].NonRecurringPrice == undefined ? "0" : parseFloat((parsedResponse[item].NonRecurringPrice)));
            ddlid = "select#ddl_" + parsedResponse[item].ExternalID;
            $(ddlid).attr("style", "width: 115px; font-size: 11px;");
            PlanDetailsFeaturePricebyMonth();
            return;
        }
    }

    for (var item in parsedResponse) {
        if (selectedValue == parsedResponse[item].ExternalID) {
            $("#Cost_" + parsedResponse[item].ExternalID).text("$0.00/mo");
            $("#SltdCost_" + parsedResponse[item].ExternalID).text("$0.00/mo");
            $("#Selected_" + parsedResponse[item].ExternalID).text(parsedResponse[item].ExternalDesc);
            $("#NonCost_" + parsedResponse[item].ExternalID).text("0");
            ddlid = "select#ddl_" + parsedResponse[item].ExternalID;
            $(ddlid).attr("style", "width: 115px; font-size: 11px;");
            PlanDetailsFeaturePricebyMonth();
            return;
        }
    }
}

function OptFeatureInternetCheck(checkBox, eid, value, desc) {
    $('input[value=' + $(checkBox).val() + ']').each(function(index) {
        $(this)[0].checked = checkBox.checked;
    });

    var totalRecurringPrice = parseFloat($('#totalRecuringprice').text());
    if (checkBox.checked) {
        $('#ddl_' + eid).attr("disabled", false);
        totalRecurringPrice += value;

        var temp = $("#summaryoptions");
        temp.show();

        var lastDisplayed = null;
        var founded = false;
        while (temp.next().attr("id").match("^Summary_") != null) {
            temp = temp.next();
            if (temp.attr("id").match("^Summary_" + eid + "$") != null) {
                founded = true;
                if (lastDisplayed == null || (lastDisplayed && lastDisplayed.attr("class") != "even"))
                    temp.attr("class", "even");
                else
                    temp.attr("class", "");

                temp.toggle();
                lastDisplayed = temp;
            } else if (!founded && temp.css("display") != "none") {
                lastDisplayed = temp;
            } else if (founded && temp.css("display") != "none") {
                lastDisplayed = temp;
                if (lastDisplayed && lastDisplayed.attr("class") == "even")
                    temp.attr("class", "");
                else
                    temp.attr("class", "even");
            }
        }
    }
    else {
        $('#ddl_' + eid).attr("disabled", true);
        $("select#ddl_" + eid).val(eid);
        $("#Cost_" + eid).text("$0.00/mo");
        $("#SltdCost_" + eid).text("$0.00/mo");
        $("#Selected_" + eid).text(desc);
        $('#ddl_' + eid).attr("style", "width: 115px; font-size: 11px;");
        totalRecurringPrice -= value;

        var temp = $("#summaryoptions");
        var lastDisplayed = null;
        var founded = false;
        while (temp.next().attr("id").match("^Summary_") != null) {
            temp = temp.next();
            if (temp.attr("id").match("^Summary_" + eid + "$") != null) {
                founded = true;
                temp.toggle();
            } else if (!founded && temp.css("display") != "none") {
                lastDisplayed = temp;
            } else if (founded && temp.css("display") != "none") {
                lastDisplayed = temp;
                if (lastDisplayed && lastDisplayed.attr("class") == "even")
                    temp.attr("class", "");
                else
                    temp.attr("class", "even");
            }
        }

        temp = $("#summaryoptions");
        founded = false;
        while (temp.next().attr("id").match("^Summary_") != null && !founded) {
            temp = temp.next();
            if (temp.css("display") != "none") {
                founded = true;
            }
        }

        if (!founded)
            $("#summaryoptions").hide();
    }
    PlanDetailsFeaturePricebyMonth();
}

function OptFeatureCheck(checkBox, value) {
    $('input[value=' + $(checkBox).val() + ']').each(function(index) {
        $(this)[0].checked = checkBox.checked;
    });
    var totalRecurringPrice = parseFloat($('#totalRecuringprice').text());

    if (checkBox.checked) {
        totalRecurringPrice += value;

        var temp = $("#summaryoptions");
        temp.show();

        var lastDisplayed = null;
        var founded = false;
        while (temp.next().attr("id").match("^Summary_") != null) {
            temp = temp.next();
            if (temp.attr("id").match("^Summary_" + eid + "$") != null) {
                founded = true;
                if (lastDisplayed == null || (lastDisplayed && lastDisplayed.attr("class") != "even"))
                    temp.attr("class", "even");
                else
                    temp.attr("class", "");

                temp.toggle();
                lastDisplayed = temp;
            } else if (!founded && temp.css("display") != "none") {
                lastDisplayed = temp;
            } else if (founded && temp.css("display") != "none") {
                lastDisplayed = temp;
                if (lastDisplayed && lastDisplayed.attr("class") == "even")
                    temp.attr("class", "");
                else
                    temp.attr("class", "even");
            }
        }
    }
    else {
        totalRecurringPrice -= value;

        var temp = $("#summaryoptions");
        var lastDisplayed = null;
        var founded = false;
        while (temp.next().attr("id").match("^Summary_") != null) {
            temp = temp.next();
            if (temp.attr("id").match("^Summary_" + eid + "$") != null) {
                founded = true;
                temp.toggle();
            } else if (!founded && temp.css("display") != "none") {
                lastDisplayed = temp;
            } else if (founded && temp.css("display") != "none") {
                lastDisplayed = temp;
                if (lastDisplayed && lastDisplayed.attr("class") == "even")
                    temp.attr("class", "");
                else
                    temp.attr("class", "even");
            }
        }

        temp = $("#summaryoptions");
        founded = false;
        while (temp.next().attr("id").match("^Summary_") != null && !founded) {
            temp = temp.next();
            if (temp.css("display") != "none") {
                founded = true;
            }
        }

        if (!founded)
            $("#summaryoptions").hide();
    }
    totalRecurringPrice = Math.round(totalRecurringPrice * 100) / 100
    $('#totalRecuringprice').text(totalRecurringPrice.toFixed(2));
    $('#totalRecuringpricewithfea').text(totalRecurringPrice.toFixed(2));
}


function PlanDetailsFeaturePricebyMonth() {
    var recPrice = 0;
    var selectedOptPrice = 0;
    var totalprice = 0;
    var totalnonrecprice = 0;
    var baseoneprice = 0;
    var eachbaseoneprice = 0;
    if ($("#baseprice1").text().length > 0) {
        recPrice = parseFloat($("#baseprice1").text().replace("/mo", "").replace("$", ""));
    }
    else if ($("#baseprice2").text().length > 0 && $("#speoffprice2").text().length > 0) {
        //recPrice = parseFloat($("#baseprice2").text().replace("/mo", "").replace("$", ""));
        recPrice = parseFloat($("#speoffprice2").text().replace("/mo", "").replace("$", ""));
    }

    if ($("#baseNonOnetime1").text().length > 0) {
        baseoneprice = parseFloat($("#baseNonOnetime1").text().replace("$", ""));
    }
    else if ($("#baseNonOnetime2").text().length > 0 && $("#prodisNonOnetime2").text().length > 0) {
        //baseoneprice = parseFloat($("#baseNonOnetime2").text().replace("$", ""));
        baseoneprice = parseFloat($("#prodisNonOnetime2").text().replace("$", ""));
    }

    //	if ($("#totbaseNonOnetime").text().length > 0) {
    //		baseoneprice = parseFloat($("#totbaseNonOnetime").text().replace("$", ""));
    //	}

    //alert(recPrice);
    $('input[name|=externalFeatureOptionsTVChk]:checked').each(function(index) {
        //alert($(this).val());
        var ctl = "#Cost_" + $(this).val();
        var nonctl = "#NonCost_" + $(this).val();
        //alert($(nonctl).text());
        selectedOptPrice = parseFloat(selectedOptPrice) + parseFloat($(ctl).text().replace("/mo", "").replace("$", ""));

        if (!isNaN(parseFloat($(nonctl).text()))) {
            eachbaseoneprice = parseFloat(eachbaseoneprice) + parseFloat($(nonctl).text());
        }
        //alert(parseFloat(selectedOptPrice).toFixed(2));
    });
    var internet = $("#ddl_CONN_SPEED").attr("selectedIndex");
    var modem = $("#ddl_MODEM_OPTION").attr("selectedIndex");
    var tvs = $("#ddl_DIG_RCVR").attr("selectedIndex");
    var hds = $("#ddl_HD_RCVR").attr("selectedIndex");
    var dvrs = $("#ddl_DVR").attr("selectedIndex");
    var hdDvrs = $("#ddl_HD_DVR").attr("selectedIndex");
    if (internet == undefined && modem == undefined && (tvs != undefined || hds != undefined || dvrs != undefined || hdDvrs != undefined)) {

        if (tvs == undefined) {
            tvs = 0;
        }
        if (hds == undefined) {
            hds = 0;
        }
        if (dvrs == undefined) {
            dvrs = 0;
        }
        if (hdDvrs == undefined) {
            hdDvrs = 0;
        }
        if (tvs > 0) {
            tvs = $("#ddl_DIG_RCVR option:selected").text();
        }
        if (hds > 0) {
            hds = $("#ddl_HD_RCVR option:selected").text();
        }
        if (dvrs > 0) {
            dvrs = $("#ddl_DVR option:selected").text();
        }
        if (hdDvrs > 0) {
            hdDvrs = $("#ddl_HD_DVR option:selected").text();
        }

        if (hds == 0 && dvrs == 0 && hdDvrs == 0) {

            $("#discountText3").css("display", "none");
        }
        else {
            //$("#discountText3").css("display", "");
        }
        var par = tvs + "^" + hds + "^" + dvrs + "^" + hdDvrs;
        $.ajax({
            url: "/PlanDetail/NonRecurringPriceFeatures^" + par,
            type: "GET",
            cache: false,
            success: function(result) {
                var pr = result.split("^");

                totalnonrecprice = pr[0];
                totalprice = pr[1];
                if (pr[2] == "") {
                    $("#discountText3").css("display", "none");
                }
                else {
                    $("#discountText3").css("display", "");
                }
                $("#lbl4").text(pr[2]);
                if (totalprice == undefined || totalprice == null || isNaN(totalprice)) {
                    totalprice = 0;
                }
                if (totalnonrecprice == undefined || totalnonrecprice == null || isNaN(totalnonrecprice)) {
                    totalnonrecprice = 0;
                }
                $('#totalRecuringprice').text("$" + parseFloat(totalprice).toFixed(2));
                $('#totalRecuringpricewithfea').text("$" + parseFloat(totalprice).toFixed(2));
                if (totalnonrecprice == "0") {
                    $("#totbaseNonOnetime").text("FREE");
                }
                else {
                    $("#totbaseNonOnetime").text("$" + parseFloat(totalnonrecprice).toFixed(2));
                }
            }
        });

    }
    else {

        totalprice = parseFloat(totalprice) + parseFloat(recPrice);
        totalprice = parseFloat(totalprice) + parseFloat(selectedOptPrice);
        if (isNaN(eachbaseoneprice)) {
            totalnonrecprice = parseFloat(baseoneprice);
        }
        else {
            totalnonrecprice = parseFloat(eachbaseoneprice) + parseFloat(baseoneprice);
        }
        if (totalprice == undefined || totalprice == null || isNaN(totalprice)) {
            totalprice = 0;
        }
        if (totalnonrecprice == undefined || totalnonrecprice == null || isNaN(totalnonrecprice)) {
            totalnonrecprice = 0;
        }
        //alert(parseFloat(totalprice).toFixed(2));
        $('#totalRecuringprice').text(parseFloat(totalprice).toFixed(2));
        $('#totalRecuringpricewithfea').text(parseFloat(totalprice).toFixed(2));
        $("#totbaseNonOnetime").text("$" + parseFloat(totalnonrecprice).toFixed(2));
        //$("#pricewithyourfeatures").text("$" + totalprice.toFixed(2) + "/mo");
    }

}
function RadioChanged(value) {
    if (value == 1) {
        ProviderChangedStep2();
    }
    else {
        $("#providerList").val($("#CurrentProvider").val());
    }
    $("#ConfirmationPV").hide();
    $("#PrefencesBox").show();
}
function ToggleFilters(tabTitle) {
    if (typeof ClickTaleExec == 'function') ClickTaleExec('ToggleFilters("' + tabTitle + '")');
    switch (tabTitle) {
        case "TV":
            $('#tvfilterdiv').show();
            $('#internetfilterdiv').hide();
            $('#phonefilterdiv').hide();
            break;
        case "Internet":
            $('#tvfilterdiv').hide();
            $('#internetfilterdiv').show();
            $('#phonefilterdiv').hide();
            break;
        case "Phone":
            $('#tvfilterdiv').hide();
            $('#internetfilterdiv').hide();
            $('#phonefilterdiv').show();
            break;
        case "Bundle":
        case "TV + Internet + Phone":
            $('#tvfilterdiv').show();
            $('#internetfilterdiv').show();
            $('#phonefilterdiv').show();
            break;
        case "TV + Phone":
            $('#tvfilterdiv').show();
            $('#internetfilterdiv').hide();
            $('#phonefilterdiv').show();
            break;
        case "TV + Internet":
            $('#tvfilterdiv').show();
            $('#internetfilterdiv').show();
            $('#phonefilterdiv').hide();
            break;
        case "Internet + Phone":
            $('#tvfilterdiv').hide();
            $('#internetfilterdiv').show();
            $('#phonefilterdiv').show();
            break;
    }
}

/* BEGIN KIOSK SECTION */
function UpdateKioskTimer() {
    if (typeof ClickTaleExec == 'function') ClickTaleExec('UpdateKioskTimer()');
    _kioskTimer -= 1000;
    $("#timeoutdisplay").html(_kioskTimer);
    if (_kioskTimer > 0) {
        _kioskTimerHandle = setTimeout("UpdateKioskTimer();", 1000);
    }
    else {
        DoKioskTimeoutWarning();
    }
}
var _defaultKioskWarning = 30000;  //30 secs
var _backupKioskTimer = _defaultKioskWarning
var _kioskTimerHandle2;

function DoKioskTimeoutWarning() {
    if (typeof ClickTaleExec == 'function') ClickTaleExec('DoKioskTimeoutWarning()');
    $.ajax({
        url: "/Timeout/Warning",
        type: "GET",
        cache: false,
        data: {},
        success: function(result) {
        $("#timeoutdisplay").html(result);
        LogOmnitureModalShow("Kiosk time warning");
            $("#timeoutdisplay").jqmShow();
            $("#timeoutContainer").show();
            _kioskTimerHandle2 = setTimeout("DoKioskTimeout();", 1000);
        }
    });
}

function DoKioskTimeout() {
    if (typeof ClickTaleExec == 'function') ClickTaleExec('DoKioskTimeout()');
    _backupKioskTimer -= 1000;
    $("#timeoutbackupdisplay").html(_backupKioskTimer / 1000);
    if (_backupKioskTimer > 0) {
        _kioskTimerHandle2 = setTimeout("DoKioskTimeout();", 1000);
    }
    else {
        window.location = "/Timeout";
    }
}

function ResetKioskTimeout() {
    if (typeof ClickTaleExec == 'function') ClickTaleExec('ResetKioskTimeout()');
    _kioskTimer = _kioskTimeout;
    $("#timeoutdisplay").html(_kioskTimer);
}

function KeepKioskSession() {
    if (typeof ClickTaleExec == 'function') ClickTaleExec('KeepKioskSession()');
    clearTimeout(_kioskTimerHandle2);
    $("#timeoutContainer").hide();
    $("#timeoutdisplay").jqmHide();
    _kioskTimer = _kioskTimeout;
    _backupKioskTimer = _defaultKioskWarning;
    UpdateKioskTimer();
}

function KioskWarningClose() {
    if (typeof ClickTaleExec == 'function') ClickTaleExec('KioskWarningClose()');
    $("#timeoutContainer").hide();
    $("#timeoutdisplay").empty();
    $("#timeoutdisplay").jqmHide();
}
/* END KIOSK SECTION */

