
function getRadioButtonValue(comp){
	if(comp.length) {
		var i;
		for(i = 0; i < comp.length; i ++){
			if(comp[i].checked){
				return comp[i].value;
			}
		}
	}else{
		if(comp.checked){
			return comp.value;
		}
	}
}

function getRadioButtonIndex(comp){
	if(comp.length) {
		var i;
		for(i = 0; i < comp.length; i ++){
			if(comp[i].checked){
				return i;
			}
		}
	}else{
		if(comp.checked){
			return 0;
		}
	}
}

function getListOrder(dom){
	var obj = dom.getElementsByTagName('input');
	var order = "";
	for(i = 0; i < obj.length ;i++){
		if (i != 0){
			order = order + "\n";
		}
		order = order + obj[i].value;
	}

	return order;
}



function addCalendar(div_id,text_id){
	YAHOO.namespace("enquate.calendar");
	var cal_id = div_id + "_cal";
	var cal_container = div_id + "_container";

	var init = function() {

		function handleSelect(type,args,obj) {
			var dates = args[0];
			var date = dates[0];
			var year = date[0], month = date[1], day = date[2];

			var txtDate1 = document.getElementById(text_id);
			var txtDate2 = document.getElementById(div_id);
			if((""+month).length == 1){
				month = "0" + month;
			}
			if((""+day).length == 1){
				day = "0" + day;
			}
			txtDate1.value = year + "/" + month + "/" + day ;
			if (typeof txtDate2.textContent != "undefined") {
				txtDate2.textContent = txtDate1.value;
			} else {
				txtDate2.innerText = txtDate1.value;
			}
			cal.hide();
		}

		var cal = new YAHOO.widget.Calendar(cal_id,cal_container, { title:"日付選択:", close:true } );
		cal.selectEvent.subscribe(handleSelect, cal, true);
		cal.render();

		YAHOO.util.Event.addListener(div_id, "click", cal.show,cal, true);
	}

	YAHOO.util.Event.onDOMReady(init);
}

function requireCheck(str){
	if(str==""){
		return false;
	} else {
		return true;
	}
}

function checkLength(len){
	if (len !=""){
		var num = parseInt(len)
		if(!isNaN(num)){
			if(num > 0){
				return true;
			} else {
				return false;
			}
		} else {
			return false;
		}
	} else {
		return true;
	}
}

function checkAll(name,value){
	var items = document.getElementsByName(name);
	for (i = 0; i < document.getElementsByName(name).length; i++) {
		document.getElementsByName(name)[i].checked = value;
	}
}

function validateCheckBox(name){
	var items = document.getElementsByName(name);
	var result = false;
	for (i = 0; i < document.getElementsByName(name).length; i++) {
		if (document.getElementsByName(name)[i].checked) {
			result = true;
		}
	}

	return result;
}