(function(g) {
   
    g("#expand-all").on("click", function(o) {
        o.preventDefault();
        g(".answers-article").removeClass("close")
    });
    g("#close-all").on("click", function(o) {
        o.preventDefault();
        g(".answers-article").removeClass("close");
        g(".answers-article").addClass("close")
    });
    
    
    if (isRPHidden()) {
        g(".leftpanel-btn").trigger("click")
    }
    g(".subnav-header").on("click", function() {
        g(this).parent().toggleClass("menu-close")
    });
    g(".friendsContainer .more, .friends-overlay-close, .friends-overlay, .social a.more-link").on("click", function(o) {
        o.preventDefault();
        g(".friends-overlay, .friends-overlay-content").toggleClass("hidden")
    })
})(jQuery);

function storeRPState(a) {
    if (Modernizr.localstorage) {
        localStorage.setItem("rpState", a)
    }
}

function isRPHidden() {
    var a = false;
    if (Modernizr.localstorage) {
        a = (localStorage.getItem("rpState") === "true")
    }
    return a
};
$(document).ready(function() {
    site.init()
});
var site = {
    init: function() {
        site.UI.init();
        site.modal.init()
    },
    UI: {
        init: function() {
            site.UI.equiHeight($(".box"));
            $("#selectCard, #selectSortBy").uniform();
            $(".back-to-top").click(function() {
                $.scrollTo("#top", 400);
                return false
            });
            $(".box-nav-wrap .tab-nav a").click(function() {
                var a = $(this).attr("href");
                $(".box-nav-wrap ul.tab").removeClass("active");
                $(".box-nav-wrap ul" + a).addClass("active");
                $(".box-nav-wrap .tab-nav a").removeClass("active");
                $(this).addClass("active");
                return false
            });
            $(".comment-nav a").click(function() {
                $(".comment-nav a").removeClass("active");
                $(this).addClass("active");
                return false
            })
        },
        equiHeight: function(c) {
            var b = 0,
                a = 0;
            c.each(function() {
                a = $(this).height();
                if (b < a) {
                    b = a
                }
            });
            c.height(b)
        }
    },
    modal: {
        init: function() {
            site.modal.position();
            $(window).resize(function() {
                site.modal.position()
            });
            $(".open-modal").click(function() {
                site.modal.open($(this).attr("href"));
                return false
            });
            $("#modalOverlay").click(function() {
                site.modal.close()
            });
            $(".close-modal").click(function() {
                site.modal.close();
                return false
            })
        },
        open: function(a) {
            $("#modalContentWrap").html($(a).html());
            $("#modalOverlay").fadeIn(400, function() {
                $("#modal").fadeIn(500)
            })
        },
        close: function() {
            $("#modal").fadeOut(400, function() {
                $("#modalContentWrap").html("");
                $("#modalOverlay").fadeOut(500)
            })
        },
        position: function() {
            var d = $(window).height(),
                b = $(window).width(),
                c = $(".modal"),
                e = parseInt(c.width(), 10),
                a = parseInt(c.height(), 10);
            c.css({
                top: ((d - a) / 2),
                left: ((b - e) / 2)
            })
        }
    }
};
$(document).ready(function() {
    $(".rightColumnContainer h1").removeAttr("id");
    $.reject({
        reject: {
            msie7: true
        },
        imagePath: "/assets/img/reject/",
        closeCookie: true,
        cookieSettings: {
            path: "/",
            expires: 0
        }
    });
    
    $(".accordian h2").on("click", function() {
        var i = $(this);
        i.parent().toggleClass("close")
    });
    if ($(".accordian").length > 0) {
        $(".accordian").each(function(i, j) {
            if (i > 0) {
                $(j).addClass("close")
            }
        })
    }
    if ($(".review-container").length > 0) {
        $("#reviewstar").raty({
            scoreName: "score",
            starOff: $("input[name='staroff']").val(),
            starOn: $("input[name='staron']").val()
        })
    }
    
    if ($(".rightColumnContainer .right #expand-all-overview").length > 0) {
        $(".right #expand-all-overview").each(function(j) {
            $(this).attr("class", "expand-all" + j);
            if ($(".rightColumnContainer .answers-content ").length > 0) {
                $(".answers-content").each(function(i) {
                    $(this).attr("id", "expand-all" + i);
                    i++
                })
            }
            j++
        });
        $(".rightColumnContainer .right #expand-all-overview").click(function() {
            var i = $(this).attr("class");
            $(".rightColumnContainer  #" + i + "").children().removeClass("close")
        })
    }
    if ($(".rightColumnContainer .right #close-all-overview").length > 0) {
        $(".right #close-all-overview").each(function(j) {
            $(this).attr("class", "close-all" + j);
            if ($(".rightColumnContainer .answers-content ").length > 0) {
                $(".answers-content").each(function(i) {
                    $(this).addClass("close-all" + i);
                    i++
                })
            }
            j++
        });
        $(".rightColumnContainer .right #close-all-overview").click(function() {
            var i = $(this).attr("class");
            $(".rightColumnContainer  ." + i + "").children().addClass("close")
        })
    }
    if ($(".siteMapAccordian .right #expand-all-overview").length > 0) {
        $(".right #expand-all-overview").each(function(j) {
            $(this).attr("class", "expand-all" + j);
            if ($(".siteMapAccordian .answers-content ").length > 0) {
                $(".answers-content").each(function(i) {
                    $(this).attr("id", "expand-all" + i);
                    i++
                })
            }
            j++
        });
        $(".siteMapAccordian .right #expand-all-overview").click(function() {
            var i = $(this).attr("class");
            $(".siteMapAccordian  #" + i + "").children().removeClass("close")
        })
    }
    if ($(".siteMapAccordian .right #close-all-overview").length > 0) {
        $(".right #close-all-overview").each(function(j) {
            $(this).attr("class", "close-all" + j);
            if ($(".siteMapAccordian .answers-content ").length > 0) {
                $(".answers-content").each(function(i) {
                    $(this).addClass("close-all" + i);
                    i++
                })
            }
            j++
        });
        $(".siteMapAccordian .right #close-all-overview").click(function() {
            var i = $(this).attr("class");
            $(".siteMapAccordian  ." + i + "").children().addClass("close")
        })
    }
    if ($(".bank-answers-page .right #expand-all-overview").length > 0) {
        $(".right #expand-all-overview").each(function(j) {
            $(this).attr("class", "expand-all" + j);
            if ($(".bank-answers-page .answers-content ").length > 0) {
                $(".answers-content").each(function(i) {
                    $(this).attr("id", "expand-all" + i);
                    i++
                })
            }
            j++
        });
        $(".bank-answers-page .right #expand-all-overview").click(function() {
            var i = $(this).attr("class");
            $(".bank-answers-page  #" + i + "").children().removeClass("close")
        })
    }
    if ($(".bank-answers-page .right #close-all-overview").length > 0) {
        $(".right #close-all-overview").each(function(j) {
            $(this).attr("class", "close-all" + j);
            if ($(".bank-answers-page .answers-content ").length > 0) {
                $(".answers-content").each(function(i) {
                    $(this).addClass("close-all" + i);
                    i++
                })
            }
            j++
        });
        $(".bank-answers-page .right #close-all-overview").click(function() {
            var i = $(this).attr("class");
            $(".bank-answers-page  ." + i + "").children().addClass("close")
        })
    }
    if ($("#panel-poll form li .poll").length > 0) {
        $("#panel-poll form li .poll").uniform()
    }
    
    if ($(".answers-article.accordian.clearfix").length > 0 && (!$("body").hasClass("bank-answers-page"))) {
        addAccordianHref()
    }
    var t = $("#totalCount").val();
    var aF = $("#accordianCount").val();
    var aC = t - aF;
    $(".moreBox").slice(0, aF).css("display", "block");
    if ($(".blogBox:hidden").length != 0) {
        $(".load-more-btn").css("display", "block;")
    }
    if (aC < 1) {
        $(".load-more-btn").css("display", "none");
        $(".all-faqs-btn").css("display", "inline-block")
    }
    $(".load-more-btn").on("click", function(i) {
        i.preventDefault();
        $(".moreBox:hidden").slice(0, aC).slideDown();
        $(".all-faqs-btn").css("display", "inline-block");
        if ($(".moreBox:hidden").length == 0) {
            $(".load-more-btn").fadeOut("slow")
        }
    });
    
    

    function aa(i) {
        var j = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
        return j.test(i)
    }
    if (typeof(FedID) != "undefined") {
        if (FedID != null && FedID != "" && $(".custBtn").length > 0 && $(".nonCustBtn").length > 0) {
            $(".custBtn").css("display", "inline-block");
            $(".nonCustBtn").attr("style", "display:none!important")
        }
    }
    if ($("a.passParam").length > 0) {
        var W = window.location.search.substring(1);
        var V = $("a.passParam").attr("href");
        $("a.passParam").attr({
            href: V + W
        })
    }
    var av, Z;
    av = 5000;
    Z = 20000;
    if ($("#myDivAdd").length) {
        if ($("body").hasClass("cross-sell-delay")) {
            setTimeout(toggle_visibility, av);
            $(document.body).on("touchmove", function() {
                $("#myDivAdd").delay(10000).fadeOut()
            });
            $(window).scroll(function() {
                $("#myDivAdd").delay(10000).fadeOut()
            });
            setTimeout(toggle_visibilityClose, Z)
        } else {
            setTimeout(toggle_visibility)
        }
    }
});


function wireUpEvents() {
    var f = 0;
    var i = "You sure you want to leave ?";
    var h = $(".poll-disclaimer .pollWindow").css("height");
    var g = $(".poll-disclaimer .pollWindow").css("width");
    var d = $(".poll-disclaimer .pollWindow").css("left");
    var c = $(".poll-disclaimer .pollWindow").css("top");
    var b = $(".poll-disclaimer").attr("href");

    function a(j) {
        if (!validNavigation) {
            if (f !== 1) {
                if ($("body").hasClass("pollFunction")) {
                    if (!j) {
                        j = window.event
                    }
                    j.cancelBubble = true;
                    j.returnValue = null;
                    if ($("body").hasClass("newTab")) {
                        window.open(b)
                    } else {
                        window.open(b, "popupWindow", "width=" + g + ",height=" + h + ", left=" + d + ", top=" + c + ", scrollbars=no")
                    }
                    if (j.stopPropagation) {
                        j.stopPropagation();
                        j.preventDefault()
                    }
                    return true
                }
            }
        }
    }
    window.onunload = a;
    document.onkeydown = function() {
        switch (event.keyCode || e.which) {
            case 116:
                validNavigation = true;
            case 114:
                validNavigation = true;
            case 82:
                if (event.ctrlKey) {
                    validNavigation = true
                }
                case 13:
                    validNavigation = true
        }
    };
    $("a").bind("click", function() {
        validNavigation = true
    });
    $("form").bind("submit", function() {
        validNavigation = true
    });
    $("input[type=submit]").bind("click", function() {
        validNavigation = true
    })
}












