function submit(frm)
{
	frm.submit();
}

function submitchk(frm)
{

	if (verify_All(frm))
	{
		frm.submit();
	}
}


function clear(frm)
{
	frm.reset();
}


//--------------------------------------------------------
//This function was used to find out what are all the fealds
//empty in the pirticular formgiven and displayes all the fields
//which are empty.this function is going to take form as an 
//argument.her we are going to pass the name of the form
//in which we want to find the null elements
//--------------------------------------------------------
function verify_All(f)
{
	var msg;
	var empty_fields="";
	//var invalid_field="";

//--------------------------------------------------------
//Find the number of elements in the form so as to check all
//the elements .in that elements find the text elements only
//--------------------------------------------------------

	for(var i=0;i<f.length;i++)
	{
		var e=f.elements[i];
		if(((e.type=="text") || (e.type=="textarea")|| (e.value=="") ) && !e.optional)
		{

//--------------------------------------------------------
//First check if the field is Empty.
//--------------------------------------------------------


			if((e.id=="mdr")&&(e.value=="")){
				continue;
			}

			if((e.id=="ABTA Number")&&(e.value=="")){
				continue;
			}


			if((e.value==null) || (e.value==""))
			{
				empty_fields+="\n     "+e.name;
				alert("Please Enter "+e.id);
				e.focus();
				return false;

			}
//--------------------------------------------------------
//check if the mail field is Valid or not.
//--------------------------------------------------------
			if((e.name=="txtemail")&&(e.value!=null)){
				var streMail=e.value;
				var count=0;
				var spaces=0;
				var dots=0;
				var len=streMail.length;
		
				for(j=0;j<len;j++)
				{	
					if(streMail.charAt(j)=="@")
					{
						count++;
					}	
					if(streMail.charAt(j)==".")
					{
						dots++;
					}	
					if(streMail.charAt(j)==" ")
					{
						spaces++;
					}	
				}

				if((count!=1 || dots==0 || spaces!=0))
				{
					alert("Enter the Valid "+e.id);
					e.select();
					e.focus();
					break;
				}
			} // if  mailTxt 

// Checking For Date

		if((e.id=="DOB")&&(e.value!=null)) 
		{
			if(!DateVerify(e))
			{
				e.focus();
				return false;
			}
		}

// checking Title , Intial and Name ,First Name and Last Name

  			if(((e.id=="Title")&&(e.value!=null))||((e.id=="Intial")&&(e.value!=null))||((e.name=="txttitle")&&(e.value!=null))||((e.name=="txtfname")&&(e.value!=null))||((e.name=="txtlname")&&(e.value!=null))){

			var str	   	
			s=e.value			//getting the value of the field
			str=""
			bag="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz "
			//defining the string which is having the intiger values and alphabetics

	//--------------------------------------------------------
	//For all the characters in the value we are going to check
	//wheter the character's are matching the character's in the string
	// decleared above  "bag"
	//--------------------------------------------------------
			for (l = 0; l < s.length; l++)
			{   
				c = s.charAt(l)
				if (bag.indexOf(c) == -1) 
					str=1
			}
			if(str==1)
			{
				alert("Enter the Valid "+e.id);
				e.select();
				e.focus();
				return false;
			}

		  }// end of title , Intial and Name ,First Name and Last Name  



  			if((e.id=="Name")&&(e.value!=null)){

			var str	   	
			s=e.value			//getting the value of the field
			str=""
			bag="'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz "
			//defining the string which is having the intiger values and alphabetics

	//--------------------------------------------------------
	//For all the characters in the value we are going to check
	//wheter the character's are matching the character's in the string
	// decleared above  "bag"
	//--------------------------------------------------------
			for (l = 0; l < s.length; l++)
			{   
				c = s.charAt(l)
				if (bag.indexOf(c) == -1) 
					str=1
			}
			if(str==1)
			{
				alert("Enter the Valid "+e.id);
				e.select();
				e.focus();
				return false;
			}

		  }// end of title , Intial and Name ,First Name and Last Name  


// checking for mdr

	/*if((e.id=="mdr")&&(e.value!=null)){
	

			var str	   	
			s=e.value			//getting the value of the field
			str=""
			bag="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 "
			//defining the string which is having the intiger values and alphabetics

	//--------------------------------------------------------
	//For all the characters in the value we are going to check
	//wheter the character's are matching the character's in the string
	// decleared above  "bag"
	//--------------------------------------------------------
			for (l = 0; l < s.length; l++)
			{   
				c = s.charAt(l)
				if (bag.indexOf(c) == -1) 
					str=1
			}
			if(str==1)
			{
				alert("Enter Valid "+e.id);
				e.select();
				e.focus();
				return false;
			}

		  }// end of mdr */ 

// checking for ABTA Registration number

// checking for ABTA Registration number

if((e.name=="txtRegistration")&&(e.value!=null)){
			var str	   	
			s=e.value			//getting the value of the field
			str=""
			bag="0123456789"
			//defining the string which is having the intiger values and alphabetics

	//--------------------------------------------------------
	//For all the characters in the value we are going to check
	//wheter the character's are matching the character's in the string
	// decleared above  "bag"
	//--------------------------------------------------------
			for (l = 0; l < s.length; l++)
			{   
				c = s.charAt(l)
				if (bag.indexOf(c) == -1) 
					str=1
			}
			if(str==1)
			{
				alert("Enter the Valid "+e.id);
				e.select();
				e.focus();
				return false;
			}

		  }// end of ABTA Registration 


// checking for ABTA Code

if((e.name=="txtABTACode")&&(e.value!=null)){


			var str	   	
			s=e.value			//getting the value of the field
			str=""
			bag="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
			//defining the string which is having the intiger values and alphabetics

	//--------------------------------------------------------
	//For all the characters in the value we are going to check
	//wheter the character's are matching the character's in the string
	// decleared above  "bag"
	//--------------------------------------------------------
			for (l = 0; l < s.length; l++)
			{   
				c = s.charAt(l)
				if (bag.indexOf(c) == -1) 
					str=1
			}
			if(str==1)
			{
				alert("Enter the Valid "+e.id);
				e.select();
				e.focus();
				return false;
			}

		  }// end of ABTA Code 
// checking address1, address2 and address3

  			if(((e.name=="txtadd1")&&(e.value!=null))||((e.name=="txtadd2")&&(e.value!=null))||((e.name=="txtadd3")&&(e.value!=null))){

			var str	   	
			s=e.value			//getting the value of the field
			str=""
			bag="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-/ "
			//defining the string which is having the intiger values and alphabetics

	//--------------------------------------------------------
	//For all the characters in the value we are going to check
	//wheter the character's are matching the character's in the string
	// decleared above  "bag"
	//--------------------------------------------------------
			for (l1 = 0; l1 < s.length; l1++)
			{   
				c = s.charAt(l1)
				if (bag.indexOf(c) == -1) 
					str=1
			}
			if(str==1)
			{
				alert("Enter Valid "+e.id);
				e.select();
				e.focus();
				return false;
			}

		  }// end of address1, address2 and address3 


// checking for telphone number

		if((e.name=="txtteleno")&&(e.value!=null)){

			var str	   	
			s=e.value			//getting the value of the field
			str=""
			bag="0123456789- "		//defining the string which is having the intiger values

	//--------------------------------------------------------
	//For all the characters in the value we are going to check
	//wheter the character's are matching the character's in the string
	// decleared above  "bag"
	//--------------------------------------------------------
			for (m = 0; m < s.length; m++)
			{   
				c = s.charAt(m)
				if (bag.indexOf(c) == -1) 
					str=1
			}
			if(str==1)
			{
					alert("Please Enter "+e.id);
					e.select();
					e.focus();
					return false;
			}

		  }//if  telephone txt

  			if((e.name=="txtpcode")&&(e.value!=null)||((e.name=="txtpcode")&&(e.value!=null))){

			var str	   	
			s=e.value			//getting the value of the field
			str=""
			bag="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789- "
			//defining the string which is having the intiger values and alphabetics

	//--------------------------------------------------------
	//For all the characters in the value we are going to check
	//wheter the character's are matching the character's in the string
	// decleared above  "bag"
	//--------------------------------------------------------
			for (l = 0; l < s.length; l++)
			{   
				c = s.charAt(l)
				if (bag.indexOf(c) == -1) 
					str=1
			}
			if(str==1)
			{
					empty_fields+="\n     "+e.name;
					break;
			}

		  }//if  pstalcode txt  

			

		} // main if
	} // for

	if((!empty_fields)) return true;


}

/************************************************/


//DATE VALIDATION

/************************************************/
//--------------------------------------------------------
// The function was used to verify whether the DATE was in
// the format of dd-mm-yyyy. The function is going to take 
// object as a parametere the object here was text field
//--------------------------------------------------------

function DateVerify(ob)
{
	var Date = ob.value;    // getting the value of the object
	var msg = "";
	var l = Date.length;		//finding the length of the string passed
	var cnt=0;
	if (l == 0)
	{
		return true;
	}

//--------------------------------------------------------
// checking wheter the given date has characters between 10 
// and 8 as date will be dd-mm-yyyy or d-m-yyyy.	
//--------------------------------------------------------
	if(l >10 || l < 8){
		msg += "Please Enter Valid Date in dd-mm-yyyy Format";
	}
	for(i = 0; i<l;i++)
	{
//--------------------------------------------------------
// checking the occruence of '-' and it must 2 and only 2 "-"
//--------------------------------------------------------

	 if(Date.charAt(i) == '/')
		cnt++;
	}
	if(cnt != 2){alert("Please enter Valid Date in dd/mm/yyyy Format");
		ob.focus();
	return false;}

//--------------------------------------------------------
// splitting the given date dd-mm-yyyy into DD ,MM,YYYY
//--------------------------------------------------------

	var DateM = Date.split("/");
	var Day = DateM[0];
	var month = DateM[1];
	var year = DateM[2];
	
//--------------------------------------------------------
// checking wheter the given year was having four characters 
// i.e. yyyy format
//--------------------------------------------------------
	
	if(year.length != 4)
	{
		msg = "Please Enter valid Date in dd-mm-yyyy Format";
	}
	var daylimit;	
	
//--------------------------------------------------------
// decleared a varible which is holding the no/. of day's 
// in a given month
//--------------------------------------------------------

	if(month == 1 || month == 3 || month == 5 || month == 7 || month == 8 ||month == 10 || month == 12)
		daylimit =  31;
	else if(month == 2)
		{ if ((year % 4) == 0) daylimit =  29;
		  else
		   daylimit = 28;
		}
	     else
		daylimit =  30;

//--------------------------------------------------------
// checking for the month which must be in between 1-12
//--------------------------------------------------------

	if(isNaN(month) || month == null || month > 12 || month < 1 )
		msg += "month: should be in range from 1 to 12 \n";

//------------------------------------------------------------------
// Days should be bebetween 0 and day limit of that particular month.
//------------------------------------------------------------------

	if(isNaN(Day) || Day == null || Day > daylimit || Day < 1 )
		msg += "Day: should be in range from 1 to " + daylimit + "\n";

	if(isNaN(year) || year == null )
		msg += "year " + year + "\n";

	if(msg != ""){
		alert("Invalid \n" + msg);
		ob.select();
		ob.focus();
		return false;
		     }
		return true; 
}
/************************************************/


//END DATE 




//--------------------------------------------------------
//This function was used to find out what are all the fealds
//empty in the pirticular formgiven and displayes all the fields
//which are empty.this function is going to take form as an 
//argument.her we are going to pass the name of the form
//in which we want to find the null elements
//--------------------------------------------------------
function verify_rates(f)
{
	var msg;
	var empty_rates="";

//--------------------------------------------------------
//Find the number of elements in the form so as to check all
//the elements .in that elements find the text elements only
//--------------------------------------------------------

	for(var i=0;i<f.length;i++)
	{
		var e=f.elements[i];
		if(((e.type=="text") || (e.value=="")) && !e.optional)
		{
//--------------------------------------------------------
//First check if the field is Empty.
//--------------------------------------------------------
			if((e.value==null) || (e.value==""))
			{
				empty_rates+="\n     "+e.name;
				break;

			}

// Change here with monohar
			if(!Validate_Float_52(e))
			{
				e.focus();
				return false;
			}

		} // main if
	} // for

 return true;

} //end of the function




/************************************************/


function Trim(ob)
{
var sTrmText=ob.value;
var bFirstTime = "T";
var sSpace = "";
var sCurrChar = "";
var sRtnString = "";

for(nI=0; nI<sTrmText.length;nI++) 
{
	sCurrChar=sTrmText.charAt(nI);
	if (sCurrChar==" ")
	{
		sSpace=sSpace+" ";
	}
	else
	{
		if (bFirstTime=="T")
		{
			sRtnString=sCurrChar;
			bFirstTime="F";
		}
		else
		{
			sRtnString=sRtnString+sSpace+sCurrChar;
		}
		sSpace="";
	}
}
ob.value=sRtnString
return sRtnString;
}
/************************************************/





/************************************************/
//--------------------------------------------------------
//this function is to verify wheter a given value is in  a specified format(5,2)  
//The function is going to take 
// object as a parameter the object here was text field
//--------------------------------------------------------

// MANOHAR HAS TO CHANGE THIS FUNCITON NAME

function Validate_Float_52(ob)
{	   
//--------------------------------------------------------
//calling the trim function which was in the same js file
//--------------------------------------------------------

		Trim(ob)
	   	var str	   	
	 	s=ob.value			//getting the value of the field
	 	str=""
		bag="0123456789."		//defining the string which is having the intiger values
		val=0;
//--------------------------------------------------------
//For all the characters in the value we are going to check
//wheter the character's are matching the character's in the string
// decleared above  "bag"
//--------------------------------------------------------
		
		for (i = 0; i < s.length; i++)
	    {   
        	c = s.charAt(i)
	        if (bag.indexOf(c) == -1) 
				str=1
//--------------------------------------------------------
//	finding the occurence of "." in the given string value
//--------------------------------------------------------
			if(c==".")
				val++
		}
		if(str==1)
		{
			alert("Please Enter Numbers only")
			ob.focus();
			return false
		}
//--------------------------------------------------------
//	If the occurence of the "." is more than one then we haveto 
//raise an alert,saying that is what done buelow in the if statement
//--------------------------------------------------------
		if(val>1)
		{
			alert("Please Enter only one decimal");
			ob.focus();
			return false
		}
//--------------------------------------------------------
//	If the number of chracters are more then 3 before decimal point then we haveto 
//raise an alert,saying that is what done below in the if statement
//--------------------------------------------------------

	arrayOfStrings = s.split(".") ;

	 if(arrayOfStrings.length == "1")
	 {      
		 if(arrayOfStrings[0].length > 3)
		 {
			alert("Maximum limit is 999.99")
			ob.focus();
			return false
		 }
	}
//--------------------------------------------------------
//	If the number of chracters are more then 2 after decimal point then we haveto 
//raise an alert,saying that is what done below in the if statement
//--------------------------------------------------------
	 if(arrayOfStrings.length == "2")
	 {      
		 if(arrayOfStrings[0].length > 3)
		 {
			alert("Maximum limit is 999 before decimal point")
			ob.focus();
			return false
		 }

		 if(arrayOfStrings[1].length > 2)
		 {
			alert("Maximum limit is 99 after decimal point")
			ob.focus();
			return false
		 }
	}
	   return true
}

/************************************************/

//--------------------------------------------------------
//This function is used to verify wheter the value in a given 
// text field was not NULL
//--------------------------------------------------------
function Validate_Null(ob)
{
if(ob.value=="")	//checking the value in the object to null
		{
			alert("PLEASE ENTER THE VALUE , THIS VALUE IS NECESSARY")
			ob.select();
			return false
		}
		return true
}
/************************************************/
