/*
 * SilverCollectionCore
 * Copyright(c) 2008, SilverBiology, LLC (Michael Giddens).
 * Website: www.SilverBiology.com
 */


Ext.ux.SearchField=Ext.extend(Ext.form.TwinTriggerField,{initComponent:function(){Ext.ux.SearchField.superclass.initComponent.call(this);this.on('specialkey',function(f,e){if(e.getKey()==e.ENTER){this.onTrigger2Click();}},this);},validationEvent:false,validateOnBlur:false,trigger1Class:'x-form-clear-trigger',trigger2Class:'x-form-search-trigger',hideTrigger1:true,width:180,hasSearch:false,paramName:'query',onTrigger1Click:function(){if(this.hasSearch){var o={start:0};o[this.paramName]='';this.el.dom.value='';this.store.reload({params:o});this.triggers[0].hide();this.hasSearch=false;}},onTrigger2Click:function(){var v=this.getRawValue();if(v.length<1){this.onTrigger1Click();return;}
var o={start:0};o[this.paramName]=v;this.store.reload({params:o});this.hasSearch=true;this.triggers[0].show();}});

Ext.ux.SelectBox=function(config){this.searchResetDelay=1000;config=config||{};config=Ext.apply(config||{},{editable:false,forceSelection:true,rowHeight:false,lastSearchTerm:false,triggerAction:'all',mode:'local'});Ext.ux.SelectBox.superclass.constructor.apply(this,arguments);this.lastSelectedIndex=this.selectedIndex||0;};Ext.extend(Ext.ux.SelectBox,Ext.form.ComboBox,{lazyInit:false,initEvents:function(){Ext.ux.SelectBox.superclass.initEvents.apply(this,arguments);this.el.on('keydown',this.keySearch,this,true);this.cshTask=new Ext.util.DelayedTask(this.clearSearchHistory,this);},keySearch:function(e,target,options){var raw=e.getKey();var key=String.fromCharCode(raw);var startIndex=0;if(!this.store.getCount()){return;}
switch(raw){case Ext.EventObject.HOME:e.stopEvent();this.selectFirst();return;case Ext.EventObject.END:e.stopEvent();this.selectLast();return;case Ext.EventObject.PAGEDOWN:this.selectNextPage();e.stopEvent();return;case Ext.EventObject.PAGEUP:this.selectPrevPage();e.stopEvent();return;}
if((e.hasModifier()&&!e.shiftKey)||e.isNavKeyPress()||e.isSpecialKey()){return;}
if(this.lastSearchTerm==key){startIndex=this.lastSelectedIndex;}
this.search(this.displayField,key,startIndex);this.cshTask.delay(this.searchResetDelay);},onRender:function(ct,position){this.store.on('load',this.calcRowsPerPage,this);Ext.ux.SelectBox.superclass.onRender.apply(this,arguments);if(this.mode=='local'){this.calcRowsPerPage();}},onSelect:function(record,index,skipCollapse){if(this.fireEvent('beforeselect',this,record,index)!==false){this.setValue(record.data[this.valueField||this.displayField]);if(!skipCollapse){this.collapse();}
this.lastSelectedIndex=index+1;this.fireEvent('select',this,record,index);}},render:function(ct){Ext.ux.SelectBox.superclass.render.apply(this,arguments);if(Ext.isSafari){this.el.swallowEvent('mousedown',true);}
this.el.unselectable();this.innerList.unselectable();this.trigger.unselectable();this.innerList.on('mouseup',function(e,target,options){if(target.id&&target.id==this.innerList.id){return;}
this.onViewClick();},this);this.innerList.on('mouseover',function(e,target,options){if(target.id&&target.id==this.innerList.id){return;}
this.lastSelectedIndex=this.view.getSelectedIndexes()[0]+1;this.cshTask.delay(this.searchResetDelay);},this);this.trigger.un('click',this.onTriggerClick,this);this.trigger.on('mousedown',function(e,target,options){e.preventDefault();this.onTriggerClick();},this);this.on('collapse',function(e,target,options){Ext.getDoc().un('mouseup',this.collapseIf,this);},this,true);this.on('expand',function(e,target,options){Ext.getDoc().on('mouseup',this.collapseIf,this);},this,true);},clearSearchHistory:function(){this.lastSelectedIndex=0;this.lastSearchTerm=false;},selectFirst:function(){this.focusAndSelect(this.store.data.first());},selectLast:function(){this.focusAndSelect(this.store.data.last());},selectPrevPage:function(){if(!this.rowHeight){return;}
var index=Math.max(this.selectedIndex-this.rowsPerPage,0);this.focusAndSelect(this.store.getAt(index));},selectNextPage:function(){if(!this.rowHeight){return;}
var index=Math.min(this.selectedIndex+this.rowsPerPage,this.store.getCount()-1);this.focusAndSelect(this.store.getAt(index));},search:function(field,value,startIndex){field=field||this.displayField;this.lastSearchTerm=value;var index=this.store.find.apply(this.store,arguments);if(index!==-1){this.focusAndSelect(index);}},focusAndSelect:function(record){var index=typeof record==='number'?record:this.store.indexOf(record);this.select(index,this.isExpanded());this.onSelect(this.store.getAt(record),index,this.isExpanded());},calcRowsPerPage:function(){if(this.store.getCount()){this.rowHeight=Ext.fly(this.view.getNode(0)).getHeight();this.rowsPerPage=this.maxHeight/this.rowHeight;}else{this.rowHeight=false;}}});

Ext.namespace('Ext.ux');Ext.ux.GMapPanel=Ext.extend(Ext.Panel,{initComponent:function(){var defConfig={plain:true,zoomLevel:3,yaw:180,pitch:0,zoom:0,gmapType:'map',border:false}
Ext.applyIf(this,defConfig);Ext.ux.GMapPanel.superclass.initComponent.call(this);},afterRender:function(){var wh=this.ownerCt.getSize();Ext.applyIf(this,wh);Ext.ux.GMapPanel.superclass.afterRender.call(this);if(this.gmapType==='map'){var config=this.mapTypes?{mapTypes:this.mapTypes}:{};this.gmap=new GMap2(this.body.dom,config);CustomGetTileUrl=function(a,b,c){this.myMercZoomLevel=0;this.myStyles="default";var lULP=new GPoint(a.x*256,(a.y+1)*256);var lLRP=new GPoint((a.x+1)*256,a.y*256);var lUL=G_NORMAL_MAP.getProjection().fromPixelToLatLng(lULP,b,c);var lLR=G_NORMAL_MAP.getProjection().fromPixelToLatLng(lLRP,b,c);if(this.myMercZoomLevel!=0&&map.getZoom()<this.myMercZoomLevel){var lBbox=dd2MercMetersLng(lUL.lngDegrees)+","+dd2MercMetersLat(lUL.latDegrees)+","+dd2MercMetersLng(lLR.lngDegrees)+","+dd2MercMetersLat(lLR.latDegrees);var lSRS="EPSG:54004";}else{var lBbox=lUL.x+","+lUL.y+","+lLR.x+","+lLR.y;var lSRS="EPSG:4326";}
var lURL=this.myBaseURL;lURL+="&REQUEST=GetMap";lURL+="&SERVICE=WMS";lURL+="&reaspect=false&VERSION=1.1.1";lURL+="&LAYERS="+this.myLayers;lURL+="&STYLES="+this.myStyles;lURL+="&FORMAT="+this.myFormat;lURL+="&BGCOLOR=0xFFFFFF";lURL+="&TRANSPARENT=TRUE";lURL+="&SRS="+lSRS;lURL+="&BBOX="+lBbox;lURL+="&WIDTH=256";lURL+="&HEIGHT=256";lURL+="&GroupName="+this.myLayers;return lURL;}
tileDRG=new GTileLayer(new GCopyrightCollection(""),1,17);tileDRG.myLayers='DRG';tileDRG.myFormat='image/jpeg';tileDRG.myBaseURL='http://www.terraserver-usa.com/ogcmap6.ashx?';tileDRG.getTileUrl=CustomGetTileUrl;tileDRG.getOpacity=function(){return 1.0;}
var topo_layer=[tileDRG];var layer1=[tileDRG];var custommap1=new GMapType(layer1,G_SATELLITE_MAP.getProjection(),"Topo");tileDoq=new GTileLayer(new GCopyrightCollection(""),1,17);tileDoq.myLayers='doq';tileDoq.myFormat='image/jpeg';tileDoq.myBaseURL='http://terraservice.net/ogcmap.ashx?';tileDoq.getTileUrl=CustomGetTileUrl;tileDoq.getOpacity=function(){return 1.0;}
var doq_layer=[tileDoq];var layer2=[tileDoq];var custommap2=new GMapType(layer2,G_SATELLITE_MAP.getProjection(),"DOQ");this.gmap.addMapType(custommap1);this.gmap.addMapType(custommap2);this.gmap.addMapType(G_PHYSICAL_MAP);}
if(this.gmapType==='panorama'){this.gmap=new GStreetviewPanorama(this.body.dom);}
if(this.controls&&this.gmapType==='map'){if(Ext.isArray(this.controls)){Ext.each(this.controls,function(control){this.gmap.addControl(control);},this);}else if(typeof this.controls==='object'){this.gmap.addControl(this.control);}
delete this.controls;}
if(this.featureConfig){if(typeof this.featureConfig==='string'){this.featureConfig=[this.featureConfig];}
Ext.each(this.featureConfig,function(feature){eval('this.gmap.'+feature+'();');},this);delete this.featureConfig;}
if(typeof this.setCenter==='object'){if(typeof this.setCenter.geoCodeAddr==='string'){this.geoCodeLookup(this.setCenter.geoCodeAddr);}else{if(this.gmapType==='map'){var point=new GLatLng(this.setCenter.lat,this.setCenter.lng);this.gmap.setCenter(point,this.zoomLevel);}
if(typeof this.setCenter.marker==='object'&&typeof point==='object'){this.addMarker(point,this.setCenter.marker,this.setCenter.marker.clear);}}
if(this.gmapType==='panorama'){this.gmap.setLocationAndPOV(new GLatLng(this.setCenter.lat,this.setCenter.lng),{yaw:this.yaw,pitch:this.pitch,zoom:this.zoom});}}
var dt=new Ext.util.DelayedTask();dt.delay(300,function(){this.addMarkers(this.markers);},this);this.on('resize',this.gmap.checkResize,this.gmap);this.changeView(G_PHYSICAL_MAP);},onResize:function(w,h){if(typeof this.gmap=='object'){this.gmap.checkResize();}
Ext.ux.GMapPanel.superclass.onResize.call(this,w,h);},setSize:function(width,height,animate){if(typeof this.gmap=='object'){this.gmap.checkResize();}
Ext.ux.GMapPanel.superclass.setSize.call(this,width,height,animate);},getMap:function(){return this.gmap;},addMarkers:function(markers){if(Ext.isArray(markers)){for(var i=0;i<markers.length;i++){var mkr_point=new GLatLng(markers[i].lat,markers[i].lng);this.addMarker(mkr_point,markers[i].marker,false,markers[i].setCenter);}}},addMarker:function(point,marker,clear,center){Ext.applyIf(marker,G_DEFAULT_ICON);if(clear===true){this.gmap.clearOverlays();}
if(center===true){this.gmap.setCenter(point,this.zoomLevel);}
var mark=new GMarker(point,marker);this.gmap.addOverlay(mark);return(mark);},geoCodeLookup:function(addr){this.geocoder=new GClientGeocoder();this.geocoder.getLocations(addr,this.addAddressToMap.createDelegate(this));},addAddressToMap:function(response){if(!response||response.Status.code!=200){Ext.MessageBox.alert('Error','Code '+response.Status.code+' Error Returned');}else{place=response.Placemark[0];addressinfo=place.AddressDetails;accuracy=addressinfo.Accuracy;if(accuracy===0){Ext.MessageBox.alert('Unable to Locate Address','Unable to Locate the Address you provided');}else{if(accuracy<7){Ext.MessageBox.alert('Address Accuracy','The address provided has a low accuracy.<br><br>Level '+accuracy+' Accuracy (8 = Exact Match, 1 = Vague Match)');}else{point=new GLatLng(place.Point.coordinates[1],place.Point.coordinates[0]);if(typeof this.setCenter.marker==='object'&&typeof point==='object'){this.addMarker(point,this.setCenter.marker,this.setCenter.marker.clear,true);}}}}},drawCircle:function(circleUnits,circleRadius,point){var center=this.gmap.getCenter();var bounds=new GLatLngBounds();var circlePoints=Array();with(Math){if(circleUnits=='KM'){var d=circleRadius/6378.8;}else{var d=circleRadius/3963.189;}
var lat1=(PI/180)*center.lat();var lng1=(PI/180)*center.lng();for(var a=0;a<361;a++){var tc=(PI/180)*a;var y=asin(sin(lat1)*cos(d)+cos(lat1)*sin(d)*cos(tc));var dlng=atan2(sin(tc)*sin(d)*cos(lat1),cos(d)-sin(lat1)*sin(y));var x=((lng1-dlng+PI)%(2*PI))-PI;var point=new GLatLng(parseFloat(y*(180/PI)),parseFloat(x*(180/PI)));circlePoints.push(point);bounds.extend(point);}
if(d<1.5678565720686044){circle=new GPolygon(circlePoints,'#000000',1,1,'#000000',0.25);}else{circle=new GPolygon(circlePoints,'#000000',1,1);}
this.gmap.addOverlay(circle);this.gmap.setZoom(this.gmap.getBoundsZoomLevel(bounds));}},changeView:function(view){this.gmap.setMapType(view);}});Ext.reg('gmappanel',Ext.ux.GMapPanel);

Ext.ux.TwinComboBox=Ext.extend(Ext.form.ComboBox,{initComponent:Ext.form.TwinTriggerField.prototype.initComponent,getTrigger:Ext.form.TwinTriggerField.prototype.getTrigger,initTrigger:Ext.form.TwinTriggerField.prototype.initTrigger,trigger1Class:'x-form-clear-trigger',hideTrigger1:true,reset:Ext.form.Field.prototype.reset.createSequence(function(){this.triggers[0].hide();}),onViewClick:Ext.form.ComboBox.prototype.onViewClick.createSequence(function(){this.triggers[0].show();}),onTrigger2Click:function(){this.onTriggerClick();},onTrigger1Click:function(){this.clearValue();this.triggers[0].hide();this.fireEvent('clear',this);}});Ext.reg('xtwincombo',Ext.ux.TwinComboBox);

Ext.ux.TwinComboBox=Ext.extend(Ext.form.DateField,{initComponent:Ext.form.TwinTriggerField.prototype.initComponent,getTrigger:Ext.form.TwinTriggerField.prototype.getTrigger,initTrigger:Ext.form.TwinTriggerField.prototype.initTrigger,trigger1Class:'x-form-clear-trigger',trigger2Class:'x-form-date-trigger',hideTrigger1:true,reset:Ext.form.Field.prototype.reset.createSequence(function(){this.triggers[0].hide();}),dateSelect:Ext.form.DateField.prototype.menuListeners.select=function(m,d){this.setValue(d);this.triggers[0].show();this.fireEvent('select',this);},onTrigger2Click:function(){this.onTriggerClick();},onTrigger1Click:function(){this.reset();this.triggers[0].hide();this.fireEvent('clear',this);}});Ext.reg('xtwincombodate',Ext.ux.TwinComboBox);

var Lang=function(){var default_lang;var lang;return{init:function(value){if((typeof value!='undefined')&&(value!='')){this.lang=eval('language_'+value);}else{this.lang=language_en;}
this.default_lang=language_en;},Get:function(lib,root,value){return(Language[lib][root][value].value);}}}();

Ext.Desktop=function(){var desktop=Ext.get('x-desktop');var taskbar=Ext.get('x-taskbar');var wbar=Ext.get('x-windows');var windows=new Ext.WindowGroup();var activeWindow;function minimizeWin(win){win.minimized=true;win.hide();}
function markActive(win){if(activeWindow&&activeWindow!=win){markInactive(activeWindow);}
activeWindow=win;Ext.fly(win.taskItem.el).addClass('active-win');win.minimized=false;}
function markInactive(win){if(win==activeWindow){activeWindow=null;Ext.fly(win.taskItem.el).removeClass('active-win');}}
function removeWin(win){win.taskItem.destroy();layout();}
function layout(){desktop.setHeight(Ext.lib.Dom.getViewHeight()-(taskbar?taskbar.getHeight():0)-wbar.getHeight());}
Ext.EventManager.onWindowResize(layout);this.layout=layout;this.createWindow=function(config,cls){var win=new(cls||Ext.Window)(Ext.applyIf(config||{},{manager:windows,minimizable:true,maximizable:true}));win.render(desktop);win.taskItem=new Ext.Desktop.TaskBarItem(win);win.cmenu=new Ext.menu.Menu({items:[]});win.animateTarget=win.taskItem.el;win.on('activate',markActive);win.on('beforeshow',markActive);win.on('deactivate',markInactive);win.on('minimize',minimizeWin);win.on('close',removeWin);layout();return win;};this.getManager=function(){return windows;};this.getWindow=function(id){return windows.get(id);}
layout();};Ext.Desktop.TaskBarItem=function(win){this.win=win;Ext.Desktop.TaskBarItem.superclass.constructor.call(this,{iconCls:win.iconCls,text:win.title,renderTo:'x-winlist',handler:function(){if(win.minimized||win.hidden){win.show();}else if(win==win.manager.getActive()){win.minimize();}else{win.toFront();}},clickEvent:'mousedown'});};Ext.extend(Ext.Desktop.TaskBarItem,Ext.Button,{onRender:function(){Ext.Desktop.TaskBarItem.superclass.onRender.apply(this,arguments);this.cmenu=new Ext.menu.Menu({items:[{text:'Restore',handler:function(){if(!this.win.isVisible()){this.win.show();}else{this.win.restore();}},scope:this},{text:'Minimize',handler:this.win.minimize,scope:this.win},{text:'Maximize',handler:this.win.maximize,scope:this.win},'-',{text:'Close',handler:function(){this.show();this.close();},scope:this.win}]});this.cmenu.on('beforeshow',function(){var items=this.cmenu.items.items;var w=this.win;items[0].setDisabled(w.maximized!==true&&w.hidden!==true);items[1].setDisabled(w.minimized===true);items[2].setDisabled(w.maximized===true||w.hidden===true);},this);this.el.on('contextmenu',function(e){e.stopEvent();if(!this.cmenu.el){this.cmenu.render();}
var xy=e.getXY();xy[1]-=this.cmenu.el.getHeight();this.cmenu.showAt(xy);},this);}});Ext.app.App=function(cfg){Ext.apply(this,cfg);this.addEvents({'ready':true,'beforeunload':true,'sessionexpire':true});Ext.onReady(this.initApp,this);};Ext.extend(Ext.app.App,Ext.util.Observable,{isReady:false,initApp:function(){this.desktop=new Ext.Desktop();this.launcher=new Ext.Toolbar({renderTo:'x-launcher'});var ms=this.getModules();if(ms){this.initModules(ms);}
this.init();Ext.EventManager.on(window,'beforeunload',this.onUnload,this);this.fireEvent('ready',this);this.isReady=true;},getModules:Ext.emptyFn,init:Ext.emptyFn,initModules:function(ms){for(var i=0,len=ms.length;i<len;i++){var m=ms[i];this.launcher.add(m.launcher);m.app=this;}},onReady:function(fn,scope){if(!this.isReady){this.on('ready',fn,scope);}else{fn.call(scope,this);}},getDesktop:function(){return this.desktop;},onUnload:function(e){if(this.fireEvent('beforeunload',this)===false){e.stopEvent();}}});Ext.app.Module=function(config){Ext.apply(this,config);Ext.app.Module.superclass.constructor.call(this);this.init();}
Ext.extend(Ext.app.Module,Ext.util.Observable,{init:function(){}});

SilverCollection=new Ext.app.App({windowIndex:0,mapIndex:0,init:function(){Ext.WindowMgr.zseed=50000;if(Config.Hint.show){this.hints();}
if(Config.Unload){window.onbeforeunload=function(){return(Lang.Get('Core','general','unload'));}}
Ext.QuickTips.init();Ext.BLANK_IMAGE_URL="images/themes/default/s.gif";Ext.fly(document.body).on('contextmenu',function(e,target){e.preventDefault();});Ext.get('loading').remove();Ext.get('loading-mask').fadeOut({remove:true});var about=new Ext.Button({text:Lang.Get('Core','about','title'),iconCls:'icon_info',handler:function(){var winAbout=new Ext.Window({title:this.text,iconCls:'icon_info',closable:true,minWidth:400,minHeight:300,width:400,height:300,modal:true,autoLoad:'docs/about/index.html',autoScroll:true,onEsc:Ext.emptyFn,bbar:new Ext.StatusBar({id:'about-status',text:'Collection is powered by <a href="http://collection.silverbiology.com" target="_blank">SilverCollection</a> a SilverBiology product.'}),buttons:[{text:'Close',handler:function(){this.ownerCt.close();}}]});SilverCollection.stats.log('About');winAbout.show();},renderTo:'about_collection'});var help=new Ext.Button({text:Lang.Get('Core','help','title'),iconCls:'icon_help',handler:function(){SilverCollection.stats.log('Help');window.open('docs/help/index.html','_blank');},renderTo:'help'});SilverCollection.stats.log('');},getModules:function(){var modules=[];var module=null;Ext.each(Config.Default.Modules,function(){module=new(this.module)(Ext.applyIf({config:this.config}||{}));modules.push(module);});return(modules);},hints:function(){var msgIndex=0;var msg=Ext.get('app-msg-hints'),msgInner=Ext.get('msg-inner'),active=null;msgInner.addClassOnOver('msg-over');function doUpdate(){msgInner.update(active.text);msg.fadeIn();}
function showMsg(index){if(!msgInner.hasClass('msg-over')){active=Config.Hint.msgs[index];if(msg.isVisible()){msg.fadeOut({callback:doUpdate});}else{doUpdate();}}}
var msgTask={run:function(){msgIndex=Config.Hint.msgs[msgIndex+1]?msgIndex+1:0;showMsg(msgIndex);},interval:Config.Hint.delay}
Ext.TaskMgr.start(msgTask);},stats:{enabled:true,log:function(pageView){if(typeof pageTracker!='undefined'){pageTracker._trackPageview('SilverCollection/'+pageView);}}}});

Ext.namespace('SilverCollection.plugins');SilverCollection.plugins.SpecimenInfo=function(config){Ext.apply(this,config,{title:Lang.Get('Core','specimen','generalTitle'),region:'center'});SilverCollection.plugins.SpecimenInfo.superclass.constructor.call(this,config);};Ext.extend(SilverCollection.plugins.SpecimenInfo,Ext.Panel,{init:function(tabs){tabs.add(this);tabs.activate(0);tabs.on('render',this.onInitView,this);},onInitView:function(tabs){this.mask=new Ext.LoadMask(this.ownerCt.ownerCt.body,{msg:Lang.Get('Core','specimen','loading'),removeMask:true});this.mask.show();var conn=new Ext.data.Connection();conn.request({url:'server/specimen.php',method:'POST',scope:this,params:tabs.ownerCt.data,success:function(responseObject){var record=Ext.decode(responseObject.responseText);if(record.success){this.ownerCt.ownerCt.setTitle(Lang.Get('Core','specimen','title')+': '+record.data.GlobalUniqueIdentifier);Config.Default.Specimen.Info_tpl.overwrite(this.body,record.data);}
this.ownerCt.ownerCt.fireEvent('afterDataLoad',record.data);this.mask.hide();},failure:function(){this.mask.hide();Ext.Msg.alert('Status','Could not load specimen data.');}});}});

Ext.namespace('SilverCollection.plugins');SilverCollection.plugins.SpecimenSheet=function(config){Ext.apply(this,config,{title:Lang.Get('Core','specimen','SpecimenSheetTitle'),iconCls:'icon_picture',region:'center'});SilverCollection.plugins.SpecimenSheet.superclass.constructor.call(this,config);};Ext.extend(SilverCollection.plugins.SpecimenSheet,Ext.Panel,{init:function(tabs){tabs.add(this);tabs.activate(0);tabs.on('render',this.onInitView,this);},onInitView:function(tabs){this.ownerCt.ownerCt.on('afterDataLoad',function(specimen){if(specimen.specimen_sheet_image==null){this.setDisabled(true);}else{Config.Default.Specimen.SpecimenSheet_tpl.overwrite(this.body,specimen);this.ownerCt.ownerCt.getBottomToolbar().addItem(new Ext.Toolbar.Button({text:Lang.Get('Core','specimen','view_specimen'),iconCls:'icon_picture',scope:this,handler:function(){window.open('specimenimage/'+this.ownerCt.ownerCt.data.CatalogNumber,'_blank');}}));}},this);}});

Ext.namespace('SilverCollection.plugins');SilverCollection.plugins.SpecimenClimate=function(config){Ext.apply(this,config,{title:Lang.Get('Core','specimen','Climate'),autoScroll:true,header:false,border:false,enableColumnMove:false,enableColumnHide:false,ds:new Ext.data.Store({proxy:new Ext.data.HttpProxy({url:'server/iwmi.php'}),reader:new Ext.data.JsonReader({root:'records',totalProperty:'totalCount'},Ext.data.Record.create([{name:'month'},{name:'p50',type:'float'},{name:'rainfall',type:'float'},{name:'daysRain',type:'float'},{name:'temp',type:'float'},{name:'dtr',type:'float'},{name:'daysFrost',type:'float'},{name:'humid',type:'float'},{name:'sunshine',type:'float'},{name:'wind',type:'float'},{name:'mai',type:'float'},{name:'penman',type:'float'}])),remoteSort:false,listeners:{'loadexception':function(a,b,c,d){Ext.Msg.alert('Status','Error - Load Exception.');}}}),cm:new Ext.grid.ColumnModel([{sortable:true,header:'&nbsp;',dataIndex:'month',width:45,renderer:this.months},{sortable:true,header:'P50',tooltip:'Mm/month',dataIndex:'p50',width:48,align:'right'},{sortable:true,header:"Rainfall",tooltip:'(P75) mm/month',dataIndex:'rainfall',width:53,align:'right'},{sortable:true,header:'Days w/Rain',tooltip:'days/month',dataIndex:'daysRain',width:72,align:'right'},{sortable:true,header:'Temp',tooltip:'(mean) deg. C',dataIndex:'temp',width:42,align:'right'},{sortable:true,header:'DTR',tooltip:'deg. C',dataIndex:'dtr',width:40,align:'right'},{sortable:true,header:'Days w/Frost',tooltip:'days/month',dataIndex:'daysFrost',width:77,align:'right'},{sortable:true,header:'Ref Humid',tooltip:'%',dataIndex:'humid',width:60,align:'right'},{sortable:true,header:'Sunshine',tooltip:'% of Hours',dataIndex:'sunshine',width:60,align:'right'},{sortable:true,header:'Wind Run',tooltip:'m/s',dataIndex:'wind',width:60,align:'right'},{sortable:true,header:'MAI',dataIndex:'mai',width:38,align:'right'},{sortable:true,header:'Penman ETo',tooltip:'mm/day',dataIndex:'penman',width:70,align:'right'}]),viewConfig:{forceFit:false,emptyText:'<div style="text-align:center; padding:20px">No Climate Data Available</div>',deferEmptyText:false},selModel:new Ext.grid.RowSelectionModel({singleSelect:true}),bbar:new Ext.StatusBar({text:'Data served from: IWMI On-Line Climate Summary Service',items:[{text:'More Info',iconCls:'icon_info',handler:function(){window.open('http://www.iwmi.cgiar.org/WAtlas/synthesizer.htm','_blank');}}]})});SilverCollection.plugins.SpecimenClimate.superclass.constructor.call(this,config);};Ext.extend(SilverCollection.plugins.SpecimenClimate,Ext.grid.GridPanel,{init:function(tabs){tabs.add(this);tabs.activate(0);tabs.on('render',this.onInitView,this);},onInitView:function(tabs){this.ownerCt.ownerCt.on('afterDataLoad',function(specimen){this.store.load({params:{GlobalUniqueIdentifier:specimen.GlobalUniqueIdentifier,DecimalLatitude:specimen.DecimalLatitude,DecimalLongitude:specimen.DecimalLongitude}});},this);},months:function(value){var months=new Array(12);months[1]='Jan';months[2]='Feb';months[3]='Mar';months[4]='Apr';months[5]='May';months[6]='Jun';months[7]='Jul';months[8]='Aug';months[9]='Sep';months[10]='Oct';months[11]='Nov';months[12]='Dec';return(months[value]);}});

Ext.namespace('SilverCollection.plugins');SilverCollection.plugins.Coordinates=function(config){this.sb=new Ext.StatusBar();Ext.apply(this,config,{title:Lang.Get('Core','specimen','Coordinates'),iconCls:'icon_distribution',region:'center',zoomLevel:9,gmapType:'map',featureConfig:['enableContinuousZoom','enableScrollWheelZoom'],controls:[new GLargeMapControl(),new GScaleControl(),new GMapTypeControl()],bbar:this.sb,listeners:{'show':function(){var dt=new Ext.util.DelayedTask();dt.delay(300,function(){this.gmap.panTo(this.firstPoint);},this);}}});SilverCollection.plugins.Coordinates.superclass.constructor.call(this,config);};Ext.extend(SilverCollection.plugins.Coordinates,Ext.ux.GMapPanel,{init:function(tabs){tabs.add(this);tabs.activate(0);tabs.on('render',this.onInitView,this);},onInitView:function(tabs){this.ownerCt.ownerCt.on('afterDataLoad',function(specimen){this.specimen=specimen;if(this.specimen.DecimalLatitude==0&&(this.specimen.biogeomancer==null||this.specimen.biogeomancer=='[]')){this.setDisabled(true);}else{if(typeof(this.gmap)!='undefined'){var baseIcon=new GIcon();baseIcon.iconSize=new GSize(16,16);baseIcon.shadowSize=new GSize(28,16);baseIcon.iconAnchor=new GPoint(8,16);baseIcon.infoWindowAnchor=new GPoint(8,0);var green_dot=new GIcon(baseIcon,"images/icons/icon19.png",null,null);GEvent.addListener(this.gmap,"moveend",function(){var center=this.gmap.getCenter();this.sb.setStatus({text:'Google Map Center Coordinates: '+center.toString()});}.createDelegate(this));var tpl="<font size=1 face=verdana><b>Unique Identifier:</b> "+this.specimen.GlobalUniqueIdentifier+"<br><b>State:</b> "+this.specimen.StateProvince+"<br><b>County:</b> "+this.specimen.County+"<br><b>Family:</b> "+this.specimen.Family+"<br><b>Species:</b> "+this.specimen.Genus+" "+this.specimen.SpecificEpithet+"<br><b>Coordinates:</b> ("+this.specimen.DecimalLatitude+","+this.specimen.DecimalLongitude+")</font>";if(this.specimen.DecimalLatitude!=0){var point=new GLatLng(this.specimen.DecimalLatitude,this.specimen.DecimalLongitude);this.firstPoint=point;var tmpMarker=this.addMarker(point,null,false,true);GEvent.addListener(tmpMarker,"click",function(){tmpMarker.openInfoWindowHtml(tpl);});}else{var points=Ext.decode(this.specimen.biogeomancer);Ext.each(points,function(point){var tpl2="<font size=1 face=verdana><b>-= Estimate from Biogeomancer =-</b><br><b>Uncertainty:</b> "+point.CoordinateUncertaintyInMeters+" meters<br><b>Unique Identifier:</b> "+this.specimen.GlobalUniqueIdentifier+"<br><b>State:</b> "+this.specimen.StateProvince+"<br><b>County:</b> "+this.specimen.County+"<br><b>Family:</b> "+this.specimen.Family+"<br><b>Species:</b> "+this.specimen.Genus+" "+this.specimen.SpecificEpithet+"<br><b>Coordinates:</b> ("+point.DecimalLatitude+","+point.DecimalLongitude+")</font>";var gPoint=new GLatLng(point.DecimalLatitude,point.DecimalLongitude);this.firstPoint=gPoint;var tmpMarker=this.addMarker(gPoint,green_dot,false,true);this.drawCircle('KM',point.CoordinateUncertaintyInMeters/1000,gPoint);GEvent.addListener(tmpMarker,"click",function(){tmpMarker.openInfoWindowHtml(tpl2);});},this);}}}},this);}});

Ext.namespace('SilverCollection.plugins');SilverCollection.plugins.SpecimenAnnotation=function(config){Ext.apply(this,config,{title:Lang.Get('Core','specimen','Annotation'),iconCls:'icon_info',region:'center',header:false,border:false,enableColumnMove:false,enableColumnHide:false,ds:new Ext.data.Store({proxy:new Ext.data.HttpProxy({url:'server/comments.php'}),reader:new Ext.data.JsonReader({root:'records',totalProperty:'totalCount',id:'commentID'},Ext.data.Record.create([{name:'description'},{name:'dateAdded',type:'date',dateFormat:'Y-m-d H:i:s'}])),remoteSort:false}),cm:new Ext.grid.ColumnModel([{sortable:false,header:"Comment",dataIndex:'description',renderer:this.blob,width:300},{sortable:false,header:"Date Posted",dataIndex:'dateAdded',renderer:this.formatDateTime}]),tbar:[{text:'Add Annotation/Comment',iconCls:'icon_comment_add',scope:this,handler:function(){var comment=new SilverCollection.Annotation(this.specimen.GlobalUniqueIdentifier);comment.show();}}],viewConfig:{forceFit:true},selModel:new Ext.grid.RowSelectionModel({singleSelect:false})});SilverCollection.plugins.SpecimenAnnotation.superclass.constructor.call(this,config);};Ext.extend(SilverCollection.plugins.SpecimenAnnotation,Ext.grid.GridPanel,{init:function(tabs){tabs.add(this);tabs.activate(0);tabs.on('render',this.onInitView,this);},onInitView:function(tabs){this.ownerCt.ownerCt.on('afterDataLoad',function(specimen){this.specimen=specimen;this.store.load({baseParams:specimen.GlobalUniqueIdentifier});},this);},formatDateTime:function(value){if(value=="Wed Dec 31 1969 18:00:00 GMT-0600 (Central Standard Time)")
return(null);return value?value.dateFormat('M d, Y'):'';},blob:function(value){return('<div style="white-space:pre">'+value+'</div>');}});

Ext.namespace('SilverCollection.plugins');SilverCollection.plugins.Download=function(config){Ext.apply(this,config,{text:Lang.Get('Core','general','download'),tooltip:Lang.Get('Core','general','download_tooltip'),iconCls:'icon_download',handler:function(){ds=this.ownerCt.store;if(ds.getCount()>0){SilverCollection.stats.log('Download');ds.baseParams.api=2;var src=ds.proxy.conn.url+"?"+Ext.urlEncode(ds.baseParams);Ext.get("download").dom.src=src;delete(ds.baseParams.api);}else{Ext.MessageBox.alert(Lang.Get('Core','general','error'),Lang.Get('Core','general','download_error'));}}});SilverCollection.plugins.Download.superclass.constructor.call(this,config);};Ext.extend(SilverCollection.plugins.Download,Ext.Toolbar.Button,{init:function(tb){tb.on('render',this.onInitView,this);},onInitView:function(tb){this.ownerCt=tb;tb.add('-',this);}});

Ext.namespace('SilverCollection.plugins');SilverCollection.plugins.Email=function(config){Ext.apply(this,config,{text:Lang.Get('Core','general','email'),tooltip:Lang.Get('Core','general','email_tooltip'),iconCls:'icon_email',handler:function(){ds=this.ownerCt.store;if(ds.getCount()>0){var email=new SilverCollection.Email(ds.proxy.conn.url,ds);email.show();}else{Ext.MessageBox.alert(Lang.Get('Core','general','error'),Lang.Get('Core','general','email_error'));}}});SilverCollection.plugins.Download.superclass.constructor.call(this,config);};Ext.extend(SilverCollection.plugins.Email,Ext.Toolbar.Button,{init:function(tb){tb.on('render',this.onInitView,this);},onInitView:function(tb){this.ownerCt=tb;tb.add('-',this);}});

SilverCollection.Browse=Ext.extend(Ext.app.Module,{init:function(){this.launcher={text:Lang.Get('Core','browse','title'),iconCls:'icon_browse',handler:this.createWindow,scope:this,windowId:++SilverCollection.windowIndex}},createWindow:function(src){var desktop=this.app.getDesktop();var win=desktop.getWindow('browse_'+src.windowId);if(!win){var browse_tree=new Ext.tree.TreePanel({title:Lang.Get('Core','browse','tree_title'),region:'west',width:275,useArrows:true,split:true,rootVisible:false,autoScroll:true,border:false,loader:new Ext.tree.TreeLoader({dataUrl:'server/browse.php',baseParams:{lib:'browse',key:Config.key},listeners:{'loadexception':function(loader,node,response){}}}),tools:[{id:'refresh',qtip:{text:Lang.Get('Core','browse','refresh')},on:{click:function(){var list=browse_tree.getChecked();for(i=0;i<list.length;i++){list[i].attributes.checked=false;list[i].getUI().toggleCheck();}
if(list.length!=0)
specimens_grid.store.load();}}}],listeners:{'beforeLoad':function(node){var filter=node.attributes.filter;this.loader.baseParams=Ext.apply(this.loader.baseParams,{nodeApi:node.attributes.nodeApi,nodeValue:node.attributes.nodeValue,path:node.attributes.path,filter:filter});if(node.attributes.nodeApi!='root'){var value=node.attributes.nodeValue;if(node.attributes.nodeValue==null){value='';}
SilverCollection.stats.log('Browse/'+node.attributes.nodeApi+'/'+value);}},'checkchange':function(node,checked){if(checked){SilverCollection.stats.log('View/'+node.attributes.nodeApi+'/'+node.attributes.nodeValue);}
specimens_grid.store.load();}}});var root=new Ext.tree.AsyncTreeNode({nodeApi:'root',nodeValue:null,path:'{}',filter:'{}'});browse_tree.setRootNode(root);root.expand(false,false);var specimens_grid=new SilverCollection.Grid.Specimens(Config.Default.Grid.Specimens);specimens_grid.store.on('beforeload',function(){var selected=browse_tree.getChecked();var output='';var filter;for(var i=0;i<selected.length;i++){filter=selected[i].attributes.filter;if(i!=0)
output+=',';output+=String.format('{ "node_type":"{0}", "node_value":"{1}", "filter":{2}, "path":"{3}"}',selected[i].attributes.nodeApi,selected[i].attributes.nodeValue,filter,selected[i].parentNode.attributes.path);}
this.baseParams.browse="["+output+"]";this.baseParams.key=Config.key});SilverCollection.stats.log('Browse');win=desktop.createWindow({id:'browse_'+src.windowId,title:src.text,width:640,height:480,iconCls:src.iconCls,shim:false,animCollapse:false,constrainHeader:true,layout:'border',items:[browse_tree,specimens_grid],listeners:{'show':function(){this.getKeyMap().disable();}}});win.maximize();}
win.show();}});

Ext.namespace('SilverCollection.Grid');SilverCollection.Grid.Specimens=function(config){Ext.each(config.cm,function(column){if(column.renderer){column.renderer=eval(column.renderer);}},this);this.cm=new Ext.grid.ColumnModel(config.cm);this.cm.defaultSortable=true;this.ds=new Ext.data.GroupingStore({proxy:new Ext.data.HttpProxy({url:'server/species_search.php',timeout:60000}),reader:new Ext.data.JsonReader({root:'records',totalProperty:'totalCount'},config.recordType),remoteSort:true,sortInfo:config.sortInfo,groupField:config.groupField});var extensions=[];Ext.each(config.extensions,function(){extensions.push(new(this));});config={region:'center',border:false,enableColumnMove:false,enableColumnHide:false,store:this.ds,cm:this.cm,sm:new Ext.grid.RowSelectionModel({singleSelect:true}),loadMask:true,view:new Ext.grid.GroupingView({forceFit:false,emptyText:Lang.Get('Core','grid_specimens','emptyText'),deferEmptyText:false,groupTextTpl:'{text} ({[values.rs.length]} {[values.rs.length > 1 ? "'+Lang.Get('Core','grid_specimens','grouping_plural')+'" : "'+Lang.Get('Core','grid_specimens','grouping_singular')+'"]})',getRowClass:function(record,index){if(record.data.iucn_redlist_type!=''&&record.data.iucn_redlist_type!=null){return'iucn_redlist';}}}),bbar:new Ext.PagingToolbar({pageSize:100,store:this.ds,displayInfo:true,displayMsg:Lang.Get('Core','grid_specimens','pb_displayMsg'),emptyMsg:Lang.Get('Core','grid_specimens','pb_emptyMsg'),plugins:extensions}),listeners:{'celldblclick':function(grid,row,column){this.viewSpecimen(grid,row,column);},'rowcontextmenu':function(grid,row,e){grid.getSelectionModel().selectRow(row);var record=grid.getSelectionModel().getSelected().data;var items=[];items.push({text:'View Details',iconCls:'icon_specimen_details',scope:this,handler:function(){this.viewSpecimen(grid,row,null);}});items.push({text:'Printable Format',iconCls:'icon_printer',handler:function(){window.open('specimen/'+record.CatalogNumber,'_blank');}});items.push('-');if(record.iucn_redlist_type!=''){items.push({text:'IUCN: '+record.iucn_redlist_type,style:'background-color: #FDC4C4',handler:function(){window.open('http://www.iucnredlist.org/search/details.php/33892/summ','_blank');}});}
items.push({text:'ITIS: Catalog of Life',handler:function(){window.open('http://www.catalogueoflife.org/annual-checklist/search_results.php?search_string='+record.Genus+'+'+record.SpecificEpithet+'&match_whole_words=on','_blank');}});items.push({text:'International Plant Names Index',handler:function(){window.open('http://www.ipni.org/ipni/advPlantNameSearch.do?find_infraspecies=&find_infragenus=&find_publicationTitle=&find_includePublicationAuthors=on&find_isIKRrecord=on&find_species='+record.SpecificEpithet+'&find_isGCIRecord=on&find_authorAbbrev=&find_includeBasionymAuthors=on&find_infrafamily=&find_genus='+record.Genus+'&find_family=&find_isAPNIRecord=on','_blank');}});items.push({text:'GBIF',handler:function(){window.open('http://data.gbif.org/search/'+record.Genus+'+'+record.SpecificEpithet+'?','_blank');}});items.push({text:'Flora of North America',handler:function(){window.open('http://www.efloras.org/browse.aspx?name_str='+record.Genus+'+'+record.SpecificEpithet,'_blank');}});items.push({text:'NatureServe',handler:function(){window.open('http://www.natureserve.org/explorer/servlet/NatureServe?searchName='+record.Genus+'+'+record.SpecificEpithet,'_blank');}});items.push({text:'Tropicos',handler:function(){window.open('http://www.tropicos.org/NameSearch.aspx?name='+record.Genus+'+'+record.SpecificEpithet,'_blank');}});items.push('-');items.push({text:'Google Images',handler:function(){window.open('http://www.google.com/images?safe=yes&q=%22'+record.Genus+'+'+record.SpecificEpithet+'%22','_blank');}});items.push({text:'PicSearch',handler:function(){window.open('http://www.picsearch.com/search.cgi?q=%22'+record.Genus+'+'+record.SpecificEpithet+'%22&cols=5&thumbs=20','_blank');}});var menu=new Ext.menu.Menu({items:items});var xy=e.getXY();menu.showAt(xy);}}}
SilverCollection.Grid.Specimens.superclass.constructor.call(this,config);}
Ext.extend(SilverCollection.Grid.Specimens,Ext.grid.GridPanel,{renderCollector:function(value,p,r){var tmp="";var tmp2="";if(r.data['associated']!='')
tmp="<br>"+r.data['associated'];if((r.data['collected']!='Wed Dec 31 1969 17:59:59 GMT-0600 (Central Standard Time)')&&(r.data['collected']!=''))
tmp2="<br>Collected: "+r.data['collected'].dateFormat('d M Y');return String.format('{0}{1}{2}',value,tmp,tmp2);},renderImageAvail:function(value){switch(value){case'1':html='<img qtip="Specimen Sheet Image Available" src=\"images/icons/picture.png\">';break;case'2':html='<img qtip="Specimen Sheet Image Available" src=\"images/icons/picture_add.png\">';break;default:html='';break;}
return(html);},renderllAvail:function(value){switch(value){case 1:html='<img qtip="Georeference provided by Collector" src=\"images/icons/map.png\">';break;case 2:html='<img qtip="Georeference estimate from Biogeomancer" src=\"images/icons/map_est.png\">';break;default:html='';break;}
return(html);},viewSpecimen:function(grid,row,column){var data=this.getSelections()[0].data;if(!Ext.isEmpty(data.CatalogNumber)){var desktop=SilverCollection.getDesktop();var win=desktop.getWindow('specimen_'+data.CatalogNumber);if(!win){Config.Default.Specimen.Window.data=data;var specimen=desktop.createWindow(Config.Default.Specimen.Window,SilverCollection.SpecimenPanel);specimen.show();}else{win.show();}}else{Ext.MessageBox.alert(Lang.Get('Core','general','error'),Lang.Get('Core','grid_specimens','error_collection_num'));}}});

SilverCollection.SpecimenPanel=function(config){var extensions=[];var buttons=[];Ext.each(config.extensions,function(){var extension=new(this.module)(Ext.applyIf({config:this.config}||{}));extensions.push(extension);});buttons.push({text:Lang.Get('Core','specimen','print'),iconCls:'icon_printer',handler:function(){window.open('specimen/'+config.data.CatalogNumber,'_blank');}});var tp=new Ext.TabPanel({resizeTabs:false,deferredRender:false,border:false,minTabWidth:75,enableTabScroll:true,defaults:{autoScroll:true},plugins:extensions});Ext.apply(this,config,{region:'center',layout:'fit',id:'specimen_'+config.data.CatalogNumber,width:300,height:500,onEsc:Ext.emptyFn,items:[tp],bbar:buttons});SilverCollection.SpecimenPanel.superclass.constructor.apply(this,arguments);};Ext.extend(SilverCollection.SpecimenPanel,Ext.Window,{});Ext.reg('SC_SpecimenPanel',SilverCollection.SpecimenPanel);

SilverCollection.Annotation=function(record_id){var comment_form=new Ext.FormPanel({labelWidth:75,region:'center',labelAlign:'left',bodyStyle:'padding: 5px 5px 0',border:false,items:[{xtype:'hidden',name:'GlobalUniqueIdentifier',value:record_id},{xtype:'textfield',fieldLabel:Lang.Get('Core','annotation','name'),name:'name',allowBlank:false,width:230},{xtype:'textfield',fieldLabel:Lang.Get('Core','annotation','email'),name:'email',vtype:'email',allowBlank:false,width:230},{xtype:'textarea',fieldLabel:Lang.Get('Core','annotation','message'),id:'msg',width:230,allowBlank:false,maxLength:4000},{xtype:'recaptcha',name:'recaptcha',id:'recaptcha',publickey:Config.recaptcha.publickey,theme:'white',lang:'en'}]});SilverCollection.Annotation.superclass.constructor.call(this,{title:Lang.Get('Core','annotation','title'),iconCls:'icon_comment',closable:true,width:345,height:335,resizable:false,plain:true,modal:true,onEsc:Ext.emptyFn,layout:'border',items:[comment_form],buttons:[{text:Lang.Get('Core','annotation','send'),scope:this,handler:function(){if(comment_form.form.isValid()){var conn=new Ext.data.Connection();conn.request({url:'server/save_comment.php',method:'POST',scope:this,params:comment_form.form.getValues(),success:function(responseObject){var o=Ext.decode(responseObject.responseText);if(o.success){Ext.Msg.alert(Lang.Get('Core','annotation','status'),Lang.Get('Core','annotation','sent'));this.close();}else{Ext.Msg.alert(Lang.Get('Core','annotation','status'),Lang.Get('Core','annotation','error')+'\r\n'+o.errorMsg);}},failure:function(){Ext.Msg.alert(Lang.Get('Core','annotation','status'),Lang.Get('Core','annotation','error'));}});}else{comment_form.form.markInvalid();}}},{text:Lang.Get('Core','annotation','cancel'),scope:this,handler:this.close}]});};Ext.extend(SilverCollection.Annotation,Ext.Window,{});

SilverCollection.Email=function(server_file,ds){var email_form=new Ext.FormPanel({labelWidth:60,region:'center',labelAlign:'left',bodyStyle:'padding: 5px 5px 0',border:false,items:[{xtype:'textfield',fieldLabel:Lang.Get('Core','email','email'),name:'email',vtype:'email',allowBlank:false,width:240},{xtype:'textarea',fieldLabel:Lang.Get('Core','email','message'),id:'msg',width:240,maxLength:4000},{xtype:'recaptcha',name:'recaptcha',id:'recaptcha',publickey:Config.recaptcha.publickey,theme:'white',lang:'en'}]});SilverCollection.Email.superclass.constructor.call(this,{title:Lang.Get('Core','general','email'),iconCls:'icon_email',closable:true,width:350,height:300,resizable:false,modal:true,layout:'border',onEsc:Ext.emptyFn,items:[email_form],buttons:[{text:'Send Data',scope:this,handler:function(){if(email_form.form.isValid()){var tmp=email_form.form.getValues();var params={};Ext.apply(params,{email_email:tmp.email,email_msg:tmp.msg,recaptcha_challenge_field:tmp.recaptcha_challenge_field,recaptcha_response_field:tmp.recaptcha_response_field,api:3},ds.baseParams);var conn=new Ext.data.Connection();conn.request({url:server_file,method:'POST',scope:this,params:params,success:function(responseObject){var o=Ext.decode(responseObject.responseText);if(o.success){Ext.Msg.alert(Lang.Get('Core','email','email_status'),Lang.Get('Core','email','email_success'));this.close();}else{Recaptcha.reload();Recaptcha.focus_response_field();Ext.Msg.alert(Lang.Get('Core','email','email_status'),Lang.Get('Core','email','email_failure')+'\r\n'+o.errorMsg);}},failure:function(){Ext.Msg.alert(Lang.Get('Core','email','email_status'),Lang.Get('Core','email','email_failure'));}});}else{email_form.form.markInvalid();}}},{text:Lang.Get('Core','email','cancel'),scope:this,handler:this.close}]});SilverCollection.stats.log('Email');};Ext.extend(SilverCollection.Email,Ext.Window,{});

SilverCollection.Search=Ext.extend(Ext.app.Module,{init:function(){this.launcher={text:Lang.Get('Core','search','title'),iconCls:'icon_search',handler:this.createWindow,scope:this,windowId:++SilverCollection.windowIndex}},createWindow:function(src){var desktop=this.app.getDesktop();var win=desktop.getWindow('search_'+src.windowId);if(!win){var search_form=new Ext.FormPanel({labelWidth:90,url:'server/search.php',frame:false,title:Lang.Get('Core','search','filters'),autoScroll:true,bodyStyle:'padding:5px 5px 0',width:250,region:'west',border:false,split:true,maxSize:250,minSize:250,defaults:{width:125},defaultType:'textfield',items:Config.Default.Filter.filters,bbar:['->',{text:Lang.Get('Core','search','reset_filters'),iconCls:'icon_refresh',handler:function(){search_form.form.reset();specimens_grid.store.load();}}]});var specimens_grid=new SilverCollection.Grid.Specimens(Config.Default.Grid.Specimens);specimens_grid.store.on('beforeload',function(){this.baseParams={key:Config.key,filters:Ext.encode(search_form.form.getValues())}});search_form.grid=specimens_grid;win=desktop.createWindow({id:'search_'+src.windowId,title:src.text,width:820,height:480,iconCls:src.iconCls,shim:false,animCollapse:false,constrainHeader:true,layout:'border',onEsc:Ext.emptyFn,items:[search_form,specimens_grid]});win.maximize();}
win.show();}});

SilverCollection.Checklist=Ext.extend(Ext.app.Module,{init:function(){this.launcher={text:Lang.Get('Core','checklist','title'),iconCls:'icon_checklist',handler:this.createWindow,scope:this,windowId:++SilverCollection.windowIndex}},createWindow:function(src){var desktop=this.app.getDesktop();var win=desktop.getWindow('checklist_'+src.windowId);if(!win){var checklist_tree=new Ext.tree.TreePanel({width:260,title:Lang.Get('Core','checklist','tree_title'),rootVisible:false,autoScroll:true,useArrows:true,loader:new Ext.tree.TreeLoader({dataUrl:'server/checklist.php',baseParams:{type:'tree'}}),bbar:['->',{text:Lang.Get('Core','checklist','reset_loc'),iconCls:'icon_refresh',handler:function(){Ext.each(checklist_tree.getChecked(),function(){this.getUI().toggleCheck();this.attributes.checked=false;});ds.load();}}],listeners:{'beforeLoad':function(node){var value=node.attributes.nodeValue;if(value==null)value='';SilverCollection.stats.log('Checklist/Browse/'+node.attributes.nodeApi+'/'+value);this.loader.baseParams=Ext.apply(this.loader.baseParams,node.attributes);},'checkchange':function(node){SilverCollection.stats.log('Checklist/View/'+node.attributes.nodeValue);switch(checklist_tabs2.getActiveTab().getId()){case'checklist':ds.load(this);break;case'regional_biodiversity':var config=[];Ext.apply(config,Config.Default.Checklist.biodiversity_cm);var index=0;Ext.each(checklist_tree.getChecked(),function(){config.push({header:"Region "+(index+1),tooltip:this.attributes.nodeValue,dataIndex:'R'+index,width:70,sortable:false,renderer:render_region});index++;});checklist_regional.getColumnModel().setConfig(config);regional_ds.load(this);break;}}}},this);var root=new Ext.tree.AsyncTreeNode({nodeApi:'Regions',nodeValue:null,path:'{}',filter:'{}'});checklist_tree.setRootNode(root);root.expand(false,false);var checklist_filters=new Ext.FormPanel({labelWidth:80,title:Lang.Get('Core','checklist','filter_title'),bodyStyle:'padding:5px 5px 0',defaults:{width:125},defaultType:'textfield',items:Config.Default.Checklist.Filter.filters,bbar:['->',{text:'Reset Filters',iconCls:'icon_refresh',handler:function(){checklist_filters.form.reset();regional_ds.load(this);}}],updateGrid:function(){switch(checklist_tabs2.getActiveTab().getId()){case'checklist':ds.load(this);break;case'regional_biodiversity':regional_ds.load(this);break;}}});var checklist_tabs=new Ext.TabPanel({activeTab:1,deferredRender:false,split:true,region:'west',width:260,defaults:{autoScroll:true},items:[checklist_tree,checklist_filters]});var ds=new Ext.data.GroupingStore({sortInfo:{field:'Family',direction:'ASC'},proxy:new Ext.data.HttpProxy({url:'server/checklist.php',timeout:60000}),reader:new Ext.data.JsonReader({root:'records',totalProperty:'totalCount',id:'record_id'},Config.Default.Checklist.recordType),listeners:{'loadexception':function(){Ext.Msg.alert(Lang.Get('Core','general','error'),Lang.Get('Core','general','load_exception'));},'beforeload':function(){var values=[];Ext.each(checklist_tree.getChecked(),function(){values.push(Ext.apply({nodeValue:this.attributes.nodeValue,nodeApi:this.attributes.nodeApi}));});this.baseParams={api:1,filters:Ext.encode(checklist_filters.form.getValues()),type:'search',values:Ext.encode(values)}}},remoteSort:true});var cm=new Ext.grid.ColumnModel(Config.Default.Checklist.cm);function loadData(){ds.load();}
var extensions=[];Ext.each(Config.Default.Checklist.Grid.extensions,function(){extensions.push(new(this));});var checklist_data=new Ext.grid.GridPanel({title:Lang.Get('Core','checklist','tab_title'),id:'checklist',enableColumnMove:false,enableColumnHide:false,store:ds,cm:cm,sm:new Ext.grid.RowSelectionModel({singleSelect:true}),loadMask:true,view:new Ext.grid.GroupingView({forceFit:false,emptyText:Lang.Get('Core','checklist','emptyText'),deferEmptyText:false,groupTextTpl:'{text}'}),bbar:new Ext.PagingToolbar({pageSize:100,store:ds,displayInfo:true,displayMsg:Lang.Get('Core','checklist','pb_displayMsg'),emptyMsg:Lang.Get('Core','checklist','pb_emptyMsg'),plugins:extensions})});checklist_filters.grid=checklist_data;checklist_filters.grid2=checklist_regional;var regional_ds=new Ext.data.GroupingStore({sortInfo:Config.Default.Checklist.sortInfo,proxy:new Ext.data.HttpProxy({url:'server/checklist.php'}),reader:new Ext.data.JsonReader({root:'data.records',totalProperty:'totalCount',id:'record_id'},Config.Default.Checklist.biodiversity_recordType),listeners:{'loadexception':function(){Ext.Msg.alert(Lang.Get('Core','general','error'),Lang.Get('Core','general','load_exception'));},'beforeload':function(){var values=[];Ext.each(checklist_tree.getChecked(),function(){values.push(Ext.apply({nodeValue:this.attributes.nodeValue,nodeApi:this.attributes.nodeApi}));});this.baseParams={api:1,filters:Ext.encode(checklist_filters.form.getValues()),type:'region',values:Ext.encode(values)}}},remoteSort:true});render_region=function(qty,dom,row,index){if(qty=='0'){return('<div class="region_empty" />');}else{return('<div class="region_notempty"><sup>'+qty+'</sup></div>');}}
var extensions2=[];Ext.each(Config.Default.Checklist.Grid.extensions,function(){extensions2.push(new(this));});var checklist_regional=new Ext.grid.GridPanel({title:'Regional Biodiversity',id:'regional_biodiversity',enableColumnMove:false,enableColumnHide:false,store:regional_ds,cm:new Ext.grid.ColumnModel([]),loadMask:true,view:new Ext.grid.GroupingView({forceFit:false,emptyText:Lang.Get('Core','checklist','emptyText'),deferEmptyText:false,groupTextTpl:'{text}'}),bbar:new Ext.PagingToolbar({pageSize:100,store:regional_ds,displayInfo:true,displayMsg:Lang.Get('Core','checklist','pb_displayMsg'),emptyMsg:Lang.Get('Core','checklist','pb_emptyMsg'),plugins:extensions2})});var checklist_tabs2=new Ext.TabPanel({activeTab:0,id:'checklist_tabs2',region:'center',items:[checklist_data,checklist_regional],listeners:{'tabchange':function(tabpanel,tab){this.loadTab(tab,checklist_tree,checklist_regional);}.createDelegate(this)}});SilverCollection.stats.log('Checklist');win=desktop.createWindow({id:'checklist_'+src.windowId,title:src.text,width:820,height:490,iconCls:src.iconCls,shim:false,animCollapse:false,constrainHeader:true,layout:'border',defaults:{border:false},items:[checklist_tabs,checklist_tabs2],listeners:{'show':function(){this.getKeyMap().disable();}}});checklist_tabs.setActiveTab(0);win.maximize();}
win.show();},loadTab:function(tab,checklist_tree,checklist_regional){switch(tab.getId()){case'checklist':tab.store.load(this);break;case'regional_biodiversity':var config=[];Ext.apply(config,Config.Default.Checklist.biodiversity_cm);var index=0;Ext.each(checklist_tree.getChecked(),function(){config.push({header:"Region "+(index+1),tooltip:this.attributes.nodeValue,dataIndex:'R'+index,width:70,sortable:false,renderer:render_region});index++;});checklist_regional.getColumnModel().setConfig(config);checklist_regional.store.load(this);break;}}});

SilverCollection.ExternalLink=Ext.extend(Ext.app.Module,{init:function(){this.launcher={};Ext.apply(this.launcher,this.config,{scope:this,windowId:++SilverCollection.windowIndex,handler:function(){SilverCollection.stats.log('External/'+this.config.text);window.open(this.config.link,this.config.target||'_blank');}});}});

var RecaptchaTemplates={VertHtml:'<table id="recaptcha_table" class="recaptchatable" >\n<tr>\n<td colspan="6" class=\'recaptcha_r1_c1\'></td>\n</tr>\n<tr>\n<td class=\'recaptcha_r2_c1\'></td>\n<td colspan="4" class=\'recaptcha_image_cell\'><div id="recaptcha_image"></div></td>\n<td class=\'recaptcha_r2_c2\'></td>\n</tr>\n<tr>\n<td rowspan="6" class=\'recaptcha_r3_c1\'></td>\n<td colspan="4" class=\'recaptcha_r3_c2\'></td>\n<td rowspan="6" class=\'recaptcha_r3_c3\'></td>\n</tr>\n<tr>\n<td rowspan="3" class=\'recaptcha_r4_c1\' height="49">\n<div class="recaptcha_input_area">\n<label for="recaptcha_response_field" class="recaptcha_input_area_text"><span id="recaptcha_instructions_image" class="recaptcha_only_if_image recaptcha_only_if_no_incorrect_sol"></span><span id="recaptcha_instructions_audio" class="recaptcha_only_if_no_incorrect_sol recaptcha_only_if_audio"></span><span id="recaptcha_instructions_error" class="recaptcha_only_if_incorrect_sol"></span></label><br/>\n<input name="recaptcha_response_field" id="recaptcha_response_field" type="text" />\n</div>\n</td>\n<td rowspan="4" class=\'recaptcha_r4_c2\'></td>\n<td><a id=\'recaptcha_reload_btn\' tabindex=\'-1\'><img id=\'recaptcha_reload\' width="25" height="17" /></a></td>\n<td rowspan="4" class=\'recaptcha_r4_c4\'></td>\n</tr>\n<tr>\n<td><a id=\'recaptcha_switch_audio_btn\' tabindex=\'-1\' class="recaptcha_only_if_image"><img id=\'recaptcha_switch_audio\' width="25" height="16" alt="" /></a><a id=\'recaptcha_switch_img_btn\' tabindex=\'-1\' class="recaptcha_only_if_audio"><img id=\'recaptcha_switch_img\' width="25" height="16" alt=""/></a></td>\n</tr>\n<tr>\n<td><a id=\'recaptcha_whatsthis_btn\' tabindex=\'-1\'><img id=\'recaptcha_whatsthis\' width="25" height="16" /></a></td>\n</tr>\n<tr>\n<td class=\'recaptcha_r7_c1\'></td>\n<td class=\'recaptcha_r8_c1\'></td>\n</tr>\n</table>\n',VertCss:'.recaptchatable td img {\n/* see http://developer.mozilla.org/en/docs/Images%2C_Tables%2C_and_Mysterious_Gaps */\ndisplay: block;\n}\n.recaptchatable .recaptcha_r1_c1 { background: url(IMGROOT/sprite.png) -0px -63px no-repeat; width: 318px; height: 9px; }\n.recaptchatable .recaptcha_r2_c1 { background: url(IMGROOT/sprite.png) -18px -0px no-repeat; width: 9px; height: 57px; }\n.recaptchatable .recaptcha_r2_c2 { background: url(IMGROOT/sprite.png) -27px -0px no-repeat; width: 9px; height: 57px; }\n.recaptchatable .recaptcha_r3_c1 { background: url(IMGROOT/sprite.png) -0px -0px no-repeat; width: 9px; height: 63px; }\n.recaptchatable .recaptcha_r3_c2 { background: url(IMGROOT/sprite.png) -18px -57px no-repeat; width: 300px; height: 6px; }\n.recaptchatable .recaptcha_r3_c3 { background: url(IMGROOT/sprite.png) -9px -0px no-repeat; width: 9px; height: 63px; }\n.recaptchatable .recaptcha_r4_c1 { background: url(IMGROOT/sprite.png) -43px -0px no-repeat; width: 171px; height: 49px; }\n.recaptchatable .recaptcha_r4_c2 { background: url(IMGROOT/sprite.png) -36px -0px no-repeat; width: 7px; height: 57px; }\n.recaptchatable .recaptcha_r4_c4 { background: url(IMGROOT/sprite.png) -214px -0px no-repeat; width: 97px; height: 57px; }\n.recaptchatable .recaptcha_r7_c1 { background: url(IMGROOT/sprite.png) -43px -49px no-repeat; width: 171px; height: 8px; }\n.recaptchatable .recaptcha_r8_c1 { background: url(IMGROOT/sprite.png) -43px -49px no-repeat; width: 25px; height: 8px; }\n.recaptchatable .recaptcha_image_cell center img { height:57px;}\n.recaptchatable .recaptcha_image_cell center { height:57px;}\n.recaptchatable .recaptcha_image_cell {\nbackground-color:white; height:57px;\n}\n/* some people break their style sheet, we need to clean up after them */\n#recaptcha_area, #recaptcha_table {\nwidth: 318px !important;\n}\n.recaptchatable, #recaptcha_area tr, #recaptcha_area td, #recaptcha_area th {\nmargin:0px !important;\nborder:0px !important;\npadding:0px !important;\nborder-collapse: collapse !important;\nvertical-align: middle !important;\n}\n.recaptchatable * {\nmargin:0px;\npadding:0px;\nborder:0px;\nfont-family:helvetica,sans-serif;\nfont-size:8pt;\ncolor:black;\nposition:static;\ntop:auto;\nleft:auto;\nright:auto;\nbottom:auto;\ntext-align:left !important;\n}\n.recaptchatable #recaptcha_image {\nmargin:auto;\n}\n.recaptchatable img {\nborder:0px !important;\nmargin:0px !important;\npadding:0px !important;\n}\n.recaptchatable a, .recaptchatable a:hover {\n-moz-outline:none;\nborder:0px !important;\npadding:0px !important;\ntext-decoration:none;\ncolor:blue;\nbackground:none !important;\nfont-weight: normal;\n}\n.recaptcha_input_area {\nposition:relative !important;\nwidth:146px !important;\nheight:45px !important;\nmargin-left:20px !important;\nmargin-right:5px !important;\nmargin-top:4px !important;\nbackground:none !important;\n}\n.recaptchatable label.recaptcha_input_area_text {\nmargin:0px !important;  \npadding:0px !important;\nposition:static !important;\ntop:auto !important;\nleft:auto !important;\nright:auto !important;\nbottom:auto !important;\nbackground:none !important;\nheight:auto !important;\nwidth:auto !important;\n}\n.recaptcha_theme_red label.recaptcha_input_area_text,\n.recaptcha_theme_white label.recaptcha_input_area_text {\ncolor:black !important;\n}\n.recaptcha_theme_blackglass label.recaptcha_input_area_text {\ncolor:white !important;\n}\n.recaptchatable #recaptcha_response_field  {\nwidth:145px !important;\nposition:absolute !important;\nbottom:7px !important;\npadding:0px !important;\nmargin:0px !important;\nfont-size:10pt;\n}\n.recaptcha_theme_blackglass #recaptcha_response_field,\n.recaptcha_theme_white #recaptcha_response_field {\nborder: 1px solid gray;\n}\n.recaptcha_theme_red #recaptcha_response_field {\nborder:1px solid #cca940;\n}\n.recaptcha_audio_cant_hear_link {\nfont-size:7pt;\ncolor:black;\n}\n.recaptchatable {\nline-height:1em;\n}\n#recaptcha_instructions_error {\ncolor:red !important;\n}\n',CleanHtml:'<table id="recaptcha_table" class="recaptchatable">\n<tr height="73">\n<td class=\'recaptcha_image_cell\' width="302"><center><div id="recaptcha_image"></div></center></td>\n<td style="padding: 10px 7px 7px 7px;">\n<a id=\'recaptcha_reload_btn\' tabindex=\'-1\'><img id=\'recaptcha_reload\' width="25" height="18" alt="" /></a>\n<a id=\'recaptcha_switch_audio_btn\' tabindex=\'-1\' class="recaptcha_only_if_image"><img id=\'recaptcha_switch_audio\' width="25" height="15" alt="" /></a><a id=\'recaptcha_switch_img_btn\' tabindex=\'-1\' class="recaptcha_only_if_audio"><img id=\'recaptcha_switch_img\' width="25" height="15" alt=""/></a>\n<a id=\'recaptcha_whatsthis_btn\' tabindex=\'-1\'><img id=\'recaptcha_whatsthis\' width="25" height="16" /></a>\n</td>\n<td style="padding: 18px 7px 18px 7px;">\n<img id=\'recaptcha_logo\' alt="" width="71" height="36" />\n</td>\n</tr>\n<tr>\n<td style="padding-left: 7px;">\n<div class="recaptcha_input_area" style="padding-top: 2px; padding-bottom: 7px;">\n<input style="border: 1px solid #3c3c3c; width: 302px;" name="recaptcha_response_field" id="recaptcha_response_field" type="text" />\n</div>\n</td>\n<td></td>\n<td style="padding: 4px 7px 12px 7px;">\n<img id="recaptcha_tagline" width="71" height="17" />\n</td>\n</tr>\n</table>\n',CleanCss:'.recaptchatable td img {\ndisplay: block;\n}\n.recaptchatable .recaptcha_image_cell center img { height:57px;}\n.recaptchatable .recaptcha_image_cell center { height:57px;}\n.recaptchatable .recaptcha_image_cell {\nbackground-color:white; height:57px; \npadding: 7px !important;\n}\n.recaptchatable, #recaptcha_area tr, #recaptcha_area td, #recaptcha_area th {\nmargin:0px !important;\nborder:0px !important;\nborder-collapse: collapse !important;\nvertical-align: middle !important;\n}\n.recaptchatable * {\nmargin:0px;\npadding:0px;\nborder:0px;\ncolor:black;\nposition:static;\ntop:auto;\nleft:auto;\nright:auto;\nbottom:auto;\ntext-align:left !important;\n}\n.recaptchatable #recaptcha_image {\nmargin:auto;\nborder: 1px solid #dfdfdf !important;\n}\n.recaptchatable a img {\nborder:0px;\n}\n.recaptchatable a, .recaptchatable a:hover {\n-moz-outline:none;\nborder:0px !important;\npadding:0px !important;\ntext-decoration:none;\ncolor:blue;\nbackground:none !important;\nfont-weight: normal;\n}\n.recaptcha_input_area {\nposition:relative !important;\nbackground:none !important;\n}\n.recaptchatable label.recaptcha_input_area_text {\nborder:1px solid #dfdfdf !important;\nmargin:0px !important;  \npadding:0px !important;\nposition:static !important;\ntop:auto !important;\nleft:auto !important;\nright:auto !important;\nbottom:auto !important;\n}\n.recaptcha_theme_red label.recaptcha_input_area_text,\n.recaptcha_theme_white label.recaptcha_input_area_text {\ncolor:black !important;\n}\n.recaptcha_theme_blackglass label.recaptcha_input_area_text {\ncolor:white !important;\n}\n.recaptchatable #recaptcha_response_field  {\nfont-size:11pt;\n}\n.recaptcha_theme_blackglass #recaptcha_response_field,\n.recaptcha_theme_white #recaptcha_response_field {\nborder: 1px solid gray;\n}\n.recaptcha_theme_red #recaptcha_response_field {\nborder:1px solid #cca940;\n}\n.recaptcha_audio_cant_hear_link {\nfont-size:7pt;\ncolor:black;\n}\n.recaptchatable {\nline-height:1em;\nborder: 1px solid #dfdfdf !important;\n}\n.recaptcha_error_text {\ncolor:red;\n}\n'};var RecaptchaStr_en={visual_challenge:"Get a visual challenge",audio_challenge:"Get an audio challenge",refresh_btn:"Get a new challenge",instructions_visual:"Type the two words:",instructions_audio:"Type the eight numbers:",help_btn:"Help",cant_hear_this:"Can't hear the sound?",incorrect_try_again:"Incorrect. Try again."};var RecaptchaStr_de={visual_challenge:"Visuelle Aufgabe generieren",audio_challenge:"Audio-Aufgabe generieren",refresh_btn:"Neue Aufgabe generieren",instructions_visual:"Gib die 2 W\u00f6rter ein:",instructions_audio:"Gib die 8 Ziffern ein:",help_btn:"Hilfe",cant_hear_this:"Kannst du nichts h\u00f6ren?",incorrect_try_again:"Falsch. Nochmals versuchen!"};var RecaptchaStr_es={visual_challenge:"Obt\u00e9n un reto visual",audio_challenge:"Obt\u00e9n un reto audible",refresh_btn:"Obt\u00e9n un nuevo reto",instructions_visual:"Escribe las 2 palabras:",instructions_audio:"Escribe los 8 n\u00fameros:",help_btn:"Ayuda",cant_hear_this:"\u00bfNo puedes o\u00edrel audio?",incorrect_try_again:"Incorrecto. Otro intento."};var RecaptchaStr_fr={visual_challenge:"D\u00e9fi visuel",audio_challenge:"D\u00e9fi audio",refresh_btn:"Nouveau d\u00e9fi",instructions_visual:"Entrez les deux mots:",instructions_audio:"Entrez les huit chiffres:",help_btn:"Aide",cant_hear_this:"Vous n'entendez pas de son?",incorrect_try_again:"Incorrect."};var RecaptchaStr_nl={visual_challenge:"Test me via een afbeelding",audio_challenge:"Test me via een geluidsfragment",refresh_btn:"Nieuwe uitdaging",instructions_visual:"Type de twee woorden:",instructions_audio:"Type de acht cijfers:",help_btn:"Help",cant_hear_this:"Kun je het geluid niet horen?",incorrect_try_again:"Foute invoer."};var RecaptchaStr_pt={visual_challenge:"Obter um desafio visual",audio_challenge:"Obter um desafio sonoro",refresh_btn:"Obter um novo desafio",instructions_visual:"Escreva as 2 palavras:",instructions_audio:"Escreva os 8 numeros:",help_btn:"Ajuda",cant_hear_this:"N\u00e3o consegue ouvir o som?",incorrect_try_again:"Incorrecto. Tenta outra vez."};var RecaptchaStr_ru={visual_challenge:"\u0417\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443",audio_challenge:"\u0417\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0437\u0432\u0443\u043a\u043e\u0432\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443",refresh_btn:"\u0417\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u043d\u043e\u0432\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443",instructions_visual:"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0434\u0432\u0430 \u0441\u043b\u043e\u0432\u0430:",instructions_audio:"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0432\u043e\u0441\u0435\u043c\u044c \u0447\u0438\u0441\u0435\u043b:",help_btn:"\u041f\u043e\u043c\u043e\u0449\u044c",cant_hear_this:"\u041d\u0435 \u0441\u043b\u044b\u0448\u0438\u0442\u0435 \u0437\u0432\u0443\u043a\u0430?",incorrect_try_again:"\u041d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e."};var RecaptchaStr_tr={visual_challenge:"G\u00f6rsel deneme",audio_challenge:"\u0130\u015Fitsel deneme",refresh_btn:"Yeni deneme",instructions_visual:"\u0130ki kelimeyi yaz\u0131n:",instructions_audio:"Sekiz numaray\u0131 yaz\u0131n:",help_btn:"Yard\u0131m (\u0130ngilizce)",cant_hear_this:"Duyamad\u0131n\u0131z m\u0131?",incorrect_try_again:"Yanl\u0131\u015f. Bir daha deneyin."};var RecaptchaLangMap={en:RecaptchaStr_en,de:RecaptchaStr_de,es:RecaptchaStr_es,fr:RecaptchaStr_fr,nl:RecaptchaStr_nl,pt:RecaptchaStr_pt,ru:RecaptchaStr_ru,tr:RecaptchaStr_tr};var RecaptchaStr=RecaptchaStr_en;var RecaptchaOptions;var RecaptchaDefaultOptions={tabindex:0,theme:'red',callback:null,lang:'en',custom_theme_widget:null};var Recaptcha={widget:null,timer_id:-1,style_set:false,theme:null,type:'image',ajax_verify_cb:null,$:function(id){if(typeof(id)=="string"){return document.getElementById(id);}
else{return id;}},create:function(public_key,element,options){Recaptcha.destroy();if(element){Recaptcha.widget=Recaptcha.$(element);}
Recaptcha._init_options(options);Recaptcha._call_challenge(public_key);},destroy:function(){var challengefield=Recaptcha.$('recaptcha_challenge_field');if(challengefield){challengefield.parentNode.removeChild(challengefield);}
if(Recaptcha.timer_id!=-1){clearInterval(Recaptcha.timer_id);}
Recaptcha.timer_id=-1;var imagearea=Recaptcha.$('recaptcha_image');if(imagearea){imagearea.innerHTML="";}
if(Recaptcha.widget){if(Recaptcha.theme!="custom"){Recaptcha.widget.innerHTML="";}else{Recaptcha.widget.style.display="none";}
Recaptcha.widget=null;}},focus_response_field:function(){var $=Recaptcha.$;var field=$('recaptcha_response_field');field.focus();},get_challenge:function(){if(typeof(RecaptchaState)=="undefined"){return null;}
return RecaptchaState.challenge;},get_response:function(){var $=Recaptcha.$;var field=$('recaptcha_response_field');if(!field){return null;}
return field.value;},ajax_verify:function(callback){Recaptcha.ajax_verify_cb=callback;var scriptURL=Recaptcha._get_api_server()+"/ajaxverify"+"?c="+encodeURIComponent(Recaptcha.get_challenge())+"&response="+encodeURIComponent(Recaptcha.get_response());Recaptcha._add_script(scriptURL);},_ajax_verify_callback:function(data){Recaptcha.ajax_verify_cb(data);},_get_api_server:function(){var protocol=window.location.protocol;var server;if(typeof(_RecaptchaOverrideApiServer)!="undefined"){server=_RecaptchaOverrideApiServer;}else if(protocol=='https:'){server="api-secure.recaptcha.net";}else{server="api.recaptcha.net";}
return protocol+"//"+server;},_call_challenge:function(public_key){var scriptURL=Recaptcha._get_api_server()+"/challenge?k="+public_key+"&ajax=1&cachestop="+Math.random();if(typeof(RecaptchaOptions.extra_challenge_params)!="undefined"){scriptURL+="&"+RecaptchaOptions.extra_challenge_params;}
Recaptcha._add_script(scriptURL);},_add_script:function(scriptURL){var scriptTag=document.createElement("script");scriptTag.type="text/javascript";scriptTag.src=scriptURL;Recaptcha._get_script_area().appendChild(scriptTag);},_get_script_area:function(){var parentElement=document.getElementsByTagName("head");if(!parentElement||parentElement.length<1){parentElement=document.body;}
else{parentElement=parentElement[0];}
return parentElement;},_init_options:function(opts){var comb_opt=RecaptchaDefaultOptions;var user_opts=opts||{};for(var p in user_opts){comb_opt[p]=user_opts[p];}
RecaptchaOptions=comb_opt;},challenge_callback:function(){var element=Recaptcha.widget;Recaptcha._reset_timer();var lang=RecaptchaLangMap[RecaptchaOptions.lang];if(typeof(lang)!="undefined"){RecaptchaStr=lang;}
if(window.addEventListener){window.addEventListener('unload',function(e){Recaptcha.destroy();},false);}
if(Recaptcha._is_ie()&&window.attachEvent){window.attachEvent('onbeforeunload',function(){});}
if(navigator.userAgent.indexOf("KHTML")>0){var iframe=document.createElement('iframe');iframe.src="about:blank";iframe.style.height="0px";iframe.style.width="0px";iframe.style.visibility="hidden";iframe.style.border="none";var textNode=document.createTextNode("This frame prevents back/forward cache problems in Safari.");iframe.appendChild(textNode);document.body.appendChild(iframe);}
Recaptcha._finish_widget();},_add_css:function(css){var styleTag=document.createElement("style");styleTag.type="text/css";if(styleTag.styleSheet){if(navigator.appVersion.indexOf("MSIE 5")!=-1){document.write("<style type='text/css'>"+css+"</style>");}
else{styleTag.styleSheet.cssText=css;}}else if(navigator.appVersion.indexOf("MSIE 5")!=-1){document.write("<style type='text/css'>"+css+"</style>");}
else{var textNode=document.createTextNode(css);styleTag.appendChild(textNode);}
Recaptcha._get_script_area().appendChild(styleTag);},_set_style:function(css){if(Recaptcha.style_set){return;}
Recaptcha.style_set=true;Recaptcha._add_css(css+"\n\n"+".recaptcha_is_showing_audio .recaptcha_only_if_image,"+".recaptcha_isnot_showing_audio .recaptcha_only_if_audio,"+".recaptcha_had_incorrect_sol .recaptcha_only_if_no_incorrect_sol,"+".recaptcha_nothad_incorrect_sol .recaptcha_only_if_incorrect_sol"+"{display:none !important}");},_init_builtin_theme:function(){var $=Recaptcha.$;var $_=RecaptchaStr;var $ST=RecaptchaState;var css,html,imgfmt;var server_no_slash=$ST.server;if(server_no_slash[server_no_slash.length-1]=="/")
server_no_slash=server_no_slash.substring(0,server_no_slash.length-1);var IMGROOT=server_no_slash+"/img/"+Recaptcha.theme;if(Recaptcha.theme=='clean'){css=RecaptchaTemplates.CleanCss;html=RecaptchaTemplates.CleanHtml;imgfmt='png';}
else{css=RecaptchaTemplates.VertCss;html=RecaptchaTemplates.VertHtml;imgfmt='gif';}
css=css.replace(/IMGROOT/g,IMGROOT);Recaptcha._set_style(css);Recaptcha.widget.innerHTML="<div id='recaptcha_area'>"+html+"</div>";$('recaptcha_reload').src=IMGROOT+"/refresh."+imgfmt;$('recaptcha_switch_audio').src=IMGROOT+"/audio."+imgfmt;$('recaptcha_switch_img').src=IMGROOT+"/text."+imgfmt;$('recaptcha_whatsthis').src=IMGROOT+"/help."+imgfmt;if(Recaptcha.theme=='clean'){$('recaptcha_logo').src=IMGROOT+"/logo."+imgfmt;$('recaptcha_tagline').src=IMGROOT+"/tagline."+imgfmt;}
$('recaptcha_reload').alt=$_.refresh_btn;$('recaptcha_switch_audio').alt=$_.audio_challenge;$('recaptcha_switch_img').alt=$_.visual_challenge;$('recaptcha_whatsthis').alt=$_.help_btn;$('recaptcha_reload_btn').href="javascript:Recaptcha.reload ();";$('recaptcha_reload_btn').title=$_.refresh_btn;$('recaptcha_switch_audio_btn').href="javascript:Recaptcha.switch_type('audio');";$('recaptcha_switch_audio_btn').title=$_.audio_challenge;$('recaptcha_switch_img_btn').href="javascript:Recaptcha.switch_type('image');";$('recaptcha_switch_img_btn').title=$_.visual_challenge;$('recaptcha_whatsthis_btn').href=Recaptcha._get_help_link();$('recaptcha_whatsthis_btn').target="_blank";$('recaptcha_whatsthis_btn').title=$_.help_btn;$('recaptcha_whatsthis_btn').onclick=function(){Recaptcha.showhelp();return false;};$('recaptcha_table').className="recaptchatable "+"recaptcha_theme_"+Recaptcha.theme;if($("recaptcha_instructions_image")){$("recaptcha_instructions_image").appendChild(document.createTextNode($_.instructions_visual));}
if($("recaptcha_instructions_audio")){$("recaptcha_instructions_audio").appendChild(document.createTextNode($_.instructions_audio));}
if($("recaptcha_instructions_error")){$("recaptcha_instructions_error").appendChild(document.createTextNode($_.incorrect_try_again));}},_finish_widget:function(){var $=Recaptcha.$;var $_=RecaptchaStr;var $ST=RecaptchaState;var $OPT=RecaptchaOptions;var theme=$OPT.theme;switch(theme){case'red':case'white':case'blackglass':case'clean':case'custom':break;default:theme='red';break;}
if(!Recaptcha.theme){Recaptcha.theme=theme;}
if(Recaptcha.theme!="custom"){Recaptcha._init_builtin_theme();}else{Recaptcha._set_style("");}
var challengeFieldHolder=document.createElement("span");challengeFieldHolder.id="recaptcha_challenge_field_holder";challengeFieldHolder.style.display="none";$('recaptcha_response_field').parentNode.insertBefore(challengeFieldHolder,$('recaptcha_response_field'));$('recaptcha_response_field').setAttribute("autocomplete","off");$('recaptcha_image').style.width='300px';$('recaptcha_image').style.height='57px';Recaptcha.should_focus=false;Recaptcha._set_challenge($ST.challenge,'image');if($OPT.tabindex){$('recaptcha_response_field').tabIndex=$OPT.tabindex;}
if(Recaptcha.widget){Recaptcha.widget.style.display='';}
if($OPT.callback){$OPT.callback();}},switch_type:function(new_type){var $C=Recaptcha;$C.type=new_type;$C.reload($C.type=='audio'?'a':'v');},reload:function(reason){var $C=Recaptcha;var $=$C.$;var $ST=RecaptchaState;if(typeof(reason)=="undefined")
reason='r';var scriptURL=$ST.server+"reload?c="+$ST.challenge+"&k="+$ST.site+"&reason="+reason+"&type="+$C.type;if(typeof(RecaptchaOptions.extra_challenge_params)!="undefined"){scriptURL+="&"+RecaptchaOptions.extra_challenge_params;}
$C.should_focus=reason!='t';$C._add_script(scriptURL);},finish_reload:function(new_challenge,type){RecaptchaState.is_incorrect=false;Recaptcha._set_challenge(new_challenge,type);},_set_challenge:function(new_challenge,type)
{var $C=Recaptcha;var $ST=RecaptchaState;var $=$C.$;$ST.challenge=new_challenge;$C.type=type;$('recaptcha_challenge_field_holder').innerHTML="<input type='hidden' name='recaptcha_challenge_field' id='recaptcha_challenge_field' value='"+$ST.challenge+"'/>";if(type=='audio'){var wavurl=$ST.server+"image?c="+$ST.challenge;var httpwavurl=wavurl;if(httpwavurl.indexOf("https://")==0){httpwavurl="http://"+httpwavurl.substring(8);}
var embedCode;if($C._is_ie()){embedCode='<object height="40" CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" src="'+httpwavurl+'" ><param name="URL" value="'+httpwavurl+'"><param name="autoStart" value="true"><param name="uimode" value="mini"></object>';}else{embedCode='<EMBED SRC="'+wavurl+'" height="40" bgcolor="white" AUTOSTART="true"/>';}
var cantHearCode='<br/><a class="recaptcha_audio_cant_hear_link" target="_blank" href="'+httpwavurl+'">'+RecaptchaStr.cant_hear_this+'</a>';$("recaptcha_image").innerHTML=embedCode+cantHearCode;}else if(type=='image'){var imageurl=$ST.server+'image?c='+$ST.challenge;$('recaptcha_image').innerHTML="<img style='display:block;' height='57' width='300' src='"+imageurl+"'/>";}
Recaptcha._css_toggle("recaptcha_had_incorrect_sol","recaptcha_nothad_incorrect_sol",$ST.is_incorrect);Recaptcha._css_toggle("recaptcha_is_showing_audio","recaptcha_isnot_showing_audio",type=='audio');$C._clear_input();if($C.should_focus){$C.focus_response_field();}
$C._reset_timer();},_reset_timer:function(){var $ST=RecaptchaState;clearInterval(Recaptcha.timer_id);Recaptcha.timer_id=setInterval("Recaptcha.reload('t');",($ST.timeout-60*5)*1000);},showhelp:function(){window.open(Recaptcha._get_help_link(),"recaptcha_popup","width=460,height=570,location=no,menubar=no,status=no,toolbar=no,scrollbars=yes,resizable=yes");},_clear_input:function(){var resp=Recaptcha.$('recaptcha_response_field');resp.value="";},_displayerror:function(msg){var $=Recaptcha.$;$('recaptcha_image').innerHTML='';$('recaptcha_image').appendChild(document.createTextNode(msg));},reloaderror:function(msg){Recaptcha._displayerror(msg);},_is_ie:function(){return(navigator.userAgent.indexOf("MSIE")>0)&&!window.opera;},_css_toggle:function(classT,classF,isset){var element=Recaptcha.widget;if(!element)
element=document.body;var classname=element.className;classname=classname.replace(new RegExp("(^|\\s+)"+classT+"(\\s+|$)"),' ');classname=classname.replace(new RegExp("(^|\\s+)"+classF+"(\\s+|$)"),' ');classname+=" "+(isset?classT:classF);element.className=classname;},_get_help_link:function(){var lang=RecaptchaOptions.lang;return'http://recaptcha.net/popuphelp/'+(lang=='en'?"":(lang+".html"));}};

Ext.ux.Recaptcha=Ext.extend(Ext.BoxComponent,{onRender:function(ct,position){if(!this.el){this.el=document.createElement('div');this.el.id=this.getId();Recaptcha.create(this.publickey,this.el,{theme:this.theme,lang:this.lang,callback:Recaptcha.focus_response_field});}
Ext.ux.Recaptcha.superclass.onRender.call(this,ct,position);}});Ext.reg('recaptcha',Ext.ux.Recaptcha);
