var main_imgs = ['total','notice','preview','event','news'];
var hidename = 'total';
var main_news = function(obj, showname) {
    for( var i in main_imgs )
        $('#img_' + main_imgs[i]).attr('src', $('#img_' + main_imgs[i]).attr('src').replace('on','off'));
    obj.src = obj.src.replace('off','on');
    hidename = showname;
    $.get("index_list.php", { b: showname },
        function(data){
            $('#main_list').html(data);
        });
}

var click_more = function() {
    if( hidename != 'total' )
        location.href = "?m=newsboard&a=" + (hidename == 'preview'?'update':hidename);
    else
        location.href = "?m=newsboard&a=notice";
}

var event_getCookie = function(name) {
    var nameOfCookie = name + "=";
    var x = 0;
    while ( x <= document.cookie.length ){
        var y = (x+nameOfCookie.length);
        if( document.cookie.substring( x, y ) == nameOfCookie){
            if((endOfCookie=document.cookie.indexOf( ";", y )) == -1)
                endOfCookie = document.cookie.length;
                return unescape( document.cookie.substring( y, endOfCookie));
        }
        x = document.cookie.indexOf( " ", x ) + 1;
        if(x == 0)
            break;
    }
    return "";
}

function event_setCookie( name, value, expiredays ){
    var todayDate = new Date();
    todayDate.setDate( todayDate.getDate() + expiredays );
    document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";"
}

var popup_new_item = function() {
    var w = 438; 
    var h = 610;
    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('new_item.php','popup',option); 
}
