function ViewPrizes(){
	location.href='http://futuremark.com/community/halloffame/lordsofoverclocking/';
}
$(document).ready(function() {	
	ecLinks.init();
	$('div.prizeBoxNavi a').click(function(){
		$('div.prizeBoxNavi a').removeClass("a selected");
		$(this).addClass("a selected");
		$('div.weekPrizes div.week').hide();
		$('div.weekPrizes div#' + $(this).attr('show')).show();

	 });
	$("a.buttonTermsnConditions").click(function () {
      		$("#termsandconditions").toggle();
	});
	$('div#toplistNavi1 a').click(function() {
		$('div#toplistNavi1 a').removeClass("a selected");
		$(this).addClass("a selected");
		$('div#'+ $(this).attr('list') + ' div.row div.gpu').hide();
		$('div#'+ $(this).attr('list') + ' div.row div.cpu').hide();
		$('div#'+ $(this).attr("list") + ' div.row div.' + $(this).attr("component")).show();
	});
	$('div#toplistNavi2 a').click(function() {
		$('div#toplistNavi2 a').removeClass("a selected");
		$(this).addClass("a selected");
		$('div#'+ $(this).attr('list') + ' div.row div.gpu').hide();
		$('div#'+ $(this).attr('list') + ' div.row div.cpu').hide();
		$('div#'+ $(this).attr("list") + ' div.row div.' + $(this).attr("component")).show();
	});
	$('div#toplistNavi3 a').click(function() {
		$('div#toplistNavi3 a').removeClass("a selected");
		$(this).addClass("a selected");
		$('div#'+ $(this).attr('list') + ' div.row div.gpu').hide();
		$('div#'+ $(this).attr('list') + ' div.row div.cpu').hide();
		$('div#'+ $(this).attr("list") + ' div.row div.' + $(this).attr("component")).show();
	});
			
 });
var counter = 0;

var msicompo = {
	counter: 0,
	init: function() {
		var continents = ["EUROPE", "AMERICA", "ASIA"];
		for( var x in continents ) {
			msicompo.getToplist( continents[x] );
		}
	},
	getToplist: function( continent ) {
		
		// Load toplist.
		$.ajax({
			url: "/community/competitions/overclocking/regional09/remotetoplist?continent=" + continent + "&r=" + Math.random(),
			dataType: "html",
			success: function(data) {	
				// Add new toplist.
				var divId = "#toplist" + continent;
				$(divId).html(data);
				//Increase counter
				counter++;
				//Fix user, gpu and cpu strings
				if( counter == 3 ) {
					msicompo.trimStrings();
				}			
			}
		});
		
	},
	trimStrings: function() {
		//Trim all class="user" divs
		var strings = $('div.row div.user');
		for(var i=0; i<strings.length; i++) {
			var newString = ($('div.row div.user:eq('+i+')').text()).substr(0,10);
			if( ($('div.row div.user:eq('+i+')').text()).length > 10 ) {
				newString = newString + "...";
			}
			$('div.row div.user:eq('+i+')').text( newString );
		}
	/*	//Trim all class="gpu" divs
		strings = $('div.row div.gpu');
		for(var i=0; i<strings.length; i++) {
			var newString = ($('div.row div.gpu:eq('+i+')').text()).substr(0,24);
			if( ($('div.row div.gpu:eq('+i+')').text()).length > 25 ) {
				newString = newString + "...";
			}
			$('div.row div.gpu:eq('+i+')').text( newString );
		}
		//Trim all class="cpu" divs
		strings = $('div.row div.cpu');
		for(var i=0; i<strings.length; i++) {
			var newString = ($('div.row div.cpu:eq('+i+')').text()).substr(0,24);
			if( ($('div.row div.cpu:eq('+i+')').text()).length > 254 ) {
				newString = newString + "...";
			}
			$('div.row div.cpu:eq('+i+')').text( newString );
		}
	*/
	}
}