/**
 * @target udc 관련 공통함수
 */

var udcLib = {};

udcLib.getValue = function(comp) {
	try {
		if (typeof comp =="string") {
			if (!$p.getComponentById(comp)) {
				comp = $p.getComponentById(udc_obj.id+"_"+comp);
			} else {
				comp = $p.getComponentById(comp);
			}
		}
		return comp.getValue();
	} catch (e) {
		//$W.exception.printStackTrace(e);
		//commLib.log("udcLib.getValue: " + e);
	}
};

udcLib.setValue = function(comp,valArr) {
	try {
		if (typeof comp =="string") {
			if (!$p.getComponentById(comp)) {
				comp = $p.getComponentById(udc_obj.id+"_"+comp);
			} else {
				comp = $p.getComponentById(comp);
			}
		}
		switch (valArr.length) {
		case 1:
			comp.setValue(valArr[0]);
			break;
		case 2:
			comp.setValue(valArr[0],valArr[1]);
			break;
		default:
			comp.setValue(valArr[0],valArr[1],valArr[2]);
			break;
		}
	} catch (e) {
		//$W.exception.printStackTrace(e);
		//commLib.log("udcLib.setValue: " + e);
	}
};

udcLib.classComp = function(comp,valArr) {
	try {
		if (typeof comp =="string") {
			if (!$p.getComponentById(comp)) {
				comp = $p.getComponentById(udc_obj.id+"_"+comp);
			} else {
				comp = $p.getComponentById(comp);
			}
		}
		switch (valArr.length) {
		case 1:
			comp.classComp(valArr[0]);
			break;
		case 2:
			comp.classComp(valArr[0],valArr[1]);
			break;
		case 3:
			comp.classComp(valArr[0],valArr[1],valArr[2]);
			break;
		default:
			comp.classComp(valArr[0],valArr[1],valArr[2],valArr[3]);
			break;
		}
	} catch (e) {
		//$W.exception.printStackTrace(e);
		//commLib.log("udcLib.classComp: " + e);
	}
};

udcLib.styleComp = function(comp,valArr) {
	try {
		if (typeof comp =="string") {
			if (!$p.getComponentById(comp)) {
				comp = $p.getComponentById(udc_obj.id+"_"+comp);
			} else {
				comp = $p.getComponentById(comp);
			}
		}
		switch (valArr.length) {
		case 1:
			comp.styleComp(valArr[0]);
			break;
		case 2:
			comp.styleComp(valArr[0],valArr[1]);
			break;
		case 3:
			comp.styleComp(valArr[0],valArr[1],valArr[2]);
			break;
		default:
			comp.styleComp(valArr[0],valArr[1],valArr[2],valArr[3]);
		break;
		}
	} catch (e) {
		//$W.exception.printStackTrace(e);
		//commLib.log("udcLib.styleComp: " + e);
	}
};

udcLib.readOnlyComp = function(comp,valArr) {
	try {
		if (typeof comp =="string") {
			if (!$p.getComponentById(comp)) {
				comp = $p.getComponentById(udc_obj.id+"_"+comp);
			} else {
				comp = $p.getComponentById(comp);
			}
		}
		switch (valArr.length) {
		case 1:
			comp.readOnlyComp(valArr[0]);
			break;
		case 2:
			comp.readOnlyComp(valArr[0],valArr[1]);
			break;
		case 3:
			comp.readOnlyComp(valArr[0],valArr[1],valArr[2]);
			break;
		default:
			comp.readOnlyComp(valArr[0],valArr[1],valArr[2],valArr[3]);
		break;
		}
	} catch (e) {
		//$W.exception.printStackTrace(e);
		//commLib.log("udcLib.readOnlyComp: " + e);
	}
};

udcLib.disableComp = function(comp,valArr) {
	try {
		if (typeof comp =="string") {
			if (!$p.getComponentById(comp)) {
				comp = $p.getComponentById(udc_obj.id+"_"+comp);
			} else {
				comp = $p.getComponentById(comp);
			}
		}
		switch (valArr.length) {
		case 1:
			comp.disableComp(valArr[0]);
			break;
		case 2:
			comp.disableComp(valArr[0],valArr[1]);
			break;
		case 3:
			comp.disableComp(valArr[0],valArr[1],valArr[2]);
			break;
		default:
			comp.disableComp(valArr[0],valArr[1],valArr[2],valArr[3]);
		break;
		}
	} catch (e) {
		//$W.exception.printStackTrace(e);
		//commLib.log("udcLib.disableComp: " + e);
	}
};

udcLib.hideComp = function(comp,valArr) {
	try {
		if (typeof comp =="string") {
			if (!$p.getComponentById(comp)) {
				comp = $p.getComponentById(udc_obj.id+"_"+comp);
			} else {
				comp = $p.getComponentById(comp);
			}
		}
		switch (valArr.length) {
		case 1:
			comp.hideComp(valArr[0]);
			break;
		case 2:
			comp.hideComp(valArr[0],valArr[1]);
			break;
		case 3:
			comp.hideComp(valArr[0],valArr[1],valArr[2]);
			break;
		default:
			comp.hideComp(valArr[0],valArr[1],valArr[2],valArr[3]);
		break;
		}
	} catch (e) {
		//$W.exception.printStackTrace(e);
		//commLib.log("udcLib.hideComp: " + e);
	}
};

udcLib.showComp = function(comp,valArr) {
	try {
		if (typeof comp =="string") {
			if (!$p.getComponentById(comp)) {
				comp = $p.getComponentById(udc_obj.id+"_"+comp);
			} else {
				comp = $p.getComponentById(comp);
			}
		}
		switch (valArr.length) {
		case 1:
			comp.showComp(valArr[0]);
			break;
		case 2:
			comp.showComp(valArr[0],valArr[1]);
			break;
		case 3:
			comp.showComp(valArr[0],valArr[1],valArr[2]);
			break;
		default:
			comp.showComp(valArr[0],valArr[1],valArr[2],valArr[3]);
		break;
		}
	} catch (e) {
		//$W.exception.printStackTrace(e);
		//commLib.log("udcLib.showComp: " + e);
	}
};

udcLib.focus = function(comp,opt) {
	try {
		if (typeof comp =="string") {
			if (!$p.getComponentById(comp)) {
				comp = $p.getComponentById(udc_obj.id+"_"+comp);
			} else {
				comp = $p.getComponentById(comp);
			}
		}
		switch (opt) {
		case "f"://기간달력 from input 포커스
			comp = WebSquare.util.getComponentById(comp.id+"_ical1_input");
			comp.focus();
			break;
		case "t"://기간달력 to input 포커스
			comp = WebSquare.util.getComponentById(comp.id+"_ical2_input");
			comp.focus();
			break;
		case "1"://1번째 input 포커스
			comp = WebSquare.util.getComponentById(comp.id+"_txt1");
			comp.focus();
			break;
		case "2"://2번째 input 포커스
			comp = WebSquare.util.getComponentById(comp.id+"_txt2");
			comp.focus();
			break;
		case "3"://3번째 input 포커스
			comp = WebSquare.util.getComponentById(comp.id+"_txt3");
			comp.focus();
			break;
		default://단일 달력 포커스
			comp = WebSquare.util.getComponentById( comp.id+"_ical_input" );
			comp.focus();
			break;
		}
	} catch (e) {
		//$W.exception.printStackTrace(e);
		//commLib.log("udcLib.focus: " + e);
	}
};

udcLib.getObj = function(id) {
	try {
		var obj;
		if ($p.getComponentById(id)) {
			obj = $p.getComponentById(id);
		} else {
			obj = $p.getComponentById(udc_obj.id+"_"+id);
		}
		return obj;
	} catch (e) {
		//$W.exception.printStackTrace(e);
		//commLib.log("udcLib.getObj: " + e);
	}
};
