﻿//R23
// Common site JavaScript 1.2

// Main Dropdown Navigation
$(document).ready(function() {

    $("#searchform input.searchsubmit").hover(
      function() {
          $('#searchform input.searchsubmit').addClass('hover');
      },
      function() {
          $('#searchform input.searchsubmit').removeClass('hover');

      }
	);

    // Tool tip accordian

    if ($("a.accordion1").length > 0) {
        new Adoro.Accordion($("a.accordion1"), { animate: true });
    };

    // Main Navigation Script
    $('.subMenu>div').hover(function() {
        $(this).find('h2').addClass('bolded');
    }, function() {
        $(this).find('h2').removeClass('bolded');
    });
    var ulNode2 = $("#menu ul")[0] || null;
    new Adoro.DropDownMenu(ulNode2, { subMenuType: "div", cssActiveClass: "hover", cssHideClass: "off" });



    // Set up the primary carousel 
    if ($("#bannercarousel").length > 0) {
        new Adoro.Carousel(document.getElementById("bannercarousel"), {
            scrollCount: 1,
            isCircular: true,
            indicators: false,
            stopButton: true,
            startButton: true,
            forwardButton: false,
            backButton: false,
            automaticDirectionBackwards: false,
            animateSpeed: 0,
            automaticDelay: 5000,
            automatic: true
        });
    };

    // Set up the navigation carousel 
    if ($("#navigationcarousel").length > 0) {
        new Adoro.Carousel(document.getElementById("navigationcarousel"), {
            scrollCount: 1,
            isCircular: true,
            indicators: false,
            stopButton: false,
            startButton: false,
            forwardButton: true,
            backButton: true,
            automaticDirectionBackwards: false
        });
    };

    //v2 IE6 PNG fix
    //$("a.button").pngFix();
    //$("div.action").pngFix();
    //$("a.claimbutton").pngFix();

    //v1 IE6 PNG fix
    //$(".rollover").parent().pngFix();

    //Live version
    $(".rollover").pngFix();


    // Policy Expander
    if ($(".policies ul").length > 0) {
    var yourEndsleighHeight = $(".yourendsleigh").height();
    var policyContainerHeight = $(".policieslistwrapper").height();
    var policyListHeight = $(".yourendsleigh ul").height();
    var listOffset = 120;
    //store original values
    var originalYourEndsleighHeight = yourEndsleighHeight;
    var originalPolicyContainerHeight = policyContainerHeight;
    var expandPolicy = true;
    var yourEndsleigh = $('.yourendsleigh');

    if ((policyListHeight > policyContainerHeight) && (yourEndsleigh.hasClass('loggedin'))) {
        // Create the button
        $(".yourendsleigh .policies").append('<button class="showmore">More</button>');

        // Bind show/hide behaviour to button 
        $(".yourendsleigh .policies .showmore").bind("click", function(e) {
            e.preventDefault();
            if (expandPolicy) {
                $(".yourendsleigh").animate({ height: policyListHeight + listOffset + 'px' }, 500);
                $(".policieslistwrapper").animate({ height: policyListHeight + 'px' }, 500);
                // set button text
                $(this).html("Less");
                expandPolicy = false;
            } else {
                $(".yourendsleigh").animate({ height: originalYourEndsleighHeight + 'px' }, 500);
                $(".policieslistwrapper").animate({ height: originalPolicyContainerHeight + 'px' }, 500);
                // set button text
                $(this).html("More");
                expandPolicy = true;
            }
        });

        $(".showmore").hover(
		   