// common function for TextArea
	function textCounter(field, maxlimit, message) 
	{
		if (field.value.length>maxlimit)
		{
			alert (message);			
			return false;
		}
		else
		{
			return true;
		}
	}

//commom function for select checkbox with alert
function checkboxalertvalidation(objname,message,itemname)
{
	with (objname)	
	{ 
		var len, idno;
		len = objname.length;
		var mychk=document.getElementsByName(itemname);
		for (i=0; i<mychk.length; i++)
		{
			if (mychk[i].checked == false) {}
			else
			{
				idno = 1;
			}
		}
		if (idno != 1)
		{
		  if (message!="")
		  {
			alert(message);
			//objname.focus();
			//objname.select();
		  }
			return false;
		}
			ret = confirm('Are you sure?');
			if (ret)
			{
				return true;
			}
			else
			{
				for (i=0; i<=len-1; i++)
				{
					objname[i].checked = false;
				}
				return false;
			}
			return true;
	}
}



//commom function for select checkbox
function checkboxvalidation(objname,message)
{
	with (objname)	
	{
		var len, id;
		len = objname.length;
		for (i=0; i<=len-1; i++)
		{
			if (objname[i].checked == false) {}
			else
			{
				id = 1;
			}
		}
		if (id != 1)
		{
		  if (message!="")
		  {
			alert(message);
			//objname.focus();
			//objname.select();
		  }
			return false;
		}
	}
}

//commom function for single select checkbox
function singlecheckboxvalidation(objname,message)
{
	with (objname)	
	{		
		if (objname.checked == false) 
		{
			if (message!="")
			{
				alert(message);			
			}
			return false;
		}
	}
}

//commom function for emptyfield
function emptyvalidation(objname, message)
{
  with(objname)
  {
    var enterval = value;
	var enterval1 = enterval.replace(/ /gi,'');
	if (enterval == '' || enterval == null || enterval1 == '' || enterval1 == null)
	{
	  if (message!="")
	  {
	    alert(message);
		objname.focus();
		objname.select();
	  }
	    return false;
    }
	  else
	  {
	    return true;
	  }
	}
} 

//commom function for emptyfield
function emptyvalidationobject(objname, message,itemname)
{
  with(objname)
  {
	var txtobj=document.getElementById(itemname)
    var enterval = txtobj.value;
	var enterval1 = enterval.replace(/ /gi,'');
	if (enterval == '' || enterval == null || enterval1 == '' || enterval1 == null)
	{
	  if (message!="")
	  {
	    alert(message);
		//objname.focus();
		//objname.select();
	  }
	    return false;
    }
	  else
	  {
	    return true;
	  }
	}
} 

//commom function for dropdown select
function dropdownvalidation (objname, message)
{
  with (objname)
  {
    var enterval = objname.options[objname.selectedIndex].value;
	if (enterval == 0)
	{
	  if (message!="")
	  {
	    alert(message);
		objname.focus();
	  }
	    return false;
    }
	  else
	  {
	    return true;
	  }
	}
} 

//commom function for multiselect box
/*function selectallvalidation(objname)
{
	with (objname)
	{
		if(objname.selectedIndex == 0)
		{
			for(i=0; i<objname.length; i++)
			{
				objname.options[i].selected = true;
			}
		}
	}

}*/

//commom function for empty multiselect box
function emptyselectvalidation(objname,message)
{
	with (objname)
	{
		if(objname.selectedIndex == "-1")
		{
			if (message!="")
			{
				alert(message);
				objname.focus();
			}
			return false;
		}
		else
		{
			return true;
		}
	}
}

//commom function for empty multiselect box
function countselectvalidation(objname,message)
{
	with (objname)
	{
		if(objname.selectedIndex == "-1")
		{
			if (message!="")
			{
				alert(message);
				objname.focus();
			}
			return false;
		}
		else
		{
			return true;
		}
	}
}

//commom function for select radiobutton
function radiovalidation(objname,message)
{
	with (objname)	
	{
		var len, id;
		len = objname.length;
		for (i=0; i<=len-1; i++)
		{
			if (objname[i].checked == false) {}
			else
			{
				id = 1;
			}
		}
		if (id != 1)
		{
		  if (message!="")
		  {
			alert(message);
			//objname.focus();
			//objname.select();
		  }
			return false;
		}
	}
}

//commom function for digit
 function digitvalidation(objname, message)
{
  with (objname)
  {
    enterval = value.length;
	if (enterval != 0)
	{
	  for (i=0;i<enterval;i++)
	  {
	    digitval = value.substring(i,i+1);
		if ('0' > digitval || '9' < digitval)
		{
		  if (message!="")
		  {
		    alert(message);
			objname.focus();
			objname.select();

		  }
		  return false;
		}
	  }
	}
	return true;
  }
} 

//commom function for character and comma,singlequote
 function charactervalidation(objname, message)
{
  with (objname)
  {
    enterval = value.length;
	enterval1 = value;
	comma = 0;
	if(value.indexOf(",")>-1) comma = 1;
	quote = 0;
	if(value.indexOf("'")>-1) quote = 1;
	if (enterval != 0)
	{

	  for (i=0;i<enterval;i++)
	  {
	    characterval = value.substring(i,i+1);
		re=/[a-z,A-Z,' ']/g;
		str=enterval1.replace(re,'');
		//alert(str);
		
		if(value.indexOf("-")>-1 || value.indexOf("/")>-1)
			{
				str="";
			}
		
		
		if(str.length>0 || (comma==1) || (quote==1))
		{
		  if (message!="")
		  {
		    alert(message);
			objname.focus();
			objname.select();
		  }
		  return false;
		}
	  }
	}
	return true;
  }
} 

//commom function for description
 function descriptionvalidation(objname, message)
{
  with (objname)
  {
    enterval = value.length;
	enterval1 = value;
	quote = 0;
	if(value.indexOf("'")>-1) quote = 1;
	if (enterval != 0)
	{

	  for (i=0;i<enterval;i++)
	  {
	    characterval = value.substring(i,i+1);
		re=/[a-z,A-Z,' ','.']/g;
		str=enterval1.replace(re,'');

		if(value.indexOf("/")>-1 || value.indexOf("(")>-1 || value.indexOf(")")>-1 ||value.indexOf("-")>-1 || value.indexOf('"')>-1 )
		 {
			str="";
		 }
		
		
		if(str.length>0 || (quote==1))
		{
		  if (message!="")
		  {
		    alert(message);
			objname.focus();
			objname.select();
		  }
		  return false;
		}
	  }
	}
	return true;
  }
} 

//common function for alpha numeric
function alphanumvalidation(objname,message)
{
	with(objname)
	{
		quote = 0;
		if(value.indexOf("'")>-1) quote = 1;
		comma = 0;
		if(value.indexOf(",")>-1) comma = 1;
		enterval = value.replace(/[a-z,A-Z,0-9,'.','-']/gi,"");
		if(value.indexOf("-")>-1)
		{
		enterval="";
		}
		//alert(enterval)
		//alert(comma);
		//alert(quote);
		if((enterval.length>0) ||(comma==1) || (quote==1))
		{
			if (message!="")
			{
				alert(message);
				objname.focus();
				objname.select();
			}
			return false;  
		}
		else 
		return true;
	}
}

//commom function for name
 function namevalidation(objname, message)
{
  with (objname)
  {
    enterval = value.length;
	enterval1 = value;
	quote = 0;
	if(value.indexOf("'")>-1) quote = 1;
	comma = 0;
	if(value.indexOf(",")>-1) comma = 1;
	if (enterval != 0)
	{

	  for (i=0;i<enterval;i++)
	  {
	    characterval = value.substring(i,i+1);
		re=/[a-z,A-Z,' ']/g;
		str=enterval1.replace(re,'');

		if(str.length>0 || (comma==1) || (quote==1))
		{
		  if (message!="")
		  {
		    alert(message);
			objname.focus();
			objname.select();
		  }
		  return false;
		}
	  }
	}
	return true;
  }
} 

// Common function for Alphabet validation. (Will accept only 'a-z', 'A-Z', ' ')
function alphabetvalidation(objname,message)
{
	with (objname)
	{
		var enterval = value.length;
		var enterval1 = value;
		for(var j=0; j<enterval; j++)
		{
			var alphaa = enterval1.charAt(j);
			var hh = alphaa.charCodeAt(0);
			//if((hh == 32) || (hh > 64 && hh < 91) || (hh > 96 && hh < 123))
			if((hh > 0 && hh <32) || (hh > 32 && hh < 65) || (hh > 91 && hh < 96) || (hh > 122))
			{				
				if (message!="")
				{
					alert(message);
					objname.focus();
					objname.select();
				}
				return false;
			}	
		}
		return true;
	}	
}

//commom function for address
function addressvalidation(objname, message)
{
  with (objname)
  {
 
    enterval = value.length;
	enterval1 = value;
	quote = 0;
	if(value.indexOf("'")>-1) quote = 1;
	if (enterval != 0)
	{

	//  for (i=0;i<enterval;i++)
	 // {
	    //characterval = value.substring(i,i+1);
		re=/[a-z,A-Z,0-9,' ','.']/g;
		str=enterval1.replace(re,'');
              
               str1=str
		for(j=0;j<=str1.length;j++)
 		{ 
                  
		  str=str.replace("-",'');
                 
		}
               
		

		if(str.length>0 || (quote==1))
		{
		  if (message!="")
		  {
		    alert(message);
			objname.focus();
			objname.select();
		  }
		  return false;
		}
	 // }
	}
	return true;
  }
} 

//commom function for digit space
 function digitspacevalidation(objname, message)
{
  with (objname)
  {
    enterval = value.length;
	enterval1 = value;
	comma = 0;
	if(value.indexOf(",")>-1) comma = 1;
	quote = 0;
	if(value.indexOf("'")>-1) quote = 1;
	if (enterval != 0)
	{

	  for (i=0;i<enterval;i++)
	  {
	    characterval = value.substring(i,i+1);
		re=/[0-9,' ']/g;
		str=enterval1.replace(re,'');

		if(str.length>0 || (comma==1) || (quote==1))
		{
		  if (message!="")
		  {
		    alert(message);
			objname.focus();
			objname.select();
		  }
		  return false;
		}
	  }
	}
	return true;
  }
} 

//commom function for contact number allows digits,comma,space,brackets and slash
 function contactnumbervalidation(objname, message)
{
  with (objname)
  {
    enterval = value.length;
	enterval1 = value;
	comma = 0;
	if(value.indexOf(",")>-1) comma = 1;
	quote = 0;
	if(value.indexOf("'")>-1) quote = 1;
	if (enterval != 0)
	{

	  for (i=0;i<enterval;i++)
	  {
	    characterval = value.substring(i,i+1);
		re=/[0-9,' ',(,),/,-]/g;
		str=enterval1.replace(re,'');

		if(str.length>0 || (comma==1) || (quote==1))
		{
		  if (message!="")
		  {
		    alert(message);
			objname.focus();
			objname.select();
		  }
		  return false;
		}
	  }
	}
	return true;
  }
} 

//commom function for date
function datevalidation(dayField,monthField,yearField,message) 
{ 
	if (dayField.selectedIndex == 0 && monthField.selectedIndex == 0 && yearField.selectedIndex == 0)
	{
	  if (message!="")
	  {
		alert(message);
	  }
		return false; 
	}
	if (dayField.selectedIndex != 0 && monthField.selectedIndex == 0 && yearField.selectedIndex == 0)
	{
	  if (message!="")
	  {
		alert(message);
	  }
		return false; 
	}
	if (dayField.selectedIndex != 0 && monthField.selectedIndex != 0 && yearField.selectedIndex == 0)
	{
	  if (message!="")
	  {
		alert(message);
	  }
		return false; 
	}
	if (dayField.selectedIndex != 0 && monthField.selectedIndex == 0 && yearField.selectedIndex != 0)
	{
	  if (message!="")
	  {
		alert(message);
	  }
		return false; 
	}
	if (dayField.selectedIndex == 0 && monthField.selectedIndex != 0 && yearField.selectedIndex == 0)
	{
	  if (message!="")
	  {
		alert(message);
	  }
		return false; 
	}
	if (dayField.selectedIndex == 0 && monthField.selectedIndex != 0 && yearField.selectedIndex != 0)
	{
	  if (message!="")
	  {
		alert(message);
	  }
		return false; 
	}
	if (dayField.selectedIndex == 0 && monthField.selectedIndex == 0 && yearField.selectedIndex != 0)
	{
	  if (message!="")
	  {
		alert(message);
	  }
		return false; 
	}
	day = dayField[dayField.selectedIndex].value; 
    month = monthField[monthField.selectedIndex].value; 
    year = yearField[yearField.selectedIndex].value; 
	if ((month == "4" || month == "6" || month == "9" || month == "11") && ( day > 30)) 
    { 
	  if (message!="")
	  {
		alert(message);
	  }
		return false; 
    } 

    if (month == "2" && day > 29) 
    { 
	  if (message!="")
	  {
		alert(message);
	  }
        return false; 
    } 

    // check for Leap Year NOW.... 
    // Any year that is divisible by 4 but not divisible by 100 except when the year is divisible by 400. 
    // Thus 1600 and 2000, although century marks, have a Leap Day. 

    if (( month == "2") &&  ( year%4 ==0 && (year%100 != 0 || year%400 == 0)))   // that is a leap year 
    { 
        if (day > 29) 
        { 
		  if (message!="")
		  {
			alert(message);
		  }
            return false; 
        } 
    } 
    else if (month == "2" && day > 28) 
    { 
	  if (message!="")
	  {
		alert(message);
	  }
        return false; 
    } 
    return true; 
} 

//Checking for search option date text field validation on onblur event
function OnClickTxtDate(FieldFrom,FieldTo)
{
	var TodayDate=new Date();
	if(document.getElementById(FieldFrom).value.length>0 && document.getElementById(FieldFrom).value.length<10)
	{
		alert("Enter a Valid Date (Ex:DDMMYYYY)");
		document.getElementById(FieldFrom).focus();
		return false;
	}
	else
	{
			//Validation for Fromdate textbox start here
			if(document.getElementById(FieldFrom).value.length==10)
			{
				
				var dayFrom=document.getElementById(FieldFrom).value.substring(0,2);
				var monthFrom=document.getElementById(FieldFrom).value.substring(3,5);
				var yearFrom=document.getElementById(FieldFrom).value.substring(6,10);
				var StrFromDate=monthFrom+"/"+dayFrom+"/"+yearFrom;  //default format
				var FromDate=new Date(StrFromDate);
				
				//checking the year
				if((yearFrom > TodayDate.getFullYear()) || (yearFrom <  "1901"))
				{
					alert("From Year(YYYY) Should be between 1901 to "+TodayDate.getFullYear());
					document.getElementById(FieldFrom).focus();
					return false;
				}
				
				//Checking months
				if(monthFrom > 12 || monthFrom < 01)
				{
					alert("Fron Month(MM) Should be between 01 to 12 ");
					document.getElementById(FieldFrom).focus();
					return false;
				}
				
				//Checking days in month
				
				if((monthFrom==04 || monthFrom==06  || monthFrom==09 || monthFrom==11) && (dayFrom > 30 || dayFrom < 01))
				{
					alert("From day(DD) should Be Between 01 to 30 For "+monthFrom+" Th Month");
					document.getElementById(FieldFrom).focus();
					return false;
				}
				else if(dayFrom > 31 || dayFrom < 01)
				{
					alert("From day(DD) should Be Between 01 to 31 For "+monthFrom+" Month");
					document.getElementById(FieldFrom).focus();
					return false;
				}
				else if((monthFrom==02) && (yearFrom%4==0 && (yearFrom%100!=0 || yearFrom%400==0))) //Leap year checking
				{
					if(dayFrom > 29 || dayFrom < 01)
					{
						alert("From day(DD) should Be Between 01 to 29 For "+monthFrom+"nd Month");
						document.getElementById(FieldFrom).focus();
						return false;
					}
				}
				else if(monthFrom==02 && (dayFrom > 28 || dayFrom < 01))
				{
					alert("From day(DD) should Be Between 01 to 28 For "+monthFrom+"nd Month");
					document.getElementById(FieldFrom).focus();
					return false;
				}
				
				//Checking with cuurent date
				if(FromDate>TodayDate)
				{
					alert("From Date should be lessthan present date");
					document.getElementById(FieldFrom).focus();
					return false;
				}
				
				
			}
			//Validation for Fromdate textbox End here
	}
	
	if(document.getElementById(FieldTo).value.length>0 && document.getElementById(FieldTo).value.length<10)
	{
		alert("Enter a Valid Date (Ex:DDMMYYY)");
		document.getElementById(FieldTo).focus();
		return false;
	}
	else
	{
			//Validation for Todate textbox start here	
			if(document.getElementById(FieldTo).value.length==10)
			{
				var dayTo=document.getElementById(FieldTo).value.substring(0,2);
				var monthTo=document.getElementById(FieldTo).value.substring(3,5);
				var yearTo=document.getElementById(FieldTo).value.substring(6,10);
				var StrToDate=monthTo+"/"+dayTo+"/"+yearTo;  //default format
				var ToDate=new Date(StrToDate);
				
				//checking the year
				if((yearTo > TodayDate.getFullYear()) || (yearTo <  "1901"))
				{
					alert("To Year(YYYY) Should be between 1901 to "+TodayDate.getFullYear());
					document.getElementById(FieldTo).focus();
					return false;
				}
				
				//Checking months
				if(monthTo > 12 || monthTo < 01)
				{
					alert("To Month(MM) Should be between 01 to 12 ");
					document.getElementById(FieldTo).focus();
					return false;
				}
				
				//Checking days in month
				
				if((monthTo==04 || monthTo==06  || monthTo==09 || monthTo==11) && (dayTo > 30 || dayTo < 01))
				{
					alert("To day(DD) should Be Between 01 to 30 For "+monthTo+" Th Month");
					document.getElementById(FieldTo).focus();
					return false;
				}
				else if(dayTo > 31 || dayTo < 01)
				{
					alert("To day(DD) should Be Between 01 to 31 For "+monthTo+" Month");
					document.getElementById(FieldTo).focus();
					return false;
				}
				else if((monthTo==02) && (yearTo%4==0 && (yearTo%100!=0 || yearTo%400==0))) //Leap year checking
				{
					if(dayTo > 29 || dayTo < 01)
					{
						alert("To day(DD) should Be Between 01 to 29 For "+monthTo+"nd Month");
						document.getElementById(FieldTo).focus();
						return false;
					}
				}
				else if(monthTo==02 && (dayTo > 28 || dayTo < 01))
				{
					alert("To day(DD) should Be Between 01 to 28 For "+monthTo+"nd Month");
					document.getElementById(FieldTo).focus();
					return false;
				}
				if(ToDate>TodayDate)
				{	
					alert("To Date should be less than present date");
					document.getElementById(FieldTo).focus();
					return false;
				}	
			}
			//Validation for Todate textbox  End here
	}
			
	
	if(document.getElementById(FieldFrom).value.length==10 && document.getElementById(FieldTo).value.length==10)
	{
		if(FromDate>ToDate)
		{
			alert("From Date should not be greater than To date");
			document.getElementById(FieldFrom).focus();
			return false;
		}
	}
}


//Validation on search text date control on onkeypress event 
function EverykeyTxtDate(field,evt)
{	
	//alert(evt.charCode);
	
	if((evt.keyCode>=48 && evt.keyCode<=57) || (evt.charCode>=48 && evt.charCode<=57))
	{
		if(field.value.length==10)
		{
			return false;
		}
	
		
		if(field.value.length==2 && evt.keyCode!=8)
		{
			field.value=field.value+"/";
			/*if(field.value>31 && field.value<0)
			{
				alert("Date should be Between 0 to 31");
				field.focus();
				return false;
			}
			else
			{
				field.value=field.value+"/";
			}*/
		}
		if(field.value.length==5 && evt.keyCode!=8 )
		{
			field.value=field.value+"/";
			/*if((field.value.charAt(3)+field.value.charAt(4))>12 && (field.value.charAt(3)+field.value.charAt(4))<0 )
			{
				alert("Month Should be Between 0 to 12");
				field.focus();
				return false;
			}
			else
			{
				field.value=field.value+"/";
			}*/
		}
	}
	else
	{
		if(evt.keyCode==8 || evt.KeyCode==9 || evt.charCode==0)
		{
			return true;
		}
		else
		{
			return false;
		}
	}
				
}

//commom function for comparing date
function datecomparevalidation(dS,mS,yS,dE,mE,yE,message) 
{ 
	var mSval = 0;
	var mEval = 0;
	if (mS[mS.selectedIndex].value == "Jan")
	{
		mSval = 1;
	}
	if (mS[mS.selectedIndex].value == "Feb")
	{
		mSval = 2;
	}
	if (mS[mS.selectedIndex].value == "Mar")
	{
		mSval = 3;
	}
	if (mS[mS.selectedIndex].value == "Apr")
	{
		mSval = 4;
	}
	if (mS[mS.selectedIndex].value == "May")
	{
		mSval = 5;
	}
	if (mS[mS.selectedIndex].value == "Jun")
	{
		mSval = 6;
	}
	if (mS[mS.selectedIndex].value == "Jul")
	{
		mSval = 7;
	}
	if (mS[mS.selectedIndex].value == "Aug")
	{
		mSval = 8;
	}
	if (mS[mS.selectedIndex].value == "Sep")
	{
		mSval = 9;
	}
	if (mS[mS.selectedIndex].value == "Oct")
	{
		mSval = 10;
	}
	if (mS[mS.selectedIndex].value == "Nov")
	{
		mSval = 11;
	}
	if (mS[mS.selectedIndex].value == "Dec")
	{
		mSval = 12;
	}

	if (mE[mE.selectedIndex].value == "Jan")
	{
		mEval = 1;
	}
	if (mE[mE.selectedIndex].value == "Feb")
	{
		mEval = 2;
	}
	if (mE[mE.selectedIndex].value == "Mar")
	{
		mEval = 3;
	}
	if (mE[mE.selectedIndex].value == "Apr")
	{
		mEval = 4;
	}
	if (mE[mE.selectedIndex].value == "May")
	{
		mEval = 5;
	}
	if (mE[mE.selectedIndex].value == "Jun")
	{
		mEval = 6;
	}
	if (mE[mE.selectedIndex].value == "Jul")
	{
		mEval = 7;
	}
	if (mE[mE.selectedIndex].value == "Aug")
	{
		mEval = 8;
	}
	if (mE[mE.selectedIndex].value == "Sep")
	{
		mEval = 9;
	}
	if (mE[mE.selectedIndex].value == "Oct")
	{
		mEval = 10;
	}
	if (mE[mE.selectedIndex].value == "Nov")
	{
		mEval = 11;
	}
	if (mE[mE.selectedIndex].value == "Dec")
	{
		mEval = 12;
	}

    start = (dS[dS.selectedIndex].value*1) + (mSval*30) + (yS[yS.selectedIndex].value*365); 
    end = (dE[dE.selectedIndex].value*1) + (mEval*30) + (yE[yE.selectedIndex].value*365); 
	if (end < start) 
    { 
	  if (message!="")
	  {
		alert(message);
	  }
        return false; 
    }
		return true;
} 

//commom function for maximum length for textarea
function maxlenvalidation(objname,objmaxlen,message)
{
	with (objname)	
	{
		var len;
		len = objname.value.length;
		if (len > objmaxlen)
		{
		  if (message!="")
		  {
			alert(message);
			objname.focus();
			objname.select();
		  }
			return false;
		}
	}
}



function checkAll1()
{
	ctr=0;
	len=document.BG.elements.length;
	for(i=0;i<len;i++)
	{
	    if(document.BG.elements.type="checkbox")
	    {	
			if(document.BG.elements[i].checked==false)
			{
				document.BG.elements[i].checked=true;
				ctr=ctr+1;
			}			
		}
	}
	if (ctr==0)
	{
		for(j=0;j<len;j++)
		{
		    if(document.BG.elements.type="checkbox")
		    {	
				if(document.BG.elements[j].checked==true)
				{
					document.BG.elements[j].checked=false;					
				}			
			}
		}
	}
}



/*function CheckAll(checkAllBox )
{
var frm = document.BG ;
  var actVar = checkAllBox.checked ;
  for(i=0;i< frm.length;i++)
  {
    e=frm.elements[i];
    if ( e.type=='checkbox' && e.name.indexOf("chkBG") != -1 )
      e.checked= actVar ;
  }
} */

function CheckAll(blnCheck,itemname)
{

var mychk=document.getElementsByName(itemname);
var mychkall=document.getElementsByName(blnCheck);


for (i=0;i<mychk.length;i++) 
{ 
mychk[i].checked = mychkall[0].checked; 

} 

}

// function for checking Max decimal values
function checkDecimal(objname,message,message1)
{
	with (objname)	
	{
		var len;
		var fieldvalue
		len = objname.value.length;
		fieldValue=objname.value;

		if (fieldValue.indexOf('.') == -1) 
		{
		  if(len>3)	// total length without decimal
		   {	
			alert(message);
			objname.focus();
			objname.select();
		        return false;
		   }
		}			

		else if (fieldValue.indexOf('.') != -1)
		{
		// Multiple dots
		var chk=0;
		for (i=0;i<len;i++)
		  {
		    digitval = value.substring(i,i+1);
			if (digitval=='.')
			{
   			  chk=chk+1;	
			  
			}
	  	 }
		
		 if(chk>1)
		    {	
			alert(message1);
			objname.focus();
			objname.select();
		        return false;
   		  }			

		len2 = fieldValue.substring(0,fieldValue.indexOf('.')).length;   // before dot
		
		if(len2>3)
		   {	
			alert(message);
			objname.focus();
			objname.select();
		        return false;
   		  }
   		  
		len1 = fieldValue.substring(fieldValue.indexOf('.')+1,len).length;  // after dot
		
		if(len1>3)
		   {	
			alert(message);
			objname.focus();
			objname.select();
		        return false;
   		  }

		}
		else
			return true;
	}
}	
 
//commom function for digit space
 function digitdotvalidation(objname, message)
{
  with (objname)
  {
    enterval = value.length;
	enterval1 = value;
	
	if (enterval != 0)
	{

	  for (i=0;i<enterval;i++)
	  {
	    characterval = value.substring(i,i+1);
		re=/[0-9,'.']/g;
		str=enterval1.replace(re,'');

		if(str.length>0)
		{
		  if (message!="")
		  {
		    alert(message);
			objname.focus();
			objname.select();
		  }
		  return false;
		}
	  }
	}
	return true;
  }
} 


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

// Email Validation
function EmailValidation(objectname)
{
	with(objectname)
	{
		emailStr=objectname.value;
		var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i
		var returnval=emailfilter.test(emailStr)
		if (returnval==false)
		{
			alert("Not a valid Email format.")
			objectname.focus();
			return false;
		}
	}
}


// Email Validation
function EmailValidation1(objectname)
{
	
	with(objectname)
{
	emailStr=objectname.value;
	var emailPat=/^(.+)@(.+)$/
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
	var validChars="\[^\\s" + specialChars + "\]"
	var quotedUser="(\"[^\"]*\")"
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
	var atom=validChars + '+'
	var word="(" + atom + "|" + quotedUser + ")"
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
	var matchArray=emailStr.match(emailPat)
	if (matchArray==null) 
	{
		alert("Not a valid Email format");
		objectname.focus();
		return false
	}
	var user=matchArray[1]	
	var domain=matchArray[2]
	if (user.match(userPat)==null) 
	{
	    // user is not valid
	    alert("Not a valid Email format.");
	   objectname.focus();
	    return false
	}
	var IPArray=domain.match(ipDomainPat)
	if (IPArray!=null)
	{
	  for (var i=1;i<=4;i++) 
	  {
	    if (IPArray[i]>255) 
	    {
		   alert("Not a valid Email format.");
		   objectname.focus();
		   return false;
		}
	  }
	    return true
	}
	var domainArray=domain.match(domainPat)
	if (domainArray==null) 
	{
		alert("Not a valid Email format.");
		objectname.focus();
		return false
	}
	var atomPat=new RegExp(atom,"g")
	var domArr=domain.match(atomPat)
	var len=domArr.length
	if (domArr[domArr.length-1].length<2 ||  domArr[domArr.length-1].length>3) 
	{
	   alert("Not a valid Email format.");
	   objectname.focus();
	   return false
	}
	if (len<2)
	{
	   alert("Not a valid Email format.");
	   objectname.focus();
	   return false
	}
}
	
}

function TrimString(sInString) {
  sInString = sInString.replace( /^\s+/g, "" );// strip leading
  return sInString.replace( /\s+$/g, "" );// strip trailing
}

// Function for wait.
function doHourglass()
{
	document.body.style.cursor = 'wait';
}




function newWindow(a_str_windowURL, a_str_windowName, a_int_windowWidth, a_int_windowHeight, a_bool_scrollbars, a_bool_resizable, a_bool_menubar, a_bool_toolbar, a_bool_addressbar, a_bool_statusbar, a_bool_fullscreen) {
  var int_windowLeft = (screen.width - a_int_windowWidth) / 2;
  var int_windowTop = (screen.height - a_int_windowHeight) / 2;
  var str_windowProperties = 'height=' + a_int_windowHeight + ',width=' + a_int_windowWidth + ',top=' + int_windowTop + ',left=' + int_windowLeft + ',scrollbars=' + a_bool_scrollbars + ',resizable=' + a_bool_resizable + ',menubar=' + a_bool_menubar + ',toolbar=' + a_bool_toolbar + ',location=' + a_bool_addressbar + ',statusbar=' + a_bool_statusbar + ',fullscreen=' + a_bool_fullscreen + '';
  var obj_window = window.open(a_str_windowURL, a_str_windowName, str_windowProperties)
    if (parseInt(navigator.appVersion) >= 4) {
      obj_window.window.focus();
    }
}

// Click of 'Enter' button for Submit.
function clickButton(buttonid)
{ 
	var bt = document.getElementById(buttonid); 
	if (typeof bt == 'object')
		{ 
			if(navigator.appName.indexOf("Netscape")>(-1)){ 
			if (event.keyCode == 13)
			{ 
				bt.click(); 
				return false; 
			} 
		} 
	if (navigator.appName.indexOf("Microsoft Internet Explorer")>(-1))
		{ 
			if (event.keyCode == 13)
			{ 
				bt.click(); 
				return false; 
			} 
		} 
	}	 
}

//commom function for Confirm Password
function confirmpassword(objname,itemname1,itemname2,message)
{  
	if (objname.itemname1.value!=objname.itemname2.value) 
	{
	  if (message!="")
	  {
	    alert(message);		
	  }
	    return false;
    }
	else
	{
		return true;
	}  	
}



