/* if the current pages has a parent, i.e. we are on a subpage */
    $parent_title = get_the_title($post->post_parent);
    //$children = wp_list_pages("title_li=&include=".$post->post_parent."&echo=0"); // list the parent page
    $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0"); // append the list of children pages to the same $children variable

/* else if the current page does not have a parent, i.e. this is a top level page */
else {
    $parent_title = get_the_title($post->ID);
    //$children = wp_list_pages("title_li=&include=".$post->ID."&echo=0");
    $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0"); // form a list of the children of the current page

/* if we ended up with any pages from the queries above */
// Below echos out both the children and header of the page with link
if ($children) { ?>

     <ul class="submenu">
	 <a href="<?php echo get_permalink($post->post_parent) ?>"><?php echo $parent_title;?></a>
     <?php echo $children; /*print list of pages*/ ?>
<?php } ?>