function userLogin() {
	$fn('unc-cash','userId').value = $('unc-login-user').value;
	$fn('unc-cash','userPw').value = $('unc-login-pw').value;
	Web.submit('unc-cash', {method:'post',action:'login-process.do'});
}

function login_focus() {
	//Web.Form.setStyle('unc-unit');
	//Web.Element.setClass('span','unc-fnt-out', 'unc-fnt-over');
	$('unc-login-user').focus();
}

function member_list_init() {
	Web.Form.setStyle('unc-unit');
	if ($('unc-member-category-list')) {
		Unc.tag.select.apply('unc-member-category-list',80,22);
	}	
}

function setJoinform(f){
	var frm = jQuery(f);
	var txt = jQuery("input:text", f);
	var pwd = jQuery("input:password", f);
	
	jQuery(txt).each(function(){
		jQuery(this).addClass("inp");
	});

	jQuery(pwd).each(function(){
		jQuery(this).addClass("inp");
	});
}

function member_init() {
	//Web.Form.setStyle('unc-unit');
	setJoinform("#unc-unit");

	Web.Form.loadForm('unc-cash');
	
	if (Web.Form.hash['userReg_no'] == 'Y') {
		$('unc-member-regno').style.display = 'inline';	
	}
	if (Web.Form.hash['userName'] == 'Y') {
		$('unc-member-name').style.display = 'inline';	
	}
	if (Web.Form.hash['userIcon'] == 'Y') {
		$('unc-member-icon').style.display = 'inline';	
	}
	if (Web.Form.hash['userPhoto'] == 'Y') {
		$('unc-member-photo').style.display = 'inline';	
	}
	if (Web.Form.hash['userZip_cd'] == 'Y') {
		$('unc-member-zipcd').style.display = 'inline';	
	}
	if (Web.Form.hash['userAddress'] == 'Y') {
		$('unc-member-address').style.display = 'inline';	
	}
	if (Web.Form.hash['userBirth_dt'] == 'Y') {
		$('unc-member-birth').style.display = 'inline';	
	}
	if (Web.Form.hash['userWedding_dt'] == 'Y') {
		$('unc-member-wedding').style.display = 'inline';	
	}
	if (Web.Form.hash['userTel'] == 'Y') {
		$('unc-member-tel').style.display = 'inline';	
	}
	if (Web.Form.hash['userHp'] == 'Y') {
		$('unc-member-hp').style.display = 'inline';	
	}
	if (Web.Form.hash['userComment'] == 'Y') {
		$('unc-member-comment').style.display = 'inline';	
	}
	if (Web.Form.hash['userHomepage'] == 'Y') {
		$('unc-member-home').style.display = 'inline';	
	}
	if (Web.Form.hash['userHobby'] == 'Y') {
		$('unc-member-hobby').style.display = 'inline';	
	}
	if (Web.Form.hash['userEmail_yn'] == 'N') {
		$n('userEmail_yn')[1].checked = true;
	}
	else {
		$n('userEmail_yn')[0].checked = true;
	}
	/*
	if (Web.Form.hash['userPublic_cd'] == 'A') {
		$n('userPublic_cd')[0].checked = true;
	}
	else if (Web.Form.hash['userPublic_cd'] == 'B') {
		$n('userPublic_cd')[1].checked = true;
	}
	else if (Web.Form.hash['userPublic_cd'] == 'C') {
		$n('userPublic_cd')[2].checked = true;
	}
	else if (Web.Form.hash['userPublic_cd'] == 'D') {
		$n('userPublic_cd')[3].checked = true;
	}
	*/
	if (Web.Form.hash['userGender'] == 'Male') {
		$n('userGender')[0].checked = true;
	}
	else if (Web.Form.hash['userGender'] == 'Female') {
		$n('userGender')[1].checked = true;
	}
	if (Web.Form.hash['userRequesttype'] == 'AB member') {
		$n('userRequesttype')[0].checked = true;
	}
	else if (Web.Form.hash['userRequesttype'] == 'Guest') {
		$n('userRequesttype')[1].checked = true;
	}
	else if (Web.Form.hash['userRequesttype'] == 'Others') {
		$n('userRequesttype')[2].checked = true;
	}
	if (Web.Form.hash['userHobby'] != 'N') {
		var val = $fn('unc-cash','serialUserHobby').value.split(",");
		var obj = $n('hobby');
		for (var i = 0; i < obj.length; i++) {
			for (var k = 0; k < val.length; k++) {
				if (obj[i].value == val[k])
					obj[i].checked = true;
			}
		}
	}
//20101230 mdcgood add
/*
		var val = $fn('unc-cash','userCountry').value;
		var obj = document.getElementById("userCountry");
		//alert(obj.length);
		for (var i = 0; i < obj.length; i++) {
				if (obj[i].value == val)
					obj[i].selected = "selected";
		}
*/
/*
	if ($('unc-alice')) {
		Unc.alice.hash['alice'] = Web.EditorManager.instance("unc-alice",{width:1,height:1,type:'normal'});
	}
*/
}

function ableToId() {
	if (!Web.Form.validateValue($fn('unc-unit','userId'))) return;
	if (!Web.Form.validateAlphaNum($fn('unc-unit','userId'))) return;
	if (!Web.Form.validateMaxByte($fn('unc-unit','userId'))) return;
	if (!Web.Form.validateMinByte($fn('unc-unit','userId'))) return;
	Web.Ajax.invoke({action:'ajax-member-id.do',params:'userId='+$fn('unc-unit','userId').value+'&command=ABLETOID',handler:'messageParsing'});

}

function ableToNick() {
	if (Web.Form.validateValue($fn('unc-unit','userNick'))) {
		Web.Ajax.invoke({action:'ajax-member-nick.do',params:'userNick='+$fn('unc-unit','userNick').value+'&command=ABLETONICK',handler:'messageParsing'});
	}
}

function ableToEmail() {
	if (Web.Form.validateEmail($fn('unc-unit','userEmail'))) {
		Web.Ajax.invoke({action:'ajax-member-email.do',params:'userEmail='+$fn('unc-unit','userEmail').value+'&command=ABLETOEMAIL',handler:'messageParsing'});
	}
}

function ableToCode() {
	if (Web.Form.validateValue($fn('unc-unit','userHospitalCode'))) {
		Web.Ajax.invoke({action:'ajax-hospital-code.do',params:'userHospitalCode='+$fn('unc-unit','userHospitalCode').value+'&command=ABLETOCODE',handler:'messageParsing'});
	}
}

function setPostcd(zip,addr) {
	$fn('unc-unit','userZip1_cd').value = zip.substring(0,3);
	$fn('unc-unit','userZip2_cd').value = zip.substring(4,7);
	$fn('unc-unit','userAddress').value = addr;	
}

function fileSend(id, mode, subid){
	if (Web.Form.validateValue(id) &&
		Web.Form.validateFile(id, "gif","jpg","jpeg","pnp", "doc", "pdf")) {
		$fn('unc-unit','mode').value = mode;
		$fn('unc-unit','subId').value = subid;
		Web.submit('unc-unit',{method:'post',target:'_hidden',action:'uploadManager',encoding:'multipart/form-data',resubmit:'Y'});
	}
}

function pasteImage(icon) {	
	$fn('unc-unit','userIcon').value = icon;
	$('unc-member-icon-view').style.display = 'inline';
	$('unc-user-icon').src = './'+Web.Form.hash['htmlImage']+'/icon/'+icon.substring(0,8)+'/'+icon;
}

function pastePhoto(photo) {
	$fn('unc-unit','userPhoto').value = photo;
	$('unc-member-photo-view').style.display = 'block';
	$('unc-user-photo').src = './'+Web.Form.hash['htmlImage']+'/photo/'+photo.substring(0,8)+'/'+photo;
}

//20101227 mdcgood add
function pasteBiodata(biodata) {
	$fn('unc-unit','userBiodata').value = biodata;
	//$('unc-member-photo-view').style.display = 'block';
	//$('unc-user-photo').src = './'+Web.Form.hash['htmlImage']+'/photo/'+photo.substring(0,8)+'/'+photo;
}

function showMemberType(id) {
	$('unc-information').style.display = 'none';
	$('unc-password').style.display = 'none';
	//$('unc-drop').style.display = 'none';
	$(id).style.display = 'inline';
	if (id == 'unc-information') {
		$fn('unc-unit','userPw').focus();
	}
	else if (id == 'unc-password') {
		$fn('unc-unit','currentPw').focus();
	}
	/*
	else if (id == 'unc-drop') {
		$fn('unc-unit','yourPw').focus();
	}
	*/
}

function memberPassword() {
	if (!Web.Form.validateValue($fn('unc-unit','currentPw'))) return;
	if (!Web.Form.validateValue($fn('unc-unit','newPw'))) return;
	if (!Web.Form.validateAlphaNum($fn('unc-unit','newPw'))) return;
	if (!Web.Form.validateMaxByte($fn('unc-unit','newPw'))) return;
	if (!Web.Form.validateMinByte($fn('unc-unit','newPw'))) return;
	
	if ($fn('unc-unit','newPw').value != $fn('unc-unit','newPw_confirm').value) {
		Web.alert({title:'Alert',msg:'입력한 새비밀번호와 비밀번호 확인값이 틀립니다1 ',focus:$fn('unc-unit','newPw')});
		return;
	}
	$fn('unc-unit','command').value = "PASSWORD";
	Web.confirm({title:'Confirm',msg:'Are you change your password?',fnok:function() {
		Web.submit('unc-unit',{method:'post',action:'member-join-process.do',target:'_self'});
	}});
}

function memberDrop() {
	if (!Web.Form.validateValue($fn('unc-unit','yourPw'))) return;
	$fn('unc-unit','command').value = "DELETE";
	Web.confirm({title:'Confirm',msg:'Really delete your account?',fnok:function() {
		Web.submit('unc-unit',{method:'post',action:'member-join-process.do',target:'_self'});
	}});
}

function memberSave() {		
	if (!eval(Web.Form.hash['login'])) {
		if (!Web.Form.validateValue($fn('unc-unit','userHospitalCode'))) return;
		if (!Web.Form.validateValue($fn('unc-unit','userId'))) return;
		if (!Web.Form.validateAlphaNum($fn('unc-unit','userId'))) return;
		if (!Web.Form.validateMaxByte($fn('unc-unit','userId'))) return;
		if (!Web.Form.validateMinByte($fn('unc-unit','userId'))) return;
		if ($fn('unc-unit','userPw').value != $fn('unc-unit','userPw_confirm').value) {
			Web.alert({title:'Alert',msg:'Differrent pw and pw confirm'});
			return;	
		}
		//alert('userPw_end');
		$fn('unc-unit','command').value = "NEW";
	} 
	else {
		$fn('unc-unit','command').value = "UPDATE";
	}

	$fn('unc-unit','userReg_no').value = '';

	$fn('unc-unit','userZip_cd').value = '';
	$fn('unc-unit','userBirth_dt').value = '';

	$fn('unc-unit','userWedding_dt').value = '';
	$fn('unc-unit','userHobby').value = '';

	
	if (!Web.Form.validateValue($fn('unc-unit','userPw'))) return;
	if (!Web.Form.validateAlphaNum($fn('unc-unit','userPw'))) return;
	if (!Web.Form.validateMaxByte($fn('unc-unit','userPw'))) return;
	if (!Web.Form.validateMinByte($fn('unc-unit','userPw'))) return;

	//if (!Web.Form.validateValue($fn('unc-unit','userNick'))) return;
	if (!Web.Form.validateValue($fn('unc-unit','userPw_question'),'Question for Password')) return;
	if (!Web.Form.validateValue($fn('unc-unit','userPw_answer'),'Answer for Password')) return;
	if (!Web.Form.validateValue($fn('unc-unit','userEmail'))) return;

	if (Web.Form.hash['userReg_no'] == 'Y') {
		if (!Web.Form.validateValue($fn('unc-unit','userReg1_no'))) return;
		if (!Web.Form.validateValue($fn('unc-unit','userReg2_no'))) return;
	}
	if (Web.Form.hash['userName'] == 'Y') {
		if (!Web.Form.validateValue($fn('unc-unit','userName'))) return;
	}
	if (Web.Form.hash['userIcon'] == 'Y') {
		if (!Web.Form.validateValue($fn('unc-unit','userIcon'),'아이콘에')) return;
	}
	if (Web.Form.hash['userPhoto'] == 'Y') {
		if (!Web.Form.validateValue($fn('unc-unit','userPhoto'),'사진에')) return;
	}
	if (Web.Form.hash['userZip_cd'] == 'Y') {
		if (!Web.Form.validateValue($fn('unc-unit','userZip1_cd'))) return;
		if (!Web.Form.validateValue($fn('unc-unit','userZip2_cd'))) return;
	}
	if (Web.Form.hash['userAddress'] == 'Y') {
		if (!Web.Form.validateValue($fn('unc-unit','userAddress'))) return;
	}
	if (Web.Form.hash['userBirth_dt'] == 'Y') {
		if (!Web.Form.validateValue($fn('unc-unit','userBirth1_dt'))) return;
		if (!Web.Form.validateValue($fn('unc-unit','userBirth2_dt'))) return;
		if (!Web.Form.validateValue($fn('unc-unit','userBirth3_dt'))) return;
	}
	if (Web.Form.hash['userWedding_dt'] == 'Y') {
		if (!Web.Form.validateValue($fn('unc-unit','userWedding1_dt'))) return;
		if (!Web.Form.validateValue($fn('unc-unit','userWedding2_dt'))) return;
		if (!Web.Form.validateValue($fn('unc-unit','userWedding3_dt'))) return;
	}
	if (Web.Form.hash['userTel'] == 'Y') {
		if (!Web.Form.validateValue($fn('unc-unit','userTel1'))) return;
		if (!Web.Form.validateValue($fn('unc-unit','userTel2'))) return;
		if (!Web.Form.validateValue($fn('unc-unit','userTel3'))) return;
	}
	if (Web.Form.hash['userHp'] == 'Y') {
		if (!Web.Form.validateValue($fn('unc-unit','userHp1'))) return;
		if (!Web.Form.validateValue($fn('unc-unit','userHp2'))) return;
		if (!Web.Form.validateValue($fn('unc-unit','userHp3'))) return;
	}
	if (Web.Form.hash['userHomepage'] == 'Y') {
		if (!Web.Form.validateValue($fn('unc-unit','userHomepage'))) return;
	}	
	/*
	if (Web.Form.hash['userComment'] != 'N') {
		var ct = Unc.alice.hash['alice'].getContent(true);
		if (Unc.alice.hash['alice'].isLimit()) {
			Web.alert({title:'경고', msg:'잡담을 너무 많이 작성하셨습니다<br>최대 잡담 작성가능 글자수는 <b>'+Unc.alice.hash['alice'].limit+'</b>바이트 입니다<br>현재 작성 글자수는 <b>'+ct.getByte()+'</b>바이트 입니다',width:400});
			return;
		}

		if (Web.Form.hash['userComment'] == 'Y' && (ct.empty() || ct == '<br>')) {
			Web.alert({title:'주의',msg:'잡담을 입력하세요'});			
			return;
		}
		*/
		var ct = "insert by default";
		$fn('unc-unit','userComment').value = ct;
	//}
	/*
	if (!$n('userPublic_cd')[0].checked && !$n('userPublic_cd')[1].checked && !$n('userPublic_cd')[2].checked && !$n('userPublic_cd')[3].checked) {
		Web.alert({title:'경고',msg:'정보공개중 최소한 하나를 선택해 주세요'});
		return;
	}
	*/
	if (Web.Form.hash['userReg_no'] != 'N' && (!$fn('unc-unit','userReg1_no').value.empty() || !$fn('unc-unit','userReg2_no').value.empty())) {
		if (!Web.Form.validateRegno($fn('unc-unit','userReg1_no'), $fn('unc-unit','userReg2_no'))) return;
	}
	if (Web.Form.hash['userZip_cd'] != 'N' && (!$fn('unc-unit','userZip1_cd').value.empty() || !$fn('unc-unit','userZip2_cd').value.empty())) {
		if (!Web.Form.validateValue($fn('unc-unit','userZip1_cd'))) return;
		if (!Web.Form.validateValue($fn('unc-unit','userZip2_cd'))) return;
		if (!Web.Form.validateNum($fn('unc-unit','userZip1_cd'))) return;
		if (!Web.Form.validateNum($fn('unc-unit','userZip2_cd'))) return;
	}
	if (Web.Form.hash['userBirth_dt'] != 'N' && 
		(!$fn('unc-unit','userBirth1_dt').value.empty() || !$fn('unc-unit','userBirth2_dt').value.empty() || !$fn('unc-unit','userBirth3_dt').value.empty())) {
		if (!Web.Form.validateValue($fn('unc-unit','userBirth1_dt'))) return;
		if (!Web.Form.validateValue($fn('unc-unit','userBirth2_dt'))) return;
		if (!Web.Form.validateValue($fn('unc-unit','userBirth3_dt'))) return;
		if (!Web.Form.validateNum($fn('unc-unit','userBirth1_dt'))) return;
		if (!Web.Form.validateNum($fn('unc-unit','userBirth2_dt'))) return;
		if (!Web.Form.validateNum($fn('unc-unit','userBirth3_dt'))) return;
	}
	if (Web.Form.hash['userWedding_dt'] != 'N' && 
		(!$fn('unc-unit','userWedding1_dt').value.empty() || !$fn('unc-unit','userWedding2_dt').value.empty() || !$fn('unc-unit','userWedding3_dt').value.empty())) {
		if (!Web.Form.validateValue($fn('unc-unit','userWedding1_dt'))) return;
		if (!Web.Form.validateValue($fn('unc-unit','userWedding2_dt'))) return;
		if (!Web.Form.validateValue($fn('unc-unit','userWedding3_dt'))) return;
		if (!Web.Form.validateNum($fn('unc-unit','userWedding1_dt'))) return;
		if (!Web.Form.validateNum($fn('unc-unit','userWedding2_dt'))) return;
		if (!Web.Form.validateNum($fn('unc-unit','userWedding3_dt'))) return;
	}
		/*
		if (Web.Form.hash['userTel'] != 'N' &&
		(!$fn('unc-unit','userTel1').value.empty() || !$fn('unc-unit','userTel2').value.empty() || !$fn('unc-unit','userTel3').value.empty())) {
		if (!Web.Form.validateValue($fn('unc-unit','userTel1'))) return;
		if (!Web.Form.validateValue($fn('unc-unit','userTel2'))) return;
		if (!Web.Form.validateValue($fn('unc-unit','userTel3'))) return;

		if (!Web.Form.validateNum($fn('unc-unit','userTel1'))) return;
		if (!Web.Form.validateNum($fn('unc-unit','userTel2'))) return;
		if (!Web.Form.validateNum($fn('unc-unit','userTel3'))) return;

	}
	*/
	if (Web.Form.hash['userHp'] != 'N' &&
		(!$fn('unc-unit','userHp1').value.empty() || !$fn('unc-unit','userHp2').value.empty() || !$fn('unc-unit','userHp3').value.empty())) {
		if (!Web.Form.validateValue($fn('unc-unit','userHp1'))) return;
		if (!Web.Form.validateValue($fn('unc-unit','userHp2'))) return;
		if (!Web.Form.validateValue($fn('unc-unit','userHp3'))) return;
		if (!Web.Form.validateNum($fn('unc-unit','userHp1'))) return;
		if (!Web.Form.validateNum($fn('unc-unit','userHp2'))) return;
		if (!Web.Form.validateNum($fn('unc-unit','userHp3'))) return;
	}
	
	if (Web.Form.hash['userEmail'] != 'N' && $fn('unc-unit','userEmail').value.empty()) {
		if (!Web.Form.validateEmail($fn('unc-unit','userEmail'))) return;	
	}
	if (Web.Form.hash['userReg_no'] != 'N' && !$fn('unc-unit','userReg1_no').value.empty() && !$fn('unc-unit','userReg1_no').value.empty()) {
		$fn('unc-unit','userReg_no').value = $fn('unc-unit','userReg1_no').value.toString()+$fn('unc-unit','userReg2_no').value.toString();
	}
	if (Web.Form.hash['userZip_cd'] != 'N' && !$fn('unc-unit','userZip1_cd').value.empty() && !$fn('unc-unit','userZip2_cd').value.empty()) {
		$fn('unc-unit','userZip_cd').value = $fn('unc-unit','userZip1_cd').value.toString()+$fn('unc-unit','userZip2_cd').value.toString();
	}
	if (Web.Form.hash['userBirth_dt'] != 'N' && !$fn('unc-unit','userBirth1_dt').value.empty() && !$fn('unc-unit','userBirth2_dt').value.empty() && !$fn('unc-unit','userBirth3_dt').value.empty()) {
		$fn('unc-unit','userBirth_dt').value = $fn('unc-unit','userBirth1_dt').value.toString()+$fn('unc-unit','userBirth2_dt').value.toString()+$fn('unc-unit','userBirth3_dt').value.toString();
	}
	if (Web.Form.hash['userWedding_dt'] != 'N' && !$fn('unc-unit','userWedding1_dt').value.empty() && !$fn('unc-unit','userWedding2_dt').value.empty() && !$fn('unc-unit','userWedding3_dt').value.empty()) {
		$fn('unc-unit','userWedding_dt').value = $fn('unc-unit','userWedding1_dt').value.toString()+$fn('unc-unit','userWedding2_dt').value.toString()+$fn('unc-unit','userWedding3_dt').value.toString();
	}
	
	if (Web.Form.hash['userHobby'] != 'N') {
		var hobbySelected = '';
		var objs = $('unc-unit');
		for (var i = 0; i < objs.elements.length; i++) {
			if (objs.elements[i].name == 'hobby' &&
				objs.elements[i].checked) {
				hobbySelected += objs.elements[i].value+',';
			}
		}
		if (Web.Form.hash['userHobby'] == 'Y' && hobbySelected == '') {
			Web.alert({title:'경고',msg:'취미를 최소 하나이상 선택해 주세요'});
			return;
		}
		$fn('unc-unit','userHobby').value = hobbySelected;
	}

	Web.submit('unc-unit',{method:'post',action:'member-join-process.do',target:'_self',encoding:'application/x-www-form-urlencoded'});
}

function userFound_init() {
	Web.Form.setStyle('unc-unit');
	Web.Element.setClass('span','unc-fnt-out', 'unc-fnt-over');
	$fn('unc-unit','userNick').focus();	
}

function userPasswordFound_init() {
	Web.Form.setStyle('unc-unit');
	Web.Element.setClass('span','unc-fnt-out', 'unc-fnt-over');
	if ($('unc-login-email')) {
		$('unc-login-email').focus();
	}
}

function userFound() {
	userStep('step3');
}

function userPasswordFound() {
	userStep('step1');
}

function userPasswordHintFound() {
	userStep('step2');
}

function userStep(fg) {
	if (fg == 'step1') {
		if (!Web.Form.validateValue($fn('unc-unit','userEmail'))) return;
	} 
	else if (fg == 'step2') {
		if (!Web.Form.validateValue($fn('unc-unit','userPw_answer'))) return;
	} 
	else if (fg == 'step3') {
		if (!Web.Form.validateValue($fn('unc-unit','userNick'))) return;
		if (!Web.Form.validateValue($fn('unc-unit','userEmail'))) return;
	} 
	else if (fg == 'back') {
		back();
		return;
	}
	Web.submit('unc-unit',{method:'post'});
}

function memberSearch() {
	if (Web.Form.validateValue($fn('unc-unit','searchKey'))) {
		Web.submit('unc-unit',{method:'post'});	
	}
}

function viewMyMessage(addr) {
	Web.Window.popup(addr,{width:450,height:500});
}

function viewCharacter(uid, e) {
	//Unc.user.loading(uid, e);
}

function writeMessage(uid) {
	Web.Window.popup('message-edit.do?receiveUserId='+uid, {width:450,height:500});
}

function viewUserArticle(uid) {
	var div = null;
	if ($("unc-user-search")) {
		div = $("unc-user-search");
	}
	else {
		div = document.createElement("div");
		div.setAttribute("id", "unc-user-search");
		document.body.appendChild(div);	
	}
		
	div.innerHTML = ""+
			"<form name=unc-temp-form>"+
				"<input type=hidden name=command value='SUMMARY'>"+
				"<input type=hidden name=searchType value='I MI'>"+
				"<input type=hidden name=thumbnailSize value=50>"+
				"<input type=hidden name=pageScale value=50>"+
				"<input type=hidden name=page value=1>"+
				"<input type=hidden name=searchOrKey value='"+uid+"'>"+
			"</form>";
		
	Web.submit('unc-temp-form',{method:'post',action:'search.do'});
}


