// IFRAME RESIZE ÇÔ¼ö ##################################################
function resizeFrame(iframeWindow, minWidth, minHeight, fixWidth, fixHeight) {
	if (!iframeWindow.name) return false;

	var iframeElement = document.getElementById(iframeWindow.name);
	var resizeWidth = 0;
	var resizeHeight = 0;

	minWidth = (minWidth ? parseInt(minWidth, 10) : 0);
	minHeight = (minHeight ? parseInt(minHeight, 10) : 0);
	fixWidth = (fixWidth ? parseInt(fixWidth, 10) : 0);
	fixHeight = (fixHeight ? parseInt(fixHeight, 10) : 0);

	if (document.all) { // ie
		if (iframeWindow.document.compatMode && iframeWindow.document.compatMode != 'BackCompat') {
			resizeWidth = iframeWindow.document.documentElement.scrollWidth;
			resizeHeight = iframeWindow.document.documentElement.scrollHeight;
		}
		else {
			resizeWidth = iframeWindow.document.body.scrollWidth;
			resizeHeight = iframeWindow.document.body.scrollHeight;
		}
	}
	else {
		resizeWidth = iframeWindow.document.body.scrollWidth;
		resizeHeight = iframeWindow.document.body.scrollHeight;
	}

	if (minWidth > 0 && resizeWidth < minWidth) resizeWidth = minWidth;			// ÃÖ¼Ò Æø
	if (minHeight > 0 && resizeHeight < minHeight) resizeHeight = minHeight;		// ÃÖ¼Ò ³ôÀÌ

	if (fixWidth > 0) resizeWidth = fixWidth;		// °íÁ¤ Æø
	if (fixHeight > 0) resizeHeight = fixHeight;	// °íÁ¤ ³ôÀÌ

	if (fixWidth > -1) iframeElement.style.width = resizeWidth + 'px';
	if (fixHeight > -1) iframeElement.style.height = resizeHeight + 'px';
}
// IFRAME RESIZE ÇÔ¼ö ##################################################

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 CreateBookmarkLink(urlStr) {
    title = "Miss Suh";
    url = urlStr;
    //FF
    if (window.sidebar) {
        window.sidebar.addPanel(title, url,"");
    }
    //IE
    else if( window.external ) {
        window.external.AddFavorite( url, title);
    }
    //Opera
    else if(window.opera && window.print) {
        return true;
    }
}


/////////////////

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_Delete2(tb,no){
	if(confirm("Delete?")){
		hidden_url('/common/db_exec.asp?mode=using_delete2&tbname='+tb+'&idx='+no);
	}
}
// ¾ÆÀÌµð,ºñ¹Ð¹øÈ£Ã£±â ###################################
function checkform_insertid(theForm)
{
  if (!(theForm.mem_name.value))
  {
	alert("ÀÌ¸§À» ½á ÁÖ¼¼¿ä!");
	theForm.mem_name.focus();
    return (false);
  }
 
  if((theForm.mem_email1.value=="")||(theForm.mem_email_dns.value=="" )){
		alert("µî·ÏÇÏ½Å ÀÌ¸ÞÀÏÀ» ÀÔ·ÂÇØ ÁÖ½Ê½Ã¿À.");
		theForm.mem_email1.focus();
		return (false);
	}
	var mem_email = theForm.mem_email1.value+"@"+theForm.mem_email_dns.value;
	if(!emailCheck(mem_email)){
  	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_email1.value=="")||(theForm.mem_email_dns.value=="" )){
		alert("µî·ÏÇÏ½Å ÀÌ¸ÞÀÏÀ» ÀÔ·ÂÇØ ÁÖ½Ê½Ã¿À.");
		theForm.mem_email1.focus();
		return (false);
	}
	var mem_email = theForm.mem_email1.value+"@"+theForm.mem_email_dns.value;
	if(!emailCheck(mem_email)){
  	return (false);
  }
  
  theForm.action="indb.asp"
  theForm.submit();
}

// È¸¿ø°¡ÀÔ ###################################################
function check_agree(fm) {
	var flag = true;
	
	if((fm.agree_1[0].checked != true)){
  	alert("ÀÌ¿ë¾à°ü¿¡ µ¿ÀÇ ÇÏ¼Å¾ß ÇÕ´Ï´Ù.");
  	return;
  }
	
	if((fm.agree_2[0].checked != true)){
  	alert("°³ÀÎÁ¤º¸º¸È£Á¤Ã¥¿¡ µ¿ÀÇ ÇÏ¼Å¾ß ÇÕ´Ï´Ù.");
  	return;
  }
	/*
  if(!fm.mem_name.value){
  	alert("È®ÀÎÇÏ½Ç ÀÌ¸§À» ÀÔ·ÂÇØÁÖ¼Å¾ß ÇÕ´Ï´Ù.");
  	fm.mem_name.focus();
  	return;
  }
  
  if(!fm.mem_email.value){
  	alert("È®ÀÎÇÏ½Ç ÀÌ¸ÞÀÏÀ» ÀÔ·ÂÇØÁÖ¼Å¾ß ÇÕ´Ï´Ù.");
  	fm.mem_email.focus();
  	return;
  }
  
  if(!emailCheck(fm.mem_email.value)){
  	return;
  }
  */
  fm.submit();
}

function mem_sendit(frm,uid)
{
	if(uid==1){
		//¾ÆÀÌµð
		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_email1.value=="")||(frm.mem_email_dns.value=="" )){
		alert("ÀÌ¸ÞÀÏÀ» ÀÔ·ÂÇØ ÁÖ½Ê½Ã¿À.");
		frm.mem_email1.focus();
		return;
	}
	var mem_email = frm.mem_email1.value+"@"+frm.mem_email_dns.value;
	if(!emailCheck(mem_email)){
  	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;}

// ·Î±×ÀÎ ##################################################
function gotoLogin() {
	location.href = "/member/login.asp?redirect="+escape(document.URL);
}

function gotoLogOut() {
	location.href = "/member/logout.asp";
}

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 check_login2(fm) {
	if(!fm.mem_name.value){
  	alert("ÀÌ¸§(Name) : ÇÊ¼ö»çÇ× ÀÔ´Ï´Ù.");
  	fm.mem_name.focus();
  	return;
  }
  
  if(!fm.order_no.value){
  	alert("ÁÖ¹®¹øÈ£(Order No) : ÇÊ¼ö»çÇ× ÀÔ´Ï´Ù.");
  	fm.order_no.focus();
  	return;
  }
  
  if((!fm.mem_hp1.value)||(!fm.mem_hp2.value)||(!fm.mem_hp3.value)){
  	alert("ÇÚµåÆù¹øÈ£ : ÇÊ¼ö»çÇ× ÀÔ´Ï´Ù.");
  	fm.mem_hp1.focus();
  	return;
  }
  
  fm.submit();
}

function changeIt(ImageToChange, ImageToShow) {
  if (document.images) { document[ImageToChange].src = ImageToShow; }
}
function bar(message) {
	if (document.images) { window.status = message; return true }
}
