/*
  (c) 2008-2014 Samnan ur Rehman
 @web        http://mywebsql.net
 @license    http://mywebsql.net/license
*/
function logout(){optionsConfirm(__("Are you sure you want to logout?"),"sess.logout",function(a,b,c){a&&(c&&optionsConfirmSave(b),wrkfrmSubmit("logout","","",""))})}
function dbSelect(){1==arguments.length?(loc="?db="+escape(arguments[0]),window.location=loc):(db=document.getElementById("dblist").options[document.getElementById("dblist").selectedIndex].text,data="x=1&db="+escape(db),$.ajax({type:"GET",url:"?",data:data,success:function(a){success=$(a).html();"1"==success?(objectsRefresh(),infoDefault()):jAlert(__("Operation failed"))},dataType:"html"}))}
function dbDrop(a){msg=str_replace("{{NAME}}","<b>"+a+"</b>",__("Are you sure you want to DROP the database {{NAME}}?"));optionsConfirm(msg,"db.drop",function(b,c,d){b&&(d&&optionsConfirmSave(c),wrkfrmSubmit("dbdrop",type,a))})}function dbEmpty(a){msg=str_replace("{{NAME}}","<b>"+a+"</b>",__("Are you sure you want to DROP all objects from the database {{NAME}}?"));optionsConfirm(msg,"db.empty",function(b,c,d){b&&(d&&optionsConfirmSave(c),wrkfrmSubmit("dbempty",type,a))})}
function dbCreate(a){if(arguments.length&&a){if(name=$.trim($("#dbname").val()),""!=name)return wrkfrmSubmit("dbcreate","",name,$("#dbselect").prop("checked")?"1":"0"),$("#dialog-dbcreate").dialog("close"),!1}else $("#dbname").val(""),$("#dbselect").prop("checked",!1),uiCreateDialog("dbcreate"),$("#dialog-dbcreate").dialog("open")}
function objectsRefresh(){state=[];$("#tablelist .expandable").each(function(){state.push($(this).attr("id"))});wrkfrmSubmit("objlist","","","",function(a){objListHandler(a,state)})}function objDefault(a,b,c){$(currentTreeItem).removeClass("current");currentTreeItem=$("#"+b);currentTreeItem.addClass("current").find("a").blur();name=c?$("#"+c+" .schmf").text()+"."+currentTreeItem.find("a").text():currentTreeItem.find("a").text();wrkfrmSubmit("showinfo",a,name,"")}
function objCreate(a,b){taskbar.openDialog("objcreate_"+a,"?q=wrkfrm&type=objcreate&id="+a+"&name="+b,600,490)}function objTruncate(a,b){msg=str_replace("{{NAME}}",b,__("Are you sure you want to truncate the table {{NAME}}?"));optionsConfirm(msg,"obj.truncate",function(c,d,e){c&&(e&&optionsConfirmSave(d),wrkfrmSubmit("truncate",a,b))})}
function objDrop(a,b){msg=str_replace("{{NAME}}","<br>"+b,__("Are you sure you want to drop this object? {{NAME}}"));optionsConfirm(msg,"obj.drop",function(c,d,e){c&&(e&&optionsConfirmSave(d),wrkfrmSubmit("drop",a,b))})}function objRename(a,b){jPrompt(__("Enter new name for the database object"),b,__("Rename Object"),function(c){null!=c&&(c&&c!=b?wrkfrmSubmit("rename",a,b,c):jAlert(__("Enter new name for the database object")))})}
function objCopy(a,b){jPrompt(__("Enter new name for the database object"),b+"_copy",__("Copy Object"),function(c){null!=c&&(c&&c!=b?wrkfrmSubmit("copy",a,b,c):jAlert(__("Enter new name for the database object")))})}function tableCreate(a){taskbar.openDialog("editable","?q=wrkfrm&type=createtbl&name="+a,800,440,!0)}function tableSelect(a){st=sql_delimiter+"SELECT * FROM "+DB.quote(a);setSqlCode(st,1)}function tableInsert(a){wrkfrmSubmit("tableinsert","",a)}
function tableUpdate(a){wrkfrmSubmit("tableupdate","",a)}function tableDescribe(a){wrkfrmSubmit("describe","",a)}function tableViewData(a){q="SELECT * FROM "+DB.quote(a);setSqlCode(sql_delimiter+q,1);wrkfrmSubmit("query","table","",a)}function tableAlter(a){taskbar.openDialog("editable-"+a,"?q=wrkfrm&type=altertbl&name="+escape(a),780,440,!0)}function tableIndexes(a){taskbar.openDialog("indexes-"+a,"?q=wrkfrm&type=indexes&name="+escape(a),680,430,!0)}
function tableEngine(a){taskbar.openModal("table-engine","?q=wrkfrm&type=enginetype&name="+escape(a),280,190,!0)}function showCreateCmd(a,b){wrkfrmSubmit("showcreate",a,b,"")}function dataImport(){taskbar.openDialog("data-import","?q=wrkfrm&type=import",610,360)}function resultsExport(){0==numRecords?jAlert(__("There is no record in the results to export"),__("Exports results")):taskbar.openModal("data-export","?q=wrkfrm&type=exportres",510,340)}
function dataExport(){taskbar.openDialog("data-export","?q=wrkfrm&type=export",600,420)}function dataBackup(){taskbar.openDialog("data-backup","?q=wrkfrm&type=backup",660,460)}function dbBatch(){taskbar.openDialog("db-batch","?q=wrkfrm&type=dbbatch",600,440)}function tableImport(){taskbar.openDialog("table-import","?q=wrkfrm&type=importtbl",610,360)}function tableExport(a){taskbar.openDialog("table-export","?q=wrkfrm&type=exporttbl&table="+a,510,340)}
function exportData(){id=0<arguments.length?arguments[0]:"";name=1<arguments.length?arguments[1]:"";query=2<arguments.length?arguments[2]:"";wrkfrmSubmit("dl","export"+id,name,query)}function exportBackup(){id=0<arguments.length?arguments[0]:"";name=1<arguments.length?arguments[1]:"";query=2<arguments.length?arguments[2]:"";wrkfrmSubmit("dl","backup"+id,name,query)}function repairTables(){wrkfrmSubmit("dbrepair","","","")}
function helpShowAll(){taskbar.openDialog("help","?q=wrkfrm&type=help",680,440)}function helpQuickTutorial(){$('<link id="ehelp_css">').appendTo("head").attr({rel:"stylesheet",type:"text/css",href:"img/ehelp.css"});$.getScript("cache.php?script=ehelp",function(){taskbar.minimizeAll();showEHelp()})}function helpOnlineDocs(){window.open("http://mywebsql.net/docs")}function helpReportBug(){window.open("http://mywebsql.net/support/bugreport/")}
function helpRequestFeature(){window.open("http://mywebsql.net/support/requests/")}
function helpCheckUpdates(){$("#main_header .updates").html(__("Check for Updates")+"...").show();link="?q=wrkfrm&type=updatecheck";$.getJSON(link,function(a){a?"1"==a.success&&"1"==a.available&&a.link?$("#main_header .updates").html("<a href='"+a.link+"'>"+__("New version is available")+"</a>"):$("#main_header .updates").html(__("You have the latest version")).fadeOut(4E3):$("#main_header .updates").html(__("Update check failed")).fadeOut(4E3)}).error(function(){$("#main_header .updates").html(__("Update check failed")).fadeOut(4E3)})}
function setPreference(a,b){data="x=1&"+escape(a)+"="+escape(b);$.ajax({type:"GET",url:"?",data:data,success:function(a){window.location=window.location},dataType:"html"})}function toolsOptions(){taskbar.openModal("tools-options","?q=wrkfrm&type=options",500,300)}function toolsDbManager(){taskbar.openDialog("db-manager","?q=wrkfrm&type=databases",600,440)}function toolsProcManager(){taskbar.openDialog("tools-proc","?q=wrkfrm&type=processes",560,380)}
function toolsDbCheck(){taskbar.openDialog("tools-check","?q=wrkfrm&type=dbrepair",600,420)}function toolsDbSearch(){taskbar.openDialog("tools-search","?q=wrkfrm&type=search",620,450)}function toolsUsers(){taskbar.openDialog("tools-users","?q=wrkfrm&type=usermanager",620,440)}function infoDefault(){$("#screen-wait").remove();wrkfrmSubmit("info","","","")}function infoServer(){wrkfrmSubmit("infoserver","","","")}function infoVariables(){wrkfrmSubmit("infovars","","","")}
function infoDatabase(){wrkfrmSubmit("infodb","","","")}function navigatePage(a,b){window.location.href="?q=wrkfrm&type="+a+"&p="+b}function copyColumn(a){}function copyText(a){}function sqlFilterText(a){};
