/*
	이미지 클릭시 이미지 크기에 맞게 팝업 표시
	ex : popImg(경로/이미지명)
*/
var imgObj = new Image(); 
function popImg(imgName){
	imgObj.src = imgName;
	setTimeout("createImgWin(imgObj)", 100);
}

function createImgWin(imgObj){
	if(!imgObj.complete){
		setTimeout("createImgWin(imgObj)", 100);
		return;
	}
	
	var pop_left = parseInt((screen.availWidth/2) - (imgObj.width/2));
	var pop_top = parseInt((screen.availHeight/2) - (imgObj.height/2));
	
	imageWin = window.open("", "_blank","width=" + imgObj.width + ",height=" + imgObj.height + ",top="+pop_top+",left="+pop_left+",toolbar='no',location='no',directories='no',status='no',menubar='no',scrollbars=1,resizable='no'");
	imageWin.document.writeln("<html>");
	imageWin.document.writeln("<head>");
	imageWin.document.writeln("<title>이미지 확대보기(" + imgObj.width + "*" + imgObj.height + ")</title>");
	imageWin.document.writeln("</head>");
	imageWin.document.writeln("<body onDragStart='return false' onSelectStart='return false' style='margin:0; text-align:center'>");
	imageWin.document.writeln("<img src='" + imgObj.src + "' border='0' alt='이미지 클릭시 현재창이 닫힙니다.' onClick='window.close();' style='cursor:pointer'>");
	imageWin.document.writeln("</body>");
	imageWin.document.writeln("<html>");
	//imageWin.document.title = imgObj.src;
	imageWin.blur();
	imageWin.focus();
}

//이메일 선택시 value값 입력
function bindEmail(obj, mail){
	if(obj.value == "etc"){
		mail.value = "";
		mail.readOnly = false;
		mail.focus();
	}else if(obj.value == ""){
		mail.value = "";
		mail.readOnly = true;
	}else{
		mail.value = obj.value;
		mail.readOnly = true;
	}
}

//관리자권환
function adminGoLink(act, pagenum, add){
	var url = "";
	if(act == 'process'){
		if(confirm('해당글을 삭제하시겠습니까?')){
			url = '?act='+act+'&mod=delete&pagenum='+parseInt(Number(pagenum));
			if(add) url += add;
			document.location=url;
		}
	}else{
		url = '?act='+act+'&mod='+act+'&pagenum='+parseInt(Number(pagenum));
		if(add) url += add;
		document.location=url;
	}
}

//게시판 버튼 링크
function goLink_old(act, pagenum, add){
	var url = "";
	if(act == 'process' || act == 'modify'){
		switch(act){
			case 'process' :
				var ment = '삭제';
				var ii = 'delete';
				break;
			case 'modify' :
				var ment = '수정';
				var ii = 'modify';
				break;
		}
		if(confirm('해당글을 '+ment+'하시겠습니까?')){
			url = '?test=test&act='+act+'&mod='+ii+'&pagenum='+parseInt(Number(pagenum));
			if(add) url += add;
			//alert(url);return;
			//document.location=url;
			popupOpen('/board_new/confirmPop.php?thisUrl='+url+'&ments='+ment, 'confirm', '330', '200', 'y');
		}
	}else{
		url = '?act='+act+'&mod='+act+'&pagenum='+parseInt(Number(pagenum));
		if(add) url += add;
		document.location=url;
	}
}

//게시판 버튼 링크
function goLink(act, pagenum, add){
	var url = "";
	if(act == 'process'){
		if(confirm('해당글을 삭제하시겠습니까?')){
			url = '?act='+act+'&mod=delete&pagenum='+parseInt(Number(pagenum));
			if(add) url += add;
			document.location=url;
		}
	}else{
		url = '?act='+act+'&mod='+act+'&pagenum='+parseInt(Number(pagenum));
		if(add) url += add;
		document.location=url;
	}
}

function goLink2(act, pagenum, add){
	var url = "";
	if(act == 'process'){
		if(confirm('최종제출 하시겠습니까?')){
			url = '?act='+act+'&mod=last&pagenum='+parseInt(Number(pagenum));
			if(add) url += add;
			document.location=url;
		}
	}else{
		url = '?act='+act+'&mod='+act+'&pagenum='+parseInt(Number(pagenum));
		if(add) url += add;
		document.location=url;
	}
}

//주소클립복사
function urlToClip(obj){
	try{
		if($Agent().IE){
			var doc = $(obj).value;
			if(window.clipboardData.setData('Text', doc)){
				alert("주소가 복사되었습니다.\n게시판이나 주소표시줄 창에서 Ctrl+V를 눌러보세요.");
			}
		}else{
			alert("주소 복사는 Internet Explorer 에서만 가능합니다.");
		}
	}
	catch(e){
		//alert('ee');
	}
}

function $Agent() {
	var isOpera = !!(window.opera);
	var nu = navigator.userAgent;
	var isIE = !isOpera && /MSIE/.test(nu), ie5=false, ie55=false, ie6=false, ie7=false, macIE=false;
	
	if (isIE) {
		/MSIE ([0-9\.]+)/.exec(nu);
		var ver = parseFloat(RegExp.$1);
		switch (ver) {
			case 5   : ie5 =true; break;
			case 5.5 : ie55=true; break;
			case 6   : ie6=true; break;
			case 7   : ie7=true; break;
			default  :
		}
	}
	
	return {
		IE     : isIE,
		IE5    : isIE && ie5,
		IE55   : isIE && ie55,
		IE6    : isIE && ie6,
		IE7    : isIE && ie7,
		macIE  : isIE && macIE,
		Gecko  : /Gecko/.test(nu),
		Opera  : isOpera,
		Safari : /WebKit/.test(nu),
		KHTML  : /KHTML/.test(nu)
	};
}

function popupOpen(obj, popName, widthLength, heightLength, scrollYn){
	var window_left = (screen.width-700)/2;
	var window_top = (screen.height-480)/2;
	openWin = window.open(obj, popName, 'scrollbars='+scrollYn+',resizable=no,history=no,width='+widthLength+',height='+heightLength+',top=' + window_top + ',left=' + window_left + '');
	openWin.focus();
}

//내용 글자수 체크
function fontMaxSize(txtArea, maxSize, checkFiled){
	var contents;
	var txtContentsLength = document.getElementById(checkFiled);

	contents = txtArea.value;

	if(contents.length > maxSize){
		alert(maxSize+"자 이내로 작성하여 주세요");
		if(event.keyCode != null && event.keyCode == 13){
			txtArea.value = contents.substr(0,maxSize-1);
		}else{
			txtArea.value = contents.substr(0,maxSize);
			txtContentsLength.value = maxSize;
		}

		txtArea.focus();
		return false;
	}

	txtContentsLength.value = contents.length;
	return true;
}

/*
	내용출력(printContents <==출력할부분 , noPrint <==미출력부분)
	ex : printing('print', 'no');
*/
function printing(printContents, noPrint, addNo){
	if(noPrint) document.getElementById(noPrint).style.display = 'none';
	if(addNo) document.getElementById(addNo).style.display = 'none';
	v = document.getElementById(printContents).innerHTML;
	win=window.open('','newWindow','width=700,height=800,top=0,left=0,scrollbars=1,resizable=1,status=0');
	win.document.open();
	win.document.write("<html><head> \n<meta http-equiv='imagetoolbar' CONTENT='no'> \n<meta http-equiv='content-type' content='text/html; charset=utf-8'><body onLoad='window.print();'>\n");
	win.document.write("<title>:::: 오리엔탈정공 입사지원서 출력 ::::</title> \n");
	win.document.write("<style type='text/css'>");
	win.document.write("img, form{border:0} body, td, a, form, p{font:12px dotum} body{margin:10px}");
	win.document.write(".left{float:left; margin:0}div .right{float:right; margin:0}.clear{clear:both; margin:0}.left_bg{background:#A6A2A8;}.td0{padding:20px 0 10px; text-align:left}.td1{width:150px; text-align:center; padding:10px; font-weight:bold; color:#858484; background:#F5F5F5}.td2{text-align:left; padding:10px; color:#858484; background:#fff}.tt1{width:90px; padding:3px; color:#2DA587; font-weight:bold;}.tt2{width:28%; padding:3px; color:#666;}");
	win.document.write(" \n\n</style></head><body> \n");
	win.document.write("<div id='body_div'>"+v+"</div></body></html>");
	win.document.close();
	document.getElementById(noPrint).style.display = '';
	document.getElementById(addNo).style.display = '';
	if(parseInt(navigator.appVersion) >= 4){
		win.window.focus();
	}
}

//자격증 출력
function addPrint(imgName, imgFile){
	imgObj.src = imgFile;
	popupOpen('/recruit/addprint.php?imgName='+imgName+'&imgFile='+imgFile, 'ja_prints', imgObj.width, imgObj.height, 1);
	
}

//숫자만 입력
function onlyNumFn(){
	if(event.keyCode >= 48 && event.keyCode <= 57){ //숫자키만 입력
		return true;
	}else{
		event.returnValue = false;
	}
}

//특정 코드 추가(숫자만 입력 포함)
function onlyNumAddFn(code){
	if(event.keyCode >= 48 && event.keyCode <= 57){ //숫자키만 입력
		return true;
	}else if( event.keyCode == code ){
		return true;
	}else{
		event.returnValue = false;
	}
}

//다음 input 박스로 자동 포커스 이동
function autonext(vl, nextform){
	if(vl.value.length == vl.smax){
		nextform.focus();
		nextform.select();
	}
}
