/*
	공통으로 사용하는 script 를 저장하는 파일 입니다.
	Auth : 엄익민 (NEXTBIZ)
*/
	// import : prototype
	document.write('<script type="text/javascript" src="../lib/prototype.js"><\/script>');
	document.write('<script type="text/javascript" src="../lib/scriptaculous.js?load=effects,builder"><\/script>');
	document.write('<script type="text/javascript" src="../lib/jquery-latest.js"><\/script>');


	// 플래시 스크립트
	function flashTrace(url,id,w,h,bg,vars,win){
		var flashStr=
		"<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0' width='"+w+"' height='"+h+"' id='"+id+"' align='middle'>"+
		"<param name='allowScriptAccess' value='always' />"+
		"<param name='movie' value='"+url+"' />"+
		"<param name='FlashVars' value='"+vars+"' />"+
		"<param name='wmode' value='"+win+"' />"+
		"<param name='quality' value='high' />"+
		"<param name='bgcolor' value='"+bg+"' />"+
		"<embed src='"+url+"' FlashVars='"+vars+"' wmode='"+win+"' quality='high' bgcolor='"+bg+"' width='"+w+"' height='"+h+"' name='"+id+"' align='middle' allowScriptAccess='always' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />"+
		"</object>";
		document.write(flashStr);
	}

	//iframe auto resize
	function iframe_autoresize(arg) {
		arg.height = eval(arg.name+".document.body.scrollHeight");
	}

	// PNG IE6 에서 구현하기
	function setPng24(obj) { 
		obj.width=obj.height=1; 
		obj.className=obj.className.replace(/\bpng24\b/i,''); 
		obj.style.filter = 
		"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src +"',sizingMethod='image');" 
		obj.src='';  
		return ''; 
	} 

	// 글자수 제한.
	function in_ti(word, length) {
		if(word.length > length) { word = word.substring(0, length) + ".."; }	
		document.write(word);
	}

	// launchCenter(url, name, width, height, att)
	function launchCenter(url, name, width, height, att) 
	{
	  var str = "height=" + height + ",innerHeight=" + height;
	  str += ",width=" + width + ",innerWidth=" + width;
	  if (window.screen) {
		var ah = screen.availHeight - 30;
		var aw = screen.availWidth - 10;

		var xc = (aw - width) / 2;
		var yc = (ah - height) / 2;

		str += ",left=" + xc + ",screenX=" + xc;
		str += ",top=" + yc + ",screenY=" + yc;
		str += "," + att
	  }
	  return window.open(url, name, str);
	}

	// keyCode 가 13 일 경우 tab.
	function enterTab(e, FocusName) {
	  var focusname_obj = document.getElementsByName(FocusName);
	  var ev = (window.event) ? window.event.keyCode : e.keyCode;

	  if (ev == 13) { eval(focusname_obj[0].focus()); }
	}

	// keyCode 가 13 일 경우만 submit
	function enterSubmit(e, SubmitName) {
		var ev = (window.event) ? window.event.keyCode : e.keyCode;

		if (ev == 13) {
			if(SubmitName != "") { eval(SubmitName + "()"); }
		}
	}

	// keyCode 가 13 일 경우 tab.
	function EnterTab(FocusName) {
	  if (window.event.keyCode == 13) {    
		eval("document.all." + FocusName + ".focus()");
	  }
	}

	// keyCode 가 13 일 경우만 submit
	function EnterSubmit(SubmitName) {
		if(window.event.keyCode == 13) {
			if(SubmitName != "") {
				eval(SubmitName + "()");
			}
		}
	}

	// 준비중
	function ready() {
		window.alert("해당메뉴는 서비스 준비중입니다.");
	}

	// add event listener (cf. onload)
	function addLoadEvent(func)
	{
		var oldonload = window.onload;
		window.onload = (typeof window.onload != 'function') ? func : function() {
			if (oldonload) { oldonload(); }
			func();
		}
	}

	// 특정 문자만 입력받기 (나머지 글자 무시)
	function chkInputVal(targetEl, mode)
	{ 
		tmpVal = targetEl.value.toString(); 
		regexp = ''; 
		repexp = ''; 
		switch(mode) {
			case 'small':regexp = /[^a-z]/g;break;
			case 'smallnum':regexp = /[^a-z0-9]/g;break;
			case 'smallnumunder':regexp = /[^a-z0-9_]/g;break;
			case 'big':regexp = /[^A-Z]/g;break;
			case 'all':regexp = /[^a-z]/i;break;
			default :regexp = /[^a-z]/i;break;
		}
		tmpVal = tmpVal.replace(regexp, repexp);
		
		// chk : returnVal
		var returnVal = "";
		if ( targetEl.value.toString() == tmpVal ) {
			returnVal = "true";
		}
		else { returnVal = "false"; }

		targetEl.value = tmpVal;	
		return returnVal;
	}

	// mailto : 단순메일링크 생성
	function mailTo(mailAdd)
	{
		if ( confirm(mailAdd+" 로 이메일을 발송하시겠습니까?") ) {
			window.location.href = "mailto:"+mailAdd;
		}
	}

	// 이미지 미리보기 (이미지만 보임)
	function imgPreWin(picName, windowName, windowWidth, windowHeight)
	{
		var winHandle = window.open("", "_blank","left=0, top=0,toolbar=no,scrollbars=no,resizable=no,width=" + windowWidth + ",height=" + windowHeight);
		if (winHandle != null)
		{
			var htmlString = "<html><head><title>"+windowName+"</title></head>"
				+ "<body leftmargin=0 topmargin=0 marginwidth=0 marginheight=0>"
				+ "<a href=javascript:window.close()><img src='" + picName + "' border='0' alt='창 닫기'></a>"
				+ "</body></html>";
			winHandle.document.open();
			winHandle.document.write(htmlString);
			winHandle.document.close();
		}
		if(winHandle != null) winHandle.focus();
	}

	// Email 형식 chk.
	function emailChk(fieldID)
	{
		var validFlag = false;
		re=/^[0-9a-zA-Z]([-_.]?[0-9a-zA-Z])*@[0-9a-zA-Z]([-_.]?[0-9a-zA-Z])*.[a-zA-Z]{2,3}$/i;
		validFlag = ( $F(fieldID).length<6 || !re.test($F(fieldID)) ) ? false : true;
		return validFlag;
	}


	/* 간단한 img resize */
	function resizeImg(imgEl, imgX, imgY) {
		if ( $(imgEl) && (!isNaN(imgX) && !isNaN(imgY)) ) {
			var imgXbo = false;

			if (imgEl.width > imgX) {
				imgEl.width = imgX;
				imgXbo = true;
			}
			if (imgEl.height > imgY) {
				if (imgXbo == true) imgEl.width = imgEl.width/(imgEl.height/imgY);
				imgEl.height = imgY;
			}
		}
	}

