var toppics = new Array();
toppics['e'] = new Array("gfx/canwea-mainpic-general-e.jpg","gfx/canwea-mainpic-forum-e.jpg","gfx/canwea-mainpic-conf10-e.jpg","gfx/canwea-mainpic-membership-e.jpg");
toppics['f'] = new Array("gfx/canwea-mainpic-general-f.jpg","gfx/canwea-mainpic-forum-f.jpg","gfx/canwea-mainpic-conf10-f.jpg","gfx/canwea-mainpic-membership-f.jpg");

var toppic_href = new Array();
toppic_href['e'] = new Array("http://www.canwea.ca/wind-energy/index_e.php","http://www.canwea.ca/events/forum/index_e.php","http://www.canwea.ca/events/conference2010/index_e.php","http://www.canwea.ca/about/whatcanweacandoforyou_e.php");
toppic_href['f'] = new Array("http://www.canwea.ca/wind-energy/index_f.php","http://www.canwea.ca/events/forum/index_f.php","http://www.canwea.ca/events/conference2010/index_f.php","http://www.canwea.ca/about/whatcanweacandoforyou_f.php");

var cur_marker = 0;
var in_progress = true;
var duration = 5000;
var tm;

function slideshow_kf() {
	var img = toppics[slideshow_lang][cur_marker];
	var href = toppic_href[slideshow_lang][cur_marker];
	change_slide_kf(img,href);
	if (in_progress) {
		cur_marker++;
		if (cur_marker >= toppics[slideshow_lang].length) { cur_marker = 0; }
		tm = setTimeout("slideshow_kf()",duration);
	}
}

function change_slide_kf(str,href) {
	$("slideshow").set("src",str);
	$("kf_link").set("href",href);
	$$("a.indicator").setStyle("backgroundPosition","top left");
	$("indicator"+cur_marker).setStyle("backgroundPosition","bottom left");
}

window.addEvent('domready', function() {
	slideshow_kf();
	toppics[slideshow_lang].each(function(i) {
		MM_preloadImages(i);
	});
	$("playpause").addEvent("click", function(e) {
		e = new Event(e);
		e.stop;
		e.preventDefault();
		switch (in_progress) {
			case true:
				clearTimeout(tm);
				in_progress = false;
				this.setStyle("backgroundPosition","bottom left");
				break;
			case false:
				this.setStyle("backgroundPosition","top left");
				in_progress = true;
				slideshow_kf();
				break;
		}
	});
	$$("a.indicator").addEvent("click", function(e) {
		e = new Event(e);
		e.stop;
		e.preventDefault();
		in_progress = false;
		clearTimeout(tm);
		$("playpause").setStyle("backgroundPosition","bottom left");
		cur_marker = this.get("rel");
		slideshow_kf();
	});
});
