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