// create the prototype on the String object

String.prototype.trim = function() {

 // skip leading and trailing whitespace
 // and return everything in between
  var x=this;
  x=x.replace(/^\s*(.*)/, "$1");
  x=x.replace(/(.*?)\s*$/, "$1");
  return x;
}

function RegExpTest(frm){

  var ver = Number(ScriptEngineMajorVersion() + "." + ScriptEngineMinorVersion());

  	var len=frm.elements.length;
  	for (i=0; i<len; i++) {
		var el=frm.elements[i];
	
		if (el.type=='textarea' || el.id=='RegExpTestField'){

			  if (ver >= 5.5){
			  		
					  var str=el.value;
					  				  
					 // var rgExp=/([A-Za-z0-9.])([^A-Za-z0-9])/ig;
					 // str=str.replace(rgExp, "$1"); //elimin spatiile sau alte caractere din
					 
					  var re1=/http|@|(www([_ -.,]|dot)*\w)|www|http|w3|(([-.,]|dot)+(com|net|com|biz|org|us))/ig;
					  var found1 = str.match(re1);               
					  if (found1!=null) {
						alert("You are not allowed to use words like "+found1+" in your text fields!");	
						//alert("You are not allowed to use words like http , www, @,< ,.com, .net in your text fields!");
						el.focus();
						 return false;
					  }
					  
					  var re1=/w[_ -.,]w[_ -.,]w|c[_ -.,]o[_ -.,]m|n[_ -.,]e[_ -.,]t|b[_ -.,]i[_ -.,]z|o[_ -.,]r[_ -.,]g/ig;
					  var found1 = str.match(re1);               
					  if (found1!=null) {
						alert("You are not allowed to use words like "+found1+" in your text fields!");	
						//alert("You are not allowed to use words like http , www, @,< ,.com, .net in your text fields!");
						el.focus();
						 return false;
					  }
					  var re2 = /\d{7}|([_ -.,/():]*\d{3}[_ -.,/():]*\d{3}[_ -.,/():]*\d{4})/ig;
					  var found2 = str.match(re2);    
					          
					  if (found2!=null) {
						alert("You are not allowed to use phone numbers in your text fields!");
						el.focus();
						return false;
					  }
			   }//end if (ver >= 5.5)
			  		 if (str.indexOf("@")!=-1)
					  {
						 alert("The words http , www, @, .com, .net are not allowed in your text fields!");
						 el.focus();
						 return false;
						 
					  }
					  if (str.indexOf("http")!=-1)
					  {
						 alert("The words http , www, @, .com, .net are not allowed in your text fields!");
						 el.focus();
						 return false;
						 
					  }

					  if (str.indexOf("www")!=-1)
					  {
						 alert("The words http , www, @, .com, .net are not allowed in your text fields!");
						 el.focus();
						 return false;
						 
					  }
					  if (str.indexOf(".com")!=-1)
					  {
						 alert("The words http , www, @, .com, .net are not allowed in your text fields!");
						 el.focus();
						 return false;
						 
					  }
					  if (str.indexOf(".net")!=-1)
					  {
						 alert("The words http , www, @, .com, .net are not allowed in your text fields!");
						 el.focus();
						 return false;
						 
					  }

		}//	  end if (el.type=='text' || el.type=='textarea' )
	 }//end for (i=0; i<len; i++)  
 
} //end function RegExpTest(str)



function Hide(valoare){
document.getElementById(valoare).style.visibility='hidden';
document.getElementById(valoare).style.display = 'none';

}