var blank = new Image();
blank.src = '/gfx/Blank.gif';
var marginHolder = 0;

$(document).ready(function()
{
	marginHolder = $(".that_guy").css("marginTop");
	$(".step_on").hide();
	$("#step_1").find("div.step_off").hide();

	var badBrowser = (/MSIE ((5\.5)|6)/.test(navigator.userAgent) && navigator.platform == "Win32");
	if (badBrowser) 
	{
		// get all pngs on page
	 	$("img[src$=.png]:visible").not(".tutorial_number").each(function() 
	 	{
		   	if (!this.complete) 
		   	{
		     	this.onload = function() { fixPng(this) };
		   	} 
		   	else 
		   	{
		     	fixPng(this);
		   	}
	 	});
	}
	
	$("#footer_quiz").click(function()
	{
		$("#open_quiz").click();
	});
	
	$("#open_quiz").toggle(function()
	{
		$(".that_guy").animate( { marginTop: "0" }, 400 );
		$(".that_guy_wrapper").animate( { marginTop: "0" }, 400 );
	},
	function()
	{
		$(".that_guy").animate( { marginTop:  "-193px" }, 300 );
		$(".that_guy_wrapper").animate( { marginTop: "-193px" }, 400 );
	});

	$(".close").click(function()
	{
		$("#open_quiz").click();
	});
	
	$(".roller").hover(function()
	{
		$(this).css("backgroundPosition", "0px -"+$(this).height()+"px");
	},
	function()
	{
		$(this).css("backgroundPosition", "0px 0px");
	});
});

function fixDiv(obj)
{
	var badBrowser = (/MSIE ((5\.5)|6)/.test(navigator.userAgent) && navigator.platform == "Win32");
	if (badBrowser) 
	{
		obj.find('img[src$=.png]:visible').not(".tutorial_number").each(function() 
	 	{
		   	if (!this.complete) 
		   	{
		     	this.onload = function() { fixPng(this) };
		   	} 
		   	else 
		   	{
		     	fixPng(this);
		   	}
	 	});
	}
}

function setBGHeight(ht)
{
	//alert(ht);
	$("div.red_bottom_bg").css("margin-top", "-"+ht+"px");
	$("div.red_bottom_bg").height(ht+"px");
	//alert($("div.red_bottom_bg").css("margin-top"));
}

function fixPng(png) 
{
	// get src
	var src = png.src;
	// set width and height
	if (!png.style.width) { png.style.width = $(png).width(); }
	if (!png.style.height) { png.style.height = $(png).height(); }
	// replace by blank image
	png.onload = function() { };
	png.src = blank.src;
	// set filter (display original image)
	png.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
 }

