///////// image toggle 
var justClickedImage='1';
var AutomaticToggle=true;
function addToggleEvents(){
	for(i=1;i<=3;i++){
		var e = document.getElementById('s'+i);
		e.onclick=function(){
			toggleImage(this,false,false);
		}
	}
	automaticToggle();
}
function automaticToggle(){
	if(!AutomaticToggle)return;
	var next = parseInt(justClickedImage)+1;
	if(next==4)next=1;
	p = document.getElementById('s'+next);
	setTimeout("toggleImage(p,AutomaticToggle,true);",3800);
}
function toggleImage(p,auto,timeout){
	//if toggle came from setTimeout function, and someone clicked during 2sec, dont toggle automaticly!
	if(timeout && !auto)return;
	//if someone clicked, disable automatic toggle
	if(!auto)AutomaticToggle=false;
	if(p.className=='active')return;
		p.className='active';
		var id=p.id.split('s')[1];
		var img = document.getElementById('p'+id);
		//deactivate others
		for(i=1;i<=3;i++)
			if(i!=id){
				t = document.getElementById('p'+i);
				p = document.getElementById('s'+i);
				p.className='';
				t.className='';
				if(i==justClickedImage)t.style.zIndex='50';
				else t.style.display='none';
			}
		//make this pic active
		img.className='active';
		img.style.zIndex = 100;
		img.style.display='none';
		Effect.Appear('p'+id, {duration:1});
		
		//store the just clicked id
		justClickedImage=id;
		//animate, if user didn't click
		if(auto)
			automaticToggle();

}
addOnLoad(addToggleEvents);