function count(idform, max) {
    var err = 0;
    var tmp = 0;
    if (document.getElementById(idform) && document.getElementById('c'+idform)) {
        tobj = document.getElementById(idform);
        cobj = document.getElementById('c'+idform);
        tmp = tobj.value.length;
        if (tmp > max) {
            err = 1;
        }
        cobj.innerHTML = tmp+' из '+max;
        if (err == 1) {
            cobj.style.color = 'red';
        } else {
            cobj.style.color = '#C0C0C0';
        }
    }
    
}

function check_reg(){
if (document.getElementById('terms').checked == false) { alert('Вы должны принять условия соглашения!');  return false; }
var email = document.getElementById('email').value;
var pass1 = document.getElementById('pass1').value;
var pass2 = document.getElementById('pass2').value;

var param = /[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/;
if (email == 0)  { alert("Введите  E-mail!"); document.getElementById('email').focus(); return false; }
if (!email.match(param)){ alert("Пожалуйста, введите свой настоящий E-mail!"); document.getElementById('email').focus(); return false; }

if (!pass1){ alert("Введите пароль!"); document.getElementById('pass1').focus(); return false; }
if (pass1.length < 4){ alert("Пароль должен содержать не менее 5 знаков"); document.getElementById('pass1').focus(); return false; }
if (!pass2){ alert("Повторите пароль!"); document.getElementById('pass2').focus(); return false; }
if (pass1 != pass2){ alert("Пароли не совпадают!"); return false; }

return true;
}

function check_remind(){
var email = document.getElementById('email').value;
var param = /[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/;
if (email == 0)  {  document.getElementById('email').focus(); return false; }
if (!email.match(param)){ alert("Пожалуйста, введите свой настоящий E-mail!"); document.getElementById('email').focus(); return false; }
return true;
}



function check_proj(){
if(document.getElementById('file').value == 0 && document.getElementById('server_file').value == 0){
 if (document.getElementById('f0').value == 0){ alert('Пожалуйста, введите название проекта.'); document.getElementById('f0').focus(); return false; }
// if (document.getElementById('f1').value == 0){ alert('Пожалуйста, укажите тематику сайта.'); document.getElementById('f1').focus(); return false; }
 if (document.getElementById('f2').value == 0){ alert('Пожалуйста, введите адрес сайта.'); document.getElementById('f2').focus(); return false; }
// if (document.getElementById('f3').value == 0){ alert('Пожалуйста, введите e-mail.'); document.getElementById('f3').focus(); return false; }
 if (document.getElementById('f4').value == 0){ alert('Пожалуйста, введите ключевые слова.'); document.getElementById('f4').focus(); return false; }
// if (document.getElementById('f5').value == 0){ alert('Пожалуйста, введите номер телефона.'); document.getElementById('f5').focus(); return false; }
// if (document.getElementById('f6').value == 0){ alert('Пожалуйста, введите город.'); document.getElementById('f6').focus(); return false; }
// if (document.getElementById('f7').value == 0){ alert('Пожалуйста, введите название сайта.'); document.getElementById('f7').focus(); return false; }
// if (document.getElementById('f8').value == 0){ alert('Пожалуйста, введите краткое описание сайта.'); document.getElementById('f8').focus(); return false; }
// if (document.getElementById('f9').value == 0){ alert('Пожалуйста, введите полное описание  сайта.'); document.getElementById('f9').focus(); return false; }
}else{
 if (document.getElementById('f0').value == 0){ alert('Пожалуйста, введите название проекта.'); document.getElementById('f0').focus(); return false; }
// if (document.getElementById('f1').value == 0){ alert('Пожалуйста, укажите тематику сайта.'); document.getElementById('f1').focus(); return false; }
// if (document.getElementById('f2').value == 0){ alert('Пожалуйста, введите адрес сайта.'); document.getElementById('f2').focus(); return false; }
// if (document.getElementById('f3').value == 0){ alert('Пожалуйста, введите e-mail.'); document.getElementById('f3').focus(); return false; }
}
}


function pay_get()
{
 str = document.order.z.value;
if (str == "Z" || str == "") { alert("Введите номер кошелька");  return false; }
new_str = str.match(/[Zz0-9]+/);
if (str != new_str) { alert("Неверный формат номера кошелька");  return false; }
if (str.length < 13) { alert("Неверный формат номера кошелька");  return false; }
}



function comment()
{
var name = document.resp.name.value;
var www = document.resp.www.value;
var txt = document.resp.txt.value;
if (name == 0)  { alert("Введите Имя!"); document.resp.name.focus(); return false; }
if (www == 0)  { alert("Введите url сайта!"); document.resp.www.focus(); return false; }
if (www != www.match(/[a-zA-Z0-9/=:.-?_]+/)) { alert("Неверный url Сайта!"); document.resp.www.focus(); return false; }
if (txt == 0)  { alert("Введите Комментарий!"); document.resp.txt.focus(); return false; }
  return true;
}

function hide()
{
  for(i=0; i<hide.arguments.length; i++)
  {
     document.getElementById(hide.arguments[i]).style.display = 'none';
  }
}
function show(id)
{
  hide('d1', 'd2'); 
  document.getElementById(id).style.display = 'block';
}