function validateForm(theform)
{
 

 pass = 1; //assume everything is ok
  msg = "<h5><font color=red>Please check the Following Errors:</font></h5>";
  
  
    if (isEmpty(theform.type.value))
  {
    msg = msg + "- Title Name cannot be empty<br>";
    pass = 0;
  }
  
  
   if (isEmpty(theform.fname.value))
  {
    msg = msg + "- First Name cannot be empty<br>";
    pass = 0;
  }
  
  
  if (isEmpty(theform.lname.value))
  {
    msg = msg + "- Last Name cannot be empty<br>";
    pass = 0;
  }
  if (isEmpty(theform.email.value))
  {
    msg = msg + "- Email ID cannot be empty<br>";
    pass = 0;
  }
  else if (!isEmail(theform.email.value)){
	msg = msg + "- Invalid Email ID<br>";
    pass = 0;
  }
 
 
 if (isEmpty(theform.password.value))
  {
    msg = msg + "- Password cannot be empty<br>";
    pass = 0;
  }
  else if (isEmpty(theform.password1.value))
  {
    msg = msg + "- Confirm Password cannot be empty<br>";
    pass = 0;
  }
  else if ((theform.password.value)!=(theform.password1.value))
  {
    msg = msg + "- Password Mismatch <br>";
    pass = 0;
  }else if(theform.password.value.length<4){
	msg = msg + "- Password length should be atleast 4 chatacter <br>";
    pass = 0;  
  }
  
  
   if (isEmpty(theform.phonenumber.value))
  {
    msg = msg + "- Phone Number Name cannot be empty<br>";
    pass = 0;
  }
  

  
  if (isEmpty(theform.address.value))
  {
    msg = msg + "- Address cannot be empty<br>";
    pass = 0;
  }
  
  
   
   if (isEmpty(theform.city.value))
  {
    msg = msg + "- City cannot be empty<br>";
    pass = 0;
  }
  
   if (isEmpty(theform.country.value))
  {
    msg = msg + "- Country cannot be empty<br>";
    pass = 0;
  }
  
  if (isEmpty(theform.zip.value))
  {
    msg = msg + "- Zip Code cannot be empty<br>";
    pass = 0;
  }
  

  if (pass == 1)
  {
    return true;
	
  }
  
  else
  {
	 //refreshimg();
	 document.getElementById("err").innerHTML=msg
    //alert(msg);
	//document.write(msg);
    return false;
  }
}



function refreshimg()
{
	//Get a reference to CAPTCHA image
	var img = document.getElementById('capimg'); 
	//Change the image
	img.src = 'Images/img.php?' + Math.random();
	
	var cc = document.getElementById('image'); 
	//Change the image
	cc.value = '';
	
}

// validators ------------------------------------------------------------------
	
function isEmpty (s) {
	var p = /\S+/;
	return !p.test(s);
}

function isEmail(string) {
    if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
        return true;
    else
        return false;
}

function isAlphaNum(string) {
    if (string.search(/^[A-Za-z0-9]+$/) != -1)
        return true;
    else
        return false;
}

function isNum(string) {
    if (string.search(/^[0-9]+$/) != -1)
        return false;
    else
        return true;
}

function isExecutable (s) {
	var p = /\.(bat|com|dll|exe|vbs)$/i;
	return p.test(s);
}

function isImage (s) {
	var p = /\.(gif|jpg)$/i;
	return p.test(s);
}

function isUrl (s) {
	var p = /^(http|https|ftp):\/\/\S+\.[^\.\s]{2,4}(\/\S*)?$/i;
	return p.test(s);
}



