function checkRequired(f)
{
        var fl=true;
        for (var intLoop=0; intLoop<f.elements.length; intLoop++)
        if ("req"==f.elements[intLoop].className)
        {
                fl=fl&checkField(f.elements[intLoop]);
        }
        if (!fl)return false;
}

function isEmpty(str)
{
        for (var intLoop=0; intLoop<str.length; intLoop++)
        if (" "!=str.charAt(intLoop))return false;
        return true;
}


function checkField(el)
{
        //el.parentNode.className=isEmpty(el.value)? "lb_error":"lb_normal";
        var fl=true;
        if (isEmpty(el.value))
        {
                fl=false;
                el.parentNode.className="lb_error";
                alert('Обязательное поле '+el.title+' не заполнено!');
        }else
        {
                if (el.name=='email' && !checkmail(el.value)) 
                {
                        fl=false;
                        el.parentNode.className="lb_error";
                        alert("Вы ввели неверный E-mail");
                }else
                if (el.type=='checkbox' && !el.checked)
                {
                        fl=false;
                        el.parentNode.className="lb_error";
                        alert('Обязательное поле '+el.title+' не отмечено!');
                }
                else
                el.parentNode.className="lb_normal";
        } 
//
        return fl;
}

function setNormal(el)
{
        el.parentNode.className="lb_normal";
}


//--------------------------
function checkmail(email) 
{ 
  if (email=="") return(false) 
  if (email.indexOf(".")==-1) return(false) 
  if (email.indexOf(".")==email.length-1) return(false) 
  dog=email.indexOf("@"); 
  if (dog==-1) return(false) 
  if ((dog<1)||(dog>email.length-5)) return(false) 
  if ((email.charAt(dog-1)=='.')||(email.charAt(dog+1)=='.')) return(false)
  return(true) 
} 


