$(document).ready(function(){$(".drop_column_anchor").live("click",function(a){a.preventDefault();a=window.parent.table;var d=$(this).parents("tr"),c=d.children("th").children("label").text(),f=$("select[name='after_field'] option[value='"+c+"']");a=PMA_messages.strDoYouReally+" :\n ALTER TABLE `"+escapeHtml(a)+"` DROP `"+escapeHtml(c)+"`";$(this).PMA_confirm(a,$(this).attr("href"),function(g){PMA_ajaxShowMessage(PMA_messages.strDroppingColumn,false);$.get(g,{is_js_confirmed:1,ajax_request:true},
function(e){if(e.success==true){PMA_ajaxShowMessage(e.message);toggleRowColors(d.next());for(var b=d.next();b.length>0;b=b.next()){var h=parseInt(b.find("td:nth-child(2)").text())-1;b.find("td:nth-child(2)").text(h)}f.remove();d.hide("medium").remove();$("#indexes").html(e.indexes_list)}else PMA_ajaxShowMessage(PMA_messages.strErrorProcessingRequest+" : "+e.error,false)})})});$(".action_primary a").live("click",function(a){a.preventDefault();a=window.parent.table;var d=$(this).parents("tr").children("th").children("label").text();
a=PMA_messages.strDoYouReally+" :\n ALTER TABLE `"+escapeHtml(a)+"` ADD PRIMARY KEY(`"+escapeHtml(d)+"`)";$(this).PMA_confirm(a,$(this).attr("href"),function(c){PMA_ajaxShowMessage(PMA_messages.strAddingPrimaryKey,false);$.get(c,{is_js_confirmed:1,ajax_request:true},function(f){if(f.success==true){PMA_ajaxShowMessage(f.message);$(this).remove();typeof f.reload!="undefined"&&window.parent.frame_content.location.reload()}else PMA_ajaxShowMessage(PMA_messages.strErrorProcessingRequest+" : "+f.error,
false)})})});$(".drop_primary_key_index_anchor").live("click",function(a){a.preventDefault();$anchor=$(this);a=$anchor.parents("tr");for(var d=$anchor.parents("td").attr("rowspan")||1,c=a,f=1,g=a.next();f<d;f++,g=g.next())c=c.add(g);a=a.children("td").children(".drop_primary_key_index_msg").val();$anchor.PMA_confirm(a,$anchor.attr("href"),function(e){PMA_ajaxShowMessage(PMA_messages.strDroppingPrimaryKeyIndex,false);$.get(e,{is_js_confirmed:1,ajax_request:true},function(b){if(b.success==true){PMA_ajaxShowMessage(b.message);
b=c.closest("table");if(c.length==b.find("tbody > tr").length){b.hide("medium",function(){$(".no_indexes_defined").show("medium");c.remove()});b.siblings("div.notice").hide("medium")}else{toggleRowColors(c.last().next());c.hide("medium",function(){$(this).remove()})}}else PMA_ajaxShowMessage(PMA_messages.strErrorProcessingRequest+" : "+b.error,false)})})});$("#fieldsForm.ajax .mult_submit[value=change]").live("click",function(a){a.preventDefault();if($("#tablestructure tbody tr").hasClass("marked")){var d=
$("#fieldsForm");a=d.attr("action");d=d.serialize()+"&ajax_request=true&submit_mult=change";changeColumns(a,d)}else PMA_ajaxShowMessage(PMA_messages.strNoRowSelected)});$("#fieldsForm.ajax #tablestructure tbody tr td.edit a").live("click",function(a){a.preventDefault();a=$(this).attr("href");if(a.substring(0,13)=="tbl_alter.php")a=a.substring(14,a.length);a+="&ajax_request=true";changeColumns("tbl_alter.php",a)});$("#table_index tbody tr td.edit_index.ajax, #indexes .add_index.ajax").live("click",
function(a){a.preventDefault();if($(this).find("a").length==0){if(!checkFormElementInRange($(this).closest("form")[0],"added_fields","Column count has to be larger than zero."))return;a=$(this).closest("form").serialize();var d=PMA_messages.strAddIndex}else{a=$(this).find("a").attr("href");if(a.substring(0,16)=="tbl_indexes.php?")a=a.substring(16,a.length);d=PMA_messages.strEditIndex}a+="&ajax_request=true";$("#edit_index_dialog").length!=0&&$("#edit_index_dialog").remove();var c=$('<div id="edit_index_dialog"></div>'),
f={};f[PMA_messages.strGo]=function(){var e=$("#index_frm");PMA_prepareForAjaxRequest(e);$.post(e.attr("action"),e.serialize()+"&do_save_data=1",function(b){$("#sqlqueryresults").length!=0&&$("#sqlqueryresults").remove();if(b.success==true){PMA_ajaxShowMessage(b.message);$("<div id='sqlqueryresults'></div>").insertAfter("#floating_menubar");$("#sqlqueryresults").html(b.sql_query);$("#result_query .notice").remove();$("#result_query").prepend(b.message);$("#table_index").remove();b=$("<div id='temp_div'><div>").append(b.index_table);
b.find("#table_index").insertAfter("#index_header");$("#edit_index_dialog").length>0&&$("#edit_index_dialog").dialog("close");$(".no_indexes_defined").hide()}else if(b.error!=undefined){b=$("<div id='temp_div'><div>").append(b.error);b=b.find(".error code").length!=0?b.find(".error code").addClass("error"):b;PMA_ajaxShowMessage(b,false)}})};f[PMA_messages.strCancel]=function(){$(this).dialog("close")};var g=PMA_ajaxShowMessage();$.get("tbl_indexes.php",a,function(e){if(e.error)PMA_ajaxShowMessage(e.error,
false);else{PMA_ajaxRemoveMessage(g);c.append(e).dialog({title:d,width:450,open:PMA_verifyColumnsProperties,modal:true,buttons:f,close:function(){$(this).remove()}});checkIndexType();checkIndexName("index_frm");PMA_convertFootnotesToTooltips(c);c.find(".slider").slider({animate:true,value:1,min:1,max:16,slide:function(b,h){$(this).closest("fieldset").find("input[type=submit]").val(PMA_messages.strAddToIndex.replace(/%d/,h.value))}});$(".ui-slider-handle").addClass("ui-state-focus")}})});$("#index_frm input[type=submit]").live("click",
function(a){a.preventDefault();for(a=$(this).closest("fieldset").find(".slider").slider("value");a--;)$("#index_columns").find("tbody > tr:first").clone().appendTo($("#index_columns").find("tbody")).find(":input").each(function(){$(this).val("")})});$("#addColumns.ajax input[type=submit]").live("click",function(a){a.preventDefault();$("#add_columns").length!=0&&$("#add_columns").remove();var d=$('<div id="add_columns"></div>');a=$("#addColumns");var c={};c[PMA_messages.strCancel]=function(){$(this).dialog("close").remove()};
var f={};f[PMA_messages.strOK]=function(){$(this).dialog("close").remove()};var g=PMA_ajaxShowMessage();$.get(a.attr("action"),a.serialize()+"&ajax_request=true",function(e){if(e.success!=undefined&&e.success==false)d.append(e.error).dialog({title:PMA_messages.strAddColumns,height:230,width:900,open:PMA_verifyColumnsProperties,modal:true,buttons:f});else{d.append(e).dialog({title:PMA_messages.strAddColumns,height:600,width:900,open:PMA_verifyColumnsProperties,modal:true,buttons:c});d=$("#add_columns");
$("#enum_editor").css("z-index","1100");PMA_convertFootnotesToTooltips(d)}PMA_ajaxRemoveMessage(g)})})});
function changeColumns(a,d){$("#change_column_dialog").length!=0&&$("#change_column_dialog").remove();var c=$('<div id="change_column_dialog"></div>'),f={};f[PMA_messages.strCancel]=function(){$(this).dialog("close").remove()};var g={};g[PMA_messages.strOK]=function(){$(this).dialog("close").remove()};var e=PMA_ajaxShowMessage();$.get(a,d,function(b){if(b.success!=undefined&&b.success==false)c.append(b.error).dialog({title:PMA_messages.strChangeTbl,height:230,width:900,modal:true,open:PMA_verifyColumnsProperties,
buttons:g});else{c.append(b).dialog({title:PMA_messages.strChangeTbl,height:600,width:900,modal:true,open:PMA_verifyColumnsProperties,buttons:f});$("#append_fields_form input[name=do_save_data]").addClass("ajax");$("#enum_editor").css("z-index","1100");c=$("#change_column_dialog");PMA_convertFootnotesToTooltips(c)}PMA_ajaxRemoveMessage(e)})};
