$(document).ready(function(){
	$.each($(".bigImageJs").children("li"),function(){
			$(this).hide();
		});
		//alert($(".bigImageJs li:first-child").attr("id"));

	if($("#initialImage").children("p").html()==""){
		$("#initialImage").remove();
			$(".bigImageJs li:first-child").addClass("thisActive");	
	$("#newUKFRS").addClass("imageLinksActive");
	$(".bigImageJs li:first-child").show();
	$(".bigImageJs li:first-child").next("li").addClass("nextActive");

		
	}else if($("#initialImage").children("p").html()=="-"){
	$(".bigImageJs li:first-child").addClass("thisActive");	
	//$("#newUKFRS").addClass("imageLinksActive");
	$("#initialImage").children("p").hide();
	$(".bigImageJs li:first-child").show();
	$(".bigImageJs li:first-child").next("li").addClass("nextActive");
	}else{
		$(".bigImageJs li:first-child").addClass("thisActive");	
	$(".bigImageJs li:first-child").show();
	$(".bigImageJs li:first-child").next("li").addClass("nextActive");	
	}

	
		
		

var myTim=setInterval(autoSlide,8000);

$(".expandedLinksContainer").hide();


	function autoSlide(){
			
		$.each($(".bigImageLinks").children("li").children("a"),function(){
			$(this).removeClass("imageLinksActive");
		});
		//$.each($(".bigImageJs").children("li"),function(){
			var thisone = $(".thisActive").attr("id");
			var nextOne = $(".nextActive").attr("id");
			//	alert(thisone);		
			$("#"+thisone).fadeOut("slow");
			$("#"+nextOne).fadeIn("slow");
			
			
			switch(nextOne){
				case"ORS":
			
				$("#newORS").addClass("imageLinksActive");
				//$("#newORS").siblings("li").removeClass("imageLinksActive");
			
				break;
				case"bandi":
			
				$("#newBANDI").addClass("imageLinksActive");
				//	$("#newBANDI").siblings("li").removeClass("imageLinksActive");
			
				break;
				case"PSA":
			
				$("#newPSA").addClass("imageLinksActive");
				//	$("#newPSA").siblings("li").removeClass("imageLinksActive");
			
				break;
				case"FLBannerImage":
			
				$("#newFireLearn").addClass("imageLinksActive");
				//	$("#newFireLearn").siblings("li").removeClass("imageLinksActive");
				break;
				case"UKfandr":
				$("#newUKFRS").addClass("imageLinksActive");
				//	$("#newUKFRS").siblings("li").removeClass("imageLinksActive");
			
				break;
				
				
			}
			
			
			
			
			
			
			
			
			
			
			
			$("#"+thisone).removeClass("thisActive");
			$("#"+nextOne).removeClass("nextActive");
			$("#"+nextOne).addClass("thisActive");		
			
			if(nextOne==$(".bigImageJs li:last-child").attr("id")){
				$(".bigImageJs li:first-child").addClass("nextActive");
				//alert(nextOne);
				//$("")
			}else{
				$("#"+nextOne).next("li").addClass("nextActive");
					//alert(nextOne);
			}
			
			
		
		
		
		
	}



$.each($(".bigImageLinks").children("li").children("a"),function(){
			$(this).attr("href","javascript:;");
		});
	$(".bigImageLinks").children("li").children("a").click(function(){
		
		clearTim();
		
		switch($(this).attr("id")){
			
			case"newUKFRS":
			$.each($(".bigImageLinks").children("li").children("a"),function(){
			$(this).removeClass("imageLinksActive");
		});
			$(this).addClass("imageLinksActive");
			$("#UKfandr").fadeIn("slow",function(){$("#UKfandr").addClass("thisActive")});	
			$("#UKfandr").siblings("li").fadeOut("fast",function(){$("#UKfandr").siblings("li").removeClass("thisActive")});		
			break;	
			case"newORS":
			$.each($(".bigImageLinks").children("li").children("a"),function(){
			$(this).removeClass("imageLinksActive");
		});
		$(this).addClass("imageLinksActive");
		$("#ORS").fadeIn("slow",function(){$("#ORS").addClass("thisActive")});	
			$("#ORS").siblings("li").fadeOut("fast",function(){$("#ORS").siblings("li").removeClass("thisActive")});	
			break;
			case"newPSA":
			$.each($(".bigImageLinks").children("li").children("a"),function(){
			$(this).removeClass("imageLinksActive");
		});
		$(this).addClass("imageLinksActive");
	$("#PSA").fadeIn("slow",function(){$("#PSA").addClass("thisActive")});	
			$("#PSA").siblings("li").fadeOut("fast",function(){$("#PSA").siblings("li").removeClass("thisActive")});
			break;
			case"newBANDI":
			$.each($(".bigImageLinks").children("li").children("a"),function(){
			$(this).removeClass("imageLinksActive");
				});
		$(this).addClass("imageLinksActive");
		$("#bandi").fadeIn("slow",function(){$("#bandi").addClass("thisActive")});	
			$("#bandi").siblings("li").fadeOut("fast",function(){$("#bandi").siblings("li").removeClass("thisActive")});			
			break;
			case"newFireLearn":
			$.each($(".bigImageLinks").children("li").children("a"),function(){
			$(this).removeClass("imageLinksActive");
		});
		$(this).addClass("imageLinksActive");
		$("#FLBannerImage").fadeIn("slow",function(){$("#FLBannerImage").addClass("thisActive")});	
			$("#FLBannerImage").siblings("li").fadeOut("fast",function(){$("#FLBannerImage").siblings("li").removeClass("thisActive")});	
			break;
						
		}
		
		
		
	});	

function clearTim(){
	clearInterval(myTim);
}







$(".BoxLinkArrow").click(function(){
	
	if($(this).siblings(".expandedLinks").children(".expandedLinksContainer").hasClass("openMenu")){
		$(this).siblings(".expandedLinks").children(".expandedLinksContainer").slideUp();
	$(this).siblings(".expandedLinks").children(".expandedLinksContainer").removeClass("openMenu");
		//break;
	}else{
	var existMenu = $(".openMenu").parent(".expandedLinks").attr("id");
	$(".openMenu").slideUp();
	$("#"+existMenu).children(".expandedLinksContainer").removeClass("openMenu");
	$(this).siblings(".expandedLinks").children(".expandedLinksContainer").slideDown();
	$(this).siblings(".expandedLinks").children(".expandedLinksContainer").addClass("openMenu");
	//break;
	}	
});
	
	$("#facilitiesMap li").click(function(){
					$(this).children("span").slideToggle("fast");
					$(this).siblings("li").children("span").hide("fast");	
				});
	
//	$(".event").parent("td").attr("style","position:relative;");
	//$(".event").siblings(".calEventPopup").hide();
	$(".event").siblings(".calEventPopup").wrap("<div class='eventOuter' ></div>");
	$(".calEventPopup").prepend("<div class='closeMe'>X</div>");
	
	
	$(".event").attr("href","javascript:;");
	$(".event").click(function(){
		var wid = $(this).siblings(".eventOuter").width();
		var middle = wid-20;
		$(this).siblings(".eventOuter").css("margin-left","-"+middle+"px");
		$(this).siblings(".eventOuter").toggle();
		
		});
	$(".closeMe").click(function(){
	
		$(this).parents(".eventOuter").hide();
		
		});
});