function removeSpaces(string) {
 return string.split(' ').join('');
}
function contact_form()
{
  var obj,obj_value;
  var obj2,obj_value2;  
/*
  Title
*/
  obj = document.forms["contact_form"].ctitle;
  obj_value =  getCheckedValue(obj);
  if (!validateNotEmpty(trimAll(obj_value)))
	{
	 	//alert("Please enter Your Title");
	 	alert("Please select Your title");
		//obj.select();
    return false;  
	}
/*
  Name
*/
  obj = document.forms["contact_form"].fname;
  obj_value =  obj.value;
  if (!validateNotEmpty(trimAll(obj_value)))
	{
	 	alert("Please enter First Name");
	 	obj.focus();	 	
	 	//obj.select();
		return false;  
	}	
  obj = document.forms["contact_form"].lname;
  obj_value =  obj.value;
  if (!validateNotEmpty(trimAll(obj_value)))
	{
	 	alert("Please enter Last Name");
	 	obj.focus();
	 	//obj.select();     	 	
		return false;  
	}
/*
  Phone
*/  	
  obj = document.forms["contact_form"].cphone;
  obj_value =  obj.value;

  obj2 = document.forms["contact_form"].cmobile;
  obj_value2 =  obj2.value;  
  
  if (!validateNotEmpty(trimAll(obj_value)) && !validateNotEmpty(trimAll(obj_value2)))
	{
	 	alert("Please enter Phone or Mobile");
	 	obj.focus();
    //obj.select();	 	
		return false;  
	}
	
/*
removeCharacters
strNoSpaces = removeCharacters( ' sfdf  dfd',
                                '\s*')
*/
	// Phone
	if (validateNotEmpty(trimAll(obj_value)))
	{
	    tmp =  removeSpaces(obj_value);    
    	if ((!validateNumeric(tmp)) || (tmp.length != 10))
       {
          //
          //alert("Please enter Phone in 10 digitals only");
          alert("Please enter Phone 10 digital only");
          
          obj.focus();
          //obj.select();    
          return false;
       }
  }    
	// Mobile
	if (validateNotEmpty(trimAll(obj_value2)))
	{
	    tmp =  removeSpaces(obj_value2);	
    	if ((!validateNumeric(tmp)) || (tmp.length != 10))
       {
          alert("Please enter Phone 10 digital only");
          obj2.focus();
          //obj2.select();    
          return false;
       }
  }
	
// Check email
  obj = document.forms["contact_form"].cemail;
  obj_value = obj.value;
  if (!validateNotEmpty(obj_value))
  {
    alert("Please enter Email");
    obj.focus();
    //obj.select();
    return false;
  }
  else
  {
    if (!emailCheck(obj.value))
    {
        alert("Please enter valid Email");
        obj.focus();
        //obj.select();
        return false;
    }
  }
// Message
	obj = document.getElementById("desc");
	if (!validateNotEmpty(trimAll(obj.value)))
	{
		alert("Please enter Message");
		obj.focus();
		//	obj.select();
    return false;
	}
	
// security_code
  obj = document.forms["contact_form"].security_code;
  obj_value = obj.value;
	if (!validateNotEmpty(trimAll(obj_value)))
	{
      alert("Please enter valid Security code");
      obj.focus();
      return false;	
  }

  return true;
}
function enquiry_form()
{

	var obj;

  obj = document.getElementById("ctitle");
  obj_text ="Title";
  if (!validateNotEmpty(obj.options[obj.selectedIndex].value))
  {
     //msg_obj.innerHTML="Please enter your " + obj_text;
     alert("Please select your " + obj_text);
     obj.focus();
     //obj.style.backgroundColor = "#000000";
     //obj.style.border = "1px solid #ff0000";
     return false; 
  }

	obj = document.getElementById("fname");
	var field ="First Name";
	if (!validateNotEmpty(trimAll(obj.value)))
	{
		alert("Please enter your " + field);
		obj.focus();
		return false;
	}

	obj = document.getElementById("lname");
	var field ="Last Name";
	if (!validateNotEmpty(trimAll(obj.value)))
	{
		alert("Please enter your " + field);
		obj.focus();
		return false;
	}
  	
	obj = document.getElementById("cemail");
	var field ="email";
	if (!validateNotEmpty(trimAll(obj.value)))
	{
		alert("Please enter your " + field);
		obj.focus();
		return false;
	}
  if (!emailCheck(obj.value))
  {
      alert("Please enter valid email");
      obj.focus();
      obj.select();
      return false;
  }

    	
	obj = document.getElementById("cphone");
	var field ="phone";
	if (!validateNotEmpty(trimAll(obj.value)))
	{
		alert("Please enter your " + field);
		obj.focus();
		return false;
	}
	
   if (!validateNumeric(obj.value))
   {
      alert("Please enter 10 digitals in Phone");
      obj.focus();
      return false;
   }
   else
   {
      if (obj.value.length != 10)
      {
        alert("Please enter 10 digitals in Phone including area codes: 02, 03, 04, 07, 08");
        obj.focus();        
        return false;
      }
   }
	
	
 obj = document.getElementById("services");
  obj_text ="Service";
  if (!validateNotEmpty(obj.options[obj.selectedIndex].value))
  {
     //msg_obj.innerHTML="Please enter your " + obj_text;
     alert("Please select a " + obj_text);
     obj.focus();
     //obj.style.backgroundColor = "#000000";
     //obj.style.border = "1px solid #ff0000";
     return false; 
  }
	
	obj = document.getElementById("desc");
	var field ="message";
	if (!validateNotEmpty(trimAll(obj.value)))
	{
		alert("Please enter your " + field);
		obj.focus();
		return false;
	}
  return true;	
}
function quote_form()
{
	var obj, obj2;

	obj = document.getElementById("fullname");
	var field ="Full Name";
	if (!validateNotEmpty(trimAll(obj.value)))
	{
		alert("Please enter " + field);
		obj.focus();
		obj.select();
		return false;
	}
	
	obj = document.getElementById("c_phone");
	var field ="Your Phone";
	obj2 = document.getElementById("email_address");
	var field2 ="Your email";
	
	if ((!validateNotEmpty(trimAll(obj.value))) && (!validateNotEmpty(trimAll(obj2.value))))
  {
    alert("Please enter your phone or your email address");
    obj.focus();
    return false;
  } 
  /*
  if (!validateNotEmpty(trimAll(obj.value)))
	{
		alert("Please enter " + field);
		obj.focus();
		obj.select();
		return false;
	}
	
	*/
	if (validateNotEmpty(trimAll(obj2.value)))
	{
		  if (!emailCheck(obj2.value))
      {
          alert("Please enter valid email");
          obj2.focus();
          obj2.select();
          return false;
      }
	}

  return true;	
}
function apply_form_val()
{
  var obj, obj1, obj2, obj_text, msg_obj;

// Tittle
  obj = document.getElementById("c_title");
  obj_text ="title";
  if (!validateNotEmpty(obj.options[obj.selectedIndex].value))
  {
     alert("Please enter your " + obj_text);
     obj.focus();
     return false; 
  }

  obj = document.getElementById("c_name");
  msg_obj = document.getElementById("msg");

  obj_text ="full name";
  if (!validateNotEmpty(obj.value))
  {
     alert("Please enter your " + obj_text);  
     obj.focus();
     return false; 
  }

  
  obj1 = document.getElementById("c_phone");
  obj2 = document.getElementById("c_mobile");
  
  if (!validateNotEmpty(obj1.value) && !validateNotEmpty(obj2.value))
  {
      alert("Please enter landline phone or mobile phone");
      obj2.focus();
      return false;
  }

  obj = document.getElementById("c_email");
  if (!validateNotEmpty(obj.value))
  {
    alert("Please enter your email");  
     obj.focus();
     return false; 
  }
  
  if (!emailCheck(obj.value))
  {
      alert("Your email is incorrect.");
      obj.focus();
      return false;
  }

    myOption = -1;
    for (i=save_money.loan_type.length-1; i > -1; i--)
    {
      if (save_money.loan_type[i].checked)
      {
          myOption = i; i = -1;
      }
    }
    if (myOption == -1)
    {
        alert("Please select a Loan Type");
        return false;
    }
/*==========================================================*/  
  
  obj = document.getElementById("loan_amount");
  obj_text ="Loan Amount";
  if (!validateNotEmpty(obj.value))
  {
     alert("Please enter " + obj_text);
     obj.focus();
     return false; 
  }
  if (!validateNumeric(obj.value))
  {
     alert("Please enter numeric only in Loan Amount");
     obj.focus();
     return false; 
  }
  
return true;
}
function contact_us_val()
{
  var obj, obj_text, msg_obj;

  obj = document.getElementById("fname");
  obj_text ="First Name";
  if (!validateNotEmpty(obj.value))
  {
     alert("Please enter your " + obj_text);
     obj.focus();
     return false; 
  }
  obj = document.getElementById("lname");
  obj_text ="Last Name";
  if (!validateNotEmpty(obj.value))
  {
     alert("Please enter your " + obj_text);
     obj.focus();
     return false; 
  }
  
  obj = document.getElementById("phone");
  obj_text ="Phone";
  if (!validateNotEmpty(obj.value))
  {
     alert("Please enter your " + obj_text);
     obj.focus();
     return false; 
  }
  
  obj = document.getElementById("email");
  obj_text ="email";
  if (!validateNotEmpty(obj.value))
  {
     alert("Please enter your " + obj_text);
     obj.focus();
     return false; 
  }
  
  obj = document.getElementById("msg");
  obj_text ="message";
  if (!validateNotEmpty(obj.value))
  {
     alert("Please enter your " + obj_text);
     obj.focus();
     return false; 
  }
  
  return true;
}  
function quote_form_val()
{
  var obj, obj_text, msg_obj;

     
  //msg_obj = document.getElementById("msg");

  obj = document.getElementById("customer_title");
  obj_text ="Title";
  if (!validateNotEmpty(obj.options[obj.selectedIndex].value))
  {
     //msg_obj.innerHTML="Please enter your " + obj_text;
     alert("Please enter your " + obj_text);
     obj.focus();
     //obj.style.backgroundColor = "#000000";
     //obj.style.border = "1px solid #ff0000";
     return false; 
  }

  obj = document.getElementById("customer_fullname");
  obj_text ="Full Name";
  if (!validateNotEmpty(obj.value))
  {
     //msg_obj.innerHTML="Please enter your " + obj_text;
     alert("Please enter your " + obj_text);
     obj.focus();
     return false; 
  } 


  obj = document.getElementById("customer_postcode");
  obj_text ="Post Code";
  if (validateNotEmpty(obj.value))
  {
     if (!validateNumeric(obj.value))
     {
        alert("Please enter 4 digitals only");
        obj.focus();
        return false;
     }
     else
     {
        if (obj.value.length != 4)
        {
          alert("Postcode must be 4 digitals");
          return false;
        }
     }      
  }


  obj = document.getElementById("customer_phone");
  obj_text ="Phone";
  if (!validateNotEmpty(obj.value))
  {
     alert("Please enter your " + obj_text);
     obj.focus();
     return false; 
  }
  
   if (!validateNumeric(obj.value))
   {
      alert("Please enter 10 digitals only");
      obj.focus();
      return false;
   }
   else
   {
      if (obj.value.length != 10)
      {
        alert("Phone number must be 10 digitals");
        return false;
      }
   }
     

  obj = document.getElementById("customer_email");
  obj_text ="Email";
  if (!validateNotEmpty(obj.value))
  {
     alert("Please enter your " + obj_text);
     obj.focus();
     return false; 
  }

  if (!emailCheck(obj.value))
  {
      alert("Please enter valid email");
      obj.focus();
      obj.select();
      return false;
  }
  
  obj = document.getElementById("customer_numbers");
  obj_text ="Number of persons";
  if (!validateNotEmpty(obj.value))
  {
     alert("Please enter your " + obj_text);
     obj.focus();
     return false; 
  }  
  
  
   if (!validateNumeric(obj.value))
   {
      alert("Please enter digitals only");
      obj.focus();
      return false;
   }
   
   if (obj.value <= 0)
   {
      alert("Number of persons must be greater than 0");
      obj.focus();
      return false;
   }
/*   
   else
   {
      if (obj.value.length != 10)
      {
        alert("Phone number must be 10 digitals");
        return false;
      }
   }
*/
  
  obj = document.getElementById("customer_time");
  obj_text ="Time";
  if (!validateNotEmpty(obj.value))
  {
     alert("Please select booking time");
     obj.focus();
     return false; 
  }   
return true;
}

