<!--link image rollover script  -->
changeIMG = new Array(2);
changeIMG[0] = new Image;
changeIMG[0].src = "../img/home/icmbanner.jpg";
changeIMG[1] = new Image;
changeIMG[1].src = "../img/home/ecssbanner.jpg";

var imgUrl=new Array(2);
changeIMG[0] = "url(\"img/home/icmbanner.jpg\")";
changeIMG[1] = "url(\"img/home/ecssbanner.jpg\")";

var detailbutton=new Array(2);
detailbutton[0] ="#icmdetailbutton";
detailbutton[1] ="#emssdetailbutton"

var flagNum=0;

//SLIDE SHOW
$(document).ready(function() {
	$(".button").show();
	$(".button a:first").addClass("active");

// hide all images except first to avoid initial flicker
$("#slideshow DIV").css({opacity: 0.0});
$("#slideshow DIV:first").css({opacity: 1.0});

// use setInterval to traverse list
var playSlideshow = setInterval( "zoneSwitch()", 6000 ); //previously 3000, 8000

// create buttons to move to specific slide
var $slideButtons = $("#slide-buttons a.slide-button");

$slideButtons.click(function(){
// stop the slideshow, to keep it from trying to overlap our transition


clearInterval(playSlideshow);
// call the function using the index of the clicked button
zoneSwitch( $slideButtons.index(this) );
// restart the slideshow
//setTimeout( playSlideshow = setInterval( "zoneSwitch()", 5000 ), 5000);
});
				
});

function zoneSwitch( slideTo ) {
var $active = $('#slideshow DIV.active');
var $button = $('.button a.active').next();
			if ( $button.length === 0) { //If reaches the end...
				$button = $('.button a:first'); //go back to first
			}
if ( $active.length == 0 ) {
	$active = $('#slideshow DIV:last');
	};
var $next = $active.next().length ? $active.next() : $('#slideshow DIV:first');
$active.addClass('last-active');
// added “slideTo” variable to allow transition to a selected slide
// defaults to null, but if it’s >= 0, it will use this index for “$next”
var slideTo = ( slideTo+1 )? slideTo : null;
if ( slideTo != null ){
	$next = $('#slideshow DIV').eq(slideTo);
	$button = $(".button a").eq(slideTo);	
};

$active.removeClass('active last-active');
$(".button a").removeClass('active'); //Remove all active class
	
$button.addClass('active'); //Add active class (the $active is declared in the  function)
//});

flagNum=(flagNum==1)?0:1;
$("#home_banner").css("background-image",changeIMG[flagNum]);

$(".detailbuttons").hide();
$(detailbutton[flagNum]).show();
}


