﻿$(document).ready(function () {
    //Start common code

    $("body").addClass("jsEnabled");

    //Toggle views used for FAQ and Terms
    $(".toggleContent").hide();

    function toggleContentShow(trigger) {
        $(trigger).removeClass("expandarrowdown").addClass("expandarrowup");
        $(trigger).closest("div").find(".toggleContent").slideDown();
        $(trigger).html("Hide");
    }

    function toggleContentHide(trigger) {
        $(trigger).removeClass("expandarrowup").addClass("expandarrowdown");
        $(trigger).closest("div").find(".toggleContent").slideUp();
        $(trigger).html("Show");
    }

    //Trigger the show and hide
    $(".toggleViews .toggle").toggle(
      function () {
          toggleContentShow(this);
      },
      function () {
          toggleContentHide(this)
      }
    );


    $(".toggleViews .toggle").toggle(
      function () {
          toggleContentShow(this);
      },
      function () {
          toggleContentHide(this)
      }
    );

    //Text sizer
    $("#textSizeSmall").click(function () {
        $("body").css("font-size", "70%");
    });

    $("#textSizeMedium").click(function () {
        $("body").css("font-size", "80%");
    });

    $("#textSizeLarge").click(function () {
        $("body").css("font-size", "90%");
    });

    //hover for navigation
    $("#contentavigation ul li").hover(
      function () {
          $(this).addClass("hover");
      },
      function () {
          $(this).removeClass("hover");
      }
    );


    //Change the links depending on region state of transition
    setTimeout(function () { showNowDigital() }, 2000);
    //check for movie mousedown - using mousedown as flash hijacks clicks
    $("#regionSelect").mousedown(function () {
        setTimeout(function () { showNowDigital() }, 2000);
    });

    function showNowDigital() {
        if ($("div").hasClass("transitioning")) {
            /*for Anglia, Central and Yorkshire show internal*/
            $("#externalLinks").hide();
            $("#internalLinks").show();
        } else {
            /*for all else show external*/
            $("#internalLinks").hide();
            $("#externalLinks").show();
        };
    }


    //End common code       
});

