jQuery(function($) {

	var cm;

	if($('#matrix .squares li a.current').length == 0){
		cm = Math.ceil(17*Math.random())-1;
	}

	$('#matrix .squares li a').each(function(i){

		if(cm == i){
			$(this).addClass('current');
		}

		if($(this).is('.current')){
			cm = i;
			$('#nav').css('background-image', 'url(img/matrix/'+REX_CUR_CLANG+'/overview'+(cm+1)+'.jpg)');
		}
		$(this).mouseover(function(){
			$('#nav').css('background-image', 'url(img/matrix/'+REX_CUR_CLANG+'/overview'+(i+1)+'.jpg)');
		});
	});


	$('#page_margin').bind('mouseover', function(){
		$('#nav').css('background-image', 'url(img/matrix/'+REX_CUR_CLANG+'/overview'+(cm+1)+'.jpg)');
	});
	$('#nav').bind('mouseover', function(){
		return false;
	});


	$('#comments_bottom a').each(function(){
		var $this = $(this);
		var href = $this.attr('href')+'?TB_iframe=true&width=500&height=550';
		$this.attr('href',href);
		$this.addClass('thickbox');
	});

	tb_init('#comments_bottom .thickbox');

});
