// jQuery functions Made By Somnath Sinha
jQuery.fn.extend({
	restrictChars: function(e, allowed){
		if (allowed == undefined)
		{
			return false;
		}
		var key = this.keyCode(e);
		var keychar = String.fromCharCode(key);
		
		if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27))
		{
			return true;
		}
		else if ((allowed.indexOf(keychar) > -1))
		{
			return true;
		}
		else
		{
			return false;
		}
	},
	numbersOnly: function(e){
		return this.restrictChars(e, '0123456789');
	},
	floatNumbersOnly: function(e){
		if (this.restrictChars(e, '.0123456789'))
		{
			if (this.keyCode(e) != 46)
			{
				return true;
			}
			else if (this[0].value.indexOf('.') == -1)
			{
				return true;
			}
			else
			{
				return false;
			}
		}
		else
		{
			return false;
		}
	},
	keyCode: function(e){
		return e.charCode ? e.charCode : (e.keyCode ? e.keyCode : 0);
	},
	nameCheck: function(){
		var expr=/^(([a-zA-Z])([0-9_'])*)+$/;
		return expr.test(jQuery(this).val());
	},
	useNameCheck: function(){
		var expr=/^(([a-zA-Z])([0-9_])*)+$/;
		return expr.test(jQuery(this).val());
	},
	emailCheck: function(){
		var expr=/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
		return expr.test(jQuery(this).val());
	},
	urlCheck: function(){
		var expr=/^(http:\/\/www.|https:\/\/www.|ftp:\/\/www.|www.){1}([\w]+)(.[\w]+){1,2}$/;
		return expr.test(jQuery(this).val());
	},
	isProperString: function(){
		var string = jQuery(this).val();
		if (string.length == 0)
		{
			return false;
		}
		
		var iChars = "*|,\":<>[]{}`\';()@&$#% ";
		for (var i = 0; i < string.length; i++)
		{
			if (iChars.indexOf(string.charAt(i)) != -1)
				return false;
		}
		return true;
	},
	numToRound: function(dec){
		if (dec == undefined || dec <= 0)
		{
			dec = 2;
		}
		var num = jQuery(this).val();
		var n=num.toString();
		var pos=n.indexOf(".");
		if(pos==-1)
		{
			var decval="";
			for(var i=0;i<dec;i++)
				decval+="0";
			return num+"."+decval;
		}
		else
		{
			var decval=n.substring(pos+1);
			for(var i=decval.length;i<dec;i++)
				decval+="0";
			return n.substring(0,pos)+"."+decval.substring(0,dec);
		}
	},
	isEmpty: function(){
		if (jQuery.trim(jQuery(this).val()).length == 0)
		{
			return true;
		}
		else
		{
			return false;
		}
	}
});
jQuery.extend({
	userNameCheck: function(str){
		var expr=/^(([a-zA-Z])([0-9_'])*)+$/;
		return expr.test(str);
	},
	nameCheck: function(str){
		var expr=/^(([a-zA-Z])([0-9_])*)+$/;
		return expr.test(str);
	},
	emailCheck: function(str){
		var expr=/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
		return expr.test(str);
	},
	urlCheck: function(str){
		var expr=/^(http:\/\/www.|https:\/\/www.|ftp:\/\/www.|www.){1}([\w]+)(.[\w]+){1,2}$/;
		return expr.test(str);
	},
	isProperString: function(string){
		if (string.length == 0)
		{
			return false;
		}
		
		var iChars = "*|,\":<>[]{}`\';()@&$#% ";
		for (var i = 0; i < string.length; i++)
		{
			if (iChars.indexOf(string.charAt(i)) != -1)
				return false;
		}
		return true;
	},
	numToRound: function(num, dec){
		if (dec == undefined || dec <= 0)
		{
			dec = 2;
		}
		if (num == undefined)
		{
			num = 0;
		}
		var n=num.toString();
		var pos=n.indexOf(".");
		if(pos==-1)
		{
			var decval="";
			for(var i=0;i<dec;i++)
				decval+="0";
			return num+"."+decval;
		}
		else
		{
			var decval=n.substring(pos+1);
			for(var i=decval.length;i<dec;i++)
				decval+="0";
			return n.substring(0,pos)+"."+decval.substring(0,dec);
		}
	},
	isEmpty: function(str){
		if (jQuery.trim(str).length == 0)
		{
			return true;
		}
		else
		{
			return false;
		}
	}
});