function max_add_post_meta()
{
    global $wpdb, $p_tpl, $taxonomies, $order_array, $post_id;
    // Get the gallery gategories
    $taxonomies = max_get_galleries();
    $post_id = @$_GET['post'] ? @$_GET['post'] : @$_POST['post_ID'];
    @($custom_fields = get_post_custom_values('_wp_page_template', $post_id));
    $p_tpl = $custom_fields[0];
    /*-----------------------------------------------------------------------------------*/
    /*	create post options meta box for post and galleries
    	/*-----------------------------------------------------------------------------------*/
    $obj_post = new UIElement_Post('post');
    $obj_post->getMetaBox();
    $obj_post = new UIElement_Post('gallery');
    $obj_post->getMetaBox();
    /*-----------------------------------------------------------------------------------*/
    /*	create photo options meta box
    	/*-----------------------------------------------------------------------------------*/
    $obj_photo_fsg = new UIElement_Photo('gallery');
    $obj_photo_fsg->getFullsizeGalleryMetaBox();
    $obj_photo = new UIElement_Photo('gallery');
    $obj_photo->getPhotoMetaBox();
    /*-----------------------------------------------------------------------------------*/
    /*	create slider options meta box
    	/*-----------------------------------------------------------------------------------*/
    $obj_slider = new UIElement_Slider('gallery');
    $obj_slider->getMetaBox();
    /*-----------------------------------------------------------------------------------*/
    /*	create background options meta box
    	/*-----------------------------------------------------------------------------------*/
    $obj_background = new UIElement_PostBackground('gallery');
    $obj_background->getMetaBox();
    /*-----------------------------------------------------------------------------------*/
    /*	create copyright options meta box
    	/*-----------------------------------------------------------------------------------*/
    $obj_copyright = new UIElement_Copyright('gallery');
    $obj_copyright->getMetaBox();
}
function max_add_page_meta()
{
    global $p_tpl, $taxonomies, $order_array, $wp_cats, $wp_gal_cats, $post;
    // Get the gallery gategories
    $taxonomies = max_get_galleries();
    $post_id = @$_GET['post'] ? @$_GET['post'] : @$_POST['post_ID'];
    @($custom_fields = get_post_custom_values('_wp_page_template', $post_id));
    $p_tpl = $custom_fields[0];
    /*-----------------------------------------------------------------------------------*/
    /*	create page options meta boxes
    	/*-----------------------------------------------------------------------------------*/
    $obj_page = new UIElement_Page('page');
    $obj_page->getSidebarMetaBox();
    $obj_page_settings = new UIElement_Page('page');
    $obj_page_settings->getPageMetaBox();
    /*-----------------------------------------------------------------------------------*/
    /*	create blog options meta box
    	/*-----------------------------------------------------------------------------------*/
    if ($p_tpl == "template-blog.php" || $p_tpl == "template-blog-fullsize.php") {
        $obj_blog_page = new UIElement('page');
        $obj_blog_page->createMetabox(array('id' => MAX_SHORTNAME . '_page_blog_meta_box', 'title' => __('Blog options', MAX_SHORTNAME), 'priority' => "high"));
        // Choose the galleries to display
        $obj_blog_page->addMultiGalleryCheckbox(array('id' => MAX_SHORTNAME . '_page_blog_category', 'label' => __('Blog Categories', MAX_SHORTNAME), "standard" => "9999", "options" => 'category', "desc" => __('Choose the Categories, you want to show on this blog page.', MAX_SHORTNAME)));
    }
    /*-----------------------------------------------------------------------------------*/
    /*	create page gallery options meta box
    	/*-----------------------------------------------------------------------------------*/
    if ($p_tpl == "template-one-column.php" || $p_tpl == "template-two-column.php" || $p_tpl == "template-three-column.php" || $p_tpl == "template-four-column.php" || $p_tpl == "template-scroller.php" || $p_tpl == "template-fullsize-gallery.php" || $p_tpl == "template-grid-fullsize.php" || $p_tpl == "template-galleria.php" || $p_tpl == "template-lightbox.php") {
        $obj_gallery = new UIElement_Gallery('page');
        $obj_gallery->getMetaBox();
    } else {
        /*-----------------------------------------------------------------------------------*/
        /*	template is a simple flickr stream template
        	/*-----------------------------------------------------------------------------------*/
        if ($p_tpl == "template-flickr.php") {
            $obj_flickr = new UIElement_Flickr('page');
            $obj_flickr->getMetaBox();
        } else {
            /*-----------------------------------------------------------------------------------*/
            /*	template is a sortable template
            	/*-----------------------------------------------------------------------------------*/
            if ($p_tpl == "template-sortable.php") {
                $obj_gallery = new UIElement('page');
                $obj_gallery->createMetabox(array('id' => MAX_SHORTNAME . '_page_gallery_meta_box', 'title' => __('Sortable grid settings', MAX_SHORTNAME), 'priority' => "high"));
                // Choose the galleries to display
                $obj_gallery->addSortableGalleryCheckbox(array('id' => 'max_sortable_galleries', 'label' => __('Connect and sort Galleries', MAX_SHORTNAME), "standard" => "", "options" => $wp_gal_cats, "desc" => __('Choose the Galleries, you want to connect and display on this sortable portfolio page. You can sort those galleries to reorder the filter links. <strong>Only marked galleries are sortable.</strong>', MAX_SHORTNAME)));
                // Show "all" link
                $obj_gallery->addDropdown(array("id" => MAX_SHORTNAME . "_page_sortable_show_all", "options" => array('true' => 'Yes', 'false' => 'No'), "standard" => 'true', "label" => __('Show "All" link on gallery filter', MAX_SHORTNAME), "desc" => 'Choose, if you want to show the "All" link on your sortable filter links.'));
                // Columns
                $obj_gallery->addDropdown(array("id" => MAX_SHORTNAME . "_page_sortable_columns", "options" => array('one' => '1 Column', 'two' => '2 Columns', 'three' => '3 Columns', 'four' => '4 Columns'), "standard" => 'three', "label" => __('Sortable columns', MAX_SHORTNAME), "desc" => 'Choose, how to show the images aspect ratio in this sortable template.'));
                // Image aspect ratio
                $obj_gallery->addDropdown(array("id" => MAX_SHORTNAME . "_page_sortable_aspect_ratio", "options" => array('default' => 'Default 4:3', 'squared' => 'Squared', 'portrait' => 'Portrait'), "standard" => 'default', "label" => __('Image aspect ratio', MAX_SHORTNAME), "desc" => 'Choose, how to show the images aspect ratio in this sortable template.'));
                // Content Fullwidth
                $obj_gallery->addDropdown(array("id" => MAX_SHORTNAME . "_page_gallery_fullwidth", "options" => array('true' => 'Yes', 'false' => 'No'), "standard" => 'false', "label" => __('Fullsize Content', MAX_SHORTNAME), "display" => true, "desc" => 'Choose, if you want to show the choosen gallery content in full browser width.'));
                $obj_gallery->addGroupOpen(array('id' => MAX_SHORTNAME . '_page_group_sorting', 'label' => __('Select photo order', MAX_SHORTNAME), "desc" => __('Select the order to show the photos of the gallery attached to this page.', MAX_SHORTNAME), 'float' => true, "display" => true));
                // Gallery Photo order
                $obj_gallery->addDropdown(array('id' => 'max_gallery_order', "options" => $order_array, "standard" => "9999", "float" => true));
                // Gallery Photo sort
                $obj_gallery->addDropdown(array('id' => 'max_gallery_sort', 'label' => "", "options" => array('DESC' => __('Descending', MAX_SHORTNAME), 'ASC' => __('Ascending', MAX_SHORTNAME)), "float" => true, "standard" => "DESC"));
                $obj_gallery->addGroupClose(array('id' => MAX_SHORTNAME . '_page_group_sorting', 'float' => true));
            } else {
                if ($p_tpl == "template-fullsize-flickr.php") {
                    $obj_flickr_fullsize = new UIElement_FlickrFullsize('page');
                    $obj_flickr_fullsize->getMetaBox();
                } else {
                    if ($p_tpl == "template-fullsize-video.php") {
                        $obj_video_fullsize = new UIElement_VideoFullsize('page');
                        $obj_video_fullsize->getMetaBox();
                    } else {
                        $obj_gallery = new UIElement('page');
                        $obj_gallery->createMetabox(array('id' => MAX_SHORTNAME . '_page_gallery_meta_box', 'title' => __('Gallery Settings', MAX_SHORTNAME), 'priority' => "high"));
                        // Portfolio Template is not selected
                        $obj_gallery->addAlert(array('id' => 'max_page_gallery_alert', 'label' => __('No Portfolio Template selected!', MAX_SHORTNAME), "standard" => "", "display" => true, "desc" => __('You have to choose a portfolio template on the right panel and publish your page to select a gallery.', MAX_SHORTNAME)));
                    }
                }
            }
        }
    }
    /*-----------------------------------------------------------------------------------*/
    /*	Create page background options meta box
    	/*-----------------------------------------------------------------------------------*/
    if ($p_tpl != "template-fullsize-gallery.php" && $p_tpl != "template-fullsize-flickr.php" && $p_tpl != "template-fullsize-video.php") {
        $obj_background = new UIElement_PageBackground('page');
        $obj_background->getMetaBox();
    }
}