/*
 * ¿Ã¹Ù¸¥ ÀÌ¸ÞÀÏ ÀÎÁö °Ë»ç
 */
function is_true_email( email )
{
	email_check =/^[_a-zA-Z0-9-]+@[\._a-zA-Z0-9-]+\.[a-zA-Z]+$/;

	if( !email_check.test( email ) )
	{
		return false
	}

	return true
}

function open_window( filename, option, win_name ) 
{
	if( !win_name )
	{
		win_name = "echosting_new"
	}

	win = window.open( filename, win_name, option );

	return win
}

function id_open_win( id, filename, option )
{

	if( !option )
	{
		option = 'width=398,height=300,scrollbars=no'
	}

	href = 'id=' + id
	filename += "?" + href

	open_window( filename, option );

}


/*
 * ¼îÇÎ¸ô ½ÅÃ» -> ½Ç¸í ÀÎÁõ Ã¢ ¶ç¿ì±â
 */
function member_modify( filename )
{
	
	width = '';
	height = '';

	if( !width )
	{
		width = 390;
	}

	if( !height )
	{
		height = 250;
	}

        option = "tollbar=no, location=no, directories=no, status=no," +
        "menubar=no, scrollbars=auto, resizable=no," +
        "width=" + width + ", height=" + height + ", top=200, left=300"

        win_name = "echosting_member_modify"

        open_window( filename, option, win_name )
}

function good_mall_pop()
{
	option = "tollbar=no, location=no, directories=no, status=no," +
	"menubar=no, scrollbars=no, resizable=no," +
	"width=640, height=486, top=200, left=300"

	filename = "/php/marketing_good_pop/marketing_good_pop.php"

	open_window( filename, option )
}

function login_pop( mode, href )
{
        option = "tollbar=no, location=no, directories=no, status=no," +
	        "menubar=no, scrollbars=no, resizable=no," +
	        "width=601, height=418, top=200, left=300 "
	
	if( !href )
	{
		href = '';
	}

        if ( mode == 'logout')
	{
		document.location = 'https://echosting.cafe24.com/php/login/login_a.php?mode=logout'
	}
	else
	{
		filename = 'https://echosting.cafe24.com/php/login/login.php' + href
        	open_window( filename, option )
	}
}

function dormancy_pop( mall_id )
{
        option = "tollbar=no, location=no, directories=no, status=no," +
	        "menubar=no, scrollbars=no, resizable=no," +
	        "width=601, height=357, top=200, left=300 "

	filename = '/php/dormancy/dor_1.php?mall_id=' + mall_id
	open_window( filename, option )
}

function lost_id_pw()  //¾ÆÀÌµð&ºñ¹Ð¹øÈ£Ã£±â @add ¹Ú´ö±æ 2007-01-12
{
        option = "tollbar=no, location=no, directories=no, status=no," +
                "menubar=no, scrollbars=yes, resizable=no," +
                "width=780, height=500, top=200, left=300 "
        
        //filename = 'http://test-udb.simplexi.com/src/php/idpass/cafe24IPSearch.php'
        //filename = 'https://udb.simplexi.com/src/php/idpass/cafe24IPSearch.php'   //ÀÛ¾÷ÈÄ ÀÌ°É·Î ±³Ã¼
        filename = 'https://user.cafe24.com/idsearch.php'   //ÀÛ¾÷ÈÄ ÀÌ°É·Î ±³Ã¼
	open_window( filename, option ,"id_pw_ck")
}

function lost_pw()
{
        option = "tollbar=no, location=no, directories=no, status=no," +
                "menubar=no, scrollbars=yes, resizable=no," +
                "width=780, height=500, top=200, left=300 "
        
        //filename = 'https://echosting.cafe24.com/php/lost_pw/lost_pw.php'
        filename = 'https://user.cafe24.com/pwsearch.php'
	
        open_window( filename, option )
}

function lost_id()
{
        option = "tollbar=no, location=no, directories=no, status=no," +
                "menubar=no, scrollbars=no, resizable=no," +
                "width=400, height=350, top=200, left=300 "

        filename = 'https://echosting.cafe24.com/php/lost_id/lost_id.php'
        open_window( filename, option )
}


function change_passwd()
{
        option = "tollbar=no, location=no, directories=no, status=no," +
                "menubar=no, scrollbars=yes, resizable=no," +
                "width=780, height=500, top=200, left=300 "

        //filename = '/php/change_passwd/change_passwd.php'
        filename = 'https://user.cafe24.com/pwchange.php'
	open_window( filename, option )
}

function pw_hint()
{
        option = "tollbar=no, location=no, directories=no, status=no," +
                "menubar=no, scrollbars=no, resizable=no," +
                "width=400, height=262, top=200, left=300 "

        filename = '/php/pw_hint/pw_hint_1.php'
        open_window( filename, option )
}

function go_help( mode, no, subject )
{
        option = "tollbar=no, location=no, directories=no, status=no," +
                "menubar=no, scrollbars=yes, resizable=no," +
                "width=950, height=525, top=200, left=300 "

        if( mode == 'help_img' )
        {
        	filename = '/help/image/userimages/0409081152156695/Image10.jpg'
        } else {
        	filename = '/go_help.php?mode=' + mode + '&no=' + no + '&subject=' + subject
        }
        open_window( filename, option )
}

function my_info_change_pop()
{

        option = "tollbar=no, location=no, directories=no, status=no," +
                "menubar=no, scrollbars=no, resizable=no," +
                "width=400, height=160, top=200, left=300 "

        filename = "/php/my/modify_succ_pop.php"

        open_window( filename, option )

}

function result_url()
{

 opener.location.reload();
 alert('¼º°ø');
 window.close()
}


function is_str_check( mode, str, min_check, max_check )
{
	var str_length = str.length

	if( !str_length )
	{
		return 1
	}

	if( str_length < min_check && min_check )
	{
		return 3
	}

	if( str_length > max_check && max_check )
	{
		return 4
	}

	if( !mode )
	{
		mode = 10
	}

	for( var j = 0; j < str_length; j++ )
	{
		s_str = str.substring( j, j + 1 )

		str_check = input_check( s_str )

		if( !( str_check & mode ) )
		{
			return 2
		}

	}

	return false
}

function input_check( check_string )
{
	var char_ASCII = check_string.charCodeAt(check_string.length-1);

	//¼ýÀÚ
	if( char_ASCII >= 48 && char_ASCII <= 57 )
		return 1;

	//¿µ¾î
	else if( ( char_ASCII >= 65 && char_ASCII <= 90 )
			|| ( char_ASCII >= 97 && char_ASCII <= 122 ) )
		return 2;

	// Æ¯¼ö±âÈ£
	else if( ( char_ASCII >= 33 && char_ASCII <= 47 )
			|| ( char_ASCII >= 58 && char_ASCII <= 64 )
			|| ( char_ASCII >= 91 && char_ASCII <= 96 )
			|| ( char_ASCII >= 123 && char_ASCII <= 126 ) )
		return 4;

	// °ø¹é
	else if( char_ASCII == 32 )
		return 8;

	//ÇÑ±Û
	else if( ( char_ASCII >= 12592 ) || ( char_ASCII <= 12687 ) )
		return 16;

	else 
		return 0;
}

function str_mix( mode )
{
	msg = ''

	str_arr = new Array()
	str_arr[1] = "¼ýÀÚ"
	str_arr[2] = "¿µ¹®"
	str_arr[4] = "Æ¯¼ö±âÈ£"
	str_arr[8] = "°ø¹é"
	str_arr[16] = "ÇÑ±Û"

	for( val in str_arr )
	{
		if( mode & val )
		{
			if( msg )
			{
				msg += " + "
			}

			msg += str_arr[val]
		}
	}

	if( msg ) 
	{
		return msg
	}

	return false
}

function board_checks(form)
{
	if(!form.writer_name.value)
	{
		alert("ÀÌ¸§À» ÀÔ·ÂÇÏ¼¼¿ä!");
		form.writer_name.focus();
		return false;
	}
	if(!form.passwd.value)
	{
		alert("¾ÏÈ£¸¦ ÀÔ·ÂÇÏ¼¼¿ä!");
		form.passwd.focus();
		return false;
	}
	if(!form.subject.value)
	{
		alert("Á¦¸ñÀ» ÀÔ·ÂÇÏ¼¼¿ä!");
		form.subject.focus();
		return false;
	}
	if(!form.content.value)
	{
		alert("³»¿ëÀ» ÀÔ·ÂÇÏ¼¼¿ä!");
		form.content.focus();
		return false;
	}
}


function notice_div_display(flag) {  
    if(flag=="1") {
        notice_div.style.display='';
    }
    else {
        notice_div.style.display='none';
    }
}

function my_account()
{
        option = "tollbar=no, location=no, directories=no, status=no," +
                "menubar=no, scrollbars=yes, resizable=no," +
                "width=780, height=500, top=200, left=300 "

        filename = 'https://user.cafe24.com/account.php'
        open_window( filename, option )
}


/**
 *  3°³¿ù°£ ºñ¹Ð¹øÈ£ ¹Ìº¯°æ½Ã ÆäÀÌÁö¿¡¼­ ¾²ÀÌ´Â ½ºÅ©¸³Æ®
 */
function chkForm1 ( e ) {
	if( !e ) return;
	stopEvent( e );

	var f = e.srcElement||e.target;

	if( !f || !f.nodeType || ( f.tagName.toUpperCase() != 'FORM' ) ) return;

	var pwd = f.nowPwd.value || '';
	var newPwd = f.newPwd.value || '';
	var newRePwd = f.newRePwd.value || '';


	if ( !pwd ) return alert( 'ÇöÀç ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇØ ÁÖ¼¼¿ä' );
	if ( !newPwd ) return alert( '»õ ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇØ ÁÖ¼¼¿ä' );
	if ( !newRePwd ) return alert( '»õ ºñ¹Ð¹øÈ£ È®ÀÎÀ» ÀÔ·ÂÇØ ÁÖ¼¼¿ä' );

	if ( pwd == newPwd ) return alert( '»õ ºñ¹Ð¹øÈ£¿Í ±âÁ¸ ºñ¹Ð¹øÈ£°¡ µ¿ÀÏÇÕ´Ï´Ù.' );
	if ( newPwd != newRePwd ) return alert( '»õ ºñ¹Ð¹øÈ£¿Í »õ ºñ¹Ð¹øÈ£ È®ÀÎÀÌ ÀÏÄ¡ÇÏÁö ¾Ê½À´Ï´Ù. \n\n ´Ù½Ã È®ÀÎÇÏ½Ã°í ÀÔ·ÂÇØ ÁÖ¼¼¿ä.' );

	if ( !isPwdChk ( newPwd , f.sUserId.value ) ) {
		f.newPwd.value = '';
		f.newRePwd.value = '';
		f.newPwd.focus();
		return false ;
	}

	f.submit( e );

}



/*------------------------------------------------------------------*/



function stopEvent( e ) {
	if( typeof e.preventDefault != 'function' ) e.returnValue = false;
	else e.preventDefault();
	if( typeof e.stopPropagation != 'function' ) e.cancelBubble = true;
	else e.stopPropagation();

	return false;
}

/*---Check----------------------------------------------------------------------*/

function isPwdChk ( pw , id ) {
	if ( !pw || !id ) return;

	//
	var cnt = 0;
	var chkPatten1 = /^[a-z][a-zA-Z0-9]{7,15}$/i;
	var chkPatten2 = /^[\x00-\x1f]|[\x21-\x2f]|[\x3a-\x40]|[\x5b-\x60]|[\x7b-\x7f]$/;
	var chkPatten3 = /\d/;

	//
	var cnt2 = 1;
	var cnt3 = 1;
    var next_pass;
	var tempw1;
	var tempw2;
	var temp_p;

	if ( pw.length < 8 ) {
		alert( 'ºñ¹Ð¹øÈ£´Â8~16ÀÚÀÇ ¿µ¹®/¼ýÀÚ¸¸ »ç¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù.' );
		return false;
	}
    if ( pw.substr(0,1) <= "9" && pw.substr(0,1) >= "0" ) {
		alert('ºñ¹Ð¹øÈ£ Ã¹ÀÚ¸®´Â ¿µ¹®ÀÌ¾î¾ßÇÕ´Ï´Ù.');
		return false;
	}
	if ( chkPatten2.test(pw) ) {
		alert( "ºñ¹Ð¹øÈ£´Â Æ¯¼ö¹®ÀÚ»ç¿ëÀÌ ºÒ°¡´ÉÇÕ´Ï´Ù." );
		return false;
	}
	if ( !chkPatten3.test(pw) || !chkPatten1.test(pw) ) {
		alert( "ºñ¹Ð¹øÈ£´Â8~16ÀÚÀÇ ¿µ¹®/¼ýÀÚ¸¸ »ç¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù." );
		return false;
	}
	if (pw == id) {
		alert( 'ºñ¹Ð¹øÈ£´Â ¾ÆÀÌµð¿Í µ¿ÀÏÇÏ°Ô »ç¿ëÀÌ ºÒ°¡´É ÇÕ´Ï´Ù.');
		return false;
	}

	for(i=0;i < pw.length;i++) {
		tempw1		= pw.charAt(i);
		next_pass	= (parseInt(tempw1.charCodeAt(0)))+1;
		temp_p		= pw.charAt(i+1);
		tempw2		= (parseInt(temp_p.charCodeAt(0)));

		if (tempw2 == next_pass) 	cnt2 = cnt2 + 1;
		else cnt2 = 1;

		if (tempw1 == temp_p) cnt3 = cnt3 + 1;
		else cnt3 = 1;

		if (cnt2 > 3) break;
		if (cnt3 > 2) break;
	}

	if (cnt2 > 3) {
		alert( 'ºñ¹Ð¹øÈ£´Â 4ÀÚÀÌ»ó ¿¬¼ÓµÈ ¹®ÀÚ¸¦ »ç¿ëÇÒ ¼ö ¾ø½À´Ï´Ù.');
		return false;
	}
	if (cnt3 > 2) {
		alert( 'ºñ¹Ð¹øÈ£´Â µ¿ÀÏ¹®ÀÚ¸¦ 3ÀÚÀÌ»ó ¹Ýº¹À¸·Î »ç¿ëÇÒ ¼ö ¾ø½À´Ï´Ù.');
		return false;
	}

    return true;
}


function chkCapsLock(e){

	var evt = window.event || e;

	var myKeyCode = 0;
	var myShiftKey = false;

	if ( document.all ) {
		myKeyCode=evt.keyCode;
		myShiftKey=evt.shiftKey;
    // Netscape 4
	} else if ( document.layers ) {
		myKeyCode=evt.which;
		myShiftKey=( myKeyCode == 16 ) ? true : false;

	// Netscape 6
	} else if ( document.getElementById ) {
		myKeyCode=evt.which;
		myShiftKey=( myKeyCode == 16 ) ? true : false;
	}

	if ( ( myKeyCode >= 65 && myKeyCode <= 90 ) && !myShiftKey ) return alert( "CapsLockÀÌ ÄÑÁ®ÀÖ½À´Ï´Ù." );
	else if ( ( myKeyCode >= 97 && myKeyCode <= 122 ) && myShiftKey ) return alert( "CapsLockÀÌ ÄÑÁ®ÀÖ½À´Ï´Ù." );
}
/**
 *  ³¡
 */
