var imgPath = "/Portals/0/Skins/Govett/images/";

// Preload images function
jQuery.preloadImages = function()
{
  for(var i = 0; i<arguments.length; i++)
  {
    jQuery("<img>").attr("src", arguments[i]);
  }
}


// Preload nav hover image
jQuery.preloadImages(imgPath + "nav_on.gif");


jQuery(document).ready(function () {
    // Extra span for accessible navigation. Span is a holder for a background image
    jQuery("ul.nav a").prepend("<span></span>");

    // Highlight nav menu on hover, except for already highlighted.
    jQuery("ul.nav li:not(ul.nav li.on)").hover(
		function () {
		    jQuery(this).addClass("on");
		},
		 function () {
		     jQuery(this).removeClass("on");
		 }
		);

    //search button swap text with img
    jQuery("#searchbox a.search").html('').addClass('searchbutton');



    // Expand/collapse long content
    var longcontent = jQuery(".longcontent");
    // If height is longer a certain number of px then restrict the height and add an expand/collapse link
    // The size of restricted area is defined in skin.css, the value below is just a trigger for the restriction
    if (longcontent.height() > 420) { // This value should be greater then the .maxheight height in skin.css.
        longcontent.addClass("maxheight"); // Add class that restricts content height
        longcontent.after("<p><a href=\"#expand\" id=\"expandlink\">Read full story</a></p>"); // Add a link that expands the content

        var expandlink = jQuery("#expandlink");

        expandlink.click(
            function () {
                // On click add/remove the class to collapse/expand the content
                (longcontent.hasClass("maxheight")) ? longcontent.removeClass("maxheight") : longcontent.addClass("maxheight");
                // Change link icon
                (expandlink.hasClass("expanded")) ? expandlink.removeClass("expanded") : expandlink.addClass("expanded");
            }
        );
    }


    // Another implementation of expand/collapce area
    var expandArea = jQuery(".expandarea");
    expandArea.hide();
    expandArea.before('<p><a href="#" class="expandarealink">Read more</a></p>');
    var exandareaLink = jQuery(".expandarealink");
    exandareaLink.click(function (event) {
        event.preventDefault();
        var parentEl = jQuery(this).parent(); // Get the parent p tag
        var expAera = parentEl.next(".expandarea"); // Find expand area next to the link. Multiple areas can be on one page.
        if (expAera.is(":visible")) {
            expAera.fadeOut("fast");
            jQuery(this).removeClass("expanded");
        }
        else {
            expAera.fadeIn();
            jQuery(this).addClass("expanded");
        }
    }); ;

});	
	
	
	
function getPrintButton() {
    document.write('<a href="#print" title="Print page" onclick="window.print()"><img src="' + imgPath + 'icon_print.gif" width="22" height="21" alt="Print" border="0" /></a>');
}
