function navControl()
{
	$('#topNav li ul').hide();
	$('#topNav li').hover(
	function()
		{
			$(this).find('ul').stop(true, true).delay(200).slideDown(800, "easeOutExpo");
			$(this).find('ul').parent().find('a:first').css({'color':'#000','background-color':'#8CC63E'});
			
		},function()
		{
			$(this).find('ul').stop(true, true).slideUp(100);
			$(this).find('ul').parent().find('a:first').css({'color':'#666','background-color':'#fff'});

		}
	);	
	
	$('#sideNav li ul').hide();
	$('#sideNav li').hover(
	function()
		{
			$(this).find("img").attr("src", $(this).find("img").attr("src").split("_Up.").join("_Over."));
			$(this).find('ul').stop(true, true).delay(200).show(500);
			
		},function()
		{
			$(this).find("img").attr("src", $(this).find("img").attr("src").split("_Over.").join("_Up."));
			$(this).find('ul').stop(true, true).delay(200).hide(200);
		}
	);	
}

function checkValidation(thisForm)
{
   if(!checkText(thisForm.firstname,"Please Enter Your First Name")){return false;}
   if(!checkText(thisForm.lastname,"Please Enter Your Last Name")){return false;}
   if(!checkText(thisForm.email,"Please Enter Your Email")){return false;}
   if(!checkText(thisForm.cemail,"Please Re-Enter Your Email")){return false;}
   if(!checkText(thisForm.address,"Please Enter Your Address")){return false;}
   if(!checkText(thisForm.city,"Please Enter Your City")){return false;}
   if(!checkText(thisForm.state,"Please Enter Your State")){return false;}
   if(!checkText(thisForm.zip,"Please Enter Your Zip")){return false;}
   if(!checkText(thisForm.country,"Please Enter Your Country")){return false;}
   if(!checkText(thisForm.phone,"Please Enter Your Phone")){return false;}


   //if email is empty, do nothing.  if email textbox is not empty, check for a valid email
   if(thisForm.email.value != "")
   {
	    if(!regExEmail(thisForm.email)){return false;}
   }
   
   return true; //returns true, unless there is a problem! (USE LOWER CASE!!)
}//END OF checkValidation///////////////////////////////////////////////////   






function checkText(fObj,msg)
{//will take in text and check for input
	var currTxt = document.getElementById("" +fObj.name + "1"); 
   if(fObj.value == "")
   {
	   currTxt.innerHTML = "<p class='contact_alert_para'>" + msg + "</p>";
	   fObj.focus();
	   return false;
   }
  return true;	
}
/*
function checkRadio(fObj,msg)
{//takes in radio button or checkbox and checks for input

	for(x=0; x<fObj.length;x++)
	{
		if(fObj[x].checked)
		{//good!!
			return true;
		}
	}
  alert(msg);
  fObj[0].focus();//focus on first element of array of named elements
  return false;

}

function checkSelect(fObj,msg)
{//checks that the 0 numbered item in the array is not selected
	if(fObj.options[0].selected)
	{
		alert(msg);
		fObj.focus();
		return false;
	}else
	{
		return true;	
	}	

}
*/
function regExEmail(eObj)
{//Uses regular expression for email check
	var currTxt = document.getElementById("" +eObj.name + "1"); 
	var rePattern = /^[a-zA-Z0-9\-]+\@[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3})$/;
 if(rePattern.test(eObj.value))
 {
 	return true;
 }
 else
 {
    currTxt.innerHTML = "<br /><p class='alertPara'>Please enter a VALID email address</p>";
	eObj.value = "";
	eObj.focus();
	return false;
 }
}



$(document).ready(function()
{
	navControl();
});
