	function validate_form(thisform)
	{
	with (thisform)
	{
	var winLoc = window.location.href;
	var popup;
	
		
	
	
	if (validate_required(name,"Please enter a name")==false)
	  {name.select();return false;}
	  
	if (validate_required(email,"Please enter an email address")==false)
	  {email.select();return false;}
	  
	if (validate_email(email,"Please enter a valid email address")==false)
  	  {email.select();return false;}

	if(winLoc.indexOf("/instruction/asktheexperts/popup.html") == -1)		//If form is not popup and had drop down category then validate drop down
	{
		if(winLoc.search("equipment") == -1 && winLoc.search("fitness") == -1 && winLoc.search("instruction/asktheexperts/instruction") == -1 && winLoc.search("rules") == -1 )		//If form is coming from section specific page, set hidden values and don't validate topic dd
		{
			if (validate_required_dropdown(category,"Please select a topic")==false)
	  		{category.focus();return false;}	  		
	  	}	
	  	
	  	popup = false;
	  	setHiddenValues(thisform, winLoc, popup);			//set hidden values
											
	} 
	else
	{
		popup = true;
		setHiddenValues(thisform, winLoc, popup);			//set hidden values
	
	}				 

	if (validate_required(question,"Please enter your question")==false)
	  {question.select();return false;}

	}
	
	
	}
	
	function setHiddenValues(thisform, winLoc, popup)
	{
		var baseURL = 'http://' + document.location.host+ '/instruction/asktheexperts/';			//gets base url
		
		if (popup)
		{
			if (winLoc.indexOf("?category=")>-1)
			{
				//Get category name from query string
				var startPos = winLoc.indexOf("?category=") + 10;			//get starting position of the directory after asktheexperts
				var categoryName = winLoc.substring(startPos);				//parse sting and get directory name based on starting 
			}			
			document.asktheexperts.category.value = categoryName;			//set hidden category input field
			baseURL = baseURL + "popupthankyou.html";						//get base url and add the correct thank you page  
		}
		else
		{			
			baseURL = baseURL + "thankyou.html";							//get base url and add the correct thank you page
		}
		
		document.asktheexperts.myurl.value = baseURL;						//set hidden myurl input field;									
	}
	
function resetAskAnExpert() {
	window.close();	
}