	String.prototype.isempty=isempty;
	String.prototype.isemailid=isemailid;
	String.prototype.istelephone=istelephone;
	String.prototype.isdate=isdate;
	String.prototype.isnumber=isnumber;
	String.prototype.trim=trim;
	String.prototype.replicateatstart=replicateatstart;
	String.prototype.replicateatend=replicateatend;
	Date.prototype.getDateTime=getDateTime;	
		
	function trim()
		{
			var i = new Number();
			var pSpace = new Boolean();
			var pStart = new Number();
			var pEnd = new Number();

			for(i=0;i<=this.length-1;i++)
				{
					if(this.charAt(i)!=" ")
						{
							pStart=i;
							pSpace=true;
							break;
						}
				}
			for(i=this.length-1;i>=0;i--)
				{
					if(this.charAt(i)!=" ")
						{
							pEnd=i+1;
							pSpace=true;
							break;
						}
				}
			if(pStart==0 && pEnd==0 && pSpace==true)
				{
					return this;
				}
			else
				{
					return this.substring(pStart,pEnd);
				}
		}
	function isempty(pmessage)
		{
			if (this.trim()=="")
				{
					if(pmessage.trim()!="")
					{
						alert(pmessage);
					}
					return true;
				}
			return false;
		}
	function isselected(pobj, pmessage)
	{
		if(pobj.selectedIndex<=0)
			{
				if(pmessage.trim()!="")
				{
					alert(pmessage);
				}
				return false;
			}
		return true;
	}
	function isemailid(pmessage)
	{
		if(this.trim()!="")
		{
			if((this.indexOf("@",0) == -1)||(this.indexOf(".",0) == -1)||(this.indexOf("@",0) == 0)||(this.indexOf(".",0) == 0)||(this.indexOf(".",0) == this.length-1))
			{
				if(pmessage.trim()!="")
				{
					alert(pmessage);
				}
				return false;
			}
		}
		return true;
	}	
	function isexisting(pobj, pval, pmessage)
	{
		var i = Number();
		var x = new String();
		for(i=0;i<=pobj.options.length-1;i++)
			{
				if(pobj.options[i].value.split("|")[0]==pval.split("|")[0])
				{
					if(pmessage.trim()!="")
					{
						alert("'" + pmessage + "'");
					}
					return true;
				}
			}
		return false;
	}
	function istelephone(pmessage)
	{
		var i = new Number();
		for(i=0;i<=this.trim().length-1;i++)
		{
			if((this.trim().charCodeAt(i)<48 || this.trim().charCodeAt(i)>57) && (this.trim().charAt(i) != " " && this.trim().charAt(i) != "+" && this.trim().charAt(i) != "-" && this.trim().charAt(i) != "/"))
			{
				alert(pmessage);
				return false;
			}
		}
		return true;
	}
	function isdate()
	{
		if(this=="//" || this=="")
		{
			return true;
		}
		/* Checks for the following valid date formats:
		MM/DD/YY   MM/DD/YYYY   MM-DD-YY   MM-DD-YYYY
		Also separates date into month, day, and year variables
		var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{2}|\d{4})$/; */
		
		/* To require a 4 digit year entry, use this line instead: */
		var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/; 
		var matchArray = this.match(datePat); // is the format ok?
		if (matchArray == null) 
		{
			alert("La date saisie n'est pas correcte !(jour/Mois/Année)")
			return false;
		}
		mois = matchArray[1]; // parse date into variables
		day = matchArray[3];
		year = matchArray[4];
		if (mois < 1 || mois > 12) 
		{
			alert("Le mois saisi doit être compris entre 1 et 12 !");
			return false;
		}
		if (day < 1 || day > 31) 
		{
			alert("Le jour saisi doit être compris entre 1 et 31 !");
			return false;
		}
		if ((mois==4 || mois==6 || mois==9 || mois==11) && day==31) 
		{
			alert("Le mois "+mois+" ne comprend pas 31 jours !")
			return false;
		}
		if (mois == 2) 
		{ // check for february 29th
			var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
			if (day>29 || (day==29 && !isleap)) 
			{
				alert("Le mois de février de l'année " + year + " ne comprend pas " + day + " jours !");
				return false;
			}
		}
		if(year<=1752)
		{
			alert("Vérifiez la date saisie");
			return false
		}
		return true;
	}
	function isnumber(pmessage)
	{
		var i = new Number();
		for(i=0;i<=this.trim().length-1;i++)
		{
			if(this.trim().charCodeAt(i)<48 || this.trim().charCodeAt(i)>57)
			{
				alert(pmessage);
				return false;
			}
		}
		return true;
	}
	function DeleteOptions(pObj)
	{
		var pI = new Number();
		if(pObj.selectedIndex>=0)
		{
			for(pI=pObj.options.length-1;pI>=0;pI--)
			{
				if(pObj.options[pI].selected==true)
				{
					if(pI!=0)
					{
						pObj.options[pI]=null;
					}
				}
			}
		}
		return false;
	}
	function getDateTime(pFormat)
	{
		var pVal = new String();
		if (pFormat=="dmy")
		{
			pVal=this.getDate() + "/" + (this.getMonth()+1) + "/" + this.getFullYear() + " " + this.getHours() + ":" + this.getMinutes() + ":" + this.getSeconds();
		}
		else
		{
			pVal=this.getDate() + "/" + (this.getMonth()+1) + "/" + this.getFullYear() + " " + this.getHours() + ":" + this.getMinutes() + ":" + this.getSeconds();
		}
		return pVal;
	}
	function replicateatend(pChar, pLength)
	{
		var pVal = new String();
		var pI = new Number();
		
		pVal=this;
		if (pLength>=1)
		{
			for (pI=1;pI<=pLength;pI++)
			{
				pVal = pVal + pChar
			}
		}
		return pVal;
	}
	function replicateatstart(pChar, pLength)
	{
		var pVal = new String();
		var pI = new Number();
		
		if (pLength>=1)
		{
			for (pI=1;pI<=pLength;pI++)
			{
				pVal = pVal + pChar
			}
		}
		pVal= pVal + this;
		return pVal;
	}	