/**** Add application wide javascripts below this point  ******/
$(document).ready(function(){
  //$(document).pngFix();
  
  
// $('a.lightbox').lightBox();  
  
  $('#homelink').click(function() {
    window.location="/";
  });
  
  //#rss_header
  $('#rss_header').click(function() {
    if ($.browser.msie && $.browser.version.substr(0,1)<7) {
      window.location="/rss";
    }
  });

   // open external links into new window.  
   function externalLinks(base_url) {
     return $('a[href^=http]:not("[href^=' + base_url + ']"):not(":has(\'img\')")');
   }
   
   $(document).ready(function() { externalLinks('this.hostname').addClass("external"); });

   $('.external').click(function(){
   this.target = "_blank";
   });   
  
	
 	$(".videocarousel").jCarouselLite({
       btnNext: ".videonext",
       btnPrev: ".videoprev",
       visible:4,
       speed: 500
   });
   // Video Gallery - hover change
   
   $('#video_thumbs li img').mouseover(function(){
     selected = $(this);
     selected_array = selected.attr("id").split("thumb_");
     //alert(selected_array[1]);
     $('.video-holder').css('display','none');
     $('#video_'+selected_array[1]).addClass('show_video');
     $('#video_'+selected_array[1]).css('display','block');
   });
                        
	$(".flickrcarousel").jCarouselLite({
      btnNext: ".flickrnext",
      btnPrev: ".flickrprev",
      visible:4,
      speed: 500
  });
  
  $(".kerrangvideocarousel").jCarouselLite({
        btnNext: ".kvideonext",
        btnPrev: ".kvideoprev",
        visible: 1,
        speed: 500,
        start: 0
  });
  	
	$(".guidejCarouselLite").jCarouselLite({
      btnNext: ".next",
      visible:1,
      speed: 1
  });
  
	$('#uniofbrum').mouseover(function(){
		this.src="/images/uniofbirminghamgrey.gif";
	});  
	$('#uniofbrum').mouseout(function(){
		this.src="/images/uniofbirmingham.gif";
	});
	
	$('#brumcityuni').mouseover(function(){
		this.src="/images/birminghamcityunigrey.gif";
	});  
	$('#brumcityuni').mouseout(function(){
		this.src="/images/birminghamcityuni.gif";
	});
	
	$('#astonuni').mouseover(function(){
		this.src="/images/astonunigrey.gif";
	});  
	$('#astonuni').mouseout(function(){
		this.src="/images/astonuni.gif";
	});
	
	$('a.new-window').click(function(){
		window.open(this.href);
		return false;
	});
	
	timeout = setTimeout('ajax_load()', 5000);	
});


function ajax_load(){
	$(".ajax-loader").each(function() {
				$(this).load($(this).attr('title'));
	});
}

//Show modal box for image
function show_image(name, caption, title, link){
	img_text = "<a href="+link+"><img src='"+name+"' alt='"+caption+"' /></a>";
	$("#latestyoutube").addClass("hidden");
	$("#raw_image").html(img_text);
	$('#gallery-container').jqm().jqmShow();
}

function close_image() {
  $("#latestyoutube").removeClass("hidden");
}