/* Start Up */
function StartUp(runnable)
{
	$(document).ready(runnable.run);
}


/* External Links */
var ExternalLinks =
{
	run: function()
	{
		$('a[rel="external"]').bind('click', ExternalLinks.click);
		$('a[href^="http:"]').bind('click', ExternalLinks.click);
		$('a[href^="https:"]').bind('click', ExternalLinks.click);
	},
	click: function(event)
	{
		open($(this).attr('href'));
		return false;
	}
}
StartUp(ExternalLinks);

/* Confirm Links */
var ConfirmLinks =
{
	run: function()
	{
		$('a.confirm').bind('click', ConfirmLinks.click);
	},
	click: function(event)
	{
		if (!confirm(this.title)) {
			return false;
		}
	}
}
StartUp(ConfirmLinks);

var ReplaceSubmit =
{
	run: function()
	{
		if (!$('#simple_wireframe').get(0)) {
			$('form .submit').hide();
			$('form .reset').hide();
			$('form .submit_button a').css("display", "block")
			.bind('click', function(e){
				$(this).parents('form').submit();
				return false;
			});
			$('form .reset_button a').css("display", "block")
			.bind('click', function(e){
				return false;
			});
		}
	}
}
//StartUp(ReplaceSubmit);

/* IE6 png fix */
var IEpngFix =
{
	run: function()
	{
		$.ifixpng('/media/dsg/spacer.gif');
		$('img[src$=".png"]').ifixpng();
		 /*$('body').pngFix();*/
	}
}
StartUp(IEpngFix);
var Table =
{
	run: function()
	{
		$('.box table tr:even').addClass('second');
		$('.box table tr th:first-child').css("text-align", "left");
		$('.box table tr td:first-child').css("text-align", "left");
		/*$('.box table tr').each(function(){
			console.log($(this).filter('td:first'));
			$(this).filter('td:first').css("text-align", "left");
		});*/
	}
}
StartUp(Table);

var BreadcrumbsPositionFix =
{
	run: function()
	{
		if ($("#center .article_rules").html()) {
			$(".breadcrumbs").hide();
		} else {
			var h1bot = $("#center .box h1:first").offset().top + $("#center .box h1:first").height() - $("#center").offset().top + 20;
			$(".breadcrumbs").css("top", h1bot + "px");
		}
	}
}
StartUp(BreadcrumbsPositionFix);