function callbacks(result,e)
{if(e.status===true)
{if(e.result.success==true)
{var $module;$module='callback_'+e.action+'_'+e.method;$=window;if(typeof $[$module]=='function')
{window[$module](result,e);}}
else
{callback_errorParser(result,e);}}
else
{if(e.action=='knichel'){var win=Ext.getCmp('knichelWin');win.mask.hide();}
Ext.MessageBox.alert('Fatal Error','Unable to communicate with the server.  <br />&nbsp;<br />Please refresh the Application as soon as possible');}}
function callback_errorParser(result,e)
{console.info(e);if(result=='{}'){return false}
if(e.method=='logout'){setCookie('derm_login','null',-1);location.reload();return}
if(e.action=='knichel'){var win=Ext.getCmp('knichelWin');win.mask.hide();}
var code='';if(is_numeric(result.code))
{code='<br />Error Code: '+String.leftPad(result.code,3,'0');}
var reason='Default Error Message';if(typeof result.reason!='undefined')
{reason=result.reason.replace("\r\n","&nbsp;<br />");}
if(typeof result.mask!='undefined')
{var el=Ext.get(result.mask);if(el!=null)
{el.unmask();}}
Ext.MessageBox.alert('Error','Application Returned Error: <p><b>'+reason+'</b></p>&nbsp;'+code);if(e.method=='changePassword'){Ext.getCmp('changePasswordWin').enable()};}
function callback_knichel_getData(result,e)
{var win=Ext.getCmp('knichelWin');win.stat.barPanel[result.site].reset(true);var debug=Ext.getCmp('knichelDebugWin');if(Ext.isDefined(debug))
{debug.panelLogin.setValue(result.login);debug.panelRequest.setValue(result.response);debug.panelAdditional.setValue(result.final);debug.panelParse.setValue(result.parse);}
MyDesktop.getModule('knichelResults').createWindow();window.stores.knichel.store.loadData(result.encodedData,true);win.stat.setActive(true);if(win.sitePos<win.sites.length)
{var fieldData=win.fieldData;fieldData.site=win.sites[win.sitePos];win.stat.barPanel[fieldData.site].wait({text:'Contacting '+fieldData.site});knichel.getData(fieldData,callbacks);win.sitePos+=1;}
else if(result.site==win.sites[(win.sites.length-1)])
{win.stat.close();}
win.doLayout();}
function callback_miscFunctions_test(result,e)
{var win=Ext.getCmp('serverDebugWin');win.panelLogin.setValue(result.login);win.panelRequest.setValue(result.response);win.panelAdditional.setValue(result.final);}
function callback_chatFunctions_post(result,e)
{var poller=Ext.Direct.getProvider('jabber_polling');var win=Ext.getCmp('chatWin');var t=e.getTransaction();jabberVariables['lastMsg']=result['ID'];if(result.oldmsgs.length>0)
{for(var i in result.oldmsgs)
{if(typeof result.oldmsgs[i].user!='undefined')
{win.post_message(result.oldmsgs[i],true);}}}
if(result['msg']!='null')
{var msg=result['msg'];win.post_message(result,true);}
if(typeof(poller)!='undefined')
{if(!poller.isConnected())
{poller.connect();}}}
function callback_SO4Functions_ingredientAdd(result,e)
{MyDesktop.desktop.showNotification({title:'Success',msg:'Ingredient Added'});for(var i in result.refresh)
{if(typeof result.refresh[i]=='string'&&Ext.isDefined(window.stores[result.refresh[i]]))
{window.stores[result.refresh[i]].store.load({params:'game_'+result.refresh[i]});}}
window.stores.itemLocation.store.load({params:'weee'});Ext.getCmp('newIngredientWin').close();};Ext.Direct.addProvider
(Ext.app.REMOTING_API);var provider=Ext.Direct.getProvider('serverstackapi');provider.timeout=60000;provider.maxRetries=0;if(typeof(provider)!='undefined')
{provider.on
({'beforecall':{fn:function(prov,obj)
{var check=getCookie('PHPSESSID');if(check!==null&&check!='')
{for(var i in obj.data)
{if(is_numeric(i)||i==0)
{i=i*1;var max=i+1;}
if(obj.data[i]!==null&&obj.data[i]!='')
{if(typeof obj.data[i]=='array'||typeof obj.data[i]=='object')
{obj.data[i]=Ext.util.JSON.encode(obj.data[i]);}
else if(typeof obj.data[i]=='boolean')
{obj.data[i]=obj.data[i].toString();}
obj.data[i]=AesCtr.encrypt(obj.data[i],check,256);}}
obj.data[max]=AesCtr.encrypt(check,check,256);}
else
{logout('encrypt');}
if(obj.action!='polling'&&typeof window.inactivityTimer!='undefined')
{window.inactivityTimer.timeout=time();}}},'data':{fn:function(prov,e)
{if(e.method=='logout'){return}
var check=getCookie('PHPSESSID');if(check!==null&&check!='')
{if(typeof e.result=='undefined')
{Ext.MessageBox.alert('Warning','Unable to communicate with the Server');console.error('Invalid Server Response');return false;}
if(e.result.nodecrypt===true)
{logout('encrypt');e.result='{}';}
else if(e.result.invalidaction===true)
{alert('invalid action');e.result='{}';}
else if(e.result.invalidmethod===true)
{alert('invalid method');e.result='{}';}
else if(e.result.loggedout===true&&e.method!='debugServer')
{logout('lout');e.result='{}';}
else
{e.result=Ext.util.JSON.decode(AesCtr.decrypt(e.result,check,256));if(e.result.sid!=check)
{logout('encrypt');e.result='{}';}}
for(var i in e.result)
{if(is_numeric(e.result[i]))
{e.result[i]=e.result[i]*1;}}}
else
{logout('encrypt');e.result='{}';}}},'exception':{fn:function()
{console.debug(arguments);}}})};if(typeof window.stores=='undefined')
{window.stores={};}
window.stores.chatStore={};window.stores.chatStore.record=Ext.data.Record.create
(['ID',{name:'user'},{name:'timestamp'},{name:'msg'}]);window.stores.chatStore.reader=new Ext.data.JsonReader
({root:"rows",totalProperty:"results"},window.stores.chatStore.record);window.stores.chatStore.store=new Ext.data.Store
({autoDestroy:false,reader:window.stores.chatStore.reader,});window.stores.recipe_foodDescription={};window.stores.recipe_foodDescription.store=new Ext.data.DirectStore
({autoLoad:false,directFn:recipeFunctions.getFoodDB,root:'rows',fields:['NDB_No','FdGrp_Cd','Long_Desc','Shrt_Desc','ComName','ManufacName','Survey','Ref_desc','Refuse','SciName','N_Factor','Pro_factor','Fat_Factor','CHO_Factor'],listeners:{load:function(o)
{}}});window.stores.recipe_foodGroup={};window.stores.recipe_foodGroup.store=new Ext.data.DirectStore
({autoLoad:false,directFn:recipeFunctions.getFoodGroups,root:'rows',fields:['FdGrp_Cd','FdGrp_Desc'],listeners:{load:function(o)
{}}});window.stores.starocean4_bestiary={};window.stores.starocean4_bestiary.record=Ext.data.Record.create
([{name:'ID'},{name:'monster'}]);window.stores.starocean4_bestiary.reader=new Ext.data.JsonReader
({root:"rows",idProperty:"ID",totalProperty:"results"},window.stores.starocean4_bestiary.record);window.stores.starocean4_bestiary.store=new Ext.data.DirectStore
({autoLoad:false,directFn:miscFunctions.getTable,reader:window.stores.starocean4_bestiary.reader,listeners:{}});window.stores.itemLocation={};window.stores.itemLocation.record=Ext.data.Record.create
([{name:'item'},{name:'type'},{name:'planet'},{name:'locations'}]);window.stores.itemLocation.reader=new Ext.data.JsonReader
({root:"rows",idProperty:"ID",totalProperty:"results"},window.stores.itemLocation.record);window.stores.itemLocation.store=new Ext.data.DirectStore
({autoLoad:false,directFn:SO4Functions.itemLocationGet,reader:window.stores.itemLocation.reader,listeners:{load:function(store,records,o)
{}}});window.stores.starocean4_itemLocationType={};window.stores.starocean4_itemLocationType.record=Ext.data.Record.create
([{name:'ID'},{name:'type'}]);window.stores.starocean4_itemLocationType.reader=new Ext.data.JsonReader
({root:"rows",idProperty:"ID",totalProperty:"results"},window.stores.starocean4_itemLocationType.record);window.stores.starocean4_itemLocationType.store=new Ext.data.DirectStore
({autoLoad:false,directFn:miscFunctions.getTable,reader:window.stores.starocean4_itemLocationType.reader,listeners:{}});window.stores.starocean4_locations={};window.stores.starocean4_locations.record=Ext.data.Record.create
([{name:'ID'},{name:'location'}]);window.stores.starocean4_locations.reader=new Ext.data.JsonReader
({root:"rows",idProperty:"ID",totalProperty:"results"},window.stores.starocean4_locations.record);window.stores.starocean4_locations.store=new Ext.data.DirectStore
({autoLoad:false,directFn:miscFunctions.getTable,reader:window.stores.starocean4_locations.reader,listeners:{}});window.stores.starocean4_planets={};window.stores.starocean4_planets.record=Ext.data.Record.create
([{name:'ID'},{name:'planet'}]);window.stores.starocean4_planets.reader=new Ext.data.JsonReader
({root:"rows",idProperty:"ID",totalProperty:"results"},window.stores.starocean4_planets.record);window.stores.starocean4_planets.store=new Ext.data.DirectStore
({autoLoad:false,directFn:miscFunctions.getTable,reader:window.stores.starocean4_planets.reader,listeners:{}});window.stores.starocean4_quests={};window.stores.starocean4_quests.record=Ext.data.Record.create
([{name:'ID'},{name:'quest'}]);window.stores.starocean4_quests.reader=new Ext.data.JsonReader
({root:"rows",idProperty:"ID",totalProperty:"results"},window.stores.starocean4_quests.record);window.stores.starocean4_quests.store=new Ext.data.DirectStore
({autoLoad:false,directFn:miscFunctions.getTable,reader:window.stores.starocean4_quests.reader,listeners:{}});window.stores.starocean4_recipeCategory={};window.stores.starocean4_recipeCategory.record=Ext.data.Record.create
([{name:'ID'},{name:'category'}]);window.stores.starocean4_recipeCategory.reader=new Ext.data.JsonReader
({root:"rows",totalProperty:"results"},window.stores.starocean4_recipeCategory.record);window.stores.starocean4_recipeCategory.store=new Ext.data.DirectStore
({autoDestroy:false,autoLoad:false,directFn:miscFunctions.getTable,reader:window.stores.starocean4_recipeCategory.reader,listeners:{}});window.stores.starocean4_recipeList={};window.stores.starocean4_recipeList.record=Ext.data.Record.create
(['ID','categoryID','createID','skilllevel','source']);window.stores.starocean4_recipeList.reader=new Ext.data.JsonReader
({root:"rows",idProperty:"ID",totalProperty:"results"},window.stores.starocean4_recipeList.record);window.stores.starocean4_recipeList.store=new Ext.data.DirectStore
({autoLoad:false,directFn:SO4Functions.recipeListGet,reader:window.stores.starocean4_recipeList.reader,listeners:{}});window.stores.starocean4_stores={};window.stores.starocean4_stores.record=Ext.data.Record.create
([{name:'ID'},{name:'store'}]);window.stores.starocean4_stores.reader=new Ext.data.JsonReader
({root:"rows",idProperty:"ID",totalProperty:"results"},window.stores.starocean4_stores.record);window.stores.starocean4_stores.store=new Ext.data.DirectStore
({autoLoad:false,directFn:miscFunctions.getTable,reader:window.stores.starocean4_stores.reader,listeners:{}});window.stores.knichel={};window.stores.knichel.record=Ext.data.Record.create
(['rateholder','carrier',{name:'transit',type:'int'},{name:'rate',type:'float'}]);window.stores.knichel.reader=new Ext.data.JsonReader
({root:"rows",totalProperty:"results"},window.stores.knichel.record);window.stores.knichel.store=new Ext.data.Store
({reader:window.stores.knichel.reader,listeners:{}});;Ext.override(Ext.Element,{scrollIntoView:function(container,hscroll){var c=Ext.getDom(container)||Ext.getBody().dom;var el=this.dom;var o=this.getOffsetsTo(c),s=this.getScroll(),l=o[0]+s.left,t=o[1]+s.top,b=t+el.offsetHeight,r=l+el.offsetWidth;var ch=c.clientHeight;var ct=parseInt(c.scrollTop,10);var cl=parseInt(c.scrollLeft,10);var cb=ct+ch;var cr=cl+c.clientWidth;if(el.offsetHeight>ch||t<ct){c.scrollTop=t;}else if(b>cb){c.scrollTop=b-ch;}
c.scrollTop=c.scrollTop;if(hscroll!==false){if(el.offsetWidth>c.clientWidth||l<cl){c.scrollLeft=l;}else if(r>cr){c.scrollLeft=r-c.clientWidth;}
c.scrollLeft=c.scrollLeft;}
return this;}});Ext.util.clone=function(o){if(!o||'object'!==typeof o){return o;}
if('function'===typeof o.clone){return o.clone();}
var c='[object Array]'===Object.prototype.toString.call(o)?[]:{};var p,v;for(p in o){if(o.hasOwnProperty(p)){v=o[p];if(v&&'object'===typeof v){c[p]=Ext.util.clone(v);}
else{c[p]=v;}}}
return c;};Ext.override(Ext.form.TextArea,{getSelection:function()
{var domElement=this.getEl().dom;if(Ext.isIE)
{var sel=document.selection;var range=sel.createRange();if(range.parentElement()!=domElement)
{return null;}
var bookmark=range.getBookmark();var selection=domElement.createTextRange();selection.moveToBookmark(bookmark);var before=domElement.createTextRange();before.collapse(true);before.setEndPoint("EndToStart",selection);var after=domElement.createTextRange();after.setEndPoint("StartToEnd",selection);return{selectionStart:before.text.length,selectionEnd:before.text.length+selection.text.length,beforeText:before.text,text:selection.text,afterText:after.text}}
else
{if(domElement.selectionEnd&&domElement.selectionStart)
{if(domElement.selectionEnd>domElement.selectionStart)
{return{selectionStart:domElement.selectionStart,selectionEnd:domElement.selectionEnd,beforeText:domElement.value.substr(0,domElement.selectionStart),text:domElement.value.substr(domElement.selectionStart,domElement.selectionEnd-domElement.selectionStart),afterText:domElement.value.substr(domElement.selectionEnd)};}}}
return null;},insertAtCursor:function(v)
{if(Ext.isIE)
{this.el.focus();var sel=document.selection.createRange();sel.text=v;sel.moveEnd('character',v.length);sel.moveStart('character',v.length);}
else
{var startPos=this.el.dom.selectionStart;var endPos=this.el.dom.selectionEnd;this.el.dom.value=this.el.dom.value.substring(0,startPos)+v+this.el.dom.value.substring(endPos,this.el.dom.value.length);this.el.focus();this.el.dom.setSelectionRange(endPos+v.length,endPos+v.length);}}});;Ext.apply(Ext.form.VTypes,{an:function(val,field)
{var regEx=/^([A-Za-z0-9\s!"#%&',-/:;=@_`~\$\(\)\*\+\.\<\>\?\\\^\{\}\|])*$/;return regEx.test(val);},anText:"Character Set:\nLetters, upper and lower case A to Z, a to z\nNumerals Ø to 9\nSymbols ! \" # $ % & ' ( ) * + , - . / : ; < = > ? @ [ \ ] ^ _ ` { | } ~",date:function(val,field)
{return(/(^([0-1][0-9])[\/.:]?([0-3][0-9])?[\/.:]?([0-9]{4})$)|(^$)/).test(val);},dateText:'Not a valid date.  Must be in the format "MM/DD/YYYY".',Email:function(v){return(/(^[A-Za-z0-9._%+\-]+@[A-Za-z0-9.\-]+\.[A-Za-z]{2,4}$)|(^$)/).test(v);},EmailText:'Emails must be in the format <span class="bold">example@email.com or blank',paragraph:function(v){return(/(^[A-Za-z0-9\.,:!\?\s\'\"\(\)\[\]\-]*$)/).test(v);},paragraphText:'Only letters, numbers, and general punction (. , : ! ?) allowed.',password1:function(val,field,form)
{var value=field.findParentByType('form').getForm().getValues();return value.newPassword==val;},password1Text:'Passwords do not match',password2:function(val,field)
{return(strlen(val)>=6||strlen(val)==0);},password2Text:'Password can not match User ID and must be at least 6 characters',numeric:function(val,field)
{return(/^([0-9])*$/).test(val);},numericText:'Can only contain digits',phone:function(val,field)
{var regEx=/^([\(\s]?[0-9]{3}\)?\s?[0-9]{3}-?[0-9]{4})(\s?[xX][0-9]{0,6})?$/;return regEx.test(val);},phoneText:'Phone numbers should be in the format 111 222-2222 X123456 where 111 is the area code and X123456 is the optional extension',posint:function(val,field)
{var regEx=/^([1-9]){1}([0-9])*$/;return regEx.test(val);},posintText:'Value must be an integer greater than 0',rxRefill:function(val,field)
{var regEx=/^([0-9]|As Needed)*$/;return regEx.test(val);},rxRefillText:'Value must either be an integer or "As Needed"',state:function(val,field)
{var regEx=/^[A-Za-z]{2}$/;return regEx.test(val);},stateText:'Use your state postal code (AZ, AR, AK, etc.)',zipcode:function(val,field)
{var regEx=/^[0-9]{5}(-?\s?[0-9]{4})?$/;return regEx.test(val);},zipcodeText:'Zip Codes should either be in 12345 or 12345-1234 format'});
