function MM_openBrWindow(theURL) { //v2.0
  window.open(theURL,'result','width=800, height=800, top=50, left=100, scrollbars=yes, statusbar=yes, status=yes');
}

function gotoPoliceURL(url) {
	if (url != "") 
		window.open(url, target="_blank");
}
function OpenWindow(url,intWidth,intHeight) {
 window.open(url, "_blank", "width="+intWidth+",height="+intHeight+",resizable=1,scrollbars=1");
}
function OpenLocation(url,intWidth,intHeight) {
 window.open(url, "_blank", "width="+intWidth+",height="+intHeight+",resizable=1,scrollbars=0");
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function Toggle() {
	// Try to get the FCKeditor instance, if available.
	var oEditor ;
	if ( typeof( FCKeditorAPI ) != 'undefined' )
		oEditor = FCKeditorAPI.GetInstance( '_DataFCKeditor' ) ;

	// Get the _Textarea and _FCKeditor DIVs.
	var eTextareaDiv	= document.getElementById( '_Textarea' ) ;
	var eFCKeditorDiv	= document.getElementById( '_FCKeditor' ) ;

	// If the _Textarea DIV is visible, switch to FCKeditor.
	if ( eTextareaDiv.style.display != 'none' ) {
		// If it is the first time, create the editor.
		if ( !oEditor ) {
			CreateEditor() ;
		}
		else {
			// Set the current text in the textarea to the editor.
			oEditor.SetHTML( document.getElementById('_DataTextarea').value ) ;
		}

		// Switch the DIVs display.
		eTextareaDiv.style.display = 'none' ;
		eFCKeditorDiv.style.display = '' ;

		// This is a hack for Gecko 1.0.x ... it stops editing when the editor is hidden.
		if ( oEditor && !document.all ) {
			if ( oEditor.EditMode == FCK_EDITMODE_WYSIWYG )
				oEditor.MakeEditable() ;
		}

		// Switch the TEXTAREAs disablable.
		document.getElementById('_DataFCKeditor').disabled = false;
		document.getElementById('_DataTextarea').disabled = true;
	}
	else {
		// Set the textarea value to the editor value.
		document.getElementById('_DataTextarea').value = oEditor.GetXHTML() ;

		// Switch the DIVs display.
		eTextareaDiv.style.display = '' ;
		eFCKeditorDiv.style.display = 'none' ;

		// Switch the TEXTAREAs disablable.
		document.getElementById('_DataFCKeditor').disabled = true;
		document.getElementById('_DataTextarea').disabled = false;
	}
}

function CreateEditor() {
	// Copy the value of the current textarea, to the textarea that will be used by the editor.
	document.getElementById('_DataFCKeditor').value = document.getElementById('_DataTextarea').value ;

	// Automatically calculates the editor base path based on the _samples directory.
	// This is usefull only for these samples. A real application should use something like this:
	// oFCKeditor.BasePath = '/fckeditor/' ;	// '/fckeditor/' is the default value.
	var sBasePath = document.location.pathname.substring(0,document.location.pathname.lastIndexOf('_samples')) ;
	sBasePath = "/include/fckeditor/"

	// Create an instance of FCKeditor (using the target textarea as the name).
	var oFCKeditor = new FCKeditor( '_DataFCKeditor' ) ;
	oFCKeditor.BasePath = sBasePath ;
	oFCKeditor.Width = '100%' ;
	oFCKeditor.Height = document.getElementById( '_DataTextarea' ).rows * 15 + 50 ;
	oFCKeditor.ToolbarSet = "Basic3"
	oFCKeditor.ReplaceTextarea() ;
}

function PrepareSave() {
	// If the textarea isn't visible update the content from the editor.
	if ( document.getElementById( '_Textarea' ).style.display == 'none' ) {
		var oEditor = FCKeditorAPI.GetInstance( '_DataFCKeditor' ) ;
		document.getElementById( '_DataTextarea' ).value = oEditor.GetXHTML() ;
	}
}
//////////End of FCKeditor related


/////////////////
function CopyClipBoard(CopyStr) {
  // IE
  if (window.clipboardData) { 
   window.clipboardData.setData("Text", CopyStr);
   alert("RSS URL이 복사되었습니다.");
  // FF
  } else if (window.netscape) { 
   try {
    netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
    alert("RSS URL이 복사되었습니다.");
   
    var copytext = CopyStr; 

    var str   = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
    if (!str) return false;

    str.data  = copytext;

    var trans = Components.classes["@mozilla.org/widget/transferable;1"].createInstance(Components.interfaces.nsITransferable);
    if (!trans) return false;

    trans.addDataFlavor("text/unicode");
    trans.setTransferData("text/unicode", str, copytext.length * 2);

    var clipid = Components.interfaces.nsIClipboard;
    var clip   = Components.classes["@mozilla.org/widget/clipboard;1"].getService(clipid);
    if (!clip) return false;

    clip.setData(trans, null, clipid.kGlobalClipboard);
   } catch(e) {
    alert("Error:Set this value to True, the setting signed.applets.codebase_principal_support.\n"+e);
    return;
   }
  } 
 }
/////////////////

function self_url(turl)
{
	self.location = turl;
}

function hidden_url(turl)
{
	hframe.location = turl;
}

function history_back()
{
	history.back();
}

// 문자열 공백제거 함수 ##################################################
// Ex) str = "    테 스   트   ".stripspace(); => str = "테스트";
String.prototype.stripspace = function() {
	return this.replace(/ /g, "");
}

// 공백 확인 ##################################################
function checkEmpty(obj) {
	if (obj.value.stripspace() == "") {
		return true;
	}
	else {
		return false;
	}
}

// Radio(CheckBox) 설정값 가져오기 ##################################################
function getRadioVal(obj) {
	var i, value = "";

	if (obj) {
		if (typeof(obj.length) == "undefined") {
			if (obj.checked) {
				value = obj.value;
			}
		}
		else {
			for (i=0; i<obj.length; i++) {
				if (obj[i].checked) {
					value = obj[i].value;
					break;
				}
			}
		}
	}
	return value;
}

function zipcode(cval)
{
window.open('/common/search_zipcode.asp?divtext='+cval,'', 'width=600, height=400,left=400,top=400, toolbar=no, location=no, directories=no, status=no, menubar=no, resizable=no, scrollbars=no, copyhistory=no');
}

function upload_photo(txt,idx)
{
window.open('/common/upload_photo.asp?table_nm='+txt+'&idx='+idx,'', 'width=500, height=150,left=400,top=400, toolbar=no, location=no, directories=no, status=no, menubar=no, resizable=no, scrollbars=no, copyhistory=no')
}

/***
사용법 : Seq_Chg(tbname,idx,seq_type,opt)
***/
function Seq_Chg(tbname,idx,seq_type,opt)
{
	hidden_url('/common/db_exec.asp?mode=seq&tbname='+tbname+'&idx='+idx+'&seq_type='+seq_type+'&opt='+opt);
}
function Seq_Chg_board(tbname,idx,seq_type)
{
	hidden_url('/common/db_exec.asp?mode=seq_board&tbname='+tbname+'&idx='+idx+'&seq_type='+seq_type);
}
function Using_Delete(tb,no,opt){
	if(confirm("Delete?")){
		hidden_url('/common/db_exec.asp?mode=using_delete&tbname='+tb+'&idx='+no+'&opt='+opt);
	}
}
function Using_Delete1(tb,no,opt){
	if(confirm("Delete?")){
		hidden_url('/common/db_exec.asp?mode=using_delete1&tbname='+tb+'&idx='+no+'&opt='+opt);
	}
}
function Using_Delete2(tb,no,opt){
	if(confirm("Delete?")){
		hidden_url('/common/db_exec.asp?mode=using_delete2&tbname='+tb+'&idx='+no+'&opt='+opt);
	}
}
function handle_change(tb,no){
	if(confirm("변경하시겠습니까?")){
		hidden_url('/common/db_exec.asp?mode=handle_change&tbname='+tb+'&idx='+no);
	}
}
// 아이디,비밀번호찾기 ###################################
function checkform_insertid(theForm)
{
  if (!(theForm.mem_name.value))
  {
	alert("이름을 써 주세요!");
	theForm.mem_name.focus();
    return (false);
  }
  
  if (!(theForm.mem_email.value))
  {
	alert("등록하신 이메일을 써 주세요~");
	theForm.mem_email.focus();
    return (false);
  }
  
  if(!emailCheck(theForm.mem_email.value)){
  	return (false);
  }
  
  theForm.action="indb.asp"
  theForm.submit();
}

function checkform_insertpw(theForm)
{
	if (!(theForm.mem_name.value))
  {
	alert("이름을 써 주세요!");
	theForm.mem_name.focus();
    return (false);
  }
	
  if (!(theForm.mem_id.value))
  {
	alert("아이디를 써 주세요!");
	theForm.mem_id.focus();
    return (false);
  }
  
  if (!(theForm.mem_email.value))
  {
	alert("등록하신 이메일을 써 주세요~");
	theForm.mem_email.focus();
    return (false);
  } 
  
  if(!emailCheck(theForm.mem_email.value)){
  	return (false);
  }
  
  theForm.action="indb.asp"
  theForm.submit();
}

// 운영자가입 ###################################################
function check_login(fm) {
	if(!fm.mem_id.value){
  	alert("ID : 필수사항 입니다.");
  	fm.mem_id.focus();
  	return;
  }
  
  if(!fm.mem_pwd.value){
  	alert("패스워드 : 필수사항 입니다.");
  	fm.mem_pwd.focus();
  	return;
  }
  
  fm.submit();
}

function mem_sendit(frm,uid)
{
	if(uid==1){
		if(frm.agree.checked==false){
	  	alert("이용약관에 동의 하셔야 합니다.");
	  	return;
	  }
		
		//아이디
		if(frm.mem_id.value=="" ){
			alert("희망하시는 아이디를 입력해 주십시오.");
			frm.mem_id.focus();
			return;
		}
		//이름
		if(frm.mem_name.value=="" ){
			alert("이름을 입력해 주십시오.");
			frm.mem_name.focus();
			return;
		}
	}
	//비밀번호
	if(frm.mem_pwd.value=="" ){
		alert("비밀번호를 입력해 주십시오.");
		frm.mem_pwd.focus();
		return;
	}
	//비밀번호확인
	if(frm.mem_pwd1.value=="" ){
		alert("비밀번호를 다시한번 입력해 주십시오.");
		frm.mem_pwd1.focus();
		return;
	}
	//비밀번호 일치확인
	if(frm.mem_pwd.value != frm.mem_pwd1.value){
		alert("비밀번호를 다시 확인해 주세요.");
		frm.mem_pwd.focus();
		return;
	}
	//이메일
	if(frm.mem_email.value=="" ){
		alert("이메일을 입력해 주십시오.");
		frm.mem_email.focus();
		return;
	}
	
	if(!emailCheck(frm.mem_email.value)){
  	return;
  }
	
	//연락처
	if(frm.mem_hp1.value=="" || frm.mem_hp2.value=="" || frm.mem_hp3.value==""){
		alert("핸드폰번호를 입력해 주십시오.");
		frm.mem_hp1.focus();
		return;
	}
	//주소
	if(frm.mem_zip.value=="" ){
		alert("주소를 입력해 주십시오.");
		frm.mem_zip.focus();
		return;
	}
	if(frm.mem_addr1.value=="" ){
		alert("주소를 입력해 주십시오.");
		frm.mem_addr1.focus();
		return;
	}
	if(uid==1){
		if(frm.Id_CK.value=="" ){
			alert("아이디 중복확인을 해주십시오.");
			return;
		}
	}
	frm.submit();
}

function tem_search_id(fm)
{
	var sid = fm.mem_id.value;
	if (Check(sid) < 4)
	{
		fm.mem_id.focus();
		alert("아이디를 입력하세요. (4-12자).");
	}
	else {
		if(CheckCharNumEng(sid) == false) {
			alert("아이디는 영문과 숫자로만 입력할 수 있습니다.");
			fm.mem_id.focus();
			fm.mem_id.select();
			return;}
		else {

			if(CheckNum(sid) == true) {
				alert("아이디는 숫자로만 입력할 수 없습니다.");
				fm.mem_id.focus();
				fm.mem_id.select();
				return;}
			else
			window.open('/common/search_id.asp?tablenm=member&sid='+sid,'아이디중복검사', 'width=350, height=200,left=400,top=400, toolbar=no, location=no, directories=no, status=no, menubar=no, resizable=no, scrollbars=no, copyhistory=no');
			}
	}
}

function CheckNum(Data) {
	var nochk='01234567890'

	for (i=0; i<Data.length; i++){
	if(nochk.indexOf(Data.substring(i,i+1)) < 0) return false;
	else return true;
	}//for 종료
}

function CheckCharNumEng(Data) {
	var nochk='01234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';

	for (i=0; i<Data.length; i++){
	if(nochk.indexOf(Data.substring(i,i+1)) < 0) 		
	{
		return false;
		}
	}//for 종료
}

function Check(keyword) 
{
	var st_num, key_len;
	st_num = keyword.indexOf(" ");	
	while (st_num != -1)
	{
		keyword = keyword.replace(" ", "");
		st_num  = keyword.indexOf(" ");
	}
	key_len=keyword.length;
	return key_len;
}

function formResize(obj,value) {
	if(value<0 && Math.abs(value)>=Math.abs(obj.rows)) {
		alert("´�񡂙O¼�½4ϴ׮");
	} else {
		obj.rows += value;
	}
}

function chkCapsLock(e, id) {
	var myKeyCode = 0;
	var myShiftKey = false;
	var myMsg = '<Caps Lock>L őn V½4ϴ׮';
	var obj = id ? document.getElementById(id) : '';
	var capsLock = false;

	if(document.all) {
		myKeyCode = e.keyCode;
		myShiftKey = e.shiftKey;
	}
	else {
		myKeyCode = e.which;
		myShiftKey = (myKeyCode==16) ? true : false;
	}

	if((myKeyCode>=65 && myKeyCode<=90) && !myShiftKey) { capsLock = true; }
	else if((myKeyCode>=97 && myKeyCode<=122) && myShiftKey) { capsLock = true; }

	if(capsLock) {
		if(obj) {
			myMsg = myMsg.replace(/[<]/gi,'&lt;');
			myMsg = myMsg.replace(/[>]/gi,'&gt;');
			myMsg = myMsg.replace(/[\n]/gi,'<br />');
			obj.innerHTML = myMsg;
		}
		else window.alert(myMsg);
	}
	else {
		if(obj) obj.innerHTML = '';
	}
}

function rbar (st,col) { st.style.backgroundColor = '#F0F3F4';return;}
function cbar (st) { st.style.backgroundColor = '';return;}
