	function F_Focus(A_Object)
	{
		document.getElementById(A_Object).focus();
	}
	
	function  F_Confirmation(A_Message)
    {
		var truthBeTold = window.confirm(A_Message);
		if(truthBeTold) 
			{
				return true;
			}
			else
			{
				return false;
			}
    }
    
    function F_Space(A_Spaces)
	{
		var Ls_Return = '';
		for(var i=1;i<=A_Spaces;i++)
			{
				Ls_Return = Ls_Return + ' ';
			}
		return Ls_Return;
	}
	
	function F_ChkNull(A_TextBox,A_Message)
	{
		for(var i=0;i<A_TextBox.length;i++)
			{
				if (Trim(document.Form1.item(A_TextBox[i]).value) == "")
					{
					alert(A_Message[i]);
					document.getElementById(A_TextBox[i]).focus();
					return false;
					}	
			}
			return true;
	}
	
	function F_ChkNullCombo(A_Combo,A_Message)
	{
		for(var i=0;i<A_Combo.length;i++)
			{
				if (document.getElementById(A_Combo[i]).selectedIndex == 0)
					{
					alert(A_Message[i]);
					document.getElementById(A_Combo[i]).focus();
					return false;
					}	
			}
			return true;
	}
	
				
	function LTrim(str)
	{
		var whitespace = new String(" \t\n\r");
		var s = new String(str);

		if (whitespace.indexOf(s.charAt(0)) != -1) 
		{
			var j=0, i = s.length;
			while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
				j++;
			s = s.substring(j, i);
		}
		return s;
	}

	function RTrim(str)
	{
		var whitespace = new String(" \t\n\r");
		var s = new String(str);
		if (whitespace.indexOf(s.charAt(s.length-1)) != -1) 
		{

			var i = s.length - 1;       
			while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
			i--;
			s = s.substring(0, i+1);
		}
		return s;
	}

	function Trim(str)
	{
		return RTrim(LTrim(str));
	}
		

	function F_EmailCheck(emailStr) 
	{
		if(Trim(emailStr).length==0)
		{
		return true;
		}

		/* The following variable tells the rest of the function whether or not
		to verify that the address ends in a two-letter country or well-known
		TLD.  1 means check it, 0 means don't. */

		var checkTLD=1;

		/* The following is the list of known TLDs that an e-mail address must end with. */

		var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;

		/* The following pattern is used to check if the entered e-mail address
		fits the user@domain format.  It also is used to separate the username
		from the domain. */

		var emailPat=/^(.+)@(.+)$/;

		/* The following string represents the pattern for matching all special
		characters.  We don't want to allow special characters in the address. 
		These characters include ( ) < > @ , ; : \ " . [ ] */

		var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";

		/* The following string represents the range of characters allowed in a 
		username or domainname.  It really states which chars aren't allowed.*/

		var validChars="\[^\\s" + specialChars + "\]";

		/* The following pattern applies if the "user" is a quoted string (in
		which case, there are no rules about which characters are allowed
		and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
		is a legal e-mail address. */

		var quotedUser="(\"[^\"]*\")";

		/* The following pattern applies for domains that are IP addresses,
		rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
		e-mail address. NOTE: The square brackets are required. */

		var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;

		/* The following string represents an atom (basically a series of non-special characters.) */

		var atom=validChars + '+';

		/* The following string represents one word in the typical username.
		For example, in john.doe@somewhere.com, john and doe are words.
		Basically, a word is either an atom or quoted string. */

		var word="(" + atom + "|" + quotedUser + ")";

		// The following pattern describes the structure of the user

		var userPat=new RegExp("^" + word + "(\\." + word + ")*$");

		/* The following pattern describes the structure of a normal symbolic
		domain, as opposed to ipDomainPat, shown above. */

		var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

		/* Finally, let's start trying to figure out if the supplied address is valid. */

		/* Begin with the coarse pattern to simply break up user@domain into
		different pieces that are easy to analyze. */

		var matchArray=emailStr.match(emailPat);

		if (matchArray==null) 
		{

			/* Too many/few @'s or something; basically, this address doesn't
			even fit the general mould of a valid e-mail address. */

			alert("Email address seems incorrect (check @ and .'s)");
			return false;
		}
		var user=matchArray[1];
		var domain=matchArray[2];

		// Start by checking that only basic ASCII characters are in the strings (0-127).

		for (i=0; i<user.length; i++) 
		{
			if (user.charCodeAt(i)>127) 
			{
				alert("The username contains invalid characters.");
				return false;
			}
			}
		for (i=0; i<domain.length; i++) 
		{
			if (domain.charCodeAt(i)>127) 
			{
				alert("Ths domain name contains invalid characters.");
			return false;
			}
		}

		// See if "user" is valid 

		if (user.match(userPat)==null) 
		{
			// user is not valid

			alert("The username doesn't seem to be valid.");
			return false;
		}

		/* if the e-mail address is at an IP address (as opposed to a symbolic
		host name) make sure the IP address is valid. */

		var IPArray=domain.match(ipDomainPat);
		if (IPArray!=null)
		{

			// this is an IP address

			for (var i=1;i<=4;i++) 
			{
				if (IPArray[i]>255) 
				{
				alert("Destination IP address is invalid!");
				return false;
				}
			}
			return true;
		}

		// Domain is symbolic name.  Check if it's valid.
	 
		var atomPat=new RegExp("^" + atom + "$");
		var domArr=domain.split(".");
		var len=domArr.length;
		for (i=0;i<len;i++) 
		{
			if (domArr[i].search(atomPat)==-1) 
			{
			alert("The domain name does not seem to be valid.");
			return false;
			}
		}

		/* domain name seems valid, but now make sure that it ends in a
		known top-level domain (like com, edu, gov) or a two-letter word,
		representing country (uk, nl), and that there's a hostname preceding 
		the domain or country. */

		if (checkTLD && domArr[domArr.length-1].length!=2 && 
		domArr[domArr.length-1].search(knownDomsPat)==-1) 
		{
			alert("The address must end in a well-known domain or two letter " + "country.");
			return false;
		}

		// Make sure there's a host name preceding the domain.

		if (len<2) 
		{
			alert("This address is missing a hostname!");
			return false;
		}

		// If we've gotten this far, everything's valid!
		return true;
	}

	function F_ValidatePassword(A_PassWord)
	{
		// Password Matching Function 
		// Match all alphanumeric character and predefined wild characters
		// Password must consists of at least 6 characters and not more than 15 characters.  
		// It Can Not Contain Space
		var reg = new RegExp("^([a-zA-Z0-9@*#]{6,15})$");
		if( reg.test(A_PassWord))
		{
			return true;
		}
		else
		{
			return false;
		}
	}

	function F_ValidateNumber(A_Number)
	{
		var reg = new RegExp("^[+-]?([0-9]*\.?[0-9]+|[0-9]+\.?[0-9]*)([eE][+-]?[0-9]+)?$");
		if( reg.test(A_Number))
		{
			return true;
		}
		else
		{
			return false;
		}
	}    
	
	function F_ValidateString(A_Number)
	{
		var reg = new RegExp("[0-9A-Za-z]");
		if( reg.test(A_Number))
		{
			return true;
		}
		else
		{
			return false;
		}
	}    
	
	function F_ValidateAlphNumeric(A_Number)
	{
		var reg = new RegExp("^[a-zA-z][a-zA-Z0-9]+$");
		if( reg.test(A_Number))
		{
			return true;
		}
		else
		{
			return false;
		}
	}   
	
	function F_ValidateEmail(A_Number)
	{
		var reg = new RegExp("^[A-Za-z0-9](([_\.\-]?[a-zA-Z0-9]+)*)@([A-Za-z0-9]+)(([\.\-]?[a-zA-Z0-9]+)*)\.([A-Za-z]{2,})$");
		if( reg.test(A_Number))
		{
			return true;
		}
		else
		{
			return false;
		}
	}   
	//by kunal:KUN-0001-20050127
	function Frm_MaskKeyPress(objEvent) 
	{
		var iKeyCode;       
		iKeyCode = objEvent.keyCode;
		var c = String.fromCharCode(iKeyCode);
		if((iKeyCode>=96 && iKeyCode<=105) || (objEvent.shiftKey==false && iKeyCode>=48 && iKeyCode<=57 ) || (iKeyCode>=37 && iKeyCode<=40) || (iKeyCode>=16 && iKeyCode<=18) || (iKeyCode==9) || (iKeyCode==46) || (iKeyCode==8)){
			return true;
		}
		return false;
	}
	//by kunal
	
	function Frm_IsDate(A_Day,A_Month,A_Year)
	{
		v=new Date(A_Month+"/"+A_Day+"/"+A_Year); 
		if (v.getMonth()!=A_Month-1) 
		{
			return false; 
		}
		else
		{
			return true;
		}
	}

//By Varsha.	
//Array of Textboxes and its Array of corresponding Max Chars. 
//Checks the maximum no of Characters allowed.
//to validate that user does not exceed more than the specified max length.
function CheckMaxLength(Txt,Maxlength)
{
	var Li_Loop;
	var Val;
	for(Li_Loop=0;Li_Loop<Txt.length;Li_Loop++)
	{
		Val=document.getElementById(Txt[Li_Loop]).value;
		if(Val.length>eval(Maxlength[Li_Loop]))
		{
			alert('Maximum '+ Maxlength[Li_Loop] +' characters are allowed');
			document.getElementById(Txt[Li_Loop]).focus();
			return false;
		}
	}
	return true;
}


//=============================by Varsha
	/*
		1-Numeric
		2-Alphabets
		3-Alphanumeric
		*/
	function Frm_MaskKey(objEvent,Type) 
	{
		var iKeyCode;       
		iKeyCode = objEvent.keyCode;
	
		//Space-32,Backspace-8,delete-46 and arrow keys-37 to 40
		if(iKeyCode==8||iKeyCode==46||(iKeyCode>=37&&iKeyCode<=40)||iKeyCode==13)
		{
			return true;
		}
		var character = String.fromCharCode(iKeyCode);
		
		
	switch(Type)
	{
		case 1:
				if(F_ValidNumber(objEvent,iKeyCode)==true)
				{
					return true;
					}
				break;
		case 2:
				if(F_ValidAlphabets(objEvent,iKeyCode)==true)
				{
				return true;
				}	
			break;
		case 3:
				if(F_ValidNumAlphabets(objEvent,iKeyCode)==true)
				{
					return true;
				}
			break;
}
return false;
}
	
/*	//By Varsha.
	function F_ValidateAlphabets(Character)
	{
		var reg = new RegExp("^[A-Za-z]+$");
		if( reg.test(Character))
		{
			return true;
		}
		else
		{
			return false;
		}
	}  
	
	function F_ValidateAlphaNumeric(Character)
	{
		var reg = new RegExp("[a-zA-Z0-9]");
		if( reg.test(Character))
		{
			return true;
		}
		else
		{
			return false;
		}
	}   

	*/
function F_ValidNumber(objEvent,iKeyCode)
{
		if((iKeyCode>=96 && iKeyCode<=105) || (objEvent.shiftKey==false && iKeyCode>=48 && iKeyCode<=57 ) || (iKeyCode>=37 && iKeyCode<=40) || (iKeyCode>=16 && iKeyCode<=18) || (iKeyCode==9) || (iKeyCode==46) || (iKeyCode==8)||(iKeyCode==35)||(iKeyCode==36))
		{
		  return true;
		}
}

function F_ValidAlphabets(objEvent,iKeyCode)
{
		if((iKeyCode>=65 && iKeyCode<=90 ) || (iKeyCode>=37 && iKeyCode<=40) || (iKeyCode>=16 && iKeyCode<=18) || (iKeyCode==9) || (iKeyCode==46) || (iKeyCode==8)||(iKeyCode==35)||(iKeyCode==36)|| (iKeyCode==32))
		{
		  return true;
		}
}

function F_ValidNumAlphabets(objEvent,iKeyCode)
{
		if((objEvent.shiftKey==false && iKeyCode>=48 && iKeyCode<=57 )||(iKeyCode>=65 && iKeyCode<=90 ) || (iKeyCode>=37 && iKeyCode<=40) || (iKeyCode>=16 && iKeyCode<=18) || (iKeyCode==9) || (iKeyCode==46) || (iKeyCode==8)||(iKeyCode==35)||(iKeyCode==36) || (iKeyCode==32))
		{
		  return true;
		}
}

function F_ValidNumberWithSpChrs(objEvent,iKeyCode,SpecChars,SpCharsWithoutShift)
{
var Li_Loop;
var Lb_Condition=false;

if((iKeyCode>=96 && iKeyCode<=105) || (objEvent.shiftKey==false && iKeyCode>=48 && iKeyCode<=57 ) || (iKeyCode>=37 && iKeyCode<=40) || (iKeyCode>=16 && iKeyCode<=18) || (iKeyCode==9) || (iKeyCode==46) || (iKeyCode==8)||(iKeyCode==35)||(iKeyCode==36))
						Lb_Condition= true;
			else
						Lb_Condition=false;

if(SpecChars!=null)
{
for(Li_Loop=0;Li_Loop<SpecChars.length;Li_Loop++)
	{
		if(Lb_Condition||((objEvent.shiftKey==true)&&(iKeyCode==SpecChars[Li_Loop])))
						Lb_Condition=true;
		else
						Lb_Condition=false;
	}
}	
	//*Add SpCharsWithoutShift
	if(SpCharsWithoutShift!=null)
	{
	for(Li_Loop=0;Li_Loop<SpCharsWithoutShift.length;Li_Loop++)
	{
		if(Lb_Condition||((objEvent.shiftKey==false)&&(iKeyCode==SpCharsWithoutShift[Li_Loop])))
						Lb_Condition=true;
		else
						Lb_Condition=false;
	}
}
	return Lb_Condition;
}

function F_ValidAlphabetsWithSpChars(objEvent,iKeyCode,SpecChars,SpCharsWithoutShift)
{
var Li_Loop;
var Lb_Condition=false;

if((iKeyCode>=65 && iKeyCode<=90 ) || (iKeyCode>=37 && iKeyCode<=40) || (iKeyCode>=16 && iKeyCode<=18) || (iKeyCode==9) || (iKeyCode==46) || (iKeyCode==8)||(iKeyCode==35)||(iKeyCode==36))
						Lb_Condition= true;
			else
						Lb_Condition=false;
if(SpecChars!=null)
{
for(Li_Loop=0;Li_Loop<SpecChars.length;Li_Loop++)
	{
		if(Lb_Condition||((objEvent.shiftKey==true)&&(iKeyCode==SpecChars[Li_Loop])))
						Lb_Condition=true;
		else
						Lb_Condition=false;
	}
}	
		//*Add SpCharsWithoutShift
if(SpCharsWithoutShift!=null)
{
	for(Li_Loop=0;Li_Loop<SpCharsWithoutShift.length;Li_Loop++)
	{
		if(Lb_Condition||((objEvent.shiftKey==false)&&(iKeyCode==SpCharsWithoutShift[Li_Loop])))
						Lb_Condition=true;
		else
						Lb_Condition=false;
	}
}
	return Lb_Condition;
}

//Special Chars ! ,@,#,$,%,^,&,*,(,),
function F_ValidNumAlphabetsWithSpChars(objEvent,iKeyCode,SpecChars,SpCharsWithoutShift)
{
var Li_Loop;
var Lb_Condition=false;

if((objEvent.shiftKey==false && iKeyCode>=48 && iKeyCode<=57 )||( iKeyCode>=65 && iKeyCode<=90 ) || (iKeyCode>=37 && iKeyCode<=40) || (iKeyCode>=16 && iKeyCode<=18) || (iKeyCode==9) || (iKeyCode==46) || (iKeyCode==8)||(iKeyCode==35)||(iKeyCode==36))
						Lb_Condition= true;
			else
						Lb_Condition=false;
	
	if(SpecChars!=null)
	{		
		for(Li_Loop=0;Li_Loop<SpecChars.length;Li_Loop++)
			{
				if(Lb_Condition||((objEvent.shiftKey==true)&&(iKeyCode==SpecChars[Li_Loop])))
								Lb_Condition=true;
				else
								Lb_Condition=false;
			}
	}
		//*Add SpCharsWithoutShift
		if(SpCharsWithoutShift!=null)
		{		
		for(Li_Loop=0;Li_Loop<SpCharsWithoutShift.length;Li_Loop++)
		{
			if(Lb_Condition||((objEvent.shiftKey==false)&&(iKeyCode==SpCharsWithoutShift[Li_Loop])))
							Lb_Condition=true;
			else
							Lb_Condition=false;
		}
		}
	return Lb_Condition;
}
	
	function Frm_MaskKeyWithSpChars(objEvent,Type,SpChars,SpCharsWithoutShift) 
	{
		var iKeyCode;       
		iKeyCode = objEvent.keyCode;
		
	switch(Type)
	{
		case 1:
				if(F_ValidNumberWithSpChrs(objEvent,iKeyCode,SpChars,SpCharsWithoutShift)==true)
				{
					return true;
					}
				break;
		case 2:
				if(F_ValidAlphabetsWithSpChars(objEvent,iKeyCode,SpChars,SpCharsWithoutShift)==true)
				{
				return true;
				}	
			break;
			case 3 :
				if(F_ValidNumAlphabetsWithSpChars(objEvent,iKeyCode,SpChars,SpCharsWithoutShift)==true)
				{
				return true;
				}	
}
return false;
}

function ValidateTel(objEvent)
		{
		   //Validate Tel..
      var Sp=["48","57"];
			var SpWithoutShift=["188","189"];
			return Frm_MaskKeyWithSpChars(event,1,Sp,SpWithoutShift);
		}
		
function ValidateMobile(objEvent)
{
	var Sp=[];
	var SpWithoutShift=["188"];
	return Frm_MaskKeyWithSpChars(event,1,Sp,SpWithoutShift);
}

function ValidateAmount(objEvent)
{
var SpChars=[];
var SpCharsWithoutShift=["190"];
return Frm_MaskKeyWithSpChars(event,1,SpChars,SpCharsWithoutShift);
}
		
function GettheKeyCode(objEvent)
{
	var iKeyCode;       
		iKeyCode = objEvent.keyCode;
	alert(iKeyCode);
	return true;
}
/*
`   192
1		49
2		50
3		51	
4		52		
5		53
6		54	
7		55
8		56
9		57	
0		48
-		189
,		188
.		190
*/
//=================	

function F_ValidateUserName(A_UserName)
	{
		var reg = new RegExp("^\[A-Za-z0-9]+(_{0,1}[A-Za-z0-9]+){0,20}$");
		if( reg.test(A_UserName))
		{
			return true;
		}
		else
		{
			return false;
		}
	}
	
	//Check for only Textboxes, Comboboxes and Radio Buttons
	function CheckMandatory(Po_Obj,Ps_Msg)
	{
	  var Elem=null;
		for(var i=0;i<Po_Obj.length;i++)
			{
			Elem = document.getElementById(Po_Obj[i]);
			
			if (Elem == null) {return true;}			  
			if(Elem.type=="text"||Elem.type=="password"||Elem.type=="textarea")
				{
				if((Trim(Elem.value)).length == 0)
					{
					alert(Ps_Msg[i] + " cannot be left blank");
					Elem.focus();
					return false;
					}	
				}
				else
				{
					if(Elem.type=="select-one")
					{
						if(Elem.selectedIndex==0)
						{
						alert("Select " + Ps_Msg[i]);
						Elem.focus();
						return false;			
						}
					}
				}
			}
			return true;
	}
	
function FindOpenerControl(Control)
		{
		    var ControlName=Control;
		    var RunControlName="";
		    var ControlFound="";
		    var Lo_Form=opener.document.Form1;
				for (i=0,n=Lo_Form.elements.length;i<n;i++)
				{
										
						RunControlName=Lo_Form.elements[i].name;
						var StartFrom=eval(RunControlName.length-ControlName.length);
						if (RunControlName.substring(StartFrom) == ControlName)
						{
						  if ( RunControlName.length > ControlName.length )
						  {
						    ControlFound=Lo_Form.elements[i];
						    return ControlFound;
						  }
						  //alert(ControlFound.name);
						}
				}
				
				
				
		}

function FindControl(Control)
		{
		    var ControlName=Control;
		    var RunControlName="";
		    var ControlFound="";
		    var Lo_Form=document.Form1;
				for (i=0,n=Lo_Form.elements.length;i<n;i++)
				{
										
						RunControlName=Lo_Form.elements[i].name;
						var StartFrom=eval(RunControlName.length-ControlName.length);
						if (RunControlName.substring(StartFrom) == ControlName)
						{
						  if ( RunControlName.length > ControlName.length )
						  {
						    ControlFound=Lo_Form.elements[i];
						    return ControlFound;
						  }
						  //alert(ControlFound.name);
						}
				}
				
				
				
		}

function FindLinks(LinkName)
{
		var RunControlName="";
		var ControlFound="";
		for (i=0,n=document.links.length;i<n;i++)
		{
				RunControlName=document.links[i].id;
				var StartFrom=eval(RunControlName.length-LinkName.length);
				if (RunControlName.substring(StartFrom) == LinkName)
				{
					if (RunControlName.length > LinkName.length)
					{
						ControlFound=document.links[i];
						return ControlFound;
					}
				}
		}		
}
function SetOpenerTextBox(Po_TxtObjName,Ps_TxtValue)
{
	var Lo_Obj=FindOpenerControl(Po_TxtObjName);
	if (Lo_Obj)
	{
		Lo_Obj.value=Ps_TxtValue;
		return true;
	}
	
	return false;
}


/*
	function  ConfirmnSetText(A_Message,Lo_Obj)
    {
		var truthBeTold = window.confirm(A_Message);
		var Lo_Obj=FindControl(Lo_Obj);
		
		if(Lo_Obj==null)
		{
				return false;
		}
		else
		{
				Lo_Obj.value=truthBeTold ;
		}
}*/

