function embed_flash(x,y,src) {
    var s = "";
    s = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';
    s+= ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0"';
    s+= ' width="'+x+'" height="'+y+'">';
    s+= '<param name="allowScriptAccess" value="always" />';
    s+= '<param name="allowFullScreen" value="false" />';
    s+= '<param name="movie" value="'+src+'" />';
    s+= '<param name="quality" value="high" />';
    s+= '<param name="menu" value="false" />';
    s+= '<param name="bgcolor" value="transparent" />';
    s+= '<param name="wmode" value="transparent" />';
    s+= '<embed src="'+src+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer"';
    s+= ' type="application/x-shockwave-flash" width="'+x+'" height="'+y+'" wmode="transparent" menu="false" bgcolor="transparent" style="margin:0px" allowScriptAccess="always"/>';
    s+= '</object>';
    document.write(s);
}

function popup_event()
{
	//document.domain = "www.callofchaos.com";
	var win = window.open('./_event_member.php','popup', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no, resizable=no,width=301,height=200'); 
	//win.focus(); 
}

function chkNumKey()
{
	if( (event.keyCode >= 48 && event.keyCode <= 57) || (event.keyCode >= 96 && event.keyCode <= 105) )
		event.returnValue = true
	else if( event.keyCode == 8 || event.keyCode == 9 ) // BS, TAB
		event.returnValue = true
	else if( event.keyCode == 16 || event.keyCode == 46 ) // SHIFT, DELETE
		event.returnValue = true
	else if( event.keyCode == 39 || event.keyCode == 37 ) //arrow key
		event.returnValue = true
	else if( event.keyCode == 109 ) //subtack
		event.returnValue = true
	else
		event.returnValue = false
}

var auto_focus = true;
var prev_value = null;
function next_input( obj, next_id )
{
    if ( obj.value.length >= 6 )
    {
        if ( auto_focus == true || obj.value != prev_value)
        {
            auto_focus = false;
            prev_value = obj.value;
            document.getElementById(next_id).focus();
        }
        return;
    } 
    auto_focus = true;
}

function popup_beginner_guide()
{
    var w = 910; 
    var h = 540;
    var pos_left = (screen.width) ? (screen.width-w)/2 : 0; 
    var pos_top = (screen.height) ? (screen.height-h)/2 : 0; 
    var option = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width='+w+',height='+h+',top='+pos_top+',left='+pos_left; 
    
    var win = window.open('beginner_guide.php','popup',option); 
}

function cc_manual_download()
{
    location.href = "?m=download&a=game";
}

function cc_easy_guide()
{
    popup_beginner_guide();
}

function cc_npds()
{
    $.modal($('#modal_npds'), {
      overlayCss: {
        backgroundColor: '#000',
        cursor: 'wait'
      },
      containerCss: {
        height: 490,
        width: 510,
        backgroundColor: '#000',
        border: '1px solid #ccc'
      }
    });
}

function desc_npds( flag )
{
    if( flag ) $('#modal_desc_npds').show();
    else $('#modal_desc_npds').hide();
}

var goSearch = function() {

    if ( $.trim($("#keyword").val()) == "" )
    {
		alert('검색어를 입력해 주세요.');
		return false;
	}

    if ( $('#keyword').length > 10 )
    {
		alert('검색어를 10byte 보다 작은 길이로 입력해 주세요.');
		return false;
	}

	return true;
}

function trim(str) {
    return str.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
}

function changebg_id( op, obj) {
    if( op )
        $("#input_id").css("background-position","0px 0px");
    else
    {
        if( trim(obj.value) == '' )
            $("#input_id").css("background-position","0px -30px");
    }
}

function changebg_pw( op, obj) {
    if( op )
        $("#input_pw").css("background-position","0px 0px");
    else
    {
        if( trim(obj.value) == '' )
            $("#input_pw").css("background-position","0px -60px");
    }
}

function logincheck() {
    if( trim( $("#input_id").val() ) === '' ) {
        alert("아이디를 입력해 주세요.");
        $("#input_id").focus();
        return false;
    }
    if( trim( $("#input_pw").val() ) === '' ) {
        alert("비밀번호를 입력해 주세요.");
        $("#input_pw").focus();
        return false;
    }
    return true;
}
