/* ============================================================
 *
 *                   Image Rotator Script
 *                   Rev: 23/06/08
 *                   image_rotator.js
 *
 * ------------------------------------------------------------
 *
 * Variables: Pic(array), ir_Link(array), ir_Link_new(array), ir_Pic_alt(array), ir_div_box
 *
 *
 *
 * ============================================================ */
window.addEventListener?window.addEventListener("load",ir_init,false):window.attachEvent("onload",ir_init);
var current=0,mHTML = "",ir_imgs="", ir_fade_speed=.025, onclick="", alt="";
function $e(i) {return document.getElementById(i);}
function ir_init() {
	if((ir_Link.length == "1")&&(!ir_Link[0] == "")){
		title="";
		if((!ir_Pic_alt[0] == "")||(!ir_Pic_alt[0] == undefined)){alt = ir_Pic_alt[0];}
		if(ir_Link_new[0] == "yes"){onclick = "onclick=\"window.open(this.href,'_blank'); return false;\""}
		mHTML+="<a href=\""+ir_Link[0]+"\" "+onclick+" title=\""+alt+"\">";
	}
	if(ir_Link.length > "1"){
		for(i=0; i<Pic.length; i++){
			onclick="";
			alt="";
			if(ir_Link[i] == undefined){ ir_Link[i] = "#" }
			if(ir_Link_new[i] == "yes"){onclick = "onclick=\"window.open(this.href,'_blank'); return false;\""}
			if((!ir_Pic_alt[i] == "")||(!ir_Pic_alt[i] == undefined)){alt = ir_Pic_alt[i];}
			mHTML+="<a href=\""+ir_Link[i]+"\" "+onclick+" title=\""+alt+"\">";
			mHTML+="<img style=\"display: none;\" src=\""+Pic[i]+"\" alt=\""+alt+"\" /></a>";
		}
	} else {
		for(i=0; i<Pic.length; i++){
			alt="";
			if((!ir_Pic_alt[i] == "")||(!ir_Pic_alt[i] == undefined)){alt = ir_Pic_alt[i];}
			mHTML+="<img style=\"display: none;\" src=\""+Pic[i]+"\" alt=\""+alt+"\" />";
		}
	}
	if((ir_Link.length == "1")&&(!ir_Link[0] == "")){mHTML+="</a>";}
	$e(ir_div_box).style.background = "transparent url('"+Pic[1]+"') no-repeat 0 0";
	$e(ir_div_box).innerHTML = mHTML;
	ir_imgs = $e(ir_div_box).getElementsByTagName("img");
	for(i=0;i<ir_imgs.length;i++) ir_imgs[i].xOpacity = .99;
	ir_imgs[0].style.display = "block";
	setTimeout(ir_fadewait,ir_fade_timer);
}
function ir_fade() {
	cOpacity = ir_imgs[current].xOpacity;
	nIndex   = ir_imgs[current+1]?current+1:0;
	cOpacity-=ir_fade_speed;
	ir_imgs[current].xOpacity = cOpacity;
	ir_opacity(ir_imgs[current]);
	if(cOpacity<=0) {
		ir_imgs[current].style.display = "none";
		ir_imgs[current].xOpacity = .99;
		ir_opacity(ir_imgs[current]);
		current = nIndex;
		ir_imgs[current].style.display = "block";
		nBackground  = ir_imgs[current+1]?current+1:0;
		$e(ir_div_box).style.background = "transparent url('"+Pic[nBackground]+"') no-repeat 0 0";
		setTimeout(ir_fadewait,ir_fade_timer);
	} else {
		setTimeout(ir_fade,ir_fade_fader);
	}
}
function ir_fadewait(){
	setTimeout(ir_fade,ir_fade_fader);
}
function ir_opacity(obj) {
	obj.style.opacity = obj.xOpacity;
	obj.style.MozOpacity = obj.xOpacity;
	obj.style.filter = "alpha(opacity=" + (obj.xOpacity*100) + ")";
	if(obj.xOpacity<=0.25){obj.xOpacity == 0}
}
