//*****************************************
// Blending Image Slide Show Script- 
//*****************************************

function SlideShow()
{
	// Specify interval between slide (in mili seconds)
	this.slide_speed = 3000;

	// Specify images
	this.slide_images = new Array(
		"/Images/Cover/photo_main1.jpg",
		"/Images/Cover/photo_main2.jpg",
		"/Images/Cover/photo_main3.jpg",
		"/Images/Cover/photo_main4.jpg"
	);

	// Specify corresponding links
	/*
	this.slide_links = new Array(
		"/Admission/F2_0708.html",
		"/Departments/Committee/MCE/wetland.html",
		"/Departments/Committee/PUB/parentnight2.html",
		"/Departments/Committee/CCA/LEAD_FLL.html"
	);
	*/
	this.slide_links = new Array("","","","");

	// Open links in new window? 1=yes, 0=no
	this.link_in_new_win = 0;

	this.current_index = 1;
	this.blend_delay = 0;
	this.images_holder = new Array();
	this.initialized = false;
	this.interval_id = 0;
}

SlideShow.prototype.goCurrentSlideLink = function()
{
	if (this.link_in_new_win)
		window.open(this.slide_links[this.current_index]);
	else
		window.location = this.slide_links[this.current_index];
}

SlideShow.prototype.moveNextSlide = function()
{
	var isIE = document.all;

	if (!document.images)
		return;

	if (isIE)
		document.images.slide.filters[0].apply();

	document.images.slide.src = this.images_holder[this.current_index].src;

	if (isIE)
		document.images.slide.filters[0].play();

	this.current_index++;
	if (this.current_index >= this.slide_images.length)
		this.current_index = 0;
}

SlideShow.prototype.startShow = function()
{
	var that = this;
	var isIE = document.all;

	if (!this.initialized) {
		this.blend_delay = (isIE) ? document.images.slide.filters[0].duration*1000 : 0;
	
		for (var i=0; i < this.slide_images.length; i++) {
			if (this.slide_links[i] == "")
				this.slide_links[i] = "javascript:void(0)";
			this.images_holder[i] = new Image();
			this.images_holder[i].src = this.slide_images[i];
		}

		this.initialized = true;
	}

	this.interval_id = setInterval(function() {
		that.moveNextSlide();
	}, this.slide_speed + this.blend_delay);
}
