﻿/**
 * XMIX
 *
 * @package   
 * @version   $Id: $
 * @copyright  
 * @author  Takuji Sho<sho@xmix.jp>
 */
xmix = new Object();
xmix.common = new Object();
xmix.common.form = function(){
	this.submit = function(name,button_id,button_value,diabler){
		if(button_id != ''){
			$("#" + button_id).attr("value",button_value);
		}
		if(diabler == undefined){
			this.disabler("#" + name);
		}
		$("#" + name).submit();
	}
	this.disabler = function(name){
		jQuery(name).bind("submit", function () {
			 var buttons = jQuery( this ).find(":image, :submit, :select");
			 setTimeout(function () {
				 buttons.attr("disabled", true);
				 setTimeout(function () {
					 buttons.attr("disabled", false);
				 }, 120000);//2分
			 }, 1);
		}).find(":image, :submit, :select").attr("disabled", false);
	}
	this.zen2han = function(value){
		var char1 = new Array("１","２","３","４","５","６","７","８","９","０");
		var char2 = new Array(1,2,3,4,5,6,7,8,9,0);
		var count;

		while(value.match(/[０-９]/)){
			for(count = 0; count < char1.length; count++){
				//入力データを全角数字から半角数字に置換する
				value = value.replace(char1[count], char2[count]);
			}
		}
		return value;
	}
	this.displayer = function(src,object){
		if(src.checked){
			$("#" + object).attr("style","display:block");
		}else{
			$("#" + object).attr("style","display:none");
		}
	}
}