//Trimメソッドの追加
String.prototype.trim = function() {

    return this.replace(/^[ 　]+|[ 　]+$/g, '');
}






//画像のボーダーカラーを変更する
function changeBorderColor(target, color){
	
	
	if(document.all || document.getElementById){
		target.style.borderColor = color;
	}
}



//タグ名とIDから要素を返す ※IEのgetElementByIdのバグ対策
function getElementByTagAndId(sTag, sId){
	
	
	//指定タグの全要素を取得
	var aElements = document.getElementsByTagName(sTag);
	
	//指定のIDを持つ要素を返す
	for(var i=0; i<aElements.length; i++){
		if(aElements[i].id == sId){
			return aElements[i];
    	}
	}
	return false;
}



//フォーム内容をPOSTする
function postForm(argForm, argItem, argValue){
	
	
	//指定の要素を指定の値に設定
	var o = getElementByTagAndId("input", argItem);
	o.value = argValue;
	
	//指定のフォームをPOST
	getElementByTagAndId("form", argForm).submit();
}



//postFormラッパー ※テンプレートからのPOST
function postFormOfTemplate(argItem, argValue){
	
	
	//テンプレートで指定した並び順をクリア
	var e1 = getElementByTagAndId("input", "hid_order_template");
	e1.value = "";
	
	//テンプレートから指定した条件をクリア
	var e2 = getElementByTagAndId("input", "hid_outside_template");
	e2.value = "";
	
	//frm_templateをPOST
	postForm("frm_template", argItem, argValue);
}



//postFormラッパー ※下部テンプレートからのPOST ※後から追加
function postFormOfLower(argItem, argValue){
	
	
	//テンプレートで指定した並び順をクリア
	var e1 = getElementByTagAndId("input", "hid_order_lower");
	e1.value = "";
	
	//テンプレートから指定した条件をクリア
	var e2 = getElementByTagAndId("input", "hid_outside_lower");
	e2.value = "";
	
	//frm_templateをPOST
	postForm("frm_lower", argItem, argValue);
}



//postFormラッパー ※検索結果画面からのPOST
function postFormOfSearch(argItem, argValue){
	
	
	//現在ページを先頭に設定
	var e1 = getElementByTagAndId("input", "hid_page");
	e1.value = 1;
	
	//外部からの検索条件をクリア
	var e2 = getElementByTagAndId("input", "hid_outside");
	e2.value = "";
	
	//外部からの並び順をクリア
	var e3 = getElementByTagAndId("input", "hid_order");
	e3.value = "";
	
	//frm_searchをPOST
	postForm("frm_search", argItem, argValue);
}



//postFormラッパー ※検索結果画面からのPOST
function postFormOfSort(argItem, argValue){
	
	
	//現在ページを先頭に設定
	var e1 = getElementByTagAndId("input", "hid_page");
	e1.value = 1;
	
	//外部からの並び順をクリア
	var e2 = getElementByTagAndId("input", "hid_order");
	e2.value = "";
	
	//frm_searchをPOST
	postForm("frm_search", argItem, argValue);
}

















