function rep_action (action,form_name){
    document.myform.action = action;
	document.myform.submit();
}
function my_ajax (url,area,param){
    var php = url;
    var pars = param
    var area_id = area;
    document.getElementById(area_id).innerHTML = 'Now Loading.........';
    
    var myAjax = new Ajax.Request(
    php,
    {
    method: 'post',
    parameters: pars,
    onComplete: function(req) {
        alert('読み込み成功しました');
    },
    onComplete: function(req) {
        document.getElementById(area_id).innerHTML = req.responseText;
    },
    onFailure: function(req) {
        alert('読み込みに失敗しました');
    },
    onException: function(req) {
        document.getElementById(area_id).innerHTML = '読み込み中にエラーが発生しました';
    }
    }
    );
}
function my_ajax_post (url,area,form){
    var php = url;
    var form_name = form
    var area_id = area;
    pars = Form.serialize(form_name);

    document.getElementById(area_id).innerHTML = 'Now Loading.........';
    
    var myAjax = new Ajax.Request(
    php,
    {
    method: 'post',
    parameters: pars,
    onComplete: function(req) {
        alert('読み込み成功しました');
    },
    onComplete: function(req) {
        document.getElementById(area_id).innerHTML = req.responseText;
    },
    onFailure: function(req) {
        alert('読み込みに失敗しました');
    },
    onException: function(req) {
        document.getElementById(area_id).innerHTML = '読み込み中にエラーが発生しました';
    }
    }
    );
}
function openPanel(url,name,w,h) {

    var p = window.open(url, name, 'resizable=yes,scrollbars=yes,width=' + w + ',height=' + h);
    p.focus();
    return p;
}
function remove_image(image){
    document.getElementById(image).value = '';
    var image_div = image + "_div";
    document.getElementById(image_div).innerHTML = '';
}
function dig_check(messagge){
	if (messagge == null){
		message = "NO MESSAGE";
	}
    return confirm(messagge);
}
function printf(fmt/*,...*/) {
    this.m_ac = arguments.length;
    this.m_av = arguments;
    this.m_fm = fmt;
    this.m_mx = fmt.length;
    this.m_ct = 0;
    this.m_ix = 1;

    this.init = function() {
        if (this.m_ac < 1)
            return "";

        if (this.m_ac == 1) {
            if (fmt.charAt(0) == "@") { //document.write()
                document.write(fmt.substr(1));
                return "";
            }
            else {
                return fmt;
            }
        }
        
        this.m_ac = 1;  //0 は fmt 
        return this.parse();
    };

    this.parse = function () {
        var rts = "";
        var doc = false;

        if (this.m_fm.charAt(0) == "@") {
            doc = true;
            this.m_ct++;
        }

        while ( this.m_ct < this.m_mx ) {
            var ch = this.m_fm.charAt(this.m_ct);
            var str = "";
            switch ( ch ) {
            case    '%':
                str = this._ident();
                if (str != "")
                    this.m_ix++;
                break;
            case    '\\':
                str = this._escape();
                break;
            default:
                str = ch;
                this.m_ct++;
                break;
            }
            rts += str;
        }
        if (doc) {
            document.write(rts);
            return "";
        }
        else {
            return rts;
        }
    };

    //エスケープ処理
    this._escape = function () {

    };

    //% 処理
    this._ident = function () {
        var sgn = false;
        var jst = false;    //右寄せ
        var len = -1;       //繰り返し回数
        var flg = true;
        var spl = ' ';      //標準は空白
        var fld = -1;       //フィールド幅指定無し

        var ch = this.m_fm.charAt(this.m_ct+1);

        if (ch == '%') {
            this.m_ct += 2;
            return '%';
        }
        this.m_ct++;
        while ( flg ) {
            ch = this.m_fm.charAt(this.m_ct);
            switch ( ch ) {
            case    '+':    //符号付き
                sgn = true;
                this.m_ct++;
                break;
            case    '-':    //左寄せ
                jst = true;
                this.m_ct++;
                break;
            case    '*':    //長さ（直後の指定子の繰り返し：Ｃ言語とは意味が違います）
                len = parseInt(this.m_av[this.m_ac]);
                this.m_ac++;
                this.m_ct++;
                break;
            case    '?':    //フィールド補間文字指定
                spl = this.m_av[this.m_ac].substr(0,1);
                this.m_ac++;
                this.m_ct++;
                break;
            case    '.':    //精度指定
                prc = true;
                this.m_ct++;
                break;
            default:
                if (ch >= '0' && ch <= '9') {
                    if (ch == '0')
                        spl = "0";
                    var n = 0;
                    var c = 0;
                    c = this.m_fm.charCodeAt(this.m_ct);
                    while ( c >= 0x30 && c <= 0x39) {
                        n = n * 10 + (c - 0x30);
                        this.m_ct++;
                        c = this.m_fm.charCodeAt(this.m_ct);
                    }
                    if (n <= 0 || n >= 65536)
                        fld = -1;
                    else
                        fld = n;
                }
                else {
                    flg = false;
                }
                break;
            }
        }
        
        var val = this.m_av[this.m_ac];
        this.m_ac++;

        var scd = '';   //sgn 時に先頭に加算される
        switch ( ch ) {
        case    'd':    //１０進数表記
            val = "" + val;
            this.m_ct++;
            scd = val.charAt(0);
            if (sgn) {
                if (spl == '0') {
                    if (scd=='-' || scd=='+') {
                        val = val.substr(1);
                    }
                    else {
                        scd = '+';
                    }
                }
                else {
                    scd = "";
                }
            }
            else {
                if (spl == '0') {
                    if (scd != '-') {
                        scd = "";
                    }
                }
            }
            
            break;
        case    'x':    //１６進数表記（小文字）
        case    'X':    //１６進数表記（大文字）
            if (ch == 'x')
                val = this.toHex(val,'a'.charCodeAt(0),0,fld);
            else
                val = this.toHex(val,'A'.charCodeAt(0),1,fld);
            this.m_ct++;
            break;
        case    'c':    //文字
        case    's':    //文字列
            this.m_ct++;
            break;
        default:
            return "";
        }

        var l = val.length;
        if (len < 0) {
            if (jst==false)
                while (l < fld) {
                    val = spl + val;
                    l++;
                }
            else
                while (l < fld) {
                    val = val + spl;
                    l++;
                }
        }
        else {
            var v = "";
            while (len > 0) {
                v += val;
                len--;
            }
            val = v;
        }
        return scd + val;
    };

    //１６進数変換
    this.toHex = function(v,a,c,f) {
        var r;
        var s = "";
        var ar;
        var ar1 = ["0","1","2","3","4","5","6","7",
                    "8","9","A","B","C","D","E","F"];
        var ar2 = ["0","1","2","3","4","5","6","7",
                    "8","9","a","b","c","d","e","f"];
        var ar3 = new Array();
        var vf;
        var idx = 0;
        if (v < 0) {
            v = -v;
            vf = 1;
        }
        else {
            vf = 0;
        }

        if (c)
            ar = ar1;
        else
            ar = ar2;

        if (vf)
            ar = ar.reverse();

//      alert("ar="+ar);
        
        if (v == 0) {
            ar3[0] = 0;
        }
        else {
            do {
                r = parseInt(v % 16);
                v = parseInt(v / 16);

                ar3[idx] = r;
                idx++;
            } while (v != 0);
        }

        var i;
        if (vf) {
            v = -1;
            for (i=0;i < ar3.length;i++) {
                ar3[i] += v;
                if (ar3[i] < 0) {
                    ar3[i] = 15;
                }
                else {
                    v = 0;
                }
            }
        }
        for (i=0;i < ar3.length;i++) {
            s = ar[ar3[i]] + s;
        }
        var l = s.length;
        if (vf) {
            if (c)
                var F = "F";
            else
                var F = "f";
            while (l < f) {
                s = F + s;
                l++;
            }
        }
        else {
            while (l < f) {
                s = "0" + s;
                l++;
            }
        }

        return s;
    };

    return this.init();
}