function ExecuteHandlers() {
    TextOptions();
    Externals();
}


function EventToggle() {

    $("ul.Events> li a[rel='Tab']")
  .bind("click", function() {
      $(this).parent().parent().find("li:visible").removeClass("Active");
      $(this).parent().addClass("Active");
      return false;
  }
  );

}


function TextOptions() {
    var currentFontSize = $("html").css("font-size");
    $("div.Textoptions a.pt14").addClass("Active");

    $("div.Textoptions a.pt14")
  .bind("click", function() {
      $(this).parent().find("a").removeClass("Active");
      $(this).addClass("Active");
      $(".Content").css("font-size", currentFontSize);
      return false;
  }
  );

    $("div.Textoptions a.pt18")
  .bind("click", function() {
      $(this).parent().find("a").removeClass("Active");
      $(this).addClass("Active");
      $(".Content").css("font-size", 18);
      return false;
  }
  );

    $("div.Textoptions a.pt24")
  .bind("click", function() {
      $(this).parent().find("a").removeClass("Active");
      $(this).addClass("Active");
      $(".Content").css("font-size", 20);
      return false;
  }
  );
}


function Externals() {
    $("a[rel='External']")
  .bind("click", function() { this.target = "_blank"; });

}


function ShowPreview() {
    $(".ThumbGallery li a")
  .bind("click", function() {
      $(".Preview img").hide();
      $(".Preview strong").hide();
      $(this).parent().parent().find("li a").removeClass("Active");
      $(this).addClass("Active");
      CImage = $(".Preview img").attr("src").split("/")[$(".Preview img").attr("src").split("/").length - 1];
      NImage = $(this).find("img").attr("src").split("/")[$(this).find("img").attr("src").split("/").length - 1];
      //$(".Preview img").attr("src",$(".Preview img").attr("src").replace(CImage,NImage)).load(function(){$(this).fadeIn("slow");$(".Preview strong").show();});
      $(".Preview img").attr("src", $(".Preview img").attr("src").replace(CImage, NImage)).fadeIn("slow");
      $(".Preview strong").html($(this).find("img").attr("alt")).fadeIn("slow");


      return false;

  });
}


function ClickList() {

    $(".ClickList>ul").eq(1).hide();

    $(".DonationSteps li a")
   .bind("click", function() {
       $(this).parent().parent().find("li").removeClass("Active");
       $(this).parent().addClass("Active");
       $(".ClickList>ul").hide();
       $(".ClickList>ul").eq($(this).attr("rel")).show();
       return false;
   });

}

function Expandlist() {

    $(".Expandlist li a")
  .bind("click", function() {
      $(this).parent().parent().find("li a").removeClass("Active");
      $(this).parent().parent().find("li p:visible").slideUp(500);
      $(this).parent().find("p").slideDown(1000);
      $(this).addClass("Active");
      return false;

  });

}

function GalleryTitles() {

    $(".gallery li a").each(function(index) {
        $(this).append("<strong>" + $(this).find("img").attr("title") + "</strong>");

    });

    $(".gallery li a img").removeAttr("style");

}


$(document).ready(function() {

    // Attach change function to all select elements with a class of 'other'
    // Allows 2 controls to be used as one when handling 'Other, please specify'

    $('select.other').change(function() {

        var $select = $(this), $input = $select.next();

        $select.val() == '-1'
                ? $input.attr('name', $select.attr('name'))
                        .fadeIn()
                : $input.removeAttr('name')
                        .fadeOut();
    }).triggerHandler('change');


    $.gaTracker(
	                'UA-1546685-12',
	                {
	                    external: '/external/',
	                    mailto: '/mailto/',
	                    download: '/downloads/',
	                    extensions: [
	                                'pdf', 'doc', 'xls', 'csv', 'jpg', 'gif', 'swf', 'xml'
	                        ]
	                }
	        );


});



