var wg1=new Image();
wg1.src="/images/widget/widget1.jpg";
var wg2=new Image();
wg2.src="/images/widget/widget2.jpg";
var wg3=new Image();
wg3.src="/images/widget/widget3.jpg";
var wg4=new Image();
wg4.src="/images/widget/widget4.jpg";
var wg5=new Image();
wg5.src="/images/widget/widget5.jpg";
var wg6=new Image();
wg6.src="/images/widget/widget6.jpg";

bgpos10='0px 0px';
bgpos11='-26px 0px';
bgpos20='0px -32px';
bgpos21='-26px -32px';
bgpos30='0px -64px';
bgpos31='-26px -64px';
bgpos40='0px -96px';
bgpos41='-26px -96px';
bgpos50='0px -128px';
bgpos51='-26px -128px';
bgpos60='0px -160px';
bgpos61='-26px -160px';

function clicker(num,stopper){	if (num==7){		num=1;
	}
	var old=parseInt($('cur').value);
	$('but'+num).style['background']="url('/images/widget/buts2.png') "+window['bgpos'+num+'1']+" no-repeat";
	$('but'+old).style['background']="url('/images/widget/buts2.png') "+window['bgpos'+old+'0']+" no-repeat";

	if (num!=old){		new Effect.Opacity("page"+num,{duration:.25,from:0,to:1.0});
		$('widgetCont1').setAttribute('onclick',"javascript: window.location='"+$('link'+num).value+"'");
		$('page1').setAttribute('onclick',"javascript: window.location='"+$('link'+num).value+"'");
		$('widgetCont1').setAttribute('title',$('title'+num).value);
		$('cur').value=num;
	}

	if (stopper==null){		fadeOut=setTimeout('autoTrans(null,null)',speed);
	} else {		clearTimeout(fadeOut);
		clearTimeout(fadeIn);
		fadeOut=0;
		fadeIn=0;
	}
}

function autoTrans(num,stopper){	var old=parseInt($('cur').value);
	if ((num!=null&&num!=old)||num==null){		new Effect.Opacity("page"+old,{duration:.25,from:1.0,to:0});
	}
	var newNum=old+1;
	if (num==null&&stopper==null){		fadeIn=setTimeout('clicker('+newNum+',null)',500);
	}else{		fadeIn=setTimeout('clicker('+num+',"true")',500);
	}
}

var speed=6000;
var fadeIn=0;
var fadeOut=0;

//clearTimeout();
clearTimeout(fadeIn);
clearTimeout(fadeOut);
Event.observe(window,'load',function(){	// let's make all elements to transparent except the first one
	$('page2').setOpacity(0);
	$('page2').setStyle({visibility:'visible'});
	$('page3').setOpacity(0);
	$('page3').setStyle({visibility:'visible'});
	$('page4').setOpacity(0);
	$('page4').setStyle({visibility:'visible'});
	$('page5').setOpacity(0);
	$('page5').setStyle({visibility:'visible'});
	$('page6').setOpacity(0);
	$('page6').setStyle({visibility:'visible'});	var fadeOut=setTimeout('autoTrans(null,null)',speed);
});
$('cur').value=1;
//fadeOut=setTimeout('autoTrans(null,null)',speed);