// JQUERY FOR PAGE LAYOUT:

// function to close the thumbnail image display:
closeThumb = function(){  
$('#thumbst').slideUp('slow', function()
{
$('#thumbsb').slideUp('slow', function()
{
 $('#blank').css('display','none');
 return true; });
});
}; 

matchheight = function()
{
	var hw =$(window).height();
	var hc =$('#content').height();
        var hd = hc + 240;
        var nhc = hw-hd+hc;                    // calc new content height
        if (nhc < 425) { nhc = 425; }           // sets a minimum height
        if (hw>hd) { $("#content").height(nhc); }// sets the height if it is too short
}

toggleText = function()
{
		if ( $.browser.msie && $.browser.version=='6.0' )
		{
			return false;
		}
		var showtext;
        var hidetext;
        var showarrow = '&nbsp;&#8250;&#8250';
        var hidearrow = '&nbsp;&#8249;&#8249';
        
	    $('.expander').slideUp('fast', function() 
	    { 
                showtext = $(this).attr('title').replace('-',' ');
                hidetext = $(this).attr('id').replace('-',' ');
                if (!showtext) { showtext='Show more'; }
		if (!hidetext) { hidetext='Hide';      }
		$(this).before('<a href="#" title="'+ showtext +'" id="'+ hidetext +'">' + showtext + showarrow + '</a>')
		.prev().toggle(
			function() { $(this).html($(this).attr('id')+hidearrow).next().slideDown('slow');     },
			function() { $(this).html($(this).attr('title')+showarrow).next().slideUp('slow');     }).prev().css('margin-bottom','0');
	    });	
}

$(window).load(function()
{
// CONTENT TOGGLE SETUP:
toggleText();

// AJAX SETUP FOR CLICKED IMAGE LINKS  
      
      // add the ajax containers to the page:
      $('#content').append('<div id="thumbsb"></div><div id="thumbst"></div><div id="blank"></div>');

      $("#tri-br a").click(function()
      { //adds a function to all the links click event
        var href = $(this).attr('href');
        href = href.replace('mediadisplay','ajax');
        // now make the ajax call:
        $.get( href , function(xml) 
		{   
             $('#thumbst').slideUp('slow');  
             $('#blank').css('display','block'); 
             $('#thumbsb').slideUp('slow', function() { $(this).html(xml).slideDown('slow'); });
		});
       return false; 
      }); 

      $("#tri-tl a").click(function()
      { //adds a function to all the links click event
        var href = $(this).attr('href');
	href = href.replace('mediadisplay','ajax');
        // now make the ajax call:
        $.get( href , function(xml) 
		{
            $('#thumbsb').slideUp('slow');
            $('#blank').css('display','block');
            $('#thumbst').slideUp('slow', function() { $(this).html(xml).slideDown('slow');} );   
		});
       return false; 
      }); 

// SLIDING MENU SETUP:
	$("#M").superfish({
		hoverClass	: "over",
		pathClass	: "overideThisToUse",
		delay		: 400,
		animation	: {height:"show"},
		speed		: "slow"
	});

// ANIMATED HEADINGS SETUP:
var id = $('#banner').attr('title');
href = "/AjaxHeadings?ID=" + id;

$.get( href , function(xml) 
{
    if( xml.substring(1,6)=="Error"){}
    else
    {
    $('#banner').html(xml).innerfade({
		speed: 'slow',
		timeout: 2000,
		type: 'sequence',
		containerheight: '90',
		containerwidth: '500',
                opacity: '0.5'
		});
	}
});

});

