function _wppa_admin()
{
    global $wpdb;
    global $q_config;
    global $wppa_revno;
    if (get_option('wppa_revision') != $wppa_revno) {
        wppa_check_database(true);
    }
    echo '
<script type="text/javascript">
	/* <![CDATA[ */
	wppaAjaxUrl = "' . admin_url('admin-ajax.php') . '";
	wppaUploadToThisAlbum = "' . __('Upload to this album', 'wp-photo-album-plus') . '";
	wppaImageDirectory = "' . wppa_get_imgdir() . '";
	/* ]]> */
</script>
';
    // Delete trashed comments
    $query = "DELETE FROM " . WPPA_COMMENTS . " WHERE status='trash'";
    $wpdb->query($query);
    $sel = 'selected="selected"';
    // warn if the uploads directory is no writable
    if (!is_writable(WPPA_UPLOAD_PATH)) {
        wppa_error_message(__('Warning:', 'wp-photo-album-plus') . sprintf(__('The uploads directory does not exist or is not writable by the server. Please make sure that %s is writeable by the server.', 'wp-photo-album-plus'), WPPA_UPLOAD_PATH));
    }
    // Fix orphan albums and deleted target pages
    $albs = $wpdb->get_results("SELECT * FROM `" . WPPA_ALBUMS . "`", ARRAY_A);
    if ($albs) {
        foreach ($albs as $alb) {
            if ($alb['a_parent'] > '0' && wppa_get_parentalbumid($alb['a_parent']) == '-9') {
                // Parent died?
                $wpdb->query("UPDATE `" . WPPA_ALBUMS . "` SET `a_parent` = '-1' WHERE `id` = '" . $alb['id'] . "'");
            }
            if ($alb['cover_linkpage'] > '0') {
                $iret = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM `" . $wpdb->posts . "` WHERE `ID` = %s AND `post_type` = 'page' AND `post_status` = 'publish'", $alb['cover_linkpage']));
                if (!$iret) {
                    // Page gone?
                    $wpdb->query("UPDATE `" . WPPA_ALBUMS . "` SET `cover_linkpage` = '0' WHERE `id` = '" . $alb['id'] . "'");
                }
            }
        }
    }
    if (isset($_REQUEST['tab'])) {
        // album edit page
        if ($_REQUEST['tab'] == 'edit') {
            if (isset($_REQUEST['edit_id'])) {
                $ei = $_REQUEST['edit_id'];
                if ($ei != 'new' && $ei != 'search' && !is_numeric($ei)) {
                    wp_die('Security check failure 1');
                }
            }
            if ($_REQUEST['edit_id'] == 'search') {
                $back_url = get_admin_url() . 'admin.php?page=wppa_admin_menu';
                if (isset($_REQUEST['wppa-searchstring'])) {
                    $back_url .= '&wppa-searchstring=' . wppa_sanitize_searchstring($_REQUEST['wppa-searchstring']);
                }
                $back_url .= '#wppa-edit-search-tag';
                ?>
<a name="manage-photos" id="manage-photos" ></a>
				<h2><?php 
                _e('Manage Photos', 'wp-photo-album-plus');
                if (isset($_REQUEST['bulk'])) {
                    echo ' - <small><i>' . __('Copy / move / delete / edit name / edit description / change status', 'wp-photo-album-plus') . '</i></small>';
                } elseif (isset($_REQUEST['quick'])) {
                    echo ' - <small><i>' . __('Edit photo information except copy and move', 'wp-photo-album-plus') . '</i></small>';
                } else {
                    echo ' - <small><i>' . __('Edit photo information', 'wp-photo-album-plus') . '</i></small>';
                }
                ?>
</h2>

<a href="<?php 
                echo $back_url;
                ?>
"><?php 
                _e('Back to album table', 'wp-photo-album-plus');
                ?>
</a><br /><br />

				<?php 
                if (isset($_REQUEST['bulk'])) {
                    wppa_album_photos_bulk($ei);
                } else {
                    wppa_album_photos($ei);
                }
                ?>
				<br /><a href="#manage-photos"><?php 
                _e('Top of page', 'wp-photo-album-plus');
                ?>
</a>
				<br /><a href="<?php 
                echo $back_url;
                ?>
"><?php 
                _e('Back to album table', 'wp-photo-album-plus');
                ?>
</a>
<?php 
                return;
            }
            if ($_REQUEST['edit_id'] == 'new') {
                if (!wppa_can_create_album()) {
                    wp_die('No rights to create an album');
                }
                $id = wppa_nextkey(WPPA_ALBUMS);
                if (isset($_REQUEST['parent_id'])) {
                    $parent = $_REQUEST['parent_id'];
                    if (!is_numeric($parent)) {
                        wp_die('Security check failure 2');
                    }
                    $name = wppa_get_album_name($parent) . '-#' . $id;
                    if (!current_user_can('administrator')) {
                        // someone creating an album for someone else?
                        $parentowner = $wpdb->get_var($wpdb->prepare("SELECT `owner` FROM `" . WPPA_ALBUMS . "` WHERE `id` = %s", $parent));
                        if ($parentowner !== wppa_get_user()) {
                            wp_die('You are not allowed to create an album for someone else');
                        }
                    }
                } else {
                    $parent = wppa_opt('default_parent');
                    if (!$wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM `" . WPPA_ALBUMS . "` WHERE `id` = %s", $parent))) {
                        // Deafault parent vanished
                        wppa_update_option('wppa_default_parent', '0');
                        $parent = '0';
                    }
                    $name = __('New Album', 'wp-photo-album-plus');
                    if (!wppa_can_create_top_album()) {
                        wp_die('No rights to create a top-level album');
                    }
                }
                $id = wppa_create_album_entry(array('id' => $id, 'name' => $name, 'a_parent' => $parent));
                if (!$id) {
                    wppa_error_message(__('Could not create album.', 'wp-photo-album-plus'));
                    wp_die('Sorry, cannot continue');
                } else {
                    $edit_id = $id;
                    wppa_set_last_album($edit_id);
                    wppa_flush_treecounts($edit_id);
                    wppa_index_add('album', $id);
                    wppa_update_message(__('Album #', 'wp-photo-album-plus') . ' ' . $edit_id . ' ' . __('Added.', 'wp-photo-album-plus'));
                    wppa_create_pl_htaccess();
                }
            } else {
                $edit_id = $_REQUEST['edit_id'];
            }
            $album_owner = $wpdb->get_var($wpdb->prepare("SELECT `owner` FROM " . WPPA_ALBUMS . " WHERE `id` = %s", $edit_id));
            if ($album_owner == '--- public ---' && !current_user_can('wppa_admin') || !wppa_have_access($edit_id)) {
                wp_die('You do not have the rights to edit this album');
            }
            // Apply new desc
            if (isset($_REQUEST['applynewdesc'])) {
                if (!wp_verify_nonce($_REQUEST['wppa_nonce'], 'wppa_nonce')) {
                    wp_die('You do not have the rights to do this');
                }
                $iret = $wpdb->query($wpdb->prepare("UPDATE `" . WPPA_PHOTOS . "` SET `description` = %s WHERE `album` = %s", wppa_opt('newphoto_description'), $edit_id));
                wppa_ok_message($iret . ' descriptions updated.');
            }
            // Remake album
            if (isset($_REQUEST['remakealbum'])) {
                if (!wp_verify_nonce($_REQUEST['wppa_nonce'], 'wppa_nonce')) {
                    wp_die('You do not have the rights to do this');
                }
                if (get_option('wppa_remake_start_album_' . $edit_id)) {
                    // Continue after time up
                    wppa_ok_message('Continuing remake, please wait');
                } else {
                    update_option('wppa_remake_start_album_' . $edit_id, time());
                    wppa_ok_message('Remaking photofiles, please wait');
                }
                $iret = wppa_remake_files($edit_id);
                if ($iret) {
                    wppa_ok_message('Photo files remade');
                    update_option('wppa_remake_start_album_' . $edit_id, '0');
                } else {
                    wppa_error_message('Remake of photo files did NOT complete');
                }
            }
            // Get the album information
            $albuminfo = $wpdb->get_row($wpdb->prepare('SELECT * FROM `' . WPPA_ALBUMS . '` WHERE `id` = %s', $edit_id), ARRAY_A);
            ?>

			<div class="wrap">
				<?php 
            wppa_admin_spinner();
            ?>
				<h2><?php 
            echo __('Edit Album Information', 'wp-photo-album-plus') . ' <span style="color:blue">' . __('Auto Save', 'wp-photo-album-plus') . '</span>';
            ?>
</h2>
				<p class="description">
					<?php 
            echo __('All modifications are instantly updated on the server, except for those that require a button push.', 'wp-photo-album-plus');
            echo ' ' . __('The <b style="color:#070" >Remark</b> fields keep you informed on the actions taken at the background.', 'wp-photo-album-plus');
            ?>
				</p>
				<p>
					<?php 
            _e('Album number:', 'wp-photo-album-plus');
            echo ' ' . $edit_id . '.';
            ?>
				</p>
					<input type="hidden" id="album-nonce-<?php 
            echo $edit_id;
            ?>
" value="<?php 
            echo wp_create_nonce('wppa_nonce_' . $edit_id);
            ?>
" />
					<table class="widefat wppa-table wppa-album-table">
						<tbody>

							<!-- Name -->
							<tr>
								<th>
									<label><?php 
            _e('Name:', 'wp-photo-album-plus');
            ?>
</label>
								</th>
								<?php 
            if (wppa_switch('wppa_use_wp_editor')) {
                ?>
									<td>
										<input id="wppaalbumname" type="text" style="width: 100%;" value="<?php 
                echo esc_attr(stripslashes($albuminfo['name']));
                ?>
" />
									</td>
									<td>
										<input type="button" class="button-secundary" value="<?php 
                _e('Update Album name', 'wp-photo-album-plus');
                ?>
" onclick="wppaAjaxUpdateAlbum(<?php 
                echo $edit_id;
                ?>
, 'name', document.getElementById('wppaalbumname') )" />
									</td>
								<?php 
            } else {
                ?>
									<td>
										<input type="text" style="width: 100%;" onkeyup="wppaAjaxUpdateAlbum(<?php 
                echo $edit_id;
                ?>
, 'name', this)" onchange="wppaAjaxUpdateAlbum(<?php 
                echo $edit_id;
                ?>
, 'name', this)" value="<?php 
                echo esc_attr(stripslashes($albuminfo['name']));
                ?>
" />
									</td>
									<td>
										<span class="description"><?php 
                _e('Type the name of the album. Do not leave this empty.', 'wp-photo-album-plus');
                ?>
</span>
									</td>
								<?php 
            }
            ?>
							</tr>

							<!-- Description -->
							<tr>
								<th>
									<label><?php 
            _e('Description:', 'wp-photo-album-plus');
            ?>
</label>
								</th>
								<?php 
            if (wppa_switch('wppa_use_wp_editor')) {
                ?>
									<td colspan="2" >

										<?php 
                //	$quicktags_settings = array( 'buttons' => 'strong,em,link,block,ins,ul,ol,li,code,close' );
                //	wp_editor(stripslashes($albuminfo['description']), 'wppaalbumdesc', array('wpautop' => false, 'media_buttons' => false, 'textarea_rows' => '6', 'tinymce' => false, 'quicktags' => $quicktags_settings ));
                wp_editor(stripslashes($albuminfo['description']), 'wppaalbumdesc', array('wpautop' => true, 'media_buttons' => false, 'textarea_rows' => '6', 'tinymce' => true));
                ?>

										<input type="button" class="button-secundary" value="<?php 
                _e('Update Album description', 'wp-photo-album-plus');
                ?>
" onclick="wppaAjaxUpdateAlbum(<?php 
                echo $edit_id;
                ?>
, 'description', document.getElementById('wppaalbumdesc') )" />
										<img id="wppa-album-spin" src="<?php 
                echo wppa_get_imgdir() . 'wpspin.gif';
                ?>
" style="visibility:hidden" />
										<br />
									</td>
								<?php 
            } else {
                ?>
									<td>
										<textarea style="width: 100%; height: 80px;" onkeyup="wppaAjaxUpdateAlbum(<?php 
                echo $edit_id;
                ?>
, 'description', this)" onchange="wppaAjaxUpdateAlbum(<?php 
                echo $edit_id;
                ?>
, 'description', this)" ><?php 
                echo stripslashes($albuminfo['description']);
                ?>
</textarea>
									</td>
									<td>
										<span class="description"><?php 
                _e('Enter / modify the description for this album.', 'wp-photo-album-plus');
                ?>
</span>
									</td>
								<?php 
            }
            ?>
							</tr>

							<!-- Timestamp -->
							<tr>
								<th>
									<label><?php 
            _e('Created:', 'wp-photo-album-plus');
            ?>
</label>
								</th>
								<td>
									<?php 
            echo wppa_local_date(get_option('date_format', "F j, Y,") . ' ' . get_option('time_format', "g:i a"), $albuminfo['timestamp']) . ' ' . __('local time', 'wp-photo-album-plus');
            ?>
								</td>

							<!-- Modified -->
							<tr>
								<th>
									<label><?php 
            _e('Modified:', 'wp-photo-album-plus');
            ?>
</label>
								</th>
								<td>
									<?php 
            if ($albuminfo['modified'] > $albuminfo['timestamp']) {
                echo wppa_local_date(get_option('date_format', "F j, Y,") . ' ' . get_option('time_format', "g:i a"), $albuminfo['modified']) . ' ' . __('local time', 'wp-photo-album-plus');
            } else {
                _e('Not modified', 'wp-photo-album-plus');
            }
            ?>
									<?php 
            ?>
								</td>

							<!-- Views -->
							<tr>
								<th>
									<label><?php 
            _e('Views:', 'wp-photo-album-plus');
            ?>
</label>
								</th>
								<td>
									<?php 
            echo $albuminfo['views'];
            ?>
								</td>
							</tr>

							<!-- Owner -->
							<?php 
            // if ( wppa_switch('wppa_owner_only') ) {
            if (current_user_can('administrator')) {
                ?>
								<tr>
									<th>
										<label><?php 
                _e('Owned by:', 'wp-photo-album-plus');
                ?>
</label>
									</th>
									<?php 
                if ($albuminfo['owner'] == '--- public ---' && !current_user_can('administrator')) {
                    ?>
										<td>
											<?php 
                    _e('--- public ---', 'wp-photo-album-plus');
                    ?>
										</td>
									<?php 
                } else {
                    ?>
										<td>
											<?php 
                    $usercount = wppa_get_user_count();
                    if ($usercount > wppa_opt('max_users')) {
                        ?>
												<input type="text" value="<?php 
                        echo $albuminfo['owner'];
                        ?>
" onchange="wppaAjaxUpdateAlbum(<?php 
                        echo $edit_id;
                        ?>
, 'owner', this)" />
											<?php 
                    } else {
                        ?>
												<select onchange="wppaAjaxUpdateAlbum(<?php 
                        echo $edit_id;
                        ?>
, 'owner', this)" ><?php 
                        wppa_user_select($albuminfo['owner']);
                        ?>
</select>
											<?php 
                    }
                    ?>
										</td>
										<td>
											<?php 
                    if (!current_user_can('administrator')) {
                        ?>
												<span class="description" style="color:orange;" ><?php 
                        _e('WARNING If you change the owner, you will no longer be able to modify this album and upload or import photos to it!', 'wp-photo-album-plus');
                        ?>
</span>
											<?php 
                    }
                    ?>
											<?php 
                    if ($usercount > '1000') {
                        echo '<span class="description" >' . __('Enter user login name or <b>--- public ---</b>', 'wp-photo-album-plus'), '</span>';
                    }
                    ?>
										</td>
									<?php 
                }
                ?>
								</tr>
							<?php 
            }
            ?>

							<!-- Order # -->
							<tr>
								<th>
									<label><?php 
            _e('Album sort order #:', 'wp-photo-album-plus');
            ?>
</label>
								</th>
								<td>
									<input type="text" onkeyup="wppaAjaxUpdateAlbum(<?php 
            echo $edit_id;
            ?>
, 'a_order', this)" onchange="wppaAjaxUpdateAlbum(<?php 
            echo $edit_id;
            ?>
, 'a_order', this)" value="<?php 
            echo $albuminfo['a_order'];
            ?>
" style="width: 50px;"/>
								</td>
								<td>
									<?php 
            if (wppa_opt('list_albums_by') != '1' && $albuminfo['a_order'] != '0') {
                ?>
										<span class="description" style="color:red">
										<?php 
                _e('Album order # has only effect if you set the album sort order method to <b>Order #</b> in the Photo Albums -> Settings screen.<br />', 'wp-photo-album-plus');
                ?>
										</span>
									<?php 
            }
            ?>
									<span class="description"><?php 
            _e('If you want to sort the albums by order #, enter / modify the order number here.', 'wp-photo-album-plus');
            ?>
</span>
								</td>
							</tr>

							<!-- Parent -->
							<tr>
								<th>
									<label><?php 
            _e('Parent album:', 'wp-photo-album-plus');
            ?>
 </label>
								</th>
								<td style="max-width:210px;">
									<?php 
            if (wppa_extended_access()) {
                ?>
										<select id="wppa-parsel" style="max-width:100%;" onchange="wppaAjaxUpdateAlbum(<?php 
                echo $edit_id;
                ?>
, 'a_parent', this)" ><?php 
                echo wppa_album_select_a(array('checkaccess' => true, 'exclude' => $albuminfo['id'], 'selected' => $albuminfo['a_parent'], 'addselected' => true, 'addnone' => true, 'addseparate' => true, 'disableancestors' => true, 'path' => wppa_switch('wppa_hier_albsel')));
                ?>
</select>
									<?php 
            } else {
                ?>
										<select id="wppa-parsel" style="max-width:100%;" onchange="wppaAjaxUpdateAlbum(<?php 
                echo $edit_id;
                ?>
, 'a_parent', this)" ><?php 
                echo wppa_album_select_a(array('checkaccess' => true, 'exclude' => $albuminfo['id'], 'selected' => $albuminfo['a_parent'], 'addselected' => true, 'disableancestors' => true, 'path' => wppa_switch('wppa_hier_albsel')));
                ?>
</select>
									<?php 
            }
            ?>
								</td>
								<td>
									<span class="description">
										<?php 
            _e('If this is a sub album, select the album in which this album will appear.', 'wp-photo-album-plus');
            ?>
									</span>
								</td>
							</tr>

							<!-- P-order-by -->
							<tr>
								<th>
									<?php 
            $order = $albuminfo['p_order_by'];
            ?>
									<label><?php 
            _e('Photo order:', 'wp-photo-album-plus');
            ?>
</label>
								</th>
								<td>
									<?php 
            $options = array(__('--- default ---', 'wp-photo-album-plus'), __('Order #', 'wp-photo-album-plus'), __('Name', 'wp-photo-album-plus'), __('Random', 'wp-photo-album-plus'), __('Rating mean value', 'wp-photo-album-plus'), __('Number of votes', 'wp-photo-album-plus'), __('Timestamp', 'wp-photo-album-plus'), __('EXIF Date', 'wp-photo-album-plus'), __('Order # desc', 'wp-photo-album-plus'), __('Name desc', 'wp-photo-album-plus'), __('Rating mean value desc', 'wp-photo-album-plus'), __('Number of votes desc', 'wp-photo-album-plus'), __('Timestamp desc', 'wp-photo-album-plus'), __('EXIF Date desc', 'wp-photo-album-plus'));
            $values = array('0', '1', '2', '3', '4', '6', '5', '7', '-1', '-2', '-4', '-6', '-5', '-7');
            ?>
									<select onchange="wppaAjaxUpdateAlbum(<?php 
            echo $edit_id;
            ?>
, 'p_order_by', this)">
									<?php 
            foreach (array_keys($options) as $key) {
                $sel = $values[$key] == $order ? ' selected="selected"' : '';
                echo '<option value="' . $values[$key] . '"' . $sel . ' >' . $options[$key] . '</option>';
            }
            ?>
									</select>
								</td>
								<td>
									<span class="description">
										<?php 
            _e('Specify the way the photos should be ordered in this album.', 'wp-photo-album-plus');
            ?>
<br />
										<?php 
            if (current_user_can('wppa_settings')) {
                _e('The default setting can be changed in the <b>Photo Albums -> Settings</b> page <b>Table IV-C1</b>.', 'wp-photo-album-plus');
            }
            ?>
									</span>
								</td>
							</tr>

							<!-- Child album order -->
							<tr>
								<th>
									<label><?php 
            _e('Sub album sort order:', 'wp-photo-album-plus');
            ?>
</label>
								</th>
								<td>
									<select onchange="wppaAjaxUpdateAlbum(<?php 
            echo $edit_id;
            ?>
, 'suba_order_by', this)" >
										<option value="0" <?php 
            if (!$albuminfo['suba_order_by']) {
                echo 'selected="selected"';
            }
            ?>
><?php 
            _e('See Table IV-D1', 'wp-photo-album-plus');
            ?>
</option>
										<option value="3" <?php 
            if ($albuminfo['suba_order_by'] == '3') {
                echo 'selected="selected"';
            }
            ?>
><?php 
            _e('Random', 'wp-photo-album-plus');
            ?>
</option>
										<option value="1" <?php 
            if ($albuminfo['suba_order_by'] == '1') {
                echo 'selected="selected"';
            }
            ?>
><?php 
            _e('Order #', 'wp-photo-album-plus');
            ?>
</option>
										<option value="-1" <?php 
            if ($albuminfo['suba_order_by'] == '-1') {
                echo 'selected="selected"';
            }
            ?>
><?php 
            _e('Order # reverse', 'wp-photo-album-plus');
            ?>
</option>
										<option value="2" <?php 
            if ($albuminfo['suba_order_by'] == '2') {
                echo 'selected="selected"';
            }
            ?>
><?php 
            _e('Name', 'wp-photo-album-plus');
            ?>
</option>
										<option value="-2" <?php 
            if ($albuminfo['suba_order_by'] == '-2') {
                echo 'selected="selected"';
            }
            ?>
><?php 
            _e('Name reverse', 'wp-photo-album-plus');
            ?>
</option>
										<option value="5" <?php 
            if ($albuminfo['suba_order_by'] == '5') {
                echo 'selected="selected"';
            }
            ?>
><?php 
            _e('Timestamp', 'wp-photo-album-plus');
            ?>
</option>
										<option value="-5" <?php 
            if ($albuminfo['suba_order_by'] == '-5') {
                echo 'selected="selected"';
            }
            ?>
><?php 
            _e('Timestamp reverse', 'wp-photo-album-plus');
            ?>
</option>
									</select>
								</td>
								<td>
									<span class="description">
										<?php 
            _e('Specify the sequence order method to be used for the sub albums of this album.', 'wp-photo-album-plus');
            ?>
									</span>
								</td>
							</tr>

							<!-- Alternative thumbnail size? -->
							<?php 
            if (!wppa_switch('wppa_alt_is_restricted') || current_user_can('administrator')) {
                ?>
							<tr>
								<th>
									<label><?php 
                _e('Use alt thumbsize:', 'wp-photo-album-plus');
                ?>
</label>
								</th>
								<td>
									<select onchange="wppaAjaxUpdateAlbum(<?php 
                echo $edit_id;
                ?>
, 'alt_thumbsize', this)" >
										<option value="0" <?php 
                if (!$albuminfo['alt_thumbsize']) {
                    echo 'selected="selected"';
                }
                ?>
><?php 
                _e('no', 'wp-photo-album-plus');
                ?>
</option>
										<option value="yes" <?php 
                if ($albuminfo['alt_thumbsize']) {
                    echo 'selected="selected"';
                }
                ?>
><?php 
                _e('yes', 'wp-photo-album-plus');
                ?>
</option>
									</select>
								</td>
								<td>
									<span class="description">
										<?php 
                _e('If set to <b>yes</b> The settings in <b>Table I-C1a,3a</b> and <b>4a</b> apply rather than <b>I-C1,3</b> and <b>4</b>.', 'wp-photo-album-plus');
                ?>
									</span>
								</td>
							</tr>
							<?php 
            }
            ?>

							<!-- Cover type -->
							<?php 
            if (!wppa_switch('wppa_covertype_is_restricted') || current_user_can('administrator')) {
                ?>
							<tr>
								<th>
									<label><?php 
                _e('Cover Type:', 'wp-photo-album-plus');
                ?>
</label>
								</th>
								<td>
									<?php 
                $sel = 'selected="selected"';
                ?>
									<select onchange="wppaAjaxUpdateAlbum(<?php 
                echo $edit_id;
                ?>
, 'cover_type', this)" >
										<option value="" <?php 
                if ($albuminfo['cover_type'] == '') {
                    echo $sel;
                }
                ?>
 ><?php 
                _e('--- default ---', 'wp-photo-album-plus');
                ?>
</option>
										<option value="default" <?php 
                if ($albuminfo['cover_type'] == 'default') {
                    echo $sel;
                }
                ?>
 ><?php 
                _e('Standard', 'wp-photo-album-plus');
                ?>
</option>
										<option value="longdesc" <?php 
                if ($albuminfo['cover_type'] == 'longdesc') {
                    echo $sel;
                }
                ?>
 ><?php 
                _e('Long Descriptions', 'wp-photo-album-plus');
                ?>
</option>
										<option value="imagefactory" <?php 
                if ($albuminfo['cover_type'] == 'imagefactory') {
                    echo $sel;
                }
                ?>
 ><?php 
                _e('Image Factory', 'wp-photo-album-plus');
                ?>
</option>
										<option value="default-mcr" <?php 
                if ($albuminfo['cover_type'] == 'default-mcr') {
                    echo $sel;
                }
                ?>
 ><?php 
                _e('Standard mcr', 'wp-photo-album-plus');
                ?>
</option>
										<option value="longdesc-mcr" <?php 
                if ($albuminfo['cover_type'] == 'longdesc-mcr') {
                    echo $sel;
                }
                ?>
 ><?php 
                _e('Long Descriptions mcr', 'wp-photo-album-plus');
                ?>
</option>
										<option value="imagefactory-mcr" <?php 
                if ($albuminfo['cover_type'] == 'imagefactory-mcr') {
                    echo $sel;
                }
                ?>
 ><?php 
                _e('Image Factory mcr', 'wp-photo-album-plus');
                ?>
</option>
									</select>
								</td>
								<td>
									<span class="description">
										<?php 
                _e('The default cover type is the systems standard set in the <b>Photo Albums -> Settings</b> page <b>Table IV-D6</b>.', 'wp-photo-album-plus');
                ?>
									</span>
								</td>
							</tr>
							<?php 
            }
            ?>

							<!-- Cover photo -->
							<tr>
								<th>
									<label><?php 
            _e('Cover Photo:', 'wp-photo-album-plus');
            ?>
</label>
								</th>
								<td>
									<?php 
            echo wppa_main_photo($albuminfo['main_photo'], $albuminfo['cover_type']);
            ?>
								</td>
								<td>
									<span class="description">
										<?php 
            if (wppa_opt('cover_type') == 'default') {
                _e('Select the photo you want to appear on the cover of this album.', 'wp-photo-album-plus');
            } else {
                _e('Select the way the cover photos of this album are selected, or select a single image.', 'wp-photo-album-plus');
            }
            ?>
									</span>
								</td>
							</tr>

							<!-- Upload limit -->
							<tr>
								<th>
									<label><?php 
            _e('Upload limit:', 'wp-photo-album-plus');
            ?>
</label>
								</th>
								<td>
								<?php 
            $lims = explode('/', $albuminfo['upload_limit']);
            if (current_user_can('administrator')) {
                ?>
										<input type="text" id="upload_limit_count" value="<?php 
                echo $lims[0];
                ?>
" style="width: 50px" onchange="wppaAjaxUpdateAlbum(<?php 
                echo $edit_id;
                ?>
, 'upload_limit_count', this)" />
										<select onchange="wppaAjaxUpdateAlbum(<?php 
                echo $edit_id;
                ?>
, 'upload_limit_time', this)" >
											<option value="0" <?php 
                if ($lims[1] == '0') {
                    echo 'selected="selected"';
                }
                ?>
><?php 
                _e('for ever', 'wp-photo-album-plus');
                ?>
</option>
											<option value="3600" <?php 
                if ($lims[1] == '3600') {
                    echo 'selected="selected"';
                }
                ?>
><?php 
                _e('per hour', 'wp-photo-album-plus');
                ?>
</option>
											<option value="86400" <?php 
                if ($lims[1] == '86400') {
                    echo 'selected="selected"';
                }
                ?>
><?php 
                _e('per day', 'wp-photo-album-plus');
                ?>
</option>
											<option value="604800" <?php 
                if ($lims[1] == '604800') {
                    echo 'selected="selected"';
                }
                ?>
><?php 
                _e('per week', 'wp-photo-album-plus');
                ?>
</option>
											<option value="2592000" <?php 
                if ($lims[1] == '2592000') {
                    echo 'selected="selected"';
                }
                ?>
><?php 
                _e('per month', 'wp-photo-album-plus');
                ?>
</option>
											<option value="31536000" <?php 
                if ($lims[1] == '31536000') {
                    echo 'selected="selected"';
                }
                ?>
><?php 
                _e('per year', 'wp-photo-album-plus');
                ?>
</option>
										</select>
										</td>
										<td>
										<span class="description"><?php 
                _e('Set the upload limit (0 means unlimited) and the upload limit period.', 'wp-photo-album-plus');
                ?>
</span>
										<?php 
            } else {
                if ($lims[0] == '0') {
                    _e('Unlimited', 'wp-photo-album-plus');
                } else {
                    echo $lims[0] . ' ';
                    switch ($lims[1]) {
                        case '3600':
                            _e('per hour', 'wp-photo-album-plus');
                            break;
                        case '86400':
                            _e('per day', 'wp-photo-album-plus');
                            break;
                        case '604800':
                            _e('per week', 'wp-photo-album-plus');
                            break;
                        case '2592000':
                            _e('per month', 'wp-photo-album-plus');
                            break;
                        case '31536000':
                            _e('per year', 'wp-photo-album-plus');
                            break;
                    }
                }
            }
            ?>
								</td>
							</tr>

							<!-- Cats -->
							<tr>
								<th>
									<label><?php 
            _e('Catogories:', 'wp-photo-album-plus');
            ?>
</label>
									<span class="description" >
										<br />&nbsp;
									</span>
								</th>
								<td>
									<input id="cats" type="text" style="width:100%;" onkeyup="wppaAjaxUpdateAlbum(<?php 
            echo $edit_id;
            ?>
, 'cats', this)" onchange="wppaAjaxUpdateAlbum(<?php 
            echo $edit_id;
            ?>
, 'cats', this)" value="<?php 
            echo stripslashes(trim($albuminfo['cats'], ','));
            ?>
" />
								</td>
								<td>
									<span class="description" >
										<?php 
            _e('Separate categories with commas.', 'wp-photo-album-plus');
            ?>
&nbsp;
										<?php 
            _e('Examples:', 'wp-photo-album-plus');
            $catlist = wppa_get_catlist();
            ?>
										<select onchange="wppaAddCat(this.value, 'cats'); wppaAjaxUpdateAlbum(<?php 
            echo $edit_id;
            ?>
, 'cats', document.getElementById('cats'))" >
											<?php 
            if (is_array($catlist)) {
                echo '<option value="" >' . __('- select -', 'wp-photo-album-plus') . '</option>';
                foreach ($catlist as $cat) {
                    echo '<option value="' . $cat['cat'] . '" >' . $cat['cat'] . '</option>';
                }
            } else {
                echo '<option value="0" >' . __('No categories yet', 'wp-photo-album-plus') . '</option>';
            }
            ?>
										</select>
										<?php 
            _e('Select to add', 'wp-photo-album-plus');
            ?>
									</span>
								</td>
							</tr>

							<!-- Default tags -->
							<tr>
								<th>
									<label><?php 
            _e('Default photo tags:', 'wp-photo-album-plus');
            ?>
</label>
								</th>
								<td>
									<input type="text" id="default_tags" value="<?php 
            echo trim($albuminfo['default_tags'], ',');
            ?>
" style="width: 100%" onkeyup="wppaAjaxUpdateAlbum(<?php 
            echo $edit_id;
            ?>
, 'default_tags', this)" onchange="wppaAjaxUpdateAlbum(<?php 
            echo $edit_id;
            ?>
, 'default_tags', this)" />
								</td>
								<td>
									<span class="description"><?php 
            _e('Enter the tags that you want to be assigned to new photos in this album.', 'wp-photo-album-plus');
            ?>
</span>
								</td>
							</tr>

							<!-- Apply default tags -->
							<?php 
            $onc1 = 'if (confirm(\'' . __('Are you sure you want to set the default tags to all photos in this album?', 'wp-photo-album-plus') . '\')) { alert(\'The page will be reloaded after the action has taken place.\');wppaRefreshAfter(); wppaAjaxUpdateAlbum(' . $edit_id . ', \'set_deftags\', 0 ); }';
            ?>
							<?php 
            $onc2 = 'if (confirm(\'' . __('Are you sure you want to add the default tags to all photos in this album?', 'wp-photo-album-plus') . '\')) { alert(\'The page will be reloaded after the action has taken place.\');wppaRefreshAfter(); wppaAjaxUpdateAlbum(' . $edit_id . ', \'add_deftags\', 0 ); }';
            ?>
							<tr>
								<th>
									<a onclick="<?php 
            echo $onc1;
            ?>
" ><?php 
            _e('Apply default tags', 'wp-photo-album-plus');
            ?>
</a>
								</th>
								<td>
								</td>
								<td>
									<span class="description"><?php 
            _e('Tag all photos in this album with the default tags.', 'wp-photo-album-plus');
            ?>
</span>
								</td>
							</tr>
							<tr>
								<th>
									<a onclick="<?php 
            echo $onc2;
            ?>
" ><?php 
            _e('Add default tags', 'wp-photo-album-plus');
            ?>
</a>
								</th>
								<td>
								</td>
								<td>
									<span class="description"><?php 
            _e('Add the default tags to all photos in this album.', 'wp-photo-album-plus');
            ?>
</span>
								</td>
							</tr>

							<!-- Link type -->
							<tr>
								<th>
									<label><?php 
            _e('Link type:', 'wp-photo-album-plus');
            ?>
</label>
								</th>
								<td>
									<?php 
            $linktype = $albuminfo['cover_linktype'];
            ?>
									<?php 
            /* if ( !$linktype ) $linktype = 'content'; /* Default */
            ?>
									<?php 
            /* if ( $albuminfo['cover_linkpage'] == '-1' ) $linktype = 'none'; /* for backward compatibility */
            ?>
									<select onchange="wppaAjaxUpdateAlbum(<?php 
            echo $edit_id;
            ?>
, 'cover_linktype', this)" >
										<option value="content" <?php 
            if ($linktype == 'content') {
                echo $sel;
            }
            ?>
><?php 
            _e('the sub-albums and thumbnails', 'wp-photo-album-plus');
            ?>
</option>
										<option value="albums" <?php 
            if ($linktype == 'albums') {
                echo $sel;
            }
            ?>
><?php 
            _e('the sub-albums', 'wp-photo-album-plus');
            ?>
</option>
										<option value="thumbs" <?php 
            if ($linktype == 'thumbs') {
                echo $sel;
            }
            ?>
><?php 
            _e('the thumbnails', 'wp-photo-album-plus');
            ?>
</option>
										<option value="slide" <?php 
            if ($linktype == 'slide') {
                echo $sel;
            }
            ?>
><?php 
            _e('the album photos as slideshow', 'wp-photo-album-plus');
            ?>
</option>
										<option value="page" <?php 
            if ($linktype == 'page') {
                echo $sel;
            }
            ?>
><?php 
            _e('the link page with a clean url', 'wp-photo-album-plus');
            ?>
</option>
										<option value="none" <?php 
            if ($linktype == 'none') {
                echo $sel;
            }
            ?>
><?php 
            _e('no link at all', 'wp-photo-album-plus');
            ?>
</option>
									</select>
								</td>
								<td>
									<span class="description">
										<?php 
            if (wppa_switch('auto_page')) {
                _e('If you select "the link page with a clean url", select an Auto Page of one of the photos in this album.', 'wp-photo-album-plus');
            } else {
                _e('If you select "the link page with a clean url", make sure you enter the correct shortcode on the target page.', 'wp-photo-album-plus');
            }
            ?>
									</span>
								</td>
							</tr>

							<!-- Link page -->
							<?php 
            if (!wppa_switch('wppa_link_is_restricted') || current_user_can('administrator')) {
                ?>
							<tr>
								<th>
									<label><?php 
                _e('Link to:', 'wp-photo-album-plus');
                ?>
</label>
								</th>
								<td style="max-width:210px;" >
									<?php 
                $query = 'SELECT `ID`, `post_title` FROM `' . $wpdb->posts . '` WHERE `post_type` = \'page\' AND `post_status` = \'publish\' ORDER BY `post_title` ASC';
                $pages = $wpdb->get_results($query, ARRAY_A);
                if (empty($pages)) {
                    _e('There are no pages (yet) to link to.', 'wp-photo-album-plus');
                } else {
                    $linkpage = $albuminfo['cover_linkpage'];
                    if (!is_numeric($linkpage)) {
                        $linkpage = '0';
                    }
                    ?>
										<select onchange="wppaAjaxUpdateAlbum(<?php 
                    echo $edit_id;
                    ?>
, 'cover_linkpage', this)" style="max-width:100%;">
											<option value="0" <?php 
                    if ($linkpage == '0') {
                        echo $sel;
                    }
                    ?>
><?php 
                    _e('--- the same page or post ---', 'wp-photo-album-plus');
                    ?>
</option>
											<?php 
                    foreach ($pages as $page) {
                        ?>
												<option value="<?php 
                        echo $page['ID'];
                        ?>
" <?php 
                        if ($linkpage == $page['ID']) {
                            echo $sel;
                        }
                        ?>
><?php 
                        _e($page['post_title'], 'wp-photo-album-plus');
                        ?>
</option>
											<?php 
                    }
                    ?>
										</select>
								</td>
								<td>
										<span class="description">
											<?php 
                    _e('If you want, you can link the title to a WP page in stead of the album\'s content. If so, select the page the title links to.', 'wp-photo-album-plus');
                    ?>
										</span>
									<?php 
                }
                ?>
								</td>
							</tr>
							<?php 
            }
            ?>

							<!-- Schedule -->
							<tr>
								<th>
									<label><?php 
            _e('Schedule:', 'wp-photo-album-plus');
            ?>
</label>
									<input type="checkbox" <?php 
            if ($albuminfo['scheduledtm']) {
                echo 'checked="checked"';
            }
            ?>
 onchange="wppaChangeScheduleAlbum(<?php 
            echo $edit_id;
            ?>
, this);" />
								</th>
								<td>
									<input type="hidden" value="" id="wppa-dummy" />
									<span class="wppa-datetime-<?php 
            echo $edit_id;
            ?>
" <?php 
            if (!$albuminfo['scheduledtm']) {
                echo 'style="display:none;"';
            }
            ?>
 >
										<?php 
            echo wppa_get_date_time_select_html('album', $edit_id, true);
            ?>
									</span>
								</td>
								<td>
									<span class="description">
										<?php 
            _e('If enabled, new photos will have their status set to the dat/time specified here.', 'wp-photo-album-plus');
            ?>
									</span>
								</td>
							</tr>
							<tr class="wppa-datetime-<?php 
            echo $edit_id;
            ?>
" >
								<th>
									<a onclick="if (confirm('<?php 
            _e('Are you sure you want to schedule all photos in this album?', 'wp-photo-album-plus');
            ?>
')) { alert('The page will be reloaded after the action has taken place.'); wppaRefreshAfter(); wppaAjaxUpdateAlbum(<?php 
            echo $edit_id;
            ?>
, 'setallscheduled', 0 ) }" ><?php 
            _e('Schedule all', 'wp-photo-album-plus');
            ?>
</a>
								</th>
							</tr>

							<!-- Reset Ratings -->
							<?php 
            if (wppa_switch('wppa_rating_on')) {
                ?>
								<tr>
									<th>
										<a onclick="if (confirm('<?php 
                _e('Are you sure you want to clear the ratings in this album?', 'wp-photo-album-plus');
                ?>
')) wppaAjaxUpdateAlbum(<?php 
                echo $edit_id;
                ?>
, 'clear_ratings', 0 )" ><?php 
                _e('Reset ratings', 'wp-photo-album-plus');
                ?>
</a>
									</th>
								</tr>
							<?php 
            }
            ?>

							<!-- Goto Upload -->
							<?php 
            if (current_user_can('wppa_upload')) {
                $a = wppa_allow_uploads($albuminfo['id']);
                if ($a) {
                    $full = 'none';
                    $notfull = '';
                } else {
                    $full = '';
                    $notfull = 'none';
                }
                $onc = 'document.location = \'' . wppa_dbg_url(get_admin_url()) . '/admin.php?page=wppa_upload_photos&wppa-set-album=' . $albuminfo['id'] . '\'';
                $oncfull = 'alert(\'' . __('Change the upload limit or remove photos to enable new uploads.', 'wp-photo-album-plus') . '\')';
                ?>
								<tr>
									<th>
										<a id="notfull" style="display:<?php 
                echo $notfull;
                ?>
" onclick="<?php 
                echo $onc;
                ?>
" ><?php 
                _e('Upload to this album', 'wp-photo-album-plus');
                if ($a > '0') {
                    echo ' ' . sprintf(__('(max %d)', 'wp-photo-album-plus'), $a);
                }
                ?>
</a>
										<a id="full" style="display:<?php 
                echo $full;
                ?>
" onclick="<?php 
                echo $oncfull;
                ?>
" ><?php 
                _e('Album is full', 'wp-photo-album-plus');
                ?>
</a>
									</th>
								</tr>
							<?php 
            }
            ?>

							<!-- Apply New photo desc -->
							<?php 
            if (wppa_switch('wppa_apply_newphoto_desc')) {
                $onc = 'if ( confirm(\'Are you sure you want to set the description of all photos to \\n\\n' . esc_js(wppa_opt('wppa_newphoto_description')) . '\')) document.location=\'' . wppa_ea_url($albuminfo['id'], 'edit') . '&applynewdesc\'';
                ?>
								<tr>
									<th>
										<a onclick="<?php 
                echo $onc;
                ?>
" ><?php 
                _e('Apply new photo desc', 'wp-photo-album-plus');
                ?>
</a>
									</th>
								</tr>
							<?php 
            }
            ?>

							<!-- Remake all -->
							<?php 
            if (current_user_can('administrator')) {
                $onc = 'if ( confirm(\'Are you sure you want to remake the files for all photos in this album?\')) document.location=\'' . wppa_ea_url($albuminfo['id'], 'edit') . '&remakealbum\'';
                ?>
								<tr>
									<th>
										<a onclick="<?php 
                echo $onc;
                ?>
" ><?php 
                _e('Remake all', 'wp-photo-album-plus');
                ?>
</a>
									</th>
								</tr>
							<?php 
            }
            ?>

							<!-- Status -->
							<tr >
								<th style="color:blue;" >
									<label style="color:#070"><?php 
            _e('Remark:', 'wp-photo-album-plus');
            ?>
</label>
								</th>
								<td id="albumstatus-<?php 
            echo $edit_id;
            ?>
" >
									<?php 
            echo sprintf(__('Album %s is not modified yet', 'wp-photo-album-plus'), $edit_id);
            ?>
								</td>
							</tr>
						</tbody>
					</table>
<a name="manage-photos" id="manage-photos" ></a>
				<h2><?php 
            _e('Manage Photos', 'wp-photo-album-plus');
            if (isset($_REQUEST['bulk'])) {
                echo ' - <small><i>' . __('Copy / move / delete / edit name / edit description / change status', 'wp-photo-album-plus') . '</i></small>';
            } elseif (isset($_REQUEST['seq'])) {
                echo ' - <small><i>' . __('Change sequence order by drag and drop', 'wp-photo-album-plus') . '</i></small>';
            } elseif (isset($_REQUEST['quick'])) {
                echo ' - <small><i>' . __('Edit photo information except copy and move', 'wp-photo-album-plus') . '</i></small>';
            } else {
                echo ' - <small><i>' . __('Edit photo information', 'wp-photo-album-plus') . '</i></small>';
            }
            ?>
</h2>
				<?php 
            if (isset($_REQUEST['bulk'])) {
                wppa_album_photos_bulk($edit_id);
            } elseif (isset($_REQUEST['seq'])) {
                wppa_album_photos_sequence($edit_id);
            } else {
                wppa_album_photos($edit_id);
            }
            ?>
				<br /><a href="#manage-photos"><?php 
            _e('Top of page', 'wp-photo-album-plus');
            ?>
</a>
			</div>
<?php 
        } else {
            if ($_REQUEST['tab'] == 'cmod') {
                $photo = $_REQUEST['photo'];
                $alb = wppa_get_album_id_by_photo_id($photo);
                if (current_user_can('wppa_comments') && wppa_have_access($alb)) {
                    ?>
				<div class="wrap">
					<h2><?php 
                    _e('Moderate comment', 'wp-photo-album-plus');
                    ?>
</h2>
				<?php 
                    //	<input type="hidden" id="album-nonce-<?php echo $edit_id
                    //" value="<?php echo wp_create_nonce('wppa_nonce_'.$edit_id);
                    //" />
                    ?>
					<?php 
                    wppa_album_photos('', $photo);
                    ?>
				</div>
<?php 
                } else {
                    wp_die('You do not have the rights to do this');
                }
            } elseif ($_REQUEST['tab'] == 'pmod' || $_REQUEST['tab'] == 'pedit') {
                $photo = $_REQUEST['photo'];
                $alb = wppa_get_album_id_by_photo_id($photo);
                if (current_user_can('wppa_admin') && wppa_have_access($alb)) {
                    ?>
				<div class="wrap">
					<h2><?php 
                    if ($_REQUEST['tab'] == 'pmod') {
                        _e('Moderate photo', 'wp-photo-album-plus');
                    } else {
                        _e('Edit photo', 'wp-photo-album-plus');
                    }
                    ?>
					</h2>
					<?php 
                    wppa_album_photos('', $photo);
                    ?>
				</div>
<?php 
                } else {
                    wp_die('You do not have the rights to do this');
                }
            } else {
                if ($_REQUEST['tab'] == 'del') {
                    $album_owner = $wpdb->get_var($wpdb->prepare("SELECT `owner` FROM " . WPPA_ALBUMS . " WHERE `id` = %s", $_REQUEST['edit_id']));
                    if ($album_owner == '--- public ---' && !current_user_can('administrator') || !wppa_have_access($_REQUEST['edit_id'])) {
                        wp_die('You do not have the rights to delete this album');
                    }
                    ?>
			<div class="wrap">
				<?php 
                    $iconurl = WPPA_URL . '/images/albumdel32.png';
                    ?>
				<div id="icon-albumdel" class="icon32" style="background: transparent url(<?php 
                    echo $iconurl;
                    ?>
) no-repeat">
					<br />
				</div>

				<h2><?php 
                    _e('Delete Album', 'wp-photo-album-plus');
                    ?>
</h2>

				<p><?php 
                    _e('Album:', 'wp-photo-album-plus');
                    ?>
 <b><?php 
                    echo wppa_get_album_name($_REQUEST['edit_id']);
                    ?>
.</b></p>
				<p><?php 
                    _e('Are you sure you want to delete this album?', 'wp-photo-album-plus');
                    ?>
<br />
					<?php 
                    _e('Press Delete to continue, and Cancel to go back.', 'wp-photo-album-plus');
                    ?>
				</p>
				<form name="wppa-del-form" action="<?php 
                    echo wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_admin_menu');
                    ?>
" method="post">
					<?php 
                    wp_nonce_field('$wppa_nonce', WPPA_NONCE);
                    ?>
					<p>
						<?php 
                    _e('What would you like to do with photos currently in the album?', 'wp-photo-album-plus');
                    ?>
<br />
						<input type="radio" name="wppa-del-photos" value="delete" checked="checked" /> <?php 
                    _e('Delete', 'wp-photo-album-plus');
                    ?>
<br />
						<input type="radio" name="wppa-del-photos" value="move" /> <?php 
                    _e('Move to:', 'wp-photo-album-plus');
                    ?>
						<select name="wppa-move-album">
							<?php 
                    echo wppa_album_select_a(array('checkaccess' => true, 'path' => wppa_switch('wppa_hier_albsel'), 'selected' => '0', 'exclude' => $_REQUEST['edit_id'], 'addpleaseselect' => true));
                    ?>
						</select>
					</p>

					<input type="hidden" name="wppa-del-id" value="<?php 
                    echo $_REQUEST['edit_id'];
                    ?>
" />
					<input type="button" class="button-primary" value="<?php 
                    _e('Cancel', 'wp-photo-album-plus');
                    ?>
" onclick="parent.history.back()" />
					<input type="submit" class="button-primary" style="color: red" name="wppa-del-confirm" value="<?php 
                    _e('Delete', 'wp-photo-album-plus');
                    ?>
" />
				</form>
			</div>
<?php 
                }
            }
        }
    } else {
        //  'tab' not set. default, album manage page.
        // if add form has been submitted
        //		if (isset($_POST['wppa-na-submit'])) {
        //			check_admin_referer( '$wppa_nonce', WPPA_NONCE );
        //			wppa_add_album();
        //		}
        // if album deleted
        if (isset($_POST['wppa-del-confirm'])) {
            check_admin_referer('$wppa_nonce', WPPA_NONCE);
            $album_owner = $wpdb->get_var($wpdb->prepare("SELECT `owner` FROM " . WPPA_ALBUMS . " WHERE `id` = %s", $_POST['wppa-del-id']));
            if ($album_owner == '--- public ---' && !current_user_can('administrator') || !wppa_have_access($_POST['wppa-del-id'])) {
                wp_die('You do not have the rights to delete this album');
            }
            if ($_POST['wppa-del-photos'] == 'move') {
                $move = $_POST['wppa-move-album'];
                if (wppa_have_access($move)) {
                    wppa_del_album($_POST['wppa-del-id'], $move);
                } else {
                    wppa_error_message(__('Unable to move photos. Album not deleted.', 'wp-photo-album-plus'));
                }
            } else {
                wppa_del_album($_POST['wppa-del-id'], '');
            }
        }
        if (wppa_extended_access()) {
            if (isset($_REQUEST['switchto'])) {
                update_option('wppa_album_table_' . wppa_get_user(), $_REQUEST['switchto']);
            }
            $style = get_option('wppa_album_table_' . wppa_get_user(), 'flat');
        } else {
            $style = 'flat';
        }
        // The Manage Album page
        ?>
		<div class="wrap">
		<?php 
        wppa_admin_spinner();
        ?>
			<?php 
        $iconurl = WPPA_URL . '/images/album32.png';
        ?>
			<div id="icon-album" class="icon32" style="background: transparent url(<?php 
        echo $iconurl;
        ?>
) no-repeat">
				<br />
			</div>

			<h2><?php 
        _e('Manage Albums', 'wp-photo-album-plus');
        ?>
</h2>
			<br />
			<?php 
        // The Create new album button
        if (wppa_can_create_top_album()) {
            $url = wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_admin_menu&amp;tab=edit&amp;edit_id=new');
            $vfy = __('Are you sure you want to create a new album?', 'wp-photo-album-plus');
            echo '<form method="post" action="' . get_admin_url() . 'admin.php?page=wppa_admin_menu" style="float:left; margin-right:12px;" >';
            echo '<input type="hidden" name="tab" value="edit" />';
            echo '<input type="hidden" name="edit_id" value="new" />';
            $onc = wppa_switch('confirm_create') ? 'onclick="return confirm(\'' . $vfy . '\');"' : '';
            echo '<input type="submit" class="button-primary" ' . $onc . ' value="' . __('Create New Empty Album', 'wp-photo-album-plus') . '" style="height:28px;" />';
            echo '</form>';
        }
        // The switch to button(s)
        if (wppa_extended_access()) {
            if ($style == 'flat') {
                ?>
					<input type="button" class="button-secundary" onclick="document.location='<?php 
                echo wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_admin_menu&amp;switchto=collapsable');
                ?>
'" value="<?php 
                _e('Switch to Collapsable table', 'wp-photo-album-plus');
                ?>
" />
				<?php 
            }
            if ($style == 'collapsable') {
                ?>
					<input type="button" class="button-secundary" onclick="document.location='<?php 
                echo wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_admin_menu&amp;switchto=flat');
                ?>
'" value="<?php 
                _e('Switch to Flat table', 'wp-photo-album-plus');
                ?>
" />
				<?php 
            }
        }
        ?>

			<br />
			<?php 
        // The table of existing albums
        if ($style == 'flat') {
            wppa_admin_albums_flat();
        } else {
            wppa_admin_albums_collapsable();
        }
        ?>
			<br />
		</div>
<?php 
    }
}
function _wppa_admin()
{
    global $wpdb;
    global $q_config;
    global $wppa_revno;
    if (get_option('wppa_revision') != $wppa_revno) {
        wppa_check_database(true);
    }
    echo '
<script type="text/javascript">
	/* <![CDATA[ */
	wppaAjaxUrl = "' . admin_url('admin-ajax.php') . '";
	wppaUploadToThisAlbum = "' . __('Upload to this album', 'wp-photo-album-plus') . '";
	wppaImageDirectory = "' . wppa_get_imgdir() . '";
	/* ]]> */
</script>
';
    // Delete trashed comments
    $query = "DELETE FROM " . WPPA_COMMENTS . " WHERE status='trash'";
    $wpdb->query($query);
    $sel = 'selected="selected"';
    // warn if the uploads directory is no writable
    if (!is_writable(WPPA_UPLOAD_PATH)) {
        wppa_error_message(__('Warning:', 'wp-photo-album-plus') . sprintf(__('The uploads directory does not exist or is not writable by the server. Please make sure that %s is writeable by the server.', 'wp-photo-album-plus'), WPPA_UPLOAD_PATH));
    }
    // Fix orphan albums and deleted target pages
    $albs = $wpdb->get_results("SELECT * FROM `" . WPPA_ALBUMS . "`", ARRAY_A);
    // Now we have tham, put them in cache
    wppa_cache_album('add', $albs);
    if ($albs) {
        foreach ($albs as $alb) {
            if ($alb['a_parent'] > '0' && wppa_get_parentalbumid($alb['a_parent']) == '-9') {
                // Parent died?
                $wpdb->query("UPDATE `" . WPPA_ALBUMS . "` SET `a_parent` = '-1' WHERE `id` = '" . $alb['id'] . "'");
            }
            if ($alb['cover_linkpage'] > '0') {
                $iret = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM `" . $wpdb->posts . "` WHERE `ID` = %s AND `post_type` = 'page' AND `post_status` = 'publish'", $alb['cover_linkpage']));
                if (!$iret) {
                    // Page gone?
                    $wpdb->query("UPDATE `" . WPPA_ALBUMS . "` SET `cover_linkpage` = '0' WHERE `id` = '" . $alb['id'] . "'");
                }
            }
        }
    }
    if (isset($_REQUEST['tab'])) {
        // album edit page
        if ($_REQUEST['tab'] == 'edit') {
            if (isset($_REQUEST['edit_id'])) {
                $ei = $_REQUEST['edit_id'];
                if ($ei != 'new' && $ei != 'search' && !is_numeric($ei)) {
                    wp_die('Security check failure 1');
                }
            }
            if ($_REQUEST['edit_id'] == 'search') {
                $back_url = get_admin_url() . 'admin.php?page=wppa_admin_menu';
                if (isset($_REQUEST['wppa-searchstring'])) {
                    $back_url .= '&wppa-searchstring=' . wppa_sanitize_searchstring($_REQUEST['wppa-searchstring']);
                }
                $back_url .= '#wppa-edit-search-tag';
                ?>
<a name="manage-photos" id="manage-photos" ></a>
				<h2><?php 
                _e('Manage Photos', 'wp-photo-album-plus');
                if (isset($_REQUEST['bulk'])) {
                    echo ' - <small><i>' . __('Copy / move / delete / edit name / edit description / change status', 'wp-photo-album-plus') . '</i></small>';
                } elseif (isset($_REQUEST['quick'])) {
                    echo ' - <small><i>' . __('Edit photo information except copy and move', 'wp-photo-album-plus') . '</i></small>';
                } else {
                    echo ' - <small><i>' . __('Edit photo information', 'wp-photo-album-plus') . '</i></small>';
                }
                ?>
</h2>

<a href="<?php 
                echo $back_url;
                ?>
"><?php 
                _e('Back to album table', 'wp-photo-album-plus');
                ?>
</a><br /><br />

				<?php 
                if (isset($_REQUEST['bulk'])) {
                    wppa_album_photos_bulk($ei);
                } else {
                    wppa_album_photos($ei);
                }
                ?>
				<br /><a href="#manage-photos"><?php 
                _e('Top of page', 'wp-photo-album-plus');
                ?>
</a>
				<br /><a href="<?php 
                echo $back_url;
                ?>
"><?php 
                _e('Back to album table', 'wp-photo-album-plus');
                ?>
</a>
<?php 
                return;
            }
            if ($_REQUEST['edit_id'] == 'new') {
                if (!wppa_can_create_album()) {
                    wp_die('No rights to create an album');
                }
                $id = wppa_nextkey(WPPA_ALBUMS);
                if (isset($_REQUEST['parent_id'])) {
                    $parent = $_REQUEST['parent_id'];
                    if (!is_numeric($parent)) {
                        wp_die('Security check failure 2');
                    }
                    $name = wppa_get_album_name($parent) . '-#' . $id;
                    if (!current_user_can('administrator')) {
                        // someone creating an album for someone else?
                        $parentowner = $wpdb->get_var($wpdb->prepare("SELECT `owner` FROM `" . WPPA_ALBUMS . "` WHERE `id` = %s", $parent));
                        if ($parentowner !== wppa_get_user()) {
                            wp_die('You are not allowed to create an album for someone else');
                        }
                    }
                } else {
                    $parent = wppa_opt('default_parent');
                    if (!$wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM `" . WPPA_ALBUMS . "` WHERE `id` = %s", $parent))) {
                        // Deafault parent vanished
                        wppa_update_option('wppa_default_parent', '0');
                        $parent = '0';
                    }
                    $name = __('New Album', 'wp-photo-album-plus');
                    if (!wppa_can_create_top_album()) {
                        wp_die('No rights to create a top-level album');
                    }
                }
                $id = wppa_create_album_entry(array('id' => $id, 'name' => $name, 'a_parent' => $parent));
                if (!$id) {
                    wppa_error_message(__('Could not create album.', 'wp-photo-album-plus'));
                    wp_die('Sorry, cannot continue');
                } else {
                    $edit_id = $id;
                    wppa_set_last_album($edit_id);
                    wppa_flush_treecounts($edit_id);
                    wppa_index_add('album', $id);
                    wppa_update_message(__('Album #', 'wp-photo-album-plus') . ' ' . $edit_id . ' ' . __('Added.', 'wp-photo-album-plus'));
                    wppa_create_pl_htaccess();
                }
            } else {
                $edit_id = $_REQUEST['edit_id'];
            }
            $album_owner = $wpdb->get_var($wpdb->prepare("SELECT `owner` FROM " . WPPA_ALBUMS . " WHERE `id` = %s", $edit_id));
            if ($album_owner == '--- public ---' && !current_user_can('wppa_admin') || !wppa_have_access($edit_id)) {
                wp_die('You do not have the rights to edit this album');
            }
            // Apply new desc
            if (isset($_REQUEST['applynewdesc'])) {
                if (!wp_verify_nonce($_REQUEST['wppa_nonce'], 'wppa_nonce')) {
                    wp_die('You do not have the rights to do this');
                }
                $iret = $wpdb->query($wpdb->prepare("UPDATE `" . WPPA_PHOTOS . "` SET `description` = %s WHERE `album` = %s", wppa_opt('newphoto_description'), $edit_id));
                wppa_ok_message($iret . ' descriptions updated.');
            }
            // Remake album
            if (isset($_REQUEST['remakealbum'])) {
                if (!wp_verify_nonce($_REQUEST['wppa_nonce'], 'wppa_nonce')) {
                    wp_die('You do not have the rights to do this');
                }
                if (get_option('wppa_remake_start_album_' . $edit_id)) {
                    // Continue after time up
                    wppa_ok_message('Continuing remake, please wait');
                } else {
                    update_option('wppa_remake_start_album_' . $edit_id, time());
                    wppa_ok_message('Remaking photofiles, please wait');
                }
                $iret = wppa_remake_files($edit_id);
                if ($iret) {
                    wppa_ok_message('Photo files remade');
                    update_option('wppa_remake_start_album_' . $edit_id, '0');
                } else {
                    wppa_error_message('Remake of photo files did NOT complete');
                }
            }
            // Get the album information
            $albuminfo = $wpdb->get_row($wpdb->prepare('SELECT * FROM `' . WPPA_ALBUMS . '` WHERE `id` = %s', $edit_id), ARRAY_A);
            // We may not use extract(), so we do something like it here manually, hence controlled.
            $id = $albuminfo['id'];
            $crypt = $albuminfo['crypt'];
            $timestamp = $albuminfo['timestamp'];
            $modified = $albuminfo['modified'];
            $views = $albuminfo['views'];
            $owner = $albuminfo['owner'];
            $a_order = $albuminfo['a_order'];
            $p_order_by = $albuminfo['p_order_by'];
            $a_parent = $albuminfo['a_parent'];
            $suba_order_by = $albuminfo['suba_order_by'];
            $name = stripslashes($albuminfo['name']);
            $description = stripslashes($albuminfo['description']);
            $alt_thumbsize = $albuminfo['alt_thumbsize'];
            $cover_type = $albuminfo['cover_type'];
            $main_photo = $albuminfo['main_photo'];
            $upload_limit = $albuminfo['upload_limit'];
            $cats = stripslashes(trim($albuminfo['cats'], ','));
            $default_tags = trim($albuminfo['default_tags'], ',');
            $cover_linktype = $albuminfo['cover_linktype'];
            // Open the photo album admin page
            echo '<div class="wrap">';
            // The spinner to indicate busyness
            wppa_admin_spinner();
            // Local js functions placed here as long as there is not yet a possibility to translate texts in js files
            ?>
<script>
function wppaTryInheritCats( id ) {

	var query;

	query = '<?php 
            echo esc_js(__('Are you sure you want to inherit categories to all (grand)children of this album?', 'wp-photo-album-plus'));
            ?>
';

	if ( confirm( query ) ) {
		wppaAjaxUpdateAlbum( id, 'inherit_cats', Math.random() );
	}
}

function wppaTryAddCats( id ) {

	var query;

	query = '<?php 
            echo esc_js(__('Are you sure you want to add the categories to all (grand)children of this album?', 'wp-photo-album-plus'));
            ?>
';

	if ( confirm( query ) ) {
		wppaAjaxUpdateAlbum( id, 'inhadd_cats', Math.random() );
	}
}

function wppaTryApplyDeftags( id ) {

	var query;

	query = '<?php 
            echo esc_js(__('Are you sure you want to set the default tags to all photos in this album?', 'wp-photo-album-plus'));
            ?>
';

	if ( confirm( query ) ) {
		wppaAjaxUpdateAlbum( id, 'set_deftags', Math.random(), true );
	}
}

function wppaTryAddDeftags( id ) {

	var query;

	query = '<?php 
            echo esc_js(__('Are you sure you want to add the default tags to all photos in this album?', 'wp-photo-album-plus'));
            ?>
';

	if ( confirm( query ) ) {
		wppaAjaxUpdateAlbum( id, 'add_deftags', Math.random(), true );
	}
}

function wppaTryScheduleAll( id ) {

	var query;

	if ( jQuery( '#schedule-box' ).attr( 'checked' ) != 'checked' ) {
		query = '<?php 
            echo esc_js(__('Please switch feature on and set dat/time to schedule first', 'wp-photo-album-plus'));
            ?>
';
		alert( query );
		return;
	}

	query = '<?php 
            echo esc_js(__('Are you sure you want to schedule all photos in this album?', 'wp-photo-album-plus'));
            ?>
';

	if ( confirm( query ) ) {
		wppaAjaxUpdateAlbum( id, 'setallscheduled', Math.random(), true );
	}
}

</script>
		<?php 
            // The header
            echo '<img src="' . WPPA_URL . '/img/album32.png' . '" alt="Album icon" />' . '<h1 style="display:inline;" >' . __('Edit Album Information', 'wp-photo-album-plus') . '</h1>' . '<p class="description">' . __('All modifications are instantly updated on the server, except for those that require a button push.', 'wp-photo-album-plus') . ' ' . __('The <b style="color:#070" >Remark</b> fields keep you informed on the actions taken at the background.', 'wp-photo-album-plus') . '</p>' . '<input' . ' type="hidden"' . ' id="album-nonce-' . $id . '"' . ' value="' . wp_create_nonce('wppa_nonce_' . $id) . '"' . ' />';
            // The edit albuminfo panel
            echo '<div' . ' id="albumitem-' . $id . '"' . ' class="wppa-table-wrap"' . ' style="width:100%;position:relative;"' . ' >';
            // Section 1
            echo "\n" . '<!-- Album Section 1 -->' . '<table' . ' class="wppa-table wppa-album-table"' . ' >' . '<tbody>' . '<tr>' . '<td>';
            // More or less static data
            // Album number
            echo __('Album number:', 'wp-photo-album-plus') . ' ' . $id . '. ';
            // Crypt
            echo __('Crypt:', 'wp-photo-album-plus') . ' ' . $crypt . '. ';
            // Created
            echo __('Created:', 'wp-photo-album-plus') . ' ' . wppa_local_date('', $timestamp) . ' ' . __('local time', 'wp-photo-album-plus') . '. ';
            // Modified
            echo __('Modified:', 'wp-photo-album-plus') . ' ';
            if ($modified > $timestamp) {
                echo wppa_local_date('', $modified) . ' ' . __('local time', 'wp-photo-album-plus') . '. ';
            } else {
                echo __('Not modified', 'wp-photo-album-plus') . '. ';
            }
            // Views
            if (wppa_switch('track_viewcounts')) {
                echo __('Views:', 'wp-photo-album-plus') . ' ' . $views . '. ';
            }
            // Clicks
            if (wppa_switch('track_clickcounts')) {
                $click_arr = $wpdb->get_col("SELECT `clicks` FROM `" . WPPA_PHOTOS . "` WHERE `album` = {$id}");
                echo __('Clicks:', 'wp-photo-album-plus') . ' ' . array_sum($click_arr) . '. ';
            }
            // Owner
            echo __('Owned by:', 'wp-photo-album-plus') . ' ';
            if (!wppa_user_is('administrator')) {
                if ($owner == '--- public ---') {
                    echo __('--- public ---', 'wp-photo-album-plus') . ' ';
                } else {
                    echo $owner . '. ';
                }
            } else {
                $usercount = wppa_get_user_count();
                if ($usercount > wppa_opt('max_users')) {
                    echo '<input' . ' type="text"' . ' value="' . esc_attr($owner) . '"' . ' onchange="wppaAjaxUpdateAlbum( ' . $id . ', \'owner\', this )"' . ' />';
                } else {
                    echo '<select' . ' onchange="wppaAjaxUpdateAlbum( ' . $id . ', \'owner\', this )"' . ' >';
                    wppa_user_select($owner);
                    echo '</select>' . ' ';
                }
            }
            // Order # -->
            echo __('Album sort order #:', 'wp-photo-album-plus') . ' ' . '<input' . ' type="text"' . ' onkeyup="wppaAjaxUpdateAlbum( ' . $id . ', \'a_order\', this )"' . ' onchange="wppaAjaxUpdateAlbum( ' . $id . ', \'a_order\', this )"' . ' value="' . esc_attr($a_order) . '"' . ' style="width:50px;' . '" />' . ' ';
            if (wppa_opt('list_albums_by') != '1' && $a_order != '0') {
                echo '<small class="description" style="color:red" >' . __('Album order # has only effect if you set the album sort order method to <b>Order #</b> in the Photo Albums -> Settings screen.<br />', 'wp-photo-album-plus') . '</small>' . ' ';
            }
            // Parent
            echo __('Parent album:', 'wp-photo-album-plus') . ' ';
            if (wppa_extended_access()) {
                echo '<select' . ' id="wppa-parsel"' . ' style="max-width:100%;"' . ' onchange="wppaAjaxUpdateAlbum( ' . $id . ', \'a_parent\', this )"' . ' >' . wppa_album_select_a(array('checkaccess' => true, 'exclude' => $id, 'selected' => $a_parent, 'addselected' => true, 'addnone' => true, 'addseparate' => true, 'disableancestors' => true, 'path' => wppa_switch('hier_albsel'))) . '</select>';
            } else {
                echo '<select' . ' id="wppa-parsel"' . ' style="max-width:100%;"' . ' onchange="wppaAjaxUpdateAlbum( ' . $id . ', \'a_parent\', this )"' . ' >' . wppa_album_select_a(array('checkaccess' => true, 'exclude' => $id, 'selected' => $a_parent, 'addselected' => true, 'disableancestors' => true, 'path' => wppa_switch('hier_albsel'))) . '</select>';
            }
            echo ' ';
            // P-order-by
            echo __('Photo order:', 'wp-photo-album-plus') . ' ';
            $options = array(__('--- default --- See Table IV-C1', 'wp-photo-album-plus'), __('Order #', 'wp-photo-album-plus'), __('Name', 'wp-photo-album-plus'), __('Random', 'wp-photo-album-plus'), __('Rating mean value', 'wp-photo-album-plus'), __('Number of votes', 'wp-photo-album-plus'), __('Timestamp', 'wp-photo-album-plus'), __('EXIF Date', 'wp-photo-album-plus'), __('Order # desc', 'wp-photo-album-plus'), __('Name desc', 'wp-photo-album-plus'), __('Rating mean value desc', 'wp-photo-album-plus'), __('Number of votes desc', 'wp-photo-album-plus'), __('Timestamp desc', 'wp-photo-album-plus'), __('EXIF Date desc', 'wp-photo-album-plus'));
            $values = array('0', '1', '2', '3', '4', '6', '5', '7', '-1', '-2', '-4', '-6', '-5', '-7');
            echo '<select' . ' onchange="wppaAjaxUpdateAlbum( ' . $id . ', \'p_order_by\', this )"' . ' >';
            foreach (array_keys($options) as $key) {
                $sel = $values[$key] == $p_order_by ? ' selected="selected"' : '';
                echo '<option value="' . $values[$key] . '"' . $sel . ' >' . $options[$key] . '</option>';
            }
            echo '</select>' . ' ';
            // Child album order
            echo __('Sub album sort order:', 'wp-photo-album-plus') . ' ' . '<select' . ' onchange="wppaAjaxUpdateAlbum( ' . $id . ', \'suba_order_by\', this )"' . ' >' . '<option value="0"' . ($suba_order_by == '0' ? 'selected="selected"' : '') . ' >' . __('--- default --- See Table IV-D1', 'wp-photo-album-plus') . '</option>' . '<option value="3"' . ($suba_order_by == '3' ? 'selected="selected"' : '') . ' >' . __('Random', 'wp-photo-album-plus') . '</option>' . '<option value="1"' . ($suba_order_by == '1' ? 'selected="selected"' : '') . ' >' . __('Order #', 'wp-photo-album-plus') . '</option>' . '<option value="-1"' . ($suba_order_by == '-1' ? 'selected="selected"' : '') . ' >' . __('Order # reverse', 'wp-photo-album-plus') . '</option>' . '<option value="2"' . ($suba_order_by == '2' ? 'selected="selected"' : '') . ' >' . __('Name', 'wp-photo-album-plus') . '</option>' . '<option value="-2"' . ($suba_order_by == '-2' ? 'selected="selected"' : '') . ' >' . __('Name reverse', 'wp-photo-album-plus') . '</option>' . '<option value="5"' . ($suba_order_by == '5' ? 'selected="selected"' : '') . ' >' . __('Timestamp', 'wp-photo-album-plus') . '</option>' . '<option value="-5"' . ($suba_order_by == '-5' ? 'selected="selected"' : '') . ' >' . __('Timestamp reverse', 'wp-photo-album-plus') . '</option>' . '</select>' . ' ';
            // Alternative thumbnail size
            if (!wppa_switch('alt_is_restricted') || current_user_can('administrator')) {
                echo __('Use alt thumbsize:', 'wp-photo-album-plus') . '<select' . ' onchange="wppaAjaxUpdateAlbum( ' . $id . ', \'alt_thumbsize\', this )"' . ' >' . '<option value="0"' . ($alt_thumbsize ? '' : ' selected="selected"') . ' >' . __('no', 'wp-photo-album-plus') . '</option>' . '<option value="yes"' . ($alt_thumbsize ? ' selected="selected"' : '') . ' >' . __('yes', 'wp-photo-album-plus') . '</option>' . '</select>' . ' ';
            }
            // Cover type
            if (!wppa_switch('covertype_is_restricted') || wppa_user_is('administrator')) {
                echo __('Cover Type:', 'wp-photo-album-plus') . ' ';
                $sel = ' selected="selected"';
                echo '<select' . ' onchange="wppaAjaxUpdateAlbum( ' . $id . ', \'cover_type\', this )"' . ' >' . '<option value=""' . ($cover_type == '' ? $sel : '') . ' >' . __('--- default --- See Table IV-D6', 'wp-photo-album-plus') . '</option>' . '<option value="default"' . ($cover_type == 'default' ? $sel : '') . ' >' . __('Standard', 'wp-photo-album-plus') . '</option>' . '<option value="longdesc"' . ($cover_type == 'longdesc' ? $sel : '') . ' >' . __('Long Descriptions', 'wp-photo-album-plus') . '</option>' . '<option value="imagefactory"' . ($cover_type == 'imagefactory' ? $sel : '') . ' >' . __('Image Factory', 'wp-photo-album-plus') . '</option>' . '<option value="default-mcr"' . ($cover_type == 'default-mcr' ? $sel : '') . ' >' . __('Standard mcr', 'wp-photo-album-plus') . '</option>' . '<option value="longdesc-mcr"' . ($cover_type == 'longdesc-mcr' ? $sel : '') . ' >' . __('Long Descriptions mcr', 'wp-photo-album-plus') . '</option>' . '<option value="imagefactory-mcr"' . ($cover_type == 'imagefactory-mcr' ? $sel : '') . ' >' . __('Image Factory mcr', 'wp-photo-album-plus') . '</option>' . '</select>' . ' ';
            }
            // Cover photo
            echo __('Cover Photo:', 'wp-photo-album-plus') . ' ' . wppa_main_photo($main_photo, $cover_type) . ' ';
            // Upload limit
            echo __('Upload limit:', 'wp-photo-album-plus') . ' ';
            $lims = explode('/', $upload_limit);
            if (!is_array($lims)) {
                $lims = array('0', '0');
            }
            if (wppa_user_is('administrator')) {
                echo '<input' . ' type="text"' . ' id="upload_limit_count"' . ' value="' . $lims[0] . '"' . ' style="width:50px"' . ' title="' . esc_attr(__('Set the upload limit (0 means unlimited).', 'wp-photo-album-plus')) . '"' . ' onchange="wppaRefreshAfter(); wppaAjaxUpdateAlbum( ' . $id . ', \'upload_limit_count\', this )"' . ' />';
                $sel = ' selected="selected"';
                echo '<select onchange="wppaRefreshAfter(); wppaAjaxUpdateAlbum( ' . $id . ', \'upload_limit_time\', this )" >' . '<option value="0"' . ($lims[1] == '0' ? $sel : '') . ' >' . __('for ever', 'wp-photo-album-plus') . '</option>' . '<option value="3600"' . ($lims[1] == '3600' ? $sel : '') . ' >' . __('per hour', 'wp-photo-album-plus') . '</option>' . '<option value="86400"' . ($lims[1] == '86400' ? $sel : '') . ' >' . __('per day', 'wp-photo-album-plus') . '</option>' . '<option value="604800"' . ($lims[1] == '604800' ? $sel : '') . ' >' . __('per week', 'wp-photo-album-plus') . '</option>' . '<option value="2592000"' . ($lims[1] == '2592000' ? $sel : '') . ' >' . __('per month', 'wp-photo-album-plus') . '</option>' . '<option value="31536000"' . ($lims[1] == '31536000' ? $sel : '') . ' >' . __('per year', 'wp-photo-album-plus') . '</option>' . '</select>' . ' ';
            } else {
                if ($lims[0] == '0') {
                    _e('Unlimited', 'wp-photo-album-plus');
                } else {
                    echo $lims[0] . ' ';
                    switch ($lims[1]) {
                        case '3600':
                            _e('per hour', 'wp-photo-album-plus');
                            break;
                        case '86400':
                            _e('per day', 'wp-photo-album-plus');
                            break;
                        case '604800':
                            _e('per week', 'wp-photo-album-plus');
                            break;
                        case '2592000':
                            _e('per month', 'wp-photo-album-plus');
                            break;
                        case '31536000':
                            _e('per year', 'wp-photo-album-plus');
                            break;
                    }
                }
                echo '. ';
            }
            // Status
            echo __('Remark:', 'wp-photo-album-plus') . ' ' . '<span' . ' id="albumstatus-' . $id . '"' . ' style="font-weight:bold;color:#00AA00;"' . ' >' . sprintf(__('Album %s is not modified yet', 'wp-photo-album-plus'), $id) . '</span>';
            echo '</td>' . '</tr>' . '</tbody>' . '</table>';
            // Section 2
            echo "\n" . '<!-- Album Section 2 -->' . '<table' . ' class="wppa-table wppa-album-table"' . ' >' . '<tbody>';
            // Name
            echo '<tr>' . '<td>' . __('Name:', 'wp-photo-album-plus') . '</td>' . '<td>' . '<input' . ' type="text"' . ' style="width:100%;"' . ' onkeyup="wppaAjaxUpdateAlbum( ' . $id . ', \'name\', this )"' . ' onchange="wppaAjaxUpdateAlbum( ' . $id . ', \'name\', this )"' . ' value="' . esc_attr($name) . '"' . ' />' . '<span class="description" >' . __('Type the name of the album. Do not leave this empty.', 'wp-photo-album-plus') . '</span>' . '</td>' . '<td>' . '</td>' . '</tr>';
            // Description
            echo '<tr>' . '<td>' . __('Description:', 'wp-photo-album-plus') . '</td>';
            if (wppa_switch('use_wp_editor')) {
                echo '<td>';
                wp_editor($description, 'wppaalbumdesc', array('wpautop' => true, 'media_buttons' => false, 'textarea_rows' => '6', 'tinymce' => true));
                echo '<input' . ' type="button"' . ' class="button-secundary"' . ' value="' . esc_attr(__('Update Album description', 'wp-photo-album-plus')) . '"' . ' onclick="wppaAjaxUpdateAlbum( ' . $id . ', \'description\', document.getElementById( \'wppaalbumdesc\' ) )"' . ' />' . '<img' . ' id="wppa-album-spin"' . ' src="' . wppa_get_imgdir() . 'spinner.gif' . '"' . ' alt="Spin"' . ' style="visibility:hidden"' . ' />' . '</td>';
            } else {
                echo '<td>' . '<textarea' . ' style="width:100%;height:60px;"' . ' onkeyup="wppaAjaxUpdateAlbum( ' . $id . ', \'description\', this )"' . ' onchange="wppaAjaxUpdateAlbum( ' . $id . ', \'description\', this )"' . ' >' . $description . '</textarea>' . '</td>';
            }
            echo '<td>' . '</td>' . '</tr>';
            // Categories
            echo '<tr>' . '<td>' . __('Catogories:', 'wp-photo-album-plus') . '</td>' . '<td>' . '<input' . ' id="cats"' . ' type="text"' . ' style="width:100%;"' . ' onkeyup="wppaAjaxUpdateAlbum( ' . $id . ', \'cats\', this )"' . ' onchange="wppaAjaxUpdateAlbum( ' . $id . ', \'cats\', this )"' . ' value="' . esc_attr($cats) . '"' . ' />' . '<br />' . '<span class="description" >' . __('Separate categories with commas.', 'wp-photo-album-plus') . '</span>' . '</td>' . '<td>' . '<select' . ' onchange="wppaAddCat( this.value, \'cats\' ); wppaAjaxUpdateAlbum( ' . $id . ', \'cats\', document.getElementById( \'cats\' ) )"' . ' >';
            $catlist = wppa_get_catlist();
            if (is_array($catlist)) {
                echo '<option value="" >' . __('- select to add -', 'wp-photo-album-plus') . '</option>';
                foreach ($catlist as $cat) {
                    echo '<option value="' . $cat['cat'] . '" >' . $cat['cat'] . '</option>';
                }
            } else {
                echo '<option value="0" >' . __('No categories yet', 'wp-photo-album-plus') . '</option>';
            }
            echo '</select>' . '</td>' . '</tr>';
            // Default tags
            echo '<tr>' . '<td>' . __('Default photo tags:', 'wp-photo-album-plus') . '</td>' . '<td>' . '<input' . ' type="text"' . ' id="default_tags"' . ' value="' . esc_attr($default_tags) . '"' . ' style="width:100%"' . ' onkeyup="wppaAjaxUpdateAlbum( ' . $id . ', \'default_tags\', this )"' . ' onchange="wppaAjaxUpdateAlbum( ' . $id . ', \'default_tags\', this )"' . ' />' . '<br />' . '<span class="description">' . __('Enter the tags that you want to be assigned to new photos in this album.', 'wp-photo-album-plus') . '</span>' . '</td>' . '<td>' . '</td>' . '</tr>';
            // Custom
            if (wppa_switch('album_custom_fields')) {
                $custom = wppa_get_album_item($edit_id, 'custom');
                if ($custom) {
                    $custom_data = unserialize($custom);
                } else {
                    $custom_data = array('', '', '', '', '', '', '', '', '', '');
                }
                foreach (array_keys($custom_data) as $key) {
                    if (wppa_opt('album_custom_caption_' . $key)) {
                        echo '<tr>' . '<td>' . apply_filters('translate_text', wppa_opt('album_custom_caption_' . $key)) . '<small style="float:right" >' . '(w#cc' . $key . ')' . '</small>:' . '</td>' . '<td>' . '<input' . ' type="text"' . ' style="width:100%;"' . ' id="album_custom_' . $key . '-' . $id . '"' . ' onkeyup="wppaAjaxUpdateAlbum( ' . $id . ', \'album_custom_' . $key . '\', this );"' . ' onchange="wppaAjaxUpdateAlbum( ' . $id . ', \'album_custom_' . $key . '\', this );"' . ' value="' . esc_attr(stripslashes($custom_data[$key])) . '"' . ' />' . '</td>' . '<td>' . '<small>' . '(w#cd' . $key . ')' . '</small>' . '</td>' . '</tr>';
                    }
                }
            }
            // Link type
            echo '<tr>' . '<td>' . __('Link type:', 'wp-photo-album-plus') . '</td>' . '<td>';
            $sel = ' selected="selected"';
            $lt = $cover_linktype;
            /* if ( !$linktype ) $linktype = 'content'; /* Default */
            /* if ( $albuminfo['cover_linkpage'] == '-1' ) $linktype = 'none'; /* for backward compatibility */
            echo '<select onchange="wppaAjaxUpdateAlbum( ' . $id . ', \'cover_linktype\', this )" >' . '<option value="content"' . ($lt == 'content' ? $sel : '') . ' >' . __('the sub-albums and thumbnails', 'wp-photo-album-plus') . '</option>' . '<option value="albums"' . ($lt == 'albums' ? $sel : '') . ' >' . __('the sub-albums', 'wp-photo-album-plus') . '</option>' . '<option value="thumbs"' . ($lt == 'thumbs' ? $sel : '') . ' >' . __('the thumbnails', 'wp-photo-album-plus') . '</option>' . '<option value="slide"' . ($lt == 'slide' ? $sel : '') . ' >' . __('the album photos as slideshow', 'wp-photo-album-plus') . '</option>' . '<option value="page"' . ($lt == 'page' ? $sel : '') . ' >' . __('the link page with a clean url', 'wp-photo-album-plus') . '</option>' . '<option value="none"' . ($lt == 'none' ? $sel : '') . ' >' . __('no link at all', 'wp-photo-album-plus') . '</option>' . '</select>' . '<br />' . '<span class="description">';
            if (wppa_switch('auto_page')) {
                _e('If you select "the link page with a clean url", select an Auto Page of one of the photos in this album.', 'wp-photo-album-plus');
            } else {
                _e('If you select "the link page with a clean url", make sure you enter the correct shortcode on the target page.', 'wp-photo-album-plus');
            }
            echo '</span>' . '</td>' . '<td>' . '</td>' . '</tr>';
            // Link page
            if (!wppa_switch('link_is_restricted') || wppa_user_is('administrator')) {
                echo '<tr>' . '<td>' . __('Link to:', 'wp-photo-album-plus') . '</td>' . '<td>';
                $query = "SELECT `ID`, `post_title` FROM `" . $wpdb->posts . "` WHERE `post_type` = 'page' AND `post_status` = 'publish' ORDER BY `post_title` ASC";
                $pages = $wpdb->get_results($query, ARRAY_A);
                if (empty($pages)) {
                    _e('There are no pages (yet) to link to.', 'wp-photo-album-plus');
                } else {
                    $linkpage = $albuminfo['cover_linkpage'];
                    if (!is_numeric($linkpage)) {
                        $linkpage = '0';
                    }
                    echo '<select' . ' onchange="wppaAjaxUpdateAlbum( ' . $id . ' , \'cover_linkpage\', this )"' . ' style="max-width:100%;"' . '>' . '<option value="0"' . ($linkpage == '0' ? $sel : '') . ' >' . __('--- the same page or post ---', 'wp-photo-album-plus') . '</option>';
                    foreach ($pages as $page) {
                        echo '<option value="' . $page['ID'] . '"' . ($linkpage == $page['ID'] ? $sel : '') . ' >' . __($page['post_title']) . '</option>';
                    }
                    echo '</select>' . '<br />' . '<span class="description" >' . __('If you want, you can link the title to a WP page in stead of the album\'s content. If so, select the page the title links to.', 'wp-photo-album-plus') . '</span>';
                }
                echo '</td>' . '<td>' . '</td>' . '</tr>';
            }
            // Schedule
            echo '<tr>' . '<td>' . __('Schedule:', 'wp-photo-album-plus') . ' ' . '<input' . ' type="checkbox"' . ' id="schedule-box"' . ($albuminfo['scheduledtm'] ? ' checked="checked"' : '') . ' onchange="wppaChangeScheduleAlbum(' . $id . ', this );"' . ' />' . '</td>' . '<td>' . '<input type="hidden" value="" id="wppa-dummy" />' . '<span class="wppa-datetime-' . $id . '"' . ($albuminfo['scheduledtm'] ? '' : ' style="display:none;"') . ' >' . wppa_get_date_time_select_html('album', $id, true) . '</span>' . '<br />' . '<span class="description" >' . __('If enabled, new photos will have their status set scheduled for publication on the date/time specified here.', 'wp-photo-album-plus') . '</span>' . '</td>' . '<td>' . '</td>' . '</tr>';
            echo '</tbody>' . '</table>';
            // Section 3, Actions
            echo "\n" . '<!-- Album Section 3 -->' . '<table' . ' class="wppa-table wppa-album-table"' . ' >' . '<tbody>' . '<tr>' . '<td>';
            // Inherit cats
            echo '<input' . ' type="button"' . ' title="' . esc_attr(__('Apply categories to all (grand)children.', 'wp-photo-album-plus')) . '"' . ' onclick="wppaTryInheritCats( ' . $id . ' )"' . ' value="' . esc_attr(__('Inherit Cats', 'wp-photo-album-plus')) . '"' . ' />' . '<input' . ' type="button"' . ' title="' . esc_attr(__('Add categories to all (grand)children.', 'wp-photo-album-plus')) . '"' . ' onclick="wppaTryAddCats( ' . $id . ' )"' . ' value="' . esc_attr(__('Add Inherit Cats', 'wp-photo-album-plus')) . '"' . ' />';
            // Apply default tags
            echo '<input' . ' type="button"' . ' title="' . esc_attr(__('Tag all photos in this album with the default tags.', 'wp-photo-album-plus')) . '"' . ' onclick="wppaTryApplyDeftags( ' . $id . ' )"' . ' value="' . esc_attr(__('Apply default tags', 'wp-photo-album-plus')) . '"' . ' />' . '<input' . ' type="button"' . ' title="' . esc_attr(__('Add the default tags to all photos in this album.', 'wp-photo-album-plus')) . '"' . ' onclick="wppaTryAddDeftags( ' . $id . ' )"' . ' value="' . esc_attr(__('Add default tags', 'wp-photo-album-plus')) . '"' . ' />';
            // Schedule all
            echo '<input' . ' type="button"' . ' title="' . esc_attr(__('Tag all photos in this album with the default tags.', 'wp-photo-album-plus')) . '"' . ' onclick="wppaTryScheduleAll( ' . $id . ' )"' . ' value="' . esc_attr(__('Schedule all', 'wp-photo-album-plus')) . '"' . ' />';
            // Reset Ratings
            if (wppa_switch('rating_on')) {
                $onc = 'if (confirm(\'' . __('Are you sure you want to clear the ratings in this album?', 'wp-photo-album-plus') . '\')) { wppaRefreshAfter(); wppaAjaxUpdateAlbum( ' . $id . ', \'clear_ratings\', 0 ); }';
                echo '<input' . ' type="button"' . ' onclick="' . $onc . '"' . ' value="' . esc_attr(__('Reset ratings', 'wp-photo-album-plus')) . '"' . ' />';
            }
            // Apply New photo desc
            if (wppa_switch('apply_newphoto_desc')) {
                $onc = 'if ( confirm(\'Are you sure you want to set the description of all photos to \\n\\n' . esc_js(wppa_opt('newphoto_description')) . '\')) document.location=\'' . wppa_ea_url($albuminfo['id'], 'edit') . '&applynewdesc\'';
                echo '<input' . ' type="button"' . ' onclick="' . $onc . '"' . ' value="' . esc_attr(__('Apply new photo desc', 'wp-photo-album-plus')) . '"' . ' />';
            }
            // Remake all
            if (wppa_user_is('administrator')) {
                $onc = 'if ( confirm(\'Are you sure you want to remake the files for all photos in this album?\')) document.location=\'' . wppa_ea_url($albuminfo['id'], 'edit') . '&remakealbum\'';
                echo '<input' . ' type="button"' . ' onclick="' . $onc . '"' . ' value="' . esc_attr(__('Remake all', 'wp-photo-album-plus')) . '"' . ' />';
            }
            // Goto Upload
            if (current_user_can('wppa_upload')) {
                $a = wppa_allow_uploads($id);
                if ($a) {
                    $full = false;
                } else {
                    $full = true;
                }
                $onc = $full ? 'alert(\'' . __('Change the upload limit or remove photos to enable new uploads.', 'wp-photo-album-plus') . '\')' : 'document.location = \'' . wppa_dbg_url(get_admin_url()) . '/admin.php?page=wppa_upload_photos&wppa-set-album=' . $id . '\'';
                $val = $full ? __('Album is full', 'wp-photo-album-plus') : __('Upload to this album', 'wp-photo-album-plus') . ($a > '0' ? ' ' . sprintf(__('(max %d)', 'wp-photo-album-plus'), $a) : '');
                echo '<input' . ' type="button"' . ' onclick="' . $onc . '"' . ' value="' . $val . '"' . ' />';
            }
            echo '</td>' . '</tr>' . '</tbody>' . '</table>';
            ?>
	</div>

					<?php 
            wppa_album_sequence($edit_id);
            ?>

<a id="manage-photos" ></a>
				<img src="<?php 
            echo WPPA_URL . '/img/camera32.png';
            ?>
" alt="Camera icon" />
				<h1 style="display:inline;" ><?php 
            _e('Manage Photos', 'wp-photo-album-plus');
            if (isset($_REQUEST['bulk'])) {
                echo ' - <small><i>' . __('Copy / move / delete / edit name / edit description / change status', 'wp-photo-album-plus') . '</i></small>';
            } elseif (isset($_REQUEST['seq'])) {
                echo ' - <small><i>' . __('Change sequence order by drag and drop', 'wp-photo-album-plus') . '</i></small>';
            } elseif (isset($_REQUEST['quick'])) {
                echo ' - <small><i>' . __('Edit photo information except copy and move', 'wp-photo-album-plus') . '</i></small>';
            } else {
                echo ' - <small><i>' . __('Edit photo information', 'wp-photo-album-plus') . '</i></small>';
            }
            ?>
</h1><div style="clear:both;" >&nbsp;</div>
				<?php 
            if (isset($_REQUEST['bulk'])) {
                wppa_album_photos_bulk($edit_id);
            } elseif (isset($_REQUEST['seq'])) {
                wppa_album_photos_sequence($edit_id);
            } else {
                wppa_album_photos($edit_id);
            }
            ?>
				<br /><a href="#manage-photos"><?php 
            _e('Top of page', 'wp-photo-album-plus');
            ?>
</a>
			</div>
<?php 
        } else {
            if ($_REQUEST['tab'] == 'cmod') {
                $photo = $_REQUEST['photo'];
                $alb = wppa_get_album_id_by_photo_id($photo);
                if (current_user_can('wppa_comments') && wppa_have_access($alb)) {
                    ?>
				<div class="wrap">
					<img src="<?php 
                    echo WPPA_URL . '/img/page_green.png';
                    ?>
" />
					<h1 style="display:inline;" ><?php 
                    _e('Moderate comment', 'wp-photo-album-plus');
                    ?>
</h1>
					<div style="clear:both;" >&nbsp;</div>
					<?php 
                    wppa_album_photos('', $photo);
                    ?>
				</div>
<?php 
                } else {
                    wp_die('You do not have the rights to do this');
                }
            } elseif ($_REQUEST['tab'] == 'pmod' || $_REQUEST['tab'] == 'pedit') {
                $photo = $_REQUEST['photo'];
                $alb = wppa_get_album_id_by_photo_id($photo);
                if (current_user_can('wppa_admin') && wppa_have_access($alb)) {
                    ?>
				<div class="wrap">
					<img src="<?php 
                    echo WPPA_URL . '/img/page_green.png';
                    ?>
" />
					<h1 style="display:inline;" ><?php 
                    if ($_REQUEST['tab'] == 'pmod') {
                        _e('Moderate photo', 'wp-photo-album-plus');
                    } else {
                        _e('Edit photo', 'wp-photo-album-plus');
                    }
                    ?>
					</h1><div style="clear:both;" >&nbsp;</div>
					<?php 
                    wppa_album_photos('', $photo);
                    ?>
				</div>
<?php 
                } else {
                    wp_die('You do not have the rights to do this');
                }
            } else {
                if ($_REQUEST['tab'] == 'del') {
                    $album_owner = $wpdb->get_var($wpdb->prepare("SELECT `owner` FROM " . WPPA_ALBUMS . " WHERE `id` = %s", $_REQUEST['edit_id']));
                    if ($album_owner == '--- public ---' && !current_user_can('administrator') || !wppa_have_access($_REQUEST['edit_id'])) {
                        wp_die('You do not have the rights to delete this album');
                    }
                    ?>
			<div class="wrap">
				<img src="<?php 
                    echo WPPA_URL . '/img/albumdel32.png';
                    ?>
" />
				<h1 style="display:inline;" ><?php 
                    _e('Delete Album', 'wp-photo-album-plus');
                    ?>
</h1>

				<p><?php 
                    _e('Album:', 'wp-photo-album-plus');
                    ?>
 <b><?php 
                    echo wppa_get_album_name($_REQUEST['edit_id']);
                    ?>
.</b></p>
				<p><?php 
                    _e('Are you sure you want to delete this album?', 'wp-photo-album-plus');
                    ?>
<br />
					<?php 
                    _e('Press Delete to continue, and Cancel to go back.', 'wp-photo-album-plus');
                    ?>
				</p>
				<form name="wppa-del-form" action="<?php 
                    echo wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_admin_menu');
                    ?>
" method="post">
					<?php 
                    wp_nonce_field('$wppa_nonce', WPPA_NONCE);
                    ?>
					<p>
						<?php 
                    _e('What would you like to do with photos currently in the album?', 'wp-photo-album-plus');
                    ?>
<br />
						<input type="radio" name="wppa-del-photos" value="delete" checked="checked" /> <?php 
                    _e('Delete', 'wp-photo-album-plus');
                    ?>
<br />
						<input type="radio" name="wppa-del-photos" value="move" /> <?php 
                    _e('Move to:', 'wp-photo-album-plus');
                    ?>
						<select name="wppa-move-album">
							<?php 
                    echo wppa_album_select_a(array('checkaccess' => true, 'path' => wppa_switch('hier_albsel'), 'selected' => '0', 'exclude' => $_REQUEST['edit_id'], 'addpleaseselect' => true));
                    ?>
						</select>
					</p>

					<input type="hidden" name="wppa-del-id" value="<?php 
                    echo $_REQUEST['edit_id'];
                    ?>
" />
					<input type="button" class="button-primary" value="<?php 
                    _e('Cancel', 'wp-photo-album-plus');
                    ?>
" onclick="parent.history.back()" />
					<input type="submit" class="button-primary" style="color: red" name="wppa-del-confirm" value="<?php 
                    _e('Delete', 'wp-photo-album-plus');
                    ?>
" />
				</form>
			</div>
<?php 
                }
            }
        }
    } else {
        //  'tab' not set. default, album manage page.
        // if add form has been submitted
        //		if (isset($_POST['wppa-na-submit'])) {
        //			check_admin_referer( '$wppa_nonce', WPPA_NONCE );
        //			wppa_add_album();
        //		}
        // if album deleted
        if (isset($_POST['wppa-del-confirm'])) {
            check_admin_referer('$wppa_nonce', WPPA_NONCE);
            $album_owner = $wpdb->get_var($wpdb->prepare("SELECT `owner` FROM " . WPPA_ALBUMS . " WHERE `id` = %s", $_POST['wppa-del-id']));
            if ($album_owner == '--- public ---' && !current_user_can('administrator') || !wppa_have_access($_POST['wppa-del-id'])) {
                wp_die('You do not have the rights to delete this album');
            }
            if ($_POST['wppa-del-photos'] == 'move') {
                $move = $_POST['wppa-move-album'];
                if (wppa_have_access($move)) {
                    wppa_del_album($_POST['wppa-del-id'], $move);
                } else {
                    wppa_error_message(__('Unable to move photos. Album not deleted.', 'wp-photo-album-plus'));
                }
            } else {
                wppa_del_album($_POST['wppa-del-id'], '');
            }
        }
        if (wppa_extended_access()) {
            if (isset($_REQUEST['switchto'])) {
                update_option('wppa_album_table_' . wppa_get_user(), $_REQUEST['switchto']);
            }
            $style = get_option('wppa_album_table_' . wppa_get_user(), 'flat');
        } else {
            $style = 'flat';
        }
        // The Manage Album page
        ?>
		<div class="wrap">
		<?php 
        wppa_admin_spinner();
        ?>
			<img src="<?php 
        echo WPPA_URL . '/img/album32.png';
        ?>
" />
			<h1 style="display:inline;" ><?php 
        _e('Manage Albums', 'wp-photo-album-plus');
        ?>
</h1>
			<div style="clear:both;" >&nbsp;</div>
			<?php 
        // The Create new album button
        if (wppa_can_create_top_album()) {
            $url = wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_admin_menu&amp;tab=edit&amp;edit_id=new');
            $vfy = __('Are you sure you want to create a new album?', 'wp-photo-album-plus');
            echo '<form method="post" action="' . get_admin_url() . 'admin.php?page=wppa_admin_menu" style="float:left; margin-right:12px;" >';
            echo '<input type="hidden" name="tab" value="edit" />';
            echo '<input type="hidden" name="edit_id" value="new" />';
            $onc = wppa_switch('confirm_create') ? 'onclick="return confirm(\'' . $vfy . '\');"' : '';
            echo '<input type="submit" class="button-primary" ' . $onc . ' value="' . __('Create New Empty Album', 'wp-photo-album-plus') . '" style="height:28px;" />';
            echo '</form>';
        }
        // The switch to button(s)
        if (wppa_extended_access()) {
            if ($style == 'flat') {
                ?>
					<input type="button" class="button-secundary" onclick="document.location='<?php 
                echo wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_admin_menu&amp;switchto=collapsable');
                ?>
'" value="<?php 
                _e('Switch to Collapsable table', 'wp-photo-album-plus');
                ?>
" />
				<?php 
            }
            if ($style == 'collapsable') {
                ?>
					<input type="button" class="button-secundary" onclick="document.location='<?php 
                echo wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_admin_menu&amp;switchto=flat');
                ?>
'" value="<?php 
                _e('Switch to Flat table', 'wp-photo-album-plus');
                ?>
" />
					<input
						type="button"
						class="button-secundary"
						id="wppa-open-all"
						style="display:inline;"
						onclick="	jQuery('#wppa-close-all').css('display','inline');
									jQuery(this).css('display','none');
									jQuery('.wppa-alb-onoff').css('display','');
									jQuery('.alb-arrow-off').css('display','');
									jQuery('.alb-arrow-on').css('display','none');
									"
						value="<?php 
                _e('Open all', 'wp-photo-album-plus');
                ?>
"
					/>
					<input
						type="button"
						class="button-secundary"
						id="wppa-close-all"
						style="display:none;"
						onclick="	jQuery('#wppa-open-all').css('display','inline');
									jQuery(this).css('display','none');
									jQuery('.wppa-alb-onoff').css('display','none');
									jQuery('.alb-arrow-on').css('display','');
									jQuery('.alb-arrow-off').css('display','none');
									"
						value="<?php 
                _e('Close all', 'wp-photo-album-plus');
                ?>
"
					/>
				<?php 
            }
        }
        ?>

			<br />
			<?php 
        // The table of existing albums
        if ($style == 'flat') {
            wppa_admin_albums_flat();
        } else {
            wppa_admin_albums_collapsable();
        }
        ?>
			<br />

			<?php 
        wppa_album_sequence('0');
        ?>
		</div>
<?php 
    }
}