alert('Oops, this is embarrassing. We are still working out some of the kinks with fuzzDev. At this time, IE seams to dislike fuzzDev and fuzzDev dislikes IE. Please excuse some of these advanced bugs while I try to resolve the dispute.');

fuzzWindow = new Object();
fuzzWindow.windows = new Object();
fuzzWindow.windowStack = new Array();
fuzzWindow.nextIndex = 1;
fuzzWindow.currentFocusWindowId = -1;
fuzzWindow.desktopSize = new Array(760,560);
fuzzWindow.desktopPadding = new Array(20,20,20,20);
fuzzWindow.windowPadding = new Array(5,12,10,4);


fuzzWindow.createWindowId = function createWindowId(){
	var i = fuzzWindow.nextIndex;
	fuzzWindow.nextIndex++;
	return i;
}

fuzzWindow.updateFocus = function updateFocus(windowId, isNew){

	if(isNew && isNew === true) isNew = true;
	else isNew = false;
	
	// find the
	//var wDiv = document.getElementById("fuzz_window_"+windowId+"_div_id");
	var winObj = fuzzWindow.windows[windowId];

	// take it out of the window stack
	var sObj = fuzzWindow.windowStack.splice(winObj.stackIndex,1);
	// push it on the end
	//alert(fuzzWindow.windowStack);
	fuzzWindow.windowStack.push(sObj[0]);
	//alert(fuzzWindow.windowStack);
	// now go through the stack and set z-index and stack index
	
	//figure out fade step
	//60
	var fade = 50;
	var fadeStep = 0;
	if(fuzzWindow.windowStack.length>1) fadeStep = Math.floor((100-fade) / (fuzzWindow.windowStack.length - 1));
	for(var x = 0; x < fuzzWindow.windowStack.length; x++){
		var tId = fuzzWindow.windowStack[x];
		fuzzWindow.windows[tId].stackIndex = x;
		var wDiv = document.getElementById("fuzz_window_"+tId+"_div_id");
		var fDiv = document.getElementById("fuzz_window_"+tId+"_window_cover_div_id");

		wDiv.style.zIndex = x+1;
		if(windowId == tId){
			hideElement(fDiv);
			if(isNew) fuzzUtils.fadeInDiv(wDiv,0,100,20,400);
			else{
				fuzzUtils.fadeInDiv(wDiv,fuzzWindow.windows[tId].currentFade,100,20,400);
			}

			fuzzWindow.windows[tId].currentFade = 100;

		}
		else{
			showElement(fDiv);
			fuzzController.setOpacity(wDiv,fade);
			//fuzzUtils.fadeInDiv(wDiv,fuzzWindow.windows[tId].currentFade,fade,20,400);
			fuzzWindow.windows[tId].currentFade = fade;

			fade += fadeStep;
		}
		t = fuzzWindow.windows[tId];
		//alert(t.name+" "+tId + " = " + wDiv.id + " = zindex:" + wDiv.style.zIndex);
	}

	//dump(fuzzWindow.windowStack);

	// put the toolbar on top

	document.getElementById("fuzz_dock_contaner_div_id").style.zIndex = fuzzWindow.windowStack.length + 1;
	document.getElementById("fuzz-dock-icon-description-div-id").style.zIndex = fuzzWindow.windowStack.length + 2;

	fuzzWindow.currentFocusWindowId = windowId;

}

// returns the window id
fuzzWindow.closeWindow = function closeWindow(windowId,doFocusRefresh){
	// remove from windows and stackindex;

	if(doFocusRefresh && doFocusRefresh === true) doFocusRefresh = true;
	else doFocusRefresh = false;

	tObj = fuzzWindow.windows[windowId];
	
	delete fuzzWindow.windows[windowId];

	fuzzWindow.windowStack.splice(tObj.stackIndex,1);


	// now remove it from the dom
	var wDiv = document.getElementById("fuzz_window_"+windowId+"_div_id");
	wDiv.parentNode.removeChild(wDiv);

	// update the focus
	if(fuzzWindow.windowStack.length > 0 && doFocusRefresh) fuzzWindow.updateFocus(fuzzWindow.windowStack[fuzzWindow.windowStack.length - 1]);
}

// returns the window id
fuzzWindow.closeAll = function closeAll(){
	tArr = fuzzWindow.windowStack.slice(0);
	
	for(var x = 0; x < tArr.length; x++){
		//alert(tArr[x]);
		fuzzWindow.closeWindow(tArr[x],false);
	}
	document.getElementById("fuzz_dock_contaner_div_id").style.display = "none";
	document.getElementById("fuzz-dock-icon-description-div-id").style.display = "none";

	// reset all variables
	fuzzWindow.nextIndex = 1;
	fuzzWindow.currentFocusWindowId = -1;
	fuzzWindow.windows = new Object();
	fuzzWindow.windowStack = new Array();
}

fuzzWindow.fixPNG = function fixPNG(img){
	var arVersion = navigator.appVersion.split("MSIE");

	alert(arVersion);

	var imgName = img.src.toUpperCase();
	if (imgName.substring(imgName.length-3, imgName.length) == "PNG"){
		var imgID = (img.id) ? "id='" + img.id + "' " : ""
		var imgClass = (img.className) ? "class='" + img.className + "' " : ""
		var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
		var imgStyle = "display:inline-block;" + img.style.cssText
		if (img.align == "left") imgStyle = "float:left;" + imgStyle
		if (img.align == "right") imgStyle = "float:right;" + imgStyle
		if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
		var strNewHTML = "<span " + imgID + imgClass + imgTitle
		+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
		+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
		+ "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
		img.outerHTML = strNewHTML
		//i = i-1
	}
}

// returns the window id
fuzzWindow.loadWindow = function loadWindow(name, x , y, content, top, left){
	var tObj = new Object();
	tObj.name = name;
	tObj.x = x;
	tObj.y = y;
	tObj.content = content;
	tObj.currentFade = 0;
	tObj.stackIndex = fuzzWindow.windowStack.length;
	tObj.id = fuzzWindow.createWindowId();

	// see if we have the top && left
	if(! top || ! left){
		// put it in the middle of the screen;
		top = fuzzWindow.desktopPadding[0] + (fuzzWindow.desktopSize[1] / 2) - ((fuzzWindow.windowPadding[0] + fuzzWindow.windowPadding[2] + y) / 2);
		left = fuzzWindow.desktopPadding[3] + (fuzzWindow.desktopSize[0] / 2) - ((fuzzWindow.windowPadding[1] + fuzzWindow.windowPadding[3] + x) / 2);

	}


	tObj.top = top;
	tObj.left = left;


	fuzzWindow.windows[tObj.id] = tObj;
	fuzzWindow.windowStack.push(tObj.id);

	//fuzzWindow.updateWindowFocus();

	wFramePaddingX = 15;
	wFramePaddingY = 17;
	//top 5
	//left 4

	// create the window
	windowDiv = document.createElement('div');
	windowDiv.setAttribute('id', "fuzz_window_"+tObj.id+"_div_id");
	windowDiv.setAttribute('class', "fuzz-window");
	windowDiv.setAttribute('className', "fuzz-window");
	windowDiv.setAttribute('style', "height:"+(y+wFramePaddingY)+"px;width:"+(x+wFramePaddingX)+"px;top:"+top+"px;left:"+left+"px");

	// create the window frame
	topLeft = document.createElement('img');
	topLeft.setAttribute('class', "top-left");
	topLeft.setAttribute('className', "top-left");
	topLeft.setAttribute('src', "images/window/top-left.png");
	
	windowDiv.appendChild(topLeft);

	// create the window frame
	wTop = document.createElement('img');
	wTop.setAttribute('class', "top");
	wTop.setAttribute('className', "top");
	wTop.setAttribute('src', "images/window/top-fs8.png");
	wTop.setAttribute('style', "width:"+(x-45)+"px");
	
	windowDiv.appendChild(wTop);
//fuzzWindow.fixPNG(wTop);

	// create the window frame
	wBottom = document.createElement('img');
	wBottom.setAttribute('class', "bottom");
	wBottom.setAttribute('className', "bottom");
	wBottom.setAttribute('src', "images/window/bottom.png");
	wBottom.setAttribute('style', "width:"+(x-45)+"px");
	windowDiv.appendChild(wBottom);
	
		// create the window frame
	topRight = document.createElement('img');
	topRight.setAttribute('class', "top-right");
	topRight.setAttribute('className', "top-right");
	topRight.setAttribute('src', "images/window/top-right.png");
	windowDiv.appendChild(topRight);

	wLeft = document.createElement('img');
	wLeft.setAttribute('class', "left");
	wLeft.setAttribute('className', "left");
	wLeft.setAttribute('src', "images/window/left.png");
	wLeft.setAttribute('style', "height:"+(y-63)+"px")
	windowDiv.appendChild(wLeft);

	wRight = document.createElement('img');
	wRight.setAttribute('class', "right");
	wRight.setAttribute('className', "right");
	wRight.setAttribute('src', "images/window/right-fs8.png");
	wRight.setAttribute('style', "height:"+(y-63)+"px");
	wRight.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src=fig0902.png,sizingMethod='scale')";
	windowDiv.appendChild(wRight);

	bottomLeft = document.createElement('img');
	bottomLeft.setAttribute('class', "bottom-left");
	bottomLeft.setAttribute('className', "bottom-left");
	bottomLeft.setAttribute('src', "images/window/bottom-left.png");
	windowDiv.appendChild(bottomLeft);

	bottomRight = document.createElement('img');
	bottomRight.setAttribute('class', "bottom-right");
	bottomRight.setAttribute('className', "bottom-right");
	bottomRight.setAttribute('src', "images/window/bottom-right-fs8.png");
	windowDiv.appendChild(bottomRight);

	fCoverDiv = document.createElement('div');
	fCoverDiv.setAttribute('class', "frame-cover");
	fCoverDiv.setAttribute('className', "frame-cover");
	fCoverDiv.setAttribute('style', "height:"+(y+wFramePaddingY)+"px;width:"+(x+wFramePaddingX)+"px");
	windowDiv.appendChild(fCoverDiv);
	
	// create the window
	titleBarDiv = document.createElement('div');
	titleBarDiv.setAttribute('id', "fuzz_window_"+tObj.id+"_titlebar_div_id");
	titleBarDiv.setAttribute('class', "fuzz-window-titlebar");
	titleBarDiv.setAttribute('className', "fuzz-window-titlebar");
	titleBarDiv.onmousedown = new Function("event","fuzzWindow.handleTitleBarMouseDown('"+tObj.id+"',event)");
	titleBarDiv.onmouseup = new Function("fuzzWindow.handleTitleBarMouseUp('"+tObj.id+"')");
	titleBarDiv.setAttribute('style', "width:" + (x - 18) + "px");


	// create a close button
	cButtonDiv = document.createElement('img');
	cButtonDiv.setAttribute('id', "fuzz_window_"+tObj.id+"_close_div_id");
	cButtonDiv.setAttribute('class', "fuzz-window-close");
	cButtonDiv.setAttribute('src', "images/icons/close.png");
	cButtonDiv.onmouseover = new Function("fuzzController.handleImageSubmitOver('fuzz_window_"+tObj.id+"_close_div_id','fuzz_window_"+tObj.id+"_close_hover_div_id')");
	cButtonDiv.onmouseout = new Function("fuzzController.handleImageSubmitOut('fuzz_window_"+tObj.id+"_close_div_id','fuzz_window_"+tObj.id+"_close_hover_div_id')");
	cButtonDiv.onclick = new Function("fuzzWindow.closeWindow('"+tObj.id+"',true)");
	titleBarDiv.appendChild(cButtonDiv);

	// create a close button
	cButtonHoverDiv = document.createElement('img');
	cButtonHoverDiv.setAttribute('id', "fuzz_window_"+tObj.id+"_close_hover_div_id");
	cButtonHoverDiv.setAttribute('class', "fuzz-window-close-hover");
	cButtonHoverDiv.setAttribute('src', "images/icons/close-hover.png");
	cButtonHoverDiv.onmouseover = new Function("fuzzController.handleImageSubmitOver('fuzz_window_"+tObj.id+"_close_div_id','fuzz_window_"+tObj.id+"_close_hover_div_id')");
	cButtonHoverDiv.onmouseout = new Function("fuzzController.handleImageSubmitOut('fuzz_window_"+tObj.id+"_close_div_id','fuzz_window_"+tObj.id+"_close_hover_div_id')");
	cButtonHoverDiv.onclick = new Function("fuzzWindow.closeWindow('"+tObj.id+"',true)");
	titleBarDiv.appendChild(cButtonHoverDiv);

	// add description
	titleBarDescription = document.createElement('span');
	titleBarDescription.innerHTML = name;
	titleBarDiv.appendChild(titleBarDescription);

	windowDiv.appendChild(titleBarDiv);

	contentContainerDiv = document.createElement('div');
	contentContainerDiv.setAttribute('class', "fuzz-window-content-container");
	contentContainerDiv.setAttribute('className', "fuzz-window-content-container");
	contentContainerDiv.setAttribute('style', "height:"+(y-51)+"px;width:"+(x-39)+"px;");
	//contentContainerDiv.innerHTML = content;

	contentDiv = document.createElement('div');
	contentDiv.setAttribute('id', "fuzz_window_"+tObj.id+"_content_div_id");
	contentDiv.setAttribute('class', "fuzz-window-content");
	contentDiv.setAttribute('className', "fuzz-window-contnet");
	contentDiv.innerHTML = content;
	contentContainerDiv.appendChild(contentDiv);

	windowDiv.appendChild(contentContainerDiv);

	wCoverDiv = document.createElement('div');
	wCoverDiv.setAttribute('id', "fuzz_window_"+tObj.id+"_window_cover_div_id");
	wCoverDiv.setAttribute('class', "window-cover");
	wCoverDiv.setAttribute('className', "window-cover");
	wCoverDiv.setAttribute('style', "height:"+(y-24)+"px;width:"+(x+wFramePaddingX)+"px");
	wCoverDiv.onclick = new Function("fuzzWindow.updateFocus('"+tObj.id+"')");
	windowDiv.appendChild(wCoverDiv);

	//suggestDiv.setAttribute('onMouseOver', "fuzzForm.handleFloatingElementOver('"+suggestDivId+"')");
	//

	//suggestDiv.setAttribute('onMouseOut', "fuzzForm.handleFloatingElementOut('"+suggestDivId+"', event, true)");
	//suggestDiv.onmouseout = new Function("fuzzForm.handleFloatingElementOut('"+suggestDivId+"', event, true)");


	//onMouseOver="fuzzForm.handleFloatingElementOver('{$suggestDivId}'
	hifiDiv = document.getElementById("fuzz_hifi_container_id");
	hifiDiv.appendChild(windowDiv);

	fuzzUtils.setOpacity(windowDiv,0);
	
	//fuzzWindow.showWindow(tObj.id);

	fuzzWindow.updateFocus(tObj.id, true);
	return tObj.id;
}

fuzzWindow.handleTitleBarMouseDown = function handleTitleBarMouseDown(windowId,e){
	if(e && e.preventDefault) e.preventDefault();

	fuzzDock.isEnabled = false;
	// set the focus
	if(fuzzWindow.currentFocusWindowId != windowId) fuzzWindow.updateFocus(windowId);

	tDiv = document.getElementById("fuzz_window_"+windowId+"_titlebar_div_id");
	if(! tDiv) return false;
	tDiv.style.cursor = "move";
	window.onmousemove =  new Function("event","fuzzWindow.move('"+windowId+"',event)");
	window.onmouseup = new Function("fuzzWindow.handleTitleBarMouseUp('"+windowId+"')");
	// get the title bar
	return false;
}

fuzzWindow.handleTitleBarMouseUp = function handleTitleBarMouseUp(windowId){
	fuzzDock.isEnabled = true;
	var tDiv = document.getElementById("fuzz_window_"+windowId+"_titlebar_div_id");
	
	if(! tDiv) return false;
	tDiv.style.cursor = "default";
	window.onmousemove =  "";
	fuzzWindow.windows[windowId].lastMouseXY = false;
	return false;
}

fuzzWindow.move = function move(windowId,e){
	//try to get the window
	if(! fuzzWindow.windows[windowId]) return false;

	w = fuzzWindow.windows[windowId];

	// see if we have a lastMouseXY
	mPos = YAHOO.util.Event.getXY(e);

	if(w.lastMouseXY && w.lastMouseXY !== false){

		hifiDiv = document.getElementById("fuzz_hifi_container_id");
		hPos = YAHOO.util.Dom.getXY(hifiDiv);

		//alert('here');
		var xOffset = w.lastMouseXY[0] - mPos[0];
		var yOffset = w.lastMouseXY[1] - mPos[1];
		var wDiv = document.getElementById("fuzz_window_"+windowId+"_div_id");
		var wPos = YAHOO.util.Dom.getXY(wDiv);
		//var cPos = YAHOO.util.Dom.getXY(hifiDiv);

		wPos[0] -= xOffset;
		wPos[1] -= yOffset;

		var tPadding = 25;
		// make sure it is within the area
		if(wPos[0] < (hPos[0] + tPadding)) wPos[0] = hPos[0] + tPadding;
		if(wPos[1] < (hPos[1] + tPadding)) wPos[1] = hPos[1] + tPadding;

		hWidth = hifiDiv.clientWidth;
		hHeight = hifiDiv.clientHeight;
		wWidth = wDiv.clientWidth;
		wHeight = wDiv.clientHeight;

		// make sure it is within the area
		if((wPos[0] + wWidth) > (hPos[0] + hWidth + -tPadding)) wPos[0] = (hPos[0] + hWidth + - tPadding - wWidth);
		if((wPos[1] + wHeight) > (hPos[1] + hHeight + -tPadding)) wPos[1] = (hPos[1] + hHeight + - tPadding - wHeight);


		YAHOO.util.Dom.setXY(wDiv,wPos);
		
		
	}
	
	fuzzWindow.windows[windowId].lastMouseXY = mPos;
	
	return false;
}


fuzzTerminal = new Object();
fuzzTerminal.doClear = false;
fuzzTerminal.currentCommand = "";
fuzzTerminal.doStartMode = false;
fuzzTerminal.currentMode = "hifi";
fuzzTerminal.initMode = "";
fuzzTerminal.historyArr = new Array();

fuzzTerminal.handleKeypress = function handleKeypress(e){
	keyCode = getKeyCode(e);
	
	// if it is a return, we must send the currnt line
	if(keyCode == 13){
		fuzzTerminal.runCommand();
	}
	else if(keyCode == 32){
		fuzzTerminal.handleSpace();
	}
	else if(keyCode == 8){
		fuzzTerminal.handleBackspace();
	}
	else fuzzTerminal.updateCurrentCommand(keyCode);
}

fuzzTerminal.handleScroll = function handleScroll(){
	pDiv = document.getElementById("fuzz-term-current-pos-div-id");
	pTop = YAHOO.util.Dom.getY(pDiv);
	pHeight = pDiv.offsetHeight;

	vXY = getViewportXY();
	sXY = getScrollXY();
	vHeight = vXY[1];
	sHeight = sXY[1];


	// get the inner container height
	iDiv = document.getElementById("fuzz_term_inner_container_id");
	iHeight = iDiv.offsetHeight;

	// get the terminal height
	tDiv = document.getElementById("fuzz_term_id");
	tHeight = tDiv.offsetHeight;

	if(iHeight < tHeight){
		// scroll to top
		tDiv.style.top = iHeight - tHeight + "px";
	}
	else tDiv.style.top = 0;
	//alert("iHeight= "+iHeight+" term= "+tHeight);
	//iDiv = pDiv = document.getElementById("fuzz_term_inner_container_id");
	//iDiv.scrollTo(100,100);

	return;

	pPos = pTop + pHeight;


	// figure out if it is on screen
	cPos = vHeight+sHeight;

	if(cPos < pPos){
		scroll(0, pPos-vHeight);
	}
	else if(pPos < sHeight){
		scroll(0, sHeight-pPos);
	}
	
}

fuzzTerminal.handleBackspace = function handleBackspace(){
	currentCommand = fuzzTerminal.currentCommand;
	if(currentCommand.length > 0){
		currentCommand = currentCommand.substring(0,currentCommand.length - 1);
		fuzzTerminal.currentCommand = currentCommand;
		cDiv = document.getElementById("fuzz-term-current-command-div-id");
		cDiv.innerHTML = currentCommand.replace(" ","&nbsp;");
	}
}

fuzzTerminal.handleSpace = function handleSpace(){
	fuzzTerminal.currentCommand += " ";

	//fuzzTerminal.currentCommand = currentCommand;
	cDiv = document.getElementById("fuzz-term-current-command-div-id");
	cDiv.innerHTML = fuzzTerminal.currentCommand.replace(/ /g,"&nbsp;");
}

fuzzTerminal.runCommand = function runCommand(currentCommand){
	if(! currentCommand) currentCommand = fuzzTerminal.currentCommand;
	
	// get the current command div
	cDiv = document.getElementById("fuzz-term-current-command-div-id");
	cDiv.innerHTML = "";
	fuzzTerminal.currentCommand = "";
	if(currentCommand != ""){
		// add to history
		fuzzTerminal.historyArr.push(currentCommand);
	}

	// add last command line to output
	oDiv = document.getElementById("fuzz-term-output-div-id");
	oText = oDiv.innerHTML
	nText = "Please enter a command:<br />user@FUZZDEV:~$&nbsp;" + currentCommand.replace(/ /g,"&nbsp;") + "<br />";
	oText += nText  + "<br />";

	// get the command output
	cText = fuzzTerminal.getOutputByCommand(currentCommand);
	oText += cText;

	

	//oText += "<br />";

	if(fuzzTerminal.doClear){
		fuzzTerminal.doClear = false;
		oDiv.innerHTML = cText;
	}
	else oDiv.innerHTML = oText;

	fuzzTerminal.handleScroll();

	// see if we need to start HIFI mode
	if(fuzzTerminal.doStartMode){
		if(fuzzTerminal.initMode == ""){
			fuzzTerminal.doStartMode = false;
			fuzzTerminal.initMode = "";
			return;
		}

		hide("fuzz-term-command-container-div-id");
		// set timeout to show splash
		
		setTimeout("fuzzTerminal.showLoadingScreen('"+fuzzTerminal.initMode+"');",2000);
	}
	
}

fuzzTerminal.showLoadingScreen = function showLoadingScreen(mode){
	if(mode == "lofi"){
		fuzzWindow.closeAll();
	}
	hide("fuzz_term_container_id");
	show("fuzz_loading_screen_container_id");
	setTimeout("fuzzTerminal.loadMode('"+mode+"');",2000);
}

fuzzTerminal.loadMode = function loadMode(mode){
	optionsArr = new Object();
	optionsArr.doHideAll = true;
	fuzzController.displayContainer("content",mode,"",false,false,"fuzzTerminal.showMode()",optionsArr);

	fuzzTerminal.doStartMode = false;
	fuzzTerminal.currentMode = mode;
	fuzzTerminal.initMode = "";
}

fuzzTerminal.showMode = function showMode(){
	hide("fuzz_loading_screen_container_id");
	fuzzController.showContainer("content");
}



fuzzTerminal.getOutputByCommand = function getOutputByCommand(currentCommand){
	tCommand = trim(currentCommand.toLowerCase());
	var val = "";
	retStr = "";
	// see if it starts with fuzzdev
	//alert(tCommand.subString(0,7));

	if(tCommand && tCommand.length >=7){
		str = tCommand.substring(0,7);
	}

	if(tCommand && tCommand.length >=7 && tCommand.substring(0,7) == "fuzzdev"){
		retArr = new Array();
		// trying to use 'fuzzDev program'
		pStr = trim(tCommand.substring(7));

		// figure out what commands we are trying to run
		if(pStr == "") retStr = fuzzTerminal.getFuzzDevTextByCommand("help");
		else{
			paramArr = pStr.split("--");

			var wasInArray = false;
		
			for(var i = 1; i < paramArr.length; i++){
				wasInArray = true;
				val = trim(paramArr[i]);
				if(val == "clear"){
					fuzzTerminal.doClear = true;
					retStr = "";
				}
				else retStr += fuzzTerminal.getFuzzDevTextByCommand(val);

				if((i+1) < paramArr.length) retStr += "<br />";
			}

			if(! wasInArray){
				retStr += fuzzTerminal.getFuzzDevTextByCommand(pStr)
			}
		}

	}
	else if (tCommand == "") retStr = "Command not found. Please type <b>'fuzzDev --help'</b> for a list of valid fuzzDev commands.<br />";
	else retStr = "Command <b>'" + currentCommand + "'</b> not found. Please type <b>'fuzzDev --help'</b>' for a list of valid fuzzDev commands.<br />";
	
	retStr += "<br />";

	return retStr;
}

fuzzTerminal.getFuzzDevTextByCommand = function getFuzzDevTextByCommand(command,isRecursive){
	var retStr = "";
	switch(command){
		case "help": case "h": case "":
			retStr += "Welcome to <b>fuzzDev</b> Program 1.0. You are in LO-FI Mode<br /><br />";
			retStr += "<b>Help</b><br />";
			retStr += "To use <b>fuzzDev</b> Program please type '<b>fuzzDev</b>' followed by one or more of the following commands:<br />";
			retStr += "--help,--h: Help and command information.<br />";

			retStr += "--about,--a: About fuzzDev.<br />";
			retStr += "--services,--s: Our Services.<br />";
			retStr += "--technology,--t: Technology we use.<br />";
			retStr += "--rates,--r: Rate Information.<br />";
			retStr += "--portfolio,--p: Portfolio of fuzzDev work.<br />";
			retStr += "--contact,--c: Contact Us.<br />";
			retStr += "--clear: Clear terminal contents.<br />";
			retStr += "--hifi: Enter HIFI website mode.<br />";
			return retStr;
			
			break;
		case "about": case "a":
			if(fuzzTerminal.currentMode == "hifi"){
				fuzzWindow.loadWindow("About",500,400,document.getElementById("fuzzdev-about-div-id").innerHTML);
				return "Loading window: fuzzdev --"+command+"<br />";
			}
			else return document.getElementById("fuzzdev-about-div-id").innerHTML;
			break;
		case "services": case "s":
			if(fuzzTerminal.currentMode == "hifi"){
				fuzzWindow.loadWindow("Services",375,300,document.getElementById("fuzzdev-services-div-id").innerHTML);
				return "Loading window: fuzzdev --"+command+"<br />";
			}
			else return document.getElementById("fuzzdev-services-div-id").innerHTML;
			break;
		case "rates": case "r":
			if(fuzzTerminal.currentMode == "hifi"){
				fuzzWindow.loadWindow("Rates",400,250,document.getElementById("fuzzdev-rates-div-id").innerHTML);
				return "Loading window: fuzzdev --"+command+"<br />";
			}
			else return document.getElementById("fuzzdev-rates-div-id").innerHTML;
			break;
			break;
		case "portfolio": case "p":
			if(fuzzTerminal.currentMode == "hifi"){
				fuzzWindow.loadWindow("Portfolio",400,250,document.getElementById("fuzzdev-portfolio-div-id").innerHTML);
				return "Loading window: fuzzdev --"+command+"<br />";
			}
			else return document.getElementById("fuzzdev-portfolio-div-id").innerHTML;
			break;
		case "contact": case "c":
			if(fuzzTerminal.currentMode == "hifi"){
				fuzzWindow.loadWindow("Contact",300,200,document.getElementById("fuzzdev-contact-div-id").innerHTML);
				return "Loading window: fuzzdev --"+command+"<br />";
			}
			else return document.getElementById("fuzzdev-contact-div-id").innerHTML;
			break;
		case "hifi":
			fuzzTerminal.doStartMode = true;
			fuzzTerminal.initMode = "hifi"
			return "Loading fuzzDev Mode <b>HIFI</b>: Please wait...";
			break;
		case "lofi":
			fuzzTerminal.doStartMode = true;
			fuzzTerminal.initMode = "lofi"
			return "Loading fuzzDev Mode <b>LOFI</b>: Please wait...";
			break;
		case "technology": case "t":
			if(fuzzTerminal.currentMode == "hifi"){
				fuzzWindow.loadWindow("Technology",400,250,document.getElementById("fuzzdev-technology-div-id").innerHTML);
				return "Loading window: fuzzdev --"+command+"<br />";
			}
			else return document.getElementById("fuzzdev-technology-div-id").innerHTML;
			break;
		default:
			return "<b>" + command + ":</b> fuzzDev Error, Command not found. Please type <b>fuzzDev --help</b> for a list of valid fuzzDev commands.<br />";
			break;
	}
}

fuzzTerminal.updateCurrentCommand = function updateCurrentCommand(keyCode){

	keyChar = String.fromCharCode(keyCode);

	if(keyChar != ""){
		tCommand = fuzzTerminal.currentCommand;
		
		fuzzTerminal.currentCommand = fuzzTerminal.currentCommand + '' + keyChar;

		// get the current command div
		cDiv = document.getElementById("fuzz-term-current-command-div-id");

		cDiv.innerHTML = fuzzTerminal.currentCommand.replace(/ /g,"&nbsp;");

		cDiv.focus();
	}

}

fuzzDock = new Object();
fuzzDock.icons = new Object();
fuzzDock.currentIcon = -1;
fuzzDock.isEnabled = true;

fuzzDock.updateIcon = function updateIcon(iconId, isOver){

	if(! fuzzDock.icons[iconId]){
		fuzzDock.icons[iconId] = new Object();
	}
	if(isOver){
		if(fuzzDock.icons[iconId].timeout){
			clearTimeout(fuzzDock.icons[iconId].timeout);
		}
	} 
	fuzzDock.icons[iconId].isOver = isOver;
}

fuzzDock.updateCalendarDescription = function updateCalendarDescription(iconId){
	//show the description
	dDiv = document.getElementById("fuzz-dock-icon-"+iconId+"-description-div-id");
	// get the time / date
	var date = new Date();
	tHour = date.getHours();

	var g = "AM";
	if(tHour == 0){
		tHour = 12;
	}
	else if(tHour == 12){
		g = "PM";
	}
	else if(tHour > 12){
		g = "PM";
		tHour -= 12;
	}

	dDiv.innerHTML = date.getMonth()+"/"+date.getDate()+"/"+date.getFullYear() + " - " + tHour+":"+date.getMinutes()+" "+g;
	return true;
}

fuzzDock.handleMouseOver = function handleMouseOver(iconId){

	if(! fuzzDock.isEnabled) return;

	fuzzDock.currentIcon = iconId;
	//
	// see if it is already over, if so, return
	//if(fuzzDock.icons[iconId] && fuzzDock.icons[iconId].isOver) return;

	fuzzDock.updateIcon(iconId, true);

	//try the onHover
	//hightlight the icon
	//fn returns false if we should not continue
	hoverDiv = document.getElementById("fuzz-dock-icon-"+iconId+"-hover-div-id");
	if(hoverDiv.innerHTML != ""){
		if(eval(hoverDiv.innerHTML+"('"+iconId+"')") === false) return;
	}


	//hightlight the icon
	//hDiv = document.getElementById("fuzz-dock-icon-hover-div-id");
	
	imgDiv = document.getElementById("fuzz-dock-icon-"+iconId+"-img-div-id");
	// get the image
	imgSrc = document.getElementById("fuzz-dock-icon-"+iconId+"-image-div-id").innerHTML;

	imgDiv.src = "images/icons/icon-hover.png";
	imgDiv.style.backgroundImage = "url(../../"+imgSrc+")";

	//showElement(hDiv);
	//YAHOO.util.Dom.setXY(hDiv,iPos);

	//show the description
	dtDiv = document.getElementById("fuzz-dock-icon-"+iconId+"-description-div-id");
	dDiv = document.getElementById("fuzz-dock-icon-description-div-id");
	dDiv.innerHTML = dtDiv.innerHTML;
	
	showElement(dDiv);
	
	iWidth = 32;
	tDWidth = (dDiv.clientWidth / 2) - (iWidth / 2);

	iPos = YAHOO.util.Dom.getXY(imgDiv);
	iPos[0] -= tDWidth;
	iPos[1] += iWidth + 5;

	
	YAHOO.util.Dom.setXY(dDiv,iPos);


}

fuzzDock.handleMouseOut = function handleMouseOut(iconId){
	if(! fuzzDock.isEnabled) return;
	//hightlight the icon
	fuzzDock.updateIcon(iconId, false);
	//hDiv = document.getElementById("fuzz-dock-icon-hover-div-id");
	//hideElement(hDiv);
	fuzzDock.icons[iconId].timeout = setTimeout("fuzzDock.removeHover('"+iconId+"');");
}

fuzzDock.removeHover = function removeHover(iconId,force){
	if(force && force === true) force = true;
	else force = false
	//hightlight the icon
	//fuzzDock.updateIcon(iconId, false);
	//
	//alert(fuzzDock.icons[iconId].isOver);
	if(force || ! fuzzDock.icons[iconId].isOver){
		//hDiv = document.getElementById("fuzz-dock-icon-hover-div-id");
		//fuzzDock.icons[iconId].isHover = false;
		//hideElement(hDiv);
		imgDiv = document.getElementById("fuzz-dock-icon-"+iconId+"-img-div-id");
		// get the image
		imgSrc = document.getElementById("fuzz-dock-icon-"+iconId+"-image-div-id").innerHTML;

		imgDiv.src = imgSrc;
		imgDiv.style.backgroundImage = "";

		//hide description
		if(iconId == fuzzDock.currentIcon){
			dDiv = document.getElementById("fuzz-dock-icon-description-div-id");
			hideElement(dDiv);
		}
	}
}

