function checkform(form)
{
 allInputs = form.getElementsByTagName('*');

 var pregMatches = Array();
 
// pregMatches['inn'] = /^[0-9\/]+$/g;
// pregMatches['email'] = /^[a-zA-Z0-9\-_.]+@[a-zA-Z0-9\-_.]+$/g;
// pregMatches['phone'] = /^[0-9()\- +]+$/g;
 
 for (var i=0; i < allInputs.length; i++)
  {
    if (allInputs[i].className == "need_field")
    {
     
      if (!allInputs[i].value || ((allInputs[i].type == "checkbox") && !allInputs[i].checked))
      {
        alert('Заполните, пожалуйста, все обязательные поля');
        allInputs[i].focus();
        return false;
      }
      
    }  


    var field_name = new String(allInputs[i].name);
    
    for (key in pregMatches)
      {
      	if ((key != 'last') && allInputs[i].value && (field_name.indexOf(key) >= 0))
      	{
      		if (!allInputs[i].value.match(pregMatches[key]))
      		{
	      		alert('Заполните, пожалуйста, корректно все поля формы');
    	  		allInputs[i].focus();
      			return false;
      		}
      	}
      }
      
  }

 return true;

}


function checkorderform(form)
{
	var address = document.getElementById("delivery_address");
	
	if (!address) {
		
		alert("Для оформления заказа вам необходимо добавить адрес доставки");
		
		document.getElementById("delivery_address_add").focus();
		
		return false;
		
	}	
}	