//----------------------
// slide navigation
//----------------------

//pause before animation
$.fn.pause = function(duration) {
	$(this).stop().animate({ dummy: 1 }, duration);
	return this;
};

function mouseleft() {
	$("#navigation").triggerHandler("mouseleave");
}

function externalLinks() {  
 if (!document.getElementsByTagName) return;  
 var anchors = document.getElementsByTagName("a");  
 for (var i=0; i<anchors.length; i++) {  
   var anchor = anchors[i];  
   if (anchor.getAttribute("href") &&  anchor.getAttribute("rel") == "external")  
     anchor.target = "_blank";  
 }  
}  
window.onload = externalLinks;


var seq;

//slide open navigation on over (add focus someday)
$(document).ready(function(){

  $("#navigation").css({ height:"50px" });
  // activate the bookmarking link
  $("#favouriteLink").click(function() { addBookmark('King\'s College London','http://'+ location.href);  });
  
  seq =  setTimeout( function() {
      jQuery('#mainImages').animate({opacity: 1}, 1000);
      jQuery('#mainImages').innerfade({
        animationtype: 'fade',
        speed: 2000,
        timeout: 8000,
        type: 'sequence',
        containerheight: '370px'
      });
    }, 200 ); 
    

    
    
     $(function(){

          if($("#left_column ul ul ul .sys_select a") && $("#left_column ul ul ul .sys_select a").length > 0)

		  {

		     $("#left_column ul ul .sys_select a").css({backgroundImage: "none"});

		     $("#left_column ul ul ul .sys_select a").css({ backgroundImage: "url(/SiteElements/Images/accordion-menu-arrow-white.jpg)" });

		     $("#left_column ul ul ul .sys_select ul a").css({ backgroundImage: "none" });

		  }

	   if($("#left_column ul ul ul ul .sys_select a") && $("#left_column ul ul ul ul .sys_select a").length > 0)

		  {

		     

		     $("#left_column ul ul ul .sys_select a").css({ backgroundImage: "none" });

		     $("#left_column ul ul ul .sys_select ul .sys_currentitem a").css({ backgroundImage: "url(/SiteElements/Images/accordion-menu-arrow-white.jpg)" });

		     

		  }

	   

    });

 

   
   $(".sys_item").hover(function(){

		$('img', this).fadeTo("slow", 0.8); },function(){   $('img', this).fadeTo("slow", 1.0); });



    $(".sys_subitem").hover(function(){

		$('img', this).fadeTo("slow", 0.8); },function(){   $('img', this).fadeTo("slow", 1.0); });


    $(".sys_large_news_image").hover(function(){

		$('img', this).fadeTo("slow", 0.8); },function(){   $('img', this).fadeTo("slow", 1.0); });
   
   $(".sys_ms_feature").hover(function(){

		$('img', this).fadeTo("slow", 0.8); },function(){   $('img', this).fadeTo("slow", 1.0); });
   

// New puff slide code added 24 Mar 2011 IKM : Start 
  
   $(".sys_large_schools_image").hover(function(){
		$('img', this).fadeTo("slow", 0.8); },function(){   $('img', this).fadeTo("slow", 1.0); });

 $(".sys_departments_feature").hover(function(){
		$('img', this).fadeTo("slow", 0.8); },function(){   $('img', this).fadeTo("slow", 1.0); });

 $(".sys_large_department_image").hover(function(){
		$('img', this).fadeTo("slow", 0.8); },function(){   $('img', this).fadeTo("slow", 1.0); });

  
  // New puff slide code added 24 Mar 2011 IKM : End
   

	var selectedInput = null;

	$("#navigation").mouseenter(
		function () {
			$(this).stop().pause(80).animate({ height:"560px" }, {
    duration: 800, 
    specialEasing: {
      width: 'linear',
      height: 'easeInOutSine'
    }});
		}).mouseleave(
		function () {
			if (selectedInput == null) {
				$(this).stop().pause(80).animate({ height:"50px" }, {
    duration: 500, 
    specialEasing: {
      width: 'linear',
      height: 'easeInOutSine'
    }} );
			}
		}
	);
});



function addBookmark(title,url) {
	if (window.sidebar) { 
		window.sidebar.addPanel(title, url,""); 
	} else if( document.all ) {
		window.external.AddFavorite( url, title);
	} else if( window.opera && window.print ) {
		return true;
	}
}



