var thisTimer;
function homeSwitchInit(){
	var allofthem = $$('.switch');
	$('swd1').addEvent('load',thisTimer = function(s){
		for(var i =0;i < allofthem.length;i++){
			var e = allofthem[i];
			if(e.getStyle('display') == 'block'){
				var nexty = i + 2;
				if(nexty > allofthem.length){
					nexty = Number(1);
				}
				var showthis = 'swd' + String(nexty);
				e.fade('out');
				e.setStyle('display','none');
				$(showthis).setStyles({ opacity:0,display:'block'});
				$(showthis).fade('in');
				$$('.swlink a').removeClass('current');
				var selector = 'swl'+String(nexty);
				$(selector).addClass('current');
				break;
			}

		}
	}.periodical(4000));
	$$('.swlink a').each(function(e){
		e.addEvent('click',function(s){
			$$('.swlink a').removeClass('current');
			e.addClass('current');
			$$('.switch').setStyle('display','none');
			$(e.id.replace("l","d")).setStyles({ opacity:0,display:'block'});
			$(e.id.replace("l","d")).fade('in');
			$clear(thisTimer);
			return false;
		});
	});
	if(allofthem.length == 1){
		$clear(thisTimer);
	}
}

