function _checkstring_rus(Str)
{
        checkExp=new RegExp("([абвгдеёжзийклмнопрстуфхцчшщъыьэюяАБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ])+");
        var matchArray=Str.match(checkExp);
        if (matchArray==null) return false;
        else return true;
}

function _checkstring_eng(Str)
{
        checkExp=new RegExp("([qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM])+");
        var matchArray=Str.match(checkExp);
        if (matchArray==null) return false;
        else return true;
}

function validate_step0(theform) {
        if ( theform.email.value=="") {
                alert("Введите e-mail!");
                return false; }
//        if (! /^\w+([\.\-]?\w+)*@\w+([\.\-]?\w+)*(\.\w{2,4})+$/.test(theform.email.value))
        if (! /^([\w\.\-]+)@\w+([\.\-]?\w+)*(\.\w{2,4})+$/.test(theform.email.value))
            {alert("Ошибка в адресе e-mail!");
                return false;}
        if ( theform.imagestamp.value=="") {
                alert("Впишите пожалуйста слово, которое видите на картинке!");
                return false; }
 return true;
}

function validate_step1(theform) {
        if ( theform.username.value=='') {
                alert("Выберите имя своего дневника (сообщества)!");
                theform.username.focus();
                return false; }

        if ( _checkstring_eng(theform.username.value) && _checkstring_rus(theform.username.value) ) {
                alert("Имя может состоят только из русских или только из английских символов!");
                theform.username.focus();
                return false; }

        if ( theform.sexchar.value==-1) {
                alert("Выберите Ваш пол!");
                theform.sexchar.focus();
                return false; }

        if ( (theform.month.value==-1) || (theform.day.value==-1) || ((theform.year.value==-1 && theform.comm.value==0)))
        {        alert("Введите день, месяц и год рождения!");
                theform.month.focus();
                return false; }

        if ( theform.city.value==0) {
                alert("Выберите город, в котором вы находитесь!");
                theform.city.focus();
                return false; }

        if ( theform.imagestamp && theform.imagestamp.value=='') {
                alert("Введите код подтверждения!");
                theform.city.focus();
                return false; }

        if ( theform.themeid.value==-1) {theform.themeid.value=0}
        if ( theform.addinfo.value=="") {
                alert("Напишите пожалуйста пару предложений о создаваемом дневнике или сообществе");
                theform.addinfo.focus();
                return false;}
 return true;
}

function validate_step2(theform) {
        if ( (theform.month.value==-1) || (theform.day.value==-1) || ((theform.year.value==-1 && theform.comm.value==0))) {
                alert("Введите день, месяц и год рождения!");
                return false; }

        if ( theform.city.value==0) {
                alert("Выберите Ваше местоположение!");
                return false; }

        if ( theform.themeid.value==-1) {theform.themeid.value=0}
//                alert("Выберите цветовую схему оформления Вашего дневника!");
//                return false; }
        if ( theform.title.value=="") {
                alert("Введите заголовок первой записи!");
                return false; }
        if ( theform.addinfo.value=="") {
                alert("Введите первую запись!");
                return false; }
 return true;
}

function validate_step3(theform) {
/*        if (theform.name.value=="") {
                alert("Введите Ваше имя!");
                return false; }

        if ( theform.pname.value==0) {
                alert("Выберите Ваше отчество!");
                return false; }

        if ( theform.industry.value==-1) {
                alert("Выберите отрасль!");
                return false; }
        if ( theform.family.value=="") {
                alert("Введите Вашу фамилию!");
                return false; }
        if ( theform.speciality.value=="") {
                alert("Введите Вашу специализацию!");
                return false; }*/
 return true;
}

function open_check(username)
{
  window.open('/check_user.php?username='+username, '_blank', 'left=100,top=100,width=450,height=300,location=0,menubar=0,resizable=0,scrollbars=1,status=0,toolbar=0');
  return false;
}


