// JavaScript Document
var initTopBound; //topBound in the scrolling window div.
var initBottomBound;
var topElement;
var bottomElement;
var checkposID;
var easeDownTruth;
var easeUpTruth;
var dodown;
var dosup;

function toggle(obj) {
	var el = document.getElementById(obj);
	el.style.display = (el.style.display != 'none' ? 'none' : '' );}

function testPos(elem){
	var el = document.getElementById(elem);
	return getpos(el).y
}

function initBounds(top, bottom){
	var t = document.getElementById(top);
	//var b = document.getElementById(top);
	topElement = top;
	bottomElement = bottom;
	initTopBound = getpos(t).y;
	//initBottomBound = getpos(b).y;
	//alert("initBottomBound ="+initBottomBound);//we'll have to sort out the actual size of that feller.
}

function scrollup(elem){
	//elem_handle = document.getElementById('window_content_1');
	//topval= elem_handle.style.top;
	//alert("testPos(topElement) = "+testPos(topElement));
	if(testPos(bottomElement) <= 520){
		clearInterval(dosup);
		easeUpTruth = false;
	}else{
		obj_up = new Effect.MoveBy( 'window_content_1', -2, 0 , {duration: 0, fps: 51});
	}
}

function scrolldown(elem){
	if(testPos(topElement) >= initTopBound+3){
		clearInterval(dodown);
		easeDownTruth = false;
	}else{
		obj_down = new Effect.MoveBy( 'window_content_1', +2, 0 , {duration: 0, fps: 51});}
	}
/*
function easeup(elem){
	if(easeUpTruth == true){
		obju_ease = new Effect.MoveBy( elem, -6, 0 , {duration: 0.1, fps: 51});
	}else{
		easeUpTruth = true;
	}
}

function easedown(elem){
	if(easeDownTruth == true){
		objd_ease = new Effect.MoveBy( elem, +6, 0 , {duration: 0.1, fps: 51});
	}else{
		easeDownTruth = true;
	}
}
*/

var box1Slid = false;
var box2Slid = false;

function slide(elem){
	if(elem == 'sideBox1'){
		if(box1Slid == false){
			slidedown(elem);
			box1Slid = true;
		}else{
			slideup(elem);
			box1Slid = false;
		}
	}else if(elem == 'sideBox2'){
		if(box2Slid == false){
			slidedown(elem);
			box2Slid = true;
		}else{
			slideup(elem);
			box2Slid = false;
		}
	}
}

function slidedown(elem){
	myel = document.getElementById(elem);
	myel.style.opacity = 0;
	myel.style.filter = 'alpha(opacity=' + 0 + ')';
	toggle(elem);
	new Effect.BlindDown(elem, {duration: 1, fps: 50});
	new Effect.Appear(elem, {duration: 1, fps: 50});
	/*myel.style.opacity = 10;
	myel.style.filter = 'alpha(opacity=' + 100 + ')';*/
}

function slideup(elem){
	new Effect.BlindUp(elem, {duration: .5, fps: 50});
	new Effect.Opacity(elem, {duration: .5, from:3, to:0, fps: 50});
}

//>>>>>>>>>>>>>>>> Start subnavigation color setting code:<<<<<<<<<<<
var subArray = [];

function addElementToSubArray(elem){
	var present = false; //element is by default not in the array;
	for(var i=0;i<subArray.length;i++){
		if(subArray[i] == elem){
			present = true;
		}
	}
	if(present == false){
		subArray.push(elem);
	}
}

function clearPreviousSelection(){
	for(var i=0;i<subArray.length;i++){
		resetColor(subArray[i]);
	}
}

function resetColor(elem){
	elem.style.color = '#F4C204';
}

function colorElement(elem){
	var elementToColor = document.getElementById(elem);
	clearPreviousSelection();
	addElementToSubArray(elementToColor);
	elementToColor.style.color = '#f37736';
}
//>>>>>>>>>>>>>End subnavigation color setting code<<<<<<<<<<<<<<<<