   var Message = "";
   function Trim(string,LorR)//-- to trim off leading,trailing or both spaces from a string
   {//- string -> string value , LorR -> 'left' or 'right'
     var s = String(string);
		 var start = 0;
		 var end = s.length ;

	   if(LorR != "left" && LorR != "right")//-- default trim form both sides
	   {
				for(var i=0 ; i<= end; i++)//-- find first non space cahracter
				{
					if(s.charAt(i) != " ")
					{
						start = i;
						break;
					}
				}
				for(var i= end ; i>=0; i--)//-- find last non space charecter
				{
					if(s.charAt(i) != " ")
					{
						end = i;
						break;
					}
				}
     }
	   else if(LorR == "left")//--- trim from start of the string only
	   {
				for(var i=0 ; i<= s.length-1; i++)//-- find first non space charecter
				{
					if(s.charAt(i) != " ")
					{
						start = i;
						break;
					}
				}

			}
			else if(LorR == "right")//--- trim from end of the string only
			{
				for(var i=s.length-1 ; i>=0; i--)//-- find last non space charecter
				{
					if(s.charAt(i) != " ")
					{
						end = i;
						break;
					}
				}
	    }

	   return s.slice(start,end);//--- return trimed string

   }
//===============================================================
	function checkEMail(strEmailAdd)
	{	
		var strRetCode			= new String()
		var locAt;	
		var locPeriod;
		
		strRetCode = true; //No Errors
			
		//Check 1
		if((strEmailAdd.indexOf(" ") != -1)  || (strEmailAdd == null))
		{
				strRetCode = false;
		}
	
		//Check 2
		if(strEmailAdd == "")
		{
				strRetCode = false;
		}

		//Check 3
		for(var cnt=0; cnt < strEmailAdd.length; cnt++)
		{
				nCharCode = strEmailAdd.charCodeAt(cnt)
					
				//check to see if between "A" - "Z" or "a" - "z" or "0" - "9" or "@" or "." or "_"
				if( !(((nCharCode > 64) && (nCharCode < 91)) || ((nCharCode > 96) && (nCharCode < 123))  || ((nCharCode > 47) && (nCharCode < 58)) || (nCharCode == 64) || (nCharCode == 46) || (nCharCode == 95) || (nCharCode == 45)))
				{
					strRetCode = false;
				} 
		}
			
		//Check 4
		locAt = strEmailAdd.indexOf("@");	
		if(!(((locAt != -1) && (locAt != 0) &&	(locAt != (strEmailAdd.length - 1)) && (strEmailAdd.indexOf("@", locAt + 1) == -1))))
		{
				strRetCode = false;
		}	
		
		//Check 5
		locPeriod = strEmailAdd.indexOf(".");
		if(!(((locPeriod != -1) && (locPeriod != (strEmailAdd.length - 1))&& (locPeriod > locAt))))
		{
				strRetCode = false;
		}
		
		return strRetCode	;
	
	}
//===============================================================
  function val_Email(TextBox,Required)//--- checks for valid email id
  {//--- TextBox -> valid textbox object | Required -> reuired entry 'true' or 'false'
		var val = String(TextBox.value);
		
		switch (Required)
		{
			case true: 
				return checkEMail(val);
			default :
				if(Trim(val) != "")
				{
					return checkEMail(val);
				}
				else
				{
					return true;
				}
		}
  }
//===============================================================
  function val_Required(TextBox)//--- checks for empty textbox
  {//-- TextBox -> textbox object
		var val = String(TextBox.value);
		Message = "";
		if(Trim(val).length <= 0)
		{
			return false;
		}
  }
//===============================================================
   function val_TextLength(TextBox,length,Required)//-- checks for total charecter in the textbox
   {
			var val = String(TextBox.value);
			Message = "";
			switch (Required)
			{
				case true:
					if(Trim(val) == "")
					{
						return false;
					}
					else if(Trim(val).length >= length)
					{
						return false;
					}

				default:
					if(Trim(val) != "" && Trim(val).length >= length)
					{
						return false;
					}
					else
					{
						return true;
					}
			}
		
   }
//===============================================================
   function val_Number(TextBox,Required)
	 {
			var val = String(TextBox.value);
			//var a_Valid = new Array("0","1","2","3","4","5","6","7","8","9",".");
			var Returnval = true;
			var strRetCode			= new String()
			var nMinPwdLength		= 3
			var nCharCode
	
			switch (Required)
			{
				case true :
					if(Trim(val) != "")
					{
						//Check 4
						for(var cnt=0; cnt < val.length; cnt++)
						{
								nCharCode = val.charCodeAt(cnt)
								
								//check to see if between "A" - "Z" or "a" - "z" or "0" - "9"
								if( !((nCharCode > 47) && (nCharCode < 58)) && nCharCode != 46)
								{
									Returnval = false;
								} 
						}
						return Returnval;
					}
					else
					{
						return false;
					}
				default :
					if(Trim(val) != "")
					{
							//Check 4
							for(var cnt=0; cnt < val.length; cnt++)
							{
									nCharCode = val.charCodeAt(cnt)
									
									//check to see if between "A" - "Z" or "a" - "z" or "0" - "9"
									if( !((nCharCode > 47) && (nCharCode < 58)) && nCharCode != 46)
									{
										Returnval = false;
									} 
							}

						return Returnval;
					}
					else
					{
						return true;
					}
			}
	 }
//===============================================================
   function val_Alphabets(TextBox,Required)
	 {
			var val = String(TextBox.value);
			//var a_Valid = new Array("A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"," ");
			var Returnval = true;
			var strRetCode			= new String()
			var nMinPwdLength		= 3
			var nCharCode

			switch (Required)
			{
				case true :
					if(Trim(val) != "")
					{
						//Check 4
						for(var cnt=0; cnt < val.length; cnt++)
						{
							nCharCode = val.charCodeAt(cnt)
							
							//check to see if between "A" - "Z" or "a" - "z" or "0" - "9"
							if( !(((nCharCode > 64) && (nCharCode < 91)) || ((nCharCode > 96) && (nCharCode < 123))) && nCharCode != 32)
							{
								Returnval = false;
							} 
						}
						return Returnval;
					}
					else
					{
						return false;
					}

				default :
					if(Trim(val) != "")
					{
						//Check 4
						for(var cnt=0; cnt < val.length; cnt++)
						{
							nCharCode = val.charCodeAt(cnt)
							
							//check to see if between "A" - "Z" or "a" - "z" or "0" - "9"
							if( !(((nCharCode > 64) && (nCharCode < 91)) || ((nCharCode > 96) && (nCharCode < 123))) && nCharCode != 32)
							{
								Returnval = false;
							} 
						}
						return Returnval;
					}
					else
					{
						return true;
					}

			}
	 }
//===============================================================
   function val_Phone(TextBox,Required)
	 {
			var val = String(TextBox.value);
			//var a_Valid = new Array("0","1","2","3","4","5","6","7","8","9"," ","-","(",")");
			Returnval = true;
			var strRetCode			= new String()
			var nMinPwdLength		= 3
			var nCharCode
			
			switch (Required)
			{
				case true :
					if(Trim(val) != "")
					{
						//Check 4
						for(var cnt=0; cnt < val.length; cnt++)
						{
								nCharCode = val.charCodeAt(cnt)
								
								//check to see if between "A" - "Z" or "a" - "z" or "0" - "9"
								if( !((nCharCode > 47) && (nCharCode < 58)) && nCharCode != 32 && nCharCode != 45 && nCharCode != 40 && nCharCode != 41)
								{
									Returnval = false;
								} 
						}
						return Returnval;
					}
					else
					{
						return false;
					}
				default :
					if(Trim(val) != "")
					{
						//Check 4
						for(var cnt=0; cnt < val.length; cnt++)
						{
								nCharCode = val.charCodeAt(cnt)
								
								//check to see if between "A" - "Z" or "a" - "z" or "0" - "9"
								if( !((nCharCode > 47) && (nCharCode < 58)) && nCharCode != 32 && nCharCode != 45 && nCharCode != 40 && nCharCode != 41)
								{
									Returnval = false;
								} 
						}
						return Returnval;
					}
					else
					{
						return true;
					}
			}
	 }
//===============================================================
	function Browser()
	{
		if(document.all)
		{
			return "IE";
		}
		else
		{
			return "NN";
		}
	}
//===============================================================
	function B_version()
	{
		return parseFloat(navigator.appVersion);
	}
//===============================================================
	function val_Password(TextBox)
	{
			var strPassword = String(TextBox.value);
			
			var strRetCode			= new String()
			var nMinPwdLength		= 3
			var nCharCode
			
			strRetCode = true; //No Errors
			
			//Check 1
			if((strPassword.indexOf(" ") != -1)  || (strPassword == null))
			{
					strRetCode = false;
			}
	
			//Check 2
			if(strPassword == "")
			{
					strRetCode = false;
			}
			
			
			//Check 3
			if(strPassword.length <= nMinPwdLength)
			{
					strRetCode = false;
			}
			
			
			//Check 4
			for(var cnt=0; cnt < strPassword.length; cnt++)
			{
					nCharCode = strPassword.charCodeAt(cnt)
					
					//check to see if between "A" - "Z" or "a" - "z" or "0" - "9"
					if( !(((nCharCode > 64) && (nCharCode < 91)) || ((nCharCode > 96) && (nCharCode < 123))  || ((nCharCode > 47) && (nCharCode < 58))))
					{
					strRetCode = false;
					} 
			}
			
			
			return strRetCode
	}
//===============================================================
	function val_DateCmb(cmbDay,cmbMonth,cmbYear,Required)//-- Three comboboxs for day,month,year
	{
		var Day   = cmbDay.options[cmbDay.selectedIndex].value;
		var Month = cmbMonth.options[cmbMonth.selectedIndex].value;
		var Year  = cmbYear.options[cmbYear.selectedIndex].value;

		switch (Required)
		{
			case true :
				if(cmbDay.selectedIndex == 0 || cmbMonth.selectedIndex == 0 || cmbYear.selectedIndex == 0 )
				{
					return false;	
				}
				else
				{
					var temp = new Date(Month+"/"+Day+"/"+Year);
					if(Number(Day) != Number(temp.getDate()))
					{
						return false;
					}
					else
					{
						return true;
					}
				}
			default :
				return true;
		}
	}
//===============================================================
	function val_List(LstBox)
	{
		if(LstBox.options[LstBox.selectedIndex].value == "NONE"){return false;}
		else{return true;}
	}
//===============================================================
	function Popup(filepath,name,width,height)
	{
		var left = (screen.width - width)/ 2;
		var top  = (screen.height - height)/ 2;
		window.open(filepath,name,"width="+width+",height="+height+",top="+top+",left="+left);
	}
//===============================================================
	function Warning(Obj,Criteria,Msg)
	{
		var val = String(Obj.value);

		if(Trim(val) != "")
		{
			evalstr = "if(val"+Criteria+"){";
			evalstr += "if(!confirm('"+Msg+"')){Obj.value = '';Obj.focus();}}";
			eval(evalstr);
		}
	}

//===============================================================
	var ScrollMsg = ""; //--- This code is used to display scrolling 
	function Scroll()//--- text in the window status bar
	{
		window.status = ScrollMsg;
			ScrollMsg = ScrollMsg.slice(1)+ScrollMsg.charAt(0);
	}
	function ScrollStatMsg(msg,delay)//-- Use this function
	{
		ScrollMsg = String(msg);
		if(ScrollStatMsg.arguments.length == 1)
		{
			window.setInterval("Scroll()",80);
		}
		else
		{
			window.setInterval("Scroll()",delay);
		}
	}
//===============================================================
