$(document).ready(function(){

	// if ie6 lets patch it up
	version = parseFloat(navigator.appVersion.split("MSIE")[1]);
	if(version < 7) {
		$.ie6fixes();
	}

	// preload images
	// if we remove the slash at the front it will work on localhost home page but mod_rewrite urls dont work
	// keeping the slash will make it work on live server as it will go from the root domain 
	$.preloadImages(
		"images/box-tf2-r.jpg",
		"images/box-l4d-r.jpg",
		"images/box-s8-r.jpg",
		"images/box-bfbc2-r.jpg",
		"images/box-avp-r.jpg"
	);
	
	//boxnav 
	$("ul#boxnav li a").click(function() {
		var html = $(this).parent().find("div").html();
		$('#content').html(html);
		//fix for ie7 when js switching
		$('#content ul:first-child').css({'float':'left'});
		return false;
	});
	
	//load first boxnav automatically
	var html = $('ul#boxnav li a').parent().find("div").html();
	$('#content').html(html);
	
	//my video stuff
	$('#video_display').html($('.media_gallery:first div').html());
	$('.media_gallery a').click(function() {
		var html = $(this).parent().find("div").html();
		$('#video_display').html(html);
		return false;
	});
	
	//steampopups	
	//tooltip();
					
});











/*
	Preload Images Function
*/
jQuery.preloadImages = function()
{
  for(var i = 0; i<arguments.length; i++)
  {
    jQuery("<img>").attr("src", arguments[i]);
  }
}

/*
	Jonesys custom function to fixup i6 stuff 
	- make items on top of transparent pngs in ie6 clickable
*/
jQuery.pngLinks = function() {
	$("a").each(
		function( intIndex ){
			$(this ).css({ position: "relative"});
		}
	);
	$("input").each(
		function( intIndex ){
			$(this ).css({ position: "relative"});
		}
	);
}

/*
	Jonesys ie6 fixes function
*/

jQuery.ie6fixes = function() {
	//$(document).pngFix({sizingMethod:"crop"});
	//$(".textbox_middle").pngFix({sizingMethod:"scale"});
	//$('a.home:hover').css({backgroundPosition: '0px 40px'});
	//$('a.listen').css({background-position-x: '-73px',  background-position-x: '0px'});
	
	$('ul#nav li').css({width:'10em'});
	$('ul#nav li a').css({textAlign:'center',padding:'11px 0px 0px 0px'});
	
	$.pngLinks();
}

this.tooltip = function(){	
	/* CONFIG */		
		xOffset = 10;
		yOffset = 20;		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result		
	/* END CONFIG */		
	$("ul.steamfriends li a").hover(function(e){											  
		this.t = this.title;
		this.title = "";									  
		$("body").append("<p id='tooltip'>"+ this.t +"</p>");
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");		
    },
	function(){
		this.title = this.t;		
		$("#tooltip").remove();
    });	
	$("ul.steamfriends li a").mousemove(function(e){
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};

