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