var RTE={$ajaxDialog:null,syntaxHiglighter:null,buttonOptions:{},validate:function(){var a=null;a=$("table.rte_table").last().find("input[name=item_name]");if(a.val()===""){a.focus();alert(PMA_messages.strFormEmpty);return false}a=$("table.rte_table").find("textarea[name=item_definition]");if(a.val()===""){this.syntaxHiglighter.focus();alert(PMA_messages.strFormEmpty);return false}return RTE.validateCustom()},validateCustom:function(){return true},postDialogShow:function(){}};
$(document).ready(function(){$("a.ajax_add_anchor, a.ajax_edit_anchor").live("click",function(a){a.preventDefault();var e=null;if($(this).hasClass("ajax_edit_anchor"))e=$(this).parents("tr");var b=PMA_ajaxShowMessage();$.get($(this).attr("href"),{ajax_request:true},function(c){if(c.success===true){PMA_ajaxRemoveMessage(b);RTE.buttonOptions[PMA_messages.strGo]=function(){RTE.syntaxHiglighter.save();if(RTE.validate()){var i=$("form.rte_form").last().serialize();b=PMA_ajaxShowMessage(PMA_messages.strProcessingRequest);
$.post($("form.rte_form").last().attr("action"),i,function(d){if(d.success===true){PMA_ajaxRemoveMessage(b);PMA_slidingMessage(d.message);RTE.$ajaxDialog.dialog("close");f==="edit"&&e.remove();if(d.insert){var g="",j=false;$("table.data").find("tr").each(function(){g=$(this).children("td").eq(0).find("strong").text().toUpperCase();g=$.trim(g);if(g!==""&&g>d.name){$(this).before(d.new_row);j=true;return false}});j||$("table.data").append(d.new_row);$(".ajaxInsert").show("slow").removeClass("ajaxInsert")}else $("table.data").find("tr").has("td").length===
0&&$("table.data").hide("slow",function(){$("#nothing2display").show("slow")});var k=0,l="";$("table.data").find("tr").has("td").each(function(){l=k%2===0?"odd":"even";$(this).removeClass().addClass(l);k++});$("table.data").find("tr").has("td").length>0&&$("#nothing2display").is(":visible")&&$("#nothing2display").hide("slow",function(){$("table.data").show("slow")})}else PMA_ajaxShowMessage(d.error,false)})}};RTE.buttonOptions[PMA_messages.strClose]=function(){$(this).dialog("close")};RTE.$ajaxDialog=
$("<div>"+c.message+"</div>").dialog({width:700,minWidth:500,buttons:RTE.buttonOptions,title:c.title,modal:true,close:function(){$(this).remove()}});RTE.$ajaxDialog.find("input[name=item_name]").focus();RTE.$ajaxDialog.find("input.datefield, input.datetimefield").each(function(){PMA_addDatepicker($(this).css("width","95%"))});var f="add";if($("input[name=editor_process_edit]").length>0)f="edit";var h=$("textarea[name=item_definition]").last();RTE.syntaxHiglighter=CodeMirror.fromTextArea(h[0],{lineNumbers:true,
matchBrackets:true,indentUnit:4,mode:"text/x-mysql"});RTE.postDialogShow(c)}else PMA_ajaxShowMessage(c.error,false)})});$("table.rte_table").find("input[name^=item], input[name^=params]").live("keydown",function(a){if(a.which===13){a.preventDefault();typeof RTE.buttonOptions[PMA_messages.strGo]==="function"&&RTE.buttonOptions[PMA_messages.strGo].call()}});$("a.ajax_export_anchor").live("click",function(a){a.preventDefault();var e=PMA_ajaxShowMessage();$.get($(this).attr("href"),{ajax_request:true},
function(b){if(b.success===true){PMA_ajaxRemoveMessage(e);var c={};c[PMA_messages.strClose]=function(){$(this).dialog("close").remove()};b=$("<div>"+b.message+"</div>").dialog({width:500,buttons:c,title:b.title}).find("textarea");CodeMirror.fromTextArea(b[0],{lineNumbers:true,matchBrackets:true,indentUnit:4,mode:"text/x-mysql"})}else PMA_ajaxShowMessage(b.error,false)})});$("a.ajax_drop_anchor").live("click",function(a){a.preventDefault();var e=$(this).parents("tr");a=$("<div/>").text(e.children("td").children(".drop_sql").html());
$(this).PMA_confirm(a,$(this).attr("href"),function(b){var c=PMA_ajaxShowMessage(PMA_messages.strProcessingRequest);$.get(b,{is_js_confirmed:1,ajax_request:true},function(f){if(f.success===true){var h=e.parent();h.find("tr").length===2?h.hide("slow",function(){$(this).find("tr.even, tr.odd").remove();$("#nothing2display").show("slow")}):e.hide("slow",function(){$(this).remove();var i=0,d="";h.find("tr").has("td").each(function(){d=i%2===0?"odd":"even";$(this).removeClass().addClass(d);i++})});PMA_ajaxRemoveMessage(c);
PMA_slidingMessage(f.sql_query)}else PMA_ajaxShowMessage(PMA_messages.strErrorProcessingRequest+" : "+f.error,false)})})})});
