// swfobject defaults
var swfoVars = {};
var swfoParams = {wmode:"transparent"};
var swfoAttrib = {};

// init chrome
function chromeInit(){
	$('ul.nav li:first a').css({
		'border-left': 'none',
		'padding-left': 0
	});
	$('ul.nav li:last a').css({'padding-right':0});
	$('#chart tr:first td, .lfm li:first').css({'border-top':'none'});
	$('ul.stats li:last').css({
		'border-bottom':'none'
	});
}

$(document).ready(function(){
	// rounders
	$('.image.round').each(function(){
		var image = $(this).children('img').attr('src'),
		height = $(this).children('img').attr('height'),
		width = $(this).children('img').attr('width');
		if(image) $(this).css({"background-image":"url("+image+")", 'height': height, 'width': width});
		$(this).html('');
	});
	
	// expand 
	$('.microhertz').click(function(){
		$(this).remove();
		$('#microhertz').show();
		$(window).scrollTo('#microhertz', 250, {offset:{top:-20}});
	});
	
	// clickers
	$('a.toggle').click(function(){
		$(this).remove();
		$('div.toggle:hidden').fadeIn();
	});
	$('a.donate').click(function() {
		$('#donate').submit();
	});
	$('a.login').click(function() {
		$('form.login').submit();
	});
	$('a.logout').click(function() {
		$('form.logout').submit();
	});
	$('input#password').click(function() {
		$(this).val('');
	});
	$('.album').each(function(i) {
		if(i%4 == 3) {
			$(this).css({
				'margin-right':0
			});
		}
	});
	
	// faders
	var welcome = readCookie('welcome');
	if(!welcome) {
		setTimeout("$('#welcome').slideDown()", 1000);
	}
	else {
		$('.intro').append('<p><a class="jq welcome">Watch the introduction</a></p>');
	}
	$('#welcome .close').click(function(){
		createCookie('welcome', 'no', 1095);
		$('#welcome').slideUp();
	});
	$('a.welcome').click(function(){
		eraseCookie('welcome');
		$(this).remove();
		$('#welcome').slideDown();
	});
	$('#leaderboard a.open').click(function(){
		$(this).remove();
		$('#chart tr.stealth').fadeIn();
	});
	$('#extended').slideDown();
	
	// buttons
	$('.button').fadeTo(0,0.8);
	$('.button').hover(function(){
		$(this).fadeTo(100,1);
	}, function(){
		$(this).fadeTo(100,0.8);	
	});

	// zebra
	$('#chart tr:even').addClass('even');
	$('#chart tr:nth-child(1)').addClass('first');
	
	// init chrome
	chromeInit();
});