// JavaScript Document
/*------------------------------------------------------------------------
Deveoped By - Vivek Davey
Date of Creation - 24/1/03
Date of Modification - 10/06/03
Description - This Js file contains all the possbile validation for a
              Data entry form and some other function which are used to
			  handle the custom controls.
--------------------------------------------------------------------------*/

//Validation for Form
function submit1_onclick(objForm)
{
	var blExit=false;
	for(var intCounter=0;intCounter<objForm.length && blExit==false;intCounter++)
	{		
		var strTemp=""
		if(objForm[intCounter].alt!=null)
		{
			strTemp=objForm[intCounter].alt.split("|");
			if(strTemp[0]=="REQ")
			{
				if(strTemp[1]=="TEXT")
				{
					Trim(objForm[intCounter])
					if(strTemp[2]=="")
					{
						if(objForm[intCounter].value=="")
						{
							alert(strTemp[3]);
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
						}
					}						
					else if(strTemp[2]=="NUMERIC")
					{
						if(IsNumeric(objForm[intCounter])==false)
						{
							alert(strTemp[3]);
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
						}
					}
					else if(strTemp[2]=="DATE")
					{
						if(isDate(objForm[intCounter].value,strTemp[3])==false)
						{
							//alert(strTemp[3]);
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
						}
					}
					else if(strTemp[2]=="PAGENAME")
					{
						if(IsValidCharacter(objForm[intCounter])==false)
						{
							alert(strTemp[3]);
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
						}
					}
					else if(strTemp[2]=="IMGPARAMS")
					{
							
						if(IsImageParameters(objForm[intCounter])==false)
						{
							alert(strTemp[3]);
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
						}
					}
					else if(strTemp[2]=="DNAME")
					{
						if(IsDomain(objForm[intCounter])==false)
						{
							alert(strTemp[3]);
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
						}
					}
					/*****************************************************************/
					else if(strTemp[2]=="LOGPWD") {
						if(IsValidLog_Pwd(objForm[intCounter]) == false) {
							alert(strTemp[3]);
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
							}
						}
					else if(strTemp[2]=="NAME") {
						if(IsValidName(objForm[intCounter]) == false) {
							alert(strTemp[3]);
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
							}
						}
					else if(strTemp[2]=="PHONE")
					{
						if(IsPhoneFax(objForm[intCounter])==false)
						{
							alert(strTemp[3]);
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
						}
					}
					/*****************************************************************/
					else if(strTemp[2]=="CHARNAME")
					{
						if(ChkCharFirst(objForm[intCounter])==false)
						{
							//alert('1');
							alert(strTemp[3]);
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
						}
					}
					else if(strTemp[2]=="USERNAME")
					{
						if(CheckSpl(objForm[intCounter])==false)
						{
							//alert('1');
							alert(strTemp[3]);
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
						}
					}
					else if(strTemp[2]=="PRICE1")
					{
						if(IsPrice(objForm[intCounter])==false)
						{
							alert(strTemp[3]);
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
						}
					}
					else if(strTemp[2]=="STRING")
					{
						if(IsCharacter(objForm[intCounter])==false)
						{
							alert(strTemp[3]);
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
						}
					}
					else if(strTemp[2]=="IP")
					{
						if(IsIP(objForm[intCounter])==false)
						{
							alert(strTemp[3]);
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
						}
					}
					
					else if(strTemp[2]=="EMAIL")
					{
						if(IsEmail(objForm[intCounter])==false)
						{
							alert(strTemp[3]);
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
						}
					}
					else if(strTemp[2]=="PATH")
					{
						if(IsPath(objForm[intCounter])==false)
						{
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
						}
					}
					else if(strTemp[2]=="NOSPL")
					{
						if(IsSpl(objForm[intCounter])==false)
						{
							alert(strTemp[3]);
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
						}
					}
					else if(strTemp[2]=="PERCENT")
					{
						if(IsPercent(objForm[intCounter])==false)
						{
							alert(strTemp[3]);
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
						}
					}
					else if(strTemp[2]=="NUMCOMMA")
					{
						if(IsNumComma(objForm[intCounter])==false)
						{
							alert(strTemp[3]);
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
						}
					}
					else if(strTemp[2]=="INT")
					{
						if(isInteger(objForm[intCounter])==false)
						{
							alert(strTemp[3]);
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
						}
					}				  
				}
				else if(strTemp[1]=="CHECK")
				{
					if(objForm[intCounter].checked==false)
					{
						alert(strTemp[3]);
						objForm[intCounter].focus();
						objForm[intCounter].select();
						blExit=true;
					}
				}
				else if(strTemp[1]=="FILE")
				{
					Trim(objForm[intCounter])					
					if(strTemp[2]=="")
					{
						if(objForm[intCounter].value=="")
						{
							alert(strTemp[3]);
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
						}
					}
				}				
				else if(strTemp[1]=="SELECT")
				{
					Trim(objForm[intCounter])
					if(strTemp[2]=="")
					{
						if(objForm[intCounter].value=="")
						{
							alert(strTemp[3]);
							objForm[intCounter].selectedIndex=0;
							blExit=true;
						}
					}
				}
				else if(strTemp[1]=="SELECTNEW")
				{
					Trim(objForm[intCounter])
					if(strTemp[2]=="")
					{
						if(objForm[intCounter].value=="0")
						{
							alert(strTemp[3]);
							objForm[intCounter].selectedIndex=0;
							blExit=true;
						}
					}
				}
				else if(strTemp[1]=="HIDDEN")
				{
					Trim(objForm[intCounter])
					if(strTemp[2]=="")
					{
						if(objForm[intCounter].value=="")
						{
							alert(strTemp[3]);
							objForm[intCounter].selectedIndex=0;
							blExit=true;
						}
					}
				}
				 else if(strTemp[1]=="TEXTAREA")
			    	{
					if(IsLong(objForm[intCounter],strTemp[4])==false)
					{
						alert(strTemp[3]);
						objForm[intCounter].focus();
						objForm[intCounter].select();
						blExit=true;
					}
					else
					{
					if(strTemp[2]=="")
						{
							if(objForm[intCounter].value=="")
							{
								alert(strTemp[3]);
								objForm[intCounter].focus();
								objForm[intCounter].select();
								blExit=true;
							}
						}
					else if(strTemp[2]=="NUMERIC")
					{
						if(IsNumeric(objForm[intCounter])==false)
						{
							alert(strTemp[3]);
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
						}
					}
					else if(strTemp[2]=="DATE")
					{
						if(isDate(objForm[intCounter].value,strTemp[3])==false)
						{
							//alert(strTemp[3]);
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
						}
					}
					else if(strTemp[2]=="PAGENAME")
					{
						if(IsValidCharacter(objForm[intCounter])==false)
						{
							alert(strTemp[3]);
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
						}
					}
					
					else if(strTemp[2]=="IMGPARAMS")
					{
							
						if(IsImageParameters(objForm[intCounter])==false)
						{
							alert(strTemp[3]);
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
						}
					}
					else if(strTemp[2]=="DNAME")
					{
						if(IsDomain(objForm[intCounter])==false)
						{
							alert(strTemp[3]);
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
						}
					}
					/*****************************************************************/
					else if(strTemp[2]=="LOGPWD") {
						if(IsValidLog_Pwd(objForm[intCounter]) == false) {
							alert(strTemp[3]);
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
							}
						}
					else if(strTemp[2]=="NAME") {
						if(IsValidName(objForm[intCounter]) == false) {
							alert(strTemp[3]);
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
							}
						}
					else if(strTemp[2]=="PHONE")
					{
						if(IsPhoneFax(objForm[intCounter])==false)
						{
							alert(strTemp[3]);
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
						}
					}
					/*****************************************************************/
					else if(strTemp[2]=="CHARNAME")
					{
						if(ChkCharFirst(objForm[intCounter])==false)
						{
							//alert('1');
							alert(strTemp[3]);
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
						}
					}
					else if(strTemp[2]=="USERNAME")
					{
						if(CheckSpl(objForm[intCounter])==false)
						{
							//alert('1');
							alert(strTemp[3]);
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
						}
					}
					else if(strTemp[2]=="PRICE1")
					{
						if(IsPrice(objForm[intCounter])==false)
						{
							alert(strTemp[3]);
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
						}
					}
					else if(strTemp[2]=="STRING")
					{
						if(IsCharacter(objForm[intCounter])==false)
						{
							alert(strTemp[3]);
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
						}
					}
					else if(strTemp[2]=="IP")
					{
						if(IsIP(objForm[intCounter])==false)
						{
							alert(strTemp[3]);
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
						}
					}
					
					else if(strTemp[2]=="EMAIL")
					{
						if(IsEmail(objForm[intCounter])==false)
						{
							alert(strTemp[3]);
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
						}
					}
					else if(strTemp[2]=="PATH")
					{
						if(IsPath(objForm[intCounter])==false)
						{
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
						}
					}
					else if(strTemp[2]=="NOSPL")
					{
						if(IsSpl(objForm[intCounter])==false)
						{
							alert(strTemp[3]);
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
						}
					}
					else if(strTemp[2]=="PERCENT")
					{
						if(IsPercent(objForm[intCounter])==false)
						{
							alert(strTemp[3]);
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
						}
					}
					else if(strTemp[2]=="NUMCOMMA")
					{
						if(IsNumComma(objForm[intCounter])==false)
						{
							alert(strTemp[3]);
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
						}
					}
					else if(strTemp[2]=="INT")
					{
						if(isInteger(objForm[intCounter])==false)
						{
							alert(strTemp[3]);
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
						}
					}
				  }
				 }			
			}
			else if(strTemp[0]=="NOTREQ")
			{
			
				Trim(objForm[intCounter])
				if(objForm[intCounter].value!="")
				{
				  if(strTemp[1]=="TEXT")
					{
						if(strTemp[2]=="")
						{
							if(objForm[intCounter].value=="")
							{
								alert(strTemp[3]);
								objForm[intCounter].focus();
								objForm[intCounter].select();
								blExit=true;
							}
						}
						else if(strTemp[2]=="URI")
						{
							if(IsvalidURI(objForm[intCounter])==false)
							{
								alert(strTemp[3]);
								objForm[intCounter].focus();
								objForm[intCounter].select();
								blExit=true;
							}
						}
						else if(strTemp[2]=="PRICE1")
						{
							if(IsPrice(objForm[intCounter])==false)
							{
								alert(strTemp[3]);
								objForm[intCounter].focus();
								objForm[intCounter].select();
								blExit=true;
							}
						}
						else if(strTemp[2]=="HYPERLINK")
						{
							if(IsvalidURL(objForm[intCounter])==false)
							{
								alert(strTemp[3]);
								objForm[intCounter].focus();
								objForm[intCounter].select();
								blExit=true;
							}
						}
						else if(strTemp[2]=="DATE")
						{
							if(isDate(objForm[intCounter].value,strTemp[3])==false)
							{
								//alert(strTemp[3]);
								objForm[intCounter].focus();
								objForm[intCounter].select();
								blExit=true;
							}
						}
						else if(strTemp[2]=="IMGPARAMS")
						{
							
							if(IsImageParameters(objForm[intCounter])==false)
							{
								alert(strTemp[3]);
								objForm[intCounter].focus();
								objForm[intCounter].select();
								blExit=true;
							}
						}
						else if(strTemp[2]=="DNAME")
						{
							if(IsDomain(objForm[intCounter])==false)
							{
								alert(strTemp[3]);
								objForm[intCounter].focus();
								blExit=true;
							}
						}
						else if(strTemp[2]=="NUMCOMMA")
						{
							if(IsNumComma(objForm[intCounter])==false)
							{
								alert(strTemp[3]);
								objForm[intCounter].focus();
								objForm[intCounter].select();
								blExit=true;
							}
						}
					/*****************************************************************/
					else if(strTemp[2]=="LOGPWD") {
						if(IsValidLog_Pwd(objForm[intCounter]) == false) {
							alert(strTemp[3]);
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
							}
						}
					else if(strTemp[2]=="NAME") {
						if(IsValidName(objForm[intCounter]) == false) {
							alert(strTemp[3]);
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
							}
						}
					else if(strTemp[2]=="PHONE")
					{
						if(IsPhoneFax(objForm[intCounter])==false)
						{
							alert(strTemp[3]);
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
						}
					}
					/*****************************************************************/
						else if(strTemp[2]=="PERCENT")
						{
							if(IsPercent(objForm[intCounter])==false)
							{
								alert(strTemp[3]);
								objForm[intCounter].focus();
								blExit=true;
							}
						}
						else if(strTemp[2]=="NUMERIC")
						{
							if(IsNumeric(objForm[intCounter])==false)
							{
								alert(strTemp[3]);
								objForm[intCounter].focus();
								objForm[intCounter].select();
								blExit=true;
							}
						}
						else if(strTemp[2]=="STRING")
						{
							if(IsCharacter(objForm[intCounter])==false)
							{
								alert(strTemp[3]);
								objForm[intCounter].focus();
								objForm[intCounter].select();
								blExit=true;
							}
						}
						else if(strTemp[2]=="IP")
						{
							if(IsIP(objForm[intCounter])==false)
							{
								alert(strTemp[3]);
								objForm[intCounter].focus();
								objForm[intCounter].select();
								blExit=true;
							}
						}										
						else if(strTemp[2]=="EMAIL")
						{
							if(IsEmail(objForm[intCounter])==false)
							{
								alert(strTemp[3]);
								objForm[intCounter].focus();
								objForm[intCounter].select();
								blExit=true;
							}
						}
						else if(strTemp[2]=="PATH")
						{
							if(IsPath(objForm[intCounter])==false)
							{
								alert(strTemp[3]);
								objForm[intCounter].focus();
								objForm[intCounter].select();
								blExit=true;
							}
						}
						else if(strTemp[2]=="NOSPL")
						{
							if(IsSpl(objForm[intCounter])==false)
							{
								alert(strTemp[3]);
								objForm[intCounter].focus();
								objForm[intCounter].select();
								blExit=true;
							}
						}
						else if(strTemp[2]=="INT")
						{
							if(isInteger(objForm[intCounter])==false)
							{
								alert(strTemp[3]);
								objForm[intCounter].focus();
								objForm[intCounter].select();
								blExit=true;
							}
						}
					}
				 else if(strTemp[1]=="TEXTAREA")
				  {
					if(objForm[intCounter].value!=""&&IsLong(objForm[intCounter],strTemp[4])==false)
					{
						alert(strTemp[3]);
						objForm[intCounter].focus();
						objForm[intCounter].select();
						blExit=true;
					}
					else
					{
					 if(strTemp[2]=="NUMERIC")
					{
						if(IsNumeric(objForm[intCounter])==false)
						{
							alert(strTemp[3]);
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
						}
					}
					else if(strTemp[2]=="PAGENAME")
					{
						if(IsValidCharacter(objForm[intCounter])==false)
						{
							alert(strTemp[3]);
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
						}
					}
					else if(strTemp[2]=="DATE")
					{
						if(isDate(objForm[intCounter].value,strTemp[3])==false)
						{
							//alert(strTemp[3]);
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
						}
					}
					else if(strTemp[2]=="IMGPARAMS")
					{
							
						if(IsImageParameters(objForm[intCounter])==false)
						{
							alert(strTemp[3]);
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
						}
					}
					else if(strTemp[2]=="DNAME")
					{
						if(IsDomain(objForm[intCounter])==false)
						{
							alert(strTemp[3]);
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
						}
					}
					/*****************************************************************/
					else if(strTemp[2]=="LOGPWD") {
						if(IsValidLog_Pwd(objForm[intCounter]) == false) {
							alert(strTemp[3]);
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
							}
						}
					else if(strTemp[2]=="NAME") {
						if(IsValidName(objForm[intCounter]) == false) {
							alert(strTemp[3]);
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
							}
						}
					else if(strTemp[2]=="PHONE")
					{
						if(IsPhoneFax(objForm[intCounter])==false)
						{
							alert(strTemp[3]);
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
						}
					}
					/*****************************************************************/
					else if(strTemp[2]=="CHARNAME")
					{
						if(ChkCharFirst(objForm[intCounter])==false)
						{
							//alert('1');
							alert(strTemp[3]);
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
						}
					}
					else if(strTemp[2]=="USERNAME")
					{
						if(CheckSpl(objForm[intCounter])==false)
						{
							//alert('1');
							alert(strTemp[3]);
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
						}
					}
					else if(strTemp[2]=="PRICE1")
					{
						if(IsPrice(objForm[intCounter])==false)
						{
							alert(strTemp[3]);
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
						}
					}
					else if(strTemp[2]=="STRING")
					{
						if(IsCharacter(objForm[intCounter])==false)
						{
							alert(strTemp[3]);
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
						}
					}
					else if(strTemp[2]=="IP")
					{
						if(IsIP(objForm[intCounter])==false)
						{
							alert(strTemp[3]);
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
						}
					}
					
					else if(strTemp[2]=="EMAIL")
					{
						if(IsEmail(objForm[intCounter])==false)
						{
							alert(strTemp[3]);
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
						}
					}
					else if(strTemp[2]=="PATH")
					{
						if(IsPath(objForm[intCounter])==false)
						{
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
						}
					}
					else if(strTemp[2]=="NOSPL")
					{
						if(IsSpl(objForm[intCounter])==false)
						{
							alert(strTemp[3]);
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
						}
					}
					else if(strTemp[2]=="PERCENT")
					{
						if(IsPercent(objForm[intCounter])==false)
						{
							alert(strTemp[3]);
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
						}
					}
					else if(strTemp[2]=="NUMCOMMA")
					{
						if(IsNumComma(objForm[intCounter])==false)
						{
							alert(strTemp[3]);
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
						}
					}
					else if(strTemp[2]=="INT")
					{
						if(isInteger(objForm[intCounter])==false)
						{
							alert(strTemp[3]);
							objForm[intCounter].focus();
							objForm[intCounter].select();
							blExit=true;
						}
					}
				 }
				}			
			  }
			}
		}
	}
	if(blExit==false)
	{
		return true;
	}
	else
	{
		return false;
	}
}
function IsLong(oObject,Len)
{
	var strString=oObject.value;	
	if (strString.length >Len) return false;
	return true;
}
function Trim1(TRIM_VALUE){
if(TRIM_VALUE.length < 1){
return"";
}
TRIM_VALUE = RTrim(TRIM_VALUE);
TRIM_VALUE = LTrim(TRIM_VALUE);
if(TRIM_VALUE==""){
return "";
}
else{
return TRIM_VALUE;
}
} //End Function

function RTrim(VALUE){
var w_space = String.fromCharCode(32);
var v_length = VALUE.length;
var strTemp = "";
if(v_length < 0){
return"";
}
var iTemp = v_length -1;

while(iTemp > -1){
if(VALUE.charAt(iTemp) == w_space){
}
else{
strTemp = VALUE.substring(0,iTemp +1);
break;
}
iTemp = iTemp-1;

} //End While
return strTemp;

} //End Function

function LTrim(VALUE){
var w_space = String.fromCharCode(32);
if(v_length < 1){
return"";
}
var v_length = VALUE.length;
var strTemp = "";

var iTemp = 0;

while(iTemp < v_length){
if(VALUE.charAt(iTemp) == w_space){
}
else{
strTemp = VALUE.substring(iTemp,v_length);
break;
}
iTemp = iTemp + 1;
} //End While
return strTemp;
}
//This function works as Trim function of VB
function Trim(item)
{
  
  var tmp = "";
  var item_length = item.value.length;
  var item_length_minus_1 = item.value.length - 1;
  for (index = 0; index < item_length; index++)
  {
    if (item.value.charAt(index) != ' ')
    {
      tmp += item.value.charAt(index);
    }
    else
    {
      if (tmp.length > 0)
      {
        if (item.value.charAt(index+1) != ' ' && index != item_length_minus_1)
        {
          tmp += item.value.charAt(index);
        }
      }
    }
  }
  item.value = tmp;
}

//  check for valid numeric strings	
function IsNumeric(oObject)
{
   var strValidChars = "0123456789.-";
   var strChar;
   var blnResult = true;
   var strString=oObject.value;	
   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
}
function IsImageParameters(oObject)
{
   var strValidChars = "0123456789";
   var strChar;
   var blnResult = true;
   var strString=oObject.value;	
   if (strString.length == 0) return false;   
	
   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
}
//check specifically for Tax
function IsNumComma(oObject)
{
   var strValidChars = "0123456789+-";
   var strChar;
   var blnResult = true;
   var strString=oObject.value;	
   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
   {
      strChar = strString.charAt(i);
      if(strValidChars.indexOf(strChar) == -1)
      {
         blnResult = false;
      }
   }
   return blnResult;
}

//  check for valid strings	
function IsCharacter(oObject)
{
   var strValidChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_. ,";
   var strChar;
   var blnResult = true;
   var strString=oObject.value;	
   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
}

//Validation for Proper Ip Address
function IsIP (oObject) {
var IPvalue=oObject.value;
errorString = "";
theName = "IPaddress";

var ipPattern = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;
var ipArray = IPvalue.match(ipPattern); 

if (IPvalue == "0.0.0.0")
errorString = errorString + theName + ': '+IPvalue+' is a special IP address and cannot be used here.';
else if (IPvalue == "255.255.255.255")
errorString = errorString + theName + ': '+IPvalue+' is a special IP address and cannot be used here.';
if (ipArray == null)
errorString = errorString + theName + ': '+IPvalue+' is not a valid IP address.';
else {
for (i = 0; i < 4; i++) {
thisSegment = ipArray[i];
if (thisSegment > 255) {
errorString = errorString + theName + ': '+IPvalue+' is not a valid IP address.';
i = 4;
}
if ((i == 0) && (thisSegment > 255)) {
errorString = errorString + theName + ': '+IPvalue+' is a special IP address and cannot be used here.';
i = 4;
      }
   }
}
extensionLength = 3;
if (errorString == "")
return true;
else
return false;
}

//Validation for proper Email address
function IsEmail(oObject) {
var emailStr=oObject.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("Email address seems incorrect (check @ and .'s)");
	//alert("Please enter a valid email address.(like username@cms.com )");
	return false;
}
var user=matchArray[1];
var domain=matchArray[2];

if (user.match(userPat)==null) {
    //alert("The username in email address doesn't seem to be valid. Please check or register fresh");
    //alert("Please enter a valid email address.(like username@cms.com )");
    return false;
}
var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {
	  for (var i=1;i<=4;i++) {
	    if (IPArray[i]>255) {
	        //alert("Destination IP address is invalid!");
	       // alert("Please enter a valid email address.(like username@cms.com )");
		return false;
	    }
    }
    return true;
}

var domainArray=domain.match(domainPat);
if (domainArray==null) {
	//alert("The domain name doesn't seem to be valid.");
	//alert("Please enter a valid email address.(like username@cms.com )");
    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("The Email address must end in a three-letter domain, or two letter country.");
   //alert("Please enter a valid email address.(like username@cms.com )");
   return false;
}

if (len<2) {
   var errStr="This address is missing a hostname!";
   //   alert(errStr);
   //alert("Please enter a valid email address.(like username@cms.com )");
   return false;
}
return true;
}


function IsDomain(oObject) {
var emailStr=oObject.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("Email address seems incorrect (check @ and .'s)");
	alert("Please enter a valid email address.(like username@cms.com )");
	return false;
}*/
//var user=matchArray[1];
var domain=emailStr;

/*if (user.match(userPat)==null) {
    //alert("The username in email address doesn't seem to be valid. Please check or register fresh");
    alert("Please enter a valid email address.(like username@cms.com )");
    return false;
}*/
var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {
	  for (var i=1;i<=4;i++) {
	    if (IPArray[i]>255) {
	        //alert("Destination IP address is invalid!");
	       // alert("Please enter a valid email address.(like username@cms.com )");
		return false;
	    }
    }
    return true;
}

var domainArray=domain.match(domainPat);
if (domainArray==null) {
	//alert("The domain name doesn't seem to be valid.");
	//alert("Please enter a valid email address.(like username@cms.com )");
    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("The Email address must end in a three-letter domain, or two letter country.");
   //alert("Please enter a valid email address.(like username@cms.com )");
   return false;
}

if (len<2) {
   var errStr="This address is missing a hostname!";
   //   alert(errStr);
   //alert("Please enter a valid email address.(like username@cms.com )");
   return false;
}
return true;
}


//Validation for proper directory path
function IsPath(oObject)
{
	strPath=oObject.value;
	var strValidChars = "abcdefghigklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
	if(strPath=="")
	{
		alert("Enter proper path");
	}
	var strChar=strPath.charAt(0);
	if (strValidChars.indexOf(strChar) == -1)
	{
		alert("Drive letter is missing")
		return false;
	}
	strChar=strPath.charAt(1);
	if(strChar!=":")
	{
		alert(": missing after drive letter");
		return false;
	}
	strChar=strPath.charAt(2);
	if(strChar!="\\")
	{
		alert("\\ slash is missing after drive letter")
		return false;
	}
	strChar=strPath.charAt(strPath.length-1);
	if(strChar=="\\")
	{
		strChar="";
		for(var intI=0;intI<(strPath.length-1);intI++)
		{
			strChar=strChar + strPath.charAt(intI);
		}
		strPath=strChar;
		oObject.value=strPath;
	}
	return true;
}

//check for price values

function IsPercent(oObject)
{
	var strValidChars = "0123456789.";
   var strChar;
   var blnResult = true;
   var strString=oObject.value;	
   if (strString.length == 0) return false;
	
   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
        else
        {
			if(strString>100)
			{
				blnResult = false;
			}
        }
      }
   return blnResult;
}

function IsPrice(oObject)
{
   var strValidChars = "0123456789.";
   var strChar,iCountDot=0;
   var blnResult = true;
   var strString=oObject.value;	
   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
    {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
      {
         blnResult = false;
      }
      else if(strChar=="."&& iCountDot==0)
      { 
		iCountDot=1;
      }
      else if(strChar==".")
      {
		blnResult=false;
		break;
      }  
    }
   return blnResult;
}
	function ValidateBlank(value)
		{
		//alert(value.length);
		   if(value.length==0)
		    return false;
		   else
		    {
		      var j=0;
		      for(i=0;i<value.length;i++)
		      {
		        if(value.charAt(i)==String.fromCharCode(32))
		        {
		          j++;
		        }
		      }
		    //  alert(j);
		      if(j==(value.length))
		       {
					//alert('Enter a valid header name in alphanumeric values');	       					
		       		return false;
		       }
		       else
		       {
					 return true;
		       }
		    }
		    
		}
//  check for valid strings	
function IsSpl(oObject)
{
   var strValidChars = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_ ()-[]";
   var strChar;
   var blnResult = true;
   var strString=oObject.value;	
   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
	blnResult = true;
   return blnResult;
}
function CheckSpl(oObject)
{
// 
   var strValidChars = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ._-";
   var strChar;
   var blnResult = true;
   var strString=oObject.value;	
  // alert(oObject.value);
   if (strString.length == 0) return false;
	
   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
}
function ChkCharFirst(oObject)
{
  var strValidChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
   var strChar;
   var blnResult = true;
   var strString=oObject.value;	
   if (strString.length == 0) return false;     
   if (strValidChars.indexOf(strString.charAt(0)) == -1)
	{
	blnResult = false;
	} 
   else if(!CheckSpl(oObject))  
     {
   //  alert('2');
        blnResult=false;
     }
     return blnResult; 
}

function isInteger(s){
	var num = s.value;
	if(s.value=="")return false;
	var i;
    for (i = 0; i < num.length; i++){   
        // Check that current character is number.
        var c = num.charAt(i);
        if (((c < "0") || (c > "9"))) return true;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr,msgString){
	//This function will check whether the date is valid or not
	var dtCh= "/";
	var minYear=1900;
	var maxYear=2100;
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(0,pos1)
	var strDay=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert("The date format should be : mm/dd/yyyy in " + msgString)
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Please enter a valid month in " + msgString)
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Please enter a valid day in " + msgString)
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear +" in " + msgString)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInt(stripCharsInBag(dtStr, dtCh))==false){
		alert("Please enter a valid date in " + msgString)
		return false
	}
return true
}

function isInt(s){
	var num = s;
	var i;
    for (i = 0; i < num.length; i++){   
      // Check that current character is number.
      var c = num.charAt(i);
      if (((c < "0") || (c > "9"))) return false;
    }
  // All characters are numbers.
  return true;
}


//This function is used to delete the records
function delete_onclick(oObject)
{
	if(confirm("Are your sure that you want to delete this record ?"))
	{
		oObject.value="delete";
		return true;
	}
	else
	{
		return false;
	}
}

//This function is used for adding the values in selection List control
function AddValue(oObject,oObject1)
{
	if(oObject.selectedIndex!=-1)
	{
		oObject1.options[oObject1.length]=new Option(oObject.options[oObject.selectedIndex].text,oObject.options[oObject.selectedIndex].value)
		oObject.options[oObject.selectedIndex]=null;
	}
}
//This function is used for deleting the values in selection List control
function DeleteValue(oObject,oObject1)
{
	if(oObject1.selectedIndex!=-1)
	{
		oObject.options[oObject.length]=new Option(oObject1.options[oObject1.selectedIndex].text,oObject1.options[oObject1.selectedIndex].value)
		oObject1.options[oObject1.selectedIndex]=null;
	}
}
//This function is used for adding all the values in selection List control
function AddAll(oObject,oObject1)
{
	var intPos=oObject.options.length-1;
	for(var intCounter=oObject.options.length-1;intCounter>=0;intCounter--)
	{
		intPos=intPos-intCounter;
		oObject1.options[oObject1.length]=new Option(oObject.options[intPos].text,oObject.options[intPos].value)
		oObject.options[intPos]=null;
		intPos=oObject.options.length-1;
	}
}
//This function is used for deleting all the values in selection List control
function DeleteAll(oObject,oObject1)
{
	var intPos=oObject1.options.length-1;
	for(var intCounter=oObject1.options.length-1;intCounter>=0;intCounter--)
	{
		intPos=intPos-intCounter;
		oObject.options[oObject.length]=new Option(oObject1.options[intPos].text,oObject1.options[intPos].value)
		oObject1.options[intPos]=null;
		intPos=oObject1.options.length-1;
	}
}

//This function is used for changing the postion of values in selection List control
function LevelUp(oObject)
{
	if(oObject.selectedIndex>0)
	{
		var strValue=oObject.options[oObject.selectedIndex].value;
		var strText=oObject.options[oObject.selectedIndex].text;
		oObject.options[oObject.selectedIndex].value=oObject.options[oObject.selectedIndex-1].value;
		oObject.options[oObject.selectedIndex].text=oObject.options[oObject.selectedIndex-1].text;
		oObject.options[oObject.selectedIndex-1].value=strValue;
		oObject.options[oObject.selectedIndex-1].text=strText;
		oObject.selectedIndex=oObject.selectedIndex-1;
	}	
}

//This function is used for changing the postion of values in selection List control
function LevelDown(oObject)
{
	if(oObject.selectedIndex<oObject.options.length-1 && oObject.selectedIndex!=-1)
	{
		var strValue=oObject.options[oObject.selectedIndex].value;
		var strText=oObject.options[oObject.selectedIndex].text;
		oObject.options[oObject.selectedIndex].value=oObject.options[oObject.selectedIndex+1].value;
		oObject.options[oObject.selectedIndex].text=oObject.options[oObject.selectedIndex+1].text;
		oObject.options[oObject.selectedIndex+1].value=strValue;
		oObject.options[oObject.selectedIndex+1].text=strText;
		oObject.selectedIndex=oObject.selectedIndex+1;
	}	
}

//This function select all the values in SelectionList control
function SelectAllSelection(objList)
{
	objList.multiple=true;
	if (objList.options.length!=-1)
	{
    	if(objList.options.length>1)
    	{
			for(var intCounter=0;intCounter<objList.options.length;intCounter++)
       		{
				objList.options[intCounter].selected=true;
       		}
    	}
	}
  	else
  	{
      objList.options[0].selected=true;
   	}
}

//This function checks for the limit of Characters entered by the user
function LimitChar(objField,intLimit)
{
	if(objField.value.length>intLimit)
	{
		alert("You cannot enter more then " + intLimit + " characters in this field !");
		objField.value=objField.value.substring(0,intLimit);
		objField.focus();
	}
}

//This function wll selects all the checkboxes
function SelectAllCheck(oObject)
{
	if(oObject!=null)
	{
		if(oObject.length!=null)
		{
			for(intCounter=0;intCounter<oObject.length;intCounter++)
			{
				oObject[intCounter].checked=true;
			}
		}
		else
		{
			oObject.checked=true;
		}
	}
}

//This function wll unselects all the checkboxes
function UnSelectAllCheck(oObject)
{
	if(oObject!=null)
	{
		if(oObject.length!=null)
		{
			for(intCounter=0;intCounter<oObject.length;intCounter++)
			{
				oObject[intCounter].checked=false;
			}
		}
		else
		{
			oObject.checked=false;
		}
	}
}

//This function will select the unselect checkboxes and unselects the selected checkbox
function InvertSelectCheck(oObject)
{
	if(oObject!=null)
	{
		if(oObject.length!=null)
		{
			for(intCounter=0;intCounter<oObject.length;intCounter++)
			{
				if(oObject[intCounter].checked==false)
				{
					oObject[intCounter].checked=true;
				}
				else
				{
					oObject[intCounter].checked=false;
				}
			}
		}
		else
		{
			if(oObject.checked==false)
			{
				oObject.checked==true;
			}
			else
			{
				oObject.checked==false;
			}
		}
	}
}

function ConfirmDelete(oObject) 
{
	var blChecked=false;
	if(oObject!=null)
	{
		if(oObject.length!=null)
		{
			for(var intCounter=0;intCounter<oObject.length;intCounter++)
			{
				if(oObject[intCounter].checked==true)
				{
					blChecked=true;
				}
			}
		}
		else
		{
			if(oObject.checked==true)
			{
				blChecked=true;
			}
		}
		
		if(blChecked==false)
		{
			alert("Please select items for deletion !");
			blChecked=false;
		}
		else
		{
			if(confirm("Are you sure you want to delete selected image(s)")==true)
			{
				blChecked=true; 
			}
			else
			{
				blChecked=false; 
			}
		}
	}
	return blChecked;
}	

//This function will check whther checkbox are selected or not
function CheckSelcection(oObject)
{
	var blChecked=false;
	if(oObject!=null)
	{
		if(oObject.length!=null)
		{
			for(var intCounter=0;intCounter<oObject.length;intCounter++)
			{
				if(oObject[intCounter].checked==true)
				{
					blChecked=true;
				}
			}
		}
		else
		{
			if(oObject.checked==true)
			{
				blChecked=true;
			}
		}
		if(blChecked==false)
		{
			alert("Please select item");
		}
		return blChecked;
	}
}

//This function will check whehter the upload file is image type or not
function IsImageFile(oObject)
{
	var strExtension=oObject.value.substring(oObject.value.length-3,oObject.value.length);
	strExtension=strExtension.toLowerCase();
	if(strExtension!="jpg" &&  strExtension!="jpeg" && strExtension!="png")
	{
		alert("Please select only JPG,JPEG and PNG file");
		return false;
	}
	
	return true;
}
// This function checks for blank TextArea
//If text area is blank it reurns false otherwise returns true
function ReplaceEnter(val)
{
	var strData=val
	strData=strData.replace(/[\n\r\s]+/,"","g");
	strData=strData.replace(" ","","g");
	strData=TrimValue(strData);
	if(strData.length==0)
	{
		//alert("Please enter value in Messages");
		return false;
	}
	return true;
}
function IsvalidURL(el){
	var elval= el.value.replace(/[\n\r\s]+/,"");
	if(elval =="") return true;
	var str=el.value
	var filter=/^((ht|f)tp(s?))(:((\/\/)(?!\/)))(((w){3}\.)?)([a-zA-Z0-9\-_\.]+(\.(com|edu|gov|int|mil|net|org|biz|info|name|pro|museum|co\.uk)))((?!\/))(([a-zA-Z0-9\-_\/]*)?)$/i
	if (filter.test(str))
	testresults=true;
	else {el.focus();el.select();testresults=false;}
	return (testresults);
}
function IsvalidURI(el){
	var elval= el.value.replace(/[\n\r\s]+/,"");
	if(elval =="") return true;
	var str=el.value
	var filter=/^((ht|f)tp(s?))(:((\/\/)(?!\/)))(((w){3}\.)?)([a-zA-Z0-9\-_\.]+(\.(com|edu|gov|int|mil|net|org|biz|info|name|pro|museum|co\.uk)))((\/)?)(([a-zA-Z0-9\-_\/?=&%|!@#$\.]*)?)$/i
	if (filter.test(str))
	testresults=true;
	else {el.focus();el.select();testresults=false;}
	return (testresults);
}
function TrimValue(strValue)
{
	var tmp = "";
	var item_length = strValue.length;
	var item_length_minus_1 = strValue.length - 1;
	for (index = 0; index < item_length; index++)
	{
		if (strValue.charAt(index) != " ")
		{
		tmp += strValue.charAt(index);
		}
		else
		{
		if (tmp.length > 0)
		{
			if (strValue.charAt(index+1) != " " && index != item_length_minus_1)
			{
			tmp += strValue.charAt(index);
			}
		}
		}
}
strValue = tmp;
return strValue;
}

function DisableQuote(e) 
	{	
		var isIE = document.all ? true:false;
		var isNS6 = !isIE && document.getElementById ? true:false;
		if(isIE)
		{
		if(event.keyCode==222)
			return false;
		else
			return true;
		}
		else
		{		
			if(e.which==222)
			{			
				//return void(0);
				//window.returnValue = false;
				return false;
				//e.returnValue =false;
				//event.which=0;
			}
			else
			{
				return true;
			}			
		}
	}
/********************************************************************************************************
Modified By  - Narendra Shrama
Date Created - 24/01/05
Description  - Function add more client side validation.
********************************************************************************************************/
/********************************************************************************************************/
function TextAreaKeyDown_Handler(objElement,intLength) {
	if(objElement.value.length < intLength)
		return true;
	alert("Provide content has exceeded the maximum limit of " + intLength + " characters.");
	objElement.focus();
	return false;
	}
/********************************************************************************************************/
function isValidImageFile(oFile) {
	var strPath = oFile.value;
	var arrSplit = strPath.split(".");
	var arrExtension = Array("jpg","jpeg","gif","bmp","tif");
	if(arrSplit == "undefined")
		return false;
	for(var index = 0; index < arrExtension.length; index++) {
		if(arrSplit[arrSplit.length-1] == arrExtension[index])
			return true;
		}
	return false;
	}
/********************************************************************************************************/
function IsPhoneFax(oObject)
{
   var strValidChars = "1234567890-";
   var strChar;
   var blnResult = true;
   var strString = oObject.value;	
   if (strString.length == 0) return false;
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
}
/********************************************************************************************************/
function IsValidLog_Pwd(oObject) {
   var strValidChars = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_";
   var strChar;
   var blnResult = true;
   var strString=oObject.value;	
   if (strString.length == 0) return false;
   for (i = 0; i < strString.length && blnResult == true; i++) {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1) {
         blnResult = false;
         }
      }
   return blnResult;
	}
/********************************************************************************************************/
function IsValidName(oObject) {
   var strValidChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
   var strChar;
   var blnResult = true;
   var strString=oObject.value;	
   if(strString.length == 0) 
		return false;
   if(strValidChars.indexOf(strString.charAt(0)) == -1)
		return false;
   strValidChars = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_. ";
   for (i = 0; i < strString.length && blnResult == true; i++) {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1) {
         blnResult = false;
         }
      }
   return blnResult;
	}
/********************************************************************************************************/
function isEmptyString(strValue) {
	if(((strValue == "") || (strValue.length == 0)))
		return true;
	return false;
	}
/********************************************************************************************************/
function isValidString(strValue,strInvalid) {
	//strInvalid = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_0123456789";
	if(isEmptyString(trimString(strInvalid)))
		strInvalid = strInvalid + "~`!@#$%^&*()-+=|[{}]|:;<,>.?\"/\\ ";
	var strValueLen = strValue.length;
	var strInvalidLen = strInvalid.length;
	for(var i = 0; i < strValueLen; i++) {
		for(var j = 0; j < strInvalidLen; j++) {
			if(strValue.charAt(i) == strInvalid.charAt(j))
				return false;
			}
		}
	return true;
	}
/********************************************************************************************************/
function trimString(strValue) {
	var chrSpace = " ";
	/*This section is for LEFT trimming of any string*/
	for(var i = 0; i < strValue.length; i++) {
		if(strValue.charAt(i) != chrSpace)
			break;
		}
	if(i != 0)
		strValue = strValue.substring(i,strValue.length);
	/*This section is for RIGHT trimming of any string*/
	for(i = (strValue.length-1); i >= 0; i--) {
		if(strValue.charAt(i) != chrSpace)
			break;
		}
	if(i != (strValue.length-1))
		strValue = strValue.substring(0,(i+1));
	return strValue;
	}	
/********************************************************************************************************/

/*Code By Vivek Davey for reseting the form and replace the double quote from the browse control*/
//This function will reset the form
function ResetForm(objForm)
{
	for(var intCounter=0;intCounter<objForm.elements.length;intCounter++)
	{
		if(objForm.elements[intCounter].type!=null)
		{
			if(objForm.elements[intCounter].type=="text")
			{
				objForm.elements[intCounter].value="";
			}
			else if(objForm.elements[intCounter].type=="select-one")
			{
				objForm.elements[intCounter].selectedIndex=0;	
			}
			else if(objForm.elements[intCounter].type=="file")
			{
				var oObject=objForm.elements[intCounter];
				var strValue=oObject.outerHTML;	
				var strFieldValue=oObject.value;
				strValue=strValue.replace(strFieldValue,"");
				oObject.outerHTML=strValue;
			}
			else if(objForm.elements[intCounter].type=="textarea")
			{
				objForm.elements[intCounter].value="";
			}
		}
	}
}
function ReplaceDoubleQuote(oObject)
{
	var strValue=oObject.value;
	if(strValue.indexOf("\"")>=0)
	{
		alert("Please enter a valid file name.");
		strValue=oObject.outerHTML;	
		var strRegExp=/\"/g;
		strValue=strValue.replace(strRegExp,"");
		oObject.outerHTML=strValue;
	}
	
}
//function for change the selection of child check boxes on the basis of parent check box
function ChangeCheckboxSelection(objParent,objChild)
{
	if(objParent!=null)
	{
		if(objChild!=null)
		{
			if(objChild.length!=null)
			{
				for(var intCounter=0;intCounter<objChild.length;intCounter++)
				{
					objChild[intCounter].checked=objParent.checked;
				}
			}
			else
			{
				objChild.checked=objParent.checked;
			}
		}
	}
}
function IsValidCharacter(oObject)
		{
			var strValidChars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_";
			var strChar;
			var blnResult = true;
			var strString=oObject.value;	
			if (strString.length == 0) return false;
			//alert('1');
			//  test strString consists of valid characters listed above
			for (i = 0; i < strString.length && blnResult == true; i++)
				{
				strChar = strString.charAt(i);
				if (strValidChars.indexOf(strChar) == -1)
					{
					blnResult = false;
					}
				}
			return blnResult;
				
		}
//function for un selecting the parent object if any child get unselect
function CheckParentCheckboxSelection(objParent,objChild)
{
	if(objParent.checked==true && objChild.checked==false)
	{
		objParent.checked=false;
	}
}
/********************************************************************************************************/