function checkEnterKey(keyPressed, boxId){
		
	if(keyPressed.which==13){
		document.getElementById('loginForm').submit();
		return true;
	}else{
		return false;
	}
}

function clearBox(boxId){
	boxId.type = 'text';
	boxId.value="";
	if (boxId.id == 'uname')
	{
		pwdBox = document.getElementById('passwd');
		pwdBox.innerHTML="<input id='pwd2' name='pwd' type='password' size='20' style='width: 150px; margin-left: 15px;' value='' onkeyup='checkEnterKey(event,this);' class='inputBoxes'/>";
//		document.getElementById('loginForm').elements['pwd2'].focus();
	}
}

function gotoClient(){
	document.getElementById('loginForm').elements['loginType'].value='client';
	document.getElementById('loginForm').elements['do'].value='logout';
	document.getElementById('loginForm').submit();
}

function gotoAdmin(){
	document.getElementById('loginForm').elements['loginType'].value='admin';
	document.getElementById('loginForm').elements['do'].value='logout';
	document.getElementById('loginForm').submit();
}
function gotoLogin(){
	document.getElementById('loginForm').elements['do'].value='login';
	document.getElementById('loginForm').action='login.asp';
	document.getElementById('loginForm').submit();
}
function gotoAdminLogin(){
	document.getElementById('loginForm').elements['do'].value='login';
	document.getElementById('loginForm').action='adminLogin.asp';
	document.getElementById('loginForm').submit();
}

function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

function validateRegistrationForm ()
{
	msg = "";
	
	if (trim(document.getElementById("NewUName").value) == "")
	{
		msg += "- Name\n";
	}
	if (trim(document.getElementById("NewPwd").value) == "")
	{
		msg += "- Password\n";
	}
	if (trim(document.getElementById("NewCompName").value) == "")
	{
		msg += "- Company Name\n";
	}
	if (trim(document.getElementById("Email").value) == "")
	{
		msg += "- Email Address\n";
	}
	if (document.getElementById("security_code").value == "")
	{
		msg += "- Security code\n";
	}
	if (msg)
	{
		alert ("Please correct the following:\n\n" + msg);
	}
	else
	{
		document.forms[0].submit();
	}
}

function validateEmailForm (form)
{
	msg = "";
	if (trim(document.getElementById("fullName").value) == "")
	{
		msg += "- Name\n";
	}
	if (trim(document.getElementById("emailAddress").value) == "")
	{
		msg += "- Email\n";
	}
	if (form == 1)
	{
		if (trim(document.getElementById("comments").value) == "")
		{
			msg += "- Message\n";
		}
	}
	else if (form == 2)
	{
		if (trim(document.getElementById("comments").value) == "")
		{
			msg += "- Project requirements\n";
		}
	}
	else if (form == 3)
	{
		if (trim(document.getElementById("comments").value) == "")
		{
			msg += "- Mailing address\n";
		}
	}
	else if (form == 4)
	{
		if (trim(document.getElementById("comments").value) == "")
		{
			msg += "- Please explain what you would like to discuss\n";
		}
	}
	if (document.getElementById("security_code").value == "")
	{
		msg += "- Security code\n";
	}
	if (msg)
	{
		alert ("Please correct the following:\n\n" + msg);
	}
	else
	{
		document.forms[1].submit();
	}
}

function UploadWait ()
{
	setTimeout ("UploadWaitNow()", 1000);
}

function UploadWaitNow ()
{
	document.getElementById("frm1").style.display = "none";
	document.getElementById("frm1_loading").style.display = "block";
}

function UpdateFTPUser (id)
{
	window.location = "?action=update_user&id=" + id + "&username=" + document.getElementById(id + "_username").value + "&password=" + document.getElementById(id + "_password").value + "&company=" + document.getElementById(id + "_company").value + "&email=" + document.getElementById(id + "_email").value;
}

function CreateFTPUser (id)
{
	window.location = "?action=create_user&username=" + document.getElementById(id + "_username").value + "&password=" + document.getElementById(id + "_password").value + "&status=" + document.getElementById(id + "_status").value + "&perms=" + document.getElementById(id + "_perms").value + "&company=" + document.getElementById(id + "_company").value + "&email=" + document.getElementById(id + "_email").value;
}

function updateFTPStatus (id, option)
{
	var conf = false;
	if (option == 1)
	{
		conf = confirm ("Would you like to also send a welcome email with FTP information to the user as well?");
	}

	if (conf)
	{
		window.location = "?action=update_status&send_mail=1&id=" + id + "&option=" + option;
	}
	else
	{
		window.location = "?action=update_status&send_mail=0&id=" + id + "&option=" + option;
	}
}

/*
	FTP Login
*/

var itemIdMaster;
var bottomval=0;

function showMenu(itemId, classNm){
    itemIdMaster = itemId;
	if (document.getElementById) {
       var nav_id = document.getElementById(itemId);
	   var menuFoot_id = document.getElementById(itemId+'_foot');
	   if (nav_id!=null){
	  		nav_id.className = classNm;
	   }
	   	   
	   if (menuFoot_id!=null){	
	     	menuFoot_id.className = 'orangeLower';
	   }
	   
	}
}

function isMouseLeaveOrEnter(e, handler)
{		
	if (e.type != 'mouseout' && e.type != 'mouseover') return false;
	var reltg = e.relatedTarget ? e.relatedTarget :
	e.type == 'mouseout' ? e.toElement : e.fromElement;
	while (reltg && reltg != handler) reltg = reltg.parentNode;
	return (reltg != handler);
}

function showQuickSubMenu(itemId){
	if (document.getElementById) {
       var nav_id = document.getElementById(itemId);
	   var nav_subId = document.getElementById(itemId+'Contents');
	   		if (nav_id!=null){								
	   			nav_id.className = 'subContainer show';
				maxHeight=nav_subId.offsetHeight - 1;
				bottomval=maxHeight;
				nav_subId.style.clip="rect(0px,146px,"+maxHeight+"px,0px)";	
	   		}
	  }
}

function showSubMenu(itemId){
	if(bottomval==1){
		bottomval = 0;
	}	
	 if (document.getElementById && bottomval==0) {
       var nav_id = document.getElementById(itemId);
	   var nav_subId = document.getElementById(itemId+'Contents');
	   		if (nav_id!=null){	
				nav_subId.style.clip="rect(0px,146px,0px,0px)";							
	   			nav_id.className = 'subContainer show';
				maxHeight=nav_subId.offsetHeight;
				openScrollMenu(""+itemId+'Contents'+"", maxHeight);	
	   		}
	  }
}

function openScrollMenu(subItem, maxHeight){
	var nav_subId = document.getElementById(subItem);
	if(bottomval<maxHeight && bottomval!=1){ 
		nav_subId.style.clip="rect(0px,146px,"+bottomval+"px,0px)";
		setTimeout("openScrollMenu('"+subItem+"',"+maxHeight+")",10);
		bottomval=bottomval+5;
	}
}

function hideSubMenu(itemId){
	bottomval = 1;	
	 if (document.getElementById) {
       var nav_id = document.getElementById(itemId);
	   var nav_subId = document.getElementById(itemId+'Contents');
	   		if (nav_id!=null){				
				nav_id.className = 'subContainer hide';
				nav_subId.style.clip="rect(0px,146px,0px,0px)";	   			
	   		}

	  }
}

function hoverMenu(itemId, classNm)
{
	if (document.getElementById && itemIdMaster!=itemId)
	{
		var nav_id = document.getElementById(itemId);
		if (nav_id!=null)
		{
			nav_id.className = classNm;
		}
	}
}