/**
			 * FlatPress widget js admin
			 */
			var FlatPress = {
				winstancedrag : function() {
					$(\'.widget-class\').draggable({
						\'scroll\' : true,
						\'helper\' : function(event) {
							return $(this).clone().appendTo(\'body\').removeClass(\'widget-class\').css({
								\'position\': \'fixed\',
								\'cursor\' : \'move\',
								\'list-style-type\' : \'none\',
								\'margin\' : \'0\',
								\'padding\' : \'0\',
								\'width\' : $(this).width(),
								\'height\' : $(this).height()
								})
							.addClass(\'widget-available\');
						}
					});
					$(\'.widget-instance\').draggable({
						\'scroll\' : true,
						\'helper\' : function(event) {
							return $(this).clone().appendTo(\'body\').removeClass(\'widget-instance\').css({
								\'position\': \'fixed\',
								\'cursor\' : \'move\',
								\'list-style-type\' : \'none\',
								\'width\' : $(this).width(),
								\'height\' : $(this).height()
								})
							.addClass(\'widget-installed\');
						}
					});
				},
				wplaceholder : function() {
					$(\'.widget-placeholder\').droppable({
						\'accept\' : \'.widget-class, .widget-instance\',
						\'activeClass\' : \'ui-state-highlight\',
						\'over\' : function(event, ui) {
							$(this).effect("highlight", { \'color\' : $(\'.widget-installed, .widget-available\').css(\'background-color\') }, 1000);
						},
						\'drop\' : function(event, ui) {
							var parent = ui.draggable.parent();
							var where = $(this).parent().attr(\'id\').split(\'-\')[1];
							var replace = null;
							if (ui.draggable.hasClass(\'widget-instance\')) {
								replace = ui.draggable;
							}
							else {
								replace = $(\'
\').append(ui.draggable.children().clone());
								replace.removeClass(\'widget-class\').addClass(\'widget-instance\');
							}
							replace.children(\'input\').attr(\'name\', \'widgets[\' + where + \'][]\');
							$(this).replaceWith(replace);
							if (parent.children().length < 1) {
								parent.append(\'' . $lang ['admin'] ['widgets'] ['default'] ['drop_here'] . '\');
							}
							FlatPress.wreload();
						}
					});
				},
				winstancedrop : function() {
					$(\'.widget-instance\').droppable({
						\'accept\' : \'.widget-class, .widget-instance\',
						\'activeClass\' : \'ui-state-highlight\',
						\'over\' : function(event, ui) {
							$(this).effect("highlight", { \'color\' : $(\'.widget-available, .widget-installed\').css(\'background-color\') }, 1000);
						},
						\'drop\' : function(event, ui) {
							var parent = ui.draggable.parent();
							var where = $(this).parent().attr(\'id\').split(\'-\')[1];
							var replace = null;
							if (ui.draggable.hasClass(\'widget-instance\')) {
								replace = ui.draggable;
							}
							else {
								replace = $(\'\').append(ui.draggable.children().clone());
								replace.removeClass(\'widget-class\').addClass(\'widget-instance\');
							}
							replace.children(\'input\').attr(\'name\', \'widgets[\' + where + \'][]\');
							$(this).after(replace);
							if (parent.children().length < 1) {
								parent.append(\'' . $lang ['admin'] ['widgets'] ['default'] ['drop_here'] . '\');
							}
							FlatPress.wreload();
						}
					});
				},
				wtrash : function() {
					$(\'#widget-trashcan\').droppable({
						\'accept\' : \'.widget-instance\',
						\'activeClass\' : \'ui-state-highlight\',
						\'over\' : function(event, ui) {
							$(this).fadeTo(\'slow\', 0.2).fadeTo(\'slow\', 1.0);
						},
						\'drop\' : function(event, ui) {
							var parent = ui.draggable.parent();
							var draggable = $(ui.draggable);
							$(\'.widget-installed\').remove();
							if(parent.children().length < 2) {
								parent.append(\'' . $lang ['admin'] ['widgets'] ['default'] ['drop_here'] . '\');
							}
							setTimeout(function() {
								draggable.remove();
							});
							FlatPress.wreload();
						}
					});
					$(\'.widget-class\').droppable({
						\'accept\' : \'.widget-instance\',
						\'activeClass\' : \'ui-state-highlight\',
						\'over\' : function(event, ui) {
							$(this).effect("highlight", { \'color\' : $(\'#widget-trashcan\').css(\'background-color\') }, 1000);
						},
						\'drop\' : function(event, ui) {
							var parent = ui.draggable.parent();
							var draggable = $(ui.draggable);
							$(\'.widget-installed\').remove();
							if(parent.children().length < 2) {
								parent.append(\'' . $lang ['admin'] ['widgets'] ['default'] ['drop_here'] . '\');
							}
							setTimeout(function() {
								draggable.remove();
							});
							FlatPress.wreload();
						}
					});
				},
				wreload : function(){
					this.winstancedrag();
					this.winstancedrop();
					this.wplaceholder();
				}
			}
			FlatPress.wreload();FlatPress.wtrash();
		';
}
add_action('wp_footer', 'admin_widgets_head');
class admin_widgets_default extends AdminPanelAction {
	// var $validators = array(array('content', 'content', 'notEmpty', false, false));
	var $events = array(
		'save'
	);
	function get_widget_lists($wlist, $wpos, &$widget_list, $registered_w, $add_empties) {
		if (!isset($wlist [$wpos]))
			return;
		$widget_list [$wpos] = array();
		foreach ($wlist [$wpos] as $idx => $wdg) {
			$widget_list [$wpos] [$idx] = array();
			$newid = $wdg; // @list($newid, $params) = explode(":", $wdg);
			$widget_list [$wpos] [$idx] ['id'] = $newid;
			if (isset($registered_w [$newid])) {
				$thiswdg = $registered_w [$newid];
				$widget_list [$wpos] [$idx] ['name'] = $thiswdg ['name'];
				if ($thiswdg ['nparams'] > 0) {
					$widget_list [$wpos] [$idx] ['params'] = $params;
				}
				/*
				 * here should go the check for
				 * limited parameters: parameters limited to a
				 * particular set would mean using a