var data_vt;function PMA_urldecode(d){return decodeURIComponent(d.replace(/\+/g,"%20"))}function PMA_urlencode(d){return encodeURIComponent(d.replace(/\%20/g,"+"))}function getFieldName(d,a){if(a=="vertical"){var b=d.siblings("th").find("a").text();if(""==b)b=d.siblings("th").text()}else{var e=d.index();b=$("#table_results").find("thead").find("th:nth("+(e-4)+") a").text();if(""==b)b=$("#table_results").find("thead").find("th:nth("+(e-4)+")").text()}return b=$.trim(b)}
function appendInlineAnchor(){if($("#top_direction_dropdown").val()=="vertical"){$("#table_results tr").find(".edit_row_anchor").removeClass("edit_row_anchor").parent().each(function(){var d=$(this),a=d.clone(),b=a.find("img:first").attr("title",PMA_messages.strInlineEdit);if(b.length!=0){var e=b.attr("src").replace(/b_edit/,"b_inline_edit");b.attr("src",e)}a.find("td").addClass("inline_edit_anchor").find("a").attr("href","#").find("span").text(" "+PMA_messages.strInlineEdit).prepend(b);a.insertAfter(d)});
$("#rowsDeleteForm").find("tbody").find("th").each(function(){var d=$(this);d.attr("rowspan")==4&&d.attr("rowspan","5")})}else{$(".edit_row_anchor").each(function(){var d=$(this);d.removeClass("edit_row_anchor");var a=d.clone(),b=a.find("img").attr("title",PMA_messages.strInlineEdit);if(b.length!=0){var e=b.attr("src").replace(/b_edit/,"b_inline_edit");b.attr("src",e);a.find("a").attr("href","#").find("span").text(" "+PMA_messages.strInlineEdit);a.find("span").first().prepend(b)}else{a.find("a").attr("href",
"#");a.find("a span").text(PMA_messages.strInlineEdit);b=a.find("input:image").attr("title",PMA_messages.strInlineEdit);if(b.length>0){e=b.attr("src").replace(/b_edit/,"b_inline_edit");b.attr("src",e)}a.find(".clickprevimage").text(" "+PMA_messages.strInlineEdit)}a.addClass("inline_edit_anchor");d.after(a)});$("#rowsDeleteForm").find("thead, tbody").find("th").each(function(){var d=$(this);d.attr("colspan")==4&&d.attr("colspan","5")})}}
$(document).ready(function(){$.ajaxSetup({cache:"false"});var d=$("#top_direction_dropdown").val();$("#top_direction_dropdown, #bottom_direction_dropdown").live("change",function(){d=$(this).val()});$("#sqlqueryresults").live("appendAnchor",function(){appendInlineAnchor()});$("#sqlqueryresults.ajax").trigger("appendAnchor");if(!$("#sqlqueryform").find("a").is("#togglequerybox")){$('<a id="togglequerybox"></a>').html(PMA_messages.strHideQueryBox).appendTo("#sqlqueryform").hide();$("#togglequerybox").bind("click",
function(){var a=$(this);a.siblings().slideToggle("fast");if(a.text()==PMA_messages.strHideQueryBox){a.text(PMA_messages.strShowQueryBox);$("#togglequerybox_spacer").remove();a.before('<br id="togglequerybox_spacer" />')}else a.text(PMA_messages.strHideQueryBox);return false})}$("#sqlqueryform.ajax").live("submit",function(a){a.preventDefault();$(".error").remove();$form=$(this);var b=PMA_ajaxShowMessage();PMA_prepareForAjaxRequest($form);$.post($(this).attr("action"),$(this).serialize(),function(e){if(e.success==
true){$(".success").fadeOut();$(".sqlquery_message").fadeOut();if(typeof e.sql_query!="undefined"){$('<div class="sqlquery_message"></div>').html(e.sql_query).insertBefore("#sqlqueryform");$(".notice").remove()}else $("#sqlqueryform").before(e.message);$("#sqlqueryresults").show();if(typeof e.reload!="undefined"){$("#sqlqueryform.ajax").die("submit");$form.find("input[name=db]").val(e.db);$form.find("input[name=ajax_request]").remove();$form.append('<input type="hidden" name="reload" value="true" />');
$.post("db_sql.php",$form.serialize(),function(l){$("body").html(l)})}}else if(e.success==false){$("#sqlqueryform").before(e.error);$("#sqlqueryresults").hide()}else{$(".success").fadeOut();$(".sqlquery_message").fadeOut();$received_data=$(e);$zero_row_results=$received_data.find('textarea[name="sql_query"]');if($zero_row_results.length>0)$("#sqlquery").val($zero_row_results.val());else{$("#sqlqueryresults").show();$("#sqlqueryresults").html(e);$("#sqlqueryresults").trigger("appendAnchor");$("#togglequerybox").show();
$("#togglequerybox").siblings(":visible").length>0&&$("#togglequerybox").trigger("click");PMA_init_slider()}}PMA_ajaxRemoveMessage(b)})});$("input[name=navig].ajax").live("click",function(a){a.preventDefault();var b=PMA_ajaxShowMessage();a=$(this).parent("form");a.append('<input type="hidden" name="ajax_request" value="true" />');$.post(a.attr("action"),a.serialize(),function(e){$("#sqlqueryresults").html(e);$("#sqlqueryresults").trigger("appendAnchor");PMA_init_slider();PMA_ajaxRemoveMessage(b)})});
$("#pageselector").live("change",function(a){var b=$(this).parent("form");if($(this).hasClass("ajax")){a.preventDefault();var e=PMA_ajaxShowMessage();$.post(b.attr("action"),b.serialize()+"&ajax_request=true",function(l){$("#sqlqueryresults").html(l);$("#sqlqueryresults").trigger("appendAnchor");PMA_init_slider();PMA_ajaxRemoveMessage(e)})}else b.submit()});$("#table_results.ajax").find("a[title=Sort]").live("click",function(a){a.preventDefault();var b=PMA_ajaxShowMessage();$anchor=$(this);$.get($anchor.attr("href"),
$anchor.serialize()+"&ajax_request=true",function(e){$("#sqlqueryresults").html(e).trigger("appendAnchor");PMA_ajaxRemoveMessage(b)})});$("#displayOptionsForm.ajax").live("submit",function(a){a.preventDefault();$form=$(this);$.post($form.attr("action"),$form.serialize()+"&ajax_request=true",function(b){$("#sqlqueryresults").html(b).trigger("appendAnchor");PMA_init_slider()})});$(".inline_edit_anchor span a").live("click",function(a){a.preventDefault();a=$(this).parents("td");a.removeClass("inline_edit_anchor").addClass("inline_edit_active").parent("tr").addClass("noclick");
var b=a.children("span.nowrap").children("a").children("span.nowrap");if(d!="vertical")b.empty();else data_vt=b.html();b.text(PMA_messages.strSave);var e='<br /><br /><a id="hide">'+PMA_messages.strHide+"</a>";if(d!="vertical"){a.append(e);$("#table_results tbody tr td a#hide").click(function(){b=$(this).siblings("span.nowrap").children("a").children("span.nowrap");b.empty();b.text(PMA_messages.strInlineEdit);var g=$(this).parent();g.removeClass("inline_edit_active hover").addClass("inline_edit_anchor");
g.parent().removeClass("hover noclick");g.siblings().removeClass("hover");for(var c=g.siblings().length,h="",f=4;f<c;f++)if(g.siblings("td:eq("+f+")").hasClass("inline_edit")!=false){h=g.siblings("td:eq("+f+")").data("original_data");if(g.siblings("td:eq("+f+")").children().length!=0){g.siblings("td:eq("+f+")").empty();g.siblings("td:eq("+f+")").append(h)}}$(this).prev().prev().remove();$(this).prev().remove();$(this).remove()})}else{var l="",m=a.parent().siblings().length;a.append(e);$("#table_results tbody tr td a#hide").click(function(){var g=
$(this).parent().index(),c=$(this).parent().children("span.nowrap").children("a").children("span.nowrap");c.empty();c.append(data_vt);c=$(this).parents("tr");c.siblings("tr:eq(3) td:eq("+g+")").removeClass("inline_edit_active").addClass("inline_edit_anchor");c.parent("tbody").find("tr").find("td:eq("+g+")").removeClass("marked hover");for(var h=6;h<=m+2;h++)if(c.siblings("tr:eq("+h+") td:eq("+g+")").hasClass("inline_edit")!=false){l=c.siblings("tr:eq("+h+") td:eq("+g+")").data("original_data");c.siblings("tr:eq("+
h+") td:eq("+g+")").empty();c.siblings("tr:eq("+h+") td:eq("+g+")").append(l)}$(this).prev().remove();$(this).prev().remove();$(this).remove()})}if(d=="vertical"){var j=a.index();e=a.parents("tbody").find("tr").find(".inline_edit:nth("+j+")");var k=a.parents("tbody").find("tr").find(".where_clause:nth("+j+")").val()}else{j=a.parent().index();e=a.parent("tr").find(".inline_edit");k=a.parent("tr").find(".where_clause").val()}e.each(function(){var g=$(this).html(),c=$(this),h=getFieldName(c,d),f=c.find("a").text(),
r=c.find("a").attr("title"),n=c.text();if(c.is(":not(.not_null)")){c.html('<div class="null_div">Null :<input type="checkbox" class="checkbox_null_'+h+"_"+j+'"></div>');c.is(".null")&&$(".checkbox_null_"+h+"_"+j).attr("checked",true);if(c.is(".enum, .set"))c.find("select").live("change",function(){$(".checkbox_null_"+h+"_"+j).attr("checked",false)});else if(c.is(".relation")){c.find("select").live("change",function(){$(".checkbox_null_"+h+"_"+j).attr("checked",false)});c.find(".browse_foreign").live("click",
function(){$(".checkbox_null_"+h+"_"+j).attr("checked",false)})}else c.find("textarea").live("keypress",function(){$(".checkbox_null_"+h+"_"+j).attr("checked",false)});$(".checkbox_null_"+h+"_"+j).bind("click",function(){if(c.is(".enum"))c.find("select").attr("value","");else if(c.is(".set"))c.find("select").find("option").each(function(){$(this).attr("selected",false)});else if(c.is(".relation"))c.find("select").length>0?c.find("select").attr("value",""):c.find("span.curr_value").empty();else c.find("textarea").val("")})}else c.html('<div class="null_div"></div>');
if(c.is(":not(.truncated, .transformed, .relation, .enum, .set, .null)")){c.append("<textarea>"+g+"</textarea>");c.data("original_data",g)}else if(c.is(".truncated, .transformed")){f="SELECT `"+h+"` FROM `"+window.parent.table+"` WHERE "+PMA_urldecode(k);$.post("sql.php",{token:window.parent.token,db:window.parent.db,ajax_request:true,sql_query:f,inline_edit:true},function(o){if(o.success==true){c.append("<textarea>"+o.value+"</textarea>");c.data("original_data",g)}else PMA_ajaxShowMessage(o.error)})}else if(c.is(".relation")){f=
{ajax_request:true,get_relational_values:true,db:window.parent.db,table:window.parent.table,column:h,token:window.parent.token,curr_value:f,relation_key_or_display_column:r};$.post("sql.php",f,function(o){c.append(o.dropdown);c.data("original_data",g)})}else if(c.is(".enum")){f={ajax_request:true,get_enum_values:true,db:window.parent.db,table:window.parent.table,column:h,token:window.parent.token,curr_value:n};$.post("sql.php",f,function(o){c.append(o.dropdown);c.data("original_data",g)})}else if(c.is(".set")){f=
{ajax_request:true,get_set_values:true,db:window.parent.db,table:window.parent.table,column:h,token:window.parent.token,curr_value:n};$.post("sql.php",f,function(o){c.append(o.select);c.data("original_data",g)})}else if(c.is(".null")){c.append("<textarea></textarea>");c.data("original_data","NULL")}})});$(".inline_edit_active span a").live("click",function(a){a.preventDefault();var b=$(this).parent().parent(),e="";if(d=="vertical")var l=b.index(),m=b.parents("tbody").find("tr").find(".inline_edit:nth("+
l+")"),j=b.parents("tbody").find("tr").find(".where_clause:nth("+l+")").val();else{m=b.parent("tr").find(".inline_edit");j=b.parent("tr").find(".where_clause").val()}a=b.is(".nonunique")?0:1;var k={},g=$("#relational_display_K").attr("checked")?"K":"D",c={},h=false,f="UPDATE `"+window.parent.table+"` SET ",r=false,n="";m.each(function(){var i=$(this),p=getFieldName(i,d),q={};if(i.is(".transformed"))h=true;if(i.find("input:checkbox").is(":checked")){f+=" `"+p+"`=NULL , ";r=true}else{if(i.is(":not(.relation, .enum, .set)")){q[p]=
i.find("textarea").val();i.is(".transformed")&&$.extend(c,q)}else if(i.is(".set")){e=i.find("select");q[p]=e.map(function(){return $(this).val()}).get().join(",")}else{e=i.find("select");if(e.length!=0)q[p]=e.val();e=i.find("span.curr_value");if(e.length!=0)q[p]=e.text();i.is(".relation")&&$.extend(k,q)}if(j.indexOf(p)>-1)n+="`"+window.parent.table+"`.`"+p+"` = '"+q[p].replace(/'/g,"''")+"' AND ";if(q[p]!=i.data("original_data")){f+=" `"+p+"`='"+q[p].replace(/'/g,"''")+"' , ";r=true}}});f=f.replace(/,\s$/,
"");n=n.substring(0,n.length-5);n=PMA_urlencode(n);f+=" WHERE "+PMA_urldecode(j);var o=$.param(k),u=$.param(c),s=$(this).parent(),t=$(this);r?$.post("tbl_replace.php",{ajax_request:true,sql_query:f,disp_direction:d,token:window.parent.token,db:window.parent.db,table:window.parent.table,clause_is_unique:a,where_clause:j,rel_fields_list:o,do_transformations:h,transform_fields_list:u,relational_display:g,"goto":"sql.php",submit_type:"save"},function(i){if(i.success==true){PMA_ajaxShowMessage(i.message);
d=="vertical"?b.parents("tbody").find("tr").find(".where_clause:nth("+l+")").attr("value",n):b.parent("tr").find(".where_clause").attr("value",n);$("#result_query").remove();typeof i.sql_query!="undefined"&&$("#sqlqueryresults").prepend(i.sql_query);PMA_unInlineEditRow(s,t,b,m,i,d)}else PMA_ajaxShowMessage(i.error)}):PMA_unInlineEditRow(s,t,b,m,"",d)})},"top.frame_content");
function PMA_unInlineEditRow(d,a,b,e,l,m){for(var j=0;j<=2;j++)d.next().remove();if(m!="vertical"){a.empty();a.html('<span class="nowrap"></span>');a.children("span.nowrap").text(PMA_messages.strInlineEdit)}else{a.children("span.nowrap").empty();a.children("span.nowrap").append(data_vt)}b.removeClass("inline_edit_active").addClass("inline_edit_anchor");b.parent("tr").removeClass("noclick");m!="vertical"?b.parent("tr").removeClass("hover").find("td").removeClass("hover"):b.parents("tbody").find("tr").find("td:eq("+
b.index()+")").removeClass("marked");e.each(function(){$this_sibling=$(this);if($this_sibling.find("input:checkbox").is(":checked")){$this_sibling.html("NULL");$this_sibling.addClass("null")}else{$this_sibling.removeClass("null");if($this_sibling.is(":not(.relation, .enum, .set)")){var k=$this_sibling.find("textarea").val();if($this_sibling.is(".transformed")){var g=getFieldName($this_sibling,m);typeof l.transformations!="undefined"&&$.each(l.transformations,function(h,f){if(h==g){if($this_sibling.is(".text_plain, .application_octetstream"))k=
f;else{var r=$this_sibling.find("textarea").val();k=$(f).append(r)}return false}})}}else{var c=k="";$test_element=$this_sibling.find("select");if($test_element.length!=0)c=$test_element.val();$test_element=$this_sibling.find("span.curr_value");if($test_element.length!=0)c=$test_element.text();if($this_sibling.is(".relation")){g=getFieldName($this_sibling,m);typeof l.relations!="undefined"&&$.each(l.relations,function(h,f){if(h==g){k=$(f);return false}})}else if($this_sibling.is(".enum"))k=c;else if($this_sibling.is(".set"))if(c!=
null){$.each(c,function(h,f){k=k+f+","});k=k.substring(0,k.length-1)}}$this_sibling.html(k)}})}function PMA_changeClassForColumn(d,a){var b=d.index();!d.closest("tr").children(":first").hasClass("column_heading")&&b--;b=d.closest("table").find("tbody tr").find("td.data:eq("+b+")");if(d.data("has_class_"+a)){b.removeClass(a);d.data("has_class_"+a,false)}else{b.addClass(a);d.data("has_class_"+a,true)}}
$(document).ready(function(){$(".browse_foreign").live("click",function(d){d.preventDefault();window.open(this.href,"foreigners","width=640,height=240,scrollbars=yes,resizable=yes");$anchor=$(this);$anchor.addClass("browse_foreign_clicked");return false});$(".column_heading").live("hover",function(){PMA_changeClassForColumn($(this),"hover")});$(".column_heading").live("click",function(){PMA_changeClassForColumn($(this),"marked")})});
