// fnSlideshow = function(){

	//options
//	slideShowFadeSpeed="slow";
//	slideShowPause=4000;

	// add overlay
//	fullUrlOfFeatureBg=$("#homepage #mainFeature").css('background-image');
//	urlOfFeatureBg=fullUrlOfFeatureBg.substring(4,fullUrlOfFeatureBg.length-1);
//	widthOffeatureHolder=$("#homepage #mainFeature").width();
//	$("#mainFeature #featureWrap1").append("<div style=\"width: " + widthOffeatureHolder + "; background-image: url(" + urlOfFeatureBg + ");\" class=\"sys_fadeOverlay\"></div>").find(".sys_fadeOverlay").hide();
//	$(window).resize(function(){
//		widthOffeatureHolder=$("#homepage #mainFeature").width();
//		$("#mainFeature #featureWrap1").find(".sys_fadeOverlay").css("width",widthOffeatureHolder);
//	});

	//prepend the overlay image
//	$("#Feature_List img").before('<img src="/SiteElements/Images/Template/Homepage/mainfeatureoverlay.png" alt="" class="sys_overlay" />');

	//ensure the slides are hidden
//	$("#Feature_List div.sys_subitem").hide();
			
	//show the first slide, add on state
//	$("#Feature_List div.sys_subitem:eq(0)").addClass("sys_on").show();
			
	//set time interval
//	runSlideshow = setInterval( "fnSlideSwitch()", 4000 );
	
//	$("#Feature_List").mouseover( function(){
//		clearInterval(runSlideshow);
//	}).mouseout( function(){
//		runSlideshow = setInterval( "fnSlideSwitch()", slideShowPause );
//	});

//};
//fnSlideSwitch = function(){
	// fade in the whitebox
//	$(".sys_fadeOverlay").fadeIn(1000, function(){
		// hide current and show next
//		$("#Feature_List div.sys_subitem.sys_on").removeClass("sys_on").hide().next("div.sys_subitem").addClass("sys_on").show();
		//check if that was the last item
//		if ($("#Feature_List div.sys_subitem.sys_on").length==0){
//			$("#Feature_List div.sys_subitem:eq(0)").addClass("sys_on").show();
//		};
	// fade out the whitebox
//	}).fadeOut(1000);
//};

$(document).ready(function(){
	
	$('#Feature_List div.sys_itemslist').innerfade({
						speed: 0,
						timeout: 7500,
						type: 'sequence',
						containerheight: '160px'
					});

	$('#RotatingNewsList_List div.sys_itemslist').innerfade({
						speed: 400,
						timeout: 6500,
						type: 'sequence',
						containerheight: '136px'
});
			
	// slider
	
	// disable the link 'why nottingham' - ulzag
	$("#homepage #mainFeature #slider h2 a.sys_whyNottmLink").attr ('href', '#');
	
	
	if($("#homepage #mainFeature #slider").hasClass("sys_disable") == false) {
	$("#homepage #mainFeature #slider .sys_content").hide().addClass("sys_on");
	$("#homepage #mainFeature #slider .sys_title").css({cursor:"pointer"}).click(function (i) {
		$(this).find("h2").toggleClass("sys_on");
		var ie6Fix = $("#homepage #mainFeature #slider .sys_btm ul.sys_buttons li a span span span span");
		if(ie6Fix.hasClass("sys_ie6Fix")) {
			ie6Fix.removeClass("sys_ie6Fix");
		}
		$("#homepage #mainFeature #slider .sys_content").slideToggle("slow", function(){
			ie6Fix.addClass("sys_ie6Fix");
		});
	});
	};

	// hide virtual tours go button
	// $("#homepage #spotlights .sys_spotlight fieldset.sys_virtualTours input").hide();

	// build virtual tours
	// insert overlay div, then hide it
	// $("#wrapper").after('<div id="overlay"></div>');
	// $("#overlay").hide();

	// insert generic modal box, then hide the box and loading message
	// $("#footerWrap").after('<div id="basicModalContent"><div id="shadowTop"><div id="modalHead"><h1>Campus Video and Virtual Campus Tours</h1><p class="sys_close"><a href="#"><strong>Close</strong></a></p></div><fieldset class="sys_virtualToursModal">' + $("fieldset.sys_virtualTours").html() + '</fieldset><div id="lightboxContainer"></div></div><div id="shadowBotton"><!-- //--></div></div><div class="sys_lightboxLoading">Loading content</div>');
	// $("#basicModalContent, .sys_lightboxLoading").hide();
	// change the ID of the new drop down, and its label
	// $("fieldset.sys_virtualToursModal label").attr("for","virtualToursModal");
	// $("fieldset.sys_virtualToursModal select").attr("id","virtualToursModal");

	//load content and show lightbox
	// $("#virtualTours").change( function(){
	//	if($(this).attr("value") != 0) {
	//		$("#overlay").height($("body").height()+12).fadeIn().find(".sys_lightboxLoading").show();
	
	//		var linkTarget = $(this).attr("value");
	//		var ajaxTarget = linkTarget + " .sys_share";
	
	//		$("#lightboxContainer").load(ajaxTarget, {}, function(){
	//			$(".sys_lightboxLoading").hide();
	//			$("#basicModalContent").fadeIn();
	//		});

	//			$(this).blur();

			//close lightbox
	//		$("#basicModalContent .sys_close a, #overlay").click(function(){
	//			$("#basicModalContent .sys_close a").blur();
	//			$("#basicModalContent").fadeOut("normal", function(){
	//				$("#overlay").fadeOut();
	//				$("#lightboxContainer").empty();
	//			});
	//		});
	//	};
//	});
		
//	$("#virtualToursModal").change( function(){
//		if($(this).attr("value") != 0) {
//			var linkTarget = $(this).attr("value");
//			var ajaxTarget = linkTarget + " .sys_share";
//			$("#lightboxContainer").empty().load(ajaxTarget);
//		};
//	});
// Use thick box for the virtual tours / videos popup. ulzag

	$("div.sys_spotlight input").hide();
	$("div.sys_spotlight select").change(function () {
	if($(this).attr("value") != "Please select a video") {
        var linkTitle = "University of Nottingham Videos";//$("div.sys_spotlight select option:selected").text();
	var linkTarget = $("div.sys_spotlight select option:selected").attr("value");
	var url = '' + linkTarget + '?KeepThis=true&TB_iframe=true&height=365&width=691';
	tb_show(linkTitle, url);
	};		 
        });  

	// run slideshow
	//fnSlideshow();

// hide other campus links when dropdown menu invoked - this is only needed for ie6-7
$("li.sys_m9 div.sys_rollover").mouseenter(function () {
      $("#otherCampuses ul li a").css({'position' : 'relative' , 'z-index' : '-1'});
    });
$("li.sys_m8 div.sys_rollover").mouseenter(function () {
      $("#otherCampuses ul li a.sys_chinacampus").css({'position' : 'relative' , 'z-index' : '-1'});
    });
$("li.sys_m9 div.sys_rollover").mouseleave(function () {
      $("#otherCampuses ul li a").css({'position' : 'relative' , 'z-index' : '1'});
    });
$("li.sys_m8 div.sys_rollover").mouseleave(function () {
      $("#otherCampuses ul li a.sys_chinacampus").css({'position' : 'relative' , 'z-index' : '1'});
    });
});

