
	function checkForInvalidCharsAtStart(strToTst, bypassMsg)
	{
		//this function tests for any of the following special characters in the entire
		//passed string! and in the firsst instance it returns false!
		
		var invalidChars = "~!@#$%^&*()_+|{}:<>?`-=\[];',./";
		var fStr;
		var i;		//this is just a simple counter!
		//we are doing this trick because " cannot be incorporated between " "...
		invalidChars = invalidChars + '"';
		//check for space char
		invalidChars = invalidChars + " ";

		//stuff the first character into the variable!
		/*alert ("Getting into it!");
		alert (invalidChars);*/
		fStr = strToTst.substring(0,1);
		for(i = 0; i < invalidChars.length; i++)
		{
			if(invalidChars.substring(i,i + 1) != "_")
			{
				//Now chek for the entire passed string!
				for(j = 0; j < strToTst.length; j++)
				{
					//alert(strToTst.substring(j,j + 1) + " and " + invalidChars.substring(i,i + 1));
					if(strToTst.substring(j,j + 1) == invalidChars.substring(i,i + 1))
					{
						if(bypassMsg == false)
						{
							alert ("EparOpar ID cannot have '" + invalidChars.substring(i,i + 1) + "' character!");
						}
						return false;
					}
				}			 
			}
			else
			{
				if(fStr == invalidChars.substring(i,i + 1))
				 {
					if(bypassMsg == false)
					{
						alert ("EparOpar ID cannot start with '" + invalidChars.substring(i,i + 1) + "' character!");
					}
					user_login.user_id.focus();
					return false;
				 }
			}
		}
		return true;		
	}
	
	
	function IsNumeric(sText)
	{
		var ValidChars = "0123456789.";
		var IsNumber=true;
		var Char;
		if(sText != "")
		{
			for (i = 0; i < sText.length && IsNumber == true; i++) 
			{ 
				Char = sText.charAt(i); 
				if (ValidChars.indexOf(Char) == -1) 
				{
					IsNumber = false;
				}
			}
		}
		else
		{
			IsNumber=false;
		}
		return IsNumber;	
	}
	
	function isPhone(num)
	{
		var isPhone=true;
		var reg2 = /[0-9\-\.\,\ ]$/; // valid
		if(!reg2.test(num))
		{
			alert("Invalid Number!");
			isPhone=false;
		}
		
		/*if(num != "")
		{
			if(IsNumeric(num))
			{
				//Next chk for the no of characters into it!
				if(num.length > 16)
				{
					alert("Check your phone number!");
					isPhone=false;
				}
			}
			else
			{
				alert("Invalid phone number!");
				isPhone=false;
			}
		}
		else
		{
			alert("Phone left empty!");
			isPhone=false;
		}*/
		return isPhone;
	}
	
	function validDays()
	{
		//validate only for feb...
		if(user_login.month.value=="February")
		{
			//Chk if the selected year is a leap year!v
			if(user_login.year.value%4 == 0)
			{
				//we are into leap year! Day can be upto 29.
				//if(user_login.day.value "30" || user_login.day.value=="31")
				if(user_login.day.value <= 29)
				{
					return true;
				}
				else
				{
					alert("Please select valid date! You have chosen a leap year!");
					user_login.day.focus();
					return false;
				}
			}
			else
			{
				// we are into any non-leap year!
				if(user_login.day.value <= 28)
				{
					return true;
				}
				else
				{
					alert("Please select valid date!");
					user_login.day.focus();
					return false;
				}
			}
		}
		else
		{
			//for any non feb months! First lets check for 30 days month!
			if(user_login.month.value=="April" || user_login.month.value=="June" || user_login.month.value=="September" || user_login.month.value=="November")
			{
				if(user_login.day.value <= 30)
				{
					return true;
				}
				else
				{
					alert("Please select valid date!");
					user_login.day.focus();
					return false;
				}
			}
		}
	}

	function validateEmail(email)
	{
		var i, ctr, j, dot;
		ctr = 0;
		//chk if it is comprising of atleaset 9 characaters!
		if(email.length < 9)
		{
			alert ("Your email doesnt seem to be a real one! Please re-check!");
			return false;
		}
		else
		{
			//check if there is a '@' in it!
			for(i = 0; i <= email.length; i++)
			{
				if(email.substring(i, i+1) == "@")
				{
					ctr++;
				}				
			}
			if(ctr <= 0 || ctr > 1)
			{
				alert ("Your email doesnt seem to be a real one! Please re-check!");
				return false;
			}
			else
			{
				//@ found, check if it is in the very first position!
				if(email.substring(0,1) == '@')
				{
					alert ("Your email doesnt seem to be a real one! Please re-check!");
					return false;
				}
				else
				{
					//chk for existance of '.'
					//reset the counter var first!
					ctr = 0;
					for(i = 0; i <= email.length; i++)
					{
						if(email.substring(i, i+1) == ".")
						{
							ctr++;
						}				
					}
					if(ctr <= 0)
					{
						alert ("Your email doesnt seem to be a real one! Please re-check!");
						return false;
					}
					else
					{
						//next check if atleast one dot appears after the @ char!
						var gotAtTheRate;
						//init it to 'false'
						gotAtTheRate = false;
						//next reset the counter var!
						ctr=0;
						for(i = 0; i <= email.length; i++)
						{
							//chk only if '@' is not found!
							if(gotAtTheRate == false)
							{
								if(email.substring(i, i+1) == "@")
								{
									//found the '@', toggle the var!
									gotAtTheRate = true;
								}
							}
							else
							{
								//chk if the character is "."
								if(email.substring(i, i+1) == ".")
								{
									//found the '.', increase the counter var!
									ctr++;
									gotAtTheRate = true;
								}
							}
						}
						//at last decide if a dot is found after the '@' or not!
						if(ctr <= 0)
						{
							alert ("Your email doesnt seem to be a real one! Please re-check!");
							return false;
						}
						else
						{
							//next check if "@" and '.' coexists! i.e like "@."...
							if(email.indexOf('@.') > -1)
							{
								//found, unfavourable!
								alert ("Your email doesnt seem to be a real one! Please re-check!");
								return false;
							}
							else if(email.indexOf('.@') > -1)
							{
								//again found, unfavpourable!
								alert ("Your email doesnt seem to be a real one! Please re-check!");
								return false;
							}
							else
							{
								//not found, data OKay!
								return true;
							}
							return true;
						}
					}
				}
			}
		}
	}
	
	function isPassword(pass)
	{
			if(pass.length<6)
			{
					alert("Password must be of atleast 6 characters.");
					return false;
			}
			
			for(i = 0; i <= pass.length; i++)
			{
				if(pass.substring(i, i+1) == " ")
				{
					alert("Blank space is not allowed here.");
					return false;
					break;
				}				
			}
			return true;
	}
	
	function isIndianPIN(pin)
	{
		var res;
		//First chk if its not empty!
		if(pin == "")
		{
			alert("Pin left empty!");
			res = false;
		}
		else
		{
			//Chk if its in numeric format!
			if(IsNumeric(pin) == false)
			{
				alert("PIN should only contain numbers!");
				res = false;
			}
			else
			{
				if(pin.length != 6)
				{
					alert("Invalid PIN, please check!");
					res = false;
				}
				else
				{
					res = true;
				}
			}
		}
		return res;
	}
	
	
	function isEmpty(value)
	{
		if(value.search(/\S/)==-1)
		{
	   		return true;
	  	}  
	  	return false; 
	}
	
	function getKeyCode(e)
	{
		if (window.event)
			return window.event.keyCode;
		else if (e)
			return e.which;
		else
			return null;
	}
	
	function keyRestrict(e, validchars) 
	{
		var key='', keychar='';
		key = getKeyCode(e);
		if (key == null) return true;
		keychar = String.fromCharCode(key);
		keychar = keychar.toLowerCase();
		validchars = validchars.toLowerCase();
		if (validchars.indexOf(keychar) != -1)
			return true;
		if ( key==null || key==0 || key==8 || key==9 || key==13 || key==27 )
			return true;
		//alert("Plese enter a valid character.");
		return false;
	}
	
	// Functions for trailing spaces.
function trim(strText) { 
		// this will get rid of leading spaces
		while (strText.substring(0,1) == ' ')
			strText = strText.substring(1, strText.length);

		// this will get rid of trailing spaces
		while (strText.substring(strText.length-1,strText.length) == ' ')
			strText = strText.substring(0, strText.length-1);
		var pos=0
		var tevePos=0
		while(strText.indexOf("\n",pos)>-1)
		{
			tevePos=strText.indexOf("\n",pos)
			pos=tevePos+1
		}
		
	   return strText;
}
	var win = null;
	function NewWindow(mypage,myname,w,h,scroll){
	var LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	var TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	var settings =
	'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
	win = window.open(mypage,myname,settings)
	}
	
	function openwin(url,w,h,scrollyes){
		var top = (screen.height-h)/2;
		var left = (screen.width-w)/2;
		var customize = "toolbar=no,menubar=no,resizable=yes,scrollbars="+scrollyes+",width="+w+",height="+h+",top="+top+",left="+left;
		window.open(url,'_blank',customize)
	}
	
	function IsInFormat(val,format)
	{
		if(!(val==""))
		{
			var reg2 = format; 
			if(!reg2.test(val))
			{
				alert("Not in valid format!");
				return false;
			}
		}
			return true;
			
	}
	
	function daysInMonth(iMonth, iYear)
	{
		return 32 - new Date(iYear, iMonth, 32).getDate();
	}



