// JavaScript Document
//Provides common functions to Campus Comunity Campaign '09
//Corey Wilkes '09

var FundHeight = 544;
var ParWidth = 474;
var HideWidth = 450;
var h = (CurFun/FunGoal)*FundHeight;
var w = ParWidth-((CurPar/ParGoal)*ParWidth);
var tempH = 0;
var tempW = ParWidth;
var r,o;

function SetValues(){
	for (var i=1;i<10;i+=1)
		returnObjById("Val"+i).innerHTML = "- $"+Math.round(FunGoal/9000*i)+",000&nbsp;";
	for(i=1;i<5;i+=1)
		returnObjById("Par"+i).innerHTML = Math.round(ParGoal/4*i)+"&nbsp;&nbsp;&nbsp;";
}

function FillOne(){
	tempH+=2;
	if (tempH<h && tempH<FundHeight)
		o=setTimeout("FillOne()",30);
	
	if (tempH>400){
		returnObjById("FillMid").style.display = 'inline';
		if (tempH>466){
			returnObjById("FillTop").style.display = 'inline';
			returnObjById("FillTop").height = tempH-466;}
		else returnObjById("FillMid").height = tempH-400;
	}
	else returnObjById("FillBot").height = tempH;
}

function MoveRunner(){
	if (w>HideWidth) return;
	tempW-=2;
	if (tempW>w && tempW>0)
		r=setTimeout("MoveRunner()",30);
	if (tempW<HideWidth)
		returnObjById('Hide').width=tempW;
	if (tempW<=0){
		returnObjById('Man').style.display='none';
	}
}


function returnObjById(id) {
// Returns an object by it's ID
    if (document.getElementById)
        var returnVar = document.getElementById(id);
    else if (document.all)
        var returnVar = document.all[id];
    else if (document.layers)
        var returnVar = document.layers[id];
    return returnVar;
}



//// Hiding and Displaying for WHO page.
function Show(Person) {
	Hide();
	returnObjById(Person).style.display='block';
	if (ScrDis()>430) location.href="#Pic";
}

function Hide() {
	var Divs = new Array();
	Divs = document.getElementsByTagName('div');
	for (i=0;i<Divs.length;i++) {
		if (Divs[i].className == "WhoBox") Divs[i].style.display='none';
	}
}

// Scroll Distance
function ScrDis() {
	var scrolled;
	if (document.documentElement && document.documentElement.scrollTop) { scrolled = document.documentElement.scrollTop; }
	else if (document.body) { scrolled = document.body.scrollTop; }
	else { scrolled = window.pageYOffset; }
	return scrolled;
}


function WebAdmin() {
	window.open("http://www.odu.edu/ao/development/dominionfund/webadmin.html?"+window.location);
}
