function ecpt_posttype_manager()
{
    global $wpdb;
    global $ecpt_db_name;
    global $ecpt_base_dir;
    ?>
	<div class="wrap">
	<div id="ecpt-wrap">
	<?php 
    if ($_GET['post-type-added']) {
        ?>
		<div class="updated fade">
			<p>Post type added. <!--You should update your <a href="options-permalink.php">permalinks</a> now--></p>
		</div>
	<?php 
    }
    ?>
	
	
	<?php 
    if ($_GET['posttype-edit']) {
        ?>
	<h2>
		Edit Post Types - 
		<a href="admin.php?page=easy-content-types/easy-content-types.php?posttypes" title="Go Back">Go Back</a>
	</h2>
	<?php 
    } else {
        ?>
	<h2>Easy Custom Post Types</h2>
	<?php 
    }
    ?>
		
		<table class="wp-list-table widefat fixed posts">
			<thead>
				<tr>
					<th>Name</th>
					<th>Labels</th>
					<th>Slug</th>
					<?php 
    if ($_GET['posttype-edit']) {
        ?>
					<th>Position</th>
					<?php 
    }
    ?>
					<th>Attributes</th>
					<?php 
    if ($_GET['posttype-edit']) {
        ?>
					<th style="width: 350px!important;">Menu Icon</th>
					<?php 
    } else {
        ?>
					<th>Menu Icon</th>
					<?php 
    }
    if (!$_GET['posttype-edit']) {
        ?>
					<th>Template File</th>
					<?php 
    }
    if ($_GET['posttype-edit']) {
        ?>
					<th>Update</th>
					<?php 
    } else {
        ?>
					<th>Edit</th>
					<?php 
    }
    ?>
				</tr>	
			</thead>
			<tfoot>
				<tr>
					<th>Name</th>
					<th>Labels</th>
					<th>Slug</th>
					<?php 
    if ($_GET['posttype-edit']) {
        ?>
					<th>Position</th>
					<?php 
    }
    ?>
					<th>Attributes</th>
					<th>Menu Icon</th>
					<?php 
    if (!$_GET['posttype-edit']) {
        ?>
					<th>Template File</th>
					<?php 
    }
    if ($_GET['posttype-edit']) {
        ?>
					<th>Update</th>
					<?php 
    } else {
        ?>
					<th>Edit</th>
					<?php 
    }
    ?>
				</tr>	
			</tfoot>
			<tbody>
				<?php 
    $i = 0;
    // editing a posttype
    if ($_GET['posttype-edit']) {
        foreach ($wpdb->get_results("SELECT * FROM " . $ecpt_db_name . " WHERE id='" . $_GET['posttype-edit'] . "';") as $key => $posttype) {
            ?>
			
							<tr <?php 
            if (ecpt_is_odd($i)) {
                echo 'class="alternate"';
            }
            ?>
>
								<td>
									<span><strong>Name</strong></span><br/>
									<input type="text" name="posttype-name" class="ecpt-text no-float" id="posttype-name" value="<?php 
            echo $posttype->name;
            ?>
" /><br/>
									<p>This is the name that will be used to query the post type from the database. Keep it a single word and simple.</p>
								</td>
								<td>
									<span><strong>Single</strong></span><br/>
									<input type="text" name="posttype-singlular" class="ecpt-text no-float" id="posttype-singlular" value="<?php 
            echo $posttype->singular_name;
            ?>
" /><br/>
									
									<p>The single label is used to refer to single post type items, such as "Add New Book".</p>
									
									<span><strong>Plural</strong></span><br/>
									<input type="text" name="posttype-plural" class="ecpt-text no-float" id="posttype-plural" value="<?php 
            echo $posttype->plural_name;
            ?>
" />
									<p>The plural label is used to refer to plural post type items, such as "Search Books".</p>
									
								</td>
								<td>
									<span><strong>Slug</strong></span><br/>
									<input type="text" name="posttype-slug" class="ecpt-text no-float" id="posttype-slug" value="<?php 
            echo $posttype->slug;
            ?>
" />
								</td>
								<td>
									<span><strong>Menu Position</strong></span><br/>
									<input type="text" name="posttype-position" class="ecpt-text no-float" id="posttype-position" value="<?php 
            echo $posttype->menu_position;
            ?>
" />
								</td>
								<td>
									<div class="ecpt-atts">
									<?php 
            if ($posttype->has_archive == 1) {
                $checked = 'checked="checked"';
            }
            echo '<div><label for="' . $posttype->has_archive . '">Archives</label>';
            echo '<input type="checkbox" name="' . $posttype->has_archive . '" id="posttype-has_archive"' . $checked . '/><br/></div>';
            $checked = '';
            if ($posttype->title == 1) {
                $checked = 'checked="checked"';
            }
            echo '<div><label for="' . $posttype->title . '">Title</label>';
            echo '<input type="checkbox" name="' . $posttype->title . '" id="posttype-title"' . $checked . '/><br/></div>';
            $checked = '';
            if ($posttype->editor == 1) {
                $checked = 'checked="checked"';
            }
            echo '<div><label for="' . $posttype->editor . '">Editor</label>';
            echo '<input type="checkbox" name="' . $posttype->editor . '" id="posttype-editor"' . $checked . '/><br/></div>';
            $checked = '';
            if ($posttype->author == 1) {
                $checked = 'checked="checked"';
            }
            echo '<div><label for="' . $posttype->author . '">Author</label>';
            echo '<input type="checkbox" name="' . $posttype->author . '" id="posttype-author"' . $checked . '/><br/></div>';
            $checked = '';
            if ($posttype->thumbnail == 1) {
                $checked = 'checked="checked"';
            }
            echo '<div><label for="' . $posttype->thumbnail . '">Thumbnail</label>';
            echo '<input type="checkbox" name="' . $posttype->thumbnail . '" id="posttype-thumbnail"' . $checked . '/><br/></div>';
            $checked = '';
            if ($posttype->excerpt == 1) {
                $checked = 'checked="checked"';
            }
            echo '<div><label for="' . $posttype->excerpt . '">Excerpt</label>';
            echo '<input type="checkbox" name="' . $posttype->excerpt . '" id="posttype-excerpt"' . $checked . '/><br/></div>';
            $checked = '';
            ?>
									</div>
									<div class="ecpt-atts">
									<?php 
            if ($posttype->fields == 1) {
                $checked = 'checked="checked"';
            }
            echo '<div><label for="' . $posttype->fields . '">Custom Fields</label>';
            echo '<input type="checkbox" name="' . $posttype->fields . '" id="posttype-fields"' . $checked . '/><br/>';
            $checked = '';
            if ($posttype->comments == 1) {
                $checked = 'checked="checked"';
            }
            echo '<div><label for="' . $posttype->comments . '">Comments</label>';
            echo '<input type="checkbox" name="' . $posttype->comments . '" id="posttype-comments"' . $checked . '/><br/></div>';
            $checked = '';
            if ($posttype->revisions == 1) {
                $checked = 'checked="checked"';
            }
            echo '<div><label for="' . $posttype->revisions . '">Revisions</label>';
            echo '<input type="checkbox" name="' . $posttype->revisions . '" id="posttype-revisions"' . $checked . '/><br/></div>';
            $checked = '';
            if ($posttype->hierarchical == 1) {
                $checked = 'checked="checked"';
            }
            echo '<div><label for="' . $posttype->hierarchical . '">Hierarchical</label>';
            echo '<input type="checkbox" name="' . $posttype->hierarchical . '" id="posttype-hierarchical"' . $checked . '/><br/></div>';
            $checked = '';
            if ($posttype->post_formats == 1) {
                $checked = 'checked="checked"';
            }
            echo '<div><label for="' . $posttype->post_formats . '">Post Formats</label>';
            echo '<input type="checkbox" name="' . $posttype->post_formats . '" id="posttype-post_formats"' . $checked . '/><br/></div>';
            $checked = '';
            if ($posttype->exclude_from_search == 1) {
                $checked = 'checked="checked"';
            }
            echo '<div><label for="' . $posttype->exclude_from_search . '">Exclude From Search</label>';
            echo '<input type="checkbox" name="' . $posttype->exclude_from_search . '" id="posttype-exclude_from_search"' . $checked . '/><br/></div>';
            $checked = '';
            if ($posttype->show_in_nav_menus == 1) {
                $checked = 'checked="checked"';
            }
            echo '<div><label for="' . $posttype->show_in_nav_menus . '">Show in Nav Menus</label>';
            echo '<input type="checkbox" name="' . $posttype->show_in_nav_menus . '" id="posttype-show_in_nav_menus"' . $checked . '/><br/></div>';
            $checked = '';
            ?>
									</div>
								</td>
								<td>
									<?php 
            if ($posttype->menu_icon != 'undefined' && $posttype->menu_icon != '') {
                ?>
									<img src="<?php 
                echo $posttype->menu_icon;
                ?>
" class="ecpt_menu_icon"/>
									<?php 
            } else {
                ?>
									<img src="<?php 
                echo $ecpt_base_dir;
                ?>
/includes/images/icon.png" class="ecpt_menu_icon" />
									<?php 
            }
            ?>
									<input type="text" name="posttype-menu-icon" class="ecpt_upload_image posttype-menu-icon" id="upload_image_<?php 
            echo $posttype->id;
            ?>
" class="posttype-menu-icon" value="<?php 
            if ($posttype->menu_icon != 'undefined' && $posttype->menu_icon != '') {
                echo $posttype->menu_icon;
            }
            ?>
" />
									<input id="upload_image_button_<?php 
            echo $posttype->id;
            ?>
" class="upload_image_button edit_posttype_upload button-primary" value="Choose Image" type="button" />
								</td>
								<td>
									<input type="submit" name="posttype-update" id="<?php 
            echo $_GET['posttype-edit'];
            ?>
" class="button-primary posttype-update" value="Update"/>
									<img src="<?php 
            echo $ecpt_base_dir;
            ?>
includes/images/ajax-loader.gif" id="ajax-loader" style="display: none;"/>
								</td>
							</tr>
						<?php 
            $i++;
        }
        // displaying list of post types
    } else {
        foreach ($wpdb->get_results("SELECT * FROM " . $ecpt_db_name . ";") as $key => $type) {
            ?>
			
							<tr <?php 
            if (ecpt_is_odd($i)) {
                echo 'class="alternate"';
            }
            ?>
 id="ecpt-posttype-<?php 
            echo $type->id;
            ?>
">
								<td><?php 
            echo $type->name;
            ?>
</td>
								<td><?php 
            echo 'Single: ' . $type->singular_name . '<br/>Plural: ' . $type->plural_name;
            ?>
</td>
								<td><?php 
            echo $type->slug;
            ?>
</td>
								<td>
									<div id="posttype-atts">
									<?php 
            $atts = array();
            // disabled at this time due to a bug in WP core
            if ($type->hierarchical == 1) {
                $atts[] = 'hierarchical';
            }
            if ($type->post_formats == 1) {
                $atts[] = 'post-formats';
            }
            if ($type->page_attributes == 1) {
                $atts[] = 'page_attributes';
            }
            if ($type->has_archive == 1) {
                $atts[] = 'has_archive';
            }
            if ($type->title == 1) {
                $atts[] = 'title';
            }
            if ($type->editor == 1) {
                $atts[] = 'editor';
            }
            if ($type->author == 1) {
                $atts[] = 'author';
            }
            if ($type->thumbnail == 1) {
                $atts[] = 'thumbnail';
            }
            if ($type->excerpt == 1) {
                $atts[] = 'excerpt';
            }
            if ($type->fields == 1) {
                $atts[] = 'custom fields';
            }
            if ($type->comments == 1) {
                $atts[] = 'comments';
            }
            if ($type->revisions == 1) {
                $atts[] = 'revisions';
            }
            foreach ($atts as $att) {
                echo '<span class="att">' . $att . '<em>,</em> </span>';
            }
            ?>
									</div>
								</td>
								<td>
									<?php 
            if ($type->menu_icon != 'undefined' && $type->menu_icon != '') {
                ?>
									<img src="<?php 
                echo $type->menu_icon;
                ?>
" class="ecpt_menu_icon"/>
									<?php 
            } else {
                ?>
									<img src="<?php 
                echo $ecpt_base_dir;
                ?>
/includes/images/icon.png" class="ecpt_menu_icon"/>
									<?php 
            }
            ?>
								</td>
								<td>
									<?php 
            if ($type->has_archive == 1) {
                ?>
									Archives: <em>archive-<?php 
                echo $type->name;
                ?>
.php</em><br/>
									<?php 
            }
            ?>
									Single: <em>single-<?php 
            echo $type->name;
            ?>
.php</em>
								</td>
								<td>
									<a href="admin.php?page=easy-content-types/easy-content-types.php?posttypes&posttype-edit=<?php 
            echo $type->id;
            ?>
" title="Edit" class="ecpt-edit" id="ecpt-edit-<?php 
            echo $type->id;
            ?>
">Edit</a> |
									<a href="edit.php?post_type=<?php 
            echo $type->name;
            ?>
" title="Edit" class="ecpt-edit" id="ecpt-edit-<?php 
            echo $type->id;
            ?>
">View <?php 
            echo $type->plural_name;
            ?>
</a> |
									<a href="post-new.php?post_type=<?php 
            echo $type->name;
            ?>
" title="Edit" class="ecpt-edit" id="ecpt-edit-<?php 
            echo $type->id;
            ?>
">Add New <?php 
            echo $type->singular_name;
            ?>
</a> |
									<a href="admin.php?page=easy-content-types/easy-content-types.php?posttypes" title="Delete" class="ecpt-delete" id="ecpt-delete-<?php 
            echo $type->id;
            ?>
">Delete</a>
									<img src="<?php 
            echo $ecpt_base_dir;
            ?>
includes/images/ajax-loader.gif" class="ajax-loader" style="display: none;"/>
								</td>
							</tr>
						<?php 
            $i++;
        }
    }
    ?>
	
			</tbody>
		</table>
		<?php 
    if (!$_GET['posttype-edit']) {
        ?>
			<!--custom post type creation form-->
			<h3>Create New Custom Post Type</h3>
			<form method="post" action="" id="ecpt-settings">
				<fieldset>
					<legend>Post Type General</legend><br/>
					
					<label for="post-type-name">Post Type Name<span class="required">*</span></label>
					<input type="text" name="post-type-name" id="ecpt-post-type-name" class="ecpt-text"  tabindex="1"/>
					<p class="ecpt-description">This is the name that you will use to query the custom post type. <strong>Note:</strong> names should be no longer than 10 letters<a href="#" class="ecpt-help"><span class="tooltip center midnightblue">This is the name referenced by the database, if you don't know what that means, don't worry about it, you don't need it.</span></a></p><br/>
										
				</fieldset><br/>
				<fieldset>
					<legend>Labels</legend><br/>
					
					<label for="label-single">Singular Label</label>
					<input type="text" name="label-single" class="ecpt-text"  tabindex="2"/>
					<p class="ecpt-description">The label used for single post type items, such as "Book"<a href="#" class="ecpt-help"><span class="tooltip center midnightblue">If you leave this blank, the name field above will be used</span></a></p><br/>

					<label for="label-plural">Plural Label</label>
					<input type="text" name="label-plural" class="ecpt-text"  tabindex="3"/>
					<p class="ecpt-description">The label used for plural post type items, such as "Books"<a href="#" class="ecpt-help"><span class="tooltip center midnightblue">If you leave this blank, the name field above will be used</span></a></p><br/>
					
				</fieldset><br/>
				
				<fieldset>
					<legend>Post Type Options</legend><br/>
					
					<label for="options-hierarchial">Hierarchical?</label>
					<input type="checkbox" name="options-hierarchial" class="ecpt-checkbox" tabindex="4"/>
					<p class="ecpt-description">Enabling this means that items can have parents and child items<a href="#" class="ecpt-help"><span class="tooltip center midnightblue">Hierarchical post types work the same way that the regular Pages work.</span></a></p><br/>
					
					<label for="options-archives">Enable Archives?</label>
					<input type="checkbox" name="options-archives" class="ecpt-checkbox" checked="checked" tabindex="5"/>
					<p class="ecpt-description">This will enable archives, such as monthly and yearly, for this post type<a href="#" class="ecpt-help"><span class="tooltip center midnightblue">Enabling this option will create archives for your post type, so that you can display a list of all items filed under a particular month or taxonomy</span></a></p><br/>				
													
					<label for="options-post_formats">Post Formats?</label>
					<input type="checkbox" name="options-post_formats" class="ecpt-checkbox" checked="checked" tabindex="6"/>
					<p class="ecpt-description">This will enable post formats, gallery, aside, default<a href="#" class="ecpt-help"><span class="tooltip center midnightblue">This will allow the new 3.1 feature for post formats to be used for this post type</span></a></p><br/>				
										
					<label for="options-archives">Exclude from Search?</label>
					<input type="checkbox" name="options-search" class="ecpt-checkbox" checked="checked" tabindex="7"/>
					<p class="ecpt-description">Checking this option will prevent this post type from showing up in search results<a href="#" class="ecpt-help"><span class="tooltip center midnightblue">If you don't want this post type to be searchable, enable this option</span></a></p><br/>				
					
					<label for="options-nav">Show in Nav Menus?</label>
					<input type="checkbox" name="options-nav" class="ecpt-checkbox" checked="checked" tabindex="8"/>
					<p class="ecpt-description">Checking this will cause this post type to show up in the custom nav menu interface<a href="#" class="ecpt-help"><span class="tooltip center midnightblue">This will allow you to add items from this post type to custom navigation menus</span></a></p><br/>
					
					<label for="options-icon">Menu Icon</label>
					<input type="text" name="options-icon" id="upload_image_1" class="posttype-menu-icon ecpt-text" tabindex="9" />
					<input id="upload_image_button_1" class="upload_image_button button-primary" value="Choose Image" type="button" />
					<p class="ecpt-description ecpt-upload-desc">Enter the URL to your menu icon, or click Choose Image to upload an icon. Optimal size: 16x16 px<a href="#" class="ecpt-help"><span class="tooltip center midnightblue">This is the icon that appears to the left of the post type name in the left navigation menu</span></a></p><br/>
					
					
				</fieldset><br/>
				
				<fieldset>
					<legend>Post Type Supports</legend><br/>

					<label for="options-title">Title</label>
					<input type="checkbox" name="options-title" class="ecpt-checkbox" checked="checked" tabindex="10"/>
					<p class="ecpt-description">Enable titles for this post type?<a href="#" class="ecpt-help"><span class="tooltip center midnightblue">This will enabled the title field for the post type</span></a></p><br/>				
					
					<label for="options-editor">Editor</label>
					<input type="checkbox" name="options-editor" class="ecpt-checkbox" checked="checked" tabindex="11"/>
					<p class="ecpt-description">Enable the main content editor for this post type?<a href="#" class="ecpt-help"><span class="tooltip center midnightblue">This will enable the main content editor, including upload media and formating buttons</span></a></p><br/>

					<label for="options-author">Author</label>
					<input type="checkbox" name="options-author" class="ecpt-checkbox" checked="checked" tabindex="12"/>
					<p class="ecpt-description">Enable author selection for this post type?<a href="#" class="ecpt-help"><span class="tooltip center midnightblue">This will enable the drop down author selection</span></a></p><br/>
					
					<label for="options-thumbnail">Thumbnail</label>
					<input type="checkbox" name="options-thumbnail" class="ecpt-checkbox" checked="checked" tabindex="13"/>
					<p class="ecpt-description">Enable the featured post image for this post type?<a href="#" class="ecpt-help"><span class="tooltip center midnightblue">This will enable the featured post thumbnail option</span></a></p><br/>
					
					<label for="options-excerpt">Excerpt</label>
					<input type="checkbox" name="options-excerpt" class="ecpt-checkbox" checked="checked" tabindex="14"/>
					<p class="ecpt-description">Enable the custom crafted excerpt for this post type?<a href="#" class="ecpt-help"><span class="tooltip center midnightblue">This will enable the hand crafted excerpt box that can be used in place of the auto-generated excerpt</span></a></p><br/>

					<label for="options-custom-fields">Custom Fields</label>
					<input type="checkbox" name="options-custom-fields" class="ecpt-checkbox" checked="checked" tabindex="15"/>
					<p class="ecpt-description">Enable custom fields for this post type?<a href="#" class="ecpt-help"><span class="tooltip center midnightblue">This will enable the custom fields for this post type</span></a></p><br/>

					<label for="options-comments">Comments</label>
					<input type="checkbox" name="options-comments" class="ecpt-checkbox" checked="checked" tabindex="16"/>
					<p class="ecpt-description">Enable comments for this post type?<a href="#" class="ecpt-help"><span class="tooltip center midnightblue">This will enable the option to turn on or off comments for this post type</span></a></p><br/>

					<label for="options-revisions">Revisions</label>
					<input type="checkbox" name="options-revisions" class="ecpt-checkbox" checked="checked" tabindex="17"/>
					<p class="ecpt-description">Enable revisions for this post type?<a href="#" class="ecpt-help"><span class="tooltip center midnightblue">This will enable automatic revision control, allowing you to revert back to previous item versions</span></a></p><br/>
					
				</fieldset><br/>

				<fieldset>
					<legend>Advanced</legend><br/>
					
					<label for="advanced-position">Menu Position</label>
					<input type="text" name="advanced-position" class="ecpt-text" tabindex="18" />
					<p class="ecpt-description">
						Enter the menu position for the post type. Click the help icon for a list of options
						<a href="#" class="ecpt-help"><span class="tooltip center midnightblue">
						5 - below Posts<br/>
						10 - below Media<br/>
						15 - below Links<br/>
						20 - below Pages<br/>
						25 - below Comments<br/>
						60 - below first separator<br/>
						65 - below Plugins<br/>
						70 - below Users<br/>
						75 - below Tools<br/>
						80 - below Settings<br/>
						100 - below second separator<br/>
						<br/></span></a>
					</p><br/>
					
					<label for="advanced-slug">Post Type Slug</label>
					<input type="text" name="advanced-slug" class="ecpt-text" tabindex="19" />
					<p class="ecpt-description">
						Enter the URL friendly slug to use for your post type. Only use this if you know what you're doing
						<a href="#" class="ecpt-help"><span class="tooltip center midnightblue">The slug is the URL friendly name of your post type. It will be displayed in the URL when viewing a post type entry or archive. Only advanced users should enter anything here<br/></span></a>
					</p><br/>
										
				</fieldset><br/>
				
				<input type="submit" name="ecpt-submit" id="ecpt-submit" class="button-primary" value="Add Post Type"  tabindex="20"/>
			</form>
		<?php 
    }
    ?>
	</div>
</div>
<?php 
}
function ecpt_tax_manager()
{
    global $wpdb;
    global $ecpt_db_tax_name;
    global $tax_objects;
    global $tax_atts;
    global $ecpt_base_dir;
    if (!isset($_REQUEST['updated'])) {
        $_REQUEST['updated'] = false;
    }
    ?>
	<div class="wrap">
	<div id="ecpt-wrap">
	
	<?php 
    if ($_GET['taxonomy-added']) {
        ?>
		<div class="updated fade">
			<p>Taxonomy added. Don't forget that you can customize your taxonomy archive layouts with template files.</p>
		</div>
	<?php 
    }
    ?>
		
	
	<?php 
    if ($_GET['edit-tax']) {
        ?>
	<h2>Edit Taxonomy - <a href="admin.php?page=easy-content-types/easy-content-types.php?taxonomies" title="Go Back">Go Back</a></h2>
	<?php 
    } else {
        ?>
	<h2>Easy Custom Taxonomies</h2>
	<?php 
    }
    ?>
	
		<!-- begin FORM -->
		
		<table class="wp-list-table widefat fixed posts">
			<thead>
				<tr>
					<th>Name</th>
					<th>Labels</th>
					<th>Object(s)</th>
					<th>Slug</th>
					<th>Attributes</th>
					<?php 
    if (!$_GET['edit-tax']) {
        ?>
					<th>Template File</th>
					<?php 
    }
    if ($_GET['edit-tax']) {
        ?>
					<th>Update</th>
					<?php 
    } else {
        ?>
					<th>Edit</th>
					<?php 
    }
    ?>
				</tr>
			</thead>
			<tfoot>
				<tr>
					<th>Name</th>
					<th>Labels</th>
					<th>Objects)</th>
					<th>Slug</th>
					<th>Attributes</th>
					<?php 
    if (!$_GET['edit-tax']) {
        ?>
					<th>Template File</th>
					<?php 
    }
    if ($_GET['edit-tax']) {
        ?>
					<th>Update</th>
					<?php 
    } else {
        ?>
					<th>Edit</th>
					<?php 
    }
    ?>
				</tr>
			</tfoot>
			<tbody>
				<?php 
    $i = 0;
    // editing a taxonomy
    if ($_GET['edit-tax']) {
        foreach ($wpdb->get_results("SELECT * FROM " . $ecpt_db_tax_name . " WHERE id ='" . $_GET['edit-tax'] . "';") as $key => $tax) {
            ?>
			
						<tr <?php 
            if (ecpt_is_odd($i)) {
                echo 'class="alternate"';
            }
            ?>
>
							<td>
								<input type="text" name="tax-name" class="ecpt-text no-float" id="tax-name" value="<?php 
            echo $tax->name;
            ?>
" />
								<p>The name is the variable used to query the taxonomy from the database.</p>
							</td>
							<td>
								<span><strong>Single</strong></span><input type="text" name="tax-singlular" class="ecpt-text no-float" id="tax-singlular" value="<?php 
            echo $tax->singular_name;
            ?>
" /><br/>
								<p>The single label is used to refer to single taxonomy items, such as "View Genre".</p>
								
								<span><strong>Plural</strong></span><input type="text" name="tax-plural" class="ecpt-text no-float" id="tax-plural" value="<?php 
            echo $tax->plural_name;
            ?>
" />
								<p>The plural name is used to refer to plural taxonomy items, such as "Search Genres".</p>
							</td>
							<td>
								<select MULTIPLE name="tax-page" id="tax-page" class="ecpt-text no-float ecpt-multi-select"/>
									<?php 
            $tax_objects = get_post_types('', 'objects');
            $pages = explode(',', $tax->page);
            foreach ($tax_objects as $object) {
                echo '<option', in_array($object->name, $pages) ? ' selected="selected"' : '', '>', $object->name, '</option>';
            }
            ?>
								</select><br/>
								<p>The object is the post type that the taxonomy will be applied to. For example, if you choose "post", then this taxonomy will be available to the regular post object.</p>
							</td>
							<td>
								<input type="text" name="tax-slug" class="ecpt-text no-float" id="tax-slug" value="<?php 
            echo $tax->slug;
            ?>
" />
								<p>The slug is the name you will use in the URL to display your taxonomy archive.</p>
							</td>
							<td>
								<div class="ecpt-atts">
								<?php 
            if ($tax->hierarchical == 1) {
                $checked = 'checked="checked"';
            }
            echo '<div><label for="' . $tax->hierarchical . '">Hierarchical</label>';
            echo '<input type="checkbox" name="' . $tax->hierarchical . '" id="tax-hierarchical"' . $checked . '/><br/></div>';
            $checked = '';
            if ($tax->show_tagcloud == 1) {
                $checked = 'checked="checked"';
            }
            echo '<div><label for="' . $tax->show_tagcloud . '">Show Tag Cloud</label>';
            echo '<input type="checkbox" name="' . $tax->show_tagcloud . '" id="tax-tagcloud"' . $checked . '/><br/></div>';
            $checked = '';
            if ($tax->show_in_nav_menus == 1) {
                $checked = 'checked="checked"';
            }
            echo '<div><label for="' . $tax->show_in_nav_menus . '">Show in Nav Menu</label>';
            echo '<input type="checkbox" name="' . $tax->show_in_nav_menus . '" id="tax-show-in-nav"' . $checked . '/><br/></div>';
            $checked = '';
            ?>
								</div>
							</td>
							<td>
								<input type="submit" name="tax-update" id="<?php 
            echo $_GET['edit-tax'];
            ?>
" class="button-primary tax-update" value="Update"/>
								<img src="<?php 
            echo $ecpt_base_dir;
            ?>
includes/images/ajax-loader.gif" id="ajax-loader" style="display: none;"/>
							</td>
						</tr>
					<?php 
            $i++;
        }
        // displaying list of all taxonomies
    } else {
        foreach ($wpdb->get_results("SELECT * FROM " . $ecpt_db_tax_name . ";") as $key => $tax) {
            ?>
			
						<tr <?php 
            if (ecpt_is_odd($i)) {
                echo 'class="alternate"';
            }
            ?>
 id="ecpt-tax-<?php 
            echo $tax->id;
            ?>
">
							<td><?php 
            echo $tax->name;
            ?>
</td>
							<td><?php 
            echo 'Single: ' . $tax->singular_name . '<br/>Plural: ' . $tax->plural_name;
            ?>
</td>
							<td>
								<ul>
								<?php 
            $pages = explode(',', $tax->page);
            foreach ($pages as $page) {
                echo '<li>' . $page . '</li>';
            }
            ?>
								</ul>
							</td>
							<td>
								<?php 
            echo $tax->slug;
            ?>
							</td>
							<td>
								<?php 
            $atts = array();
            if ($tax->hierarchical == 1) {
                $atts[] = 'hierarchical';
            }
            if ($tax->show_tagcloud == 1) {
                $atts[] = 'tagcloud';
            }
            if ($tax->show_in_nav_menus == 1) {
                $atts[] = 'show in nav menus';
            }
            foreach ($atts as $att) {
                echo $att . ', ';
            }
            ?>
							</td>
							
							<td>
								Specific Term: <em>taxonomy-<?php 
            echo $tax->name;
            ?>
-{term}.php</em><br/>
								Archive: <em>taxonomy-<?php 
            echo $tax->name;
            ?>
.php</em>
							</td>
							<td>
								<a href="admin.php?page=easy-content-types/easy-content-types.php?taxonomies&edit-tax=<?php 
            echo $tax->id;
            ?>
" title="edit" class="ecpt-edit-taxonomy" id="ecpt-edit-<?php 
            echo $tax->id;
            ?>
">Edit</a> |
								<a href="edit-tags.php?taxonomy=<?php 
            echo str_replace(' ', '_', strtolower($tax->name));
            ?>
&post_type=<?php 
            echo $tax->page;
            ?>
" title="edit" class="ecpt-edit-taxonomy" id="ecpt-edit-<?php 
            echo $tax->id;
            ?>
">View</a> |
								<a href="admin.php?page=easy-content-types/easy-content-types.php?taxonomies" title="Delete" class="ecpt-delete-taxonomy" id="ecpt-delete-<?php 
            echo $tax->id;
            ?>
">Delete</a>
								<img src="<?php 
            echo $ecpt_base_dir;
            ?>
includes/images/ajax-loader.gif" class="ajax-loader" style="display: none;"/>
							</td>
						</tr>
					<?php 
            $i++;
        }
    }
    ?>
			</tbody>
		</table>
		
		<?php 
    if (!$_GET['edit-tax']) {
        ?>
		
			<!--custom taxonomy creation form-->
			<h3>Create New Custom Taxonomy</h3>
			<form method="post" action="" id="ecpt-settings">
				<fieldset>
					<legend>Taxonomy General</legend><br/>
					
					<label for="taxonomy-name">Taxonomy Name<span class="required">*</span></label>
					<input type="text" name="taxonomy-name" id="ecpt-taxonomy-name" class="ecpt-text" tabindex="1"/>
					<p class="ecpt-description">This is the main name of the taxonomy<a href="#" class="ecpt-help"><span class="tooltip center midnightblue">This is the name referenced by the database, if you don't know what that means, don't worry about it. Just enter a name that makes sense to you</span></a></p><br/>
					
					<label for="taxonomy-object">Object<span class="required">*</span></label>
					<select name="taxonomy-object[]" MULTIPLE id="ecpt-taxonomy-object" class="ecpt-text ecpt-multi-select" tabindex="2"/>
						<?php 
        $custom_post_type_objs = get_post_types('', 'objects');
        foreach ($custom_post_type_objs as $custom_post_type_obj) {
            echo '<option>' . $custom_post_type_obj->name . '</option>';
        }
        ?>
					</select>
					<p class="ecpt-description">This is the post type that will use this taxonomy.<a href="#" class="ecpt-help"><span class="tooltip center midnightblue">You may give this taxonomy to more than one post type by holding the Contral (Command on a Mac) and selecting more than one</span></a></p><br/>
				</fieldset><br/>
				<fieldset>
					<legend>Labels</legend><br/>
					
					<label for="label-single">Singular Label</label>
					<input type="text" name="label-single" class="ecpt-text" tabindex="3"/>
					<p class="ecpt-description">The label used for single taxonomy items, such as "Genre"<a href="#" class="ecpt-help"><span class="tooltip center midnightblue">This is the name that will be used to refer to single items of this taxonomy. If you leave this blank, the name field above will be used</span></a></p><br/>

					<label for="label-plural">Plural Label</label>
					<input type="text" name="label-plural" class="ecpt-text" tabindex="4"/>
					<p class="ecpt-description">The label used for plural taxonomy items, such as "Genres"<a href="#" class="ecpt-help"><span class="tooltip center midnightblue">This is the name that will be used to refer to plural items. If you leave it blank, the name field above will be used</span></a></p><br/>
					
				</fieldset><br/>
				
				<fieldset>
					<legend>Taxonomy Options</legend><br/>
					
					<label for="options-hierarchial">Hierarchical?</label>
					<input type="checkbox" name="options-hierarchial" class="ecpt-checkbox" tabindex="5"/>
					<p class="ecpt-description">Enabling this means that items can have parent and child items<a href="#" class="ecpt-help"><span class="tooltip center midnightblue">This means that you will be able to create tiers with this taxonomy, just like the default post categories. Great for catalogs</span></a></p><br/>

					<label for="options-hierarchial">Show Tag Cloud?</label>
					<input type="checkbox" name="options-tagcloud" class="ecpt-checkbox" tabindex="6"/>
					<p class="ecpt-description">Enabling this means that this taxonomy can be displayed as a tag cloud<a href="#" class="ecpt-help"><span class="tooltip center midnightblue">This will allow the terms within this taxonomy to be displayed as a tag cloud, allowing your visitors to view posts by taxonomy term, and also which terms are the most popular. Just like post tags.</span></a></p><br/>
					
					
					<label for="options-nav">Show in Nav Menus?</label>
					<input type="checkbox" name="options-nav" class="ecpt-checkbox" checked="checked" tabindex="7"/>
					<p class="ecpt-description">Checking this will cause this taxonomy to show up in the custom nav menu interface<a href="#" class="ecpt-help"><span class="tooltip center midnightblue">This will allow you to add individual taxonomies and taxonomy terms to the WP nav menus</span></a></p><br/>
					
					<label for="options-slug">Slug</label>
					<input type="text" name="options-slug" class="ecpt-text" tabindex="8"/>
					<p class="ecpt-description">The URL friendly "nice name" of your taxonomy<a href="#" class="ecpt-help"><span class="tooltip center midnightblue">The slug will be displayed in the URL when accessing your taxonomy archives. Example, if you give your Genres taxonomy a slug of "song-types", your archive URL will be http://yoursite.com/song-types, or similar depending on your permalink structure.<br/> The slug is useful when you have a taxonomy and post type (or regular page) that are named the same thing.<br/>This is an advanced option and should be left blank by most</span></a></p><br/>
					
				</fieldset><br/>
				
				<input type="submit" id="ecpt-submit" class="button-primary" value="Add Taxonomy" tabindex="9"/>
			</form>
		<?php 
    }
    ?>
	</div>
</div>
<?php 
}
function ecpt_metabox_manager()
{
    global $wpdb;
    global $ecpt_db_meta_name;
    global $ecpt_db_meta_fields_name;
    global $field_types;
    global $metabox_pages;
    global $metabox_contexts;
    global $metabox_priorities;
    global $ecpt_base_dir;
    if (!isset($_REQUEST['updated'])) {
        $_REQUEST['updated'] = false;
    }
    ?>
	<div class="wrap">
	<div id="ecpt-wrap">
	
	<?php 
    if ($_GET['metabox-added']) {
        ?>
		<div class="updated fade">
			<p>Meta Box added. Now you should add some fields to your meta box by clicking "Edit Fields"</p>
		</div>
	<?php 
    }
    ?>
		
	
	<!--edit specific field-->
	<?php 
    if ($_GET['fields-edit'] && $_GET['edit-field']) {
        ?>
		<h2>
			Edit Field - <a href="javascript:history.go(-1)" title="Go Back">Go Back</a>
		</h2>
		<form id="edit-field" type="post">
			<table class="wp-list-table widefat fixed posts">
				<thead>
					<tr>
						<th>Name</th>
						<th>Type</th>
						<th>Description</th>
						<th>Options</th>
						<th>Update</th>
					</tr>
				</thead>
				<tfoot>
					<tr>
						<th>Name</th>
						<th>Type</th>
						<th>Description</th>
						<th>Options</th>
						<th>Update</th>
					</tr>
				</tfoot>
				<tbody>		
				<?php 
        foreach ($wpdb->get_results("SELECT * FROM " . $ecpt_db_meta_fields_name . " WHERE id='" . $_GET['edit-field'] . "';") as $key => $field) {
            ?>
		
					<tr <?php 
            if (ecpt_is_odd($i)) {
                echo 'class="alternate"';
            }
            ?>
 id="ecpt-field-<?php 
            echo $field->id;
            ?>
">
						<td>
							<input type="text" id="field-name" name="field-name" value="<?php 
            echo $field->nicename;
            ?>
"  class="ecpt-text no-float"/>
							<p>The field name is displayed next to the field and also used for displaying the field content.</p>
						</td>
						<td>
							<select name="field-type" id="field-type" class="ecpt-text no-float"/>
								<?php 
            foreach ($field_types as $option) {
                echo '<option id="' . $option . '"', $field->type == $option ? ' selected="selected"' : '', '>', $option, '</option>';
            }
            ?>
							</select>
							<p>The field type determines what kind of field is displayed</p>
						</td>						
						<td>
								<input type="text" id="field-desc" name="field-desc" value="<?php 
            echo $field->description;
            ?>
"  class="ecpt-text no-float"/>
								<p>The field description is display beneath the field in the metabox</p>
						</td>
						<td>
							<?php 
            if ($field->type == 'textarea') {
                ?>
								<?php 
                if ($field->rich_editor == 1) {
                    $checked = 'checked="checked"';
                }
                ?>
									<input type="checkbox" class="ecpt-checkbox" id="rich-editor" name="rich-editor" <?php 
                if ($checked) {
                    echo $checked;
                }
                ?>
/>
									<p>Enable the rich editor?</p>
								<?php 
                $checked = '';
                ?>
							<?php 
            } else {
                if ($field->type == 'select' || $field->type == 'radio') {
                    ?>
								<input type="text" id="field-options" name="field-options" value="<?php 
                    echo $field->options;
                    ?>
" class="ecpt-text no-float"/>
								<p>Set the available field options here, each separated by a comma. Options are only for radio and select field types.</p>
							<?php 
                } else {
                    if ($field->type == 'slider') {
                        ?>
								<input type="text" id="field-max" name="field-max" value="<?php 
                        echo $field->max;
                        ?>
" class="ecpt-text no-float"/>
								<p>Enter the maximum value accepted here</p>
							<?php 
                    }
                }
            }
            ?>
						</td>
					
						<td>
							<input type="submit" name="field-update" id="<?php 
            echo $_GET['edit-field'];
            ?>
" class="button-primary field-update" value="Update"/>
							<img src="<?php 
            echo $ecpt_base_dir;
            ?>
includes/images/ajax-loader.gif" id="ajax-loader" style="display: none;"/>
						</td>
					</tr>
				<?php 
            $i++;
        }
        ?>
			</table>		
		</form>	
			
		<!--edit fields-->
	<?php 
    } elseif ($_GET['fields-edit']) {
        ?>
			<?php 
        foreach ($wpdb->get_results("SELECT * FROM " . $ecpt_db_meta_name . " WHERE id='" . $_GET['fields-edit'] . "';") as $key => $metabox) {
            ?>
			<h2>
				Edit Fields for <?php 
            echo $metabox->name;
            ?>
 - 
				<a href="admin.php?page=easy-content-types/easy-content-types.php?metaboxes" title="Go Back">Go Back</a>
			</h2>
			<table class="wp-list-table widefat fixed posts">
				<thead>
					<tr>
						<th>Order</th>
						<th>Name</th>
						<th>Type</th>
						<th>Description</th>
						<th>Options</th>
						<th>Shortcode</th>
						<th>Delete</th>
					</tr>
				</thead>
				<tfoot>
					<tr>
						<th>Order</th>
						<th>Name</th>
						<th>Type</th>
						<th>Description</th>
						<th>Options</th>
						<th>Shortcode</th>
						<th>Delete</th>
					</tr>
				</tfoot>
				<tbody>
				<?php 
            $i = 1;
            ?>
				<?php 
            foreach ($wpdb->get_results("SELECT * FROM " . $ecpt_db_meta_fields_name . " WHERE parent='" . $metabox->name . "' ORDER BY list_order;") as $key => $field) {
                ?>
			
							<tr id="recordsArray_<?php 
                echo $field->id;
                ?>
" class="ecpt-field <?php 
                if (ecpt_is_odd($i)) {
                    echo 'alternate';
                }
                ?>
">
								<td><a href="#" class="dragHandle"></a></td>
								<td><?php 
                echo $field->nicename;
                ?>
</td>
								<td><?php 
                echo $field->type;
                ?>
</td>
								<td><?php 
                echo $field->description;
                ?>
</td>
								<td>
									<?php 
                if ($field->type == 'textarea') {
                    ?>
										<?php 
                    if ($field->rich_editor == 1) {
                        echo 'Rich Editor';
                    } else {
                        echo 'Plain Text';
                    }
                    ?>
									<?php 
                } else {
                    if ($field->type == 'select' || $field->type == 'radio') {
                        ?>
										<?php 
                        echo $field->options;
                        ?>
									<?php 
                    } else {
                        if ($field->type == 'slider') {
                            ?>
										<?php 
                            echo 'Max: ' . $field->max;
                            ?>
									<?php 
                        }
                    }
                }
                ?>
								</td>
								<td>[ecpt_field id="<?php 
                echo $field->name;
                ?>
"]</td>
								<td>
									<a href="admin.php?page=easy-content-types/easy-content-types.php?metaboxes&fields-edit=8&edit-field=<?php 
                echo $field->id;
                ?>
" title="Edit" class="ecpt-edit-field" id="ecpt-edit-field-<?php 
                echo $field->id;
                ?>
">Edit</a> |
									<a href="#" title="Delete" class="ecpt-delete-field" id="ecpt-delete-field-<?php 
                echo $field->id;
                ?>
">Delete</a>
									<img src="<?php 
                echo $ecpt_base_dir;
                ?>
includes/images/ajax-loader.gif" class="ajax-loader" style="display: none;"/>
								</td>
							</tr>
						<?php 
                $i++;
            }
            ?>
			</table>
			<?php 
        }
        ?>
		
			<!--custom metabox field creation form-->
			<h3>Create New Metabox Field</h3>
			<form method="post" id="ecpt-settings">
				<fieldset>
					<legend>Field Info</legend><br/>
					
					<?php 
        $counter = 0;
        foreach ($wpdb->get_results("SELECT * FROM " . $ecpt_db_meta_fields_name . " ORDER BY id DESC LIMIT 1;") as $key => $field) {
            // add all the list orders together
            $id = $field->id;
            $newID = $id + 1;
            // add 1 to the last ID
        }
        ?>
					<input type="hidden" value="<?php 
        echo $metabox->id;
        ?>
" name="current-field"/>
					<input type="hidden" value="<?php 
        echo $metabox->name;
        ?>
" name="field-parent"/>
					<input type="hidden" value="<?php 
        echo $newID;
        // last ID + 1
        ?>
" name="field-order"/>
					
					<label for="field-name">Field Name<span class="required">*</span></label>
					<input type="text" name="field-name" id="ecpt-field-name" class="ecpt-text" tabindex="1"/>
					<p class="ecpt-description">This is the main name of the field<a href="#" class="ecpt-help"><span class="tooltip center midnightblue">This is the name that will be used to display field data on the site, and also will be display next to the field in the post editor</span></a></p><br/>
					
					<label for="field-desc">Field Description</label>
					<input type="text" name="field-desc" id="ecpt-field-desc" class="ecpt-text" tabindex="2"/>
					<p class="ecpt-description">The field description<a href="#" class="ecpt-help"><span class="tooltip center midnightblue">This is description of the field that will be shown beneath the field in the editor</span></a></p><br/>
									
					<label for="field-type">Type</label>
					<select name="field-type" id="ecpt-field-type" class="ecpt-text"  tabindex="3"/>
						<?php 
        foreach ($field_types as $field_type) {
            echo '<option id="' . $field_type . '">' . $field_type . '</option>';
        }
        ?>
					</select>
					<p class="ecpt-description">The type of field you would like to insert<a href="#" class="ecpt-help"><span class="tooltip center midnightblue">If you choose "select" or "radio" a new input will become available for you to enter the options</span></a></p><br/>
					
					<div class="ecpt-disabled">
						<label for="field-options">Options</label>
						<input type="text" name="field-options" id="ecpt-field-options" class="ecpt-text"  tabindex="4"/>
						<p class="ecpt-description">Options for select and radio fields. Separate options with a comma<a href="#" class="ecpt-help"><span class="tooltip center midnightblue">A sample set of options would look like this (without the quotes): "option 1, option 2, option 3"</span></a></p><br/>
					</div>
					<div class="ecpt-rich-editor-disabled">
						<label for="rich-editor">Rich Editor</label>
						<input type="checkbox" name="rich-editor" id="ecpt-rich-editor" class="ecpt-checkbox"  tabindex="5"/>
						<p class="ecpt-description">Enable the Rich Editor for this textarea?<a href="#" class="ecpt-help"><span class="tooltip center midnightblue">This option will enable "rich" formatting controls, such as italic, bold, alignment, link, etc</span></a></p><br/>
					</div>
					
					<div class="ecpt-max-disabled">
						<label for="field-max">Max Value</label>
						<input type="text" name="field-max" id="ecpt-field-max" class="ecpt-text"  tabindex="6"/>
						<p class="ecpt-description">Enter the maximum value for this slider<a href="#" class="ecpt-help"><span class="tooltip center midnightblue">This is the highest value that the slider can "slide" too.</span></a></p><br/>
					</div>
					
				</fieldset><br/>
				
				<input type="submit" id="ecpt-submit" class="button-primary" value="Add Field"/>
			</form>			
		
	<!--metabox-->
	<?php 
    } else {
        ?>
		<?php 
        if ($_GET['metabox-edit']) {
            ?>
		<h2>
			Edit Metabox - 
				<a href="admin.php?page=easy-content-types/easy-content-types.php?metaboxes" title="Go Back">Go Back</a>
		</h2>
		<?php 
        } else {
            ?>
		<h2>Easy Custom Meta Boxes</h2>
		<?php 
        }
        ?>
			<table class="wp-list-table widefat fixed posts">
				<thead>
					<tr>
						<th>Name</th>
						<th>Page</th>
						<th>Context</th>
						<th>Priority</th>
						<?php 
        if (!$_GET['metabox-edit']) {
            ?>
						<th>Fields</th>
						<?php 
        }
        ?>
						<th>Edit</th>
					</tr>
				</thead>
				<tfoot>
					<tr>
						<th>Name</th>
						<th>Page</th>
						<th>Context</th>
						<th>Priority</th>
						<?php 
        if (!$_GET['metabox-edit']) {
            ?>
						<th>Fields</th>
						<?php 
        }
        ?>
						<th>Edit</th>
					</tr>
				</tfoot>
				<tbody>
					<?php 
        $i = 0;
        // editing a meta box
        if ($_GET['metabox-edit']) {
            foreach ($wpdb->get_results("SELECT * FROM " . $ecpt_db_meta_name . " WHERE id = '" . $_GET['metabox-edit'] . "';") as $key => $metabox) {
                $name = $metabox->name;
                ?>
			
								<tr <?php 
                if (ecpt_is_odd($i)) {
                    echo 'class="alternate"';
                }
                ?>
>
									<td>
										<input type="text" id="metabox-name" name="metabox-name" value="<?php 
                echo $metabox->nicename;
                ?>
"  class="ecpt-text no-float"/>
										<p>The meta box name is displayed at the top of the meta box on the editor screen</p>
									</td>
									<td>
										<select name="metabox-page" id="metabox-page" class="ecpt-text no-float"/>
											<?php 
                $pages = get_post_types('', 'objects');
                $metabox_pages = array();
                foreach ($pages as $page) {
                    $metabox_pages[] = $page->name;
                }
                $metabox_pages[] = 'link';
                foreach ($metabox_pages as $metabox_page) {
                    echo '<option', $metabox->page == $metabox_page ? ' selected="selected"' : '', '>', $metabox_page, '</option>';
                }
                ?>
										</select>
										<p>The page is the post type that the meta box is displayed on. For example, if you choose "post", the meta box will be displayed on the regular post screen.</p>
									</td>
									<td>
										<select name="metabox-context" id="metabox-context" class="ecpt-text no-float"/>
											<?php 
                foreach ($metabox_contexts as $metabox_context) {
                    echo '<option', $metabox->context == $metabox_context ? ' selected="selected"' : '', '>', $metabox_context, '</option>';
                }
                ?>
										</select>
										<p>The context is the location on the editor screen thatthe metabox will be displayed</p>
									</td>
									<td>
										<select name="metabox-priority" id="metabox-priority" class="ecpt-text no-float"/>
											<?php 
                foreach ($metabox_priorities as $priority) {
                    echo '<option', $metabox->priority == $priority ? ' selected="selected"' : '', '>', $priority, '</option>';
                }
                ?>
										</select>
										<p>Priority determines how "high" on the editor screen the meta box appears</p>
									</td>
									<td>
										<input type="submit" name="metabox-update" id="<?php 
                echo $_GET['metabox-edit'];
                ?>
" class="button-primary metabox-update" value="Update"/>
										<img src="<?php 
                echo $ecpt_base_dir;
                ?>
includes/images/ajax-loader.gif" id="ajax-loader" style="display: none;"/>
									</td>
								</tr>
							<?php 
                $i++;
            }
            // viewing all metaboxes
        } else {
            foreach ($wpdb->get_results("SELECT * FROM " . $ecpt_db_meta_name . ";") as $key => $metabox) {
                $name = $metabox->name;
                ?>
			
								<tr <?php 
                if (ecpt_is_odd($i)) {
                    echo 'class="alternate"';
                }
                ?>
 id="ecpt-metabox-<?php 
                echo $metabox->id;
                ?>
">
									<td><?php 
                echo $metabox->nicename;
                ?>
</td>
									<td><?php 
                echo $metabox->page;
                ?>
</td>
									<td><?php 
                echo $metabox->context;
                ?>
</td>
									<td><?php 
                echo $metabox->priority;
                ?>
</td>
									<td>
										<?php 
                foreach ($wpdb->get_results("SELECT * FROM " . $ecpt_db_meta_fields_name . " WHERE parent='" . $name . "';") as $key => $meta_field) {
                    echo $meta_field->nicename . ', ';
                }
                ?>
									</td>
									<td>
										<a href="admin.php?page=easy-content-types/easy-content-types.php?metaboxes&metabox-edit=<?php 
                echo $metabox->id;
                ?>
" title="Edit Metabox" class="ecpt-edit">Edit</a> | 
										<a href="admin.php?page=easy-content-types/easy-content-types.php?metaboxes&fields-edit=<?php 
                echo $metabox->id;
                ?>
" title="Edit Fields" class="ecpt-edit">Edit Fields</a> | 
										<a href="#" title="Delete <?php 
                echo $metabox->name;
                ?>
" class="ecpt-delete-metabox" id="ecpt-delete-<?php 
                echo $metabox->id;
                ?>
">Delete</a>
										<img src="<?php 
                echo $ecpt_base_dir;
                ?>
includes/images/ajax-loader.gif" class="ajax-loader" style="display: none;"/>
									</td>
								</tr>
							<?php 
                $i++;
            }
        }
        ?>
				</tbody>
			</table>
			<?php 
        if (!$_GET['metabox-edit']) {
            ?>
			<p>Click the "Edit Fields" link in order to add fields to a meta box</p>
			<p>Need help displaying the content from your meta boxes? <a href="admin.php?page=easy-content-types/easy-content-types.php?help#field-info">Click here</a>.
			<?php 
        }
        ?>
			<?php 
        // only show the add new box form if not editing
        if (!$_GET['metabox-edit']) {
            ?>
			<!--custom metabox creation form-->
			<h3>Create New Custom Metabox</h3>
			<form method="post" action="<?php 
            echo $ecpt_base_filse;
            ?>
" id="ecpt-settings">
				<fieldset>
					<legend>Metabox General</legend><br/>
					
					<label for="metabox-name">Metabox Name<span class="required">*</span></label>
					<input type="text" name="metabox-name" id="ecpt-metabox-name" class="ecpt-text"/>
					<p class="ecpt-description">This is the main name of the metabox<a href="#" class="ecpt-help"><span class="tooltip center midnightblue">The metabox name will show up in the header of the box on the editor screen</span></a></p><br/>
					
					<label for="metabox-page">Page</label>
					<select name="metabox-page" id="ecpt-metabox-page" class="ecpt-text"/>
						<?php 
            $pages = get_post_types('', 'objects');
            $metabox_pages = array();
            foreach ($pages as $page) {
                $metabox_pages[] = $page->name;
            }
            $metabox_pages[] = 'link';
            foreach ($metabox_pages as $metabox_page) {
                echo '<option>' . $metabox_page . '</option>';
            }
            ?>
					</select>
					<p class="ecpt-description">This is the post type that will use this metabox<a href="#" class="ecpt-help"><span class="tooltip center midnightblue">If you want to put the metabox on the regular Posts screen, then choose "post"</span></a></p><br/>
					
					<label for="metabox-context">Context</label>
					<select name="metabox-context" id="ecpt-metabox-context" class="ecpt-text"/>
						<option>normal</option>
						<option>advanced</option>
						<option>side</option>
					</select>
					<p class="ecpt-description">The location on the editor screen to display the meta box.<a href="#" class="ecpt-help"><span class="tooltip center midnightblue">Advanced / Normal = main column, with Advanced being above Normal. Side = right, narrow column.</span></a></p><br/>
					
					<label for="metabox-priority">Priority</label>
					<select name="metabox-priority" id="ecpt-metabox-priority" class="ecpt-text"/>
						<option>default</option>
						<option>high</option>
						<option>core</option>
						<option>low</option>
					</select>
					<p class="ecpt-description">The priority determines how "high" the meta box appears in the editor<a href="#" class="ecpt-help"><span class="tooltip center midnightblue">Metaboxes with 'high' priorites will appear above boxes with 'default' priority, for example</span></a></p><br/>
					
				</fieldset><br/>
				
				<input type="submit" id="ecpt-submit" class="button-primary" value="Add Meta Box"/>
			</form>
			<?php 
        }
        ?>
	<?php 
    }
    ?>
	</div><!--end #ecpt-wrap-->
	</div><!--end #wrap-->
<?php 
}