var tabTop=0;
var theHeight=0;
var theDir=0;


function init(){
	var theElm=$('menu_botTab');
	var defaultTop = 422;
	
	theHeight=theElm.getHeight();
	
	newTop=defaultTop-theHeight;
	
	//consoleDump('The height of the div is ' + theHeight + 'px');
	//consoleDump('The old top of the dic is ' + theElm.getStyle('top'));
	
	theElm.setStyle({top:newTop+'px'});
	
	tabTop=newTop;
	
	//consoleDump('The new top of the div is ' + theElm.getStyle('top'));
	
	var sPath = window.location.pathname;
	var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
	/* automatic animation on project page
	if (sPage.length!=0 && sPage=="project.cfm"){
		toggleTab('toggleTabLink','REGISTER FOR<br />eNEWSLETTER','321 eNEWSLETTER<br />&nbsp;');
	}*/
	
}

function toggleTab(elm,defaultText,alternateText){
	var theElm=$('menu_botTab');
	var theAmount=0;
	var repText;
	if (!theDir){
		theAmount=theHeight-55;
		theDir=1;
		repText=alternateText;
	}else{
		theAmount=-(theHeight-55);
		theDir=0;		
		repText=defaultText;
	}
	// afterFInish updates the calling link
	new Effect.Move (theElm,{ y: theAmount, mode: 'relative', duration:.5,afterFinish:function(){if(repText.length){$(elm).update(repText);}}});
	//consoleDump('The var top of is ' + tabTop);
	//consoleDump('The current top of the div is ' + theElm.getStyle('top'));
}

function initHome(){
	toggleTab('toggleTabLink','REGISTER FOR<br />eNEWSLETTER','321 eNEWSLETTER<br />&nbsp;');
	Element.setOpacity('tabOne', 0);
	$('tabOne').show();
	new Effect.Opacity('tabOne',{duration:.5, from:0, to:1});
}
function initRetail(){
	toggleTab('toggleTabLink','Retail Quick Facts','Retail Quick Facts');
}
function initSubMenu(){
	toggleTab('','','');
}
function initOffice(){
	toggleTab('toggleTabLink','Office Quick Facts','Office Quick Facts');
}
// Console Dump Functions
function consoleDump(text){
	if(window.console) {
		window.console.log(text);
	}
}
/*
*
*	function showHide(theShowElem,theHideElem)
*
*	@theShowElem	The Element you want to display
*	@theHideElem	The Element(s) you want to hide - accepts lists
*
*/
function showHide(theShowElem,theHideElem){
	var theElems=theHideElem.split(',');
	// Show the Element
	//consoleDump(theShowElem);
	Element.setOpacity(theShowElem, 0);
	$(theShowElem).show();
	new Effect.Opacity(theShowElem,{duration:.5, from:0, to:1});
	// Hide Other Elements
	for (i=0;i<theElems.length;i++){
		//consoleDump(theElems[i])
		$(theElems[i]).hide();
	}
}
/*
**********************************
WINDOW OBJECT VARIABLES
**********************************
*/
	var WindowObjectReference = null; // global variable
	var PreviousUrl;	
/*
*	function openWin (Opens a centered window object)
*
*	@url = URL String (Required)
*	@win = Window Name (Required)
*	@myWidth = Window Width (Required)
*	@myHeight = Window Height (Required)
*	@scrollBars = Yes/No Value (Required)		
*/
function openWin(url,win,myWidth,myHeight,scrollBars){
	var tHeight=screen.height/2;
	var tWidth=screen.width/2;
	var top=tHeight-myHeight/2;
	var left=tWidth-myWidth/2;
	var Feats="width="+myWidth+",height="+myHeight+",top="+top+",left="+left+", screenY=" +top+",screenX="+left+",scrollbars="+scrollBars+", toolbar=no, status=yes, resizable=yes,alwayRaised=yes";
	if(WindowObjectReference == null || WindowObjectReference.closed)
		{
			WindowObjectReference=window.open(url,win,Feats);
			WindowObjectReference.focus();
		}
		else if(previousUrl !=url)
		{
			WindowObjectReference=window.open(url,win,Feats);
			WindowObjectReference.focus();
		}
		else
		{
			WindowObjectReference.focus();
		}
	previousUrl=url;
}
window.onload=init;
