$(document).ready(function(){$(".drop_column_anchor").live("click",function(a){a.preventDefault();a=window.parent.table;var c=$(this).parents("tr"),d=c.children("th").children("label").text(),f=$("select[name='after_field'] option[value='"+d+"']");a=PMA_messages.strDoYouReally+" :\n ALTER TABLE `"+escapeHtml(a)+"` DROP `"+escapeHtml(d)+"`";$(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(c.next());for(var b=c.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();c.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 c=$(this).parents("tr").children("th").children("label").text();
a=PMA_messages.strDoYouReally+" :\n ALTER TABLE `"+escapeHtml(a)+"` ADD PRIMARY KEY(`"+escapeHtml(c)+"`)";$(this).PMA_confirm(a,$(this).attr("href"),function(d){PMA_ajaxShowMessage(PMA_messages.strAddingPrimaryKey,false);$.get(d,{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 c=$anchor.parents("td").attr("rowspan")||1,d=a,f=1,g=a.next();f<c;f++,g=g.next())d=d.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=d.closest("table");if(d.length==b.find("tbody > tr").length){b.hide("medium",function(){$(".no_indexes_defined").show("medium");d.remove()});b.siblings("div.notice").hide("medium")}else{toggleRowColors(d.last().next());d.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 c=
$("#fieldsForm");a=c.attr("action");c=c.serialize()+"&ajax_request=true&submit_mult=change";changeColumns(a,c)}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 c=PMA_messages.strAddIndex}else{a=$(this).find("a").attr("href");if(a.substring(0,16)=="tbl_indexes.php?")a=a.substring(16,a.length);c=PMA_messages.strEditIndex}a+="&ajax_request=true";$("#edit_index_dialog").length!=0&&$("#edit_index_dialog").remove();var d=$('<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);d.append(e).dialog({title:c,width:450,open:PMA_verifyColumnsProperties,modal:true,buttons:f,close:function(){$(this).remove()}});checkIndexType();checkIndexName("index_frm");PMA_convertFootnotesToTooltips(d);d.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 c=$('<div id="add_columns"></div>');a=$("#addColumns");var d={};d[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)c.append(e.error).dialog({title:PMA_messages.strAddColumns,height:230,width:900,open:PMA_verifyColumnsProperties,modal:true,buttons:f});else{c.append(e).dialog({title:PMA_messages.strAddColumns,height:600,width:900,open:PMA_verifyColumnsProperties,modal:true,buttons:d});c=$("#add_columns");
$("#enum_editor").css("z-index","1100");PMA_convertFootnotesToTooltips(c)}PMA_ajaxRemoveMessage(g)})})});
function changeColumns(a,c){$("#change_column_dialog").length!=0&&$("#change_column_dialog").remove();var d=$('<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,c,function(b){if(b.success!=undefined&&b.success==false)d.append(b.error).dialog({title:PMA_messages.strChangeTbl,height:230,width:900,modal:true,open:PMA_verifyColumnsProperties,
buttons:g});else{d.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");d=$("#change_column_dialog");PMA_convertFootnotesToTooltips(d)}PMA_ajaxRemoveMessage(e)})}
$(document).ready(function(){$("#append_fields_form input[name=do_save_data]").live("click",function(a){a.preventDefault();a=$("#append_fields_form");if(checkTableEditForm(a[0],a.find("input[name=orig_num_fields]").val()))if(a.hasClass("ajax")){PMA_prepareForAjaxRequest(a);$.post(a.attr("action"),a.serialize()+"&do_save_data=Save",function(c){if($("#sqlqueryresults").length!=0)$("#sqlqueryresults").remove();else $(".error").length!=0&&$(".error").remove();if(c.success==true){PMA_ajaxShowMessage(c.message);
$("<div id='sqlqueryresults'></div>").insertAfter("#floating_menubar");$("#sqlqueryresults").html(c.sql_query);$("#result_query .notice").remove();$("#result_query").prepend(c.message);if($("#change_column_dialog").length>0)$("#change_column_dialog").dialog("close").remove();else $("#add_columns").length>0&&$("#add_columns").dialog("close").remove();$.post($("#fieldsForm").attr("action"),$("#fieldsForm").serialize()+"&ajax_request=true",function(d){$("#fieldsForm").remove();$("#addColumns").remove();
d=$("<div id='temp_div'><div>").append(d);$("#sqlqueryresults").length!=0?d.find("#fieldsForm").insertAfter("#sqlqueryresults"):d.find("#fieldsForm").insertAfter(".error");d.find("#addColumns").insertBefore("iframe.IE_hack");$table_clone=false;moreOptsMenuResize()})}else{c=$("<div id='temp_div'><div>").append(c).find(".error code").addClass("error");PMA_ajaxShowMessage(c,false)}})}else{a.append('<input type="hidden" name="do_save_data" value="Save" />');a.submit()}})},"top.frame_content");
var $table_clone=false;
function moreOptsMenuResize(){var a=$("table#tablestructure");if(!(a.length==0||a.hasClass("PropertiesIconic"))){if($table_clone!==false){a.replaceWith($table_clone);a=$table_clone}$table_clone=a.clone();a.find("td.more_opts").hide();var c=function(){var e=0;a.find("tr").eq(1).find("td.edit, td.drop, .replaced_by_more:visible, .more_opts:visible").each(function(){e+=$(this).outerWidth()});return e},d=$(window).width();a.find("tr").eq(0).children().each(function(){if($(this).index()<9)d-=$(this).outerWidth()+
1});var f=c();if(f>d)for(;f>d&&$(".replaced_by_more:visible").length>0;){f=a.find("tr").eq(1).find(".replaced_by_more:visible").last().prop("className").split(" ");a.find("."+f.join(".")).hide();a.find(".replace_in_more.action_"+f[0]).show();a.find("td.more_opts").show();f=c()}$(".replaced_by_more:hidden").length==0&&a.find("td.more_opts").hide();setTimeout(function(){$(".structure_actions_dropdown").each(function(){var e=$(this),b=e.parent().position().left+e.parent().innerWidth()-e.innerWidth(),
h=e.parent().position().top+e.parent().innerHeight();e.css({top:h,left:b})})},100);var g=$("select[name='after_field']");$("iframe[class='IE_hack']").width(g.width()).height(g.height()).offset({top:g.offset().top,left:g.offset().left});a.find("td.more_opts").unbind("mouseenter").bind("mouseenter",function(){$.browser.msie&&$.browser.version=="6.0"&&$("iframe[class='IE_hack']").show().width(g.width()+4).height(g.height()+4).offset({top:g.offset().top,left:g.offset().left});$(".structure_actions_dropdown").hide();
$(this).children(".structure_actions_dropdown").show();if($.browser.msie){var e=$(this).offset().left+$(this).innerWidth()-$(this).children(".structure_actions_dropdown").innerWidth(),b=$(this).offset().top+$(this).innerHeight();$(this).children(".structure_actions_dropdown").offset({top:b,left:e})}}).unbind("mouseleave").bind("mouseleave",function(){$(this).children(".structure_actions_dropdown").hide();$.browser.msie&&$.browser.version=="6.0"&&$("iframe[class='IE_hack']").hide()})}}$(window).resize(moreOptsMenuResize);
$(function(){$(".replace_in_more").hide();moreOptsMenuResize()});
