function hide(y)
{
	for (i=0; i<y; ++i)
	{
		el = "panel"+i;
  		document.getElementById(el).style.display = 'none';
	}
}

function show(x,y)
{
		hide(y);
		el = "panel"+x;
  		document.getElementById(el).style.display = 'block';
}

var disappearSet = 0;
var moveBy = 2;
var openMenu = "";

function showSubNav(id,num)
{
	el = document.getElementById(id);
	fullHeight = (num*20)+2
	
			el.style.height = "0";
			el.style.display = 'block';
			var intID = function() {
				var curHeight = el.offsetHeight;
				var newHeight = curHeight + moveBy;
				if (newHeight <= fullHeight)
				{
					el.style.height = newHeight + "px";
				}
				else {
					clearInterval(intTimer);
				}
			}
			
			intTimer = setInterval(intID, 15);
			
			//document.getElementById(id).style.height = fullHeight+"px";
			//document.getElementById(id).style.display = 'block';	
}


var subNav = new Array('servicesNav','careersNav');

var disappearSet = 0;

function showSubNav2(id)
{
	hideSubNav2();
	if(disappearSet == 1)
	{
		clearTimeout(disappear);
	}
	document.getElementById(id).style.display = "block";
}


function hideSubNav2()
{		
	for (i=0; i<subNav.length; ++i)
	{
		document.getElementById(subNav[i]).style.display = 'none';
	}
}

function stay2()
{
	clearTimeout(disappear);
}

function leave2()
{
	disappear = setTimeout("hideSubNav2()",1500);
	disappearSet = 1;
}

var subNav3 = new Array('charterNav','fjcServicesNav');

var disappearSet = 0;

function showSubNav3(id)
{
	hideSubNav3();
	if(disappearSet == 1)
	{
		clearTimeout(disappear);
	}
	document.getElementById(id).style.display = "block";
}


function hideSubNav3()
{		
	for (i=0; i<subNav3.length; ++i)
	{
		document.getElementById(subNav3[i]).style.display = 'none';
	}
}

function stay3()
{
	clearTimeout(disappear);
}

function leave3()
{
	disappear = setTimeout("hideSubNav3()",1500);
	disappearSet = 1;
}

var subNav4 = new Array('servicesNav','fjcServicesNav');

var disappearSet = 0;

function showSubNav4(id)
{
	hideSubNav4();
	if(disappearSet == 1)
	{
		clearTimeout(disappear);
	}
	document.getElementById(id).style.display = "block";
}

function hideSubNav4()
{		
	for (i=0; i<subNav4.length; ++i)
	{
		document.getElementById(subNav4[i]).style.display = 'none';
	}
}

function stay4()
{
	clearTimeout(disappear);
}

function leave4()
{
	disappear = setTimeout("hideSubNav4()",1500);
	disappearSet = 1;
}

var subNav5 = new Array('capabilitiesNav','fjcServicesNav');

var disappearSet = 0;

function showSubNav5(id)
{
	hideSubNav5();
	if(disappearSet == 1)
	{
		clearTimeout(disappear);
	}
	document.getElementById(id).style.display = "block";
}

function hideSubNav5()
{		
	for (i=0; i<subNav5.length; ++i)
	{
		document.getElementById(subNav5[i]).style.display = 'none';
	}
}

function stay5()
{
	clearTimeout(disappear);
}

function leave5()
{
	disappear = setTimeout("hideSubNav5()",1500);
	disappearSet = 1;
}

var subNav6 = new Array('courseNav','fleetNav','promosNav','fjcServicesNav');

var disappearSet = 0;

function showSubNav6(id)
{
	hideSubNav6();
	if(disappearSet == 1)
	{
		clearTimeout(disappear);
	}
	document.getElementById(id).style.display = "block";
}

function hideSubNav6()
{		
	for (i=0; i<subNav6.length; ++i)
	{
		document.getElementById(subNav6[i]).style.display = 'none';
	}
}

function stay6()
{
	clearTimeout(disappear);
}

function leave6()
{
	disappear = setTimeout("hideSubNav6()",1500);
	disappearSet = 1;
}

function stay()
{
	clearTimeout(disappear);
}

function leave()
{
	disappear = setTimeout("hideDropDown()",2000);
	disappearSet = 1;
}

function changeImage(x)
{
	document.getElementById('galleryImage').src=x;
}

function popUp(URL,w,h) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,height="+h+",width="+w+",left = 0,top = 0');");
}

//VALIDATION
function setRequiredColors(fieldName)
{
	var label = fieldName + "Label";
	
	if (document.getElementById(fieldName).value == "")
	{
		document.getElementById(label).style.color="#C00";
	}
	else
	{
		document.getElementById(label).style.color="#333";
	}
}
function checkFieldsRSVPForm() {
	
	var fieldsArray	= new Array();
		fieldsArray	= Array('rsvpFName','rsvpLName','rsvpCompany','rsvpEMail','rsvpPhone','rsvpEMail','rsvpAddress1','rsvpNumAttending','rsvpCity','rsvpState','rsvpZip');
		
	for (var i=0; i<fieldsArray.length; i++)
	{
		
		var label = fieldsArray[i] + "Label";
		
		if(document.getElementById(fieldsArray[i]).value == "")
		{
			// set form action to nothing
			document.forms.rsvpForm.action= "";
			// alert the problem
			alert ("You are missing one or more required field(s).");
			// loop through all fields for text color change
			for (var j=0; j<fieldsArray.length; j++)
			{
				setRequiredColors(fieldsArray[j]);
			}
			return(false);
		}
		else
		{
			document.forms.rsvpForm.action="send_rsvp.php";
		}
	}
	
}