



 exp_ver2=/firefox\/2.0/;
  exp_ver3=/opera 8/;
 
  if (exp_ver3.test(ua) ) {
    //document.write("<link rel='stylesheet' href='../css/main_ff2.css' type='text/css' />");
   document.write("<style>div.warning_border{height:23px;}  .graybox select.inline{height:21px;}  .graybox textarea{height:119px;} .graybox input{height:23px;}</style>"); 
  }
   if (exp_ver2.test(ua)) {
    //document.write("<link rel='stylesheet' href='../css/main_ff2.css' type='text/css' />");
   document.write("<style>div.warning_border{height:23px;}  .graybox select.inline{height:21px;}  .graybox textarea{height:115px;} .graybox input{height:18px;}</style>"); 
  }
var errMessage = "";
function tr(obj){
    s=obj.value;
    ieval = obj.def_value;
    if (ieval) {
     if (ieval == s)
       return "";
    }
    re=/^\s+/;s=s.replace(re, "");
    re=/\s+$/;s=s.replace(re, "");
    obj.value=s;
    return s;
}
function checkFields() {
    var el; 
    errMessage="";
    resetWarnings();
    if (tr(document.QuestionForm.question)=="") { 
        document.QuestionForm.question.focus(); 
        errMessage = "<div class='warning'>"+"Enter text of your question"+"</div>"+errMessage;
        el = document.getElementById('war_question');
        el.className = el.className.replace("no_warrning","warning_border");
    }
    if (!document.QuestionForm.byPhone.checked && !document.QuestionForm.byEmail.checked){
        document.QuestionForm.byPhone.focus(); 
        errMessage = "<div class='warning'>"+"Please, fill in at least one contact field."+"</div>"+errMessage;
        el = document.getElementById('war_user_email');
        el.className = el.className.replace("no_warrning","warning_border");
        el = document.getElementById('war_user_phone');
        el.className = el.className.replace("no_warrning","warning_border");       
    }
    if (document.QuestionForm.byEmail.checked && tr(document.QuestionForm.user_email)=="") { 
        document.QuestionForm.user_email.focus(); 
        errMessage = "<div class='warning'>"+"Enter your E-mail"+"</div>"+errMessage;
        el = document.getElementById('war_user_email');
        el.className = el.className.replace("no_warrning","warning_border");
    } else {
        if (document.QuestionForm.byEmail.checked && !isEmailTest(document.QuestionForm.user_email.value)) {
          document.QuestionForm.user_email.focus(); 
          errMessage = "<div class='warning'>"+"Enter correct E-mail"+"</div>"+errMessage;
          el = document.getElementById('war_user_email');
          el.className = el.className.replace("no_warrning","warning_border");
        }
    }
    if (document.QuestionForm.byPhone.checked && tr(document.QuestionForm.user_phone)=="") { 
        document.QuestionForm.user_phone.focus(); 
        errMessage = "<div class='warning'>"+"Enter your phone number / personal account"+"</div>"+errMessage;
        el = document.getElementById('war_user_phone');
        el.className = el.className.replace("no_warrning","warning_border");
    }
    if (tr(document.QuestionForm.user_name)=="") { 
        document.QuestionForm.user_name.focus(); 
        errMessage = "<div class='warning'>"+"Enter your name"+"</div>"+errMessage;
        el = document.getElementById('war_user_name');
        el.className = el.className.replace("no_warrning","warning_border");
    }
    if (errMessage=="") { 
        return true; 
    }
    else {
        document.getElementById("sendQuestionsInfo").innerHTML=errMessage;
        return false;
    }
}
function isEmailTest(inputValue) {
    var match = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(inputValue);
    return match;
}
function resetWarnings() {
    var el = document.getElementById('sendQuestionsInfo');
    if (el){
      el.innerHTML='';
    }
    el = document.getElementById('war_question');
    el.className = el.className.replace("warning_border","no_warrning");
    el = document.getElementById('war_user_email');
    el.className = el.className.replace("warning_border","no_warrning");
    el = document.getElementById('war_user_phone');
    el.className = el.className.replace("warning_border","no_warrning");
    el = document.getElementById('war_user_name');
    el.className = el.className.replace("warning_border","no_warrning");
}
function goSub() {
    if (document.QuestionForm.issubmit.value==0 && checkFields()) { 
        document.QuestionForm.issubmit.value=1;
        document.QuestionForm.submit();
    }
}
function truncateTextAreas() {
   var txts = document.getElementsByTagName('TEXTAREA')
   for(var i = 0, l = txts.length; i < l; i++) {
     if(/^[0-9]+$/.test(txts[i].getAttribute("maxlength"))) {
       txts[i].onkeyup = function() {
         var len = parseInt(this.getAttribute("maxlength"), 10);
         if(this.value.length > len) {
           //alert('Maximum length exceeded: ' + len);
           this.value = this.value.substr(0, len);
           return false;
         }
       }
     }
   }
 }
function phoneChangeListener(obj){
   var el = document.getElementsByName("byPhone")[0];
   if(obj.value!="") {
      el.checked = true;
   }else{
      el.checked = false;
   }  
}
function emailChangeListener(obj){
   var el = document.getElementsByName("byEmail")[0];
   if(obj.value!="") {
      el.checked = true;
   }else{
      el.checked = false;
   }  
}
 addOnloadEvent(truncateTextAreas);


