/********************************************************************************************
Project Name	:	MCCIA
Copyright		:	Copyright(c) 2002
Company			:	DishnetDSL, Pune
Name of Module	:	Client Side validations
Functionality	:	Does client side Validations of various forms
Version			:
Author			:	Jitendra,Seema				Date:13/03/2002
Reviewed By		:
Modified By		:
Remark			:
********************************************************************************************/


/*******************************************************************************************
						Main function calling various functions
*******************************************************************************************/

	function validate(frm,fieldName)
	{
		for(eleCnt=0;eleCnt<frm.elements.length;eleCnt++)
		{
			//alert('ele: ' + frm.elements[eleCnt].name + ' ele: ' + frm.elements[eleCnt].value)
			
			index=0
			index1=0
			ch=''
			ch1=''
			
			str=frm.elements[eleCnt].id
		
			index=str.indexOf(",")
			ch=parseInt(str.substring(0,index))

						
			if(str!='')			
			{
				ch1=fieldName.substring(0,fieldName.indexOf(","))
				index1=fieldName.indexOf(",")
				fieldName=fieldName.substring(index1+1,fieldName.length)

			}
			
			while(index!=-1)
			{				
				switch(parseInt(ch))
				{
					case 1:
							if(checkEmpty(frm.elements[eleCnt],ch1))
								return
							break;
					case 2:
							if(checkSpace(frm.elements[eleCnt],ch1))
								return
							break;
					case 3:
							if(emailvalid(frm.elements[eleCnt-1],frm.elements[eleCnt]))
								return
							break;
					case 4:
							if(checkConsecutiveSpecialChar(frm.elements[eleCnt],ch1))
								return
							break;
					case 5:
							if(isNumericOnClick(frm.elements[eleCnt],ch1))
								return
							break;									
					case 6:
							if(isAlphabetOnClick(frm.elements[eleCnt],ch1))
								return
							break;			
					case 7:
							if(isAtOrDotOnClick(frm.elements[eleCnt],ch1))
								return
							break;		
					case 8:
							if(checkCombo(frm.elements[eleCnt],ch1))
								return
							break;						
					case 9:
							if(checkSingleSpace(frm.elements[eleCnt],ch1))
								return
							break;		
					case 10:
							if(isDateCorrect(frm.elements[eleCnt].value,frm.elements[eleCnt+1].value,frm.elements[eleCnt+2].value)==false)
							{
								alert('Invalid date selected.Please select valid date')	
								frm.elements[eleCnt].focus
								return
							}
							break;		
					case 11:
							if(checkPayMode(frm.elements[eleCnt],frm.elements[eleCnt+1],frm.elements[eleCnt+5],frm.elements[eleCnt+6])==false)
								return
							break;		
					case 12:
							if(isPhoneNumberOnClick(frm.elements[eleCnt],ch1))
								return
							break;									
					case 13:
					//		alert('calling alpha')
							if(isAlphaNumericOnlyOnClick(frm.elements[eleCnt],ch1))
								return
							break;													
					case 14:
							if(checkLength(frm.elements[eleCnt],ch1))
								return
							break;									
					case 15:
							if(isLoginId(frm.elements[eleCnt],ch1))
								return
							break;				
					case 16:
							if(confirmPassword(frm.elements[eleCnt],frm.elements[eleCnt-1]))
								return
							break;		
					
					case 17 :
							//alert('calling email validation ' + frm.elements[eleCnt].name)
							//alert(abc(frm.elements[eleCnt]))
							if(checkEmail(frm.elements[eleCnt])==false)
							{
							//	alert('in email validation ')
								return
							}
							//alert('after email validation ')
							break;		
					
					case 18:
							if(fromDateToDate(frm.elements[eleCnt].value,frm.elements[eleCnt+1].value,frm.elements[eleCnt+2].value,
											  frm.elements[eleCnt+3].value,frm.elements[eleCnt+4].value,frm.elements[eleCnt+5].value,ch1)==false)
							{
								frm.elements[eleCnt].focus
								return
							}
							break;		
					case 19:
							if(isPincodeOnClick(frm.elements[eleCnt],ch1))
								return
							break;							
													
					case 20:
							if(checkTemplate(frm.elements[eleCnt],frm.elements[eleCnt+1],frm.elements[eleCnt+2],frm.elements[eleCnt+3],ch1)==false)
								return
							break;		
					case 21:
							if(startToLastDate(frm.elements[eleCnt].value,frm.elements[eleCnt+1].value,frm.elements[eleCnt+2].value,
											  frm.elements[eleCnt-6].value,frm.elements[eleCnt-5].value,frm.elements[eleCnt-4].value,ch1)==false)
							{
								frm.elements[eleCnt].focus
								return
							}
							break;		
									
					case 22:
						if(startTime_Endtime(frm.elements[eleCnt],frm.elements[eleCnt+1],frm.elements[eleCnt+2],frm.elements[eleCnt+3])==false)
							{
								//frm.elements[eleCnt].focus
								return
							}
							break;		
													
                    			case 23:
							if(lessThanSysDate(frm.elements[eleCnt].value,frm.elements[eleCnt+1].value,frm.elements[eleCnt+2].value)==false)
							{
								alert('Start/End date cannot be less than today\'s date.Please select a date greater than today\'s date.')	
								frm.elements[eleCnt].focus
								return
							}
							break;		

					case 24:
							if(equalToSysDate(frm.elements[eleCnt].value,frm.elements[eleCnt+1].value,frm.elements[eleCnt+2].value)==false)
							{
								alert(ch1 + ' cannot be equal to today\'s date.Please select a date greater than today\'s date.')	
								frm.elements[eleCnt].focus
								return
							}
							break;		
										
					case 25:
							if(ch_same_rcptID(frm.elements[eleCnt],frm.elements[eleCnt+10])==false)
							{
								alert('Identical Receipt ID\'s .Please Check ')	
								return
							}
							break;									
							
                    			case 26:
							if(modifyDate(frm.elements[eleCnt].value,frm.elements[eleCnt+1].value,frm.elements[eleCnt+2].value,ch1)==false)
							{
								//alert('Start/End date cannot be less than today\'s date.Please select a date greater than today\'s date.')	
								frm.elements[eleCnt].focus
								return
							}
							break;		
							
					case 27:
							if(reverse_fromDateToDate(frm.elements[eleCnt].value,frm.elements[eleCnt+1].value,frm.elements[eleCnt+2].value,
											  frm.elements[eleCnt-3].value,frm.elements[eleCnt-2].value,frm.elements[eleCnt-1].value,ch1)==false)
							{
								frm.elements[eleCnt].focus
								return
							}
							break;	
					case 28:
							if(chk_date_for_chequeMode(frm.elements[eleCnt],frm.elements[eleCnt+1],frm.elements[eleCnt+2],frm.elements[eleCnt-2])==false)
							{
								frm.elements[eleCnt].focus
								return
							}
							break;	
					case 29:
							if(checkFacultyTemplate(frm.elements[eleCnt-1],frm.elements[eleCnt],frm.elements[eleCnt+1],frm.elements[eleCnt+2],frm.elements[eleCnt+3],ch1)==false)
								return
							break;		
								
			        	case 30:
							if(checkCountry(frm.elements[eleCnt-3],frm.elements[eleCnt-2],frm.elements[eleCnt-1],frm.elements[eleCnt],ch1)==false)
								return
							break;	
							
					case 31:
							if(isAlphabetandCommaOnClick(frm.elements[eleCnt],ch1))
								return
							break;	
					case 32:
							if(checkQualification(frm.elements[eleCnt],frm.elements[eleCnt+1])==false)
							return
							break;	
							
					case 33:
							if(checkExperience(frm.elements[eleCnt],frm.elements[eleCnt+1],frm.elements[eleCnt+2],frm.elements[eleCnt+3])==false)
							return
							break;	
				
					case 34:
							if(checkIndustry(frm.elements[eleCnt],frm.elements[eleCnt+1])==false)
							return
							break;	
					case 35:if(isNumericAndDotOnClick(frm.elements[eleCnt],ch1)==false)		
							return
							break;	
					case 36:if(chkBalAmt(frm.elements[eleCnt],ch1)==false)		
							return
							break;	
					case 37:if(fun4(frm.elements[eleCnt],ch1)==false)		
							return
							break;	
							
					case 38:if(fromtodate(frm.elements[eleCnt],frm.elements[eleCnt+1],ch1)==false)		
							return;
							break;			
				
					case 39:if(LessSysdate(frm.elements[eleCnt],ch1)==false)		
							return;
							break;			
					
					case 40:if(ColdWarmHotClosed()==false)		
							return;
							break;			
				
					case 41:if (ChkTextAreaLength200(frm.elements[eleCnt],ch1)==false)		
							return;
							break;			
					case 42:if (ChkTextAreaLength1024(frm.elements[eleCnt],ch1)==false)		
							return;
							break;	
									
					case 43:if (ChkEmptyCheckbox()==false)		
							return;
							break;			
				
													
				}//end of switch
				str=str.substring((index+1),str.length)
				index=0
				index=str.indexOf(",")
				ch=parseInt(str.substring(0,index))
				

			}
		}
		frm.submit()		
		return
		
	}//end of validate
	


/*******************************************************************************************
							Function to check for empty fields
*******************************************************************************************/
	

	function checkEmpty(control,ch1)
	{
		//alert("here")
		if(control.value=="")
		{
			alert(ch1 + ' cannot be empty.\nPlease enter the value.')
			control.focus()
			return true
		}
		return false
	}//end of checkEmpty
	

/*******************************************************************************************
							Function to validate email address
*******************************************************************************************/


	function emailvalid(control,control1)
	{
		var length1 = control.value.length 
		var length2 = control1.value.length
		
		if(((control.value=='')&&(control1.value!='')) || ((control.value!='')&&(control1.value=='')))
		{
			alert("Please enter value for both EmailId and Domain Name.Either of them cannot be empty")
			control.value=""
			control1.value=""
//			alert(control.name)
			control.focus()
			return(true)
		}
		
		if((length1 + length2) >50)
		{
			alert("E-Mail Size is above 50 characters")
			control.value=""
			control1.value=""
			control.focus()
			return(true)
		}
		
		return(false)
	}//End of function emailvalid


/*******************************************************************************************
							Function to check for alphaNumerics only
*******************************************************************************************/

	function isAlphaNumericOnlyOnClick(control,ch1)
	{
	//	alert('in alpha')
		val=control.value
		len=val.length;
		if(val.length!=0)
		{
			   while(len>0)
			   {
	//				alert('char at: '+val.charAt(len-1))
					if((!(((val.charAt(len-1)>='0')&&(val.charAt(len-1)<='9'))||
							((val.charAt(len-1)>='A')&&(val.charAt(len-1)<='Z'))||
							((val.charAt(len-1)>='a')&&(val.charAt(len-1)<='z'))||
							(val.charAt(len-1)==' '))))
					{
	
						alert('Please enter alphabets or numbers only for ' + ch1)   
						control.value='';
						control.focus()
						return true
			   		}
					len--;
				}
		}
		return false
			
	}//end of IsAlphaNumericOnlyOnClick


/*******************************************************************************************
							Function to check for character only data
*******************************************************************************************/
	
	   
	function IsAlphabet()
	{
	//alert(window.event.keyCode)
		if ( (!(window.event.keyCode >= 65  && window.event.keyCode <= 90 ))  && (!(window.event.keyCode >= 97  && window.event.keyCode <= 122 ))&& (!(window.event.keyCode==32)) )
       		window.event.keyCode = 0
		
	}   
	
	   
	function IsAlphabetandComma()
	{
	//alert(window.event.keyCode)
	//allows "." also
		if ( (!(window.event.keyCode >= 65  && window.event.keyCode <= 90 ))  && (!(window.event.keyCode >= 97  && window.event.keyCode <= 122 ))&& (!(window.event.keyCode==32)) && (!(window.event.keyCode==44))&& (!(window.event.keyCode==46)) )
       		window.event.keyCode = 0
		
	}   
   
/*******************************************************************************************
							Function to check for phone number
*******************************************************************************************/
   
   
	function isPhoneNumber()
	{
		if ( (window.event.keyCode < 48  || window.event.keyCode > 57) && (!(window.event.keyCode ==45)) )
			window.event.keyCode = 0
	}   


/*******************************************************************************************
							Function to check for pincode
*******************************************************************************************/
   
   
	function IsPincode()
	{
		//alert(window.event.keyCode)
		if ( !(((window.event.keyCode>=48)  && (window.event.keyCode<=57))))
			window.event.keyCode = 0
	}   
	
   
/*******************************************************************************************
							Function to check for numeric data
*******************************************************************************************/
   
   
	function IsNumeric()
	{
		//alert(window.event.keyCode)
		//if ( !(((window.event.keyCode>=48)  && (window.event.keyCode<=57)) || (window.event.keyCode==46)))
		if ( !(((window.event.keyCode>=48)  && (window.event.keyCode<=57))))
		{
			alert('Only Numbers are allowed.')
			window.event.keyCode = 0
		}	
	}   
	
	
/*******************************************************************************************
							Function to check for @ and . symbols
*******************************************************************************************/
	
	
	function IsAtOrDot()
	{
		if ( (window.event.keyCode == 64)|| (window.event.keyCode == 46) ) 
			window.event.keyCode = 0
	}   
	

/*******************************************************************************************
							Function to check for only spaces entered
*******************************************************************************************/

	
	function checkSpace(control,ch1)
	{
	   val=control.value;
	   len=val.length;
	 //  alert('len: ' + val.length + ' ele: ' + control.name)
	   j=0;
	   
	   if(val.length!=0)
	   {
	   
	   
	   	while(len>0)
	   	
	   {			
	   	   if(val.charAt(len-1)==' ')
	   	   {
	   	   j++;
	   
	   
	   		}
	   		len--;
	   	}
	   //alert('val len: ' + val.length)
	  // alert('j: ' + j)
	   	if (val.length===j)
	   	{
			alert('Invalid value entered for ' + ch1 + '. All spaces!!!')   
			control.value='';
			control.focus();
	   		return false;
	   	}
	     }
	     return true;
	   }
		

/*******************************************************************************************
							Function to check for special characters
*******************************************************************************************/


function checkSpecialChars()
{
	//alert(window.event.keyCode)
	if ( (window.event.keyCode == 96) || (window.event.keyCode == 126) || (window.event.keyCode == 33)
			|| (window.event.keyCode == 64)|| (window.event.keyCode == 35)|| (window.event.keyCode == 36)
			|| (window.event.keyCode == 94)|| (window.event.keyCode == 124)|| (window.event.keyCode == 92)
			|| (window.event.keyCode == 63)|| (window.event.keyCode == 62)|| (window.event.keyCode == 60)
			|| (window.event.keyCode == 43)|| (window.event.keyCode == 61)|| (window.event.keyCode == 39)
			|| (window.event.keyCode == 44)			
	   )
			window.event.keyCode = 0

}//end of checkSpecialChars


/*******************************************************************************************
							Function to check for only special chars entered
*******************************************************************************************/

	
function checkConsecutiveSpecialChar(control,ch1)
{
   val=control.value;
   len=val.length;
   j=0;
   
   arr=new Array("&","*","(",")","-","_","{","}","[","]",":",";","'",",",".","/")
   
  for(i=0;i<arr.length;i++)		   
  {
	len=val.length;
	j=0
	if(val.length!=0)
	{
		   while(len>0)
		   {
				if(val.charAt(len-1)==arr[i])
				{
					j++;
		   		}
				len--;
			}
	if(j>3)
	{  
		if (val.length===j)
		{
				alert('Invalid value entered for ' + ch1 + '.Please enter appropriate value.')   
				control.value='';
				control.focus()
				return true
		}
	}	
	}
  }	
  return false;
}

/*******************************************************************************************
							Function to check for isPhoneNumber OnClick Event
*******************************************************************************************/


function isPhoneNumberOnClick(control,ch1)
{
	val=control.value
	len=val.length;
	if(val.length!=0)
	{
		   while(len>0)
		   {
				if((!(((val.charAt(len-1)>='0')&&(val.charAt(len-1)<='9')) || (val.charAt(len-1)==='-'))))
				{
					alert('Please enter numeric value only for ' + ch1)   
					control.value='';
					control.focus()
					return true
		   		}
				len--;
			}
	}
	return false
}//end of isNumericOnClick


/*******************************************************************************************
							Function to check for isPincodeOnClick Event
*******************************************************************************************/


function isPincodeOnClick(control,ch1)
{
	val=control.value
	len=val.length;
	if(val.length!=0)
	{
		   while(len>0)
		   {
				if((!(((val.charAt(len-1)>='0')&&(val.charAt(len-1)<='9')))))
				{
					alert('Please enter numeric value only for ' + ch1)   
					control.value='';
					control.focus()
					return true
		   		}
				len--;
			}
	}
	return false
}//end of isNumericOnClick



/*******************************************************************************************
							Function to check for isNumeric OnClick Event
*******************************************************************************************/


function isNumericOnClick(control,ch1)
{
	val=control.value
	len=val.length;
	if(val.length!=0)
	{
		   while(len>0)
		   {
				if((!(((val.charAt(len-1)>='0')&&(val.charAt(len-1)<='9')))))
				{
					alert('Please enter numeric value only for ' + ch1)   
					control.value='';
					control.focus()
					return true
		   		}
				len--;
			}
	}
	return false
}//end of isNumericOnClick


/*******************************************************************************************
							Function to check for isAlphabet OnClick Event
*******************************************************************************************/


function isAlphabetOnClick(control,ch1)
{
	val=control.value
	len=val.length;
	if(val.length!=0)
	{
		   while(len>0)
		   {
				if((!((val.charAt(len-1)>='A')&&(val.charAt(len-1)<='Z'))) && (!((val.charAt(len-1)>='a')&&(val.charAt(len-1)<='z'))) && (!(val.charAt(len-1)==' '))&& (!(val.charAt(len-1)=='.')))
				{
					alert('Please enter characters only for ' + ch1)   
					control.value='';
					control.focus()
					return true
		   		}
				len--;
			}
	}
	return false
}//end of isAlphabetOnClick



function isAlphabetandCommaOnClick(control,ch1)
{
	val=control.value
	len=val.length;
	if(val.length!=0)
	{
		   while(len>0)
		   {
				if((!((val.charAt(len-1)>='A')&&(val.charAt(len-1)<='Z'))) && (!((val.charAt(len-1)>='a')&&(val.charAt(len-1)<='z'))) && (!(val.charAt(len-1)==' ')) && (!(val.charAt(len-1)==',')) )
				{
					alert('Please enter characters only for ' + ch1)   
					control.value='';
					control.focus()
					return true
		   		}
				len--;
			}
	}
	return false
}//end of isAlphabetandCommaOnClick

/*******************************************************************************************
						Function to check for isAtOrDot OnClick Event
*******************************************************************************************/


function isAtOrDotOnClick(control,ch1)
{
	val=control.value
	len=val.length;
	if(val.length!=0)
	{
		   while(len>0)
		   {
				if((val.charAt(len-1)==64) ||(val.charAt(len-1)==46))
				{
					alert('@ or dot not allowed in ' + ch1 + '.Please enter appropriate value.')   
					control.value='';
					control.focus()
					return true
		   		}
				len--;
			}
	}
	return false
}//end of isAtOrDotOnClick


/*******************************************************************************************
				Function to check if a value has been selectde from combobox
*******************************************************************************************/


function checkCombo(control,ch1)
{
	if(control.value=='sel'||control.value=='')
	{
		alert('Please select ' + ch1 + '.')   
	//	control.value='';
		control.focus()
		return true
	}
	return false;
}//end of checkCombo


/*******************************************************************************************
						Function to check for only one space entered
*******************************************************************************************/

	
	function checkSingleSpace(control,ch1)
	{
		str1=control.value;
		
		if((str1.length==1) && (str1==' '))
		{
			alert('Only space entered for ' + ch1 + '.Please enter appropriate value.')   
			control.value='';
			control.focus()
			return true
		}
		return false;
	
	}//end of function checkSingleSpace
	
	
/*******************************************************************************************
								Function to check valid date
*******************************************************************************************/
	
	
function isDateCorrect(dd,mm,yyyy)
{

	flag=true
	if(dd==31)
	{
		switch (parseInt(mm))
		{
		case 1  :
				 flag = true;	
				 break;
		case 3  :
				 flag = true;
				 break;
		case 5  :
				 flag = true;	
				 break;
		case 7  :
				 flag = true;	
				 break;
		case 8  :
				 flag = true;	
				 break;
		case 10  :
				 flag = true; 
				 break;
		case 12  :
				 flag = true; 
				 break;
		default :
				 flag = false; 
				 break;
				 
		}//end of switch
	}
	
	if( (dd==30) && (mm==2) )
	{	
		/*alert("here also")	*/
		flag = false
	 }
	
	if(dd==29 && mm==2) 
		if ((yyyy%4)==0)
			flag = true
		else
			flag = false	
		
	if(dd==28 && mm==2) 
		if ((yyyy%4)!=0)
			flag = true
		else
			flag = false				 
			
	if(dd == '' || mm == '' || yyyy == '')
	{ 
	if(dd == '' && mm == '' && yyyy == '')
		flag = true
	else
		flag = false
	}

			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
   return flag;
   }   			
   
   
/*******************************************************************************************
							Function to validate payment mode
*******************************************************************************************/
	
	
function checkPayMode(control,control1,control2,control3)
{
	//alert('control.name:' + control.name)
	//alert('control1.name:' + control1.name)
	//alert('control2.name:' + control2.name)
	//alert('control3.name:' + control3.name)
	if((control.value=="Cash") && ((control1.value!='') || (control2.value!='')))
	{
		alert('You have selected to pay by cash. \nPlease do not enter Cheque/DD No and Drawee Bank Name')
		control1.value=""
		control2.value=""
		control3.focus;
		return false
	}
	if((control.value=="Cheque") && ((control1.value=='') || (control2.value=='')))
	{
		alert('You have selected to pay by Cheque. \nPlease enter Cheque No and Drawee Bank Name')
		control1.focus;
		return false
	}
	if((control.value=="DD") && ((control1.value=='') || (control2.value=='')))
	{
		alert('You have selected to pay by DD. \nPlease enter DD No and Drawee Bank Name')
		control1.focus;
		return false
	}
	return true
	
}//end of payMode
   
   
/*******************************************************************************************
							Function to validate content length of textarea
*******************************************************************************************/
	
	
function checkLength(control,ch1)
{
   len=control.value.length
   
   if (len>255)
   {
		alert('The number of characters entered in ' + ch1 + ' has exceeded the maximum limit of 255 characters.\n Please check the contents.')
		control.focus;
		return true
   }
   return false
   
}//end of checkLength


/*******************************************************************************************
			  Function to check if the date is greater than or equal to sysdate
*******************************************************************************************/
	
	
/*function checkSysDate(control,control1,control2,ch1)
{
   dt = new Date()
   alert('dt: ' + dt.getDate + ' mnth: ' + dt.getMonth() + ' yr: ' + getYear())	
   alert(control.value + '/' + control1.value + '/' + control2.value)
   dt2=new Date(control.value + '/' + control1.value + '/' + control2.value)
   alert(dt==dt2)
   
	//	alert('The number of characters entered in ' + ch1 + ' has exceeded the maximum limit of 255 characters.\n Please check the contents.')
	//	control.focus;
	//	return true
   
   return false
   
}//end of checkLength*/
   
   
/*******************************************************************************************
							Function to check for login validation
*******************************************************************************************/

	function isLoginId(control,ch1)
	{
//		alert('in alpha')
		val=control.value
		len=val.length;
		if(val.length!=0)
		{
			   while(len>0)
			   {
//					alert('char at: '+val.charAt(len-1))
					if((!(((val.charAt(len-1)>='0')&&(val.charAt(len-1)<='9'))||
							((val.charAt(len-1)>='A')&&(val.charAt(len-1)<='Z')||
							(val.charAt(len-1)>='a')&&(val.charAt(len-1)<='z') ||
							(val.charAt(len-1)=='-') || (val.charAt(len-1)=='_')
						))))
					{
						alert('Please enter alphabets, numbers, - or _ only for ' + ch1)   
						control.value='';
						control.focus()
						return true
			   		}
					len--;
				}
		}
		return false
			
	}//end of islogibid
   
   
/*******************************************************************************************
							Function to check for confirm password
*******************************************************************************************/

	function confirmPassword(control,control1)
	{
		if(control.value!=control1.value)
		{
			alert("Values entered for password and confirm password should be the same.\nPlease enter appropriate values.");
			control.value='';
			control.focus()
			return true
		}
		return false
		
    }//end of confirmPassword
   
/*******************************************************************************************
							Function to check for confirm password
*******************************************************************************************/
   
   
function checkEmail(control)
{
//alert('in email validation1111111 ')
strAccount = control.value
//alert('value: ' + strAccount)
var i = 0;
	var nCount = 0;
	var nDotCount = 0;
	var cChar;
	if(!(control.value == ''))
	{
	for (i=0 ; i< strAccount.length ; i++)
	{
		cChar = strAccount.charAt(i);
		if (cChar == '@')
		{
			nCount ++;
		}
		else if (nDotCount == 0 && cChar == '.')
		{
			//nCount ++;
			nDotCount++;
		}
		else if (cChar==' ' || cChar=='[' || cChar==']' || cChar=='{' ||
			cChar=='}' || cChar==':' || cChar==';' || cChar=='<' || cChar=='>' ||
			cChar=='?' || cChar=='/' || cChar=='\\' || cChar==','
			)
		{
			//return false;
			alert("Please enter valid Email ID");
			control.value="";
			control.focus();
			return false
		}
	}
	if(nCount !=1 || nDotCount!=1)
	{
		alert("Please enter @ and '.' at appropriate place.")
		control.value="";
		control.focus();
		return false;
	}
	}
	return true
}


/*******************************************************************************************
							Function to check from date less than to date
*******************************************************************************************/
   
   
function startToLastDate(dd,mm,yy,dd1,mm1,yy1,ch1)
{
	
	dt=new Date(yy,(mm-1),dd)
	dt1=new Date(yy1,(mm1-1),dd1)
		
	if(dt>dt1)
	{
		ind=ch1.indexOf(":")
		
		s1=ch1.substring(0,ind)
		s2=ch1.substring(ind+1,ch1.length)
		
		alert(s1 + ' date greater than ' + s2 + ' date.\nPlease select ' + s1 +' date less than or equal to ' + s2 + ' Date')	
		return false
	}
	
	return true

}//end of function fromDateToDate

/*******************************************************************************************
							Function to check from date less than to date
*******************************************************************************************/
   
   
function fromDateToDate(dd,mm,yy,dd1,mm1,yy1,ch1)
{
	
	dt=new Date(yy,(mm-1),dd)
	dt1=new Date(yy1,(mm1-1),dd1)
		
	if(dt>dt1)
	{
		ind=ch1.indexOf(":")
		
		s1=ch1.substring(0,ind)
		s2=ch1.substring(ind+1,ch1.length)
		
		alert(s1 + ' date greater than ' + s2 + ' date.\nPlease select ' + s1 +' date less than or equal to ' + s2 + ' Date')	
		return false
	}
	
	return true

}//end of function fromDateToDate



/*******************************************************************************************
							Function to check reverse of (from date less than to date)
*******************************************************************************************/
   
function reverse_fromDateToDate(dd,mm,yy,dd1,mm1,yy1,ch1)
{
	dt = mm+"/"+dd+"/"+yy
	dt1 = mm1+"/"+dd1+"/"+yy1


	if(dt != "0/0/0" && dt1 == "0/0/0")
	{
		ind=ch1.indexOf(":")
		
		s1=ch1.substring(0,ind)
		s2=ch1.substring(ind+1,ch1.length)
		
		alert('Please Select Proper From Date')
		return false
	}
		return true
	

}//end of function fromDateToDate








/*******************************************************************************************
							Function to check radios
*******************************************************************************************/

function checkTemplate(control,control1,control2,control3,ch1)
{

	if(control.type=='radio')
	 {
			if((control.checked == true)&& ((control3.value=='Enter your Data Here....')||(control3.value=='')))
			{
				alert('You have selected to create template !! please fill gist ')
				control3.value = ""
				control3.focus()
				return false
			}
			if((control.checked == true)&& (control2.value!=''))
			{
				alert('You have selected  to create template !! please do not give filename ')
				control2.value = ""
				control3.focus()
				return false
			}
			if((control1.checked == true)&& (control2.value==''))
			{
				alert('You have selected not to create template !! please  give file name ')
				control2.focus()
				return false
			}
			
			if((control1.checked == true)&& (control3.value!='Enter your Data Here....'))
			{
				if(control3.value!='')
				{
					alert('You have selected not to create template !! please do not give gist ')
					control3.value = ""
					control2.focus()
					return false
				}
			}
			
			return true
	 } 
}//end of checkTemplate

/*******************************************************************************************
							Function to check start time & end time
*******************************************************************************************/

function startTime_Endtime(control, control1,control2,control3)
{
	st_time = control.value
	end_time = control2.value
	
	st_am_pm = control1.value
	end_am_pm = control3.value
	
	//alert(st_time + '      ' + end_time + '     ' + st_am_pm + '      ' + end_am_pm)
	
	if(st_time.length<4 || end_time.length<4)
	{
		alert('Invalid time!! \nPlease enter time in the 4 digit format e.g. 0100 or 1200 or 0730')	
		control.value = ""
		control2.value = ""
		control.focus()
		return false
	}
	//alert('hihihihih' + parseInt(end_time) + '       end time' + parseInt(end_time))
	
	if(st_time.substring(0,1)=="0")
	{
		st_time=st_time.substring(1,st_time.length)
	//	alert("st: " + st_time)
	}
	
	if((parseInt(st_time)>1259) || (parseInt(st_time)<100))
	{
		alert('Invalid time!! Please enter start time in the range of 0100 to 1259')	
		control.value = ""
		control.focus()
		return false
	}
	
	if(end_time.substring(0,1)=="0")
	{
		end_time=end_time.substring(1,end_time.length)
	//	alert("end: " + end_time)
	}

	if((parseInt(end_time)>1259) || (parseInt(end_time)<100))
	{
		alert('Invalid time!! Please enter end time in the range of 0100 to 1259')	
		control2.value = ""
		control2.focus()
		return false
	}
	
	if((parseInt(st_time) >= parseInt(end_time))&&(st_am_pm==end_am_pm))
	{		
		alert('Start time can not be greater than or equal to end time !! Please check')	
		control.value = ""
		control2.value = ""
		control.focus()
		return false
	}
	
	return true

}//end of function startTime_Endtime



/*******************************************************************************************
						Function to check whether date less than sysDate
*******************************************************************************************/

function lessThanSysDate(dd,mm,yy)
{
	todaysDate=new Date()
	
	dd=parseInt(dd)+1
	selectedDate=new Date(yy,(mm-1),dd,todaysDate.getHours(),todaysDate.getMinutes(),todaysDate.getSeconds())
	//alert(todaysDate.getHours())
	//alert(todaysDate + '   ' + selectedDate)
	
	if(selectedDate<todaysDate)
		return false
	
	return true
	
}//end of lessThanSysDate


/*******************************************************************************************
					Function to check whether date is equal to sysDate
*******************************************************************************************/

function equalToSysDate(dd,mm,yy)
{
	todaysDate=new Date()
	
	selectedDate=new Date(yy,(mm-1),dd,todaysDate.getHours(),todaysDate.getMinutes(),todaysDate.getSeconds())
	
	//alert(todaysDate + ' 11111  ' + selectedDate)
	if(selectedDate==todaysDate)
		return false
	
	return true
	
}//end of equalToSysDate




/*******************************************************************************************
					Function to check for identical receipt id's
*******************************************************************************************/

function ch_same_rcptID(control, control1)
{
	h_id = control.value
	e_id = control1.value
	if(h_id == e_id )
	{
	control.value = ""
	control1.value  = ""
	control.focus()
	return false;
	}
	return true
	
}//end of ch_same_rcptID



/*******************************************************************************************
						Function fo scrolling msg on status bar
*******************************************************************************************/


function scroll(scrlStr) 
{
	alert('1')
	scrlStr1=scrlStr
	alert('2')
	width=140;
		alert('3')
	strLen=scrlStr.length;
		alert('4')
	pos1=1-width; 
   alert('5')
	scroll = "";    
	pos1++; 
	alert('6')
	if(pos1 == strLen) 
		pos1 =1 - width;   
		alert('7')
	if(pos1<0)   
	{       alert('8')
		for(i=1;i<=Math.abs(pos1);i++)
			scroll=scroll+" ";      
			scroll=scroll+scrlStr.substring(0,width-i+1);
	}
	
	else    
		scroll=scroll+scrlStr.substring(pos1,pos1+width);    
		alert('10')
	window.status=scroll; 
	alert(scrlStr1 + "       " + "\n" + scrlStr)	 
}


/*******************************************************************************************
					Function to check date while making modifications
*******************************************************************************************/


function modifyDate(dt,mon,yr,ch1)
{
//	alert(dt + '    ' + mon + '    ' + yr)
	startdt=new Date(yr,(mon-1),dt)
	
//	alert("startdt: " + startdt)
	
	ind=ch1.indexOf(":")
	ch1=ch1.substring(ind+1,ch1.length)	
	
	ind=ch1.indexOf(":")
		
	strdt=ch1.substring(ind+1,ch1.length)
//	alert("dt: " + strdt)
	
	mon1=strdt.substring(0,2)
//	alert('mon1: ' + mon1)
	
	ind=strdt.indexOf("/")
	strdt1=strdt.substring(ind+1,strdt.length)
	
	dt1=strdt1.substring(0,strdt1.indexOf("/"))
//	alert('dt1: ' + dt1)
	
	ind=strdt.indexOf("/")
	yr1=strdt1.substring(ind+1,strdt1.length)
//	alert('yr1: ' + yr1)
	
	dt2=new Date(yr1,(mon1-1),dt1)
//	alert("dt2: " + dt2)
	
	if(startdt<dt2)
	{
		alert('Start/End/Registration Date cannot be less \nthan current Start/End/Registration date.')
		return false
	}
	return true
}


/*******************************************************************************************
					Function to check date while the payment mode is cheque(date less then 6 months)
*******************************************************************************************/

	
	
function chk_date_for_chequeMode(control,control1,control2,control3)
{
	//alert('control.name:' + control.name + 'value is' + control.value)
	//alert('control1.name:' + control1.name + 'value is' + control1.value)
	//alert('control2.name:' + control2.name+ 'value is' + control2.value)
	//alert('control3.name:' + control3.name + 'value is' + control3.value)
	
	dt = control.value
	mon = control1.value 
	yr = control2.value
	if(control3.value == 'Cheque')
	{
	todaysDate=new Date()
	startdt=new Date(yr,(mon-1),dt)
	var difference = todaysDate.getTime() - startdt.getTime(); 	
	var daysDifference = Math.floor(difference/1000/60/60/24);
	//alert (daysDifference) 
	if (daysDifference > 180)
	{
	alert('sorry !! Cheque Date is not valid')
	return false
	}
	}
	return true
} 

/*******************************************************************************************
							Function to check radios for faculty template
*******************************************************************************************/

function checkFacultyTemplate(control3,control,control1,control2,control4,ch1)
{
	

	if(control.type=='radio')
	 {
			if((control.checked == true)&& (control2.value ==''))
			{
				alert('You have selected to create  template For Faculty!! please give filename  ')
				control2.focus()
				return false
			}
			if((control1.checked == true)&& (control2.value!=''))
			{
				alert('You have selected not to create template For Faculty !! please do not give filename ')
				control2.value = ""
				control2.focus()
				return false
			}
					
			return true
	 } 
}//end of checkFacultyTemplate
	
	

/*******************************************************************************************
							Function to check Country's FOR SSI
*******************************************************************************************/

function checkCountry(control,control1,control2,control3,ch1)
{
/*
alert(control.name + 'and value is ' + control.value)
alert(control1.name + 'and value is ' + control1.value)
alert(control2.name + 'and value is ' + control2.value)
alert(control3.name + 'and value is ' + control3.value)
*/ 
			if( ((control.value  != '') || (control1.value !='') || (control2.value !='')) && (control3.value == 'sel'))
			{
				alert('Please Select Country  Name ')
				control3.focus()
				return false
			}
					
			return true
	 
}//end of checkcountry

/*******************************************************************************************
							Function to check Qualification for SEE
*******************************************************************************************/
	
	
function checkQualification(control,control1)
{
if(((control.value != "") && (control1.value == "")) || ((control1.value != "") && (control.value == "")) ) 
{
alert('Please Enter Proper Qualification Details !!')
control.focus()
return false
}
return true
}



/*******************************************************************************************
							Function to check Experience for SEE
*******************************************************************************************/
	
	
function checkExperience(control1,control2,control3,control4)
{
flag = 0
	if(control1.value != "")
	{
	flag = flag +1
	}
	if(control2.value != "") 
	{
	flag = flag +1
	}
	if(control3.value != "") 
	{
	flag = flag +1
	}
	if(control4.value != "") 
	{
	flag = flag +1
	}
if (!(flag == 0 || flag == 4))
{
alert('Please Enter All Experience Details !! ')
control1.focus()
return false
}
return true
}
/*******************************************************************************************
							Function to check Industry  for SSI
*******************************************************************************************/


 function checkIndustry(control1,control2)
   {
   if (control1.checked == true)
 { 
 if (control2.value == "sel" || control2.value == "" )
 {
 alert('Please Select Appropriate Industry')
 control2.focus()
 return false
 }
 }
 return true

 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 /*******************************************************************************************
 							Function to check for isNumeric with only 1 dot(.) OnClick Event
 *******************************************************************************************/
 
 
 function isNumericAndDotOnClick(control,ch1)
 {
 	//alert("inFun");
 	val=control.value
 	len=val.length;
 	if(val.length!=0)
 	{
 		   while(len>0)
 		   {
 				if((!(((val.charAt(len-1)>='0')&&(val.charAt(len-1)<='9'))||(val.charAt(len-1)=='.') )))
 				{
 					alert('Please enter numeric value only for ' + ch1)   
 					control.value='';
 					control.focus()
 					return false
 		   		}
 				len--;
 			}
 	}
 	return true
 }//end of isNumericOnClick
 
 
 function chkBalAmt(control,ch1)
 {
 	alert("bal"+document.frm.iBalAmt.value);
 	
 	if( parseFloat(document.frm.chk_amt.value) > parseFloat(document.frm.iBalAmt.value ) )
 	{
 		alert("Cheque / DD Amount is Greater Than Balance Amount");
 		document.frm.chk_amt.value="";
 		document.frm.chk_amt.focus();
 		return false;	
 	}
 	else
 	{
 		return true;
 	}
 }//end of chkBalAmt
 
 
 
 
 
 function fun4()
 	{
 		var flag=0;
 		for (i=1;i<11;i++)
 		{
 			str="document.frm.Rem"+i;
 			rem=eval(str);
 			
 			str="document.frm.Dr"+i;
 			dr=eval(str);
 			
 			str="document.frm.Cr"+i;
 			cr=eval(str);
 				
 			
 			if (rem.value!="")
 				
 				{
 					flag=1;
 					//alert("here");
 					if ((cr.value!="")|| (dr.value!=""))
 					{
 						//alert("here1");	
 						
 						continue;
 					}	
 					else
 					{	
 						alert("Plz Enter Debit Or Credit Amount");
 						rem.focus();
 						return false;
 					}
 						
 				}
 			
 		}//for
 		
 		for (i=1;i<11;i++)
 			{
 				str="document.frm.Rem"+i;
 				rem=eval(str);
 			
 				str="document.frm.Dr"+i;
 				dr=eval(str);
 			
 				str="document.frm.Cr"+i;
 				cr=eval(str);
 				
 				if ((cr.value!="")||(dr.value!=""))
 					{
 						if(rem.value=="")
 							{
 								alert("Plz Enter Remarks");				
 								rem.focus();
 								return false;
 							}
 							else
 							{
 								//Dr , CR ,Remarks all are Empty OK
 							}
 					}
 				
 			}//for
 			//frm.submit();
 			if (flag==1)
 			{
 				return true;	
 				 
 				
 				
 			}
 			else
 			{
 				alert("Plz Enter At Least One Calclulation");
 				return false;
 			}
 	}	// end of fun4()	
 

//----------------------------------------------------------------------------------------------------------------------------

function fromtodate(sF,sT)
{
	
	sFrom=sF.value;
	sTo=sT.value;
	//alert(sFrom);
	
	index=sFrom.indexOf('-');
	df=sFrom.substring(0,index);
	//alert(df);
	
	sFrom=sFrom.substring(index+1,sFrom.length);
	//alert(sFrom);
	
	index=sFrom.indexOf('-');
	mf=sFrom.substring(0,index);
	//alert(mf);
	
	yf=sFrom.substring(index+1,sFrom.length);
	//alert(yf);
	
	strfrom=mf+" "+df+","+yf;
	//alert("From :"+strfrom);
	//alert("to");
	
	
	index=sTo.indexOf('-');
	dt=sTo.substring(0,index);
	//alert(dt);
	
	sTo=sTo.substring(index+1,sTo.length);
	//alert(sTo);
	
	index=sTo.indexOf('-');
	mt=sTo.substring(0,index);
	//alert(mt);
	
	yt=sTo.substring(index+1,sTo.length);
	//alert(yt);
	
	
	strto=mt+" "+dt+","+yt;
	//alert("To: "+strto);
	
	fromd=new Date(strfrom);
	tod=new Date(strto);
	
	if (fromd>tod )
	{
		//alert("LESS");
		alert("To Date is Less Than From Date ");
		return false;
		
	}
	else
	{
		return true;
		//alert("ok");
	}
	
}

//-------------------------------------------------------------------------------------------------------------------------------------------------



function LessSysdate(sF)
{
	
	
	alert(str);
	
	sFrom=sF.value;
	/*//sTo=sT.value;
	//alert(sFrom);
	
	index=sFrom.indexOf('/');
	df=sFrom.substring(0,index);
	//alert(df);
	
	sFrom=sFrom.substring(index+1,sFrom.length);
	//alert(sFrom);
	
	index=sFrom.indexOf('/');
	mf=sFrom.substring(0,index);
	//alert(mf);
	
	yf=sFrom.substring(index+1,sFrom.length);
	//alert(yf);
	
	strfrom=mf+" "+df+","+yf;
	//alert("From :"+strfrom);
	
	//alert("to");
	
	
/*	index=sTo.indexOf('-');
	dt=sTo.substring(0,index);
	//alert(dt);
	
	sTo=sTo.substring(index+1,sTo.length);
	//alert(sTo);
	
	index=sTo.indexOf('-');
	mt=sTo.substring(0,index);
	//alert(mt);
	
	yt=sTo.substring(index+1,sTo.length);
	//alert(yt);
	
	
	strto=mt+" "+dt+","+yt;
	alert("To: "+strto);
	*/
	fromd=new Date(sFrom);
	
//	alert(fromd);
	tod=new Date();
	
	//alert(fromd);
	//alert(tod);
	//alert(fromd.getDate()+'-'+fromd.getMonth()+'-'+fromd.getFullYear());
	//alert(tod.getDate()+'-'+tod.getMonth()+'-'+tod.getFullYear());
	//alert(fromd.getDate()+'<'+tod.getDate());
	
	//if ((parseInt(fromd.getDate(),10)<parseInt(tod.getDate(),10))&&(parseInt(fromd.getMonth(),10)>parseInt(tod.getMonth(),10)||parseInt(fromd.getMonth(),10)==parseInt(tod.getMonth(),10))&&(parseInt(fromd.getFullYear(),10)>parseInt(tod.getFullYear(),10)||parseInt(fromd.getFullYear(),10)== parseInt(tod.getFullYear(),10)) )
	if(fromd<tod)
	{
		//alert("ok here");
		//alert("From Date is Less Than To Date ");
		alert(ch1+" is Less Than Todays Date ");
		return false;
		
	}
	else
	{
		//;
		//return true;
		//lert("here");
		//alert("ok");
	}
}


//--------------------------------------------------------------------------------------------------------------------------------------/-------------------------------------------------------------------

function ColdWarmHotClosed()
{
	cold=document.frm.targetcold.value;
	
	warm=document.frm.targetwarm.value;
	
	hot=document.frm.targethot.value;
	
	closed1=document.frm.targetclosed.value; 
	
	
	//alert(cold);	
	//alert(warm);
	
	if (parseInt(cold,10)<parseInt(warm,10) )
	{
		alert("No Of Warm Suspects are Greater Than Cold Suspects");
		return false;
	}
	//alert(warm);
	//alert(hot);
	
	if (parseInt(warm,10)<parseInt(hot,10) )
	{
		alert("No Of Hot Suspects are Greater Than Warm Suspects");
		return false;
	}
	//alert(hot);
	//alert(closed1);
	if (parseInt(hot,10)<parseInt(closed1,10) )
	{
		alert("No Of Closed Suspects are Greater Than Hot Suspects");
		return false;
	}
	
	
	
}


//--------------------------------------------------------------------------------------------------------------------------------------/--------------------------------------------------------------------



//--------------------------------------------------------------------------------------------------------------------------------------/-------------------------------------------------------------------
//Chek Text Area Length UpTo 200

function ChkTextAreaLength200(control,ch1)
{
	val=control.value;
	len=val.length;
	//alert(len);
	if (len >200 )
		{	
			alert(ch1+'  Can Not Be More Than 200 Characters');
			return false;
		}
	else
		return true;
	
	
}


//--------------------------------------------------------------------------------------------------------------------------------------/--------------------------------------------------------------------

//--------------------------------------------------------------------------------------------------------------------------------------/-------------------------------------------------------------------
//Chek Text Area Length UpTo 1024

function ChkTextAreaLength1024(control,ch1)
{
	val=control.value;
	len=val.length;
	//alert(len);
	if (len >1024 )
		{	
			alert(ch1+'  Can Not Be More Than 1024 Characters');
			return false;
		}
	else
		return true;
	
	
}


//--------------------------------------------------------------------------------------------------------------------------------------/--------------------------------------------------------------------

//--------------------------------------------------------------------------------------------------------------------------------------/-------------------------------------------------------------------
//

function ChkEmptyCheckbox()
{
	var flag=0;
	
		if (document.frm.prospect[0].checked==true) 
		{
				//alert("in loop");
				for (i=0;i<6;i++)
				{
					//	alert("for loop");
						if (document.frm.yes_prospect[i].checked==true)
						{
							//alert("if");
							flag=1;
						}
				}
		
				if(flag==1)
				{
					//alert(flag);
					return true;
				}
				else
				{
					alert("Please Select Atleast One Product Type");
					return false; 
				}
	
		}	
		
				
		
}


//--------------------------------------------------------------------------------------------------------------------------------------/--------------------------------------------------------------------
function showmsg(msg)
{
	window.status = msg;
}