//===========================================================================//
function check_url(urlstr) {
	if(urlstr=="") return true;
	var regexp=/(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/
	return regexp.test(urlstr);
}
//===========================================================================//
function check_email(emailstr) {
	if(emailstr.replace(/\b[\w|\.]+@\w+\.\S+/gi,"x")!="x") return false;
	return true;
}
//===========================================================================//
//Trim a string from the sides
function trim(trimstr) {
	if(trimstr==null||trimstr=="") return "";
	return trimstr.replace(/^(\s+)?(.*\S)(\s+)?$/, '$2');
}
//===========================================================================//
//Check for bad words
function check_badwords(str) {
	var badwords=new Array("fuck","shit","dick","asshole","pussy","penis","blowjob","bitch","slut","cunt","twat","anal");
	var tempstr=str.toLowerCase();
	for(i=0;i<badwords.length;i++) {if(tempstr.indexOf(badwords[i])>=0) return false;}
  return true;
}
//===========================================================================//
//Check for long words 30 chars
function check_longwords(str) {
  count=1;
	i=0;
	pos=0;
	do {
	  pos=str.substring(i).indexOf(" ");
	  if(pos>=0) {i+=pos+1;}
	  if(pos>0) {count++;}	
	} while(pos>=0&&pos<30);
	
  if(pos>=30 || (str.length-i)>=30) return false;
  return true;
}
//===========================================================================//
