/*********
**	These functions are usefull to check the charecters and numbers.
**  checknum alows numbers only and checkchar allows charecters only.
**  For these developers has to pass the event as an aurgument.
*********/
function checkchar(evt)
{
	evt = (evt) ? evt : window.event
	var charCode = (evt.which) ? evt.which : evt.keyCode
	if(charCode !=9 && charCode !=8 && charCode !=46 && charCode !=13  )
	if ( (charCode <31 || charCode>=33 ) && charCode <= 64 || charCode >90 && (charCode < 97 || charCode > 123)&&(charCode != 9) )
	{
		status= "This field accepts alphabets only. ";
		return false;
	}
	 return true;
}
function phone(evt)
{
		//alert(event.keyCode);
		evt = (evt) ? evt : window.event
		var charCode = (evt.which) ? evt.which : evt.keyCode
		if (charCode > 31 && (charCode < 48 || charCode > 57)&& (charCode < 43 || charCode > 43)&& (charCode < 45 || charCode > 45))
		{
			status = "This field accepts numbers only."
			//alert("This field accepts numbers only")
			return false;
		}
		status = ""
		return true;
}	
function checkIt(evt)
	{
		//alert(event.keyCode);
		evt = (evt) ? evt : window.event
		var charCode = (evt.which) ? evt.which : evt.keyCode
		if (charCode > 31 && (charCode < 48 || charCode > 57)&& (charCode < 46 || charCode > 46)) {
			status = "This field accepts numbers only."
			//alert("This field accepts numbers only")
			return false;
		}
		status = ""
		return true;
	}
	function trimspaces(str)
		{
			while((str.indexOf(' ',0) == 0) && (str.length > 1))
			{
				str = str.substring(1, str.length);
			}
			while((str.lastIndexOf(' ') == (str.length - 1) && (str.length > 1)))
			{
				str = str.substring(0,(str.length - 1));
			}
			if((str.indexOf(' ',0) == 0) && (str.length == 1)) str = '';
			return str;
		}
		  
function validate_form(Obj)
{
	for ( i = 0; i < Obj.elements.length; i++) {
		formElem = Obj.elements[i];	
		switch (formElem.type) 
		{
				case 'text':
				case 'password':
				case 'select-one':
				case 'textarea':
				case 'select-multiple':
				case 'file':
				split_title=formElem.title.split("::");
				if(split_title[0]=='Fill' && trimspaces(formElem.value)==''){
						alert(split_title[1]);
						formElem.focus();
						return false;
						}
				if(split_title[0]=='selfill' && trimspaces(formElem.value)=='Select'){
						alert(split_title[1]);
						formElem.focus();
						return false;
						}		
				/*if(split_title[0]=='Fill3' && trimspaces(formElem.value)==''){
						alert(split_title[1]);
						formElem.focus();
						return false;
						} */
				if(split_title[0]=='Fill3' && trimspaces(formElem.value)!=''){
							if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(formElem.value)){
								}else{
									alert('Invalid E-mail Address! Please re-enter.');
									formElem.focus();
									return false;
								}
					}
					break;
			}
		}
		return true;
 }
function chkedu()
{
	//return true;
	if(document.frm_participantinfo.sel_specialize_1.value=='Select' || document.frm_participantinfo.board_1=='')
	{
		alert("Please complete matric eduction detail");
		document.frm_participantinfo.sel_specialize_1.focus();
		return false;
	}
	for(i=1;i<=4;i++)
	{
		inpt_sp = eval("document.frm_participantinfo.sel_specialize_"+i);
		inpt_brd = eval("document.frm_participantinfo.board_"+i);
		inpt_passyear = eval("document.frm_participantinfo.passyear_"+i);  
		inpt_gpa = eval("document.frm_participantinfo.percent_"+i); 
		
		fillspval=inpt_sp.value;
		fillbrdval = inpt_brd.value; 
		fillpassyearval = inpt_passyear.value; 
		fillpercent = inpt_gpa.value;
		if(fillspval!='Select' || fillbrdval!='' || fillpassyearval!='Select' || fillpercent!='')
		{
			if(fillbrdval=='')
			{
				alert("Please complete education detail");
				inpt_brd.focus();
				return false;
			}
			if(fillspval=='Select')
			{
				alert("Please complete education detail");
				inpt_sp.focus();
				return false;
			}
			if(fillpassyearval=='Select')
			{
				alert("Please complete education detail");
				inpt_passyear.focus();
				return false;
			}
			if(fillpercent=='')
			{
				alert("Please complete education detail");
				inpt_gpa.focus();
				return false;
			}
		}
	}
	
	for(i=4;i>2;i--)
	{
		j=i-1;
		inpt_sp = eval("document.frm_participantinfo.sel_specialize_"+i);
		inpt_brd = eval("document.frm_participantinfo.board_"+i);  
		inpt_passyear = eval("document.frm_participantinfo.passyear_"+i);  
		inpt_gpa = eval("document.frm_participantinfo.percent_"+i);  
		fillspval=inpt_sp.value;
		fillbrdval = inpt_brd.value; 
		fillpassyearval = inpt_passyear.value; 
		fillpercent = inpt_gpa.value;
		if(j >=2)
		{
			inptb_sp = eval("document.frm_participantinfo.sel_specialize_"+j);
			inptb_brd = eval("document.frm_participantinfo.board_"+j);  
			inptb_passyear = eval("document.frm_participantinfo.passyear_"+j);  
			inptb_gpa = eval("document.frm_participantinfo.percent_"+j);  
			
			fillbspval=inptb_sp.value;
			fillbbrdval = inptb_brd.value; 
			fillbpassyearval = inptb_passyear.value; 
			fillbpercent = inptb_gpa.value;
		}
		if(fillspval!='' && fillbrdval!='')
		{
			if(fillbspval=='' || fillbbrdval=='')
			{
				alert("Please complete above education detail");
				return false;
			}
		}		
	} 
	return true;
}
