/*
// "Simple Image Rotator" Module for Joomla! 1.0.x - Version 1.2
// License: http://www.gnu.org/copyleft/gpl.html
// Authors: Fotis Evangelou - George Chouliaras
// Copyright (c) 2006 - 2007 JoomlaWorks.gr - http://www.joomlaworks.gr
// Project page at http://www.joomlaworks.gr - Demos at http://demo.joomlaworks.gr
// ***Last update: August 30th, 2007***
*/

var delay = 5000;
var transition = 40;
var imageContainer = 'jw-sir';
var d=document, imgs = new Array(), zInterval = null, currentmulti=0, pause=false;
function so_init(rotatenum) {
	if(!d.getElementById || !d.createElement)return;
	imgs[rotatenum] = new Array();
	imgs[rotatenum] = d.getElementById([imageContainer+rotatenum]).getElementsByTagName("img");
	for(i=1;i<imgs[rotatenum].length;i++) imgs[rotatenum][i].xOpacity = 0;
	imgs[rotatenum][0].style.display = "block";
	imgs[rotatenum][0].xOpacity = .99;
	totaldelay = ((rotatenum) / totalmulti) * delay;
	setTimeout("so_xfade("+rotatenum+")",totaldelay);
}
function so_xfade(rotatenum) {
	current = window['current' + rotatenum];
	cOpacity = imgs[rotatenum][current].xOpacity;
	nIndex = imgs[rotatenum][current+1]?current+1:0;
	nOpacity = imgs[rotatenum][nIndex].xOpacity;
	cOpacity-=.05; 
	nOpacity+=.05;
	imgs[rotatenum][nIndex].style.display = "block";
	imgs[rotatenum][current].xOpacity = cOpacity;
	imgs[rotatenum][nIndex].xOpacity = nOpacity;
	setOpacity(imgs[rotatenum][current]); 
	setOpacity(imgs[rotatenum][nIndex]);
	if(cOpacity<=0) {
		imgs[rotatenum][current].style.display = "none";
		window['current' + rotatenum] = nIndex;
		setTimeout("so_xfade("+rotatenum+")",delay);
	} else {
		setTimeout("so_xfade("+rotatenum+")",transition);
	}
	function setOpacity(obj) {
		if(obj.xOpacity>.99) {
			obj.xOpacity = .99;
			return;
		}
		obj.style.opacity = obj.xOpacity;
		obj.style.MozOpacity = obj.xOpacity;
		obj.style.filter = "alpha(opacity=" + (obj.xOpacity*100) + ")";
	}
}
function hideLoading() {document.getElementById(preLoader).style.display = 'none';}


// DOM2
if ( typeof window.addEventListener != "undefined" ) { window.addEventListener( "load", init_ahr, false ); }
// IE 
else if ( typeof window.attachEvent != "undefined" ) { window.attachEvent( "onload", init_ahr ); }
else {
	if ( window.onload != null ) {
		var oldOnload = window.onload;
		window.onload = function ( e ) {
			oldOnload( e );
			init_ahr();
		};
	}
	else 
		window.onload = init_ahr;
}
