/**
 * File Name: common.js
 * @version : 1.0
 * @author : Pratik Gandhi
 * File Description : News Print Common Java Script 
 * 										file used to check the common validation  
 *										on text boxes of any form
 * Date of Creation :10/12/2000
 * Last Updated#Reason:02/01/2001#Update for Display Field value
 * Methods :-  removeblank(field) 
 *			 ->Used to remove the extra spaces from the text box enter by user.
 * 			   check_Detail()
 *				->Used to check the Number and blank field from the
 *  			  	  Roll received transaction Detail form
 *		  	   check_DetailPreference()
 *				->Used to check the Number and blank field from the
 *  			  Roll received transaction Detail form
 * 
 */

 //Validation rule.//
 // B- Field Can not be Blank
 // S- Field Can not enter any Special Character.
 // E- Field is an E-mail Field
 // N- Field can Enter only Numeric.
 // C- Field can Enter only Character.
 // D- Date Field. 
 // P- Space not Allowed.
 // R - Field can't Enter Numeric value.

/*Method common is used to check the following detail from the any form
    1> Check the validation as per given in the form
 		2> Check the size of control box
 		Following Validation is to be done on any Control of any form
 		 	B - Field Can not be Blank
	 		S - Field Can not enter any Special Character.
 			A - Field Can be Only Alpha Numberic Field and can contain Space
 			E - Field is an E-mail Field
  			N - Field can Enter only Numeric.
  			C - Field can Enter only Character.
			D - Field is a Date Field
			F - Field is an Float Datatype Field
*/ 		
function common(formIndex,obj_ary,obj_chk,obj_size)
{
	//alert(formIndex)
	//alert("General "  + obj_ary)
	//alert(obj_chk)
	//alert(obj_size)
for(i=0;i<obj_ary.length;i++)
 {//for loop of object array loop
   		var display=obj_ary[i];
   			//alert(display)
			var idx=display.indexOf('|');
			//alert(idx)
			//Retrieve the Display Value of Control box if specified
			if(idx!=-1) 
			 {
			 	  display=display.substring(idx+1,display.length);
			 	  //alert(display + "---display")
				  obj_ary[i]=obj_ary[i].substring(0,idx);
				  //alert(obj_ary[i])
			 }
	   		var s1=document.forms[formIndex].elements[obj_ary[i]];
			 //check for sizefield
			 //alert(obj_ary[i])
			 //alert(s1)
			 	if(!sizeField(s1,obj_size[i],display))
					return false;
   	 	 	
   	 	 	for(var k=0;k<obj_chk[i].length;k++)
   	 	 	{//access list for loop
   	 	 	  var chk=obj_chk[i].substring(k,k+1);
   	 	 	  //check for Blank Condition
   	 	 	  //alert("chk->" + chk)
   	 	 	  if(chk=='b' || chk=='B')
   	 	 	   {
   	 	 		//	alert("blank" + s1)	
		 	 	   removeblank(s1);
   	 	 	   	  if(!blankField(s1,display))
   	 	 	   	  {
   	 	 	   	 // alert("blank")
					//alert(blankField(s1,display))   	 	 	   	  
   	 	 	   	      return false;
   	 	 	   	  }
   	 	 	   }//End of Blank Field Checking Condition
	 	 	  
			 //check for Number Field
   	 	 	   else if(chk=='n' || chk=='N')
   	 	 	   {
   	 	 	   	  if(!numberField(s1,display))
   	 	 	   	    return false;
   	 	 	   }//End of Number Field Checking Condition
   	 	 	   //check for Float Field
   	 	 	   else if(chk=='f' || chk=='F' )
   	 	 	   {
   	 	 	   	  if(!floatField(s1,display))
   	 	 	   	    return false;
   	 	 	   }//End of Float Field Checking Condition
   	 	 	   //check for Character Field
   	 	 	   else if(chk=='c' || chk=='C')
   	 	 	   {
   	 	 	   	  if(!charField(s1,display))
   	 	 	   	    return false;
   	 	     }//End of Character Field Checking Condition
   	 	     
  	 	 	   //check for Character Field that are non numeric
   	 	 	   else if(chk=='r' || chk=='R')
   	 	 	   {
   	 	 	   	  if(!nonNumericField(s1,display))
   	 	 	   	    return false;
   	 	     }//End of Character Field Checking Condition

   	 	     
   	 	     //check for Date Field
   	 	     else if(chk=='d' || chk=='D')
   	 	 	   {
   	 	 	   	  if(!isValidDate(s1))
   	 	 	   	    {    return false;}
   	 	 	   	    
   	 	 	   }//End of Character Field Checking Condition
   	 	 	   //check for E-mail Field
   	 	 	   else if(chk=='e' || chk=='E')
   	 	 	   {
   	 	 	   	  if(!emailField(s1,display))
   	 	 	   	    return false;
   	 	 	   }//End of Email Field Checking Condition
  	 	 	   //check for Special Characters
  	 	 	   else if(chk=='z' || chk=='Z')
   	 	 	   {
   	 	 	   	  if(!checkSpace(s1,display))
   	 	 	   	    return false;
   	 	 	   }
  	 	 	   else if(chk=='s' || chk=='S')
   	 	 	   {
   	 	 	   	  if(!specialField(s1,display))
   	 	 	   	    return false;
   	 	 	   }//End of Special Character Checking Condition
   	 	 	   
   	 	 	   else if(chk=='q' || chk=='Q')
   	 	 	   {
   	 	 	   	  if(!allowSpace(s1,display))
   	 	 	   	    return false;
   	 	 	   }//End of Special Character Checking Condition
   	 	 	   
 	 	       //check for Alphanumeric Characters
 	 	       else if(chk=='a' || chk=='A')
   	 	 	   {
   	 	 	   	  if(!nameField(s1,display))
   	 	 	   	    return false;
   	 	 	   }//End of Alphanumeric Checking Condition
  		 	//check for Space
 	 	       else if(chk=='p' || chk=='P')
   	 	 	   {
   	 	 	   	  if(!spaceField(s1,display))
   	 	 	   	    return false;
   	 	 	   }//End of Space Checking Condition
   	 	 	}//End of For loop for separting each Checking- access list
//   	 	 }//End of If condition for matching object
//   	}//End of for loop of elements of form
 }//End of for loop of passing array objects
 
return true;
}//End of function


//Function specialField is used check weather the field
//contains any Special Characters or not.
function specialField(formCtrl,display)
{
 var str = formCtrl.value;
 //alert(str)
	for(x = 1; x <= str.length; x++)
    {
		if((str.charAt(x) == "~") || (str.charAt(x) == "`")  || (str.charAt(x) == "#") || 
			(str.charAt(x) == "$") || (str.charAt(x) == "%") || (str.charAt(x) == "^") || 
			(str.charAt(x) == "&") || (str.charAt(x) == "*") || (str.charAt(x) == "(") || 
			(str.charAt(x) == ")") || (str.charAt(x) == "+") || (str.charAt(x) == "?") || 
			(str.charAt(x) == "<") || (str.charAt(x) == ">") || (str.charAt(x) == "/") || 
			(str.charAt(x) == "|") || (str.charAt(x) == "{") || (str.charAt(x) == "}") || 
			(str.charAt(x) == "[") || (str.charAt(x) == "]") || (str.charAt(x) == " ") || 
			(str.charAt(x) == "'") || (str.charAt(x) == ".") ||(str.charAt(x) == "\"") || (str.charAt(x) == "@"))
		{
			alert("Special Characters are not allowed")
			formCtrl.select();
			formCtrl.focus();
			return false;
		}
	}
  return true;
}//End of specialField function

//*************************************************************************************
//Function specialField is used check weather the field
//contains any Special Characters or not. This is the Value Passed
function specialFieldCheck(str1,display)
{
 var str = str1;
 //alert(str)
	for(x = 1; x <= str.length; x++)
    {
		if((str.charAt(x) == "~") || (str.charAt(x) == "`")  || (str.charAt(x) == "#") || 
			(str.charAt(x) == "$") || (str.charAt(x) == "%") || (str.charAt(x) == "^") || 
			(str.charAt(x) == "&") || (str.charAt(x) == "*") || (str.charAt(x) == "(") || 
			(str.charAt(x) == ")") || (str.charAt(x) == "+") || (str.charAt(x) == "?") || 
			(str.charAt(x) == "<") || (str.charAt(x) == ">") || (str.charAt(x) == "/") || 
			(str.charAt(x) == "|") || (str.charAt(x) == "{") || (str.charAt(x) == "}") || 
			(str.charAt(x) == "[") || (str.charAt(x) == "]") || (str.charAt(x) == " ") || 
			(str.charAt(x) == "'") || (str.charAt(x) == ".") ||(str.charAt(x) == "\"") || (str.charAt(x) == "@"))
		{
			
			alert("Special Characters are not allowed")
			return false;
		}
	}
  return true;
}//End of specialField function


//function charField is used to check that field
//should contain only character.
function charFieldValue(str1,display)
{
//alert("char")
 var str = str1;
	for(x = 1; x <= str.length; x++)
    {
		if((str.charAt(x) == "~") || (str.charAt(x) == "`")  || (str.charAt(x) == "#") || 
			(str.charAt(x) == "$") || (str.charAt(x) == "%") || (str.charAt(x) == "^") || 
			(str.charAt(x) == "&") || (str.charAt(x) == "*") || (str.charAt(x) == "(") || 
			(str.charAt(x) == ")") || (str.charAt(x) == "+") || (str.charAt(x) == "?") || 
			(str.charAt(x) == "<") || (str.charAt(x) == ">") || (str.charAt(x) == "/") || 
			(str.charAt(x) == "|") || (str.charAt(x) == "{") || (str.charAt(x) == "}") || 
			(str.charAt(x) == "[") || (str.charAt(x) == "]") || (str.charAt(x) == "'") || 
			(str.charAt(x) == "@"))
		{
			alert("Special Characters are not allowed")
			return false;
		}
	}
  return true;
}//end of charField method
//****************************************************************************************
//*****************************************************
//function blakField used to check whether the field is blank or not
function blankFieldCheck(str1,display)
{
//alert(formCtrl.value.length+' length');
//alert("display" + display + formCtrl.value)
//alert(formCtrl.value.length)	
	if(str1.length == 0)
	{
		alert(display+' should not be blank');
		return false;
	}
	return true; 
}//End of blankField method

//function numberField is used to check that field
//should contain only float type .
function floatFieldCheck(str1,display)
{
	str = str1;
	
	len=str.length;
  //alert(str.length); 
  flag=1
  for(x=0;x<len;x++)
  {
  	//alert(str.charAt(i)); 
  	if(!(str.charAt(x)=='.' || !isNaN(str.charAt(x))))
  	  flag=0; 
  }
	if(flag)
		return true;
	else {
		alert('Not Valid Number Format' ); 
		return false;
	}	
}//End of floatField method
//*****************************************************
function allowSpace(formCtrl,display)
{
 var str = formCtrl.value;
	for(x = 1; x <= str.length; x++)
    {
		if((str.charAt(x) == "~") || (str.charAt(x) == "`")  || (str.charAt(x) == "#") || 
			(str.charAt(x) == "$") || (str.charAt(x) == "%") || (str.charAt(x) == "^") || 
			(str.charAt(x) == "&") || (str.charAt(x) == "*") || (str.charAt(x) == "(") || 
			(str.charAt(x) == ")") || (str.charAt(x) == "+") || (str.charAt(x) == "?") || 
			(str.charAt(x) == "<") || (str.charAt(x) == ">") || (str.charAt(x) == ".") || 
			(str.charAt(x) == "|") || (str.charAt(x) == "{") || (str.charAt(x) == "}") || 
			(str.charAt(x) == "[") || (str.charAt(x) == "]") || (str.charAt(x) == ";") || 
			(str.charAt(x) == "\"") ||(str.charAt(x) == "'") ||(str.charAt(x) == "@"))
		{
			alert("Special Characters are not allowed")
			formCtrl.select();
			formCtrl.focus();
			return false;
		}
	}
  return true;
}//End of specialField function




//Function nonNumericField is used check weather the field
//contains any numeric value or not.
function nonNumericField(formCtrl,display)
{
 var str = formCtrl.value;
	for(x = 1; x <= str.length; x++)
    {
		if((str.charAt(x) == "1") || (str.charAt(x) == "2")  || (str.charAt(x) == "3") || 
			(str.charAt(x) == "4") || (str.charAt(x) == "5") || (str.charAt(x) == "6") || 
			(str.charAt(x) == "7") || (str.charAt(x) == "8") || (str.charAt(x) == "9") || 
			(str.charAt(x) == "0"))
		{
			//alert("Numbers are not allowed")
			alert(display+' can not contain numbers')
			formCtrl.select();
			formCtrl.focus();
			return false;
		}
	}
  return true;
}//End of nonNumericField function


		function checkSpace(formCtrl,display)
		{
			//alert("space")
			//var str = document.frmincidentdescription.elements(formCtrl).value
			var str = formCtrl.value;
			bln = 0
			for(x = 1; x <= str.length; x++)
			{
				if(str.charAt(x) == " ")
				{
					bln = 1
					if(x>50 && str.length > 51)
					{
						//alert("inner")
						alert("Insert valid information in" + display)
						formCtrl.select();
						//formCtrl.focus();
						return false;
					}
					else
					{
						return true
					}
				}
				else
				{
					//if(str.length > 51)
					//{
						bln = 0
					//}
					//alert(bln)
					//alert(display)
				}
			}
			if(bln == 0)
			{
					//alert("alert")
					//alert(parseInt(str.length))
					if(parseInt(str.length) > 51)
					{
						//alert("alert")
						alert("Insert valid information in" + display)
						formCtrl.select();
						//formCtrl.focus();
						return false;
					}

			}
			return true;
		}



//Function nameField is used check that field should
//contains only alphanumeric characters and blank space
function nameField(formCtrl,display)
{
 var str = formCtrl.value;
	for(x = 1; x <= str.length; x++)
    {
		if((str.charAt(x) == "~") || (str.charAt(x) == "`")  || (str.charAt(x) == "#") || 
			(str.charAt(x) == "$") || (str.charAt(x) == "%") || (str.charAt(x) == "^") || 
			(str.charAt(x) == "&") || (str.charAt(x) == "*") || (str.charAt(x) == "(") || 
			(str.charAt(x) == ")") || (str.charAt(x) == "+") || (str.charAt(x) == "?") || 
			(str.charAt(x) == "<") || (str.charAt(x) == ">") || (str.charAt(x) == "/") || 
			(str.charAt(x) == "|") || (str.charAt(x) == "{") || (str.charAt(x) == "}") || 
			(str.charAt(x) == "[") || (str.charAt(x) == "]") || 
			(str.charAt(x) == "@"))
		{
			alert("Special Characters are not allowed")
			formCtrl.select();
			formCtrl.focus();
			return false;
		}
	}
  return true;
}//end of nameField method

//Function emailField is used check the validation of normal email id
function emailField(formCtrl)
{
 var str = formCtrl.value;
 var len=str.length;
 var apos=str.indexOf('@');	
 var dotpos=str.lastIndexOf('.');	
 var lastpos=str.length-1;
  if(len>0)
  { //if length condition
  if(apos<1 || dotpos-apos<2 || lastpos-dotpos<2)
	{
		alert("Enter valid email address");
		formCtrl.select();
		formCtrl.focus();
		return false;
	}
	for(x = 1; x <= str.length; x++)
    {
		if((str.charAt(x) == "~") || (str.charAt(x) == "`")  || (str.charAt(x) == "#") || 
			(str.charAt(x) == "$") || (str.charAt(x) == "%") || (str.charAt(x) == "^") || 
			(str.charAt(x) == "&") || (str.charAt(x) == "*") || (str.charAt(x) == "(") || 
			(str.charAt(x) == ")") || (str.charAt(x) == "+") || (str.charAt(x) == "?") || 
			(str.charAt(x) == "<") || (str.charAt(x) == ">") || (str.charAt(x) == "/") || 
			(str.charAt(x) == "|") || (str.charAt(x) == "{") || (str.charAt(x) == "}") || 
			(str.charAt(x) == "\"") || (str.charAt(x) == "'") || (str.charAt(x) == "`") || 
			(str.charAt(x) == "[") || (str.charAt(x) == "]") || (str.charAt(x) == " "))
		 {
			alert("Enter valid email address")
			formCtrl.select();
			formCtrl.focus();
			return false;
		}//End of if condition
	}//End of for loop
}//end of length if condition
return true;
}	//end of emailField method

//function blakField used to check whether the field is blank or not
function blankField(formCtrl,display)
{
//alert(formCtrl.value.length+' length');
//alert("display" + display + formCtrl.value)
//alert(formCtrl.value.length)
if(formCtrl.value.length == 0)
{
	alert(display+' should not be blank');
	formCtrl.select();
	formCtrl.focus();
	return false;
}
return true; 
}//End of blankField method


function spaceField(formCtrl,display)
{
str=formCtrl.value;
if(str.indexOf(' ')!=-1)
 {
	alert(display+' Can not Contain Space');
	formCtrl.select();
	formCtrl.focus();
	return false;
 }
	return true; 
}//End of spaceField method


//function numberField is used to check that field
//should contain only number .
function numberField(formCtrl,display)
{
if(isNaN(formCtrl.value))
 {
	alert(display+' contains only Numbers ');
	formCtrl.select();
	formCtrl.focus();
	return false;
 }
return true; 
}//end of numberField method


//function charField is used to check that field
//should contain only character.
function charField(formCtrl,display)
{
//alert("char")
 var str = formCtrl.value;
	for(x = 1; x <= str.length; x++)
    {
		if((str.charAt(x) == "~") || (str.charAt(x) == "`")  || (str.charAt(x) == "#") || 
			(str.charAt(x) == "$") || (str.charAt(x) == "%") || (str.charAt(x) == "^") || 
			(str.charAt(x) == "&") || (str.charAt(x) == "*") || (str.charAt(x) == "(") || 
			(str.charAt(x) == ")") || (str.charAt(x) == "+") || (str.charAt(x) == "?") || 
			(str.charAt(x) == "<") || (str.charAt(x) == ">") || (str.charAt(x) == "/") || 
			(str.charAt(x) == "|") || (str.charAt(x) == "{") || (str.charAt(x) == "}") || 
			(str.charAt(x) == "[") || (str.charAt(x) == "]") || (str.charAt(x) == "'") || 
			(str.charAt(x) == "@"))
		{
			alert("Special Characters are not allowed")
			formCtrl.select();
			formCtrl.focus();
			return false;
		}
	}
  return true;
}//end of charField method

//function numberField is used to check that field  length
//should satisfies it's maximum length 
function sizeField(formCtrl,size,display)
{
	//alert(formCtrl)
	//alert(formCtrl.value)
	str=formCtrl.value;
	
    if(str.length>size)
 	{	
 		alert('The Maximum Limit of '+display+' is '+size+' characters' ); 
		formCtrl.select();
		formCtrl.focus();
  		return false;
  	}
  	
  	return true;
}//end of sizeField method

//function numberField is used to check that field
//should contain only float type .
function floatField(formCtrl,display)
{
	str = formCtrl.value;
	len=str.length;
  //alert(str.length); 
  flag=1
  for(x=0;x<len;x++)
  {
  	//alert(str.charAt(i)); 
  	if(!(str.charAt(x)=='.' || !isNaN(str.charAt(x))))
  	  flag=0; 
  }
	if(flag)
		return true;
	else {
		alert('Not Valid Number Format' ); 
		formCtrl.select();
		formCtrl.focus();
		return false;
	}	
}//End of floatField method

//function numberField is used to check that field

function isValidDate(control) 
{ 
	dateStr=control.value
	var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{2}|\d{4})$/; 
	
	if(dateStr.length == 0 )
		return true;

	var matchArray = dateStr.match(datePat); // is the format ok? 
	
	if (matchArray == null) 
	{ 
		alert("Please enter valid date") 
		control.select();
		control.focus()
		return false; 
	} 
	
	month = matchArray[1]; // parse date into variables 
	day = matchArray[3]; 
	year = matchArray[4]; 

	if (month < 1 || month > 12)
	{ // check month range 
		alert("Please enter valid date"); 
		control.select();
		control.focus()
		return false; 
	} 

	if (day < 1 || day > 31)
	{
		alert("Please enter valid date"); 
		control.select();
		control.focus()
		return false; 
	} 
	
	if ((month==4 || month==6 || month==9 || month==11) && day==31) 
	{
		alert("Month "+month+" doesn't have 31 days!"); 
		control.select();
		control.focus()
		return false; 
	} 
	
	if (month == 2)
	 { // check for february 29th 
		var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)); 
		
		if (day>29 || (day==29 && !isleap)) 
		{ 
			alert("February " + year + " doesn't have " + day + " days!"); 
			control.select();
			control.focus()
			return false; 
		} 
	}

	// NOTE : -
	// If the year is of 2 digit then remove following comments
	/*
	if(year > 99 ){//check date for no of degits 
	alert("Year must be of 2 digits");
	return false;
	}
	*/

	if (year < 1900  || year > 9999 )
	{
		alert("Please enter valid date");
		control.select();
		control.focus()
		return false;
	}
 
	return true; // date is valid 
} 
//End Date Validation Function







function removeblank(field)
{
//alert(field.value);
//var j = field.value.length;
//alert(j);

var newstr=field.value;
var j=newstr.length;
    for(var i=0;i<j;i++)
      {
      if(i==0 && newstr.charAt(0)==' ')
          {
	          newstr=newstr.substring(1,j+1);
	          j=newstr.length;
	          i--;
         	}
       }
		field.value=newstr;
		j=newstr.length;
		for(var k=0;k<j;k++)
			{
				var m=k+1;
				if(newstr.charAt(k)==newstr.charAt(k+1)&&newstr.charAt(k+1)==' ')
					{
						newstr=newstr.substring(0,m-1) + newstr.substring(m,j+1);
						j=newstr.length;
						k--;	
					}
			}
field.value=newstr;

}


function DateComparison(formindex,d1,d2)
{
	return 1;
	var sdate =document.forms[formindex].elements[d2].value;
	var fdate= document.forms[formindex].elements[d1].value;

	fyy = fdate.substring(6,10);
	fmm = fdate.substring(3,5);
	fdd = fdate.substring(0,2);	


	syy = sdate.substring(6,10);
	smm = sdate.substring(3,5);
	sdd = sdate.substring(0,2);	


	if(fyy>syy)
		{
			return 1;
		}

	else if(fyy < syy)
				{
				return 2;
				}
	else
	{
		if(fmm>smm)
			{
				return 1;
			}		
		else if(fmm < smm)
			{
				return 2;
			}
		else
		{
			if(fdd > sdd)
				{
					return 1;
				}
			else if(fdd < sdd )
				{
					return 2;
				}
			else
				{
					return 0;
				}	
		}
	}	
}




function InitList(sName)
{
	var len = sName.options.length;
	if (len < 1)
	    return;
		
	for (i=0; i<=len; i++)
	{
	
			sName.options[0]=null;
	}
	
}

function fillSkill(sName, sObj,sHid)
{
  
	index = 0;
	var opt;
	var selcat;
	var s;
	var sId;	
	var objstr;
	InitList(sName);
	
	sObjIndex = sObj.options.selectedIndex;
	if(sObjIndex !=-1) {
	sId = sObj.options[sObjIndex].value;
	if ((sId!=0)|| sId=="")
	{
	if (sHid=="M") {
		objstr="document.forms[0].t1";
	}
	if (sHid=="O"){
		objstr="document.forms[0].t1" + sId;
		}
	s = (eval(objstr).value);

	do
		{
			c = s.indexOf("#",0);
			s = s.substring(c+1);
			cat = s.substring(0,s.indexOf("#",1));
			catId = cat.substring(0,cat.indexOf("_",1));
			cat = cat.substring(cat.indexOf("_",1)+1);
			skill = cat.substring(0,cat.indexOf("_",1));
			skilldesc = cat.substring(cat.indexOf("_",1)+1);
			if (sHid=="M"){
			//opt	= new Option('(Select One )', 0);
			}
			if(sHid=="O"){
			opt	= new Option('(Select a Object)', 0);
			}
			//sName.options[0] = opt;	


			if (catId == sId)
			{	
				selcat = catId;	
				opt	= new Option(skilldesc,skill);
				sName.options[index] = opt;				
				index++;
			}

			if (selcat != null) {
				if (selcat != sId) {
					c = -1;
				}
			}
		
		}
		

		while (c != -1);
		//sName.options[0].selected = true;		
	
		//history.go(1);
	}	
			if (sHid=="M"){
			//opt	= new Option('N.A', 1);
			}
			if(sHid=="O"){
			opt	= new Option('N.A', 31);
			}
			//sName.options[index] = opt;	

 }
}

function checkComboTotal(formIndex,cmb)
{
	var idx=cmb.indexOf('|');
	var display=cmb;
	if(idx!=-1) 
	{
	   display=display.substring(idx+1);
	   cmb=cmb.substring(0,idx);
	}
	var obj=document.forms[formIndex].elements[cmb];
	if(obj.length==0)
	{
		alert(display+'  Should not be Null ');
		return false;
	}
	return true;
}



function CheckAll(obj_name)
{
	for (var i=0;i<document.forms[0].elements.length;i++)
	{
		var e = document.forms[0].elements[i];
		if ((e.name == obj_name) && (e.type=='checkbox') && (e.name != 'allbox'))
		{
		  if (!e.checked)
		    e.checked=true
		  else
		      e.checked=false
		}//end of if    
	}//end of for
}//end of function



function dateGreater(dateFrom,dateTo)
{



var From = new Date(dateFrom); 
var day = From.getYear();
var month = From.getMonth();


var FromDate = new Date(From.getMonth() + "-" + From.getDate() + "-" + From.getYear());


var To = new Date(dateTo);

var ToDate = new Date(To.getYear(),To.getMonth(),To.getDate(),0,0,0);

if ( FromDate > ToDate ){ alert("To Date should be Greater than From Date");return false;}
return true;
}





/*******************************************************************************************
		Function to convert the number in text format
******************************************************************************************/

function convertText(num,cur)
{
 i1=num.indexOf(".");
 var pon="";
 if(i1!=-1)
 {
   pon=num.substring(i1+1);
   num=num.substring(0,i1);
 }
 var str="";
 var	des1=new Array('',' One',' Two',' Three',' Four',' Five',' Six',' Seven',' Eight',' Nine');
 var	des2=new Array('',' Eleven',' Tweleve',' Thirteen',' Fourteen',' Fifteen',' Sixteen',' Seventeen',' Eighteen ',' Nineteen ');
 var	des3=new Array('',' Ten',' Twenty',' Thirty',' Fourty',' Fifty',' Sixty',' Seventy',' Eighty',' Ninety');
 var	des4=new Array(' Ten',' Hundread',' Thousand',' Lakh',' Crore');
 
var flag=false;

if (parseInt(num)==0)
str="Zero"
else
{
for(i=1;i<=num.length;i++)
 {
 	digit=num.substring(i-1,i);
 	if(flag)
 	{
 		flag=false;
 		if (num.length-i==2 && digit!="0")
			str=str+des4[1]; 	
		if (num.length-i==3 && digit!="0")
			str=str+des4[2]; 	
		if (num.length-i==5 && digit!="0")
   			str=str+des4[3]; 	
	   if (num.length-i==7 && digit!="0")
			str=str+des4[4]; 	
 		continue;
 	}	
   if (num.length-i==1 || num.length-i==4 || num.length-i==6 || num.length-i==8 )
   {
		if(digit=="1")
		{
			if(num.charAt(i)=="0") 
			{
			  str=str+des3[digit]; 	
			}
			else
			{
			str=str+des2[num.charAt(i)];
			flag=true;
			continue;
			}
		}	
		else
			str=str+des3[digit]; 	
			
	}	
	else
		str=str+des1[digit]; 	

   if (num.length-i==2 && digit!="0")
		str=str+des4[1]; 	
   if (num.length-i==3 && digit!="0")
		str=str+des4[2]; 	
   if (num.length-i==5 && digit!="0")
   		str=str+des4[3]; 	
   if (num.length-i==7 && digit!="0")
		str=str+des4[4]; 	

 }//end of for
 
 }
 
 
  if(i1!=-1)
  {
   str=cur+" "+str+" and " + convertText(pon,'');
  } 
  else
   str=cur+" "+str;
  return str;

}//end of function
//***********************************************************************************************





