var expanded = new Array(4);
    
function Nav(page){
	location.replace(page);
}

function resetForms(formNumber, startField, endField) {
	var itemNumber = startField;
	while (itemNumber <= endField) {
				document.forms[formNumber].item(itemNumber).value = "";
				itemNumber++;
	}
}

function validateForm(_myForm, startField, endField) {
	var itemNumber = startField;
	while (itemNumber <= endField) {
		if (itemNumber == 4 || itemNumber == 6 || itemNumber == 13 || itemNumber == 17) {
			if (_myForm.item(itemNumber).value == "") {
					_myForm.item(itemNumber).value = " ";
			} 
		} else {
			if (_myForm.item(itemNumber).value == "") {
				alert("A required field is missing information.");
				_myForm.item(itemNumber).focus();
				return false;
			}
		}
		
		switch(itemNumber) {
			case 9:
				if (_myForm.item(itemNumber).value.length < 5) {
					alert("Your zip code is invalid.");
					_myForm.item(itemNumber).focus();
					return false;
				}
				break;
			case 10:
				if (_myForm.item(itemNumber).value.length < 3) {
					alert("Your telephone area code is invalid.");
					_myForm.item(itemNumber).focus();				
					return false;
				}
				break;
			case 11:
				if (_myForm.item(itemNumber).value.length < 3) {
					alert("Your telephone exchange is invalid.");
					_myForm.item(itemNumber).focus();
					return false;
				}
				break;
			case 12:
				if (_myForm.item(itemNumber).value.length < 4) {
					alert("Your telephone line is invalid.");
					_myForm.item(itemNumber).focus();
					return false;
				}
				break;
			case 14:
				if (_myForm.item(itemNumber).value.length < 3) {
					alert("Your telephone area code is invalid.");
					_myForm.item(itemNumber).focus();
					return false;
				}
				break;
			case 15:
				if (_myForm.item(itemNumber).value.length < 3) {
					alert("Your telephone exchange is invalid.");
					_myForm.item(itemNumber).focus();
					return false;
				}
				break;
			case 16:
				if (_myForm.item(itemNumber).value.length < 4) {
					alert("Your telephone line is invalid.");
					_myForm.item(itemNumber).focus();
					return false;
				}
				break;
			case 18:
				if (_myForm.item(itemNumber).value.indexOf("@") == -1) {
					alert("No '@' in address.");
					_myForm.item(itemNumber).focus();
					return false;
				} else {
					var adr = _myForm.item(itemNumber).value.split("@");
					if (adr[0].length < 1) {
						 alert("User addres absent.");
						 _myForm.item(itemNumber).focus();
						 return false;
					} else if (adr[1].indexOf(".") == -1) { 
						alert("No dot in address.");
						_myForm.item(itemNumber).focus();
						return false;
					} else if (adr[1].length < 3) {
						alert("Domain incorrect.");
						_myForm.item(itemNumber).focus();
						return false;
					}
				}
				break;
		}			
		itemNumber++;
	}
	return true;
}

function addParent(strName) {
    var strID; 
    var strTemp;
	var is_IE, is_NS;
	var myElement = document.getElementById("myLayer2Div");
	if (navigator.appName == "Microsoft Internet Explorer") {
		is_IE = true;
	} else {
		is_NS = true;
	}
	
    strID = "ID" + intCount;
    intCount++;

    if (is_IE) {
		strTemp = '<DIV ID="' + strID + '" CLASS="parent"><IMG CLASS="image" SRC="images/blue.gif" ALT="*" ALIGN=MIDDLE BORDER=0 WIDTH=11 HEIGHT=11>' + strName + '<DIV CLASS="child" STYLE="display:none"></DIV></DIV>';
		outlineDiv.insertAdjacentHTML("BeforeEnd", strTemp);
	} else {
		strTemp = '<DIV ID="' + strID + '" CLASS="parent"><IMG CLASS="image" SRC="images/blue.gif" ALT="*" ALIGN=MIDDLE BORDER=0 WIDTH=11 HEIGHT=11>' + strName + '<DIV CLASS="child" STYLE="display:hidden;display:none;">TEST</DIV></DIV>';
		myElement.innerHTML = strTemp;
	}
    return strID;
}

function addChild(strParentID, strName, strUrl) {
    var strTemp;
    var objTemp;
	var is_IE, is_NS;
	var myElement = document.getElementById("myLayer2Div");
	if (navigator.appName == "Microsoft Internet Explorer") {
		is_IE = true;
	} else {
		is_NS = true;
	}
	
    strTemp = '&nbsp;&nbsp;&nbsp;&nbsp;<A HREF="' + strUrl + '" CLASS="link">' + strName + '</A><BR>';

    objTemp = document.all.item(strParentID);
    if (is_IE) {
		objTemp.children(1).insertAdjacentHTML("BeforeEnd", strTemp);
	} else {
		myElement.children(1).innerHTML = objTemp;
	}
}

function doClick(iSection) {
    var sID = window.event.srcElement.id;
    if (expanded[sID.substring(2)] == "yes") {
		return;
	} else {
		expanded[sID.substring(2)] = "yes";
	}    
	
    if (window.event.srcElement.className == "parent" || window.event.srcElement.className == "image") {
	   expandCollapse();
	}
	
	var topPosition, gapPosition;
	var is_IE, is_NS;
	if (navigator.appName == "Microsoft Internet Explorer") {
		is_IE = true;
	} else {
		is_NS = true;
	}
	
	if (is_IE) {
		topPosition = document.getElementById("companyLogo").offsetHeight + document.getElementById("myLayer2Div").offsetHeight + 30;
	} else {
		topPosition = document.getElementById("myLayerMarkerDiv").offsetTop + 120;
		if (topPosition < (document.getElementById("companyLogo").offsetHeight + document.getElementById("myLayer2Div").offsetHeight))
			topPosition = document.getElementById("companyLogo").offsetHeight + document.getElementById("myLayer2Div").offsetHeight;
	}
	
	if (topPosition > document.getElementById("myLayer1Div").offsetHeight && is_IE) {	
		gapPosition = document.getElementById("myLayer2Div").offsetHeight - document.getElementById("myLayer1Div").offsetHeight;
	} else {
		gapPosition = document.getElementById("myLayerMarkerDiv").offsetTop - (document.getElementById("myLayer1Div").offsetTop + document.getElementById("myLayer1Div").offsetHeight - 120);
	}
	gapPosition += 30;
	
	if (topPosition > (document.getElementById("myLayer1Div").offsetHeight + document.getElementById("companyLogo").offsetHeight)) {
		document.getElementById("myLayer4Div").style.top = document.getElementById("companyLogo").offsetHeight + document.getElementById("myLayer1Div").offsetHeight;
		document.getElementById("myLayer4Div").style.height = gapPosition;
	}
	document.getElementById("myLayer3Div").style.top = topPosition;	
	window.event.cancelBubble = true;
}

function expandCollapse() {
    var objElement;
	var objTargetDiv;
	var imgIcon;

	objElement = window.event.srcElement;

    //did the user click the image or the parent name?
    if (objElement.className == "parent") {
        objTargetDiv = objElement.children(1);
        imgIcon = objElement.children(0);
    } else {
        objTargetDiv = objElement.parentElement.children(1);
        imgIcon = objElement;
    }
    
    //if the parent has children, expand or collapse them
    if (objTargetDiv.children.length > 0) {
		if (objTargetDiv.style.display == "none") {
			objTargetDiv.style.display = "";
			imgIcon.src = "images/red.gif";
		} else {
			objTargetDiv.style.display = "none";
            imgIcon.src = "images/blue.gif";
		}
	}
}

function doMouseOver() {
	if (window.event.srcElement.tagName == "A") {
        oldColor = window.event.srcElement.style.color;
        window.event.srcElement.style.color = "red";
    }
    window.event.cancelBubble = true;
}

function doMouseOut() {
    if (window.event.srcElement.tagName == "A") {
        window.event.srcElement.style.color = oldColor;
    }
    window.event.cancelBubble = true;
}

function buildMenus() {
	var topPosition, gapPosition;
	var is_IE, is_NS;
	if (navigator.appName == "Microsoft Internet Explorer") {
		is_IE = true;
	} else {
		is_NS = true;
	}
		
	if (is_IE) {
		topPosition = document.getElementById("companyLogo").offsetHeight + document.getElementById("myLayer2Div").offsetHeight + 30;
	} else {
		topPosition = document.getElementById("myLayerMarkerDiv").offsetTop + 120;
		if (topPosition < (document.getElementById("companyLogo").offsetHeight + document.getElementById("myLayer2Div").offsetHeight))
			topPosition = document.getElementById("companyLogo").offsetHeight + document.getElementById("myLayer2Div").offsetHeight;
	}
	
	if (topPosition > document.getElementById("myLayer1Div").offsetHeight && is_IE) {	
		gapPosition = document.getElementById("myLayer2Div").offsetHeight - document.getElementById("myLayer1Div").offsetHeight;
	} else {
		gapPosition = document.getElementById("myLayerMarkerDiv").offsetTop - (document.getElementById("myLayer1Div").offsetTop + document.getElementById("myLayer1Div").offsetHeight - 120);
	}
	gapPosition += 30;
	
	if (topPosition > (document.getElementById("myLayer1Div").offsetHeight + document.getElementById("companyLogo").offsetHeight)) {
		document.write("<div id=\"myLayer4Div\">");
		document.write("");
		document.write("</div>");
		document.getElementById("myLayer4Div").style.top = document.getElementById("companyLogo").offsetHeight + document.getElementById("myLayer1Div").offsetHeight;
		document.getElementById("myLayer4Div").style.height = gapPosition;
	}
	document.getElementById("myLayer3Div").style.top = topPosition;
}

function servicesMenu() {
	var myElement = document.getElementById("myLayer2Div");
	var text = '<table cellSpacing="0" cellPadding="10"><tr><td width="448" valign="top">';
	text += '<P align=justify><font class="headerBlue">Services&nbsp;</font><br>';
	text += '<font class="dashes">- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -</font><br>';
	text += '<div id="myDivA" class="expand" style="position:relative;left:0px;top:0px;height:25px;cusor:hand;cursor:pointer;" onclick="expandCollapse(\'myDiv\', \'A\');">';
	text += '<img class="image" SRC="images/blue.gif" WIDTH="11" HEIGHT="11">Click here to test this script.';
	text += '<div id="myDiv" style="position:relative;left:0px;top:0px;height:25px;visibility:hidden;background:white;">';
	text += '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
	text += '<a href="javascript:doNuhn();">Click here to hide it again</a>.<BR>';
	text += '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
	text += '<a href="javascript:doNuhn();">Click here to hide it again</a>.';
	text += '</div>';
	text += '</div>';
	text += '<font class="paragraph"></font>';
	text += '<font class="dashes">- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -</font><br>';
	text += '<font class="paragraph"><p align="justify"></p></FONT></FONT></td><td width="201" valign="top">&nbsp;</td>';
	text += '</tr></table>';
	myElement.innerHTML = text;
}

function addNSParent(strName, divLayer) {
    var strID; 
    var strTemp;
	var is_IE, is_NS;
	var myElement = document.getElementById(divLayer);
		
    strID = "ID" + intCount;
    intCount++;

    if(divLayer != "myLayerMarkerDiv"){
		strTemp = '<DIV ID="' + strID + '" CLASS="parent"><IMG CLASS="image" SRC="images/blue.gif" ALT="*" ALIGN=MIDDLE BORDER=0 WIDTH=11 HEIGHT=11>' + strName + '<br>';
    } else {
		topPosition = document.getElementById("myLayerMarkerDiv").offsetTop + 120;
		if (topPosition < (document.getElementById("companyLogo").offsetHeight + document.getElementById("myLayer2Div").offsetHeight))
			topPosition = document.getElementById("companyLogo").offsetHeight + document.getElementById("myLayer2Div").offsetHeight;
		
	gapPosition = document.getElementById("myLayerMarkerDiv").offsetTop - (document.getElementById("myLayer1Div").offsetTop + document.getElementById("myLayer1Div").offsetHeight - 120);
	gapPosition += 30;
	
	if (topPosition > (document.getElementById("myLayer1Div").offsetHeight + document.getElementById("companyLogo").offsetHeight)) {
		document.getElementById("myLayer4Div").style.top = document.getElementById("companyLogo").offsetHeight + document.getElementById("myLayer1Div").offsetHeight;
		document.getElementById("myLayer4Div").style.height = gapPosition;
	}

		document.getElementById("myLayer3Div").style.top = topPosition;	
		window.event.cancelBubble = true;	
	}
    
    if (divLayer == "outlineDiv1") {
        strTemp += '&nbsp;&nbsp;&nbsp;&nbsp;<A HREF="services/automation.asp?service=Automation" CLASS="link">Automation</A><BR>';
        strTemp += '&nbsp;&nbsp;&nbsp;&nbsp;<A HREF="services/projplan.asp?service=Project%20Planning" CLASS="link">Project Planning</A><BR>';
        strTemp += '&nbsp;&nbsp;&nbsp;&nbsp;<A HREF="services/techstrat.asp?service=Technology%20Strategy" CLASS="link">Technology Strategy</A><BR>';
        strTemp += '&nbsp;&nbsp;&nbsp;&nbsp;<A HREF="services/changemanage.asp?service=Change%20Management" CLASS="link">Change Management</A><BR>';
    }
    
    if (divLayer == "outlineDiv2") {
        strTemp += '&nbsp;&nbsp;&nbsp;&nbsp;<A HREF="services/ebiztechstrat.asp?service=Technology%20Strategy%20and%20Planning" CLASS="link">Technology Strategy and Planning</A><BR>';
        strTemp += '&nbsp;&nbsp;&nbsp;&nbsp;<A HREF="services/ebizsoftdev.asp?service=Software%20and%20Application%20Development" CLASS="link">Software and Application Development</A><BR>';
        strTemp += '&nbsp;&nbsp;&nbsp;&nbsp;<A HREF="services/ebizwebdev.asp?service=Web%20Application%20Strategy,%20Design,%20and%20Development" CLASS="link">Web Application Strategy, Design, and Development</A><BR>';
    }
    
    if (divLayer == "outlineDiv3") {
        strTemp += '&nbsp;&nbsp;&nbsp;&nbsp;<A HREF="services/entsysint.asp?service=Systems%20Integration" CLASS="link">Systems Integration</A><BR>';
        strTemp += '&nbsp;&nbsp;&nbsp;&nbsp;<A HREF="services/entarchitecture.asp?service=Enterprise%20Architecture" CLASS="link">Enterprise Architecture</A><BR>';
        strTemp += '&nbsp;&nbsp;&nbsp;&nbsp;<A HREF="services/entsysmanage.asp?service=Systems%20Management" CLASS="link">Systems Management</A><BR>';
        strTemp += '&nbsp;&nbsp;&nbsp;&nbsp;<A HREF="services/enttechstrat.asp?service=Technology%20Strategy%20and%20Planning" CLASS="link">Technology Strategy and Planning</A><BR>';
        strTemp += '&nbsp;&nbsp;&nbsp;&nbsp;<A HREF="services/entsecurity.asp?service=Security%20Design%20and%20Implementation" CLASS="link">Security Design and Implementation</A><BR>';
        strTemp += '&nbsp;&nbsp;&nbsp;&nbsp;<A HREF="services/entsoftdev.asp?service=Software%20and%20Application%20Development" CLASS="link">Software and Application Development</A><BR>';
        strTemp += '&nbsp;&nbsp;&nbsp;&nbsp;<A HREF="services/entsupportmaint.asp?service=Post%20Implementation%20Support%20and%20Maintenance" CLASS="link">Post Implementation Support and Maintenance</A><BR>';
    }
    
    if (divLayer == "outlineDiv4") {
        strTemp += '&nbsp;&nbsp;&nbsp;&nbsp;<A HREF="services/itdatamanage.asp?service=Data%20Management" CLASS="link">Data Management</A><BR>';
        strTemp += '&nbsp;&nbsp;&nbsp;&nbsp;<A HREF="services/itsysmanage.asp?service=System%20Management" CLASS="link">System Management</A><BR>';
        strTemp += '&nbsp;&nbsp;&nbsp;&nbsp;<A HREF="services/itsysdocs.asp?service=System%20Documentation" CLASS="link">System Documentation</A><BR>';
    }
    myElement.innerHTML = strTemp;
    return strID;
}

function createCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name)
{
	createCookie(name,"",-1);
}
