 $(document).ready(function(){
	hoverDiv();
	roundedCorners();
	javaScriptEnabled();
	swapImages();
  });

 $(document).ready(function() {

     var originalFontSize = $('body').css('fontSize');
     if (typeof originalFontSize == "undefined") { originalFontSize = 12; }

     // Reset Font Size
     $(".med").click(function() {
     var originalFontSizeNum = parseFloat(originalFontSize, 10);
     if (originalFontSizeNum > 100) { originalFontSizeNum = 12; }
     $('body').css('fontSize', originalFontSizeNum);
     });
     // Increase Font Size
     $(".lar").click(function() {
         var currentFontSize = $('body').css('fontSize');
         var currentFontSizeNum = parseFloat(currentFontSize, 10);        
         if (currentFontSizeNum > 100) { currentFontSizeNum = 12; }
          var newFontSize = currentFontSizeNum * 1.2;
         $('body').css('fontSize', newFontSize);
         return false;
     });
     // Decrease Font Size
     $(".sma").click(function() {
         var currentFontSize = $('body').css('fontSize');
         var currentFontSizeNum = parseFloat(currentFontSize, 10);
         if (currentFontSizeNum > 100) { currentFontSizeNum = 12; }
         var newFontSize = currentFontSizeNum * 0.8;
         $('body').css('fontSize', newFontSize);
         return false;
     });
 });
 
 
 //  swap latest news images
function swapImages() {

	$(".list-ln li ").hover(function() {
		$(".list-ln div").addClass('off')
		$("div", this).removeClass('off');
		
	}, function() {
		$(".list-ln div").addClass('off')
		$(".list-ln li:first div").removeClass('off');
	});
}

// maximise clickabe area of the homepage boxes and set the hover background
function hoverDiv() {

	$(".hover").bind("click", function(e){
		var linkIs = $("a", this)[0].href;
		window.location = linkIs;
	}); 
	$(".hover").css({cursor:"pointer"});

	$(".hover").hover(function() {
		$(this).addClass('box-hlg-hp');
		$(this).removeClass('box-std-hp');
		
		}, function() {
		$(this).removeClass('box-hlg-hp');
		$(this).addClass('box-std-hp');
	});
}

// add rounded corners
function roundedCorners() {
	$("#atoz a,#cfonts a,.btn,.bbtn").wrapInner("<span><span><span><span></span></span></span></span>");
	$(".subtabs a").wrapInner("<span><span></span></span>");
	//$("#header").wrapInner("<div><div><div><div></div></div></div></div>");
	$(".box-hlg").wrapInner("<div><div><div><div></div></div></div></div>");
	$("#listServices").wrapInner("<div><div><div><div></div></div></div></div>");
	$("#error").wrapInner("<div><div><div><div><div><div><div></div></div></div></div></div></div></div>");
}

//  display the homepage promo
function homepagePromo(){
	$("#listServices").prepend("<div class='hImg'><img src='i/temp-home.jpg' alt='' /></div>");
}

// add class to body if javascript is enabled
function javaScriptEnabled(){
	$("body").addClass("js");
}

function SearchOnKeyPress(e) {
    var KeyID = (window.event) ? event.keyCode : e.keyCode;
    if (KeyID == 13) {
        $("[id*=searchButton]").click();
    }
}