/**
 * ====================================================
 * JavaScript (message)
 *
 * @author    : maomao
 * @date      : 2007/06/20
 * @copyright : (c) maomao-studio. All Rights Reserved.
 *     
 * ====================================================
 */

var MSG = 
{
	 W001	: "%sが入力されていません(必須項目)"
	,W002	: "%sのフォーマットが不正です。"
};

// ----------------------------------------------------- alertボックス
var AlertBox = function(){
	AlertBox_OBJ = null;
	this.count = 0;
	this.msg = "下記のエラーがあります：";
}
AlertBox.prototype.push = function(){
	var args = arguments;
	var format = function(){
		var i, msg = "", argNum = 0, startPos;
		var numArgs = args.length;
		if (numArgs) {
			var objName = args[argNum++];
			if (AlertBox_OBJ == null){
				AlertBox_OBJ= objName;
			}
			theStr = args[argNum++];
			startPos = 0;  endPos = theStr.indexOf("%s",startPos);
			if(endPos == -1) endPos = theStr.length;
			while (startPos < theStr.length) {
				msg += theStr.substring(startPos,endPos);
				if (argNum < numArgs) msg += args[argNum++];
				startPos = endPos+2;  endPos = theStr.indexOf("%s",startPos);
				if (endPos == -1) endPos = theStr.length;
			}
			if (!msg) msg = args[0];
		}
		return msg;
	};
	// 新規に要素（タグ）を生成
	this.msg += "\n   [" + (++this.count) + "] - " + format();
	return this;
}
AlertBox.prototype.show = function(){
	alert(this.msg);
	document.getElementById(AlertBox_OBJ).focus();
}
AlertBox.prototype.ifHas = function(){
	return (this.count > 0);
}
