﻿
/* Home page related*/
var arrowpop = "http://home.mcafee.com/SupportPages/FetchContent.aspx?pgName=";
var threatpop = "http://home.mcafee.com/SupportPages/ThreatMeterHelp.aspx";




$(function() {
    if ( ($(".portlet ul#single").length) || ($(".portlet ul#multiple").length)){
        QuickLinks();
        }
        var ulElm = $(".protletRow ul");
        
        if($(".protletRow li").length == 3) {
            ulElm.addClass("lnk3");        
        } else {
            ulElm.addClass("lnk2");
        }
        ulElm.css("display","block");
    
   /* $(".protletRow li.txt1 a").mouseover(function() {
    $(this).attr( "class", "hover" );
        DisplayContent("ShopWithConfidence", "#ShopWithCon", arrowpop);
        $(".buyWithConf").show();
    })*/
    /*$(".protletRow li.txt2 a").mouseover(function() {
    $(this).attr( "class", "hover" );
        DisplayContent("WhyMcAfee", "#whyMfe", arrowpop);
        $(".whyMfe").show();
        if(is_ie6){
            $("#slt").ajaxStop(function() {
                $(this).css({visibility:'hidden'});
            });
             if ($(".tt-bdy").length){
                $(".portlet #slt").css({visibility:'hidden'});
                }
        }
           
        $("#whyMfe").ajaxComplete(function(){
            var iFrame;
            var objList = document.getElementById('whyMfe');
            
            if (is_ie6 && objList != null) { 
            var innerChild = document.getElementById("tt-bttmarrow-title");
            
            iFrame = document.createElement('iframe');
            iFrame.id = 'ieIframehome';
            iFrame.src = 'https://secureimages.mcafee.com/brand/images/spacer.gif';

            objList.appendChild(iFrame);
            objList.insertBefore(iFrame, objList.firstChild);
            }
        });
        
    });*/ 

    /*$(".protletRow li.txt1 a , .protletRow li.txt2 a").mouseout(function() {
    $(this).removeAttr("class")
        $(".buyWithConf").hide();
        $(".whyMfe").hide();
        if(is_ie6){
            $(".portlet #slt").css({visibility:'visible'});
              $("#slt").ajaxStop(function() {
                $(this).css({visibility:'visible'});
            });
        }
    });*/
    
     $('.protletRow li a').click(function(){
        var elem = $('.bttm-arrw-tt');
        var elemId = $(this).attr('id');
        var elemDiv = $('div.bttm-arrw-tt.' + elemId);
        if(!elemDiv.is(':visible')){
            elem.hide();
            $("#errorMsgDiv").hide();
            $("#email").val('');
            elemDiv.show();
            return false;
        }
        if(elemDiv.is(':visible')){
            elemDiv.hide();
            
        }
    });
	$('.bttm-arrw-tt span.clsImg').click(function(){
            $("#errorMsgDiv").hide();
            $("#email").val('');
            $('.bttm-arrw-tt').hide();                           
      });


    //News letter email validation and submit
     $('#btnNewsLetterSignUp').click(function() {  
        $("#errorMsgDiv").hide();
        var hasError = false;
        var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;

        var emailaddressVal = $("#email").val();
        if(emailaddressVal == '' || !emailReg.test(emailaddressVal)) {
            $("#errorMsgDiv").show();
            return false;
        }
        else {
            window.location.href="/Root/NewsLetter.aspx?ea="+emailaddressVal.replace('@','%40')+"&sid=1";
            return false;
        }
    });

    $(".threatTxt").click(function() {
        $("#threatmeterHP").show();
        DisplayContent("", "#threatmeterHP", threatpop);
        if(is_ie6){
            $("#slt").ajaxStop(function() {
                $(this).css({visibility:'hidden'});
            });
             if ($(".theatBody").length){
                $(".portlet #slt").css({visibility:'hidden'}); 
                }
        }
    });
    /* Threat meter pop up*/
    $("#threatmeterHP").ajaxComplete(function() {
        $(".threat-meter-pop").css({ "top": "0", "display": "block" });
        if(is_ie6){ 
        $(".threat-meter-pop").ajaxComplete(function(){
            $(".portlet #slt").css({visibility:'hidden'});
            });
        }
        $(".graybtn input").attr('onclick', '#');
        $("a.tt-close").attr("href", "#");
        $("#threatmeterHP a.tt-close , .center .graybtn").click(function() {
            $("#threatmeterHP").hide();
             if(is_ie6){
             if ($(".theatBody").length){
                $(".portlet #slt").css({visibility:'visible'}); 
                }
        }
        })
    })
    if(is_ie6){ 
    $("#topnav .personalnav .last a").click(function(){$(".portlet #slt").css({visibility:'hidden'});});
    $(".loginHolder a.close").click(function(){$(".portlet #slt").css({visibility:'visible'});});
    }

var po = $(".protletRow ul");
var setPo = po.offset();
var poBase = $(".ftrcurve");
var setPoBase = poBase.offset();
$(".bttm-arrw-tt").css({bottom:setPoBase.top - setPo.top});
});


function DisplayContent(param, id ,link) {
    $(".ajxLodImg").ajaxStart(function() {
        $(this).show();
    });
    $(".ajxLodImg").ajaxStop(function() {
        $(this).hide();
    });
    $.ajax({
        type: 'GET',
        url: link + param,
        dataType: 'html',
        success: function(htmlStr, textStatus) {
            $(id).html(htmlStr);
        },
        error: function(xhr, textStatus, errorThrown) {
            //  alert('An error occurred! ' + (errorThrown ? errorThrown : xhr.status));
        }

    });


}

function QuickLinks() {
    var num = document.getElementById("numOfPkgs").value;
    if (num == "0" || num == "1")
            $('#single').css({display:'block'});
    else 
        $('#multiple').css({display:'block'});
}

function SecurityDropDown(dropdown) {
    $(".ajxLodImg").show();
    var myindex = dropdown.selectedIndex
    var SelValue = dropdown.options[myindex].value
    if(SelValue != "1")
        window.location.href = SelValue;
    return true;
}

