
var theImage = new Array()
theImage[0] = 'images/flash_btn_1.gif'
theImage[1] = 'images/flash_btn_2.gif'
theImage[2] = 'images/flash_btn_3.gif'

function orimage()
{
document.getElementById("myImage1").src="images/flash_btn_1.gif"
document.getElementById("myImage2").src="images/flash_btn_2.gif"
document.getElementById("myImage3").src="images/flash_btn_3.gif"
}

active = Math.floor(Math.random()*4);
var arrayLength = 4;
k = 1;
var fadeinTimer,fadeoutTimer,hideTimer;
function animate(i,interaction)
{
	clearTimeout(fadeinTimer);
	clearTimeout(fadeoutTimer);
	clearTimeout(hideTimer);
	if(interaction=="first")
	{
		fadeIn(i);
		active = i;
		k = active;
	    timerID = setInterval("autorotator()",7000);
	}
	if(interaction==true)
	{	
		timerID=clearInterval(timerID);
	}
	orimage();
	if(active!=i)
	{
		fadeOut(active);
		fadeIn(i);
		active = i;
	}
	if (i+1!=4){
		document.getElementById("myImage" + (i+1)).src=theImage[i];
	}
	if(interaction==true)
	{
		k = active;
		timerID = setInterval("autorotator()",7000);
	}
}

function autorotator()
{
	animate(k,false);
	if(k!=3)
	{
		k=k+1;
	}
	else
	{
		k =0;
	}
}

function getElm(eID) {
	return document.getElementById(eID);
}
function show(eID) {
	getElm(eID).style.display='block';
}
function hide(eID) {
	getElm(eID).style.display='none';
}
function setOpacity(eID, opacityLevel) {
	var eStyle = getElm(eID).style;
	eStyle.opacity = opacityLevel / 100;
	eStyle.filter = 'alpha(opacity='+opacityLevel+')';
}
function fadeIn(eID) {
	setOpacity(eID, 0); show(eID); var timer = 0;
	for (var i=1; i<=100; i++) {
		fadeinTimer = setTimeout("setOpacity('"+eID+"',"+i+")", timer * 5);
		timer++;
	}
}
function fadeOut(eID) {
	var timer = 0;
	for (var i=100; i>=1; i--) {
		fadeoutTimer = setTimeout("setOpacity('"+eID+"',"+i+")", timer * 3);
		timer++;
	}
	hideTimer = setTimeout("hide('"+eID+"')", 500);
}
var accordion=function(){
	var tm=sp=10;
	function slider(n){this.nm=n; this.arr=[]}
	slider.prototype.init=function(t,c,k){
		var a,h,s,l,i; a=document.getElementById(t); this.sl=k?k:'';
		h=a.getElementsByTagName('span'); s=a.getElementsByTagName('div'); this.l=h.length;
		for(i=0;i<this.l;i++){var d=h[i]; this.arr[i]=d; d.onmouseover=new Function(this.nm+'.pro(this)'); if(c==i){d.className=this.sl}}
		l=s.length;
		for(i=0;i<l;i++){var d=s[i]; d.mh=d.offsetHeight; if(c!=i){d.style.height=0; d.style.display='none'}}
	}
	slider.prototype.pro=function(d){
		for(var i=0;i<this.l;i++){
			var h=this.arr[i], s=h.nextSibling; s=s.nodeType!=1?s.nextSibling:s; clearInterval(s.tm);
			if(h==d){s.style.display=''; su(s,1); h.className=this.sl}
			else if(s.style.display==''){su(s,-1); h.className=''}
		}
	}
	function su(c,f){c.tm=setInterval(function(){sl(c,f)},tm)}
	function sl(c,f){
		var h=c.offsetHeight, m=c.mh, d=f==1?m-h:h; c.style.height=h+(Math.ceil(d/sp)*f)+'px';
		c.style.opacity=h/m; c.style.filter='alpha(opacity='+h*100/m+')';
		if(f==1&&h>=m){clearInterval(c.tm)}else if(f!=1&&h==1){c.style.display='none'; clearInterval(c.tm)}
	}
	return{slider:slider}
}();


