//--------------------------------------
//  0埋め処理
//--------------------------------------
function Str_FillZero(_Str,_Count){
    var _Size = 0;
    _Size = Array((_Count + 1) - _Str.toString().split('').length);
    
    return _Size.join('0') + _Str;
}

//--------------------------------------
//  カンマ区切り処理
//--------------------------------------
function Str_Figure(_Str) {
    var _Num = new String(_Str).replace(/,/g, "");
    while(_Num != (_Num = _Num.replace(/^(-?\d+)(\d{3})/, "$1,$2")));
    
    return _Num;
}


//--------------------------------------
//  日付型からYYYYMMDDの取得
//--------------------------------------
function Str_DateToString(_Date){
    var _Str = '';
    
    //ブラウザ互換の考慮
    var _I_YY = _Date.getYear();
    if (_I_YY < 2000){
        _I_YY += 1900;
    }
    var _I_MM = _Date.getMonth() + 1;
    var _I_DD = _Date.getDate();
    
    var _S_YY = new String(_I_YY);
    var _S_MM = new String(_I_MM);
    var _S_DD = new String(_I_DD);
    
    _S_MM = Str_FillZero(_S_MM, 2);
    _S_DD = Str_FillZero(_S_DD, 2);
    
    _Str += _S_YY;
    _Str += _S_MM;
    _Str += _S_DD;
    
    return _Str;
}

//--------------------------------------
//  日付型からHHMISSの取得
//--------------------------------------
function Str_TimeToString(_Date){
    var _Str = '';
    
    //ブラウザ互換の考慮
    var _I_HH = _Date.getHours();
    var _I_MI = _Date.getMinutes();
    var _I_SS = _Date.getSeconds();
    
    var _S_HH = new String(_I_HH);
    var _S_MI = new String(_I_MI);
    var _S_SS = new String(_I_SS);
    
    _S_HH = Str_FillZero(_S_HH, 2);
    _S_MI = Str_FillZero(_S_MI, 2);
    _S_SS = Str_FillZero(_S_SS, 2);
    
    _Str += _S_HH;
    _Str += _S_MI;
    _Str += _S_SS;
    
    return _Str;
}

//--------------------------------------
//  YYYYMMDDHHmmSSから日付文字列の生成
//--------------------------------------
function Str_TimeCodeToString(_Date, _Ptn){
    var _Str = '';
    
    //受け取った文字列を日付型に変換
    
    var _YY = _Date.substring(0,4);
    var _MM = _Date.substring(4,6);
    var _DD = _Date.substring(6,8);
    var _HH = _Date.substring(8,10);
    var _mm = _Date.substring(10,12);
    var _SS = _Date.substring(12,14);
    
    if(_Ptn == 1){
        //YYYY年MM月DD日 HH時mm分SS秒
        _Str += _YY;
        _Str += "年";
        _Str += _MM;
        _Str += "月";
        _Str += _DD;
        _Str += "日 ";
        _Str += _HH;
        _Str += "時";
        _Str += _mm;
        _Str += "分";
        _Str += _SS;
        _Str += "秒";
    }else if(_Ptn == 2){
        //YYYY/MM/DD HH:mm:SS
        _Str += _YY;
        _Str += ".";
        _Str += _MM;
        _Str += ".";
        _Str += _DD;
        _Str += " ";
        _Str += _HH;
        _Str += ":";
        _Str += _mm;
        _Str += ":";
        _Str += _SS;
        //_Str += "";
    }else{
        _Str += _Date;
    }
    
    return _Str;
}

//--------------------------------------
//  データからテーブルを生成する
//--------------------------------------
function Str_MakeTable(_Data,_Size,_Ptn){
    var _HtmStr = '';
    
    var _i = 0;
    var _ilen = _Size.length;
    
    //---------------------------
    // パターン1
    //---------------------------
    if(_Ptn == 1){
        
        var _bufLine = '';
        
        //一覧の生成
        _HtmStr += '<Table border=\'0px\' cellpadding=\'1px\' cellspacing=\'0px\' style=\'width:100%;\'>';
            
            //ラインの生成
            _bufLine = C_tag_tdst('3px','13px','ln_po_b_top_s.png');
                //ライン部
                _bufLine += C_tag_LineDiv('3px','13px');
            _bufLine += C_tag_tded;
            
            _HtmStr += C_tag_trst;
                _HtmStr += C_tag_tdst('4px','13px','ln_po_b_top_l.png');
                    //ライン部
                    _HtmStr += C_tag_LineDiv('4px','13px');
                _HtmStr += C_tag_tded;
                
                //_i = 0;
                for(;_i < _ilen; _i++){
                    
                    if(_i > 0){
                        _HtmStr += _bufLine;
                    }
                    
                    _HtmStr += C_tag_tdst(_Size[_i],'13px','ln_po_b_top.png');
                        //データ部
                        _HtmStr += C_tag_LineDiv('100%','13px');
                    _HtmStr += C_tag_tded;
                }
                
                _HtmStr += C_tag_tdst('4px','13px','ln_po_b_top_r.png');
                    //ライン部
                    _HtmStr += C_tag_LineDiv('4px','13px');
                _HtmStr += C_tag_tded;
            _HtmStr += C_tag_tred;
            
            //ヘッダ
            _bufLine = C_tag_tdst('3px','4px','ln_po_b_y.png');
                //ライン部
                _bufLine += C_tag_LineDiv('3px','4px');
            _bufLine += C_tag_tded;
            
            _HtmStr += C_tag_trst;
                _HtmStr += C_tag_tdst('4px','4px','ln_po_b_y_l.png');
                    //ライン部
                    _HtmStr += C_tag_LineDiv('4px','4px');
                _HtmStr += C_tag_tded;
                
                _i = 0;
                for(;_i < _ilen; _i++){
                    
                    if(_i > 0){
                        _HtmStr += _bufLine;
                    }
                    
                    _HtmStr += C_tag_tdst(_Size[_i],'auto','in_po_b.png');
                        //データ部
                        _HtmStr += _Data[0][_i];
                    _HtmStr += C_tag_tded;
                }
                
                _HtmStr += C_tag_tdst('4px','4px','ln_po_b_y_r.png');
                    //ライン部
                    _HtmStr += C_tag_LineDiv('4px','4px');
                _HtmStr += C_tag_tded;
            _HtmStr += C_tag_tred;
            
            
            //ラインの生成
            _bufLine = C_tag_tdst('3px','4px','ln_po_b_x_s.png');
                //ライン部
                _bufLine += C_tag_LineDiv('3px','4px');
            _bufLine += C_tag_tded;
            
            _HtmStr += C_tag_trst;
                _HtmStr += C_tag_tdst('4px','4px','ln_po_b_y_s_l.png');
                    //ライン部
                    _HtmStr += C_tag_LineDiv('4px','4px');
                _HtmStr += C_tag_tded;
                
                _i = 0;
                for(;_i < _ilen; _i++){
                    
                    if(_i > 0){
                        _HtmStr += _bufLine;
                    }
                    
                    _HtmStr += C_tag_tdst(_Size[_i],'4px','ln_po_b_x.png');
                        //データ部
                        _HtmStr += C_tag_LineDiv('100%','4px');
                    _HtmStr += C_tag_tded;
                }
                
                _HtmStr += C_tag_tdst('4px','4px','ln_po_b_y_s_r.png');
                    //ライン部
                    _HtmStr += C_tag_LineDiv('4px','4px');
                _HtmStr += C_tag_tded;
            _HtmStr += C_tag_tred;
            
            
            //データ用ラインの元(横)
            _bufLine = C_tag_tdst('3px','1px','ln_po_b_x_ms.png');
                //ライン部
                _bufLine += C_tag_LineDiv('3px','1px');
            _bufLine += C_tag_tded;
            
            var _bufXLine = '';
            _bufXLine += C_tag_trst;
                _bufXLine += C_tag_tdst('4px','1px','ln_po_b_y_ms_l.png');
                    //ライン部
                    _bufXLine += C_tag_LineDiv('4px','1px');
                _bufXLine += C_tag_tded;
                
                _i = 0;
                for(;_i < _ilen; _i++){
                    
                    if(_i > 0){
                        _bufXLine += _bufLine;
                    }
                    
                    _bufXLine += C_tag_tdst(_Size[_i],'1px','ln_po_b_m.png');
                        //データ部
                        _bufXLine += C_tag_LineDiv('100%','1px');
                    _bufXLine += C_tag_tded;
                }
                
                _bufXLine += C_tag_tdst('4px','1px','ln_po_b_y_ms_r.png');
                    //ライン部
                    _bufXLine += C_tag_LineDiv('4px','1px');
                _bufXLine += C_tag_tded;
            _bufXLine += C_tag_tred;
            
            //データ用ラインの元(縦)
            var _bufYLine = '';
            
            _bufYLine += C_tag_tdst('4px','4px','ln_po_b_y.png');
                //ライン部
                _bufYLine += C_tag_LineDiv('4px','4px');
            _bufYLine += C_tag_tded;
            
            //データ
            for(var _j = 1,_jlen = _Data.length;_j < _jlen; _j++){
                if(_j > 1){
                    _HtmStr += _bufXLine;
                }
                
                _HtmStr += C_tag_trst;
                    _HtmStr += C_tag_tdst('4px','4px','ln_po_b_y_l.png');
                    
                    _i = 0;
                    for(;_i < _ilen; _i++){
                        if(_i > 0){
                            _HtmStr += _bufYLine;
                        }
                        
                        _HtmStr += C_tag_tdst(_Size[_i],'auto','in_po_b_m.png');
                            //データ部
                            _HtmStr += _Data[_j][_i];
                        _HtmStr += C_tag_tded;
                    }
                    
                    _HtmStr += C_tag_tdst('4px','4px','ln_po_b_y_r.png');
                _HtmStr += C_tag_tred;
            }
            
            
            //ラインの生成
            _bufLine = C_tag_tdst('3px','4px','ln_po_b_bot_s.png');
                //ライン部
                _bufLine += C_tag_LineDiv('3px','4px');
            _bufLine += C_tag_tded;
            
            _HtmStr += C_tag_trst;
                _HtmStr += C_tag_tdst('4px','4px','ln_po_b_bot_l.png');
                    //ライン部
                    _HtmStr += C_tag_LineDiv('4px','4px');
                _HtmStr += C_tag_tded;
                
                _i = 0;
                for(;_i < _ilen; _i++){
                    if(_i > 0){
                        _HtmStr += _bufLine;
                    }
                    
                    _HtmStr += C_tag_tdst(_Size[_i],'4px','ln_po_b_bot.png');
                        //データ部
                        _HtmStr += C_tag_LineDiv('100%','4px');
                    _HtmStr += C_tag_tded;
                }
                
                _HtmStr += C_tag_tdst('4px','4px','ln_po_b_bot_r.png');
                    //ライン部
                    _HtmStr += C_tag_LineDiv('4px','4px');
                _HtmStr += C_tag_tded;
            _HtmStr += C_tag_tred;
        
        _HtmStr += '</Table>';
        
    }
    
    return _HtmStr;
}

//--------------------------------------
//  ランダムな文字列を生成する
//--------------------------------------
function Str_MakeRandobet(n, b) {
    b = b || '';
    var a = 'abcdefghijklmnopqrstuvwxyz'
        + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
        + '0123456789'
        + b;
    a = a.split('');
    var s = '';
    for (var i = 0; i < n; i++) {
        s += a[Math.floor(Math.random() * a.length)];
    }
    return s;
}

