window.signup =
  {
    //ERRORS: BEGIN
    errors : [],
    //ERRORS: END

    flag : function(item, flag, title)
      {
        if (title.length > 0)
          {
            document.getElementById(item).style.cursor = 'help';
            document.getElementById(item).title = title;
          }
        else
          {
            document.getElementById(item).style.cursor = '';
            document.getElementById(item).title = '';
          }

             if (flag == 'ok')            document.getElementById(item).src = '/templates/images/signup/ok.gif';
        else if (flag == 'error')         document.getElementById(item).src = '/templates/images/signup/error.gif';
        else if (flag == 'not_available') document.getElementById(item).src = '/templates/images/signup/not_available.gif';
        else if (flag == 'unknown')       document.getElementById(item).src = '/templates/images/signup/unknown.gif';
        else                              document.getElementById(item).src = '/templates/images/signup/null.gif';
      },

    all : function()
      {
        this.errors = [];

        this.login();
        this.password();
        this.password_confirm();
        this.email();
        this.name_first();
        this.name_last();
        this.birthdate();
        this.gender();
        this.terms();
        this.legality();
        //this.captcha();

        this.nick();
        this.country();
        this.city();
        this.address1();
        this.address2();
        this.postcode();
        this.phone_cell();
        this.phone_home();
        this.phone_work();
        this.im();
        this.referrer_id();
        this.promo_code();
        this.subscribed();

        if (this.errors.length > 0)
          {
            var message = ((this.errors.length == 1)?'Error:\r\n':'Errors:\r\n');
            for (var i = 0; i < this.errors.length; ++i)
              {
                message += '\r\n * ' + this.errors[i];
              }
            alert(message);

            return false;
          }
        else
          {
            return true;
          }
      },

    login : function(exists)
      {
        var regexp_login1 = /^[A-Za-z0-9_-]+$/;
        var regexp_login2 = /^[A-Za-z]/;

        if (document.getElementById('signup_login').value.length == 0)
          {
            this.login_exists_timing_stop();
            this.errors.push('Login is required');
            this.flag('signup_login_flag', 'error', 'Login is required');
            return false;
          }
        else if (!regexp_login1.test(document.getElementById('signup_login').value))
          {
            this.login_exists_timing_stop();
            this.errors.push('Only Latin letters, numbers, hyphens and underscores can be used for your login');
            this.flag('signup_login_flag', 'error', 'Only Latin letters, numbers, hyphens and underscores can be used for your login');
            return false;
          }
        else if (!regexp_login2.test(document.getElementById('signup_login').value))
          {
            this.login_exists_timing_stop();
            this.errors.push('Login should begin with a letter');
            this.flag('signup_login_flag', 'error', 'Login should begin with a letter');
            return false;
          }
        else if (document.getElementById('signup_login').value.length < 3)
          {
            this.login_exists_timing_stop();
            this.errors.push('Your login must be at least 3 characters');
            this.flag('signup_login_flag', 'error', 'Your login must be at least 3 characters');
            return false;
          }
        else if (document.getElementById('signup_login').value.length > 20)
          {
            this.login_exists_timing_stop();
            this.errors.push('Your login is too long; 20 characters max');
            this.flag('signup_login_flag', 'error', 'Your login is too long; 20 characters max');
            return false;
          }
        else if (exists)
          {
            document.getElementById('signup_login_exists').value = 0;
            signup.flag('signup_login_flag', 'unknown', 'Please, wait...');
            this.login_exists(document.getElementById('signup_login').value, 'signup.flag(\'signup_login_flag\', \'not_available\', \'Sorry, but that login already exists\'); document.getElementById(\'signup_login_exists\').value = 1;', 'signup.flag(\'signup_login_flag\', \'ok\', \'OK\'); document.getElementById(\'signup_login_exists\').value = 0;', 'signup.flag(\'signup_login_flag\', \'unknown\', \'Login availability is unknown\'); document.getElementById(\'signup_login_exists\').value = 0;');
            return true;
          }
        else if (document.getElementById('signup_login_exists').value == 1)
          {
            this.errors.push('Your login is not available');
            return false;
          }
        else
          {
            signup.flag('signup_login_flag', 'ok', 'OK');
            return true;
          }
      },

    password : function()
      {
        var regexp_password = /^[A-Za-z0-9]+$/;

        if (document.getElementById('signup_password').value.length == 0)
          {
            this.errors.push('Password is required');
            this.flag('signup_password_flag', 'error', 'Password is required');
            return false;
          }
        else if (document.getElementById('signup_password').value == document.getElementById('signup_login').value)
          {
            this.errors.push('Your password and login cannot be the same');
            this.flag('signup_password_flag', 'error', 'Your password and login cannot be the same');
            return false;
          }
        else if (document.getElementById('signup_password').value == document.getElementById('signup_nick').value)
          {
            this.errors.push('Your password and screen name cannot be the same');
            this.flag('signup_password_flag', 'error', 'Your password and screen name cannot be the same');
            return false;
          }
        else if (!regexp_password.test(document.getElementById('signup_password').value))
          {
            this.errors.push('Only Latin letters and numbers can be used for your password');
            this.flag('signup_password_flag', 'error', 'Only Latin letters and numbers can be used for your password');
            return false;
          }
        else if (document.getElementById('signup_password').value.length < 6)
          {
            this.errors.push('Your password must be at least 6 characters');
            this.flag('signup_password_flag', 'error', 'Your password must be at least 6 characters');
            return false;
          }
        else if (document.getElementById('signup_password').value.length > 32)
          {
            this.errors.push('Your password is too long; 32 characters max');
            this.flag('signup_password_flag', 'error', 'Your password is too long; 32 characters max');
            return false;
          }
        else
          {
            this.flag('signup_password_flag', 'ok', 'OK');
            return true;
          }
      },

    password_confirm : function()
      {
        if (document.getElementById('signup_password_confirm').value.length == 0)
          {
            this.errors.push('Password confirmation is required');
            this.flag('signup_password_confirm_flag', 'error', 'Password confirmation is required');
            return false;
          }
        else if (document.getElementById('signup_password').value != document.getElementById('signup_password_confirm').value)
          {
            this.errors.push('Your password and confirmation are not the same');
            this.flag('signup_password_confirm_flag', 'error', 'Your password and confirmation are not the same');
            return false;
          }
        else
          {
            this.flag('signup_password_confirm_flag', 'ok', 'OK');
            return true;
          }
      },

    email : function()
      {
        var regexp_email = /^[a-zA-Z0-9\._-]+@(.{1,}\.)*[a-zA-Z0-9]+[a-zA-Z0-9-]*[a-zA-Z0-9]+\.[a-zA-Z]{2,4}$/;

        if (document.getElementById('signup_email').value.length == 0)
          {
            this.errors.push('E-mail is required');
            this.flag('signup_email_flag', 'error', 'E-mail is required');
            return false;
          }
        else if (!regexp_email.test(document.getElementById('signup_email').value))
          {
            this.errors.push('There is a mistake in your e-mail');
            this.flag('signup_email_flag', 'error', 'There is a mistake in your e-mail');
            return false;
          }
        else if (document.getElementById('signup_email').value.length > 129)
          {
            this.errors.push('Your e-mail is too long; 129 characters max');
            this.flag('signup_email_flag', 'error', 'Your e-mail is too long; 129 characters max');
            return false;
          }
        else
          {
            this.flag('signup_email_flag', 'ok', 'OK');
            return true;
          }
      },

    name_first : function()
      {
        var regexp_name_first = /^[A-Za-z]+$/;

        if (document.getElementById('signup_name_first').value.length == 0)
          {
            this.errors.push('First name is required');
            this.flag('signup_name_first_flag', 'error', 'First name is required');
            return false;
          }
        else if (!regexp_name_first.test(document.getElementById('signup_name_first').value))
          {
            this.errors.push('Only Latin letters are allowed in your first name');
            this.flag('signup_name_first_flag', 'error', 'Only Latin letters are allowed in your first name');
            return false;
          }
        else if (document.getElementById('signup_name_first').value.length > 20)
          {
            this.errors.push('Your first name is too long; 20 characters max');
            this.flag('signup_name_first_flag', 'error', 'Your first name is too long; 20 characters max');
            return false;
          }
        else
          {
            this.flag('signup_name_first_flag', 'ok', 'OK');
            return true;
          }
      },

    name_last : function()
      {
        var regexp_name_last = /^[A-Za-z]+$/;

        if (document.getElementById('signup_name_last').value.length == 0)
          {
            this.errors.push('Last name is required');
            this.flag('signup_name_last_flag', 'error', 'Last name is required');
            return false;
          }
        else if (!regexp_name_last.test(document.getElementById('signup_name_last').value))
          {
            this.errors.push('Only Latin letters are allowed in your last name');
            this.flag('signup_name_last_flag', 'error', 'Only Latin letters are allowed in your last name');
            return false;
          }
        else if (document.getElementById('signup_name_last').value.length > 20)
          {
            this.errors.push('Your last name is too long; 20 characters max');
            this.flag('signup_name_last_flag', 'error', 'Your last name is too long; 20 characters max');
            return false;
          }
        else
          {
            this.flag('signup_name_last_flag', 'ok', 'OK');
            return true;
          }
      },

    birthdate : function()
      {
        if ((this.birthdate_day()) && (this.birthdate_month()) && (this.birthdate_year()))
          {
            if ((document.getElementById('signup_birthdate_day').value == 0) && (document.getElementById('signup_birthdate_month').value == 0) && (document.getElementById('signup_birthdate_year').value == 0))
              {
                this.errors.push('Date of Birth is required');
                this.flag('signup_birthdate_flag', 'error', 'Date of Birth is required');
                return false;
              }
            else
              {
                this.flag('signup_birthdate_flag', 'ok', 'OK');
                return true;
              }
          }
        else
          {
            return false;
          }
      },

    birthdate_day : function()
      {
        if (((document.getElementById('signup_birthdate_day').value == 0) && ((document.getElementById('signup_birthdate_month').value != 0) || (document.getElementById('signup_birthdate_year').value != 0))) || ((document.getElementById('signup_birthdate_day').value != 0) && ((document.getElementById('signup_birthdate_month').value == 0) && (document.getElementById('signup_birthdate_year').value == 0))))
          {
            this.errors.push('Date of birth should be entered in full');
            this.flag('signup_birthdate_flag', 'error', 'Date of birth should be entered in full');
            return false;
          }
        else if (((document.getElementById('signup_birthdate_day').value == 29) && (document.getElementById('signup_birthdate_month').value == 2) && (document.getElementById('signup_birthdate_year').value % 4 != 0)) || ((document.getElementById('signup_birthdate_month').value == 2) && (document.getElementById('signup_birthdate_day').value == 30)) || (((document.getElementById('signup_birthdate_month').value == 2) || (document.getElementById('signup_birthdate_month').value == 4) || (document.getElementById('signup_birthdate_month').value == 6) || (document.getElementById('signup_birthdate_month').value == 9) || (document.getElementById('signup_birthdate_month').value == 11)) && (document.getElementById('signup_birthdate_day').value == 31)))
          {
            this.errors.push('Date of birth doesn\'t exist');
            this.flag('signup_birthdate_flag', 'error', 'Date of birth doesn\'t exist');
            return false;
          }
        else if (!((document.getElementById('signup_birthdate_day').value >= 0) && (document.getElementById('signup_birthdate_day').value <= 31)))
          {
            this.errors.push('Date of birth is invalid');
            this.flag('signup_birthdate_flag', 'error', 'Date of birth is invalid');
            return false;
          }
        else return true;
      },

    birthdate_month : function()
      {
        if (((document.getElementById('signup_birthdate_month').value == 0) && ((document.getElementById('signup_birthdate_day').value != 0) || (document.getElementById('signup_birthdate_year').value != 0))) || ((document.getElementById('signup_birthdate_month').value != 0) && ((document.getElementById('signup_birthdate_day').value == 0) && (document.getElementById('signup_birthdate_year').value == 0))))
          {
            this.errors.push('Date of birth should be entered in full');
            this.flag('signup_birthdate_flag', 'error', 'Date of birth should be entered in full');
            return false;
          }
        else if (!((document.getElementById('signup_birthdate_month').value >= 0) && (document.getElementById('signup_birthdate_month').value <= 12)))
          {
            this.errors.push('Date of birth is invalid');
            this.flag('signup_birthdate_flag', 'error', 'Date of birth is invalid');
            return false;
          }
        else return true;
      },

    birthdate_year : function()
      {
        if (((document.getElementById('signup_birthdate_year').value == 0) && ((document.getElementById('signup_birthdate_day').value != 0) || (document.getElementById('signup_birthdate_month').value != 0))) || ((document.getElementById('signup_birthdate_year').value != 0) && ((document.getElementById('signup_birthdate_day').value == 0) && (document.getElementById('signup_birthdate_month').value == 0))))
          {
            this.errors.push('Date of birth should be entered in full');
            this.flag('signup_birthdate_flag', 'error', 'Date of birth should be entered in full');
            return false;
          }
        else if (!(document.getElementById('signup_birthdate_year').value >= 0))
          {
            this.errors.push('Date of birth is invalid');
            this.flag('signup_birthdate_flag', 'error', 'Date of birth is invalid');
            return false;
          }
        else return true;
      },

    gender : function()
      {
        if ((document.getElementById('signup_gender_m').checked) || (document.getElementById('signup_gender_f').checked))
          {
            this.flag('signup_gender_flag', 'ok', 'OK');
            return true;
          }
        else
          {
            this.errors.push('Gender is required');
            this.flag('signup_gender_flag', 'error', 'Gender is required');
            return false;
          }
      },

    terms : function()
      {
        if (document.getElementById('signup_terms').checked)
          {
            this.flag('signup_terms_flag', 'ok', 'OK');
            return true;
          }
        else
          {
            this.errors.push('You must agree with our Terms and Conditions');
            this.flag('signup_terms_flag', 'error', 'You must agree with our Terms and Conditions');
            return false;
          }
      },

    legality : function()
      {
        if (document.getElementById('signup_legality').checked)
          {
            this.flag('signup_legality_flag', 'ok', 'OK');
            return true;
          }
        else
          {
            this.errors.push('You must accept full responsibility for the legality of your actions on BetCruise under the laws of your jurisdiction');
            this.flag('signup_legality_flag', 'error', 'You must accept full responsibility for the legality of your actions on BetCruise under the laws of your jurisdiction');
            return false;
          }
      },

    captcha : function()
      {
        return true;

        var regexp_captcha = /^[0-9]+$/;

        if (document.getElementById('signup_captcha').value.length == 0)
          {
            this.errors.push('Sequence from the image is required');
            this.flag('signup_captcha_flag', 'error', 'Sequence from the image is required');
            return false;
          }
        else if (!regexp_captcha.test(document.getElementById('signup_captcha').value))
          {
            this.errors.push('Only numbers can be used in a sequence from the image');
            this.flag('signup_captcha_flag', 'error', 'Only numbers can be used in a sequence from the image');
            return false;
          }
        else if (document.getElementById('signup_captcha').value.length != 5)
          {
            this.errors.push('The sequence from the image should be 5 characters long');
            this.flag('signup_captcha_flag', 'error', 'The sequence from the image should be 5 characters long');
            return false;
          }
        else
          {
            this.flag('signup_captcha_flag', 'ok', 'OK');
            return true;
          }
      },

    nick : function(exists)
      {
        var regexp_nick1 = /^[A-Za-z0-9_-]+$/;
        var regexp_nick2 = /^[A-Za-z]/;

        if (document.getElementById('signup_nick').value.length == 0)
          {
            this.nick_exists_timing_stop();
            this.flag('signup_nick_flag', 'null', '');
            return true;
          }
        else if (!regexp_nick1.test(document.getElementById('signup_nick').value))
          {
            this.nick_exists_timing_stop();
            this.errors.push('Only Latin letters, numbers, hyphens and underscores can be used for your screen name');
            this.flag('signup_nick_flag', 'error', 'Only Latin letters, numbers, hyphens and underscores can be used for your screen name');
            return false;
          }
        else if (!regexp_nick2.test(document.getElementById('signup_nick').value))
          {
            this.nick_exists_timing_stop();
            this.errors.push('Screen name should begin with a letter');
            this.flag('signup_nick_flag', 'error', 'Screen name should begin with a letter');
            return false;
          }
        else if (document.getElementById('signup_nick').value.length < 3)
          {
            this.nick_exists_timing_stop();
            this.errors.push('Your screen name be must at least 3 characters');
            this.flag('signup_nick_flag', 'error', 'Your screen name must be at least 3 characters');
            return false;
          }
        else if (document.getElementById('signup_nick').value.length > 20)
          {
            this.nick_exists_timing_stop();
            this.errors.push('Your screen name is too long; 20 characters max');
            this.flag('signup_nick_flag', 'error', 'Your screen name is too long; 20 characters max');
            return false;
          }
        else if (exists)
          {
            document.getElementById('signup_nick_exists').value = 0;
            signup.flag('signup_nick_flag', 'unknown', 'Please, wait...');
            this.nick_exists(document.getElementById('signup_nick').value, 'signup.flag(\'signup_nick_flag\', \'not_available\', \'Sorry, but that screen name already exists\'); document.getElementById(\'signup_nick_exists\').value = 1;', 'signup.flag(\'signup_nick_flag\', \'ok\', \'OK\'); document.getElementById(\'signup_nick_exists\').value = 0;', 'signup.flag(\'signup_nick_flag\', \'unknown\', \'Screen name availability is unknown\'); document.getElementById(\'signup_nick_exists\').value = 0;');
            return true;
          }
        else if (document.getElementById('signup_nick_exists').value == 1)
          {
            this.errors.push('Your screen name is not available');
            return false;
          }
        else
          {
            this.flag('signup_nick_flag', 'ok', 'OK');
            return true;
          }
      },

    country : function(exists)
      {
        if (document.getElementById('signup_country').value.length == 0)
          {
            this.country_exists_timing_stop();
            this.flag('signup_country_flag', 'null', '');
            return true;
          }
        else if (document.getElementById('signup_country').value.length < 3)
          {
            this.country_exists_timing_stop();
            this.errors.push('Your country must be at least 3 characters');
            this.flag('signup_country_flag', 'error', 'Your country must be at least 3 characters');
            return false;
          }
        else if (document.getElementById('signup_country').value.length > 38)
          {
            this.country_exists_timing_stop();
            this.errors.push('Your country is too long; 38 characters max');
            this.flag('signup_country_flag', 'error', 'Your country is too long; 38 characters max');
            return false;
          }
        else if (exists)
          {
            document.getElementById('signup_country_exists').value = 1;
            signup.flag('signup_country_flag', 'unknown', 'Please, wait...');
            this.country_exists(document.getElementById('signup_country').value, 'signup.flag(\'signup_country_flag\', \'ok\', \'OK\'); document.getElementById(\'signup_country_exists\').value = 1;', 'signup.flag(\'signup_country_flag\', \'null\', \'\'); document.getElementById(\'signup_country_exists\').value = 1;', 'signup.flag(\'signup_country_flag\', \'not_available\', \'Sorry, but that country does not exist\'); document.getElementById(\'signup_country_exists\').value = 0;', 'signup.flag(\'signup_country_flag\', \'unknown\', \'Country availability is unknown\'); document.getElementById(\'signup_country_exists\').value = 1;');
            return true;
          }
        else if (document.getElementById('signup_country_exists').value == 0)
          {
            this.errors.push('Your country is not available');
            return false;
          }
        else
          {
            signup.flag('signup_country_flag', 'null', '');
            return true;
          }
      },

    city : function()
      {
        var regexp_city = /^[A-Za-z-\s]+$/;

        if (document.getElementById('signup_city').value.length == 0)
          {
            this.flag('signup_city_flag', 'null', '');
            return true;
          }
        else if (!regexp_city.test(document.getElementById('signup_city').value))
          {
            this.errors.push('Only Latin letters, hyphens and spaces are allowed in your city');
            this.flag('signup_city_flag', 'error', 'Only Latin letters, hyphens and spaces are allowed in your city');
            return false;
          }
        else if (document.getElementById('signup_city').value.length > 32)
          {
            this.errors.push('Your city is too long; 32 characters max');
            this.flag('signup_city_flag', 'error', 'Your city is too long; 32 characters max');
            return false;
          }
        else
          {
            this.flag('signup_city_flag', 'ok', 'OK');
            return true;
          }
      },

    address1 : function()
      {
        var regexp_address1 = /^[A-Za-z0-9-_,\.\'\s\/\[\]\:\;\`\#\*\(\)]+$/;

        if (document.getElementById('signup_address1').value.length == 0)
          {
            this.flag('signup_address1_flag', 'null', '');
            return true;
          }
        else if (!regexp_address1.test(document.getElementById('signup_address1').value))
          {
            this.errors.push('Inadmissible character in your address line one');
            this.flag('signup_address1_flag', 'error', 'Inadmissible character in your address line one');
            return false;
          }
        else if (document.getElementById('signup_address1').value.length > 100)
          {
            this.errors.push('Your address line one is too long; 100 characters max');
            this.flag('signup_address1_flag', 'error', 'Your address line one is too long; 100 characters max');
            return false;
          }
        else
          {
            this.flag('signup_address1_flag', 'ok', 'OK');
            return true;
          }
      },

    address2 : function()
      {
        var regexp_address2 = /^[A-Za-z0-9-_,\.\'\s\/\[\]\:\;\`\#\*\(\)]+$/;

        if (document.getElementById('signup_address2').value.length == 0)
          {
            this.flag('signup_address2_flag', 'null', '');
            return true;
          }
        else if (!regexp_address2.test(document.getElementById('signup_address2').value))
          {
            this.errors.push('Inadmissible character in your address line two');
            this.flag('signup_address2_flag', 'error', 'Inadmissible character in your address line two');
            return false;
          }
        else if (document.getElementById('signup_address2').value.length > 100)
          {
            this.errors.push('Your address line two is too long; 100 characters max');
            this.flag('signup_address2_flag', 'error', 'Your address line two is too long; 100 characters max');
            return false;
          }
        else
          {
            this.flag('signup_address2_flag', 'ok', 'OK');
            return true;
          }
      },

    postcode : function()
      {
        var regexp_postcode = /^[A-Za-z0-9\s]+$/;

        if (document.getElementById('signup_postcode').value.length == 0)
          {
            this.flag('signup_postcode_flag', 'null', '');
            return true;
          }
        else if (!regexp_postcode.test(document.getElementById('signup_postcode').value))
          {
            this.errors.push('Only Latin letters, numbers and spaces are allowed in your postal code');
            this.flag('signup_postcode_flag', 'error', 'Only Latin letters, numbers and spaces are allowed in your postal code');
            return false;
          }
        else if (document.getElementById('signup_postcode').value.length > 16)
          {
            this.errors.push('Your postal code is too long; 16 characters max');
            this.flag('signup_postcode_flag', 'error', 'Your postal code is too long; 16 characters max');
            return false;
          }
        else
          {
            this.flag('signup_postcode_flag', 'ok', 'OK');
            return true;
          }
      },

    phone_cell : function()
      {
        if ((this.phone_cell_country()) && (this.phone_cell_area()) && (this.phone_cell_local()))
          {
            if (document.getElementById('signup_phone_cell_local').value.length == 0)
              {
                this.flag('signup_phone_cell_flag', 'null', '');
              }
            else
              {
                this.flag('signup_phone_cell_flag', 'ok', 'OK');
              }

            return true;
          }
        else
          {
            return false;
          }
      },

    phone_cell_country : function()
      {
        var regexp_phone_cell_country = /^[0-9]+$/;

        if ((document.getElementById('signup_phone_cell_country').value.length == 0) && (document.getElementById('signup_phone_cell_local').value.length != 0))
          {
            this.errors.push('Cell phone should be entered in full');
            this.flag('signup_phone_cell_flag', 'error', 'Cell phone should be entered in full');
            return false;
          }
        else if (document.getElementById('signup_phone_cell_country').value.length == 0)
          {
            return true;
          }
        else if (!regexp_phone_cell_country.test(document.getElementById('signup_phone_cell_country').value))
          {
            this.errors.push('Only numbers allowed in cell phone country code');
            this.flag('signup_phone_cell_flag', 'error', 'Only numbers allowed in cell phone country code');
            return false;
          }
        else if (document.getElementById('signup_phone_cell_country').value.length > 3)
          {
            this.errors.push('Cell phone country code is too long; 3 characters max');
            this.flag('signup_phone_cell_flag', 'error', 'Cell phone country code is too long; 3 characters max');
            return false;
          }
        else return true;
      },

    phone_cell_area : function()
      {
        var regexp_phone_cell_area = /^[0-9]+$/;

        if ((document.getElementById('signup_phone_cell_area').value.length == 0) && (document.getElementById('signup_phone_cell_local').value.length != 0))
          {
            this.errors.push('Cell phone should be entered in full');
            this.flag('signup_phone_cell_flag', 'error', 'Cell phone should be entered in full');
            return false;
          }
        else if (document.getElementById('signup_phone_cell_area').value.length == 0)
          {
            return true;
          }
        else if (!regexp_phone_cell_area.test(document.getElementById('signup_phone_cell_area').value))
          {
            this.errors.push('Only numbers allowed in cell phone area code');
            this.flag('signup_phone_cell_flag', 'error', 'Only numbers allowed in cell phone area code');
            return false;
          }
        else if (document.getElementById('signup_phone_cell_area').value.length > 5)
          {
            this.errors.push('Cell phone area code is too long; 5 characters max');
            this.flag('signup_phone_cell_flag', 'error', 'Cell phone area code is too long; 5 characters max');
            return false;
          }
        else return true;
      },

    phone_cell_local : function()
      {
        var regexp_phone_cell_local = /^[0-9]+$/;

        if (document.getElementById('signup_phone_cell_local').value.length == 0)
          {
            return true;
          }
        else if (!regexp_phone_cell_local.test(document.getElementById('signup_phone_cell_local').value))
          {
            this.errors.push('Only numbers allowed in cell phone subscriber\'s number');
            this.flag('signup_phone_cell_flag', 'error', 'Only numbers allowed in cell phone subscriber\'s number');
            return false;
          }
        else if (document.getElementById('signup_phone_cell_local').value.length > 24)
          {
            this.errors.push('Cell phone subscriber\'s number is too long; 24 characters max');
            this.flag('signup_phone_cell_flag', 'error', 'Cell phone subscriber\'s number is too long; 24 characters max');
            return false;
          }
        else return true;
      },

    phone_home : function()
      {
        if ((this.phone_home_country()) && (this.phone_home_area()) && (this.phone_home_local()))
          {
            if (document.getElementById('signup_phone_home_local').value.length == 0)
              {
                this.flag('signup_phone_home_flag', 'null', '');
              }
            else
              {
                this.flag('signup_phone_home_flag', 'ok', 'OK');
              }

            return true;
          }
        else
          {
            return false;
          }
      },

    phone_home_country : function()
      {
        var regexp_phone_home_country = /^[0-9]+$/;

        if ((document.getElementById('signup_phone_home_country').value.length == 0) && (document.getElementById('signup_phone_home_local').value.length != 0))
          {
            this.errors.push('Home phone should be entered in full');
            this.flag('signup_phone_home_flag', 'error', 'Home phone should be entered in full');
            return false;
          }
        else if (document.getElementById('signup_phone_home_country').value.length == 0)
          {
            return true;
          }
        else if (!regexp_phone_home_country.test(document.getElementById('signup_phone_home_country').value))
          {
            this.errors.push('Only numbers allowed in home phone country code');
            this.flag('signup_phone_home_flag', 'error', 'Only numbers allowed in home phone country code');
            return false;
          }
        else if (document.getElementById('signup_phone_home_country').value.length > 3)
          {
            this.errors.push('Home phone country code is too long; 3 characters max');
            this.flag('signup_phone_home_flag', 'error', 'Home phone country code is too long; 3 characters max');
            return false;
          }
        else return true;
      },

    phone_home_area : function()
      {
        var regexp_phone_home_area = /^[0-9]+$/;

        if ((document.getElementById('signup_phone_home_area').value.length == 0) && (document.getElementById('signup_phone_home_local').value.length != 0))
          {
            this.errors.push('Home phone should be entered in full');
            this.flag('signup_phone_home_flag', 'error', 'Home phone should be entered in full');
            return false;
          }
        else if (document.getElementById('signup_phone_home_area').value.length == 0)
          {
            return true;
          }
        else if (!regexp_phone_home_area.test(document.getElementById('signup_phone_home_area').value))
          {
            this.errors.push('Only numbers allowed in home phone area code');
            this.flag('signup_phone_home_flag', 'error', 'Only numbers allowed in home phone area code');
            return false;
          }
        else if (document.getElementById('signup_phone_home_area').value.length > 5)
          {
            this.errors.push('Home phone area code is too long; 5 characters max');
            this.flag('signup_phone_home_flag', 'error', 'Home phone area code is too long; 5 characters max');
            return false;
          }
        else return true;
      },

    phone_home_local : function()
      {
        var regexp_phone_home_local = /^[0-9]+$/;

        if (document.getElementById('signup_phone_home_local').value.length == 0)
          {
            return true;
          }
        else if (!regexp_phone_home_local.test(document.getElementById('signup_phone_home_local').value))
          {
            this.errors.push('Only numbers allowed in home phone subscriber\'s number');
            this.flag('signup_phone_home_flag', 'error', 'Only numbers allowed in home phone subscriber\'s number');
            return false;
          }
        else if (document.getElementById('signup_phone_home_local').value.length > 24)
          {
            this.errors.push('Home phone subscriber\'s number is too long; 24 characters max');
            this.flag('signup_phone_home_flag', 'error', 'Home phone subscriber\'s number is too long; 24 characters max');
            return false;
          }
        else return true;
      },

    phone_work : function()
      {
        if ((this.phone_work_country()) && (this.phone_work_area()) && (this.phone_work_local()))
          {
            if (document.getElementById('signup_phone_work_local').value.length == 0)
              {
                this.flag('signup_phone_work_flag', 'null', '');
              }
            else
              {
                this.flag('signup_phone_work_flag', 'ok', 'OK');
              }

            return true;
          }
        else
          {
            return false;
          }
      },

    phone_work_country : function()
      {
        var regexp_phone_work_country = /^[0-9]+$/;

        if ((document.getElementById('signup_phone_work_country').value.length == 0) && (document.getElementById('signup_phone_work_local').value.length != 0))
          {
            this.errors.push('Work phone should be entered in full');
            this.flag('signup_phone_work_flag', 'error', 'Work phone should be entered in full');
            return false;
          }
        else if (document.getElementById('signup_phone_work_country').value.length == 0)
          {
            return true;
          }
        else if (!regexp_phone_work_country.test(document.getElementById('signup_phone_work_country').value))
          {
            this.errors.push('Only numbers allowed in work phone country code');
            this.flag('signup_phone_work_flag', 'error', 'Only numbers allowed in work phone country code');
            return false;
          }
        else if (document.getElementById('signup_phone_work_country').value.length > 3)
          {
            this.errors.push('Work phone country code is too long; 3 characters max');
            this.flag('signup_phone_work_flag', 'error', 'Work phone country code is too long; 3 characters max');
            return false;
          }
        else return true;
      },

    phone_work_area : function()
      {
        var regexp_phone_work_area = /^[0-9]+$/;

        if ((document.getElementById('signup_phone_work_area').value.length == 0) && (document.getElementById('signup_phone_work_local').value.length != 0))
          {
            this.errors.push('Work phone should be entered in full');
            this.flag('signup_phone_work_flag', 'error', 'Work phone should be entered in full');
            return false;
          }
        else if (document.getElementById('signup_phone_work_area').value.length == 0)
          {
            return true;
          }
        else if (!regexp_phone_work_area.test(document.getElementById('signup_phone_work_area').value))
          {
            this.errors.push('Only numbers allowed in work phone area code');
            this.flag('signup_phone_work_flag', 'error', 'Only numbers allowed in work phone area code');
            return false;
          }
        else if (document.getElementById('signup_phone_work_area').value.length > 5)
          {
            this.errors.push('Work phone area code is too long; 5 characters max');
            this.flag('signup_phone_work_flag', 'error', 'Work phone area code is too long; 5 characters max');
            return false;
          }
        else return true;
      },

    phone_work_local : function()
      {
        var regexp_phone_work_local = /^[0-9]+$/;

        if (document.getElementById('signup_phone_work_local').value.length == 0)
          {
            return true;
          }
        else if (!regexp_phone_work_local.test(document.getElementById('signup_phone_work_local').value))
          {
            this.errors.push('Only numbers allowed in work phone subscriber\'s number');
            this.flag('signup_phone_work_flag', 'error', 'Only numbers allowed in work phone subscriber\'s number');
            return false;
          }
        else if (document.getElementById('signup_phone_work_local').value.length > 24)
          {
            this.errors.push('Work phone subscriber\'s number is too long; 24 characters max');
            this.flag('signup_phone_work_flag', 'error', 'Work phone subscriber\'s number is too long; 24 characters max');
            return false;
          }
        else return true;
      },

    im : function()
      {
        var regexp_im = /^[-_A-Za-z0-9\@\.\s]+$/;

        if (document.getElementById('signup_im').value.length == 0)
          {
            this.flag('signup_im_flag', 'null', '');
            return true;
          }
        else if (!regexp_im.test(document.getElementById('signup_im').value))
          {
            this.errors.push('Only Latin letters, numbers, hyphens, underscores, the \'@\' symbol, dots and spaces are allowed in your instant messenger ID');
            this.flag('signup_im_flag', 'error', 'Only Latin letters, numbers, hyphens, underscores, the \'@\' symbol, dots and spaces are allowed in your instant messenger ID');
            return false;
          }
        else if (document.getElementById('signup_im').value.length > 32)
          {
            this.errors.push('Your instant messenger ID is too long; 32 character max');
            this.flag('signup_im_flag', 'error', 'Your instant messenger ID is too long; 32 character max');
            return false;
          }
        else
          {
            this.flag('signup_im_flag', 'ok', 'OK');
            return true;
          }
      },

    referrer_id : function()
      {
        var regexp_referrer_id = /^[0-9]+$/;

        if (document.getElementById('signup_referrer_id').value.length == 0)
          {
            this.flag('signup_referrer_id_flag', 'null', '');
            return true;
          }
        else if (!regexp_referrer_id.test(document.getElementById('signup_referrer_id').value))
          {
            this.errors.push('Only numbers are allowed in your referrer ID');
            this.flag('signup_referrer_id_flag', 'error', 'Only number are allowed in your referrer ID');
            return false;
          }
        else if (document.getElementById('signup_referrer_id').value.length > 15)
          {
            this.errors.push('Your referrer ID is too long; 15 characters max');
            this.flag('signup_referrer_id_flag', 'error', 'Your referrer ID is too long; 15 characters max');
            return false;
          }
        else
          {
            this.flag('signup_referrer_id_flag', 'ok', 'OK');
            return true;
          }
      },

    promo_code : function()
      {
        var regexp_promo_code = /^[a-zA-Z0-9]+$/;

        if (document.getElementById('signup_promo_code').value.length == 0)
          {
            this.flag('signup_promo_code_flag', 'null', '');
            return true;
          }
        else if (!regexp_promo_code.test(document.getElementById('signup_promo_code').value))
          {
            this.errors.push('Only Latin letters and numbers are allowed in your promo code');
            this.flag('signup_promo_code_flag', 'error', 'Only Latin letters and numbers are allowed in your promo code');
            return false;
          }
        else if (document.getElementById('signup_promo_code').value.length < 4)
          {
            this.errors.push('Your promo code is too short; 4 characters min');
            this.flag('signup_promo_code_flag', 'error', 'Your promo code is too short; 4 characters min');
            return false;
          }
        else if (document.getElementById('signup_promo_code').value.length > 6)
          {
            this.errors.push('Your promo code is too long; 6 characters max');
            this.flag('signup_promo_code_flag', 'error', 'Your promo code is too long; 6 characters max');
            return false;
          }
        else
          {
            this.flag('signup_promo_code_flag', 'ok', 'OK');
            return true;
          }
      },

    subscribed : function()
      {
        if (document.getElementById('signup_subscribed').checked)
          {
            this.flag('signup_subscribed_flag', 'ok', 'OK');
            return true;
          }
        else
          {
            this.flag('signup_subscribed_flag', 'null', '');
            return true;
          }
      },

    //LOGIN EXISTS: BEGIN
    login_exists : function(login, action_true, action_false, action_error)
      {
        time = new Date();
        this.login_exists_timestamp = time.getTime();
        setTimeout('signup.login_exists_timing(\''+login.replace(/\'/g, '\\\'')+'\', \''+action_true.replace(/\'/g, '\\\'')+'\', \''+action_false.replace(/\'/g, '\\\'')+'\', \''+action_error.replace(/\'/g, '\\\'')+'\')', 1000);
      },

    login_exists_timing : function(login, action_true, action_false, action_error)
      {
        time = new Date();
        if (time.getTime() - this.login_exists_timestamp >= 950)
          {
            if (id = this.login_exists_request(login)) { setTimeout('signup.login_exists_response('+id+', \''+action_true.replace(/\'/g, '\\\'')+'\', \''+action_false.replace(/\'/g, '\\\'')+'\', \''+action_error.replace(/\'/g, '\\\'')+'\')', 100); }
          }
      },

    login_exists_timing_stop : function()
      {
        time = new Date();
        this.login_exists_timestamp = time.getTime();
      },

    login_exists_request : function(login)
      {
        vars = [];
        vars['name_exists'] = login;
        return ajax.request('/scripts/api/api.php', 'get', vars);
      },

    login_exists_response : function(id, action_true, action_false, action_error)
      {
        if (answer = ajax.response(id))
          {
                 if (answer['error'])            eval(action_error);
            else if (answer['response'] == true) eval(action_true);
            else                                 eval(action_false);
          }
        else
          {
            setTimeout('signup.login_exists_response('+id+', \''+action_true.replace(/\'/g, '\\\'')+'\', \''+action_false.replace(/\'/g, '\\\'')+'\', \''+action_error.replace(/\'/g, '\\\'')+'\')', 100);
          }
      },
    //LOGIN EXISTS: END

    //NICK EXISTS: BEGIN
    nick_exists : function(nick, action_true, action_false, action_error)
      {
        time = new Date();
        this.nick_exists_timestamp = time.getTime();
        setTimeout('signup.nick_exists_timing(\''+nick.replace(/\'/g, '\\\'')+'\', \''+action_true.replace(/\'/g, '\\\'')+'\', \''+action_false.replace(/\'/g, '\\\'')+'\', \''+action_error.replace(/\'/g, '\\\'')+'\')', 1000);
      },

    nick_exists_timing : function(nick, action_true, action_false, action_error)
      {
        time = new Date();
        if (time.getTime() - this.nick_exists_timestamp >= 950)
          {
            if (id = this.nick_exists_request(nick)) { setTimeout('signup.nick_exists_response('+id+', \''+action_true.replace(/\'/g, '\\\'')+'\', \''+action_false.replace(/\'/g, '\\\'')+'\', \''+action_error.replace(/\'/g, '\\\'')+'\')', 100); }
          }
      },

    nick_exists_timing_stop : function()
      {
        time = new Date();
        this.nick_exists_timestamp = time.getTime();
      },

    nick_exists_request : function(nick)
      {
        vars = [];
        vars['name_exists'] = nick;
        return ajax.request('/scripts/api/api.php', 'get', vars);
      },

    nick_exists_response : function(id, action_true, action_false, action_error)
      {
        if (answer = ajax.response(id))
          {
                 if (answer['error'])            eval(action_error);
            else if (answer['response'] == true) eval(action_true);
            else                                 eval(action_false);
          }
        else
          {
            setTimeout('signup.nick_exists_response('+id+', \''+action_true.replace(/\'/g, '\\\'')+'\', \''+action_false.replace(/\'/g, '\\\'')+'\', \''+action_error.replace(/\'/g, '\\\'')+'\')', 100);
          }
      },
    //NICK EXISTS: END

    //COUNTRY EXISTS: BEGIN
    country_exists : function(country, action_true, action_false, action_null, action_error)
      {
        time = new Date();
        this.country_exists_timestamp = time.getTime();
        setTimeout('signup.country_exists_timing(\''+country.replace(/\'/g, '\\\'')+'\', \''+action_true.replace(/\'/g, '\\\'')+'\', \''+action_false.replace(/\'/g, '\\\'')+'\', \''+action_null.replace(/\'/g, '\\\'')+'\', \''+action_error.replace(/\'/g, '\\\'')+'\')', 1000);
      },

    country_exists_timing : function(country, action_true, action_false, action_null, action_error)
      {
        time = new Date();
        if (time.getTime() - this.country_exists_timestamp >= 950)
          {
            if (id = this.country_exists_request(country)) { setTimeout('signup.country_exists_response('+id+', \''+action_true.replace(/\'/g, '\\\'')+'\', \''+action_false.replace(/\'/g, '\\\'')+'\', \''+action_null.replace(/\'/g, '\\\'')+'\', \''+action_error.replace(/\'/g, '\\\'')+'\')', 100); }
          }
      },

    country_exists_timing_stop : function()
      {
        time = new Date();
        this.country_exists_timestamp = time.getTime();
      },

    country_exists_request : function(country)
      {
        vars = [];
        vars['country_exists'] = country;
        return ajax.request('/scripts/api/api.php', 'get', vars);
      },

    country_exists_response : function(id, action_true, action_false, action_null, action_error)
      {
        if (answer = ajax.response(id))
          {
                 if (answer['error'])             eval(action_error);
            else if (answer['response'] == true)  eval(action_true);
            else if (answer['response'] == false) eval(action_false);
            else                                  eval(action_null);
          }
        else
          {
            setTimeout('signup.country_exists_response('+id+', \''+action_true.replace(/\'/g, '\\\'')+'\', \''+action_false.replace(/\'/g, '\\\'')+'\', \''+action_null.replace(/\'/g, '\\\'')+'\', \''+action_error.replace(/\'/g, '\\\'')+'\')', 100);
          }
      }
    //COUNTRY EXISTS: END
  }
