function submitSemiSearchForm()
{ 
	if(validateSemiSearchForm())
	{ 
      document.form1.action="../supportsevices/resource_data_results.jsp";
	  document.form1.submit();
	}
	
}

function validateSemiSearchForm()
{
		if(document.form1.Interest.value=="-1")
		{  
           alert("Please select a valid value for Area of Interest");
		   document.form1.Interest.focus();
	       return false;
		}
	return true;
}

function submitSearchForm()
{ 
	if(validateSearchForm())
	{ 
      document.form1.action="../supportsevices/resource_data_results.jsp";
	  document.form1.submit();
	}
	
}

function validateSearchForm()
{

		/*if(document.forms[0].IndusExp.value=="0" )
		{  
           alert("Please select a valid value for Industry Experience");
		   document.form1.IndusExp.focus();
	       return false;
		}

		if(document.forms[0].AcadExp.value=="0" )
		{  
           alert("Please select a valid value for Academic Experience");
		   document.form1.AcadExp.focus();
	       return false;
		}*/
		
		if(document.form1.Qual.value=="0")
		{  
           alert("Please select a valid value for Qualifications");
		   document.form1.Qual.focus();
	       return false;
		}

		if(document.form1.Interest.value=="")
		{  
           alert("Please enter a value for Area of Interest");
		   document.form1.Interest.focus();
	       return false;
		}

		if(document.form1.TimeAvail.value=="0")
		{  
           alert("Please select a valid value for Time Availability");
		   document.form1.TimeAvail.focus();
	       return false;
		}
		
	return true;
}

function submitMemberRegForm()
{ 
	if(validateMemberRegForm())
	{ 
      document.form1.action="../registration_control.jsp";
	  document.form1.submit();
	}
	
}
function validateMemberRegForm()
{
		if(document.form1.Name.value=="")
		{  
           alert("Name cannot be blank");
		   document.form1.Name.focus();
	       return false;
		}

		if(someValInOneNotInTwo(document.form1.Name.value," _0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'")) {
					 alert("Name cannot have special characters");
					 document.form1.Name.value="";
					 document.form1.Name.focus();
					 return false;
		}
		
		if(document.form1.email.value=="")
		{
           alert("Email id cannot be blank");
		   document.form1.email.focus();
	       return false;
		}

	 if(isNotProperEmail(document.form1.email.value)) 
	{
		alert("Please enter a valid email address");
		document.form1.email.value="";
		document.form1.email.focus();
		return false;
	}

		if(document.forms[0].IndustryExp.value=="0" )
		{  
           alert("Please select a valid value for Industry Experience");
		   document.form1.IndustryExp.focus();
	       return false;
		}

		if(document.forms[0].AcadExp.value=="0" )
		{  
           alert("Please select a valid value for Academic Experience");
		   document.form1.AcadExp.focus();
	       return false;
		}
		
		if(document.form1.Qualific.value=="0")
		{  
           alert("Please select a valid value for Qualifications");
		   document.form1.Qualific.focus();
	       return false;
		}

		if(document.form1.Interest.value=="")
		{  
           alert("Please enter a value for Area of Interest");
		   document.form1.Interest.focus();
	       return false;
		}

		if(document.form1.TimeAvail.value=="0")
		{  
           alert("Please select a valid value for Time Availability");
		   document.form1.TimeAvail.focus();
	       return false;
		}

		if(document.form1.NatOfCont.value=="")
		{  
           alert("Please enter a value for Nature of Contribution");
		   document.form1.NatOfCont.focus();
	       return false;
		}
		
	return true;
}

function someValInOneNotInTwo(strg,val) {
	
	for (i=0;i<strg.length;i++) {	
		var s = strg.charAt(i);
			if (val.indexOf(s)==-1)
						return true;
   	 }
	   	 return false;
}

function isNotProperEmail(str)
		{
	if(someValInOneNotInTwo(str,"_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@.1234567890")) return true;	
	at = str.indexOf('@');
	dot= str.indexOf('.');	
	if((at==-1)||(dot==-1)) return true; //if either dot or @ are absent
	substr2 = str.substr(at+1,str.length); //extract substring after @
	secondAt = substr2.indexOf('@');
	dotAfterFirstAt = substr2.indexOf('.');
	underscoreAfterFirstAt=substr2.indexOf('_');
    if(underscoreAfterFirstAt==0)return true;//_ after @
		       underscore=str.substr(dot+1,str.length);
			   
			  for(i=0;i<underscore.length;++i)
			{     
				  if(underscore.charAt(i)=='_')return true;//underscore in .com
			}
		
	sublen = substr2.length;
	if(substr2.charAt(sublen-1)=='.')return true; //if the last character is a dot
	if(secondAt!=-1) return true; //if a second @ is present
	if((dotAfterFirstAt==0)||(dotAfterFirstAt==-1)) return true; //if dot is present immediately after first @ or absent after first @
	return false;
		}	


function submitUpdatesForm()
{ 
	if(validateUpdatesForm())
	{ 
      document.form1.action="../registration_control.jsp";
	  document.form1.submit();
	}
	
}

function validateUpdatesForm()
{
		if(document.form1.Name.value=="")
		{  
           alert("Name cannot be blank");
		   document.form1.Name.focus();
	       return false;
		}

		if(someValInOneNotInTwo(document.form1.Name.value,"_0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'")) {
					 alert("Name cannot have special characters");
					 document.form1.Name.value="";
					 document.form1.Name.focus();
					 return false;
		}
		
		if(document.form1.Category.value=="-1")
		{  
           alert("Please select a valid value for Category");
		   document.form1.Category.focus();
	       return false;
		}

		if(document.form1.Company.value=="")
		{  
           alert("Please enter a value for Company");
		   document.form1.Company.focus();
	       return false;
		}

		if(document.form1.Email.value=="")
		{
           alert("Email id cannot be blank");
		   document.form1.Email.focus();
	       return false;
		}

	 if(isNotProperEmail(document.form1.Email.value)) 
	{
		alert("Please enter a valid email address");
		document.form1.Email.value="";
		document.form1.Email.focus();
		return false;
	}
		
		if(document.form1.EventsNews.checked==false && document.form1.PolChanges.checked==false && document.form1.AccreditNews.checked==false)
		{  
           alert("Please choose one category for recieving updates");
	       return false;
		}

	
	return true;
}

function submitFeedBackForm()
{ 
	if(validateFeedBackForm())
	{ 
      document.form1.action="../registration_control.jsp";
	  document.form1.submit();
	}
	
}

function validateFeedBackForm()
{

	if(document.form1.FeedType[0].checked==false && document.form1.FeedType[1].checked==false && document.form1.FeedType[2].checked==false && document.form1.FeedType[3].checked==false && document.form1.FeedType[4].checked==false && document.form1.FeedType[5].checked==false)
		{  
           alert("Please choose one category for classifying your feedback");
	       return false;
		}

		if(document.form1.Comments.value=="")
		{  
           alert("Please enter your comments");
		   document.form1.Comments.focus();
	       return false;
		}

		if(document.form1.Name.value=="")
		{  
           alert("Name cannot be blank");
		   document.form1.Name.focus();
	       return false;
		}

		if(someValInOneNotInTwo(document.form1.Name.value,"_0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'")) {
					 alert("Name cannot have special characters");
					 document.form1.Name.value="";
					 document.form1.Name.focus();
					 return false;
		}
		
		if(document.form1.Email.value=="")
		{
           alert("Email id cannot be blank");
		   document.form1.Email.focus();
	       return false;
		}

	 if(isNotProperEmail(document.form1.Email.value)) 
	{
		alert("Please enter a valid email address");
		document.form1.Email.value="";
		document.form1.Email.focus();
		return false;
	}
		
		if(document.form1.FeedType[0].checked==true)
			document.form1.CommentId.value = "1" ;
		if(document.form1.FeedType[1].checked==true)
			document.form1.CommentId.value = "2" ;
		if(document.form1.FeedType[2].checked==true)
			document.form1.CommentId.value = "3" ;
		if(document.form1.FeedType[3].checked==true)
			document.form1.CommentId.value = "4" ;
		if(document.form1.FeedType[4].checked==true)
			document.form1.CommentId.value = "5" ;
		if(document.form1.FeedType[5].checked==true)
			document.form1.CommentId.value = "6" ;

	return true;
}

function submitCommentsForm()
{ 
	if(validateCommentsForm())
	{ 
      document.form1.action="../registration_control.jsp";
	  document.form1.submit();
	}
	
}

function validateCommentsForm()
{
		if(document.form1.Name.value=="")
		{  
           alert("Name cannot be blank");
		   document.form1.Name.focus();
	       return false;
		}

		if(someValInOneNotInTwo(document.form1.Name.value,"_0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'")) {
					 alert("Name cannot have special characters");
					 document.form1.Name.value="";
					 document.form1.Name.focus();
					 return false;
		}

		if(document.form1.Category.value=="-1")
		{  
           alert("Please Choose A Category");
		   document.form1.Category.focus();
	       return false;
		}

		if(document.form1.Company.value=="")
		{  
           alert("Company Name cannot be blank");
		   document.form1.Company.focus();
	       return false;
		}
		
		if(document.form1.College.value=="-1")
		{  
           alert("Please Choose A College");
		   document.form1.College.focus();
	       return false;
		}
		if(someValInOneNotInTwo(document.form1.Company.value,"_0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'")) {
					 alert("Company Name cannot have special characters");
					 document.form1.Company.value="";
					 document.form1.Company.focus();
					 return false;
		}
		
		if(document.form1.Email.value=="")
		{
           alert("Email id cannot be blank");
		   document.form1.Email.focus();
	       return false;
		}

	 if(isNotProperEmail(document.form1.Email.value)) 
	{
		alert("Please enter a valid email address");
		document.form1.Email.value="";
		document.form1.Email.focus();
		return false;
	}
	var types = document.forms[0].totalTypes.value;
	var atleastOne="false";
	for(i=7; i <= types; i++)
	{

		if(eval("document.forms[0].CommTypeCheck" + i + ".checked") ==  true)
		{
			atleastOne = "true";
			if((eval("document.forms[0].CommTypeText" + i + ".value") == null) || (eval("document.forms[0].CommTypeText" + i + ".value") == ""))
			{	alert("Please enter a value for the checkbox selected");				
				eval("document.forms[0].CommTypeText" + i + ".focus()")
				return false;
			}						
		}
	}
	
	if(atleastOne == "false")
	{
		alert("Please choose one topic to comment on");
		return false;
	}
		
	return true;
}