function displayHelp(){var a=PMA_ajaxShowMessage(PMA_messages.strDisplayHelp,1E4);a.click(function(){PMA_ajaxRemoveMessage(a)})}Array.max=function(a){return Math.max.apply(Math,a)};Array.min=function(a){return Math.min.apply(Math,a)};function isNumeric(a){return!isNaN(parseFloat(a))&&isFinite(a)}function isEmpty(a){for(var c in a)return false;return true}
function getTimeStamp(a,c){if(c.toString().search(/datetime/i)!=-1||c.toString().search(/timestamp/i)!=-1)return getDateFromFormat(a,"yyyy-MM-dd HH:mm:ss",a);else if(c.toString().search(/time/i)!=-1)return getDateFromFormat("1970-01-01 "+a,"yyyy-MM-dd HH:mm:ss");else if(c.toString().search(/date/i)!=-1)return getDateFromFormat(a,"yyyy-MM-dd")}
function getType(a){return a.toString().search(/int/i)!=-1||a.toString().search(/decimal/i)!=-1||a.toString().search(/year/i)!=-1?"numeric":a.toString().search(/time/i)!=-1||a.toString().search(/date/i)!=-1?"time":"text"}function getCord(a){var c=[],g=$.extend(true,[],a);a=jQuery.unique(a).sort();$.each(g,function(k,h){c.push(jQuery.inArray(h,a))});return[c,a,g]}function scrollToChart(){var a=$("#dataDisplay").offset().top-100;$("html,body").animate({scrollTop:a},500)}
$(document).ready(function(){$("input[name='mode']:checked").val();var a=null,c=null,g=$("#tableid_0").val(),k=$("#tableid_1").val(),h=$("#types_0").val(),l=$("#types_1").val(),t=$("#dataLabel").val(),p=jQuery.parseJSON($("#querydata").html());$("#tableid_0").change(function(){$("#zoom_search_form").submit()});$("#tableid_1").change(function(){$("#zoom_search_form").submit()});$("#tableid_2").change(function(){$("#zoom_search_form").submit()});$("#tableid_3").change(function(){$("#zoom_search_form").submit()});
$("#inputFormSubmitId").click(function(){if($("#tableid_0").get(0).selectedIndex==0||$("#tableid_1").get(0).selectedIndex==0)PMA_ajaxShowMessage(PMA_messages.strInputNull);else g==k&&PMA_ajaxShowMessage(PMA_messages.strSameInputs)});$('<div id="togglesearchformdiv"><a id="togglesearchformlink"></a></div>').insertAfter("#zoom_search_form").hide();$("#togglesearchformlink").html(PMA_messages.strShowSearchCriteria).bind("click",function(){var d=$(this);$("#zoom_search_form").slideToggle();d.text()==
PMA_messages.strHideSearchCriteria?d.text(PMA_messages.strShowSearchCriteria):d.text(PMA_messages.strHideSearchCriteria);return false});var q={};q[PMA_messages.strSave]=function(){var d={},f={},b=4,e=false,m=false;for(key in i){var n=i[key],o=$("#fields_null_id_"+b).attr("checked")?null:$("#fieldID_"+b).val();if(o instanceof Array)o=$("#fieldID_"+b).map(function(){return $(this).val()}).get().join(",");if(n!=o){i[key]=o;d[key]=o;if(key==g){e=true;p[c][g]=o}else if(key==k){m=true;p[c][k]=o}}if($("#fieldID_"+
b).hasClass("bit"))f[key]="bit";b++}if(e||m){if(e){if(h=="numeric")j[0][c][0]=i[g];else if(h=="time")j[0][c][0]=getTimeStamp(i[g],$("#types_0").val());a.series[0].data=j[0];a.replot()}if(m){if(l=="numeric")j[0][c][1]=i[k];else if(l=="time")j[0][c][1]=getTimeStamp(i[k],$("#types_1").val());a.series[0].data=j[0];a.replot()}}if(!isEmpty(d)){b="UPDATE `"+window.parent.table+"` SET ";for(key in d){b+="`"+key+"`=";e=d[key];if(e==null)b+="NULL, ";else if($.trim(e)=="")b+="'', ";else if(f[key]!=null){if(f[key]==
"bit")b+="b'"+e+"', "}else b+=isNumeric(e)?e+", ":"'"+e+"', "}b=b.substring(0,b.length-2);b+=" WHERE "+PMA_urldecode(p[c].where_clause);$.post("sql.php",{token:window.parent.token,db:window.parent.db,ajax_request:true,sql_query:b,inline_edit:false},function(s){if(s.success==true){$("#sqlqueryresults").html(s.sql_query);$("#sqlqueryresults").trigger("appendAnchor")}else PMA_ajaxShowMessage(s.error,false)})}$("#dataDisplay").dialog("close")};q[PMA_messages.strCancel]=function(){$(this).dialog("close")};
$("#dataDisplay").dialog({autoOpen:false,title:PMA_messages.strDataPointContent,modal:true,buttons:q,width:$("#dataDisplay").width()+80,open:function(){$(this).find("input[type=checkbox]").css("margin","0.5em")}});$("#dataDisplay").find(":input").live("keydown",function(d){if(d.which===13){d.preventDefault();typeof q[PMA_messages.strSave]==="function"&&q[PMA_messages.strSave].call()}});if(p!=null){$("#zoom_search_form").slideToggle().hide();$("#togglesearchformlink").text(PMA_messages.strShowSearchCriteria);
$("#togglesearchformdiv").show();var i,j=[],r={series:[{showLine:false}],axes:{xaxis:{label:$("#tableid_0").val(),labelRenderer:$.jqplot.CanvasAxisLabelRenderer},yaxis:{label:$("#tableid_1").val(),labelRenderer:$.jqplot.CanvasAxisLabelRenderer}},highlighter:{show:true,tooltipAxes:"y",yvalues:2,formatString:'<span class="hide">%s</span>%s'},cursor:{show:true,zoom:true,showTooltip:false}};if(t=="")r.highlighter.show=false;h=getType(h);l=getType(l);j[0]=[];if(h=="time"){originalXType=$("#types_0").val();
if(originalXType=="date")format="%Y-%m-%d";$.extend(r.axes.xaxis,{renderer:$.jqplot.DateAxisRenderer,tickOptions:{formatString:format}})}if(l=="time"){originalYType=$("#types_1").val();if(originalYType=="date")format="%Y-%m-%d";$.extend(r.axes.yaxis,{renderer:$.jqplot.DateAxisRenderer,tickOptions:{formatString:format}})}$.each(p,function(d,f){if(h=="numeric")var b=parseFloat(f[g]);if(h=="time")b=getTimeStamp(f[g],originalXType);if(l=="numeric")var e=parseFloat(f[k]);if(l=="time")e=getTimeStamp(f[k],
originalYType);j[0].push([b,e,f[t],f.where_clause,d])});a=$.jqplot("querychart",j,r);$("button.button-reset").click(function(d){d.preventDefault();a.resetZoom()});$("div#resizer").resizable();$("div#resizer").bind("resizestop",function(){$("div#querychart").height($("div#resizer").height()*0.96);$("div#querychart").width($("div#resizer").width()*0.96);a.replot({resetAxes:true})});$("div#querychart").bind("jqplotDataClick",function(d,f,b,e){c=e[4];var m=4;$.post("tbl_zoom_select.php",{ajax_request:true,
get_data_row:true,db:window.parent.db,table:window.parent.table,where_clause:e[3],token:window.parent.token},function(n){for(key in n.row_info){$field=$("#fieldID_"+m);$field_null=$("#fields_null_id_"+m);if(n.row_info[key]==null){$field_null.attr("checked",true);$field.val("")}else{$field_null.attr("checked",false);$field.attr("multiple")?$field.val(n.row_info[key].split(",")):$field.val(n.row_info[key])}m++}i={};i=n.row_info});$("#dataDisplay").dialog("open")})}});
