//----------------------------------------------
// VARS
//----------------------------------------------
var section = "home";
var sections = new Array();
var positions = new Array("0","-63","-153","-270","-339","-404","-503");

//----------------------------------------------
// INIT
//----------------------------------------------
$(document).ready(function()
{
	$('.scroll-pane').jScrollPane();
});

//----------------------------------------------
// NAVIGATION
//----------------------------------------------
function navMouseEvents(item, num)
{
	var curSection = "#"+getItemName(item);
	sections.push(item);
	
	var curBackground = "#"+getItemName(item)+"_bkg";
	
	$(item)
		.mouseover(function()
		{
			//$(this).stop().animate({backgroundPosition:"("+getBkgX(num)+"px -24px)"}, {duration:200});
			$(this).stop().animate({top:"-24px"}, {duration:200});
		})
		.mouseout(function()
		{
			if(section != getItemName(item))
			{
				$(this).stop().animate({top:"0px"}, {duration:200});
			}
		})
		.click(function()
		{
			var curOffset = $(curSection).css("top");
			var curOffsetNum = -(curOffset.substr(0, curOffset.indexOf("px")))+"px";
			
			var curBgOffset = $(curBackground).css("top");
			var curBgOffsetNum = -(curBgOffset.substr(0, curBgOffset.indexOf("px")))+"px";
			
			section = getItemName(item);
			resetNav();
			
			if(curSection == "#equipment")
			{
				callEquipResize();
			}
			if(curSection == "#services")
			{
				callServResize();
			}
			
			$("#sections").stop().animate({top:curOffsetNum}, {duration:200});
			$("#backgrounds").stop().animate({top:curBgOffsetNum}, {duration:200});
			$("#sectionswrapper").stop().animate({height:$(curSection).css("height")}, {duration:200});
			$("#contact").stop().animate({top:$(curSection).css("height")}, {duration:200});
			return false;
		})
}
function resetNav()
{
	for(i = 0; i < sections.length; i++)
	{
		var item = sections[i];
		if(section != getItemName(item))
		{
			$(item).stop().animate({top:"0px"}, {duration:200});
		}
	}
}
function flowFooter(h)
{
	//alert(h);
	$("#contact").stop().animate({top:h+"px"}, {duration:200});
}
function callEquipResize()
{
	/* Call a function registered as callPlayBall in the SWF named myMovie. */
	document.getElementById("equipswf").callEquipResizeFlash(); 
}
function callServResize()
{
	/* Call a function registered as callPlayBall in the SWF named myMovie. */
	document.getElementById("servswf").callServResizeFlash(); 
}
//----------------------------------------------
// HOME
//----------------------------------------------
function showHomeSection()
{
	
}

//----------------------------------------------
// SERVICES
//----------------------------------------------
function showServicesSection()
{
	
}

//----------------------------------------------
// EQUIPTMENT
//----------------------------------------------
function showEquiptmentSection()
{
	
}

//----------------------------------------------
// RATES
//----------------------------------------------
function showRatesSection()
{
	
}

//----------------------------------------------
// BOOK
//----------------------------------------------
function showBookSection()
{
	
}

//----------------------------------------------
// LOCATION
//----------------------------------------------
function showLocationSection()
{
	
}

//----------------------------------------------
// HYPE
//----------------------------------------------
function showHypeSection()
{
	
}

//----------------------------------------------
// LIGHTBOX
//----------------------------------------------
function LightboxDelegate(url,caption)
{
	$('#lightboxLink').attr({ 
		href: url,
		title: caption,
		alt: caption
	});
	$('#lightboxLink').lightBox()
	$('#lightboxLink').click();
}

//----------------------------------------------
// UTILS
//----------------------------------------------
function getBkgX(num)
{
	//var xPos = $(item).css("backgroundPosition").substr(0, $(item).css("backgroundPosition").indexOf(" "));
	var xPos = positions[num];
	return xPos;
}
function getItemName(item)
{
	var name = item.substr(item.indexOf("_")+1, item.length);
	return name;
}

