/**
 * Method Output
 *
 * Page,v 1.0 2010/03/03 11:08:00 ivi.vova Exp
 *
 * Copyright (C) 2010 ivi.vova, E-mail: ivi.vova@gmail.com
 */

function method_output(time)
{

    /**
     * local values
     */
    //time
    this.time=time;
    //method output
    this.method_output_count_webmoney=12;
    this.method_output_count_yandex=22;
    /**
     * local values
     */

    /**
     * if number form
     */
    this.check_isNumber = function(str)
    {
        return str.match(/^([0-9]+)$/);
    }

    /**
     * show error
     * @param inc
     */
    this.showError = function(id)
    {
        var obj=document.getElementById(id);
        obj.style.backgroundColor='red';
    }

    /**
     * show sucess
     * @param inc
     */
    this.showSucess = function(id)
    {
        var obj=document.getElementById(id);
        obj.style.backgroundColor='white';
    }

    /**
     * set method of withdrawal
     * @param param - set parameter function
     * @return null
     */
    this.setMethodOfWithdrawal = function(param,id)
    {
        if(param=='wmz')
        {
            var obj=document.getElementById(id);
            obj.disabled=false;
            obj.value='Z';
        }
        if(param=='wmu')
        {
            var obj=document.getElementById(id);
            obj.disabled=false;
            obj.value='U';
        }
        if(param=='wmr')
        {
            var obj=document.getElementById(id);
            obj.disabled=false;
            obj.value='R';
        }
        if(param=='wme')
        {
            var obj=document.getElementById(id);
            obj.disabled=false;
            obj.value='E';
        }
        if(param=='yandex')
        {
            var obj=document.getElementById(id);
            obj.disabled=false;
            obj.value='';
        }
    }

    /**
     * set values of withdrawal
     * @param param - set parameter function
     * @return null
     */
    this.setValuesOfWithdrawal = function(id)
    {
        var obj=document.getElementById('to');
        var obj0=document.getElementById('valuesofwithdraw_text');
        var thisint=obj.value;
        var param=obj0.value;
        var tmp_buf;
        if(thisint=='wmz')
        {
            if(param.charAt(0)=='Z'&&param.length>0)
            {
                var tmpmas='';
                var inc=0;
                for(var i=1;i<param.length;i++)
                {
                    if(inc>=this.method_output_count_webmoney)
                    {
                        break;
                    }
                    inc++;
                    tmpmas+=param.charAt(i);
                }
                tmp_buf=this.check_isNumber(tmpmas);
                if(tmp_buf!=null)
                {
                    obj0.value='Z'+tmpmas;
                    this.showSucess('valuesofwithdraw_text');
                }
                else
                {
                    obj0.value='Z';
                    this.showError('valuesofwithdraw_text');
                }
            }
            else
            {
                obj0.value='Z';
                this.showError('valuesofwithdraw_text');
            }
        }
        else if(thisint=='wmu')
        {
            if(param.charAt(0)=='U'&&param.length>0)
            {
                var tmpmas='';
                var inc=0;
                for(var i=1;i<param.length;i++)
                {
                    if(inc>=this.method_output_count_webmoney)
                    {
                        break;
                    }
                    inc++;
                    tmpmas+=param.charAt(i);
                }
                tmp_buf=this.check_isNumber(tmpmas);
                if(tmp_buf!=null)
                {
                    obj0.value='U'+tmpmas;
                    this.showSucess('valuesofwithdraw_text');
                }
                else
                {
                    obj0.value='U';
                    this.showError('valuesofwithdraw_text');
                }
            }
            else
            {
                obj0.value='U';
                this.showError('valuesofwithdraw_text');
            }
        }
        else if(thisint=='wmr')
        {
            if(param.charAt(0)=='R'&&param.length>0)
            {
                var tmpmas='';
                var inc=0;
                for(var i=1;i<param.length;i++)
                {
                    if(inc>=this.method_output_count_webmoney)
                    {
                        break;
                    }
                    inc++;
                    tmpmas+=param.charAt(i);
                }
                tmp_buf=this.check_isNumber(tmpmas);
                if(tmp_buf!=null)
                {
                    obj0.value='R'+tmpmas;
                    this.showSucess('valuesofwithdraw_text');
                }
                else
                {
                    obj0.value='R';
                    this.showError('valuesofwithdraw_text');
                }
            }
            else
            {
                obj0.value='R';
                this.showError('valuesofwithdraw_text');
            }
        }
        else if(thisint=='wme')
        {
            if(param.charAt(0)=='E'&&param.length>0)
            {
                var tmpmas='';
                var inc=0;
                for(var i=1;i<param.length;i++)
                {
                    if(inc>=this.method_output_count_webmoney)
                    {
                        break;
                    }
                    inc++;
                    tmpmas+=param.charAt(i);
                }
                tmp_buf=this.check_isNumber(tmpmas);
                if(tmp_buf!=null)
                {
                    obj0.value='E'+tmpmas;
                    this.showSucess('valuesofwithdraw_text');
                }
                else
                {
                    obj0.value='E';
                    this.showError('valuesofwithdraw_text');
                }
            }
            else
            {
                obj0.value='E';
                this.showError('valuesofwithdraw_text');
            }
        }
        else if(thisint=='yandex')
        {
            tmp_buf=this.check_isNumber(param);
            if(tmp_buf!=null)
            {
                var tmpmas='';
                var inc=0;
                for(var i=0;i<param.length;i++)
                {

                    if(inc>=this.method_output_count_yandex)
                    {
                        break;
                    }
                    inc++;
                    tmpmas+=param.charAt(i);
                }
                obj0.value=tmpmas;
                this.showSucess('valuesofwithdraw_text');
            }
            else
            {
                obj0.value='';
                this.showError('valuesofwithdraw_text');
            }
        }
        else
        {
            obj0.value='';
            this.showError('valuesofwithdraw_text');
        }
    }
    
}

var methodoutput = new method_output(1000);

