var current_pos = 0;
var bypass_slide = false;

var moving = {};

var load_is_complete = false;

var current_slide = "home";


function ShowArrow (name) {
	if(!load_is_complete) return false;
	
	
	var e = $('arrow_'+name);

	if (bypass_slide) {
		e.show();
		HideArrow.delay(1, e);
		return true;
	}
	
	if ( moving[name] ) return false;
	
	SetMoving(name, true);
	
	
	// fade in
	Effect.Appear(e, { duration: 0.4 });
	
	new Effect.Move( e, { x:-100, y:-20, duration: 0, mode: 'relative' });
	new Effect.Move( e, { x:100, y:20, duration: 0.2, mode: 'relative', delay:0.1 });
	
	
	// fade out after delay
	HideArrow.delay(1, e);
	
	// set moving var after hiding
	SetMoving.delay(1.5, name, false);
}

function HideArrow (e) {
	if (bypass_slide) {
		e.hide();
		return true;
	}
	
	Effect.Fade(e, { duration: 0.5 });
}

function SetMoving (name, ismoving) {
	moving[name] = ismoving;
}

function SetMainHeight (targ) {
	// set the container height to the height of the current section (unless it's home)
	var targ_h = $(targ).getHeight() + 40;
	
	if (targ_h < 500) targ_h = 800;
	
	$('container').setStyle({ height: targ_h + 'px' });
	
}



function GoTo (section) {
	var e = $('scroller');
	//						sectionW + padding
	var targ = -(section * (900 + 200));
	var title = menu_parts[section];
	
	
	
	
	// set the container height to the height of the current section (unless it's home)
	SetMainHeight(title);
	current_slide = title;
	
	
	new Effect.Move(e, { x:(targ - current_pos) , y: 0 , duration: 1,  transition: Effect.Transitions.sinoidal, queue: 'end'});
	
	current_pos = targ;
	
	
	
	// set menu
	for (x=0; x<menu_parts.length; x++) {
		var cur = $('menu_' + menu_parts[x]);
		if (x==section) {
			cur.addClassName('active');
		} else {
			cur.removeClassName('active');
		}
	}
	
	
		
}


function DoInit () {
	SetMainHeight(current_slide);
	
	load_is_complete = true;
}



document.observe("dom:loaded", function() { DoInit(); });