/**
 * ACTIONSCRIPT / JS COMM
 *
 **/
function thisMovie(movieName) {
	if (navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName];
	} else {
		return document[movieName];
	}
} // thisMovie
function sendToActionScript(name, value) {
	if (thisMovie(name)) thisMovie(name).sendToActionScript(value);
} // sendToActionScript

/**
 * PLAY SOUND
 *
 **/
function playSound(name)
{
	sendToActionScript('epiphanet-sound', name);
} // playSound

/**
 * SET OVERS
 * Creates the roll over anims for the nav.
 *
 **/
var navClass		= "navitems";
var moveAmt			= 25;
var moveSpeed		= 750;
var topPos			= "-70px";
function setOvers()
{
	$('.'+navClass).each(function(item) {
		$(this).hover(function() {
			var moveTo = parseFloat(topPos)+moveAmt;
			$(this).animate(
				{ top: moveTo + "px" },
				{ duration: moveSpeed, queue: false }
			);
			playSound('swoosh');
		}, function() {
			$(this).animate(
				{ top: topPos },
				{ duration: moveSpeed, queue: false }
			);
		});
	});
} // setOvers

/**
 * ITEM OVERS
 *
 **/
var origContent = '';
var overDelay = 250;
function itemOvers()
{
	//origContent = $("#content-inner").html();
	$(".item").each(function(item) {
		$(this).hover(function() {
			var id = $(this).attr("id").substr(5);
			playSound('s'+id);
			$(this).oneTime(overDelay, "over", function() {
				$("#content-portfolio").html($("#html-"+id).html());
			});
		}, function() {
			$(this).stopTime("over");
		});
	});

} // itemOvers

/**
 * SET EXTERNAL TARGETS
 *
 **/
function setExternalTargets()
{
	$("a").each(function(a) {
		if ($(this).attr("href") && $(this).attr("rel") == "external")
		{
			$(this).attr("target", "_blank");
		} // external link
	});
} // setExternalTarget

/**
 * DETECT RESOLUTION
 *
 **/
function detectResolution()
{
	//var width = screen.width;
	var width = $(window).width();
	if (width < 500) location.replace('http://mobile.epiphanet.com');
} // detectResolution

/**
 * INIT CONTENT
 *
 **/
function initContent()
{
	var loc = window.location.toString();
	if (loc.indexOf("#") !== -1)
	{
		loc = loc.substr(loc.lastIndexOf("#")+1);
		if (loc == "iphone") loc = "2";		
		$("#content-portfolio").html($("#html-"+loc).html());
	} // indexOf
} // initContent

/**
 * DOCUMENT READY
 *
 **/
$(document).ready(function() {
	setOvers();
	itemOvers();
	setExternalTargets();
	initContent();
	//detectResolution();
});