/*
 * Zipwhip Web 2.0 Messaging Product 1.0.
 * Copyright(c) 2008, Zipwhip.
 * 
 * 
 * This product is not currently available for public release. Only Zipwhip employees and authorized Carriers, and their customers are permitted to access this product during the authorized beta.
 */


Zw={capabilities:{mouseEventsCss:true},namespace:function(){for(var i=0;i<arguments.length;i++){var arg=arguments[i];if(Ext.type(arg)!='string')
continue;var parts=arg.split('.');if(!Ext.isArray(parts))
continue;var p="";for(var j=0;j<parts.length;j++){p+=parts[j];Ext.namespace(p);p+='.';}}}};Zw.Application=Ext.extend(Object,{m_window:null,m_MediaWindow:null,init:function(){this.windows=new Ext.util.MixedCollection();this.attachToZButton();this.desktop=new Zw.Desktop();this.desktop.init();delete Zw.Desktop;},attachToZButton:function(){var el=Ext.get('z-button');el.addClassOnOver('x-btn-over');el.addClassOnClick('x-btn-click');el.on('click',this.onZButtonClick,this);},onZButtonClick:function(){this.showZMenu();},showZMenu:function(){if(!this.menu){this.menu=new Zw.controls.FloatingPanel({cls:"x-menu z-zw-dropdown zw-dropdown z",height:155,autoWidth:true,allowOtherMenus:true,hidden:false,frame:false,border:false,bodyStyle:'',preventContextMenu:true,defaults:{xtype:'Zw.controls.WindowToolbarButtonGroup',cls:'zw-windowtbar-btn-group zw-windowtbar-btn-group-tall',columns:2,rows:2,scale:'tall',defaults:{xtype:'Zw.controls.WindowToolbarButton',scope:this,handler:this.dropdownHandler,iconAlign:'left',scale:'smallish'}},items:[{clsAddl:'zw-windowtbar-corporate',items:[{text:'About',code:'about',iconCls:'corp-about'},{text:'Contact',code:'contact',iconCls:'corp-contact'},{text:'Biz Dev',code:'bizdev',iconCls:'corp-bizdev'},{text:'Jobs',code:'jobs',iconCls:'corp-jobs'}]},{clsAddl:'zw-windowtbar-application',items:[{text:'Beta',code:'beta',iconCls:'corp-beta'},{text:'Media',code:'media',iconCls:'corp-media'},{text:'Tell a Friend',iconCls:'corp-tellafriend',code:'tellafriend',colspan:2}]}]});var bl=Ext.get('z-button').getAnchorXY('bl');bl[1]-=3;bl[0]-=8;this.menu.showAt(bl);this.menu.on('hide',this.onMenuHide,this);}else{this.menu.hide();}},dropdownHandler:function(sender){if(this.menu)
this.menu.hide();var code=sender.code;switch(code){case'beta':this.showWindow('Zw.features.corp.BetaWindow');break;case'media':this.showWindow('Zw.features.corp.MediaWindow');break;case'tellafriend':this.showWindow('Zw.features.corp.TellAFriendWindow');break;case'jobs':this.showWindow('Zw.features.corp.JobsWindow');break;case'bizdev':this.showWindow('Zw.features.corp.BizDevWindow');break;case'contact':this.showWindow('Zw.features.corp.ContactUsWindow');break;case'about':this.showWindow('Zw.features.corp.CorpAboutWindow');break;}},onMenuHide:function(){if(this.menu)
this.menu.destroy();delete this.menu;},start:function(){this.dropdownHandler({code:'about'});},showWindow:function(xtype){var window=this.windows.key(xtype);if(window){}else{window=this.desktop.register(Ext.ComponentMgr.create({xtype:xtype,autoDestroy:true,closeAction:'destroy',listeners:{scope:this,destroy:function(window){this.windows.remove(window);}}}));this.windows.add(xtype,window);}
window.show();return window;}});Zw.Application=new Zw.Application();Zw.Desktop=Ext.extend(Object,{m_taskbar:null,m_windows:null,init:function(){this.m_windows=[];this.m_taskbar=new Zw.controls.Taskbar({renderTo:'taskbar'});this.m_taskbar.on('windowclose',this.onTaskbarEntryClose,this);this.m_taskbar.on('windowrestore',this.onTaskbarEntryRestore,this);this.m_taskbar.on('windowshow',this.onTaskbarEntryShow,this);this.m_taskbar.on('minimizeall',this.onTaskbarMinimizeAll,this);},onTaskbarMinimizeAll:function(){var foundSomeVisible=false;var visibleList=[];Ext.each(this.m_windows,function(w){if(w.isVisible()){foundSomeVisible=true;visibleList.push(w);}});if(!foundSomeVisible){this.m_taskbar.showAll();}else{this.m_taskbar.suspendLayout();for(var i=0;i<visibleList.length;i++){visibleList[i].minimize();}
this.m_taskbar.resumeLayout(true);}},onTaskbarEntryClose:function(sender,e){var window=e.window;this.m_taskbar.unregister(window);window.close();if(window.closeAction=='destroy'){Ext.destroy(window);}},onTaskbarEntryShow:function(sender,e){var window=e.window;this.m_taskbar.unregister(window);},onTaskbarEntryRestore:function(sender,e){var window=e.window;window.show();},onWindowBeforeShow:function(sender,e){var window=sender;if(window.preventCascade){return;}
var xy=window.el.getCenterXY();var range=30;var offset=10;var L=this.m_windows.length;var offsetXY=[0,0];for(var j=0;j<10;j++){var o=offset*j;offsetXY=[xy[0]+o,xy[1]+o];var conflicts=false;for(var i=0;i<L;i++){var w=this.m_windows[i];if(w==window)
continue;var existingXY=w.getPosition();var x1=existingXY[0];var y1=existingXY[1];var x2=offsetXY[0];var y2=offsetXY[1];var dx=Math.abs(x1-x2);var dy=Math.abs(y1-y2);var distance=Math.sqrt(dx*dx+dy*dy);if(distance<range){conflicts=true
break;}else{}}
if(!conflicts){break;}}
window.setPagePosition(offsetXY[0],offsetXY[1]);},onWindowDestroy:function(window){this.unregisterWindow(window);},register:function(window){window.on('minimize',this.onWindowMinimize,this);this.m_windows.push(window);return window;},onWindowMinimize:function(window){window.hide();this.m_taskbar.register(window);}});

Ext.BLANK_IMAGE_URL='//beta.zipwhip.com/js/ext/ext-2.1/resources/images/default/s.gif';Zw.namespace('Zw.util');Zw.namespace('Zw.data');Ext.apply(Zw.util,{createToStoreForDropdown:function(to){var toStore=new Ext.data.Store();toStore.add=Zw.data.ClonedStore.add;if(to&&Ext.isArray(to)&&to.length>0&&to[0]){toStore.add(to);}
return toStore;},getUrlVars:function(){var vars=[],hash;var hashes=window.location.href.slice(window.location.href.indexOf('?')+1).split('&');for(var i=0;i<hashes.length;i++)
{hash=hashes[i].split('=');vars.push(hash[0]);vars[hash[0]]=hash[1];}
return vars;},applyAddPlugin:function(clazz){clazz.prototype.addPlugin=this._addPlugin;clazz.prototype._addPlugin=this._addPlugin;},_addPlugin:function(p){if(!p)return;var t=Ext.type(p);if(t=='array'){Ext.each(p,this._addPlugin,this);return;}else if(t=='string'){}else if(p.xtype){p=Ext.ComponentMgr.create(p,p.xtype);}
if(this.initialized||this.initialConfig){p.init(this);}else{this.plugins=this.plugins||[];this.plugins.push(p);}
return p;},executeCallback:function(args,params){if(args){if(args.callback){if(!params)params=[];if(!Ext.isArray(params))params=[params];args.callback.apply(args.scope||this,params);}}},msgCt:null,isValidForGroupMembership:function(contact){if(!contact)return;return!this.isZipgroupContact(contact);},getFullName:function(contact){var firstName=Zw.data.get(contact,'firstName');var lastName=Zw.data.get(contact,'lastName');if(!firstName&&!lastName){return'Unnamed';}else{if(!firstName)return lastName;if(!lastName)return firstName;return firstName+' '+lastName;}},destroyPlugins:function(item){Ext.each(item.plugins,function(p){if(p.destroy)
p.destroy();});},resolveType:function(t){if(Ext.type(t)=='string'){var ts=t.split('.');var L=ts.length;var obj=window;for(var i=0;i<L;i++){var t=obj[ts[i]];if(t){obj=t;}else{return null;}}
return obj;}else{return t;}},create3PartBox:function(t,s){return['<div class="riser">','<div class="x-box-t"></div>','<div class="x-box-m"><h3>',t,'</h3>',s,'</div>','<div class="x-box-b"></div>','</div>'].join('');},convertMinutesToValue:function(minutes){if(minutes==0){return 0;}else if(minutes==0.5){return 1;}else if(minutes==1){return 2;}else if(minutes==5){return 3;}else if(minutes==15){return 4;}else if(minutes==30){return 5;}else if(minutes==60){return 6;}},isZipgroupAddress:function(address){if(address){var addressObject=new Zw.util.Address({value:address});return addressObject&&(addressObject.scheme==='device')&&(addressObject.query!=='0');}else{return false;}},isZipgroupContact:function(contact){return contact&&(contact.id!=-1)&&Zw.util.isZipgroupAddress(Zw.data.get(contact,'address'));},isAdhocGroupAddress:function(address){return address&&(address.indexOf(',')!==-1);},isAdhocGroupContact:function(contact){return contact&&(contact.id!=-1)&&Zw.util.isAdhocGroupAddress(Zw.data.get(contact,'address'));},isMembershipMessage:function(message,websiteDeviceId){var deviceId=Zw.data.get(message,'fromDeviceId');return this.isMembershipContact(deviceId,websiteDeviceId);},isMembershipContact:function(contactDeviceId,websiteDeviceId){if(contactDeviceId==-1)return false;if(contactDeviceId&&websiteDeviceId){return(contactDeviceId!=websiteDeviceId);}
return false},convertSliderToMinutes:function(sliderValue){var i=0;switch(sliderValue){case 0:i=0;break;case 1:i=.5;break;case 2:i=1;break;case 3:i=5;break;case 4:i=15;break;case 5:i=30;break;default:i=60;break;}
return i;},formatMinutes:function(mins,abbreviate){if(mins==0){return'Instantly';}
if(mins==1){return abbreviate?'1 min':'1 minute'}else if(mins<1){mins=mins*60;if(mins==1)
return mins+(abbreviate?' sec':' second');else
return mins+(abbreviate?' secs':' seconds');}else if(mins>1){return mins+(abbreviate?' mins':' minutes');}},formatThread:function(thread){if(Ext.isEmpty(thread))
return'-';if(thread.length&&thread.length<8){return thread;}
else{var ar=/\D*(\d\d\d)\D*(\d\d\d)\D*(\d\d)\D*/.exec(thread);if(ar){return String.format("{0}-{1}-{2}",ar[1],ar[2],ar[3]);}else{return thread;}}},returnTrue:function(){return true;},returnFalse:function(){return false;},returnThis:function(){return this;},returnScope:function(scope){return Zw.util.returnThis.createDelegate(scope);},trace:function(){try{if(Zw){if(Zw.Application||Zw.debug){if(Zw.Application.debug||Zw.debug){if(window&&window.console){if(console&&console.trace){console.trace();}}}}}}catch(ex){}},log:function(obj){try{if((Zw&&Zw.Application&&Zw.Application.debug)||Zw.debug){if(window&&window.console){console.log.apply(console,arguments);}else if(Ext.isAir&&window.runtime){runtime.trace.apply(runtime,Array.prototype.slice.call(arguments,0));}}}catch(ex){}},dynamicGetValue:Zw.data.get=function(obj,field,defaultValue){var result;if(obj&&field){if(Ext.type(obj.get)==='function'){result=obj.get(field);}else{result=obj[field];}}
return(result===undefined)?defaultValue:result;},getBrowserSize:function(){var myWidth=0,myHeight=0;myWidth=Ext.lib.Dom.getViewWidth(true);myHeight=Ext.lib.Dom.getViewHeight(true);return{width:myWidth,height:myHeight};},getUrl:function(arg){return Zw.Application.Net.baseUrl+arg;},getTemplate:function(tpl,compile){var result=tpl;if(Ext.type(tpl)=='string')
result=new Ext.XTemplate(tpl);else if(Ext.type(tpl)=='array')
result=new Ext.XTemplate(tpl);else
result=tpl;if(compile)
result.compile();return result;},createRandomString:function(){var chars="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";var string_length=8;var randomstring='';for(var i=0;i<string_length;i++){var rnum=Math.floor(Math.random()*chars.length);randomstring+=chars.substring(rnum,rnum+1);}
return randomstring;},formatMobileNum:function(rawMobileNum){if(rawMobileNum)
return Zw.util.MobileNumberFormatterPlugin.getInstance().display(rawMobileNum);else
return null;},msg:function(title,format,pause){if(!this.msgCt){this.msgCt=Ext.get('msg-div');if(!this.msgCt)
this.msgCt=Ext.DomHelper.insertFirst(document.body,{id:'msg-div'},true);}
title=title||'no title';format=format||'no format';var s=String.format.apply(String,Array.prototype.slice.call(arguments,1));var m=Ext.DomHelper.append(this.msgCt,{html:this.create3PartBox(title,s)},true);var p=2;if(pause>0)p=pause;m.fadeIn({duration:.5}).pause(p).ghost("t",{remove:true});return m;},createBox:function(title,format,pause){return['<div class="msg">','<div class="x-box-tl"><div class="x-box-tr"><div class="x-box-tc"></div></div></div>','<div class="x-box-ml"><div class="x-box-mr"><div class="x-box-mc"><h3>',t,'</h3>',s,'</div></div></div>','<div class="x-box-bl"><div class="x-box-br"><div class="x-box-bc"></div></div></div>','</div>'].join('');},init:function(){Ext.QuickTips.init();}});Zw.util.Clone=function(o){if(!o||'object'!==typeof o){return o;}
var c='function'===typeof o.pop?[]:{};var p,v;for(p in o){if(o.hasOwnProperty(p)){v=o[p];if(v&&'object'===typeof v){c[p]=Zw.util.Clone(v);}
else{c[p]=v;}}}
return c;};Zw.util.setCaretTo=function setCaretTo(obj,pos){try{if(obj.createTextRange){var range=obj.createTextRange();range.move("character",pos);range.select();}else if(obj.selectionStart||(obj.selectionStart===0)){obj.focus();obj.setSelectionRange(pos,pos);}}catch(ex){Zw.console('found exception in setCaretTo');Zw.trace();}}
Zw.util.shortBogusMarkup='<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed metus nibh, sodales a, porta at, vulputate eget, dui. Pellentesque ut nisl. Maecenas tortor turpis, interdum non, sodales non, iaculis ac, lacus. Vestibulum auctor, tortor quis iaculis malesuada, libero lectus bibendum purus, sit amet tincidunt quam turpis vel lacus. In pellentesque nisl non sem. Suspendisse nunc sem, pretium eget, cursus a, fringilla vel, urna.';Zw.util.bogusMarkup='<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed metus nibh, sodales a, porta at, vulputate eget, dui. Pellentesque ut nisl. Maecenas tortor turpis, interdum non, sodales non, iaculis ac, lacus. Vestibulum auctor, tortor quis iaculis malesuada, libero lectus bibendum purus, sit amet tincidunt quam turpis vel lacus. In pellentesque nisl non sem. Suspendisse nunc sem, pretium eget, cursus a, fringilla vel, urna.<br/><br/>Aliquam commodo ullamcorper erat. Nullam vel justo in neque porttitor laoreet. Aenean lacus dui, consequat eu, adipiscing eget, nonummy non, nisi. Morbi nunc est, dignissim non, ornare sed, luctus eu, massa. Vivamus eget quam. Vivamus tincidunt diam nec urna. Curabitur velit.</p>';var Cookies={set:function(name,value){var argv=arguments;var argc=arguments.length;var expires=(argc>2)?argv[2]:null;var path=(argc>3)?argv[3]:'/';var domain=(argc>4)?argv[4]:null;var secure=(argc>5)?argv[5]:false;document.cookie=name+"="+escape(value)+
((expires==null)?"":("; expires="+expires.toGMTString()))+
((path==null)?"":("; path="+path))+
((domain==null)?"":("; domain="+domain))+
((secure==true)?"; secure":"");},get:function(name){var arg=name+"=";var alen=arg.length;var clen=document.cookie.length;var i=0;var j=0;while(i<clen){j=i+alen;if(document.cookie.substring(i,j)==arg)
return Cookies.getCookieVal(j);i=document.cookie.indexOf(" ",i)+1;if(i==0)
break;}
return null;},clear:function(name){if(Cookies.get(name)){document.cookie=name+"="+"; expires=Thu, 01-Jan-70 00:00:01 GMT";}},getCookieVal:function(offset){var endstr=document.cookie.indexOf(";",offset);if(endstr==-1){endstr=document.cookie.length;}
return unescape(document.cookie.substring(offset,endstr));}};Zw.util.markDiffs=function(oldTokens,newTokens){var newTokensLength=newTokens.length;newTokens.startPos=0;newTokens.endPos=newTokensLength-1;if(Ext.isEmpty(oldTokens))
return newTokens;var oldTokensLength=oldTokens.length;var L=Math.min(oldTokensLength,newTokensLength);var k=0;var diff=false;for(var i=0;i<L;i++){k=i;if(newTokens[i].value!=oldTokens[i].value){diff=true;break;}
newTokens[i].same=true;}
if(!diff){return;}
newTokens.startPos=k;newTokens.endPos=newTokensLength-1;for(var m=1;m<(L-k);m++){var N=newTokens[newTokensLength-m].value;var O=oldTokens[oldTokensLength-m].value;if(N!=O){break;}
newTokens.endPos=newTokensLength-1-m;newTokens[newTokensLength-m].same=true;}}
Zw.util.detokenize=function(tokens){var L=tokens.length;var result=[];var S=L-1;for(var i=0;i<L;i++){var t=tokens[i];if(t){if(t.value){var val=t.value;if(t.newLine==true){val='\n'+val;}
if(i!=S){val=val+' ';}
result.push(val);}}}
return result.join('');}
Zw.util.tokenizeString=function(string){var tokens=[];var items=string.split(' ');var len=items.length;var pos=0;for(var i=0;i<len;i++){var item=items[i];var length=item.length;if(item==''){if(tokens.length==0){tokens.push({value:'',isSpace:true,pos:pos,len:1});}else{var t=tokens[tokens.length-1];t.value+=' ';t.len+=1;}}else if(item.indexOf('\n')==-1)
tokens.push({value:item,pos:pos,len:length});else{var crs=item.split('\n');var L=crs.length;tokens.push({value:crs[0],pos:pos,len:crs[0].length});for(var j=1;j<L;j++){var c=crs[j];tokens.push({value:c,newLine:true,pos:pos,len:length});}}
pos+=length+1;}
return tokens;}
Zw.util.highlightText=function(content,filter,el){if(Ext.isEmpty(filter))
return content;var result=content;var L=filter.length;if(content.substring(0,L).toLowerCase()==filter.toLowerCase()){result='<span class="highlight">'+content.substring(0,L)+'</span>'+content.substring(L);}
if(el)
el.update(result);return result;}
Zw.util.AlphabetTree=function(){this.root=[];this.root.words=[];this.add=function(replacement,source,startLen,endLen){var minimum=startLen;var maximum=endLen;var selector=source;var word=replacement;var node=this.root;for(var i=selector.length-1;i>-1;i--){var letter=selector.charAt(i).toLowerCase();var child=this.root[letter];if(!child){child=this.root[letter]=[];child.words=[];}
node=node[letter]=child;}
node.words[node.words.length]={len:minimum,value:word,source:selector};}
this._search=function(word,tokenStart,tokenEnd){var reversedWord=word.split('').reverse();var node=this.root;var length=0;var result=[];for(var i=0;i<reversedWord.length;i++){var letter=reversedWord[i];var child=node[letter];if(child){var childValues=child.words;if(childValues){for(var j=0;j<childValues.length;j++){var item=childValues[j];if(item.len<=length){var search=item.source.substring(0,length+1);if(search.toLowerCase()==word)
result.push(Ext.apply(item,{start:tokenEnd,end:tokenStart}));}}}
node=child;}else{return[];}
length++;}
return result;};this.search=function(tokens,offset){offset=offset||0;var results=[];var word='';var length=0;var tokenStart=tokens.length-1;for(var i=tokenStart;i>=0;i--){var token=tokens[i];var item=token.value;if(word=='')
word+=item;else
word=item+' '+word;var result=this._search(word,offset+tokenStart,offset+i);if(result.length>0)
results=results.concat(result);length++;}
return results;}};Zw.util.createFakeFwdThread=function(thread){if(!(Ext.isEmpty(thread))){return String.format('{0}-001-{1}',thread.substring(0,thread.length-5),thread.substring(thread.length-2))}}
Zw.util.formatName=function(firstName,lastName,format){var f=format||'';f=f.toLowerCase();var result='';lastName=lastName?lastName:'';firstName=firstName?firstName:'';if(f=='full'){result=firstName;if(firstName.length&&lastName.length){result+=' ';}
if(lastName.length){result+=lastName;}}else if(f=='first')
result=String.format('{0}',firstName);else if(f=='last')
result=String.format('{0}',lastName);else if(f=='lastinitial'){if(lastName.length>1){result=String.format('{0} {1}',firstName,lastName.substring(0,1));}else{result=firstName;}}else if(f=='firstinitial')
if(firstName.length>1){result=String.format('{0} {1}',firstName.substring(0,1),lastName);}else{result=lastName;}
else if(f=='initials')
if(firstName.length>1&&lastName.length>1){result=String.format('{0}{1}',firstName.substring(0,1),lastName.substring(0,1));}else{if(firstName.length>1)
result=String.format('{0}',firstName.substring(0,1));else
result=String.format('{0}',firstName);}
else if(f=='off')
return'';else if(f=='custom')
return'';else
return format;return result;};Zw.util.tokenizePhoneNumbers=function(value){var items=value.split(/[\;\,]/);var L=items.length;var results=[];for(var i=0;i<L;i++){var test=items[i];if(Ext.isEmpty(test))
continue;var matches;if(test.indexOf('+61')!=-1){matches=/^[^\+]*(\+\d\D*\d\D*\d\D*\d\D*\d\D*\d\D*\d\D*\d\D*\d\D*\d\D*\d)(\s*.*)$/.exec(test);}else{matches=/^\D*\+*1*\D*(\d\D*\d\D*\d\D*\d\D*\d\D*\d\D*\d\D*\d\D*\d\D*\d)(\s*.*)$/.exec(test);}
if(!matches){results.push({original:test})}else{Zw.console(matches);var number=Zw.util.getRawPhoneNumber(matches[1]);var name=matches[2];results.push({original:test,name:name,number:number});}}
return results;}
Zw.util.getRawPhoneNumber=function(value){var phoneNumberDelimiters='()-. '
var validWorldPhoneChars=phoneNumberDelimiters+'+';if(!Ext.isEmpty(value))
value=value.replace(/^1*/,'');var cleanedNumber=Zw.util.stripCharsInBag(value,validWorldPhoneChars);return(value.indexOf('+')==0)?'+'+cleanedNumber:cleanedNumber;}
Zw.util.stripCharsInBag=function(s,bag){if(!s)
return s;var returnString=''
for(var i=0;i<s.length;i++)
{var c=s.charAt(i);if(bag.indexOf(c)==-1)returnString+=c;}
return returnString;}
Zw.util.phoneNumberValidator=function(value){var result=Zw.util.isPhoneNumber(value);return result?true:'Please enter your valid US Mobile Number.';}
Zw.util.isPhoneNumber=function(value){if(value=='')return false;var digits='0123456789';var phoneNumberDelimiters='()-. ';var validWorldPhoneChars=phoneNumberDelimiters+'+';if(!Ext.isEmpty(value))
value=value.replace(/^1*/,'');function isInteger(s)
{if(Ext.isEmpty(s))return false;for(var i=0;i<s.length;i++)
{var c=s.charAt(i);if(((c<'0')||(c>'9')))return false;}
return true;}
function checkInternationalPhone(strPhone){s=Zw.util.stripCharsInBag(strPhone,validWorldPhoneChars);return(isInteger(s)&&s.length==Zw.util.MobileNumberFormatterPlugin.getInstance().getFormatNumberLength(strPhone));}
return checkInternationalPhone(value);}
Zw.util.compositeMessageContent=function(message){var body=Zw.data.get(message,'body').replace(/\n/g,'<br>')
var fromName=Zw.data.get(message,'fromName');return(fromName?(fromName+':'):(''))+body;}
Zw.util.formatPartialMobileNum=function(value){if(!value)return;value=Zw.util.getRawPhoneNumber(value);var result='(';for(var i=0;i<value.length;i++){var c=value.charAt(i);if(i==0)
result='(';else if(i==3)
result+=') ';else if(i==6)
result+='-';result+=c;}
return result;}
Ext.Element.prototype.onDoubleClick=function(fcn,scope){scope=scope||this;this.on('dblclick',fcn,scope);}
function UUID(){this.id=this.createUUID();}
UUID.prototype.valueOf=function(){return this.id;}
UUID.prototype.toString=function(){return this.id;}
UUID.prototype.createUUID=function(){var dg=new Date(1582,10,15,0,0,0,0);var dc=new Date();var t=dc.getTime()-dg.getTime();var h='-';var tl=UUID.getIntegerBits(t,0,31);var tm=UUID.getIntegerBits(t,32,47);var thv=UUID.getIntegerBits(t,48,59)+'1';var csar=UUID.getIntegerBits(UUID.rand(4095),0,7);var csl=UUID.getIntegerBits(UUID.rand(4095),0,7);var n=UUID.getIntegerBits(UUID.rand(8191),0,7)+
UUID.getIntegerBits(UUID.rand(8191),8,15)+
UUID.getIntegerBits(UUID.rand(8191),0,7)+
UUID.getIntegerBits(UUID.rand(8191),8,15)+
UUID.getIntegerBits(UUID.rand(8191),0,15);return tl+h+tm+h+thv+h+csar+csl+h+n;}
UUID.getIntegerBits=function(val,start,end){var base16=UUID.returnBase(val,16);var quadArray=new Array();var quadString='';var i=0;for(i=0;i<base16.length;i++){quadArray.push(base16.substring(i,i+1));}
for(i=Math.floor(start/4);i<=Math.floor(end/4);i++){if(!quadArray[i]||quadArray[i]=='')quadString+='0';else quadString+=quadArray[i];}
return quadString;}
UUID.returnBase=function(number,base){var convert=['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];if(number<base)var output=convert[number];else{var MSD=''+Math.floor(number/base);var LSD=number-MSD*base;if(MSD>=base)var output=this.returnBase(MSD,base)+convert[LSD];else var output=convert[MSD]+convert[LSD];}
return output;}
UUID.rand=function(max){return Math.floor(Math.random()*max);}
Zw.console=Zw.util.log;Zw.trace=Zw.util.trace;Zw.util.formatMobileNumber=Zw.util.formatMobileNum;Zw.util.formatPartialMobileNumber=Zw.util.formatPartialMobileNum;Ext.apply(Ext.form.VTypes,{phoneNumber:Zw.util.phoneNumberValidator});Zw.util.getNameParts=function(name){var regex=/(.*) (.*)/;name=name||'';name=name.trim();var matches=regex.test(name);var result={firstName:name,lastName:''};if(matches){var parts=regex.exec(name);result.firstName=parts[1].trim();result.lastName=parts[2].trim();}
return result;}
Zw.util.preventSpellcheck=function(c){var el=null;if(c.getEl){el=c.getEl();if(!el){if(c.on){c.on('render',function(){var el=c.getEl();if(el)
Zw.util.preventSpellcheck(el);},this,{single:true});return true;}
return false;}else{el.dom.spellcheck=false;return true;}}else{if(c.dom){c.dom.spellcheck=false;return true;}}
c.dom.spellcheck=false;return true;}
Zw.util.forceRepaint=function(el,delay){var fooClass='foobar';if(delay){delay=(typeof delay==='number')?delay:10;setTimeout(function(){el.addClass(fooClass);el.removeClass(fooClass);},delay);}else{el.addClass(fooClass);el.removeClass(fooClass);}};Zw.util.stripHTML=function(html){return html.replace(/<\w+(\s+("[^"]*"|'[^']*'|[^>])+)?>|<\/\w+>/gi,'').replace('&nbsp;',' ');};Zw.util.ContactsProxy=Ext.data.HttpProxy;Zw.util.applyAddPlugin(Ext.BoxComponent);Zw.preventContactsSort=Zw.util.getUrlVars()['preventContactsSort'];

Zw.namespace('Zw.controls');Zw.controls.Div=Ext.extend(Ext.Container,{cls:'zw-div',styleX:'',tooltip:'',addMouseClasses:false,initEvents:Ext.emptyFn,layout:'auto',initComponent:function(){this.onBeforeInit();Zw.controls.Div.superclass.initComponent.call(this);if(this.delayedItems)
this.items=this.delayedItems;delete this.delayedItems;this.onAfterInit();},onBeforeInit:Ext.emptyFn,onAfterInit:Ext.emptyFn,beforeDestroy:function(){Ext.destroy(this.el);Zw.controls.Div.superclass.beforeDestroy.call(this);},onRender:function(ct,position){Zw.controls.Div.superclass.onRender.call(this,ct,position);this.fixHtml();if(this.tpl){if(Ext.type(this.tpl)=='string'){this.tpl=new Ext.XTemplate(this.tpl);this.tpl.compile();}}else{if(Ext.type(Zw.controls.Div.tpl)=='string'){Zw.controls.Div.tpl=new Ext.XTemplate(Zw.controls.Div.tpl);Zw.controls.Div.tpl.compile();}
this.tpl=Zw.controls.Div.tpl;}
if(!this.el){if(position){this.el=this.tpl.insertBefore(position,this,true);}else{this.el=this.tpl.append(ct,this,true);}
this.initDiv(this.el);this.el.id=this.getId();if(this.forId){this.el.setAttribute('htmlFor',this.forId);}}
if(this.addMouseClasses){var e=Ext.fly(this.el);e.addClassOnOver('mo');e.addClassOnFocus('mf');e.addClassOnClick('md');if(this.baseMouseCls){e.addClassOnOver(this.baseMouseCls+'-mo');e.addClassOnFocus(this.baseMouseCls+'-mf');e.addClassOnClick(this.baseMouseCls+'-md');}}
var e=Ext.get(this.el);if(this.handler||this.addMouseEvents||this.listenClick||this.enableMouseEvents||this.onClick){e.on('click',this.onClick,this);}
if(this.addMouseEvents||this.enableMouseEvents){e.on('mouseover',this.onMouseOver,this);e.on('mousedown',this.onMouseDown,this);e.on('mouseup',this.onMouseUp,this);e.on('mouseout',this.onMouseOut,this);}
if(this.tooltip&&this.tooltip!=''){this.tooltipEl=new Ext.ToolTip({target:this.el,dismissDelay:0,mouseOffset:[1,10],html:this.tooltip});}
this.initEvents();},initDiv:Ext.emptyFn,fixHtml:function(){if(!this.preventIEHack){if(Ext.isIE){if(this.items){if(this.html){this.html='<span></span>'+this.html;}}}}
return this.html;},onMouseDown:function(sender,e){this.fireEvent('mousedown',this,e,sender);},onMouseOver:function(sender,e){this.fireEvent('mouseover',this,e,sender);},onMouseUp:function(sender,e){this.fireEvent('mouseup',this,e,sender);},onMouseOut:function(sender,e){this.fireEvent('mouseout',this,e,sender);},onClick:function(sender,e){if(this.handler)
this.handler.call(this.scope||this,sender,e);this.fireEvent('click',this,e,sender);},onRenderCustomTemplate:Ext.emptyFn,close:function(){this.destroy();}});Zw.controls.Div.tpl='<div class="{cls} {clsX}" style="{styleX} {style}">{html}</div>';Ext.reg('Zw.controls.Div',Zw.controls.Div);Ext.reg('div',Zw.controls.Div);Zw.controls.Link=Ext.extend(Zw.controls.Div,{href:'#',tpl:'<a class="{cls} {clsX}" style="{styleX} {style}" href="{href}">{html}</a>',listenClick:true});Ext.reg('link',Zw.controls.Link);Ext.reg('Zw.controls.Link',Zw.controls.Link);Zw.controls.Span=Ext.extend(Zw.controls.Div,{tpl:'<span class="{cls} {clsX}" style="{styleX} {style}">{html}</span>'});Ext.reg('span',Zw.controls.Span);Ext.reg('Zw.controls.Span',Zw.controls.Span);

Zw.namespace('Zw.controls');Zw.controls.Taskbar=Ext.extend(Zw.controls.Div,{preventLayout:false,defaultType:'Zw.controls.TaskbarEntry',cls:'context-taskbar',tpl:'<div><div class="minimize-all"></div></div>',initComponent:function(){Zw.controls.Taskbar.superclass.initComponent.call(this);this.addEvents({'windowrestore':true,'windowclose':true});},hide:function(){this.el.fadeOut({callback:Zw.controls.Taskbar.superclass.hide,scope:this});},initDiv:function(el){this.els={};this.els.minimize=el.child('.minimize-all');this.els.minimize.addClassOnOver('minimize-all-mo');this.els.minimize.addClassOnClick('minimize-all-md');this.els.minimize.on('click',this.minimizeAll,this);},suspendLayout:function(){this.preventLayout=true;},resumeLayout:function(doLayout){this.preventLayout=false;if(doLayout)this.doLayout();},minimizeAll:function(){this.fireEvent('toggleAll',this);},showAll:function(){this.fireEvent('showAll',this);},register:function(win,preventLayout){var entry=this.add({text:win.title,windowCls:win.cls,closable:win.closable});entry.__window=win;win.__entry=entry;win.on('show',this.onWindowShow,this);entry.on('restore',this.onEntryRestore,this);entry.on('close',this.onEntryClose,this);if(!preventLayout&&!this.preventLayout){this.doLayout();}},unregister:function(win,preventLayout){var entry=win.__entry;delete win.__entry;delete entry.__window;this.remove(entry);win.un('show',this.onWindowShow,this);Ext.destroy(entry);if(!preventLayout&&!this.preventLayout){this.doLayout();}},onWindowShow:function(sender,e){this.fireEvent('windowshow',this,{entry:sender.__entry,window:sender});},onEntryClose:function(sender,e){this.fireEvent('windowclose',this,{entry:sender,window:sender.__window});},onEntryRestore:function(sender,e){this.fireEvent('windowrestore',this,{entry:sender,window:sender.__window});}});Zw.controls.TaskbarEntry=Ext.extend(Zw.controls.Div,{cls:'entry',tpl:'<div class="{cls} {windowCls}"><div class="wrap"><div class="body"><div class="icon {iconCls}"></div><span class="text">{text}</span><div class="close"></div></div></div></div>',closable:true,text:'This is example',iconCls:'zw-window-icon',addMouseEvents:true,addMouseClasses:false,initDiv:function(el){this.els={};this.els.close=el.child('.close');this.els.text=el.child('.text');this.els.iconCls=el.child('.icon');this.el.addClassOnOver('entry-mo');this.els.close.addClassOnOver('close-mo');this.els.close.addClassOnClick('close-md');if(!this.closable){this.el.addClass('unclosable');}
this.els.text.unselectable();},_blink:function(){this.el.toggleClass('entry-blink');},blink:function(){if(!this.blinkTaskRunner){this.blinkTaskRunner=new Ext.util.TaskRunner();}
this.blinkTaskRunner.start({run:this._blink,interval:500,scope:this});},onClick:function(e){if(e.getTarget('.close')){this.fireEvent('close',this);}else{this.fireEvent('restore',this);}},onMouseDown:function(e){var target=e.getTarget('.close');if(target){Ext.fly(target).addClass('md');}else{this.el.addClass('md');}},onMouseUp:function(e){var target=e.getTarget('.close');if(target){Ext.fly(target).removeClass('md');}else{this.el.removeClass('md');}},onDestroy:function(){if(this.blinkTaskRunner){this.blinkTaskRunner.stopAll();delete this.blinkTaskRunner;}}});Ext.reg('Zw.controls.TaskbarEntry',Zw.controls.TaskbarEntry);

Zw.namespace('Zw.controls');Zw.controls.StatusBar=Ext.extend(Ext.StatusBar,{ctCls:"zw-statusbar",showResizer:true,afterRender:function(){Zw.controls.StatusBar.superclass.afterRender.call(this);var tpl=new Ext.Template('<td class="zw-window-resizer-td">','<div class="zw-window-resizer-wrap">','<div class="zw-window-resizer-div"/>','</div>','</td>');var trEl=Ext.get(this.tr);var lastTdEl=trEl.child("td:last");this.resizerEl=tpl.insertAfter(lastTdEl,null,true);},garbage:""});Ext.reg('zwStatusBar',Zw.controls.StatusBar);

Ext.namespace("Ext.v3");Ext.v3.Button=Ext.extend(Ext.Component,{hidden:false,disabled:false,pressed:false,enableToggle:false,menuAlign:"tl-bl?",type:'button',menuClassTarget:'tr',clickEvent:'click',handleMouseEvents:true,tooltipType:'qtip',buttonSelector:"button:first",scale:'small',iconAlign:'left',arrowAlign:'right',initComponent:function(){Ext.v3.Button.superclass.initComponent.call(this);this.addEvents("click","toggle",'mouseover','mouseout','menushow','menuhide','menutriggerover','menutriggerout');if(this.menu){this.menu=Ext.menu.MenuMgr.get(this.menu);}
if(typeof this.toggleGroup==='string'){this.enableToggle=true;}},getTemplateArgs:function(){var cls=(this.cls||'');cls+=this.iconCls?(this.text?' x-btn-text-icon':' x-btn-icon'):' x-btn-noicon';if(this.pressed){cls+=' x-btn-pressed';}
return[this.text||'&#160;',this.type,this.iconCls||'',cls,'x-btn-'+this.scale+' x-btn-icon-'+this.scale+'-'+this.iconAlign,this.getMenuClass()];},getMenuClass:function(){return this.menu?(this.arrowAlign!='bottom'?'x-btn-arrow':'x-btn-arrow-bottom'):'';},onRender:function(ct,position){if(!this.template){if(!Ext.v3.Button.buttonTemplate){Ext.v3.Button.buttonTemplate=new Ext.Template('<table cellspacing="0" class="x-btn {3}"><tbody class="{4}">','<tr><td class="x-btn-tl"><i>&#160;</i></td><td class="x-btn-tc"></td><td class="x-btn-tr"><i>&#160;</i></td></tr>','<tr><td class="x-btn-ml"><i>&#160;</i></td><td class="x-btn-mc"><em class="{5}" unselectable="on"><button class="x-btn-text {2}" type="{1}">{0}</button></em></td><td class="x-btn-mr"><i>&#160;</i></td></tr>','<tr><td class="x-btn-bl"><i>&#160;</i></td><td class="x-btn-bc"></td><td class="x-btn-br"><i>&#160;</i></td></tr>',"</tbody></table>");Ext.v3.Button.buttonTemplate.compile();}
this.template=Ext.v3.Button.buttonTemplate;}
var btn,targs=this.getTemplateArgs();if(position){btn=this.template.insertBefore(position,targs,true);}else{btn=this.template.append(ct,targs,true);}
var btnEl=btn.child(this.buttonSelector);btnEl.on('focus',this.onFocus,this);btnEl.on('blur',this.onBlur,this);this.initButtonEl(btn,btnEl);Ext.ButtonToggleMgr.register(this);},initButtonEl:function(btn,btnEl){this.el=btn;if(this.icon){btnEl.setStyle('background-image','url('+this.icon+')');}
if(this.tabIndex!==undefined){btnEl.dom.tabIndex=this.tabIndex;}
if(this.tooltip){if(typeof this.tooltip=='object'){Ext.QuickTips.register(Ext.apply({target:btnEl.id},this.tooltip));}else{btnEl.dom[this.tooltipType]=this.tooltip;}}
if(this.handleMouseEvents){btn.on("mouseover",this.onMouseOver,this);btn.on("mousedown",this.onMouseDown,this);}
if(this.menu){this.menu.on("show",this.onMenuShow,this);this.menu.on("hide",this.onMenuHide,this);}
if(this.id){this.el.dom.id=this.el.id=this.id;}
if(this.repeat){var repeater=new Ext.util.ClickRepeater(btn,typeof this.repeat=="object"?this.repeat:{});repeater.on("click",this.onClick,this);}
btn.on(this.clickEvent,this.onClick,this);},afterRender:function(){Ext.v3.Button.superclass.afterRender.call(this);if(Ext.isIE6){this.autoWidth.defer(1,this);}else{this.autoWidth();}},setIconClass:function(cls){if(this.el){this.el.child(this.buttonSelector).replaceClass(this.iconCls,cls);}
this.iconCls=cls;},beforeDestroy:function(){if(this.rendered){var btn=this.el.child(this.buttonSelector);if(btn){btn.removeAllListeners();}}
if(this.menu){Ext.destroy(this.menu);}},onDestroy:function(){if(this.rendered){Ext.ButtonToggleMgr.unregister(this);}},autoWidth:function(){if(this.el&&this.text){this.el.setWidth("auto");if(Ext.isIE7&&Ext.isStrict){var ib=this.el.child(this.buttonSelector);if(ib&&ib.getWidth()>20){ib.clip();ib.setWidth(Ext.util.TextMetrics.measure(ib,this.text).width+ib.getFrameWidth('lr'));}}
if(this.minWidth){if(this.el.getWidth()<this.minWidth){this.el.setWidth(this.minWidth);}}}},setHandler:function(handler,scope){this.handler=handler;this.scope=scope;},setText:function(text){this.text=text;if(this.el){this.el.child("td.x-btn-mc "+this.buttonSelector).update(text);}
this.autoWidth();},getText:function(){return this.text;},toggle:function(state){state=state===undefined?!this.pressed:state;if(state!=this.pressed){if(state){this.el.addClass("x-btn-pressed");this.pressed=true;this.fireEvent("toggle",this,true);}else{this.el.removeClass("x-btn-pressed");this.pressed=false;this.fireEvent("toggle",this,false);}
if(this.toggleHandler){this.toggleHandler.call(this.scope||this,this,state);}}},focus:function(){this.el.child(this.buttonSelector).focus();},onDisable:function(){if(this.el){if(!Ext.isIE6||!this.text){this.el.addClass(this.disabledClass);}
this.el.dom.disabled=true;}
this.disabled=true;},onEnable:function(){if(this.el){if(!Ext.isIE6||!this.text){this.el.removeClass(this.disabledClass);}
this.el.dom.disabled=false;}
this.disabled=false;},showMenu:function(){if(this.menu){this.menu.show(this.el,this.menuAlign);}
return this;},hideMenu:function(){if(this.menu){this.menu.hide();}
return this;},hasVisibleMenu:function(){return this.menu&&this.menu.isVisible();},onClick:function(e){if(e){e.preventDefault();}
if(e.button!=0){return;}
if(!this.disabled){if(this.enableToggle&&(this.allowDepress!==false||!this.pressed)){this.toggle();}
if(this.menu&&!this.menu.isVisible()&&!this.ignoreNextClick){this.showMenu();}
this.fireEvent("click",this,e);if(this.handler){this.handler.call(this.scope||this,this,e);}}},isMenuTriggerOver:function(e,internal){return this.menu&&!internal;},isMenuTriggerOut:function(e,internal){return this.menu&&!internal;},onMouseOver:function(e){if(!this.disabled){var internal=e.within(this.el,true);if(!internal){this.el.addClass("x-btn-over");if(!this.monitoringMouseOver){Ext.getDoc().on('mouseover',this.monitorMouseOver,this);this.monitoringMouseOver=true;}
this.fireEvent('mouseover',this,e);}
if(this.isMenuTriggerOver(e,internal)){this.fireEvent('menutriggerover',this,this.menu,e);}}},monitorMouseOver:function(e){if(e.target!=this.el.dom&&!e.within(this.el)){if(this.monitoringMouseOver){Ext.getDoc().un('mouseover',this.monitorMouseOver,this);this.monitoringMouseOver=false;}
this.onMouseOut(e);}},onMouseOut:function(e){var internal=e.within(this.el)&&e.target!=this.el.dom;this.el.removeClass("x-btn-over");this.fireEvent('mouseout',this,e);if(this.isMenuTriggerOut(e,internal)){this.fireEvent('menutriggerout',this,this.menu,e);}},onFocus:function(e){if(!this.disabled){this.el.addClass("x-btn-focus");}},onBlur:function(e){this.el.removeClass("x-btn-focus");},getClickEl:function(e,isUp){return this.el;},onMouseDown:function(e){if(!this.disabled&&e.button==0){this.getClickEl(e).addClass("x-btn-click");Ext.getDoc().on('mouseup',this.onMouseUp,this);}},onMouseUp:function(e){if(e.button==0){this.getClickEl(e,true).removeClass("x-btn-click");Ext.getDoc().un('mouseup',this.onMouseUp,this);}},onMenuShow:function(e){this.ignoreNextClick=0;this.el.addClass("x-btn-menu-active");this.fireEvent('menushow',this,this.menu);},onMenuHide:function(e){this.el.removeClass("x-btn-menu-active");this.ignoreNextClick=this.restoreClick.defer(250,this);this.fireEvent('menuhide',this,this.menu);},restoreClick:function(){this.ignoreNextClick=0;}});Ext.reg('button',Ext.Button);Ext.ButtonToggleMgr=function(){var groups={};function toggleGroup(btn,state){if(state){var g=groups[btn.toggleGroup];for(var i=0,l=g.length;i<l;i++){if(g[i]!=btn){g[i].toggle(false);}}}}
return{register:function(btn){if(!btn.toggleGroup){return;}
var g=groups[btn.toggleGroup];if(!g){g=groups[btn.toggleGroup]=[];}
g.push(btn);btn.on("toggle",toggleGroup);},unregister:function(btn){if(!btn.toggleGroup){return;}
var g=groups[btn.toggleGroup];if(g){g.remove(btn);btn.un("toggle",toggleGroup);}},getPressed:function(group){var g=groups[group];if(g){for(var i=0,len=g.length;i<len;i++){if(g[i].pressed===true){return g[i];}}}
return null;}};}();Ext.ButtonGroup=Ext.extend(Ext.Panel,{baseCls:'x-btn-group',layout:'table',defaultType:'button',frame:true,internalDefaults:{removeMode:'container',hideParent:true},initComponent:function(){this.layoutConfig=this.layoutConfig||{};Ext.applyIf(this.layoutConfig,{columns:this.columns});if(!this.title){this.addClass('x-btn-group-notitle');}
this.on('afterlayout',this.onAfterLayout,this);Ext.ButtonGroup.superclass.initComponent.call(this);},applyDefaults:function(c){c=Ext.ButtonGroup.superclass.applyDefaults.call(this,c);var d=this.internalDefaults;if(c.events){Ext.applyIf(c.initialConfig,d);Ext.apply(c,d);}else{Ext.applyIf(c,d);}
return c;},onAfterLayout:function(){var bodyWidth=this.body.getFrameWidth('lr')+this.body.dom.firstChild.offsetWidth;this.body.setWidth(bodyWidth);this.el.setWidth(bodyWidth+this.getFrameWidth());}});Ext.reg('buttongroup',Ext.ButtonGroup);

Ext.namespace('Zw.controls');Zw.controls.Button=Ext.extend(Ext.v3.Button,{handleMouseEvents:Zw.capabilities.mouseEventsCss,genre:Zw.controls.BUTTON_GENRE_WINDOW_TOOLBAR,name:null,getTemplateArgs:function(){var cls=(this.cls||'');cls+=this.iconCls?(this.text?' x-btn-text-icon':' x-btn-icon'):' x-btn-noicon';if(this.pressed){cls+=' x-btn-pressed';}
return[this.text||'&#160;',this.type,this.iconCls||'',cls,'x-btn-'+this.scale+' x-btn-icon-'+this.scale+'-'+this.iconAlign+' '+this.cls+'-wrap',this.getMenuClass()];},initComponent:function(){Zw.controls.Button.superclass.initComponent.call(this);if(!this.name)
this.name=this.text;},onRender:function(ct,pos){if(!this.template){if(!Zw.controls.Button.template){Zw.controls.Button.template=new Ext.Template('<table cellspacing="0" class="x-btn {3}"><tbody class="{4}">','<tr class="x-btn-row">','<td class="x-btn-ml"></td>','<td class="x-btn-mc">','<em class="{5}" unselectable="on">','<button class="x-btn-text {2}" type="{1}">{0}</button>','</em>','</td>','<td class="x-btn-mr"><i>&#160;</i></td>','</tr>',"</tbody></table>");Zw.controls.Button.template.compile();}
this.template=Zw.controls.Button.template;}
Zw.controls.Button.superclass.onRender.call(this,ct,pos);},afterRender:function(){Ext.v3.Button.superclass.afterRender.call(this);this.autoWidth();},garbage:""});Zw.controls.BUTTON_GENRE_TOPTOOLBAR=1;Zw.controls.BUTTON_GENRE_WINDOW_TOOLBAR=2;Zw.controls.BUTTON_GENRE_MENU_RIGHTCLICK=3;Zw.controls.BUTTON_GENRE_SENDMSG_COMPOSE=4;Zw.controls.BUTTON_GENRE_SENDMSG_POSTSEND=5;

Ext.namespace('Zw.controls');Zw.controls.ActionButton=Ext.extend(Ext.Button,{name:null,splitButton:false,splitButtonHandler:undefined,autoWidth:Ext.emptyFn,cls:'zw-action-button',disabledClass:'x-item-disabled zw-action-button-disabled',initComponent:function(){Zw.controls.ActionButton.superclass.initComponent.call(this);if(this.splitButton){this.cls+=' zw-action-button-split';}
if(this.iconCls){this.cls+=' x-btn-text-icon';}
var tpl=null;if(this.splitButton){tpl=this.splitTpl;}else{tpl=this.tpl;}
if(!tpl){tpl=new Ext.Template("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"x-btn-wrap\"><tbody><tr>","<td class=\"x-btn-left\"><i>&#160;</i></td><td class=\"x-btn-center\">","<em unselectable=\"on\" class=\"x-btn-main\"><button class=\"x-btn-text x-btn-main\" type=\"{1}\">{0}</button></em>","<em class=\"x-btn-split\"></em>",(this.splitButton?"<em unselectable=\"on\" class=\"x-btn-side\"><button class=\"x-btn-side\" type=\"button\"></button></em>":""),"</td><td class=\"x-btn-right\"><i>&#160;</i></td>","</tr></tbody></table>");tpl.compile();}
this.template=tpl;if(!this.name)
this.name=this.text;},activateSplitButtonMouseEventsClasses:function(el,baseCls,mo,md){if(mo){el.on('mouseover',function(){el.addClass(baseCls+'-mo');},this);el.on('mouseout',function(){el.removeClass(baseCls+'-mo');},this);}
if(md){el.on('mousedown',function(e){e.stopPropagation();el.addClass(baseCls+'-md');},this);el.on('mouseup',function(e){e.stopPropagation();el.removeClass(baseCls+'-md');},this);}else{el.on('mousedown',function(){el.removeClass(baseCls+'-mo');},this);}},onRender:function(ct,position){Zw.controls.ActionButton.superclass.onRender.call(this,ct,position);if(this.splitButton){var mainButtonWrapper=this.el.child('em.x-btn-main');var sideButtonWrapper=this.el.child('em.x-btn-side');var mainButton=this.el.child('button.x-btn-main');var sideButton=this.el.child('button.x-btn-side');this.activateSplitButtonMouseEventsClasses(mainButtonWrapper,'x-btn-main',true,false);this.activateSplitButtonMouseEventsClasses(sideButtonWrapper,'x-btn-side',true,true);mainButton.addClass('zw-button-icon-send');sideButton.on('click',this.sideButtonClick,this);}
var el=Ext.get(this.el);if(el){el.addClassOnOver('zw-action-button-mo');el.addClassOnFocus('zw-action-button-mf');el.addClassOnClick('zw-action-button-md');}},sideButtonClick:function(e,el){if(this.splitButtonHandler&&!this.disabled){var sideButtonClickArgs=Array.prototype.slice.call(arguments);this.splitButtonHandler.apply((this.scope||this),sideButtonClickArgs);}},onDisable:function(){if(this.el){this.el.addClass(this.disabledClass);this.el.dom.disabled=true;}
this.disabled=true;},onEnable:function(){if(this.el){this.el.removeClass(this.disabledClass);this.el.dom.disabled=false;}
this.disabled=false;},setSize:function(){},getSize:function(){return this.el.getSize();},garbage:""});Ext.reg('Zw.controls.ActionButton',Zw.controls.ActionButton);

Zw.namespace('Zw.controls');Zw.controls.WindowToolbarButton=Ext.extend(Zw.controls.Button,{genre:Zw.controls.BUTTON_GENRE_WINDOW_TOOLBAR,height:40,minWidth:20,cls:"zw-windowtbar-btn",scale:'medium',iconAlign:'top'});Ext.reg('Zw.controls.WindowToolbarButton',Zw.controls.WindowToolbarButton);

Zw.controls.WindowToolbarButtonGroup=Ext.extend(Ext.ButtonGroup,{cls:'zw-windowtbar-btn-group',handler:Ext.emptyFn,initComponent:function(){if(this.clsAddl&&this.clsAddl!='')
this.cls+=" "+this.clsAddl;Zw.controls.WindowToolbarButtonGroup.superclass.initComponent.call(this);},_enableButton:function(item){item.enable();},_disableButton:function(item){item.disable();},enableButton:function(code){Ext.each(this.find('code',code),function(c){c.enable();},this);},disableButton:function(code){Ext.each(this.find('code',code),function(c){c.disable();},this);},enableButtons:function(){this.items.each(this._enableButton,this);},disableButtons:function(){this.items.each(this._disableButton,this);},setDefaults:function(d){this.defaults=Ext.applyIf(this.defaults||{},d);this.defaults=Ext.applyIf(this.defaults,{xtype:"Zw.controls.WindowToolbarButton",handler:this.handler,scope:this.scope||this});},onAfterRender:function(){Zw.controls.WindowToolbarButtonGroup.superclass.onAfterRender.call(this);},garbage:""});Ext.reg('Zw.controls.WindowToolbarButtonGroup',Zw.controls.WindowToolbarButtonGroup);

Zw.namespace('Zw.controls');Zw.controls.FloatingPanel=Ext.extend(Ext.Panel,{frame:true,hidden:true,cls:'x-menu',bodyStyle:'padding: 0; position: relative;',register:true,floating:{shadow:false,shim:true,useDisplay:true,constrain:false},constrainPosition:true,initComponent:function(){Zw.controls.FloatingPanel.superclass.initComponent.call(this);if(this.register){Ext.menu.MenuMgr.register(this);}},onRender:function(ct,pos){Zw.controls.FloatingPanel.superclass.onRender.call(this,ct,pos);if(this.preventContextMenu){this.el.dom.oncontextmenu=function(){return false;};}},showAt:function(xy){if(!this.rendered)
this.render(Ext.getBody());Zw.controls.ContextMenu.superclass.show.call(this);if(this.constrainPosition){xy=this.el.adjustForConstraints(xy);}
this.setPagePosition(xy[0],xy[1]);},showBy:function(el,pos,offset){if(!this.rendered)
this.render(Ext.getBody());var result=this.el.getAlignToXY(el,pos||this.defaultAlign);if(offset){result[0]+=offset[0];result[1]+=offset[1];}
this.showAt(result);}});Zw.controls.ContextMenu=Ext.extend(Zw.controls.FloatingPanel,{baseCls:'zw-dropdown-medium',cls:'gradient x-menu zw-dropdown',width:226,height:139,layout:'anchor',register:true});Zw.controls.ContextMenu.Group=Ext.extend(Ext.Panel,{baseCls:'zw-dropdown-light',frame:true,anchor:'100%',bodyStyle:'position:relative',layout:'anchor',plugins:[{init:function(client){client.on('render',function(){var e=client.body;e.createChild([{tag:'div',cls:'blue',children:{tag:'div',cls:client.image}},{tag:'div',cls:'whitewash'}]);});}}],constructor:function(args){args=args||{};Ext.each(args.items,function(el){Ext.applyIf(el,args.xdefaults);if(el.xtype){Ext.applyIf(el,{xtype:'Zw.controls.ContextMenu.Item',anchor:'-10'});}});Zw.controls.ContextMenu.Group.superclass.constructor.apply(this,[args]);},initComponent:function(){this.items=[{xtype:'panel',baseCls:'zw-dropdown-white',frame:true,anchor:'0 -2',layout:'anchor',items:this.items,bodyStyle:'margin-left: 15px;padding-right:5px;',style:'position:absolute; z-index: 1; display:block; right:0; bottom: 0; left:0; top:0;'}];Zw.controls.ContextMenu.superclass.initComponent.call(this);}});Zw.controls.ContextMenu.Item=Ext.extend(Ext.Panel,{frame:true,anchor:'-10',cls:'item',baseCls:'zw-menu-item',disabledClass:'nameitem-template-disabled',onClick:Ext.emptyFn,fireClickEvent:function(){if(this.disabled)return;if(this.fireEvent('click')){this.onClick();this.handler.call(this.scope||this,this,this.getEl());}},_onRender:function(){this.getEl().on('click',this.fireClickEvent,this);},setupClickHandlers:function(){this.on('render',this._onRender,this);},initComponent:function(){Zw.controls.ContextMenu.Item.superclass.initComponent.call(this);this.handler=this.initialConfig.handler||Ext.emptyFn;this.addEvents({'click':true});this.setupClickHandlers();if(this.disabled){this.cls+=(' '+this.disabledClass);}
this._mouseOutDelay=new Ext.util.DelayedTask();},_mouseOutDelay:null,_onMouseOver:function(){if(this.disabled)return;var el=this.el;el.addClass('mo');if(el.hasClass('selected')||el.hasClass(this.baseCls+'-selected')){el.addClass(this.baseCls+'-selected-mo');}
this._mouseOutDelay.cancel();},__onMouseOut:function(){this.el.removeClass(['mo',this.baseCls+'-selected-mo'])},_onMouseOut:function(){this._mouseOutDelay.delay(5,this.__onMouseOut,this);},onRender:function(ct,pos){Zw.controls.ContextMenu.Item.superclass.onRender.call(this,ct,pos);if(!this.dontMO&&Zw.capabilities.mouseOverCss){this.el.on({mouseover:{scope:this,fn:this._onMouseOver},mouseout:{scope:this,fn:this._onMouseOut}})}
if(this.initialConfig.text)
this.body.createChild(this.initialConfig.text);}});Zw.controls.ContextMenu.SelectionGroup=Ext.extend(Ext.util.Observable,{isOkToChange:function(sender){return(this.fireEvent('beforechange',this,sender))},setValue:function(sender){this.value=sender;this.fireEvent('change',this,sender);},constructor:function(args){Zw.controls.ContextMenu.SelectionGroup.superclass.constructor.apply(this,arguments);this.addEvents({'change':true});this.addEvents({'beforechange':true});}});Zw.controls.ContextMenu.CheckItem=Ext.extend(Zw.controls.ContextMenu.Item,{selected:false,onClick:function(){if(this.group)
this.setSelected(true);},setSelected:function(value,silent){if(value==this.selected){return;}
if(!silent){if(value){if(this.group.isOkToChange(this)){this.selected=value;this.group.setValue(this);}}else{this.selected=value;}}else{this.selected=value;}
if(value){this.onSelect();}else{this.onUnselect();}},select:function(silent){this.setSelected(true,silent);},unselect:function(silent){this.setSelected(false,silent);},onSelect:function(){this.addClass(this._getSelectedClass());},onUnselect:function(){this.removeClass(this._getSelectedClass());},_getSelectedClass:function(){return this.baseCls+'-selected';},_onGroupChange:function(group,sender){if(sender==this){}else{if(this.selected){this.unselect(false,true);}}},initComponent:function(){Zw.controls.ContextMenu.CheckItem.superclass.initComponent.call(this);if(this.selected){this.cls+=' '+this._getSelectedClass();}
this.group=this.initialConfig.group;if(this.group)
this.group.on('change',this._onGroupChange,this);}});Ext.reg('Zw.controls.ContextMenu',Zw.controls.ContextMenu);Ext.reg('Zw.controls.ContextMenu.Group',Zw.controls.ContextMenu.Group);Ext.reg('Zw.controls.ContextMenu.Item',Zw.controls.ContextMenu.Item);Ext.reg('Zw.controls.ContextMenu.CheckItem',Zw.controls.ContextMenu.CheckItem);

Zw.namespace('Zw.controls');Zw.controls.Window=Ext.extend(Ext.Window,{constrain:false,xtype:'Zw.controls.Window',monitorResize:false,modal:false,constrainHeader:false,context:null,cascadeWindows:false,cls:'zw-window',targetTaskbar:'desktop',minimizable:true,maximizable:true,focus:Ext.emptyFn,shadow:"sides",shadowOffset:7,border:false,plain:true,alignToEl:null,alignToPosition:'tl-tl',alignToXOffset:0,alignToYOffset:0,showIcon:true,onEsc:Ext.emptyFn,alreadyPositioned:false,initComponent:function(){if(this.targetTaskbar===null){this.minimizable=false;}
if(!Zw.capabilities.ALLOW_MINIMIZE){this.minimizable=false;}
if(!Zw.capabilities.ALLOW_MAXIMIZE){this.maximizable=false;}
this.addPlugin(new Zw.util.ProxyPlugin({namespace:'/desktop/window'}));if(!this.bbar){if(!this.preventStatusBar){this.bbar=new Zw.controls.StatusBar({statusAlign:'left',defaultText:'',defaultIconCls:'default-icon',text:this.statusBarText,iconCls:'ready-icon'});}}
if(this.getItems){this.items=this.getItems();}
this.onInit();Zw.controls.Window.superclass.initComponent.call(this);if(!this.title||this.title=="")
this.title="New Text";this.on("render",this.getDefaultPosition,this);},onInit:Ext.emptyFn,initEvents:function(){Zw.controls.Window.superclass.initEvents.call(this);this.on("activate",this.onActivate,this);this.on("deactivate",this.onDeactivate,this);this.on("close",this.onClose,this);},createToolHandler:function(t,tc,overCls,panel){return function(e){t.removeClass(overCls);if(tc.handler){tc.handler.call(tc.scope||t,e,t,panel);}};},afterRender:function(){Zw.controls.Window.superclass.afterRender.call(this);var hdrEl=this.el.child("div.x-window-header");if(this.showIcon){var tpl=new Ext.Template('<div class="zw-window-icon" />');var hdrTxtEl=hdrEl.child("span.x-window-header-text");tpl.insertBefore(hdrTxtEl);}
if(this.closable){var closeEl=hdrEl.child("div.x-tool-close");closeEl.addClassOnClick("x-tool-close-down");}
var minEl;var maxEl;if(this.maximizable){maxEl=hdrEl.child("div.x-tool-maximize");maxEl.addClassOnClick("x-tool-maximize-down");var restoreEl=hdrEl.child("div.x-tool-restore");restoreEl.addClassOnClick("x-tool-restore-down");}
if(this.minimizable){minEl=hdrEl.child("div.x-tool-minimize");minEl.addClassOnClick("x-tool-minimize-down");}},onActivate:function(){if(!this.topHdrEl)
this.topHdrEl=this.el.child("div.x-window-tl");this.topHdrEl.removeClass("zw-window-inactive");this.el.removeClass("zw-window-inactive-wrap");},onClose:Ext.emptyFn,onDeactivate:function(){if(!this.topHdrEl)
this.topHdrEl=this.el.child("div.x-window-tl");this.topHdrEl.addClass("zw-window-inactive");this.el.addClass("zw-window-inactive-wrap");},ghost:function(cls){return Zw.controls.Window.superclass.ghost.call(this,this.cls);},maximize:function(){Zw.controls.Window.superclass.maximize.call(this);},restore:function(){Zw.controls.Window.superclass.restore.call(this);},attention:function(){this.fireEvent('attention',this);},setActive:function(active){if(active){if(!this.maximized){this.showActiveShadow();}
this.fireEvent('activate',this);}else{this.showInactiveShadow();this.fireEvent('deactivate',this);}},showActiveShadow:function(){if(this.el){if(!this.destroyed){this.el.enableShadow(true);}}},showInactiveShadow:function(){this.el.disableShadow();},disableShadow:function(){if(this.shadow){this.shadowDisabled=true;this.shadow.hide();this.lastShadowOffset=this.shadowOffset;this.shadowOffset=0;}},enableShadow:function(show){if(this.shadow){this.shadowDisabled=false;this.shadowOffset=this.lastShadowOffset;delete this.lastShadowOffset;if(show){this.sync(true);}}},getDefaultPosition:function(){if(this.alignToEl){this.getEl().setWidth(this.width);var position=this.getEl().getAlignToXY(this.alignToEl,this.alignToPosition);this.x=this.x||(position[0]+this.alignToXOffset);this.y=this.y||(position[1]+this.alignToYOffset);}},destroy:function(){this.destroyed=true;this.un("activate",this.dirtyFocusRemover,this);delete this.context;Zw.controls.Window.superclass.destroy.call(this);}});Ext.reg('zwWindow',Zw.controls.Window);Ext.reg('Zw.controls.Window',Zw.controls.Window);

Zw.Plugin=Ext.extend(Ext.util.Observable,{_autoInitsPlugins:true,initialized:false,clonePluginArray:true,requireClient:false,client:null,log:Ext.emptyFn,autoDestroy:true,identifier:null,destroyEvent:'beforeDestroy',autoInit:false,constructor:function(config){Ext.apply(this,config);this.events=[];this.initialConfig=config||{};if(this.autoInit){this.init(this.client);}},init:function(client){this._init(client);this.initialized=true;var c=this.client;if(this.requireClient&&!c)
return;this.onInit(c);},_init:function(client){this.client=client;if(this.requireClient&&!this.client)return;this.destroyables=[];if(this.identifier){this.log=Zw.console;}
if(this.client&&this.autoDestroy){if(this.client.on){this.client.on(this.destroyEvent,this.beforeDestroy,this,{single:true});}}
if(this.plugins){this.initPlugins();}},destroyDestroyable:function(fn,scope,tag,thing){fn.call(scope,thing);if(tag)
delete this[tag];},destroyDestroyables:function(){Ext.each(this.destroyables,function(args){var fn,scope,tag,thing;fn=args.fn||Ext.destroy;scope=args.scope||Ext;tag=args.tag;thing=args.target||this[tag];this.destroyDestroyable(fn,scope,tag,thing);delete args.target;},this);delete this.destroyables;},addDestroyable:function(args){this.destroyables.push(args);},addPlugin:function(p){if(this.initialized){p.init(this);}else{this.plugins=this.plugins||[];if(!Ext.type(this.plugins)!='array')
this.plugins=[this.plugins];this.plugins.push(p);}
return p;},initPlugins:function(){if(!this.pluginConfig){if(this.client){this.pluginConfig=this.client.pluginConfig;}}
if(this.clonePluginArray){var p=[];for(var i=0;i<this.plugins.length;i++){p[i]=this.plugins[i];}
this.plugins=p;}
Ext.each(this.plugins,this.initChildPlugin,this);},initChildPlugin:function(plugin,index){if(Ext.type(plugin)=='string')
plugin=Ext.ComponentMgr.create({},plugin);if(Ext.type(plugin.xtype)=='string')
plugin=Ext.ComponentMgr.create(plugin,plugin.xtype);this.plugins[index]=plugin;plugin.init(this);},getContext:function(){var context=this.context;if(!context)context=this.client.context;if(!context)context=this.client.factory?this.client.factory.context:null;this.context=context;return context;},onInit:Ext.emptyFn,beforeDestroy:function(){Ext.destroy(this);},destroy:function(){if(!this.destroyed){this.onDestroy();this._destroy();return;}
if(Zw.Application.debug){Zw.console("You tried to destroy me twice.",this);console.trace();}},onDestroy:Ext.emptyFn,_destroy:function(){this.fireEvent('beforeDestroy',this);this.destroyed=true;if(this.client)
this.client.un(this.destroyEvent,this.beforeDestroy,this,{single:true});delete this.initialConfig;delete this.client;delete this.pluginConfig;if(this.plugins){}
this.fireEvent('destroy',this);this.destroyDestroyables();this.purgeListeners();this.suspendEvents();}});Zw.Plugin.initEarlyPlugins=function(){if(this.plugins){if(Ext.isArray(this.plugins)){var plugin,i;for(i=0;((plugin=this.plugins[i]));i++){if(plugin.earlyInit){plugin.earlyInitialized=false;plugin.init(this);plugin.earlyInitialized=true;}}}else{var plugin=this.plugins;if(plugin.earlyInit){plugin.earlyInitialized=false;plugin.init(this);plugin.earlyInitialized=true;}}}};

Zw.namespace('Zw.util');Zw.util.BatchFactory=Ext.extend(Object,{m_types:null,init:function(){this.m_types=[];},register:function(thing){this.m_types.push(thing);},remove:function(oldThing){this.replace(oldThing,'Zw.features.app.NullFeature');},replace:function(oldThing,newThing){var oldString=this.resolveXtype(oldThing);var oldType=Zw.util.resolveType(oldThing);var L=this.m_types.length;var found=false;for(var i=0;i<L;i++){var f=this.m_types[i];var t=Ext.type(f);var isString=(t=='string');if(isString){if(oldString==f){this.m_types[i]=newThing;found=true;}}else{if(oldType==f){this.m_types[i]=newThing;found=true;}}}
if(!found){this.register(newThing);}},resolveXtype:function(t){if(Ext.type(t)=='string')
return t;else
return t.xtype;},createAll:function createAll(args){var result=[];var L=this.m_types.length;for(var i=0;i<L;i++){var f=this.m_types[i];var thing=this.create(f,args);if(thing)
result.push(thing);}
return result;},create:function create(factory,args){var t=Ext.type(factory);var thing=null;if(t=='function'){thing=new factory(args);}else if(t=='string'){var type=Zw.util.resolveType(factory);thing=new type(args);}else{thing=new factory(args);}
return thing;}});

Zw.util.ProxyPlugin=Ext.extend(Zw.Plugin,{args:null,scope:'features',namespace:'',deep:false,onInit:function(){if(this.namespace){var plugins=Zw[this.scope].PluginFactory.create(this.namespace,this.args);if(this.noisy){alert("init plugins on channel "+this.scope+":"+this.namespace+": "+plugins);}
if(plugins&&plugins.length===0){return;}
if(plugins&&this.client){if(this.deep||(!this.client.addPlugin)){Ext.each(plugins,this.addPlugin,this);}else if(this.client._autoInitsPlugins){Ext.each(plugins,this.client.addPlugin,this.client);}else{Ext.each(plugins,this.addAndInitPlugin,this);}}}},addAndInitPlugin:function(plugin){if(Ext.isArray(plugin)){Ext.each(plugin,this.addAndInitPlugin,this);}else{this.client.addPlugin(plugin);}},onDestroy:function(){delete this.args;}});Ext.reg('Zw.util.ProxyPlugin',Zw.util.ProxyPlugin);

Zw.util.NamespacedFactory=Ext.extend(Object,{namespaces:null,init:function(){this.namespaces=new Ext.util.MixedCollection();},register:function(namespace,factory){if(Ext.type(namespace)=='string'){this._register(namespace,factory);}else{Ext.each(namespace,function(n){this._register(n,factory);},this);}},_register:function(namespace,factory){var factories=this.namespaces.get(namespace);if(!factories){factories=new Zw.util.ProxyBatchFactory();factories.init();this.namespaces.add(namespace,factories);}
factories.register(factory);},create:function(namespace,args){var factories=this.namespaces.key(namespace);var result=null;if(factories){result=factories.createAll(args);}
return result;}});

Zw.util.ProxyBatchFactory=Ext.extend(Zw.util.BatchFactory,{create:function(factory,args){var t=Ext.type(factory);var thing=null;if(t=='function'){thing=factory(args);}else if(t=='string'){var type=Zw.util.resolveType(factory);thing=new type(args);}else{thing=factory.create(args);}
return thing;}});

Zw.namespace('Zw.features');Zw.namespace('Zw.app');Zw.features.Factory=new Zw.util.BatchFactory();Zw.features.Factory.init();Zw.features.PluginFactory=new Zw.util.NamespacedFactory();Zw.features.PluginFactory.init();Zw.app.PluginFactory=new Zw.util.NamespacedFactory();Zw.app.PluginFactory.init();

Zw.namespace('Zw.util');Zw.util.FieldinatorPlugin=Ext.extend(Zw.Plugin,{map:null,easyWireups:true,backupFieldProvider:Ext.emptyFn,_init:function(client){Zw.util.FieldinatorPlugin.superclass._init.call(this,client);this.map=new Ext.util.MixedCollection();if(this.easyWireups){this.client.field=this.findField.createDelegate(this);this.client.value=this.getValue.createDelegate(this);}},getEl:function(){if(!this.el){this.el=this.client;}
return this.el;},findField:function(code){var field=this.map.get(code);if(!field){var fields=this.getEl().find('code',code);if(fields&&fields.length>0){field=fields[0];}else{field=this.backupFieldProvider.call(this.scope,code);}
this.map.add(code,field);}
return field;},field:function(code){return this.findField(code);},value:function(code){return this.getValue(code);},getValue:function(code){return this.findField(code).getValue();},_destroy:function(){if(this.easyWireups&&this.client){delete this.client.field;delete this.client.value;}
delete this.map;Zw.util.FieldinatorPlugin.superclass._destroy.call(this);}});

Zw.util.TabinatorPlugin=Ext.extend(Zw.util.FieldinatorPlugin,{listenEvent:'show',bufferListener:false,enabled:true,autoFocus:true,fields:null,_init:function(client){if(!this.plugins)
this.plugins=[new Zw.util.TabinatorFocusFirstTabStrategyPlugin()];Zw.util.TabinatorPlugin.superclass._init.call(this,client);},onInit:function(){if(!this.fields)
this.fields=[];this.addEvents({'render':true,'beforeChange':true,'change':true});if(this.autoAttach){this.onClientRender();}else{this.client.on(this.listenEvent,this.onClientRender,this,{single:true,buffer:this.bufferListener});}},_addEachField:function(code,index){var field=this.findField(code);field.__index=index;var el=this.findField(code).el;this.compositeEl.add(el);},onClientActivate:function(){this.keyNav.enable();},onClientDeactivate:function(){this.keyNav.disable();},onClientRender:function(){this.compositeEl=new Ext.CompositeElementLite();Ext.each(this.fields,this._addEachField,this);this.initKeyNav();this.attachListeners();this.fireEvent('render',this);},onTab:function(e){Zw.console('TabinatorPlugin.onTab!');if(!e.ctrlKey){e.preventDefault();}
if(!e.shiftKey){this.focusNextField();}else{this.focusPrevField();}},initKeyNav:function(){this.keyNav=new Ext.KeyNav(this.compositeEl,Ext.apply({scope:this,'tab':this.onTab},this.keyNavArgs));},enable:function(){this.enabeld=true;this.attachListeners();this.keyNav.enable();},disable:function(){this.enabled=false;this.detachListeners();this.keyNav.disable();},focusPrevField:function(){var currentFocusedField=this.findCurrentFocusedField();if(!currentFocusedField){this.focusFieldByIndex(0);}else{var index=this.findFieldIndex(currentFocusedField);if(index<=0){this.focusFieldByIndex(this.fields.length-1);}else{this.focusFieldByIndex(index-1);}
if(this.findCurrentFocusedField().disabled){this.focusPrevField();}}},focusNextField:function(){var currentFocusedField=this.findCurrentFocusedField();if(!currentFocusedField){Zw.console("Nothing is focused, so starting at zero");this.focusFieldByIndex(0);}else{var index=this.findFieldIndex(currentFocusedField);if(index>=this.fields.length-1){Zw.console("Starting over at zero because index ",index,'was greater than length',this.fields.length-1);this.focusFieldByIndex(0);}else{Zw.console('Focusing next');this.focusFieldByIndex(index+1);}
if(this.findCurrentFocusedField().disabled){this.focusNextField();}}},findCurrentFocusedField:function(){return this.focusField;},findFieldIndex:function(){return this.focusField.__index;},focusFieldByIndex:function(index){Zw.console("FocusFieldByIndex",index);var code=this.fields[index];this.focusFieldByCode(code);},focusFieldByCode:function(code){var field=this.findField(code);this.setFocusField(field);},onFieldBlur:function(sender){if(this.focusField==sender){Zw.console("Field blur, so setting to null");this.setFocusField(null);}},setFocusField:function(field){var old=this.focusField;if(this.fireEvent('beforeChange',this,old,field)){this.focusField=field;if(field)
field.focus();this.fireEvent('change',this,old,this.focusField);}},onFieldFocus:function(sender){if(sender){this.setFocusField(sender);Zw.console("Field focus, so setting field to ",this.focusField,arguments);}else{Zw.console("Field focus, but it was undefined, so we are ignoring it.")}},onDestroy:function(){delete this.focusField;delete this.fields;},addField:function(code){this.fields.push(code);},attachListeners:function(){Ext.each(this.fields,this._attachListener,this);this.fireEvent('attach',this);},_attachListener:function(field){field=this.findField(field);field.on('blur',this.onFieldBlur,this);field.on('focus',this.onFieldFocus,this);},detachListeners:function(){Ext.each(this.fields,this._detachListener,this);this.fireEvent('detach',this);},_detachListener:function(field){field=this.findField(field);field.on('blur',this.onFieldBlur,this);field.on('focus',this.onFieldFocus,this);}});

Zw.controls.AjaxProcessWindow=Ext.extend(Zw.controls.Window,{startProcessing:function(){this.setProcessing(true);},stopProcessing:function(){this.setProcessing(false);},setProcessing:function(value){this.processing=value;if(this.processing){this.onStartProcessing();}else{this.onStopProcessing();}},enableField:function(field){this.getField(field).enable();},disableField:function(field){this.getField(field).disable();},onStartProcessing:function(){this.fields.each(this.disableField,this);this.clickables.each(this.disableField,this);if(this.cmdSubmit)
this.cmdSubmit.disable();},onStopProcessing:function(){this.fields.each(this.enableField,this);this.clickables.each(this.enableField,this);if(this.cmdSubmit)
this.cmdSubmit.enable();},setValue:function(field,value){this.getField(field).setValue(value);},getValue:function(field){return this.getField(field).getValue();},clearValue:function(field){this.setValue(field,'');},_clearInvalid:function(field){this.getField(field).clearInvalid();},clearInvalid:function(){this.fields.each(this._clearInvalid,this);},getField:function(code){if(Ext.type(code)!='string')
return code;var prop="_"+code;if(!this[prop]){this[prop]=this.find('code',code)[0];}
return this[prop];},registerSubmit:function(field){field=this.getField(field);field.handler=this.submit;field.scope=this;this.cmdSubmit=field;},registerField:function(field,submitOnEnter){field=this.getField(field);this.fields.add(field);if(submitOnEnter)
field.on('specialkey',this.onSpecialKey,this);},registerClickable:function(field){this.clickables.add(this.getField(field));},onSpecialKey:function(sender,e){if(e.getKey()==Ext.EventObject.ENTER){this.submit();}else{}},getStatusBar:function(){return this.getField('statusbar')},initComponent:function(){this.bbar=new Zw.controls.StatusBar({statusAlign:"left",defaultText:'',defaultIconCls:'default-icon',text:'',code:'statusbar',iconCls:'ready-icon'});Zw.controls.AjaxProcessWindow.superclass.initComponent.call(this);this.fields=new Ext.util.MixedCollection();this.clickables=new Ext.util.MixedCollection();if(this.autoWireup){Ext.each(this.find('autoWireup',true),function(item){if(item.wireupType=='submit')
this.registerSubmit(item.code);else
this.registerField(item.code);},this);}},validate:function(){var v=true;this.fields.each(function(field){v=v&&field.validate();},this);if(v){v=v&&this.onValidate();}
Zw.console('Validation result: ',v);return v;},onValidate:Zw.util.returnTrue,onComplete:function(failure){this.stopProcessing();},onFailure:Ext.emptyFn,onSuccess:Ext.emptyFn,parseSuccess:function(sender,args){Zw.console('ParseSuccess: ',arguments);var success=args.success;this.onComplete(sender,args);if(!success){Zw.console('parsing success: failure');this.onFailure.call(this.scope||this,sender,args);}else{Zw.console('parsing success: success');this.onSuccess.call(this.scope||this,sender,args);if(this.closeOnSuccess)
this.close();}},parseFailure:function(sender,args){Zw.console('Subcomponent failure',arguments);this.onComplete(sender,args);this.onFailure.call(this.scope||this,sender,args);},submit:function(){if(this.validate()!=false){this.startProcessing();if(!this.onSubmit(Ext.apply(this.getSubmitArgs(),this.extraSubmitArgs))){this.stopProcessing();}}},onSubmit:function(args){if(this.ajax){Ext.applyIf(args,{success:this.parseSuccess,failure:this.parseFailure,scope:this});var w=this.ajax.call(this.ajaxScope||Zw.Application.Net,args);if(w){if(w.invoke){w.invoke();}}}
return true;},getSubmitArgs:function(){var args=this.args()||{};return args;},args:Ext.emptyFn,onDestroy:function(){delete this.field;Ext.destroy(this.fields);delete this.fields;Ext.destroy(this.clickables);delete this.clickables;Zw.controls.AjaxProcessWindow.superclass.onDestroy.call(this);}});

Zw.namespace("Zw.features.z");Zw.features.z.AboutZipwhipWindow=Ext.extend(Zw.controls.Window,{title:'About Zipwhip',stateful:false,mainText:"Zipwhip is a text messaging utility.<br><br>"+"With 150 billion text messages sent every month in the U.S., text messaging has clearly become a full-blown communication medium. "+"We believe that texting is now bigger than the mobile phone and should be accessible to you wherever you are, especially from the internet.<br><br>"+"The Zipwhip texting portal enables you to quickly send and receive text messages across carrier networks. You even have the freedom to walk away from your computer knowing that your incoming messages will be promptly Smart Forwarded to your mobile phone. Additional features include Scheduled Texting and Group Messaging.<br><br>"+"Please reference the FAQ section or email us via our customer support window with additional questions. Enjoy!",id:'zw-window-about',cls:'zw-window zw-window-about',height:420,width:350,layout:'anchor',getItems:function(){return[{xtype:'div',cls:'center',height:83,defaultType:'div',items:[{cls:'left'},{cls:'right'}]},{xtype:'div',cls:'swirl',anchor:'100% -83',layout:'fit',items:{xtype:'div',cls:'about',html:Zw.capabilities.ABOUT_US_TEXT?Zw.capabilities.ABOUT_US_TEXT:this.mainText}}];}});Ext.reg('Zw.features.z.AboutZipwhipWindow',Zw.features.z.AboutZipwhipWindow);

Zw.namespace("Zw.features.corp");Zw.features.corp.CorpAboutWindow=Ext.extend(Zw.features.z.AboutZipwhipWindow,{height:420,width:420,mainText:"Zipwhip is a text messaging utility.<br><br>"+"With 150 billion text messages sent every month in the U.S., text messaging has clearly become a full-blown communication medium. "+"We believe that texting is now bigger than the mobile phone and should be accessible to you wherever you are, especially from the internet. <br><br>"+"The Zipwhip texting portal enables you to quickly send and receive text messages across carrier networks. You even have the freedom to walk away from your computer knowing that your incoming messages will be promptly Smart Forwarded to your mobile phone. Additional features include Scheduled Texting and Group Messaging.<br><br>"+"If you're interested in beta access, please apply from the Beta link in the Z pull down menu. If you're a Sprint user, simply go to <a href=\"http://sprint.zipwhip.com/\">sprint.zipwhip.com</a> and login with your Sprint username and password."});Ext.reg('Zw.features.corp.CorpAboutWindow',Zw.features.corp.CorpAboutWindow);

Zw.namespace("Zw.features.corp");Zw.features.corp.MediaWindow=Ext.extend(Zw.controls.Window,{title:'Media Guidelines',stateful:false,id:'zw-window-media',cls:'zw-window zw-window-media',width:300,height:440,layout:'anchor',getItems:function(){return[{xtype:'div',cls:'center',anchor:'100%',height:61,items:[{xtype:'div',cls:'left',height:61,items:[{xtype:'div',cls:'right'}]}]},{xtype:'div',cls:'swirl',anchor:'100% -61',autoScroll:false,layout:'fit',items:[{xtype:'div',cls:'padded-body',items:[{xtype:'panel',baseCls:'none',cls:'content',autoScroll:false,autoLoad:'/corp/media.html'}]}]}];}});Ext.reg('Zw.features.corp.MediaWindow',Zw.features.corp.MediaWindow);

Zw.namespace("Zw.features.corp");Zw.features.corp.BetaWindow=Ext.extend(Zw.controls.Window,{title:'Beta',stateful:false,id:'zw-window-beta',cls:'zw-window zw-window-beta',height:390,width:620,layout:'anchor',onInit:function(){this.addPlugin(new Zw.util.FieldinatorPlugin({fields:['fullName','mobileNumber','email']}));},afterRender:function(){Zw.features.corp.BetaWindow.superclass.afterRender.call(this);},getItems:function(){return[{xtype:'div',cls:'center',anchor:'100%',height:61,items:[{xtype:'div',cls:'left',height:61,items:[{xtype:'div',cls:'right'}]}]},{xtype:'div',cls:'swirl',anchor:'100% -61',autoScroll:false,layout:'border',defaults:{xtype:'div'},items:[{region:'west',width:350,autoScroll:false,layout:"fit",items:[{xtype:'div',style:"overflow:hidden;",cls:'',layout:"fit",items:[{code:'scroll',xtype:'div',style:'padding:20px;',defaultType:'div',layout:'anchor',defaults:{anchor:'100%'},items:[{html:'<h1>Zipwhip Beta Access</h1>'},{anchor:'',cls:'zw-window-beta-image image'},{anchor:'',html:'For those of you who have been granted a Zipwhip Beta access code, please enter it here.'},{xtype:'textfield',anchor:'',emptyText:'Enter code here...',style:'margin-bottom: 10px;margin-top: 10px;'},{html:"Note: this is our first release to the public and we're counting on you to dive in and give us as much feedback as possible. Thanks for your help. Enjoy!",style:'padding-bottom: 10px;'},{xtype:'Zw.controls.ActionButton',text:'Enter Zipwhip',style:'margin-bottom: 20px;',handler:function(){Ext.Msg.alert('Incorrect beta key','<b>Incorrect beta key.</b> Please verify your key or contact support if you feel this is in error.');}}]}]}]},{region:'center',autoScroll:false,layout:"anchor",items:[{xtype:'div',style:"overflow:hidden;",cls:'',layout:"anchor",anchor:"100%",style:'padding-top:20px;padding-right:20px;padding-left:10px;padding-bottom:10px;',items:[{xtype:'div',html:'<h1>Request Access Code</h1>'},{xtype:'div',html:'In order to get access to our beta we need to know who you are. Please fill out the fields below and we will be in touch with you in a timely manner. Thank you.',style:'padding-bottom: 10px;'},{xtype:'form',baseCls:'none',labelWidth:100,defaults:{xtype:'textfield',anchor:'-40'},layoutConfig:{labelSeparator:':'},items:[{fieldLabel:'Full&nbsp;Name',code:'fullName'},{fieldLabel:'Mobile&nbsp;Number',code:'mobileNumber'},{fieldLabel:'Email',code:'email'}]},{xtype:'Zw.controls.ActionButton',text:'Submit & Close',style:'margin-top: 0 ; margin-bottom: 25px;',scope:this,handler:function(){Zw.Application.Net.corporateBeta({scope:this,success:function(){this.close();},failure:function(){alert('Unable to communicate with servers. Please try again or refresh the page.');},params:{fullName:this.value('fullName'),mobileNumber:this.value('mobileNumber'),email:this.value('email')}});}}]}]}]}]}});Ext.reg('Zw.features.corp.BetaWindow',Zw.features.corp.BetaWindow);

Zw.namespace("Zw.features.corp");Zw.features.corp.BizDevWindow=Ext.extend(Zw.controls.Window,{title:'Business Development',stateful:false,id:'zw-window-bizdev',cls:'zw-window zw-window-bizdev',height:330,width:600,layout:'anchor',getItems:function(){return[{xtype:'div',cls:'center',anchor:'100%',height:61,items:[{xtype:'div',cls:'left',height:61,items:[{xtype:'div',cls:'right'}]}]},{xtype:'div',cls:'swirl',anchor:'100% -61',autoScroll:false,layout:'fit',items:[{xtype:'div',cls:'padded-body',items:[{xtype:'panel',baseCls:'none',cls:'content',autoScroll:false,autoLoad:'/corp/bizdev.html'}]}]}];}});Ext.reg('Zw.features.corp.BizDevWindow',Zw.features.corp.BizDevWindow);

Zw.namespace("Zw.features.corp");Zw.features.corp.ContactUsWindow=Ext.extend(Zw.controls.AjaxProcessWindow,{title:'Contact Us',stateful:false,id:'zw-window-contactus',cls:'zw-window zw-window-contactus',width:400,height:420,autoWireup:true,layout:'anchor',getItems:function(){return[{xtype:'div',cls:'center',anchor:'100%',height:61,items:[{xtype:'div',cls:'left',height:61,items:[{xtype:'div',cls:'right'}]}]},{xtype:'div',cls:'swirl',anchor:'100% -61',autoScroll:false,layout:'fit',items:[{xtype:'div',cls:'padded-body',style:'overflow-y:scroll;position:relative;',defaultType:'div',items:[{cls:'zw-window-contactus-reach header',style:'padding-bottom: 10px;',html:'Reach Out To Us'},{cls:'zw-window-contactus-info-wrap',width:200,layout:'table',layoutConfig:{columns:2},defaultType:'div',items:[{html:'Email:'},{html:'info@zipwhip.com'},{html:'Phone:'},{html:'(206) 569-0212'},{html:'Fax:'},{html:'(206) 237-9909'}]},{cls:'image zw-window-contactus-image'},{cls:'header',style:'padding-top: 30px; padding-bottom: 12px;',html:"We'll Contact You"},{style:'padding-bottom: 10px;',html:"Please leave your personal information and comments below if you'd like a Zipwhip representative to contact you."},{xtype:'form',baseCls:'none',defaultType:'textfield',labelAlign:'left',labelWidth:60,defaults:{anchor:'95%',labelSeparator:''},items:[{fieldLabel:'Name',autoWireup:true,code:'name',name:'name'},{fieldLabel:'Email',autoWireup:true,code:'email',name:'email',vtype:'email'},{fieldLabel:'Phone',autoWireup:true,code:'number',name:'number'},{hideLabel:true,fieldLabel:'',xtype:'textarea',autoWireup:true,code:'comments',height:100,name:'comments',emptyText:'Type your comments here…'}]},{xtype:'Zw.controls.ActionButton',wireupType:'submit',style:'margin-bottom: 10px',autoWireup:true,code:'submit',text:'Submit & Close'}]}]}];},onSuccess:function(){this.close();},onValidate:function(){var result=true;if(!this.getValue('email').length){this.getField('email').markInvalid("Please enter your e-mail address");result=false;}
return result;},ajax:function(args){Zw.Application.Net.commentSend({scope:args.scope,success:args.success,failure:args.failure,params:args});},args:function(){return{name:this.getValue('name'),email:this.getValue('email'),metaData:this.getValue('number'),comment:this.getValue('comments'),topic:'Corporate Contact Us',portal:'corporate'};}});Ext.reg('Zw.features.corp.ContactUsWindow',Zw.features.corp.ContactUsWindow);

Zw.namespace("Zw.features.corp");Zw.features.corp.JobsWindow=Ext.extend(Zw.controls.Window,{stateful:false,title:'Jobs',id:'zw-window-jobs',cls:'zw-window zw-window-jobs',width:440,height:440,layout:'anchor',getItems:function(){return[{xtype:'div',cls:'center',anchor:'100%',height:61,items:[{xtype:'div',cls:'left',height:61,items:[{xtype:'div',cls:'right'}]}]},{xtype:'div',cls:'swirl',anchor:'100% -61',autoScroll:false,layout:'fit',items:[{xtype:'div',cls:'padded-body',style:'overflow-y:auto;position:relative;',defaultType:'div',items:[{xtype:'panel',baseCls:'none',style:'position:relative;',autoLoad:'/corp/jobs.html'}]}]}];}});Ext.reg('Zw.features.corp.JobsWindow',Zw.features.corp.JobsWindow);

Zw.namespace("Zw.features.corp");Zw.features.corp.TellAFriendWindow=Ext.extend(Zw.controls.AjaxProcessWindow,{title:'Tell A Friend',stateful:false,autoWireup:true,id:'zw-window-tellafriend',cls:'zw-window zw-window-tellafriend',height:380,width:500,layout:'anchor',getItems:function(){return[{xtype:'div',cls:'center',anchor:'100%',height:61,items:[{xtype:'div',cls:'left',height:61,items:[{xtype:'div',cls:'right'}]}]},{xtype:'div',cls:'swirl',anchor:'100% -61',autoScroll:false,layout:'border',defaults:{xtype:'div'},items:[{region:'west',width:200,items:{xtype:'div',cls:'image zw-window-tellafriend-image top'}},{region:'center',layout:'border',items:[{xtype:'div',region:'north',style:'padding:10px;padding-left:0;padding-right:20px;',html:"Share Zipwhip Beta with your friends! Get them access too. And don't forget about mom. Zipwhip is ideal for anybody who wants an easier and faster way to kick off a text."},{region:'center',xtype:'form',baseCls:'none',labelWidth:80,layoutConfig:{},defaults:{xtype:'textfield',anchor:'-20'},items:[{fieldLabel:'From&nbsp;Email',vtype:'email',code:'from',allowBlank:false,autoWireup:true,emptyText:'Your email'},{fieldLabel:'To&nbsp;Email',vtype:'email',code:'to',allowBlank:false,autoWireup:true,emptyText:'Your friend\'s email'},{hideLabel:true,xtype:'textarea',code:'body',allowBlank:false,autoWireup:true,anchor:'-20 -65',listeners:{'render':this._onFieldRender}}]},{region:'south',xtype:'div',height:44,style:"padding-top:8px;",items:{xtype:'Zw.controls.ActionButton',cls:'zw-action-button rightAlign',code:'submit',text:'Submit & Close',wireupType:'submit',autoWireup:true}}]}]}];},onInit:function(){this.addPlugin(new Zw.util.TabinatorPlugin({easyWireups:true,fields:['from','to','body','submit']}));},afterRender:function(){Zw.features.corp.TellAFriendWindow.superclass.afterRender.call(this);Zw.util.preventSpellcheck(this.getField('body'));},onValidate:function(){this.getField('to').validate();this.getField('from').validate();this.getField('body').validate();return true;},ajax:function(args){Zw.Application.Net.shareSend({scope:args.scope,success:args.success,failure:args.failure,params:args});},args:function(){return{to:this.value('to'),from:this.value('from'),body:this.value('body')};},onSuccess:function(){Ext.Msg.alert('Sent Successfully','Your message has been sent.',this.onClickOk,this);},onFailure:function(){Ext.Msg.alert('Unable to contact server','Unable to communicate with server. Your message has not been sent.');},onClickOk:function(){this.close();},_onFieldRender:function(){this.setRawValue("Hey, check out this beta app when you get a chance. Zipwhip is a new text messaging utility on the web! You have to apply for access, but I thought you'd dig this. I did.");}});Ext.reg('Zw.features.corp.TellAFriendWindow',Zw.features.corp.TellAFriendWindow);

Zw.app.ApplicationNet=Ext.extend(Object,{baseUrl:'',_createCallback:function(callback,success,_scope,eventSource){return function(response,options){var json=null;if(response.data){json=response.data;}else{try{var responseText=Ext.isAir?response.responseText.replace(/new Date\((\d+)\)/g,'$1'):response.responseText;json=Ext.decode(responseText);}catch(err){}}
if(_scope&&callback)
callback.call(_scope,this,json,response);};},_request:function(args){Ext.apply(args,{success:this._createCallback(args.success||Ext.emptyFn,true,args.scope||this,this),failure:this._createCallback(args.failure||Ext.emptyFn,false,args.scope||this,this)});args.url=this.baseUrl+args.url;if(args.delayInvoke){return{invoke:Ext.Ajax.request.createDelegate(Ext.Ajax,[args])};}else{Ext.Ajax.request(args);}},commentSend:function(args){return this._request(Ext.apply(args,{url:'comment/send',method:'POST'}));},shareSend:function(args){return this._request(Ext.apply(args,{url:'share/send',method:'POST'}));},corporateBeta:function(args){return this._request(Ext.apply(args,{url:'corporate/beta',method:'POST'}));}});Zw.Application.Net=new Zw.app.ApplicationNet();
