window.onresize = function() { history.go(0); preLoad();}

var available_height = 0, available_width = 0, thisBrowserIs = "", NNUoM = ""
var scrollDir = "up", scrollspeed = 10, scroll_y_pos = 0, scrollLoop = true
var menu_selection = "content", MenuAction = ""
var Vmenu_height, Vmenu_width = 150, Vmenu_Target = 0, Vmenu_Start = 0, VupSpeed = 1, VdownSpeed = 3, V_y_clip = 0
var imageGroup = new Array(), x_Array = new Array(), y_Array = new Array(), z_Array = new Array()
var aMonthNames = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
var aDayNames = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday");
var aBiscuitType = new Array("YELLOW","BLUE","RED","GREEN");
var aBkgd = new Array("#FEFDD0","#E3F2FC","#FEDADA","#DEFCD6");
var aLinkBkg = new Array("#DDD455","#6FA7C0","#AB1D13","#8C8C34");
var aHoverBkg = new Array("#c59022","#2b7396","#82210E","#52490E");
var aFontColor = new Array("#000","#fff","#fff","#fff");
var xBkgColor = "";
var xFontColor = "";
var SoyLentProduct = "";
var CurDate = new Date();
var CurYear = CurDate.getFullYear();                 
var DayName, MonthName, thisYear, thisDate, todaysDate, dateSuffix, CurHour, CurMinutes, CurrentTime;
var HourSuffix = "AM";
var CurDayPart = "";
var TimeStamp = "Saturday, the 12th of November, 1955";
DayName = aDayNames[CurDate.getDay()]
MonthName = aMonthNames[CurDate.getMonth()]
thisYear = CurDate.getFullYear()
thisDate = CurDate.getDate()
switch (thisDate) {
case 1:
dateSuffix="st"
break
case 21:
dateSuffix="st"
break
case 31:
dateSuffix="st"
break    
case 2:  
dateSuffix="nd"  
break    
case 22:
dateSuffix="nd"
break;   
case 3:
dateSuffix="rd"  
break     
case 23:
dateSuffix="rd"  
break      
default:   
dateSuffix="th"
}
todaysDate="Today is " + DayName + ", the " + thisDate + dateSuffix + " of " + MonthName + ", " + thisYear + "."
CurHour = CurDate.getHours()
if (CurHour < 12) {CurDayPart = "Good morning, my name is Bill Eytel."}
if (CurHour > 11) {HourSuffix="PM"}
if (CurHour >= 12) {
	CurDayPart = "Good afternoon, my name is Bill Eytel."
	if (CurHour > 16){CurDayPart = "Good evening, my name is Bill Eytel."}
	CurHour = CurHour - 12
}
if (CurHour == 24 || CurHour == 0) {CurHour = 12}
CurMinutes=CurDate.getMinutes()
if (CurMinutes<10) {CurMinutes = "0" + CurMinutes}

CurrentTime = CurHour + ":" + CurMinutes + " " + HourSuffix + "."
TimeStamp = todaysDate + "<br />You arrived here at " + CurrentTime	

SoyLentProduct = aBiscuitType[0];
if (DayName == "Monday" || DayName == "Friday") {
	SoyLentProduct = aBiscuitType[1];
}
if (DayName == "Wednesday" || DayName == "Saturday") {
	SoyLentProduct = aBiscuitType[2];
}
if (DayName == "Tuesday") {
	SoyLentProduct = aBiscuitType[3];
}

// Pre-Loading of images //
function preLoad() {
	checkDimensions()	
	positionObjects()
}
// End preLoad

// Begin checkDimensions function //
function checkDimensions () {
	if(typeof(window.innerWidth)=='number'){
		thisBrowserIs = "Non-IE";
		available_height = window.innerHeight;
		available_width = window.innerWidth;
		var agent = navigator.userAgent.toLowerCase();
		if ((agent.indexOf('mozilla')!=-1) && ((agent.indexOf('spoofer')==-1) && (agent.indexOf('compatible') == -1))){
			thisBrowserIs = "NN-Moz-FF";
			NNUoM = "px";
		}
	}
	else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)){
		thisBrowserIs = "IE-DOM"
		available_height = document.documentElement.clientHeight;
		available_width = document.documentElement.clientWidth;
	}
	else if(document.body && (document.body.clientWidth || document.body.clientHeight)){
		thisBrowserIs = "IE-Quirks";
		available_height = document.body.clientHeight;
		available_width = document.body.clientWidth;
	}
	
	V_mTopObj = getProperties("VmenuTop");
	V_mBodyObj = getProperties("VmenuBody");
	V_mTextObj = getProperties("VmenuText");
	V_mBottomObj = getProperties("VmenuBottom");
	V_mBodyObj.visibility = "visible";
	V_mTextObj.visibility = "visible";
	
	wSoylentObj = getProperties("Soylent");
	wBkgdImgObj = getProperties("BkgdImg");
	wFooterObj = getProperties("Footer");
	wBkgdImgObj.backgroundColor = aBkgd[0];
	wFooterObj.backgroundColor = aBkgd[0];
	wSoylentObj.backgroundColor = aLinkBkg[0];
	wSoylentObj.color = aFontColor[0];

	if (DayName == "Monday" || DayName == "Friday") {
		wBkgdImgObj.backgroundColor = aBkgd[1];
		wFooterObj.backgroundColor = aBkgd[1];
		wSoylentObj.backgroundColor = aLinkBkg[1];
		wSoylentObj.color = aFontColor[1];
	}
	if (DayName == "Wednesday" || DayName == "Saturday") {
		wBkgdImgObj.backgroundColor = aBkgd[2];
		wFooterObj.backgroundColor = aBkgd[2];
		wSoylentObj.backgroundColor = aLinkBkg[2];
		wSoylentObj.color = aFontColor[2];
	}
	if (DayName == "Tuesday") {
		wBkgdImgObj.backgroundColor = aBkgd[3];
		wFooterObj.backgroundColor = aBkgd[3];
		wSoylentObj.backgroundColor = aLinkBkg[3];
		wSoylentObj.color = aFontColor[3];
	}
}
// End checkDimensions 

// Begin positionObjects function.
function positionObjects() {
	Vmenu_height = available_height * .5
	V_mTopObj.height = 18 + NNUoM
	V_mTopObj.width = Vmenu_width + NNUoM
	V_mTopObj.top = 5 + NNUoM
	V_mTopObj.left = 5 + NNUoM
	V_mTopObj.visibility = "visible"
	
	V_mBodyObj.height = Vmenu_height + NNUoM
	V_mBodyObj.width = (Vmenu_width * .98) + NNUoM
	V_mBodyObj.top = 23 + NNUoM
	V_mBodyObj.left = 6 + NNUoM
	V_mBodyObj.visibility = "visible"
	
	V_mTextObj.height = (Vmenu_height * .96) + NNUoM
	V_mTextObj.width = (Vmenu_width * .88) + NNUoM
	V_mTextObj.top = 28 + NNUoM
	V_mTextObj.left = 12 + NNUoM
	V_mTextObj.visibility = "visible"
	
	V_mBottomObj.height = 19 + NNUoM
	V_mBottomObj.width = Vmenu_width + NNUoM
	V_mBottomObj.top = ((parseInt(V_mTopObj.top) + parseInt(V_mTopObj.height)) - 2) + NNUoM
	V_mBottomObj.left = parseInt(V_mTopObj.left) + NNUoM
	V_mBottomObj.margin = 0 +NNUoM
	V_mBottomObj.visibility = "visible"
	Vmenu_Start = parseInt(V_mBottomObj.top) - 2
	Vmenu_Target = Vmenu_Start + (Vmenu_height + 3)
	IWantTheMenuTo("Open")
}
// End of positionObjects function.

// Menu processing
function IWantTheMenuTo(doThis){
	action = doThis
	y_pos = parseInt(V_mBottomObj.top)
	moveTheVMenu(action)
}
function moveTheVMenu(doThis){
	var aniTimer = null
	MenuAction = doThis
	if(MenuAction == "Open"){
		y_pos = y_pos + VdownSpeed
		if(y_pos <= Vmenu_Target){
			V_mBottomObj.top = y_pos + NNUoM
			V_y_clip = V_y_clip + VdownSpeed
			clipThis(V_mBodyObj,0,Vmenu_width,V_y_clip,0)
			clipThis(V_mTextObj,0,Vmenu_width,V_y_clip,0)
			clearTimeout(aniTimer)
			aniTimer = setTimeout("moveTheVMenu(MenuAction)",5)
		}
	}
	if(MenuAction == "Close") {
		y_pos = y_pos - VupSpeed
		if(y_pos >= Vmenu_Start) {
			V_mBottomObj.top = y_pos + NNUoM
			V_y_clip = V_y_clip - VupSpeed
			clipThis(V_mBodyObj,0,Vmenu_width,V_y_clip,0)
			clipThis(V_mTextObj,0,Vmenu_width,V_y_clip,0)
			clearTimeout(aniTimer)
			aniTimer = setTimeout("moveTheVMenu(MenuAction)",5)
		}
	}
}

function clipThis(obj,t,r,b,l) {
		obj.clip = "rect("+t+"px "+r+"px "+b+"px "+l+"px)"
}
// End of menu animation.
// End of Menu processing

function onerror() {
document.location.href = "javascript:"
}

// Begin getProperties function
function getProperties(objName) {
	if (document.layers && document.layers[objName]){
		return document.layers[objName]
	}
	else if (document.all && document.all(objName)) {
		return document.all(objName).style
	}
	else if (document.getElementById && document.getElementById(objName)) {
		return document.getElementById(objName).style
    }
    else {
		return false
	}
}
// End getProperties function
