$(document).ready(function(){
	//"InfoMode" -- changes appearance of links
	var infoModeOn = true;
	$("#infoModeToggle").click(function(){
		if (!infoModeOn){
			infoModeOn = true;
			$(".infoModeOff").addClass("infoModeOn");
			$(".infoModeOff").removeClass("infoModeOff");
		}else{
			infoModeOn = false;
			$(".infoModeOn").addClass("infoModeOff");
			$(".infoModeOn").removeClass("infoModeOn");
		}
	});
	
	
	//Infomode Top Button Explanation
	$("#infoModeToggle").hover(function(e){
		$("#infoModeInfo").stop(true, true);
		var theX = e.pageX+5;
		var theY = e.pageY+5;
		$("#infoModeInfo").css({top: theY, left: theX});
		$("#infoModeInfo").fadeIn();
	}, function(){$("#infoModeInfo").fadeOut();});

	
	//Sku landing buttons
	var isShowing = "#overview_div";
	var newSrc = $("#overview").attr("src");
	if (newSrc != undefined){
	newSrc = newSrc.replace(".png", "_hover.png");
	$("#overview").attr("src", newSrc);
	}
	$(".skuLandingButtons").click(function(){
		var divId = "#"+this.id+"_div";
		
		if (this.id == "nft"){
			var theContent = "<div style='text-align: center; margin: 0 auto;'>"+$("#nft_div").html()+"</div>";
			$.nyroModalManual({content: theContent});
		}else{
			//reset all button colors
			$(".skuLandingButtons").each(function(i){
				var newSrc = $(this).attr("src");
				newSrc = newSrc.replace("_hover.png", ".png");
				$(this).attr("src", newSrc);
			});
			var newSrc = $(this).attr("src");
			newSrc = newSrc.replace(".png", "_hover.png");
			$(this).attr("src", newSrc);
			$(isShowing).fadeOut(function(){
				$(divId).fadeIn();
				isShowing = divId;
			});
		}
	});
	//Set the language links to this page
	if (location.href == "http://astro.bluebandmedia.com/" || location.href == "http://astro.ca/" || location.href == "http://www.astro.ca/"){
		var newLink = location.href+"fr/index.php";
	}else if (location.href == "http://astro.bluebandmedia.com/fr/" || location.href == "http://astro.ca/fr/"){
		var newLink = location.href+"index.php";
	}else{
		if ((location.href).search("fr/index.php") == "-1")
		var newLink = (location.href).replace("index.php", "fr/index.php");
		else
		var newLink = (location.href).replace("fr/index.php", "index.php");
	}
	
	$(".langLink").attr("href", newLink);
	
	//Search button first click clears the val
	var firstClick = false;
	$("#searchBox").click(function(){
		if (!firstClick){
			$(this).val("");
			firstClick = true;
		}
	});
});

//This is the image preloader. Neat huh?
jQuery.preloadImages = function()
{
  for(var i = 0; i<arguments.length; i++)
  {
    jQuery("<img>").attr("src", arguments[i]);
  }
}
