<?php
function drk_add_online_meta_boxes(){
    add_meta_box(
        "post_metadata_online_id",
        "Is Online",
        "drk_meta_box_online",
        array("markets","venders",'tlg_channels','other_services','top_forums'),
        "normal",
        "default"
    );
}

add_action('add_meta_boxes','drk_add_online_meta_boxes');

function drk_meta_box_online( ) {
    global $post;
    $isOnline = get_post_meta($post->ID, '_isOnline', true);
    ?>
    <input id="_isOnline" name="_isOnline" type="checkbox" value="<?php echo $isOnline?>" <?php echo $isOnline > 0 ?  "checked": "" ?>  onclick="setIsOnline()"/>
    <script>
        function setIsOnline(){
            if(document.getElementById('_isOnline').checked){
                document.getElementById('_isOnline').value = 1;
            }else{
                document.getElementById('_isOnline').value = 0;
            }
        }
    </script>
    <?php
}

function drk_save_online_meta_boxes(){
    global $post;
    if(defined('DOING_AUTOSAVE') && DOING_AUTOSAVE){
		return;
	}
	update_post_meta($post->ID,"_isOnline", sanitize_key($_POST["_isOnline"]));
}
add_action("save_post", "drk_save_online_meta_boxes");