// JavaScript Document

function validate(val, show)
{	
	if(document.getElementById("mtxtQuestion").value=="" || document.getElementById("mtxtQuestion").value=="Enter your question here...")	
	{
		alert("Please enter question")
		document.getElementById("mtxtQuestion").focus();
		return false;
	}

	var str = document.getElementById("mtxtQuestion").value;
	var trimmed = str.replace(/^\s+|\s+$/g, '') ;

	if(!trimmed)
	{
		alert("Blank spaces not allowed in question box");
		document.getElementById("mtxtQuestion").focus();
		return false;
	}
	
	if(show==1 && document.getElementById("cmbCategory").value==0)
	{
		alert("Please select category");
		document.getElementById("cmbCategory").focus();
		return false;
	}
	else
	{
		document.frmAskQuestion.submit();				
	}	
	
	return false;
}

function IsEmpty(aTextField) 
{
	if ((aTextField.value.length!=0) || (aTextField.value!="")) 
   {   
   	  return 1;
   }
   else 
   { 
		return 0;
   }
}	

function validateNew(val, show)
{
	if(val==2)
	{
		if(document.getElementById("mtxtQuestion").value=="" || document.getElementById("mtxtQuestion").value=="Type your question here...")	
		{
			alert("Please enter question")
			document.getElementById("mtxtQuestion").focus();
			return false;
		}

		if(show==1 && document.getElementById("cmbCategory").value==0)
		{
			alert("Please select category");
			document.getElementById("cmbCategory").focus();
			return false;
		}
		else
		{
			document.frmAskQuestion.submit();				
		}
	}
	else
	{
		document.frmAskQuestion.submit();	
	}
	
	return false;
}
