var Table = {

	init: function()
	{
		$$('.table').each(function(table, i) {
			Table.activate(null, table, table.select('tr.title').first());
			table.select('tr.title').each(function(tr, i) {
				tr.observe('mouseenter', function(event) {
					Table.activate(event, table, tr);
				})
			})
			table.select('tr').each(function(tr, i) {
				tr.observe('click', Table.click)
			})
		})
	},

	activate: function(event, table, tr)
	{
		table.select('.active').first().removeClassName('active');
		table.select('.data:not(.hidden)').first().addClassName('hidden');
		if (tr) tr.addClassName('active');
		if (tr) tr.next().removeClassName('hidden');
	},
	
	click: function(event)
	{
		var url = this.select('.tr-link').first().href;
		if (url != undefined) {
			window.location = url;
		}
	}
}
/*
var Modal = {
	init: function()
	{
		$$('.modal').each(function(obj, i) {
			$(obj).observe('click', function(event) {
				showSlideWindow(obj, 600, 400);
				Event.stop(event);
			});
		});
	}
};

var Promo = {
	enabled: false,
	data: [],
	init: function(promo_raw)
	{
		if (promo_raw){
			data = this.decode(promo_raw);
			if (typeof data.promo_id != 'undefined'){
				this.enabled = true;
				this.data = data;
				this.setStyle();
			}
		}
	},
	setStyle: function()
	{
			var sheet=document.styleSheets[0];
			var rules=sheet.cssRules? sheet.cssRules: sheet.rules;
			for (i=0; i<rules.length; i++){
				if(rules[i].selectorText.toLowerCase()=="body"){
					rules[i].style.backgroundImage = 'url(' + base_url + 'img/promo/banner/' + this.data.promo_id + '/' + this.data.banner + ')';
					rules[i].style.backgroundRepeat = 'no-repeat';
					rules[i].style.backgroundColor = this.data.background_color;
					rules[i].style.backgroundPosition = 'center top';
					rules[i].style.backgroundAttachment = 'fixed';
					rules[i].style.cursor = 'pointer';
				}
				if(rules[i].selectorText.toLowerCase()=="#wrapper"){
					rules[i].style.backgroundImage = 'url(' + base_url + 'img/promo/page/' + this.data.promo_id + '/' + this.data.page + ')';
					rules[i].style.backgroundRepeat = 'repeat-x';
					rules[i].style.backgroundColor = this.data.page_color;
					rules[i].style.backgroundAttachment = 'scroll';
					rules[i].style.cursor = 'default';
				}
			}
	},
	decode: function(raw)
	{
		var encoded = raw.replace(/(\w{2})/g,"%$1");
		var data = eval('(' + unescape(encoded) +')');
		return data;
	},
	click: function()
	{
		if (!this.enabled) return;
		if (this.data.url.substr(0, 25).toLowerCase() == 'http://www.rakedeals.com/'){
			window.location = this.data.url;
		}
		else {
			window.open(base_url+"click/", 'promo');
		}
		
	}
}

var Languages = {
	init: function() {
		$$('.languages')[0].observe('mouseover', function(event) {
			$$('.languages ul')[0].style.display = 'block';
		})
		$$('.languages')[0].observe('mouseout', function(event) {
			$$('.languages ul')[0].style.display = 'none';
		})	}
}

var Review = {
	top: null,
	dload: null,
	init: function(){
		this.dload = $('dload');
		if (!this.dload) return;
		this.top = $$('.right_main_block.tournaments')[0];
		
	},
	scroll: function(){
		if (this.top == null) return;
			if (this.top.viewportOffset()[1]+200 < 0) {
				this.dload.style.top = '0px';
				this.dload.style.left = (this.top.viewportOffset()[0]-5) + 'px';
				if(!this.dload.visible())
					if(Prototype.Browser.IE || Prototype.Browser.Chrome) this.dload.show(); else this.dload.appear();//this.dload.show(); }
			} else {
				if(this.dload.visible())
					if(Prototype.Browser.IE || Prototype.Browser.Chrome) this.dload.hide(); else this.dload.fade({duration:0.5}); //this.dload.hide();
			}
	}
	
};

if (typeof promo != 'undefined') {
	Promo.init(promo);
}
*/
Event.observe(window, 'load', function() {
	Table.init();
//	Languages.init();
//	Modal.init();
//	Calculator.init();
//	Review.init();
});
/*
Event.observe(window, 'scroll', function() {
	Review.scroll();
});

*/


