//-------------------------------------------------------------------
// START: NAV GLOBAL VARIABLES
//-------------------------------------------------------------------

//-------------------------------------------------------------------
// START: PULSE VARIABLES
//-------------------------------------------------------------------

	// general
	var iPulseDelay				= 1200; // time in millseconds between each pulse
	var bPulseTimerIsSet		= false;
	
	// start
	var iPulseStartColor		= "#d0d0cf"; // color, including the # - symbol
	var iPulseStartPositionY	= 0;
	var iPulseStartPositionX	= 15;
	var iPulseStartOpacity		= 0.0;
	
	// stop 1 (in this case stop 1 = peak position)
	var iPulseStop1Color		= "#d0d0cf"; // color, including the # - symbol
	var iPulseStop1PositionY	= 0;
	var iPulseStop1PositionX	= 15;
	var iPulseStop1Opacity		= 0.6;
	var iPulseStop1SpeedIn		= 0; // how fast it moves in to the peak position
	var iPulseStop1TypeIn		= "jswing";
	var iPulseStop1Rest			= 100; // time that the word stops here
	
	// end
	var iPulseEndColor			= "#d0d0cf"; // color, including the # - symbol
	var iPulseEndPositionY		= 50;
	var iPulseEndPositionX		= 15;
	var iPulseEndOpacity		= 0.0;
	var iPulseEndSpeedIn		= 2000; // how fast it moves out from the peak position
	var iPulseEndTypeIn			= "jswing";
	
//-------------------------------------------------------------------
// START: NAV SETTINGS
//-------------------------------------------------------------------

	var bPageIsHome = false;
	
	var origWidth= new Array();

	window['expand_done']=true;
	window['shiftdown_done']=true;
	window['shiftup_done']=true;
	window['unexpand_done']=true;
	
	var permanent= new Array("about","portfolio","team","news","jobs");
	var permanent_url = new Array("/about","/portfolio","/team","/news","/jobs");
	
	var aBrandWord= new Array();	
	var aBrandCopy= new Array();
							  
	var bMenuFallen=false;
	
	var items= new Array();	
	var item_copy= new Array();

//-------------------------------------------------------------------
// START: JQUERY FUNCTIONS
//-------------------------------------------------------------------

// JQUERY - START READY FUNCTIONS
$(document).ready(function(){
	
	// define items
	items = ["spark", aBrandWord[1], permanent[0], aBrandWord[2], permanent[1], aBrandWord[3], permanent[2], aBrandWord[4], permanent[3], aBrandWord[5], permanent[4]]
	item_copy= ["", aBrandCopy[1], "", aBrandCopy[2], "", aBrandCopy[3], "", aBrandCopy[4], "", aBrandCopy[5]]
	item_id= ["navoption1", "navoption2", "navoption3", "navoption4", "navoption5", "navoption6", "navoption7", "navoption8", "navoption9", "navoption10", "navoption11"]
	
}); // end jQuery load

//-------------------------------------------------------------------
// START: FUNCTIONS USED BY ALL MENUS
//-------------------------------------------------------------------

function fncMenuEventAdd() {
	$('div').each(function(i) {
		$("#"+item_id[i] +" p").click(function() { 
			if (!document.getElementById(item_id[i]+'_expanded') && jQuery.inArray(items[i],permanent) == -1)	{
				if(window['expand_done'] && window['unexpand_done'] && window['shiftdown_done'] && window['shiftup_done'])	{
					fncMenuExpand(item_id[i], i);					
				}
			} else	{
				if (i%2==1)	{ //this is a "brand" word, there is no link, if clicked twice, close this
					//document.location.href=permanent_url[jQuery.inArray(items[i],permanent)];
				} else {
					document.location.href=permanent_url[jQuery.inArray(items[i],permanent)];
				}
			}
		});

		$("#"+item_id[i] + " p").mouseover(function()	{
			fncMenuShimmer(items[i],item_id[i]);
		});
	});
} // function fncMenuEventAdd

function fncMenuExpand(curr,index) {
	var container;
	
	$("#"+curr).css({ opacity: '.99'});
	//if ($.browser.opera) {
	//	$("#"+curr).css({ width: origWidth[index]+'px' });
	//}
	if ($.browser.msie) {
		t=$("#"+curr).offset().top + $("#"+curr).height();
		
		if (bPageIsHome) {
			container='#page_container';
		} else {
			container='#spark_menu';
		}
		l=15;
	} else	{
		t=55;
		container='#'+curr;
		l=0;
	}
	
	//create child div
	childtext= jQuery('<span><\/span>').addClass('expanded').attr('id',curr+'_expanded').css({position:'absolute', top: t+'px',padding: '12px 0px 12px 0px',left: l+'px',display:'block',letterSpacing: '0px', fontSize: '15px', textTransform: 'none', opacity: '.3', fontFamily: 'arial, sans', width:'650px', lineHeight: '18px', color: '#181818',height: 'auto', cursor: 'auto'});
	childtext.appendTo(container);
	
	$("#"+curr+'_expanded').html(item_copy[index]);
	exp_height=$("#"+curr+'_expanded').height()+24;
	
	
	fncMenuRetract(curr, index, exp_height);
	$("#"+curr+'_expanded').css({ lineHeight: '0px' });

	window['expand_done']=false;
	$("#"+curr+'_expanded').animate({lineHeight:'18px', opacity: '.99'},200,"easeInCirc", function()	{ window['expand_done']=true;} );

	if($.browser.msie && $.browser.version<7.0)	{
		$("#menu_ie6").css({height:'10px', backgroundRepeat: 'no-repeat'});
	}

} // function fncMenuExpand

function fncMenuShimmer(item,this_item_id) {
	if (bMenuFallen) {
		for (m=0;m<items.length;m++)	{
			$("#"+item_id[m]+"_linkdicator").remove(); 
			if (items[m]==item && jQuery.inArray(items[m],permanent)!=-1)	{
				
				$("#"+item_id[m]).append("<span id='"+this_item_id+"_linkdicator' style='position: absolute; top: 6px;display: block;height: 53px;width: 50px;overflow:hidden;background: url(/global/img/icons/linkdicator_up.png) 0px 2px no-repeat !IMPORTANT;top:0px;left:" + $("#"+item_id[m]).width() +"px'></span>");
				$("#"+this_item_id+"_linkdicator").mouseover(function()	{
					//$("#"+item+"_linkdicator").css({background: "url(/global/img/icons/linkdicator_up.png) no-repeat !IMPORTANT"});
				});
				$("#"+this_item_id+"_linkdicator").click(function()	{
					document.location.href=permanent_url[jQuery.inArray(item,permanent)];
				});
			} 
	
			if (items[m]!=item)	{
				$("#"+item_id[m]).css({opacity:'.40'});
				$("#"+item_id[m]).css({filter:'alpha(opacity=10)'});
				if (document.getElementById(item_id[m]+'_expanded'))	{
					$("#"+item_id[m]+'_expanded').css({opacity:'.40'});
					$("#"+item_id[m]+'_expanded').css({filter:'alpha(opacity=10)'});
				}
			} 
		} // for
		
		$("#"+this_item_id).css({opacity: '.99'});
		if (document.getElementById(this_item_id+'_expanded')) {
			$('#'+this_item_id+'_expanded').css({opacity: '.99'});
		};
	} //bMenuFallen
} // function fncMenuShimmer


function fncMenuRetract(curr, index, exp_height) {
	menu_expanded=false;
	
	$('div').each(function(i)	{
						   
		if(document.getElementById(item_id[i]+'_expanded') && item_id[i] != curr) {
			menu_expanded=true;
			expanded_index=i;
			expanded_id=item_id[i]+'_expanded';
			old_exp_height=$('#'+item_id[i]+'_expanded').height()+24;
		}
				
		if (menu_expanded && curr==item_id[items.length-1]) {
			window['shiftdown_done']=false;
		
			$('#'+item_id[i]).animate({ letterSpacing: '-5px' },100,function() {
				window['shiftdown_done']=true;
				if(expanded_index != items.length-1 && i == items.length-1)	{
					fncMenuShiftUp(expanded_id,expanded_index,old_exp_height);
				}
			});
		}
		
		//content shifts down
		if (i>index && i<items.length)	{
			window['shiftdown_done']=false;
			if ($('#'+item_id[i]).offset())	{
				offset=$('#'+item_id[i]).offset().top;
			}
		
			$('#'+item_id[i]).animate({top: (offset + exp_height) + 'px' },200,"easeOutBounce", function() {
				window['shiftdown_done']=true;
				if(menu_expanded && i==items.length-1)	{
					fncMenuShiftUp(expanded_id,expanded_index,old_exp_height);
				}
			});
		}
	});
} // function fncMenuRetract

function fncMenuShiftUp(expanded_id,expanded_index,old_exp_height)	{
	if (expanded_index != item_id.length-1)	{
		window['shiftup_done']=false;
	}
	ex=$("#"+expanded_id).height();
	window['unexpand_done']=false;
	
	$("#"+expanded_id).animate({opacity: '0.0'},200,"easeOutCirc", function()	{ window['unexpand_done']=true;$("#"+expanded_id).remove();} );
	
	$('div').each(function(i) {
		if(i>expanded_index) {
			if($('#'+item_id[i]).offset()) {
				offset=$('#'+item_id[i]).offset().top;
			}
			
			$('#'+item_id[i]).animate({top: (offset - old_exp_height) + 'px' },50,"easeOutElastic", function()	{ window['shiftup_done']=true; }, {queue: false});
			
			if ($.browser.msie) {
				if (document.getElementById(item_id[i]+'_expanded')) {
					$('#'+item_id[i]+"_expanded").animate({top: ($('#'+item_id[i]+"_expanded").offset().top - old_exp_height) + 'px' },50,"easeInCirc", function()	{ window['shiftup_done']=true; });
				}
			}	
		}
	});
} // function fncMenuShiftUp
