// JavaScript Document
function checkform()
{
 
 var expTelephone = /[^\d\s-\.]+/;
 var expPin = /[^\d\s-\.]+/;
// var expDigit = /[^\d]+/;	

var b;
for (i = 1; i < document.frmdesign.dtype.options.length; i++) {
    if (document.frmdesign.dtype.options[i].selected) { 
		var b = 1;
		
		}
}
      if (!b) {
            alert("Please select the type of project.");
            document.frmdesign.dtype.focus();
            return false;
    }
	
if (((document.getElementById('otherbox').style.display)=='block') && (document.frmdesign.otherp.value.replace(/\s/g,'')=="")) {
		alert("Please enter your project type.");
		
		document.frmdesign.otherp.focus();
		return false;
	}

if (document.frmdesign.name.value.replace(/\s/g,'')=="") {
		alert("Please enter your name.");
		
		document.frmdesign.name.focus();
		return false;
	}
 

if(document.frmdesign.email.value.replace(/\s/g,'')=="")
	{
		alert("Please provide a valid email address.");
		document.frmdesign.email.value="";
		
		document.frmdesign.email.focus();
		return false;
	}
	else if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(document.frmdesign.email.value))
	{
		alert("Please provide a valid email address.")
		document.frmdesign.email.focus();
		return false;
	}
	
/*if (document.frmdesign.address.value.replace(/\s/g,'')=="") {
		alert("Please enter your address.");
		
		document.frmdesign.address.focus();
		return false;
	}
	
if (document.frmdesign.pphone.value.replace(/\s/g,'')=="") {
		alert("Please enter your personal phone number.");
		
		document.frmdesign.pphone.focus();
		return false;
	}
else if(expTelephone.test(document.frmdesign.pphone.value)==true)
	{
		alert("Phone number must be numeric.");
		
		document.frmdesign.pphone.focus();
		return false;
	}
	
if(document.frmdesign.pphone.value.replace(/\s/g,'')=="")
	{

		alert("Please provide your phone number.\nFor example, 01274 106107");
		document.frmdesign.pphone.value="";
		document.frmdesign.pphone.focus();
		return false;
	}
	if(expTelephone.test(document.frmdesign.pphone.value.replace(/\s/g,''))==true)
	{
		alert("Phone number must be numeric");
		document.frmdesign.pphone.focus();
		return false;
	}
	var dayphone=document.frmdesign.pphone.value.replace(/\s/g,'');
	if((dayphone.length!=10&&dayphone.length!=11)||(dayphone.charAt(0)!=0))
	{
			alert("Please provide a valid UK telephone number.\nFor example, 01274 106107");
			document.frmdesign.pphone.focus();
			return false;	
	}*/
	
if (document.frmdesign.contactno.value.replace(/\s/g,'')=="") {
		alert("Please enter your contact number.");
		
		document.frmdesign.contactno.focus();
		return false;
	}
else if(expTelephone.test(document.frmdesign.contactno.value)==true)
	{
		alert("Contact number must be numeric.");
		
		document.frmdesign.contactno.focus();
		return false;
	}

 document.frmdesign.submit();	

}	

function isNumberKey(evt)
     {
        var charCode = (evt.which) ? evt.which : event.keyCode
        if (charCode > 31 && (charCode < 48 || charCode > 57))
           return false;

        return true;
     }
	 
function otherpro()
	{
		document.getElementById('otherbox').style.display='block';
				
	}
	
function checkval()
	{
		 
		 var opvalue= document.getElementById('otherp').value; 
		 
		 len = document.frmdesign.dtype.length
		 i = 0;
		 chosen = "none"
		 for (i = 0; i < len; i++) 
		 {
			if (document.frmdesign.dtype.options[i].selected) 
			{
				chosen = document.frmdesign.dtype.options[i].value;
			
				if(chosen=="Other")
				{
					document.getElementById('otherbox').style.display='block';
				}
				
				if(chosen!="Other")
				{
					document.getElementById('otherbox').style.display='none';
					document.getElementById('otherp').value="";
					
				}
			}
		 }
		 //alert(document.frmdesign.dtype.options[i].value);
	
	
				
	}
