
function LTrim(str){
	while(str.charAt(0)==" " || str.charAt(0)=="?"){
		str = str.substring(1,str.length)
	}
	return(str); 
}

function RTrim(str){
	while(str.charAt(str.length-1)==" " || str.charAt(str.length-1)=="?"){
		str = str.substring(0,str.length-1)
	}
	return(str); 
}

function Trim(str){
	str = str.replace(/^[ ?]+/,"");
	str = str.replace(/[ ?]+$/,"");
	return(str);
}

////
// 指定された年月の最終日を取得します。
// @param year 年
// @param month 月
//
function getMonthLastDay(year, month) {

	var y;
	if(isNaN(year)) {
		y = parseInt(year);
	} else {
		y = year;
	}
	
	var m;
	if(isNaN(month)) {
		m = parseInt(month);
	} else {
		m = month;
	}

	var obj = new Date(y,m,1);
	var mtime = obj.getTime() - 86400000;
	obj.setTime(mtime);
	
	return obj.getDate();
}

////
// 指定されたセレクトボックスオブジェクトをクリアする。
// @param selectbox_obj セレクトボックスオブジェクト
//
function clearSelectBox(selectbox_obj) {
	if(selectbox_obj) {
		while(selectbox_obj.options.length>1) {
			selectbox_obj.options[0] = null;
		}
	}
}

////
// 指定された日付セレクトボックスオブジェクトを指定された年月用に設定します。
// @param year 年
// @param month 月
// @param day_selectbox_obj 日付セレクトボックスオブジェクト
//
function setDaysSelectBox(year, month, day_selectbox_obj) {
	if(day_selectbox_obj) {
		var lastDay = getMonthLastDay(year, month);
		
		clearSelectBox(day_selectbox_obj);
		
		for(i=0; i<lastDay; i++) {
			var day = i+1
			if(day<10) {
				day_selectbox_obj.options[i] = new Option("0"+day,"0"+day);
			} else {
				day_selectbox_obj.options[i] = new Option(""+day,""+day);
			}
		}
	}
}
function getSelectedValue(selObj) {
	if (selObj == null || selObj.selectedIndex < 0) return null;
	return selObj.options[selObj.selectedIndex].value;
}
String.prototype.trim = function() {
	return this.replace(/^\s*/, "").replace(/\s*$/, "");
}

