var autoplay = 1;


/*--------------collapsible Find Information section--------------*/
$(document).ready(function(){
	
	$("#findinfoboxes a.arrow").eq(1).addClass("active");
	$("#findinfoboxes ul").eq(1).show();

	$("#findinfoboxes a.arrow").click(function(){
		$(this).next("ul").slideToggle("medium");
		//$(this).siblings.removeClass("active");
		$(this).toggleClass("active");
		//$("#findinfoboxes a.arrow").removeClass("active");
		$("#findinfoboxes a.arrow").not(this).removeClass("active");
		$("#findinfoboxes a.arrow").not(".active").find("+ ul").slideUp("medium");
		
	});

});


/*--------- news & events tabs ------------------------------------*/
$(document).ready(function(){
	
	$("#news a.tab").addClass("active");
	$("#news a.tab").show();
	
	$("#events a.tab").click(function(){		
		$("#news a.tab").removeClass("active");
		$("#news a.tab").find("+ ul").slideUp("medium");
		$(this).addClass("active");	
		$(this).find("+ ul").slideDown("medium");		
		return false;
	});
	$("#news a.tab").click(function(){		
		$("#events a.tab").removeClass("active");
		$("#events a.tab").find("+ ul").slideUp("medium");
		$(this).addClass("active");	
		$(this).find("+ ul").slideDown("medium");		
		return false;
	});
});


/*--------- png fix for IE6 ------------------------------------*/
$(document).ready(function(){
	$("#flashbanner").supersleight();
	$("#rightcolumn").supersleight();
	$("#lowercontent").supersleight();	
});


/*--------- Banner  ------------------------------------*/
$(document).ready(function() {	

	//Show Banner

	//Click and Hover events for thumbnail list
	$(".image_thumb ul li:first").addClass('active'); 
	  
	$(".image_thumb ul li .block a").click(function(){ 				 
		 StopSlide();			
			var id = this.id.replace("pagelink","");
			SwitchSlide(id);
		
		
			$(".image_thumb ul li").removeClass('active'); //Remove class of 'active' on all lists
			$("li#thumb"+id).addClass('active');  //add class of 'active' on this list only
			return false;
	});


	$(".image_thumb ul li").click(function(){ 		
		StopSlide();			
		var id = this.id.replace("thumb","");
		SwitchSlide(id);
		$(".image_thumb ul li").removeClass('active'); //Remove class of 'active' on all lists
		$(this).addClass('active');  //add class of 'active' on this list only
		return false;
		
	}) .hover(function(){
		$(this).addClass('hover');
		}, function() {
		$(this).removeClass('hover');
	});
	
});//Close Function

function SwitchSlide(id){
	//temporary fix to handle cache issue
	var imgAlt = "";
	var imgSrc = "";
	var imgHref = "";
	
	if (id == 1) {
		$(".main_image img").fadeOut(300, function() {
			$(".main_image img").attr({ src: "/images/_banner/splash1.jpg" , alt: "Women's Leadership"});
			$(".main_image a").attr({ href: "/about/spotlight/women/"});
			$(".main_image img").fadeIn(300);
		});
	} else if (id == 2) {
		$(".main_image img").fadeOut(300, function() {
			$(".main_image img").attr({ src: "/images/_banner/splash2.jpg" , alt: "Sustainability &amp; The Environment"});
			$(".main_image a").attr({ href: "/about/spotlight/sustainability/"});
			$(".main_image img").fadeIn(300);
		});
	} else if (id == 3) {
		$(".main_image img").fadeOut(300, function() {
			$(".main_image img").attr({ src: "/images/_banner/splash3.jpg" , alt: "Global Understanding"});
			$(".main_image a").attr({ href: "/about/spotlight/global/"});
			$(".main_image img").fadeIn(300);
		});
	} else if (id == 4) {
		$(".main_image img").fadeOut(300, function() {
			$(".main_image img").attr({ src: "/images/_banner/splash4.jpg" , alt: "Innovation &amp Research"});
			$(".main_image a").attr({ href: "/about/spotlight/innovation/"});
			$(".main_image img").fadeIn(300);
		});
	} 
	
	/*
	var imgAlt = $("#thumbheader"+id).text(); //Get Alt Tag of Image
	var imgSrc = $("#thumblink"+id).attr("href"); //Get Main Image Src
	var imgHref = $("#pagelink"+id).attr("href"); //Get page URL
	$(".main_image img").fadeOut(300, function() {
		$(".main_image img").attr({ src: imgSrc , alt: imgAlt});
		$(".main_image a").attr({ href: imgHref});
		$(".main_image img").fadeIn(300);
	});
	*/
}

function SlideBanner(slide){
	$(".image_thumb ul li:first").addClass('active'); 
	$(".image_thumb ul li").click(function(){ 
		//Set Variables
		var imgAlt = $(slide).find('h2').text(); //Get Alt Tag of Image
		var imgTitle = $(slide).find('a').attr("href"); //Get Main Image URL
		var imgHref = $(slide).find('.block a').attr("href"); //Get Main Image URL
		
		if ($(slide).is(".active")) {  //If it's already active, then...
			return false; // Don't click through
		} else {
			//Animate the Teaser		
			$(".main_image img").animate({ opacity: 0}, 0 );
			$(".main_image img").attr({ src: "",alt:""});
			$(".main_image a").attr({ href: ""});
			$(".main_image img").attr({ src: imgTitle , alt: imgAlt});
			$(".main_image a").attr({ href: imgHref});
			$(".main_image img").fadeIn({ opacity: 1}, 250 );
		}
		
		$(".image_thumb ul li").removeClass('active'); //Remove class of 'active' on all lists
		$(slide).addClass('active');  //add class of 'active' on this list only
		return false;
		
	}) .hover(function(){
		$(slide).addClass('hover');
		}, function() {
		$(slide).removeClass('hover');
	});
	
}

//autoplay banner slide
$(window).load(function(){
	var play="ok";
	
	//set loop settings
	var slideTimer = 4500;
	
	SlideIt(1);
	
	function SlideIt(j){
		if(autoplay == 1){
			if(j == 4)
				var n = 1
			else
				var n = j+1;
			$("#splash"+j).stop().animate({opacity: 1},slideTimer, function() {
				if(autoplay == 1){
					$("#splash"+j).fadeOut("slow", function(){
						$(".image_thumb li").removeClass("active");						
						$("#splash"+j).fadeIn("slow");									
						//Set variables
						var imgAlt = $("#thumb"+n).find('h2').text(); //Get Alt Tag of Image/*
						var imgTitle = $("#thumb"+n).find('a').attr("href"); //Get Main Image URL
						var imgHref = $("#splash"+n).find('a').attr("href"); //Get Main Image URL
						
						//Animate the Teaser	
						$(".main_image img").animate({ opacity: 0}, 0 );
						$(".main_image img").attr({ src: "",alt:""});
						$(".main_image a").attr({ href: ""});
						$(".main_image img").attr({ src: imgTitle , alt: imgAlt});
						$(".main_image a").attr({ href: imgHref});
						$("#thumb"+n).addClass("active");
						$(".main_image img").animate({ opacity: 1}, 250,function(){
								if(autoplay == 1) SlideIt(n);	
			});});}});	
		}			
	}
});
	

function StopSlide(){
	autoplay = 0;
}

