function validate()
{
var filter = /^(http:\/\/www.|https:\/\/www.|ftp:\/\/www.|www.){1}([\w]+)(.[\w]+){1,2}$/;
	if(document.form.title.value=="")
	 {
	  alert("Please enter the title");
	  document.form.title.focus();
	  return false;
	  }
  
 if(document.form.url.value=="")
 {
  alert("Please enter the URL");
  document.form.url.focus();
   return false;
  
 }
  if(document.form.url.value!="")
  {
	if (!(filter.test(document.form.url.value)))
		{
			alert("Please Enter Valid Url");
			document.form.url.focus();
			return false;
		}
	}
 
 if(document.form.desc.value=="")
 {
  alert("Please enter the description");
  document.form.desc.focus();
   return false;
  
 }
 

 if(document.form.name.value=="")
 {
  alert("Please enter name");
  document.form.name.focus();
   return false;
 }

 if(document.form.email.value=="")
 {
  alert("Please enter the email");
   document.form.email.focus();
  return false;
  
 }
 else
 {
  if(!IsEmail(document.form.email,"Enter Valid Email Address"))
		   {
		       return false
		   }
 }
 
 if(document.form.rurl.value=="")
 {
  alert("Please enter the Reciprocal Link URL");
  document.form.rurl.focus();
   return false;
  
 }
  if(document.form.rurl.value!="")
  {
	if (!(filter.test(document.form.rurl.value)))
		{
			alert("Please Enter Valid Reciprocal Link Url");
			document.form.rurl.focus();
			return false;
		}
	}
return true;
 
}
function IsEmail(obj){
	if(Trim(obj.value) == ""){
		alert("Email or Confirm Email should not be blank.");
		obj.focus();
		return false;
	}
	else{
	    if(obj.value.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
    	    return true;
	    else{
			alert("Enter Valid Email Address");
			obj.focus();
    	    return false;
		}
	}
}
function validateURL(url)
{
lengthValue = Trim(document.form.url.value);
lengthValue = lengthValue.length;
if(lengthValue != 0)
{
var j = new RegExp();
j.compile=(/^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/); 
lengthValue = Trim(document.form.url.value);
if (!j.test(lengthValue))
{
alert("Please enter valid URL");
return false;
}


}
}
function Trim(str) {
	str = str.replace(/^\s+/, '');
	for (var i = str.length - 1; i >= 0; i--) {
		if (/\S/.test(str.charAt(i))) {
			str = str.substring(0, i + 1);
			break;
		}
	}
	return str;
}