var common_lib = {
	//=====================================================//
	// Ajax
	//=====================================================//
	HOST: location.protocol + "//www.tohto-coop.or.jp/server/ajax_host.php",
//	HOST: location.protocol + "//192.168.0.76/server/ajax_host.php",
//	HOST: location.protocol + "//192.168.201.5/server/ajax_host.php",
	ajaxGetData : function(parameter, complete, failure, exeption, asynchronous) {
		parameter = parameter.escapeHTML();
		var option = {
			method: 'get',
			parameters: parameter,
			asynchronous: asynchronous,
			onComplete : complete,
			onFailure : failure,
			onException : exeption
		};
		new Ajax.Request(this.HOST, option);
	},
	ajaxPostData : function(data, complete, failure, exeption, asynchronous) {
		var option = {
			method: 'post',
			postBody : data,
			asynchronous: asynchronous,
			onComplete : complete,
			onFailure : failure,
			onException : exeption
		};
		return new Ajax.Request(this.HOST, option);
	},
	ajaxUpdate : function(method, data, element, complete, failure, exeption){
		var option = {
			method: method,
			onComplete : complete,
			onFailure : failure,
			onException : exeption
		};
		if(method.toUpperCase == "POST") {
			option.postBody = data;
		} else {
			option.parameters = data;
		}
		new Ajax.Updater({success:element}, this.HOST, option);
	},
	//=====================================================//
	// メソッド名： changeTxtEnabled
	// 引数：id - txtfieldのid
	//	   bool - Boolean
	// 戻り値：なし
	// 機能：テキストフィールドの使用／不使用の変更 
	//=====================================================//
	changeTxtEnabled : function(id,bool){
		$(id).disabled = !bool;	
		if($(id).disabled==true){
			$(id).style.backgroundColor = "#CCCCCC";
		}else{
			$(id).style.backgroundColor = "#FFFFFF";
			$(id).focus();
		}
	},
	//=====================================================//
	// メソッド名： getMyCookie
	// 引数：sKey - キー
	// 戻り値：値（該当無い場合-1）
	// 機能： クッキーから値を取得 
	//=====================================================//
	getMyCookie : function(sKey) {
	    var i, index, arr;
	    arr = document.cookie.split(";");
	    for(i = 0; i < arr.length; i++) {
	        index = arr[i].indexOf("=");
	        if(arr[i].substring(0, index) == sKey || arr[i].substring(0, index) == " " + sKey)
	            return arr[i].substring(index + 1);
	    }
	    return -1;
	},
	//=====================================================//
	// メソッド名： setMapArray
	// 引数：data - key=val,key=val,key=val...
	// 戻り値： 連想配列
	// 機能：
	//=====================================================//
	setMapArray : function(data){
		var aRet = new Array();
		var aRow = data.split(",");
		for(var i = 0;i < aRow.length;i++){
			aCol = aRow[i].split("=");
			aRet[aCol[0]]= aCol[1].replace("\n","");
		}
		return aRet;
	},
	//=====================================================//
	// メソッド名： trim
	// 引数：str - 文字列
	// 戻り値： 文字列
	// 機能：トリム
	//=====================================================//
	trim :function(str){
		return str.replace(/^[\s　]+|[\s　]+$/g, "");
	},
	//=====================================================//
	// メソッド名：setUnselectable
	// 引数：elem - Element
	// 戻り値： なし
	// 機能： 要素を選択不可に設定する
	//=====================================================//
	setUnselectable : function(elem){
		elem.unselectable = "on";
		elem.tabIndex = -1;
		Element.setStyle(elem, {
			"-moz-user-select": "none",
			"-khtml-user-select": "none",
			"user-select": "none"
		});
	},
	//=====================================================//
	// メソッド名：isValidDate
	// 引数：text 日付文字列 /区切り
	// 戻り値： boolean
	// 機能： カレンダーに存在する日付かチェックする
	//=====================================================//
	isValidDate : function(text) {
	    if (text.length == 0 || text== "") {
	        return false;
	    }
	    var arrDate = text.split("/");
	    if(arrDate.length == 3) {    
	        var date = new Date(Number(arrDate[0]) , Number(arrDate[1]) - 1 ,Number(arrDate[2]));
	        if(date.getFullYear() == arrDate[0] && 
	          (date.getMonth() == arrDate[1] - 1) && 
	           date.getDate() == arrDate[2]) {
	            return true;
	        }
	    }
	    return false;
	},
	//=====================================================//
	// メソッド名：chkZenHiragana
	// 引数：text ひらがな文字列
	// 戻り値： boolean
	// 機能： 全角ひらがな以外の文字列が使われていないかチェックする
	//=====================================================//
	chkZenHiragana : function(str) {
		if (str.match(/^[\u3040-\u309F]+$/)) {
		    return true;
		} else {
		    return false;
		}
	},
	//=====================================================//
	// BackScrollイベント処理
	//=====================================================//
	 doBackScroll : function() {
	    var pos = common_lib.getScrollPosition();
	    window.scrollTo(Math.max(Math.floor(pos.x / 2),0), Math.max(Math.floor(pos.y -(pos.y / 5)),0));
	    if (pos.x > 0 || pos.y > 0) {
	        window.setTimeout("common_lib.doBackScroll()", 5);
	        return false;
	    }
	},	
	//=====================================================//
	// スクロール量を取得し、オブジェクトとして返す
	//=====================================================//
	getScrollPosition : function() {
	    var obj = new Object();
	    obj.x = document.body.scrollLeft || document.documentElement.scrollLeft;
	    obj.y = document.body.scrollTop || document.documentElement.scrollTop;
	    return obj;
	}
}
