// --------------------------------------------
// Make jQuery and Prototype play nice together
// --------------------------------------------
var $j = jQuery.noConflict();

// -----------------------------------------------------
// Functions for content loading and history/deeplinking
// -----------------------------------------------------
// This function is called after calling $.historyInit(); after calling $.historyLoad(); after pushing "Go Back" button of a browser
function callback(hash) {
	if(hash) {
		// restore loaded state
		$j("#content").fadeOut("fast", function() {
			$j("#content").load(hash, function() {
				$j("#content").fadeIn("fast");
				setContentScroll();
			});
		});
	} else {
		// load default content
		$j("#content").load('gallery_videos.html', function() {
			setContentScroll();
		});
	}
}

$j(document).ready(function() {
	$j.history.init(callback);
	$j("a[@rel='history']").click(function(){
		$j.history.load(this.href.replace(/^.*#/, ''));
		return false;
	});
});

// ---------------------------
// Functions for the main menu
// ---------------------------

function load(thisPage, thisPageTitle) {
	if (thisPage)
	{
		//alert("load: "+thisPage+" | "+thisPageTitle);
		$j.history.load(thisPage);
		document.title = thisPageTitle; // set page titles in the xml file
	}
}

function loadIntoNewWindow(thisPage) {
	window.open(thisPage, '_blank');
}

// -----------------------
// Functions for rollovers
// -----------------------
// Preload images
if (document.images) {
	var swap_sites_buttonOff = new Image();
	swap_sites_buttonOff.src = "img/ftr_site_swap_btn_off.jpg";
	var swap_sites_buttonOn = new Image();
	swap_sites_buttonOn.src = "img/ftr_site_swap_btn_over.jpg";
	
	var join_the_conversationOff = new Image();
	join_the_conversationOff.src = "img/btn_join_the_conversation_off.jpg";
	var join_the_conversationOn = new Image();
	join_the_conversationOn.src = "img/btn_join_the_conversation_on.jpg";

	var buyOff = new Image();
	buyOff.src = "img/btn_pre-order_now_off.jpg";
	var buyOn = new Image();
	buyOn.src = "img/btn_pre-order_now_on.jpg";

}

// Swap functions
function act (imgName) {
    if (document.images) {
		document[imgName].src = eval(imgName + "On.src");
    }
}

function inact (imgName) {
    if (document.images) {
        document[imgName].src = eval(imgName + "Off.src");
    }
}
