/*
	Flightless - design.interactive.motion.graphic
	Copyright 2009 Flightless
*/

// ------------------------------------------------------------
// flash
// ------------------------------------------------------------
// setHeightPx - set flash height in px
function setHeightPx(h) {
	$('main').setStyle({
		height: h+'px'
	});
	$('main').down().height = h+'px'; // safari % fix
}

// setHeightPerc - set flash height in %
function setHeightPerc(p) {
	$('main').setStyle({
		height: p+'%'
	});
	$('main').down().height = p+'%'; // safari % fix
}

// getHeightPx - return current computed flash height
function getHeightPx() {
	return $('main').getHeight();
}

// maximiseFlash - tell flash to clear and hide content
function maximiseFlash() {
	$('flightless').maximise();
}

// showAbout - show about content
function showAbout() {
	$('flightless').showAbout();
}

// showContact - show contact content
function showContact() {
	$('flightless').showContact();
}

// ------------------------------------------------------------
// content
// ------------------------------------------------------------
// loadContent - load html content into page
function loadContent(path, bgcol) {
	new Ajax.Updater({success: 'content'}, path, {
		onFailure: function(xHR, xJSON) {
			onLoadFailed();
		},
		onComplete: function() {
			onContentLoaded();
		},
		evalScripts: true
	});
	$('content').show();
}

// onLoadFailed - load failed
function onLoadFailed() {
	$('content').innerHTML = '<div>Sorry, this content does not exist.</div><div><a href="#" onclick="maximiseFlash(); return false;">Close</a></div>';
	$('content').show();
}

// clearContent - clear and hide content
function clearContent() {
	$('content').hide();
	$('content').innerHTML = "";
}

// onContentLoaded - load complete
function onContentLoaded() {
	sIFRReplaceStag();
}
