window.addEvent('domready',function(){
	var page;
	$$('#menu>ul>li').each(function(l,i){
		if (l.getChildren().length>1) {
			l.addEvent('mouseenter',function(e){
				 this.getLast().set('styles',{'display':'block'});
				});
			l.addEvent('mouseleave',function(e){
				this.getLast().set('styles',{'display':'none'});
				});
			}
		});
	
	$$('.tabcontin').each(function(d){d.set('morph');});
	$$('.tabbed a').each(function(a,j){
		$$('#media .tabcont').each(function(d,i){ if (i==j) a.obj = d; if (i==0 && j==0) { d.set({'styles':{'display':'block'}}); a.addClass('selected'); } });
		a.addEvent('click',function(e){
			new Event(e).stop();
			$$('#media .tabcont').each(function(d) { d.set({'styles':{'display':'none'}}); });
			$$('.tabbed a').each(function(a){a.removeClass('selected');});
			this.addClass('selected');
			this.obj.set({'styles':{'display':'block'}});
			});
		});
	
	
	$$('.pager a').each(function(a,j){
		var i = a.getLast(); if (i.get('src').indexOf('dbullet')>-1)  page = j;
		if (a.hasClass('leftarr') || a.hasClass('rightarr')) return;
		a.addEvent('click',function(e){
			new Event(e).stop();
			page = j;
			$$('.pager img').each(function(i,k){
				if (k == page) i.set('src',i.get('src').replace('wbullet','dbullet'));
				else i.set('src',i.get('src').replace('dbullet','wbullet'));
				});
			$$('.tabcontin').each(function(d){d.morph({'left':(1-page)*315});});
			});
		});
	
	$$('.leftarr').getLast().addEvent('click',function(e){
		new Event(e).stop();
		page = page - 1;
		if (page<1) page = 1;
		$$('.pager img').each(function(i,k){
			if (k == page) i.set('src',i.get('src').replace('wbullet','dbullet'));
			else i.set('src',i.get('src').replace('dbullet','wbullet'));
			});
		$$('.tabcontin').each(function(d){d.morph({'left':(1-page)*315});});
		});
	
	$$('.rightarr').getLast().addEvent('click',function(e){
		new Event(e).stop();
		page = page + 1;
		if (page>($$('.pager li').length - 2)) page = $$('.pager li').length - 2;
		$$('.pager img').each(function(i,k){
			if (k == page) i.set('src',i.get('src').replace('wbullet','dbullet'));
			else i.set('src',i.get('src').replace('dbullet','wbullet'));
			});
		$$('.tabcontin').each(function(d){d.morph({'left':(1-page)*315});});
		});
	
	$$('.rightbox ul').each(function(d){
		d.getChildren().each(function(l,i){
			var k = l.getLast();
			if (i == 0) k.set({'styles':{'height':48}});
			k.set('morph');
			l.addEvent('click',function(e){
				this.getParent().getChildren().each(function(s){ if (s.getLast() != k) s.getLast().morph({'height':Browser.Engine.trident?1:0}); });
				if (this.getLast().getSize().y > 1) window.location.href = this.get('rel');
				this.getLast().morph({'height':48});
				});
			});
		});
	
	$$('#mainnews div div').each(function(d,i){
		if (i == 0) d.addClass('selected'); d.ord = i;
		d.addEvent('mouseenter',function(e){
			$$('#mainnews div div').each(function(c,j){ c.removeClass('selected'); });
			d.addClass('selected');
			$('mainlink').set({href:d.getChildren().getLast().getChildren().getLast().get('href')});
			$$('#mainnews img').each(function(c,j){
				if (j == d.ord) c.removeClass('inhidden'); else c.addClass('inhidden');
				});
			});
		d.addEvent('mouseleave',function(e){});
		});
	
	$$('#moviesin div').each(function(d){
		var mo = Browser.Engine.trident?24:24;
		d.set('morph');
		d.set({'styles':{'height':mo}});
		d.addEvent('click',function(){
			var t = this.getSize().y;
			if (t == mo) {
				$$('#moviesin div').each(function(e){e.morph({'height':mo});});
				this.morph({'height':24+this.getChildren().getLast().getSize().y});
				}
			else
				window.location.href = '/movie';
			});
		});
	if ($('footballin')) {
		$('footballin').set('morph');
		$('footleft').addEvent('click',function(e){
			new Event(e).stop();
			var t = $('footballin').getPosition($('footballout')).x;
			t = t + 312;
			if (t > 2 ) t = 2;
			var p = Math.floor((2-t)/312);
			$$('.footpage').each(function(i,j){ if (j == p) i.set({src:'/files/pics/dbullet.png'}); else i.set({src:'/files/pics/wbullet.png'}); });
			$('footballin').morph({left:t});
			});
		$('footright').addEvent('click',function(e){
			new Event(e).stop();
			var t = $('footballin').getPosition($('footballout')).x;
			t = t - 312;
			if (t < -5*312+2) t = -5*312+2;
			var p = Math.floor((2-t)/312);
			$$('.footpage').each(function(i,j){ if (j == p) i.set({src:'/files/pics/dbullet.png'}); else i.set({src:'/files/pics/wbullet.png'}); });
			$('footballin').morph({left:t});
			});
		$$('.footpage').each(function(i,j){
			i.addEvent('click',function(e){
				new Event(e).stop();
				$$('.footpage').each(function(k,l){ if (l == j) k.set({src:'/files/pics/dbullet.png'}); else k.set({src:'/files/pics/wbullet.png'}); });
				$('footballin').morph({left:2-j*312});
				});
			});
		}
	if ($('weatherin')) {
		$('weatherin').set('morph');
		$('weatleft').addEvent('click',function(e){
			new Event(e).stop();
			var t = $('weatherin').getPosition($('weatherout')).x;
			t = t + 312;
			if (t > 2 ) t = 2;
			var p = Math.floor((2-t)/312);
			$$('.weatpage').each(function(i,j){ if (j == p) i.set({src:'/files/pics/dbullet.png'}); else i.set({src:'/files/pics/wbullet.png'}); });
			$('weatherin').morph({left:t});
			});
		$('weatright').addEvent('click',function(e){
			new Event(e).stop();
			var t = $('weatherin').getPosition($('weatherout')).x;
			t = t - 312;
			if (t < -5*312+2) t = -5*312+2;
			var p = Math.floor((2-t)/312);
			$$('.weatpage').each(function(i,j){ if (j == p) i.set({src:'/files/pics/dbullet.png'}); else i.set({src:'/files/pics/wbullet.png'}); });
			$('weatherin').morph({left:t});
			});
		$$('.weatpage').each(function(i,j){
			i.addEvent('click',function(e){
				new Event(e).stop();
				$$('.weatpage').each(function(k,l){ if (l == j) k.set({src:'/files/pics/dbullet.png'}); else k.set({src:'/files/pics/wbullet.png'}); });
				$('weatherin').morph({left:2-j*312});
				});
			});
		}
	$$('.article object').each(function(o){ var w = new Element ('div', {'styles':{'text-align':'center'}}); w.wraps(o); });
	$$('.gthumb img').each(function(i){ i.addEvent('click',function(e){$('gotd').src = this.get('rel');});});

	$$('.keeper').each(function(s){
		var i = s.getChildren('img').getLast();
		i.addEvent('click',function(e){
			if (e.target.get('src').indexOf('yes')>0) e.target.set({'src':'/pics/no.png'});	else e.target.set({'src':'/pics/yes.png'});
			z = $('zitem');
			z.set({'value':''});
			$$('.keeper img').each(function(j){
				if (j.get('src').indexOf('no')>0) z.set({'value':z.get('value')+','+j.get('rel')});
				});
			z.set({'value':z.get('value').substr(1)});
			//alert(z.get('value'));
			});
		});

	$$('.switch').each(function(i){i.addEvent('mouseenter',function(e){this.set({src:this.get('src').replace(/grey/,'icon')});});i.addEvent('mouseleave',function(e){this.set({src:this.get('src').replace(/icon/,'grey')});});});
	});

