/**
 * Success stories (VIEW)
 *
 * The script for check of user input.
 *
 * @package    CuteOnly Dating Service
 * @version    1.0 alpha
 * @since      07.02.2008
 * @copyright  2004-2009 Cute International Inc. 
 *             2004-2009 5Dev
 * @link       http://5dev.com
 */
function SuccessStories(err) 
{ 
    this.__construct(err);
}
SuccessStories.prototype = 
{
    mForm:    null,
    mErr:     null,
    mErrFlag: false,
    mAjax1:   true,
    mAjax2:   true,

    __construct: function(err)
    {
        this.mErr              = err;
    },

    newAlert: function(err)
    {
        var img = new Image(15,15);
        img.src = '/i/error.gif';
        var str = '<img src="/i/error.gif" width="15" height="15" border="0" style="cursor:hand; cursor:pointer;" alt="'+err+'" title="'+err+'" />&nbsp;'+err; 
        return str;
    },

    CheckS: function(obj)
    {
        this.mForm         = obj;
        obj.butOk.disabled = true;
        var arr            = obj.elements;
        this.mErrFlag      = false;

        if (3 > arr['SI[man_name]'].value.length)
        {
            if (!this.mErrFlag) 
            {
            	_v('SI_err_div[man_name]').className = 'active_error'; /* man name focus specify */
                arr['SI[man_name]'].focus();
            }

            if (0 == arr['SI[man_name]'].value.length) 
            {
                _v('SI_err_div[man_name]').className = 'active_error'; /* man name specify */
                _v('SI_err[man_name]').innerHTML     = this.newAlert(this.mErr[20]);
            }
            else
            {
                _v('SI_err_div[man_name]').className = 'active_error'; /* man name specify */
                _v('SI_err[man_name]').innerHTML     = this.newAlert(this.mErr[22]);
            }

            this.mErrFlag = true;
        }
        else 
        {
            _v('SI_err_div[man_name]').className = '123'; /* man name ok */
            _v('SI_err[man_name]').innerHTML = '&nbsp;';
        }

        if (3 > arr['SI[girl_name]'].value.length)
        {
            if (!this.mErrFlag) 
            {
            	_v('SI_err_div[girl_name]').className = 'active_error'; /* girl name focus specify */
                arr['SI[girl_name]'].focus();
            }

            if (0 == arr['SI[girl_name]'].value.length) 
            {
                _v('SI_err_div[girl_name]').className = 'active_error'; /* girl name specify */
                _v('SI_err[girl_name]').innerHTML     = this.newAlert(this.mErr[25]);
            }
            else
            {
                _v('SI_err_div[girl_name]').className = 'active_error'; /* girl name specify */
                _v('SI_err[girl_name]').innerHTML     = this.newAlert(this.mErr[27]);
            }

            this.mErrFlag = true;
        }
        else 
        {
            _v('SI_err_div[girl_name]').className = '123'; /* girl name ok */
            _v('SI_err[girl_name]').innerHTML = '&nbsp;';
        }

        var email_chk = false;
        if (0 < arr['SI[email]'].value.length
            && !check_email(arr['SI[email]'].value))
        {
            if (!this.mErrFlag)
                arr['SI[email]'].focus();
            _v('SI_err_div[email]').className = 'active_error'; /* email specify correct */
            _v('SI_err[email]').innerHTML     = this.newAlert(this.mErr[30]);
            this.mErrFlag = true;
        }
        else
        {
            _v('SI_err_div[email]').className = '123'; /* email ok */
            _v('SI_err[email]').innerHTML = '';
        }

        if (3 > arr['SI[descr]'].value.length)
        {
            if (!this.mErrFlag) 
            {
            	_v('SI_err_div[descr]').className = 'active_error'; /* descr focus specify */
                arr['SI[descr]'].focus();
            }

            _v('SI_err_div[descr]').className = 'active_error'; /* descr specify */
            _v('SI_err[descr]').innerHTML     = this.newAlert(this.mErr[35]);

            this.mErrFlag = true;
        }
        else 
        {
            _v('SI_err_div[descr]').className = '123'; /* descr ok */
            _v('SI_err[descr]').innerHTML = '';
        }

        var imgExpr = /\.(jpeg|jpg|png|gif)$/i;

        for (var i = 1; i <= 3; i++)
        {
            if (0 < obj.elements['SI[file' + i + ']'].value.length
                && !imgExpr.test(obj.elements['SI[file' + i + ']'].value))
            {
                if (!this.mErrFlag) 
                {
                	_v('SI_err_div[file'+ i +']').className = 'active_error'; /* descr focus specify */
                    arr['SI[file1]'].focus();
                }
           
                _v('SI_err_div[file'+ i +']').className = 'active_error'; /* descr specify */
                _v('SI_err[file'+ i +']').innerHTML     = this.newAlert(this.mErr[40]);
           
                this.mErrFlag = true;
            }
            else 
            {
                _v('SI_err_div[file'+ i +']').className = '123'; /* descr ok */
                _v('SI_err[file'+ i +']').innerHTML = '&nbsp;';
            }
        }

        if (!this.mErrFlag)
           obj.submit();
        else
           obj.butOk.disabled = false;

        return;
    }
}

