var bam=(typeof(bam)==="object")?bam:(function(window,document,$,undefined){$.ajaxSettings.traditional=true;var STRING="string",NUMBER="number",OBJECT="object",FUNCTION="function",TRUE=true,FALSE=false,NULL=null;var _findStyle=function(href){var styles=document.styleSheets,stLen=styles.length-1,cStyle=NULL;if(stLen>=0){do{cStyle=styles[stLen];if(!!cStyle.href&&cStyle.href.lastIndexOf(href)>-1){return cStyle;}}while(stLen--);}return NULL;};var _modules={add:function(path){if(!/add|isLoaded/.test(path)){this[path]=TRUE;}},isLoaded:function(path){var out=FALSE,mod=_modules[path];if(typeof(mod)!=="undefined"){out=TRUE;}return out;}};var _bam={version:"3.3",homePath:"/shared/scripts/bam/packed/",extend:function(){var ext=NULL,obj=NULL,i;if(arguments.length>1){obj=arguments[0];ext=arguments[1];}else{obj=_bam;ext=arguments[0];}if(typeof(ext)===OBJECT&&!!ext){for(i in ext){if(ext.hasOwnProperty(i)){if(typeof(ext[i])===OBJECT){if(!obj[i]||!!obj[i].path){obj[i]=ext[i];if(arguments.length===1){obj[i].packageName="bam."+i;}}}}}}},augment:function(){var ext=NULL,obj=NULL,i;if(arguments.length>1){obj=arguments[0];ext=arguments[1];}else{obj=_bam;ext=arguments[0];}if(typeof(ext)===OBJECT&&!!ext){for(i in ext){if(ext.hasOwnProperty(i)){if(typeof(ext[i])===FUNCTION){if(!obj[i]){obj[i]=ext[i];}}}}}},imports:function(){function _syncLoad(obj){if(typeof(obj)===OBJECT&&!!obj.lib){var path=_bam.homePath+obj.path;delete _bam[obj.lib];_bam.loadSync(path);}}if(arguments.length>1){var aLen=arguments.length-1;do{_syncLoad(arguments[aLen]);}while(aLen--);}else{_syncLoad(arguments[0]);}},load:function(path,cb){if(typeof(path)===STRING){if(!_modules.isLoaded(path)){$.get(path,function(text){try{var json=eval("("+text+")");bam.extend(json);_modules.add(path);if(!!cb&&typeof(cb)===FUNCTION){cb();}}catch(ex){}});}else{if(!!cb&&typeof(cb)===FUNCTION){cb();}}}},loadSync:function(){function _syncLoad(path){$.ajax({type:"GET",url:path,dataType:"text",async:FALSE,success:function(text){try{var json=eval("("+text+")");bam.extend(json);_modules.add(path);}catch(ex){}}});}if(arguments.length>1){var aLen=arguments.length-1,_a=0;do{if(!_modules.isLoaded(arguments[_a])){_syncLoad(arguments[_a]);}}while(_a++<aLen);}else{if(!_modules.isLoaded(arguments[0])){_syncLoad(arguments[0]);}}},loadCSS:function(){var stylePath,aLen=arguments.length-1,_a=0;if(aLen>=0){var _head=document.getElementsByTagName("head")[0],_link=document.createElement("link"),cLink=NULL;_link.setAttribute("rel","stylesheet");_link.setAttribute("type","text/css");do{if(!_findStyle(arguments[_a])){stylePath=arguments[_a];if(typeof(stylePath)===STRING){cLink=_link.cloneNode(TRUE);cLink.setAttribute("href",stylePath);_head.appendChild(cLink);}}}while(_a++<aLen);}},unloadCSS:function(){var styleSheet=NULL,owner=NULL,parent=NULL,aLen=arguments.length-1;if(aLen>=0){do{if(!!(styleSheet=_findStyle(arguments[aLen]))){styleSheet.disabled=TRUE;owner=(!!styleSheet.owningElement)?styleSheet.owningElement:styleSheet.ownerNode;parent=(!!owner.parentElement)?owner.parentElement:owner.parentNode;parent.removeChild(owner);}}while(aLen--);}},clone:function(obj){if(typeof(obj)===OBJECT&&!!obj){function F(){}F.prototype=obj;return new F();}else{throw new Error("bam.clone() was called with an invalid or null argument.");}},collections:{path:"bam.collections.js",lib:"collections"},cookies:{path:"bam.cookies.js",lib:"cookies"},datetime:{path:"bam.datetime.js",lib:"datetime"},dom:{path:"bam.dom.js",lib:"dom"},filters:{path:"bam.filters.js",lib:"filters"},forms:{path:"bam.forms.js",lib:"forms"},soap:{path:"bam.soap.js",lib:"soap"},url:{path:"bam.url.js",lib:"url"},validation:{path:"bam.validation.js",lib:"validation"},xml:{path:"bam.xml.js",lib:"xml"},object:{typeOf:function(obj){var out="",ots=Object.prototype.toString;if(typeof(obj)===OBJECT){switch(TRUE){case (obj===NULL):out="null";break;case (ots.call(obj)==="[object String]"):out=STRING;break;case (ots.call(obj)==="[object Number]"):out=isNaN(obj)?"NaN":NUMBER;break;case (ots.call(obj)==="[object Date]"):out=isNaN(obj)?"NaN":"date";break;case (ots.call(obj)==="[object Array]"||obj instanceof Array):out="array";break;case (ots.call(obj)==="[object Error]"):out="error";break;case ("tagName" in obj):out=obj.tagName.toLowerCase();break;case ("nodeType" in obj):out="xml";break;default:out=OBJECT;}}else{if(typeof(obj)===NUMBER&&isNaN(obj)){out="NaN";}else{out=typeof(obj);}}return out;},getDeepValue:function(obj,deepProp){var props=deepProp.split("."),i=0,n=props.length;while(typeof(obj=obj[props[i]])!=="undefined"&&++i<n){}return obj;},setDeepValue:function(obj,deepProp,val){var props=deepProp.split("."),root=obj,i=0,n=props.length-1,p,t;while(i<n){p=props[i];t=typeof obj[p];obj=obj[p]=(t===OBJECT||t===FUNCTION)?obj[p]:{};i++;}obj[props[i]]=val;return root;},extend:function(subclass,superclass,overrides){if(!superclass||!subclass){throw new Error("extend failed, please check that all dependencies are included.");}var F=function(){};F.prototype=superclass.prototype;subclass.prototype=new F();subclass.prototype.constructor=subclass;subclass.superclass=superclass.prototype;if(superclass.prototype.constructor===Object.prototype.constructor){superclass.prototype.constructor=superclass;}if(overrides){for(var i in overrides){if(overrides.hasOwnProperty(i)){subclass.prototype[i]=overrides[i];}}var isIE=!+"\v1";if(isIE){bam.object._IEEnumFix(subclass.prototype,overrides);}}},_IEEnumFix:function(obj,ext){var fnNames=["toString","valueOf"],fnName,fn,i,n;for(i=0,n=fnNames.length;i<n;++i){fnName=fnNames[i];fn=ext[fnName];if(typeof fn===FUNCTION&&fn!=Object.prototype[fnName]){obj[fnName]=fn;}}},proxy:function(fn,obj){var scope=obj||window,defaults;fn=(typeof fn==="string")?scope[fn]:fn;if(arguments.length<3){return function(){return fn.apply(scope,arguments);};}else{defaults=Array.prototype.slice.call(arguments,2);return function(){var args=[];for(var i=0;i<Math.max(arguments.length,defaults.length);++i){args[i]=(typeof arguments[i]!=="undefined")?arguments[i]:defaults[i];}return fn.apply(scope,args);};}},eventProxy:function(){var fn=bam.object.proxy.apply(NULL,arguments);return function(){return fn.apply(NULL,Array.prototype.slice.call(arguments,1));};}},namespace:function(obj,ns){var props=(ns||obj).split("."),i,n;obj=ns&&obj||bam;for(i=0,n=props.length;i<n;++i){obj=obj[props[i]]=obj[props[i]]||{};}return obj;},util:{ensureArray:function(val){return(val instanceof Array)?val:(typeof val!=="undefined")?[val]:[];},getQueryResults:function(data){var deepProp=(typeof arguments[1]!=="undefined")?arguments[1]+".":"";return bam.util.ensureArray(bam.object.getDeepValue(data,deepProp+"queryResults.row"));},getQueryResult:function(data){return bam.util.getQueryResults(data,arguments[1])[arguments[2]||0];},countQueryResults:function(data){var deepProp=(typeof arguments[1]!=="undefined")?arguments[1]+".":"";return parseInt(bam.object.getDeepValue(data,deepProp+"queryResults.totalSize"),10);},wrapQueryResults:function(data){return bam.object.setDeepValue({},"queryResults.row",data);}},number:{limitValueToRange:function(val,rangeA,rangeB){var min=Math.min(rangeA,rangeB),max=Math.max(rangeA,rangeB);return Math.max(Math.min(val,max),min);}},string:(function(){var _self={trim:function(str){return $.trim(str);},equals:function(str,str2){if(typeof(str)===STRING&&typeof(str2)===STRING){return str===str2;}},equalsIgnoreCase:function(str,str2){if(typeof(str)===STRING&&typeof(str2)===STRING){return str.toLowerCase()===str2.toLowerCase();}},toCharArray:function(str){if(typeof(str)===STRING){return str.split("");}},instr:function(str,from,to,val){var _out=str;if(typeof(str)===STRING){if((!isNaN(from))&&(from>=0)&&(from<=str.length)){if((!isNaN(to))&&(to>=0)&&(to<=str.length)){var _tmp=str.substring(0,from);_tmp+=val;_tmp+=str.substring(to);_out=_tmp;}}}return _out;},textWrap:function(str,largestWordLength,wordPartSize,wordBreaker){if(bam.object.typeOf(str)!==STRING){return str;}else{str=String(str);}largestWordLength=largestWordLength||20;wordPartSize=wordPartSize||5;var userAgent;if(wordBreaker){}else{if((userAgent=navigator.userAgent.match(/Firefox\/([0-9\.]+)/i))&&parseInt(userAgent[1],10)<3){wordBreaker="&#8203;";}else{wordBreaker="&shy;";}}var regex=new RegExp("([a-z0-9\\-_]{"+largestWordLength+",})([^<]*?>)?","gi");return str.replace(regex,function(){var match=arguments[1];var result=[];var i=0;if(match.indexOf(wordBreaker)!==-1||arguments[2]){if(arguments[2]){match+=arguments[2];}return match;}while(match.length>0){result.push(match.substring(0,wordPartSize));match=match.substring(wordPartSize);}return result.join(wordBreaker);});},StringBuffer:function(str){this.buffer=[];this.length=0;if(!!str){this.append(str);}},escapeHTML:function(htmlStr){var div=document.createElement("div");div["innerText" in div?"innerText":"textContent"]=htmlStr;return div.innerHTML;},unescapeHTML:function(htmlStr){var div=document.createElement("div");div.innerHTML=htmlStr;return div["innerText" in div?"innerText":"textContent"].replace("&apos;","'");}};_self.StringBuffer.prototype={append:function(obj){if(typeof obj!=="undefined"){var tmp=String(obj);this.length+=tmp.length;this.buffer.push(tmp);}return this;},replace:function(start,end,rplStr){if(bam.object.typeOf(rplStr)===STRING){var tmp=this.toString();tmp=bam.string.instr(tmp,start,end,rplStr);this.clear();this.append(tmp);}return this;},remove:function(start,end){if(!!end){this.replace(start,end,"");}else{this.replace(start,this.length,"");}return this;},reverse:function(){this.buffer=this.toString().split("").reverse();return this;},clear:function(){this.length=0;this.buffer.length=0;return this;},toString:function(){return this.buffer.join("");}};return _self;})(),env:(function(win){var _host={};_host.isDev=_host.isQA=_host.isBeta=_host.isProd=false;var _subdomain=win.location.host.split(".").reverse()[2];var _env=_subdomain&&(_subdomain.indexOf("dev")>-1&&"Dev"||_subdomain.indexOf("qa")>-1&&"QA"||_subdomain.indexOf("beta")>-1&&"Beta")||"Prod";_host["is"+_env]=true;var _userAgent=win.navigator.userAgent;var _client={isIPad:!!_userAgent.match(/ipad.+Mac/i),isXoom:!!_userAgent.match(/Android 3/i)};return{host:_host,client:_client};})(window)};_bam.object.bind=_bam.object.proxy;_bam.object.namespace=_bam.namespace;$.bindable=function(obj){obj=obj.prototype||obj;$(["bind","one","unbind"]).each(function(i,method){obj[method]=function(type,data,fn,thisObject){$(this)[method](type,data,fn,thisObject);return this;};});obj.trigger=function(type,data){var event=new $.Event(type),all=new $.Event(event);event.preventDefault();all.type="*";if(event.type!=="*"){$(this).trigger(event,data);}$(this).trigger(all,data);return this;};if(typeof arguments[1]==="string"){$.each(arguments[1].split(/\s+/),function(i,type){obj[type]=function(data,fn,thisObject){return arguments.length?this.bind(type,data,fn,thisObject):this.trigger(type);};});}return obj;};_bam.getDateByOffset=function(offset){var offsetHours=~~(offset/100),offsetMinutes=offset%100,local=(typeof arguments[1]!=="undefined")?new Date(arguments[1]):new Date();return new Date(local.getUTCFullYear(),local.getUTCMonth(),local.getUTCDate(),local.getUTCHours()+offsetHours,local.getUTCMinutes()+offsetMinutes,local.getUTCSeconds(),local.getUTCMilliseconds());};return _bam;})(this,this.document,jQuery);

