// MDF Form Scripted by Empire Elements
// www.empire-elements.co.uk
function validate(f) 
	{
	  if (f.col1.value=="") {
        alert("Please add External Colour!");
        f.col1.focus();
        return false;
        } 
	 if (f.col2.value=="") {
        alert("Please add Rout Styles Doors!");
        f.col2.focus();
        return false;
        } 
	 if (f.col3.value=="") {
        alert("Please add Rout Styles Drawer Fronts!");
        f.col3.focus();
        return false;
        } 
	 var a = parseInt(f.phone.value,10);
     if (! a || a <= 0 ) {
        alert("Please put your telephone number!");
        f.phone.focus();
        return false;
        }      
	  if (f.delivery.value=="") {
        alert("Please add delivery address!");
        f.delivery.focus();
        return false;
        } 
      if(f.pravidla.checked == false){
        alert("Sorry, you must confirm that order details are correct");
	    f.pravidla.focus();
        return false;
        }		
      if(f.pravidla2.checked == false){
        alert("Sorry, you must agree to our terms and conditions");
	    f.pravidla2.focus();
        return false;
        }		
     if(f.name.value == "") {
        alert("Please add your name");
        f.name.focus();
        return false;
        }
	  charset=new RegExp("^[^.]+(\.[^.]+)*@([^.]+[.])+[a-z]{2,3}$");
      if (!charset.test(f.email.value))
         {
         window.alert("Please add valid email address!");
         f.email.focus();
         return false;
         }
      charset=new RegExp("/^\w{1}:\\.+\.jpg$|^\w{1}:\\.+\.gif$|^\w{1}:\\.+\.png$|^\w{1}:\\.+\.JPG$$|^\w{1}:\\.+\.bmp$/");
      if(f.image.value !=""){
	  if(!check_img(f.image.value)){
	    alert("Please upload only .JPG or .GIF or .PNG or .BMP");
        f.image.focus();
        return false;
	   }
        }
return true; 
}
function check_img(img)
{
  re = /^\w{1}:\\.+\.jpg$|^\w{1}:\\.+\.gif$|^\w{1}:\\.+\.png$|^\w{1}:\\.+\.JPG$$|^\w{1}:\\.+\.bmp$/;
  return img.search(re) == 0;
}