﻿$(document).ready(function() {

    // Brand Logo Assignment
    var brand = $.query.get('brand');
    var brandCookie = null;
    if (brand == '') {
        // Brand is not set through the querystring
        //   Check if brand is set in the cookie
        brandCookie = $.cookie("brandCookie");

        if (brandCookie == null) {
            // No brandCoookie
            // Set the brand and brandCookie to anthem
            brand = "anthem";
            $.cookie("brandCookie", "anthem", { expires: 365 });
        }
        else {
            // There is a brandCookie.
            // Set the brand to brandCookie.
            brand = brandCookie;
            // Update brandCookie for another year.
            $.cookie("brandCookie", brandCookie, { expires: 365 });
        }
    }
    else {
        // Brand is set through the querystring
        // Update the cookie
        $.cookie("brandCookie", brand, { expires: 365 });
    }

    // Show the correct logo.
    if ($.browser.msie && $.browser.version == 6) {

        $("#empire-logo").remove();
        $("#georgia-logo").remove();
        $("#california-logo").remove();
        $("#anthem-logo").remove();

        if (brand == "georgia") {
            $("#header-container").append("<img id=\"georgia-logo\" src=\"images/georgia-logo.png\" />");
        }
        else if (brand == "empire") {
            $("#header-container").append("<img id=\"empire-logo\" src=\"images/empire-logo.png\" />");
        }
        else if (brand == "california") {
            $("#header-container").append("<img id=\"california-logo\" src=\"images/california-logo.png\" />");
        }
        else {
            $("#header-container").append("<img id=\"anthem-logo\" src=\"images/anthem-logo.png\" />");
        }
    }
    else {
        $("#california-logo").remove();
        if (brand == "georgia") {
            $("img#georgia-logo").show();
        }
        else if (brand == "empire") {
            $("img#empire-logo").show();
        }
        else if (brand == "california") {
            $("#header-container").append("<img id=\"california-logo\" src=\"images/california-logo.png\" />");
        }
        else {
            $("img#anthem-logo").show();
        }
    }

    // Set the proper footer
    // Get the year for the copyright dates.
    var currentYear = new Date().getFullYear();
    if (brand == "georgia") {
        $("#footer-copy").html("© " + currentYear + " BlueCross BlueShield of Georgia<br/><br/>Blue Cross Blue Shield of Georgia and Blue Cross Blue Shield Healthcare Plan of Georgia are <br/>Independent licensees of the Blue Cross Blue Shield Association.");
    }
    else if (brand == "empire") {
        $("#footer-copy").html("© " + currentYear + " Empire BlueCross BlueShield<br/><br/>Services provided by Empire HealthChoice HMO, Inc. and/or Empire HealthChoice Assurance, Inc., licensees of the Blue Cross and Blue Shield Association, an association of independent Blue Cross and Blue Shield Plans, serving residents and businesses in the 28 eastern and southeastern counties of New York State. All external sites will open in a new browser window. Please view our Website Privacy Policy for more information.");
    }
    else if (brand == "california") {
        $("#footer-copy").html("® Anthem is a registered trademark. ® The Blue Cross name and symbol are registered marks of the Blue Cross Association © " + currentYear + " Anthem Blue Cross. <br/><br/>Anthem Blue Cross is the trade name of Blue Cross of California.  Anthem Blue Cross and Anthem Blue Cross Life and Health Insurance Company are independent licensees of the Blue Cross Association.");
    }
    else {
        $("#footer-copy").html("© 2005-" + currentYear + " copyright of Anthem Insurance Companies, Inc.<br/><br/>Anthem Blue Cross and Blue Shield is the trade name of: In Colorado: Rocky Mountain Hospital and Medical Service, Inc. In Connecticut: Anthem Health Plans, Inc. In Indiana: Anthem Insurance Companies, Inc.  In Kentucky: Anthem Health Plans of Kentucky, Inc. In Maine: Anthem Health Plans of Maine, Inc. In Missouri: RightCHOICE® Managed Care, Inc. (RIT), Healthy Alliance® Life Insurance Company (HALIC), and HMO Missouri, Inc. RIT and certain affiliates administer non-HMO benefits underwritten by HALIC and HMO benefits underwritten by HMO Missouri, Inc. RIT and certain affiliates only provide administrative services for self-funded plans and do not underwrite benefits.  In Nevada: Rocky Mountain Hospital and Medical Service, Inc.  In New Hampshire:  Anthem Health Plans of New Hampshire, Inc. In Ohio: Community Insurance Company. In Virginia:  Anthem Health Plans of Virginia, Inc. In Wisconsin: Blue Cross Blue Shield of Wisconsin (\"BCBSWi\") underwrites or administers the PPO and indemnity policies; Compcare Health Services Insurance Corporation (\"Compcare\") underwrites or administers the HMO policies; and Compcare and BCBSWi collectively underwrite or administer the POS policies.  Independent licensees of the Blue Cross Blue Shield Association. ® ANTHEM is a registered trademark. The Blue Cross and Blue Shield names and symbols are registered marks of the Blue Cross and Blue Shield Association.  Serving residents and businesses in Indiana, Kentucky, Missouri (excluding 30 counties in the Kansas City area), Ohio, Wisconsin, Colorado, Nevada, Connecticut, Maine, New Hampshire and Virginia (excluding the city of Fairfax, the town of Vienna and the area east of State Route 123). Use of the Anthem Web sites constitutes your agreement with our <a href=\"javascript:openNewWindow('/wps/portal/ahpfooter?content_path=shared/noapplication/f6/s0/t0/pw_ad070873.htm&amp;label=Terms of Use');\">Terms of Use</a>");
    }

    // Get the correct Representative.
    var representative = $("#representative");

    var repCode = $.cookie("repCookie");

    if (repCode != null) {
        initializeRep(repCode);
    }
    else {
        // Set the Representative Information
        $("#meet-your-rep").html("<a href=\"javascript:openRepLocator()\">Locate your Representative</a>");
        //$("span.representative").each(function() { $(this).html("<a href=\"meet-your-rep.htm\">" + rep.name + "</a>") });
    }

    //    $("#emailBCCEmail").val("ralphjohnreed@yahoo.com");
    //    $("#emailBCCName").val("John Reed BCC");
    $("#emailBCCEmail").val("fepfieldservice@wellpoint.com");
    $("#emailBCCName").val("FEP Field Service");

    $("#emailFromEmail").val("no-reply@anthem.com");
    $("#emailFromName").val("Anthem FEP");

    // We need to change to use the pass / fail naming convention for confirmation redirects.
    var hostName = window.location.hostname;
    var originalPath = window.location.pathname;
    var successPath = originalPath.replace(".htm", "-success.htm");
    var failPath = originalPath.replace(".htm", "-fail.htm");

    $("#emailFailureUrl").val("http://" + hostName + failPath);
    $("#emailSuccessUrl").val("http://" + hostName + successPath);

    // Hide the live chat navigation for now.
    $("#live-chat-nav").hide();

    // Set the default form values cookies.
    var firstNameFValue = $.cookie("firstNameFValue");
    if (firstNameFValue != null) { $("#firstName").val(firstNameFValue); }
    var lastNameFValue = $.cookie("lastNameFValue");
    if (lastNameFValue != null) { $("#lastName").val(lastNameFValue); }
    var emailAddressFValue = $.cookie("emailAddressFValue");
    if (emailAddressFValue != null) { $("#emailAddress").val(emailAddressFValue); }
    var phoneNumberFValue = $.cookie("phoneNumberFValue");
    if (phoneNumberFValue != null) { $("#phoneNumber").val(phoneNumberFValue); }
    var addressFValue = $.cookie("addressFValue");
    if (addressFValue != null) { $("#address").val(addressFValue); }
    var jobTitleFValue = $.cookie("jobTitleFValue");
    if (jobTitleFValue != null) { $("#jobTitle").val(jobTitleFValue); }
    var agencyFValue = $.cookie("agencyFValue");
    if (agencyFValue != null) { $("#agency").val(agencyFValue); }
    var memberStatusFValue = $.cookie("memberStatusFValue");

    if (memberStatusFValue != null) {

        var selectedMemberStatusRadioButton = $("input:radio[value=" + memberStatusFValue + "]")[0];
        if (selectedMemberStatusRadioButton != undefined) {
            selectedMemberStatusRadioButton.checked = true;
        }

        if (memberStatusFValue == "Other") {
            var memberStatusOtherTextAreaFValue = $.cookie("memberStatusOtherTextAreaFValue");
            if (memberStatusOtherTextAreaFValue != null) {
                $("#memberStatusOtherTextArea").val(memberStatusOtherTextAreaFValue);
            }
        }
    }

    // Assign the changeFSAC button click event to the openRepLocator function.
    $("#changeFSAC").click(function() { openRepLocator() });
    // Same for if they click on the input box.
    $("#fieldServiceAccountConsultant").click(function() { openRepLocator() });

    $("#testimonial-1").html("<p>Definitely, Blue Cross Blue Shield adds security to my family.</p> <p> Again, knowing that this is a company that is stable, that is going to be here, that we are not going to get a letter in the mail saying that you need to make another major decision, another choice, for another provider right now.</p>  <p>For me Blue is stability, Blue is security, and Blue is my choice.<img src=\"images/end-quote.png\" alt=\"End Quote\" /></p>");
    $("#newsletter-2").html("<p>Each issue is packed with the latest informative news to improve your life and keep you healthy.</p><p>In addition, check out our Web site to discover free health and wellness seminars provided by your Field Service Account Consultant.</p><p>All from the people who touch your community, every day.</p><a class=\"link-button\" href=\"subscription-signup.htm\" style=\"margin-top: 4px; margin-bottom: 10px;\">SIGN UP</a>");

    // Hide the social media footer
    $("#social-media").hide();
});

function setRep(repCode) {

    var rep = getRep(repCode);

    // Store the Rep in a cookie.
    $.cookie("repCookie", repCode, { expires: 365 });

    var representative = $("#representative");

    // Set the Representative Information
    representative.children("a").hide();
    initializeRep(repCode);
    representative.children("a").fadeIn(1200);

    $("#video-card-container").show();

    var slcontrol = $("#videoSLObject")[0];
    if (slcontrol != null) {
        slcontrol.content.MainPage.UpdateVideo(rep);
    };

    setRequestMaterialsOption();
    
}

function updateNonSLFSACCard(repCode) {
    var currentRep = getRep(repCode);
    var currentRepCode = currentRep.code;

    // Sue Tiernan does not have a video.  Check for her and remove link.
    // Neither does Steve
    if ((currentRep.code == "sue") || (currentRep.code == "steve") || (currentRep.code == "erica")) {
        $("#video-player-video-link").hide();
    }
    else {
        $("#video-player-video-link").attr("href", "ClientBin/" + currentRepCode + ".wmv");
    }
    var videoPlayerImage = $("#video-player-image");
    videoPlayerImage.attr("src", "images/" + currentRepCode + ".jpg");
    // Disable right click.
    videoPlayerImage.noContext();
    $("#video-player-rep-name").html(currentRep.name);
    $("#video-player-state").html("Field Service Account Consultant<br />" + currentRep.state);
    $("#video-player-phone").html("Phone: " + currentRep.phone);
    $("#video-player-fax").html("Fax: " + currentRep.fax);
    var videoPlayerEmail = $("#video-player-email");
    videoPlayerEmail.html(currentRep.email);
    videoPlayerEmail.attr("href", "mailto:" + currentRep.email);
    $("#video-player-contact").attr("href", "vCards/" + currentRepCode + ".vcf");
}

function setRequestMaterialsOption() {
    var currentRep = getCurrentRep();

    // Clear Missouri and California Options
    $("#HCP-BR").remove();
    $("#HCP").remove();
    $("label[for=HCP]").remove();
    $("#HMP-BR").remove();
    $("#HMP").remove();
    $("label[for=HMP]").remove();

    // Create HMO California Material Request for non-California
    if (currentRep.state == "California") {
        $("label[for=HEN]").after("<br id=\"HCP-BR\" /><input type=\"checkbox\" id=\"HCP\" class=\"checkbox\" name=\"services\" value=\"HMO California Information Package\" /> <label class=\"checkbox-label\" for=\"HCP\">HMO California Information Package</label>");
    }
    // Create HMO Missouri Material Request for non-California
    else if (currentRep.state == "Missouri") {
        $("label[for=HEN]").after("<br id=\"HMP-BR\" /><input type=\"checkbox\" id=\"HMP\" class=\"checkbox\" name=\"services\" value=\"HMO Missouri Information Package\" /> <label class=\"checkbox-label\" for=\"HMP\">HMO Missouri Information Package</label>");
    }
}

function initializeRep(repCode) {

    var rep = getRep(repCode);
    
    var representative = $("#representative");

    // Set the Representative Information
    $("#meet-your-rep").html("Your Field Service Account Consultant:<span id=\"representative\"><a href=\"meet-your-rep.htm\"><img src=\"images/rep-icon.gif\" />" + rep.name + "</a></span>");
    //representative.children("a").html("<img src=\"images/rep-icon.gif\" />" + rep.name);
    $("span.representative").each(function() { $(this).html("<a href=\"meet-your-rep.htm\">" + rep.name + "</a>") });

    // Set the Field Service Account Consultant Input Field
    $("#fieldServiceAccountConsultant").val(rep.name);

    // Set the email form values.
    $("#emailToEmail").val(rep.email);
    $("#emailToName").val(rep.name);
    //$("#emailToEmail").val("ralphjohnreed@yahoo.com");
    //$("#emailToName").val("Ralph John Reed To");

    $(".FSACName").each(function() { $(this).html(rep.name) });
    $("#rep-defined").show();
    $("#rep-not-defined").hide();
}

function getRep(repCode) {
    var reps = Object;
    reps.sue = { code: 'sue', name: 'Sue Tiernan', email: 'sue.tiernan@wellpoint.com', phone: '925-706-0171', fax: '925-706-8881', state: 'California' };
    reps.richard = { code: 'richard', name: 'Richard Gracey', email: 'richard.gracey@wellpoint.com', phone: '916-858-3565', fax: '916-636-2335', state: 'California' };
    reps.marjorie = { code: 'marjorie', name: 'Margie Sone-Doehner', email: 'margie.sone-doehner@wellpoint.com', phone: '760-473-8094', fax: '760-473-8917', state: 'California' };
    reps.robert = { code: 'robert', name: 'Robert Moss', email: 'robert.moss@wellpoint.com', phone: '818.234.2946', fax: '818.234.2568', state: 'California' };
    reps.jane = { code: 'jane', name: 'Jane Fluekiger', email: 'jane.fluekiger@wellpoint.com', phone: '303-831-2512', fax: '720-981-9348', state: 'Colorado' };
    reps.deborah = { code: 'deborah', name: 'Deborah Herget', email: 'deborah.herget@anthem.com', phone: '203-985-6125', fax: '203-985-6318', state: 'Connecticut' };
    reps.charles = { code: 'charles', name: 'Charles Smith', email: 'charles.smith@bcbsga.com', phone: '404-923-3172', fax: '404-923-3175', state: 'Georgia' };
    reps.sheila = { code: 'sheila', name: 'Sheila Wright', email: 'swright@bcbsga.com', phone: '404-923-3174', fax: '404-923-3175', state: 'Georgia' };
    reps.shan = { code: 'shan', name: 'Shan Unverzagt', email: 'shan.unverzagt@anthem.com', phone: '317-287-6778', fax: '317-287-6177', state: 'Indiana' };
    reps.susan = { code: 'susan', name: 'Susan Horn', email: 'susan.horn@anthem.com', phone: '502-889-2736', fax: '502-889-3257 ', state: 'Kentucky' };
    reps.erica = { code: 'erica', name: 'Erica Graff', email: 'erica.graff@bcbsmo.com', phone: '314-923-6111', fax: '314-923-5151', state: 'Missouri' };
    reps.steve = { code: 'steve', name: 'Steve Amico', email: 'stephen.amico@anthem.com', phone: '207-822-7104', fax: '207-822-8111', state: 'Maine and New Hampshire' };
    reps.cathy = { code: 'cathy', name: 'Kathy Reardon', email: 'kathy.reardon@anthem.com', phone: '775-448-4258', fax: '775-448-4281', state: 'Nevada' };
    reps.patricia = { code: 'patricia', name: 'Patricia Farrell', email: 'patricia.farrell@empireblue.com', phone: '212-476-3449', fax: '718-278-7083', state: 'New York' };
    reps.diane = { code: 'diane', name: 'Diane Hombach', email: 'diane.hombach@empireblue.com', phone: '518-367-5404', fax: '518-367-6124', state: 'New York' };
    reps.ruth = { code: 'ruth', name: 'Ruth White', email: 'ruth.white@empireblue.com', phone: '845-695-4458', fax: '845-695-3049', state: 'New York' };
    reps.marlon = { code: 'marlon', name: 'Marlon Byrd', email: 'marlon.byrd@anthem.com', phone: '513-872-5921', fax: '513-475-1598', state: 'Ohio' };
    reps.david = { code: 'david', name: 'David Norman', email: 'dave.norman@anthem.com', phone: '614-433-8949', fax: '614-433-8497', state: 'Ohio' };
    reps.linda = { code: 'linda', name: 'Linda Fletcher', email: 'linda.fletcher@anthem.com', phone: '757-326-5155', fax: '757-631-5161', state: 'Virginia' };
    reps.kathy = { code: 'kathy', name: 'Kathy Bass', email: 'kathy.bass@anthem.com', phone: '804-678-0320 ', fax: '804-678-0167', state: 'Virginia' };
    reps.keith = { code: 'keith', name: 'Keith Wray', email: 'keith.wray@anthem.com ', phone: '540-853-5125', fax: '540-853-4368', state: 'Virginia' };
    reps.vanessa = { code: 'vanessa', name: 'Vanessa Lacey', email: 'vanessa.lacey@anthem.com', phone: '703-227-5310 ', fax: '703-227-5355', state: 'Virigina' };
    reps.amy = { code: 'amy', name: 'Amy Scheevel', email: 'amy.scheevel@bcbswi.com', phone: '608-783-2366', fax: '608-783-2367', state: 'Wisconsin' };

    var rep = reps[repCode];

//    if (!rep) {
//        return reps.sue;
//    }
//    else {
        return rep;
//    }
}

function getCurrentRep() {
    return getRep($.cookie("repCookie"));
}

function onSLError(sender, args) {
    alert("onSLError:" + args.errorType + " " + args.errorMessage + " " + args.errorCode);
}

function onSLLoad(plugin, usercontext, sender) {
    //alert("onSLLoad");
}

function hideRepLocator() {
    $("#content-body").css({ opacity: 1.0, backgroundColor: "White" });
    $("#popup-container").hide();
}

function RepresentativeFound(repCode) {
    hideRepLocator();
    setRep(repCode);
}

function openRepLocator() {
        $("#content-body").css({ opacity: 0.4 });
        $("#popup-container").show(1000);
}

function openNewWindow(url) {
    window.open(url, "", "height=400,width=500,resizable=yes,scrollbars=yes,menubar=no,location=no,toolbar=no");
}

