/*
 * Oodrive-core-min
 * Copyright(c) 2006, Nicolas BUI.
 * 
 * This code is licensed under BSD license. Use it as you wish, 
 * but keep this copyright intact.
 */


var Is={a:function(cl,baseCl){return cl instanceof baseCl;},objOrFn:function(obj){return Is.obj(obj)||Is.fn(obj);},obj:function(subject){return typeof subject=='object'&&subject!==null;},fn:function(subject){return typeof subject=='function';},array:function(subject){return Is.obj(subject)&&subject.constructor==Array;},str:function(subject){return typeof subject=='string';},bool:function(subject,convert){_convert=!!convert;_isbool=(typeof subject=='boolean');return _isbool?_isbool:Is.oneOf(subject,[0,1,'true','false','yes','no']);},oneOf:function(subject,values){if(Is.array(values)){for(var i=0,l=values.lengh;i<l;i++){if(subject==values[i]){return true;}}}
return false;},num:function(){var args=arguments;return arguments.length==1?typeof arguments[0]=='number':(function(){for(var i=0,l=args.length;i<l;i++){if(typeof args[i]!=='number'){return false;}}
return true;})();},integer:function(v){var args=arguments;return arguments.length==1?typeof arguments[0]=='number'&&arguments[0]==ceil(arguments[0]):(function(){for(var i=0,l=args.length;i<l;i++){if(typeof args[i]!=='number'||args[i]!==ceil(args[i])){return false;}}
return true;})();},float:function(v){var args=arguments;return arguments.length==1?typeof arguments[0]=='number'&&arguments[0]!==ceil(arguments[0]):(function(){for(var i=0,l=args.length;i<l;i++){if(typeof args[i]!=='number'||args[i]===ceil(args[i])){return false;}}
return true;})();},nou:function(o){return typeof(o)==='undefined'||(typeof(o)==='object'&&o===null);},NoU:function(o){return Is.nou(o);},u:function(o){return typeof(o)==='undefined';},n:function(o){return o===null;},emptyStr:function(subject){if(Is.str(subject)){return String(str).search(/\S/)<0;}
return false;},emptyArray:function(subject){if(Is.array(subject)){return subject.length==0;}
return false;},empty:function(subject){if(Is.str(subject)){return String(subject).search(/\S/)<0;}
else if(Is.array(subject)){return subject.length==0;}
return false;},ie:!!document.all,dom:(document.getElementById&&document.createElement),digit:function(str,signed){var pattern=/^\s*\d+\s*$/;if(Is.bool(signed)&&signed){pattern=/^\s*(\+|-)?\d+\s*$/;}
return String(str).search(pattern)>=0;},decimal:function(str,signed){var pattern=/^\s*((\d+(\.\d+)?)|(\.\d+))\s*$/;if(signed===true){pattern=/^\s*(\+|-)?((\d+(\.\d+)?)|(\.\d+))\s*$/;}
return String(str).search(pattern)>=0;},currency:function(str,signed){var pattern=/^\s*((\d+(\.\d\d)?)|(\.\d\d))\s*$/;if(signed===true){pattern=/^\s*(\+|-)?((\d+(\.\d\d)?)|(\.\d\d))\s*$/;}
return String(str).search(pattern)>=0;},email:function(str){var pattern=/^\s*[\w\-\+_]+(\.[\w\-\+_]+)*\@[\w\-\+_]+\.[\w\-\+_]+(\.[\w\-\+_]+)*\s*$/;return String(str).search(pattern)>=0;}}
var Str={ltrim:function(str){return Is.str(str)?str.replace(/(^\s*)/g,''):str;},rtrim:function(str){return Is.str(str)?str.replace(/(\s*$)/g,''):str;},trim:function(str){return Is.str(str)?str.replace(/(^\s*)|(\s*$)/g,''):str;}}
var Tine={__interfaces:[],merge:function(target,source,override){var o=typeof override=='boolean'?override:true;if(typeof target!='undefined'&&typeof source=='object'){for(var f in source){if(o||typeof target[f]=='undefined'){target[f]=source[f];}}}
return target;},override:function(target,source){if(typeof target=='object'&&typeof source=='object'){for(var f in source){if(typeof target[f]!='undefined'){target[f]=source[f];}}}
return target;},extend:function(cl,su,override){if(Is.fn(su)){var F=function(){};F.prototype=su.prototype;cl.prototype=new F();}
if(Is.fn(override)){override=override();}
cl.prototype.constructor=cl;if(su.prototype.constructor==Object.prototype.constructor){su.prototype.constructor=su;}
if(Is.obj(override)){Tine.merge(cl.prototype,override,true);}
cl.superclass=su.prototype;cl.__interfaces=[];return cl;},implemented:function(cl,iface,implementAll){if(!Is.NoU(cl.__interfaces)){if(Is.str(iface)||Is.fn(iface)){iface_name='';if(Is.fn(iface)){var cn=iface.toString().match(/function ([^\s\(\)]+)/);if(cn&&cn.length>=2){iface_name=cn[1];}}
else{iface_name=iface;}
return!Is.NoU(cl.__interfaces[iface_name]);}
else if(Is.array(iface)){var implAll=!Is.NoU(implementAll)?implementAll:true;var res=implAll?true:false;for(var i in iface){if(implAll){res=res&&Tine.implemented(cl,iface[i]);}
else{res=res||Tine.implemented(cl,iface[i]);}}
return res;}}},implements:function(cl){if(arguments.length>1){var ifaces=arguments;var offset=1;if(Is.array(arguments[1])){offset=0;ifaces=arguments[1];}
for(var i=offset;i<ifaces.length;i++){var iface=ifaces[i];if(Is.str(iface)){iface=Tine.require(iface);}
if(Is.obj(iface)&&Is.a(iface,Tine.Interface)){iface.checkImplementation(cl);}}}
return cl;},override:function(classTarget,props){return Tine.overload(classTarget,props);},overload:function(classTarget,props){if(Is.NoU(classTarget.superclass)){classTarget.prototype.constructor=classTarget;classTarget.superclass=Object.prototype;}
if(Is.obj(props)){Tine.merge(classTarget.prototype,props,true);}
return classTarget;},ns:function(){var args=arguments;var l=args.length;var res=[];for(var i=0;i<l;i++){var ns=args[i].split('.');var o=window;for(var j=0;j<ns.length;j++){o[ns[j]]=o[ns[j]]||{};o=o[ns[j]];}
res.push(o);}
return l==1?res[0]:res;},namespace:function(){return Tine.ns.apply(null,arguments);},require:function(namespace,message){var msg=message||"";var onerr={msg:''};var res=[];var ns=namespace.split('.');var nl=ns.length;var o=window;for(var j=0;j<nl;j++){if(Is.u(o[ns[j]])){var _msg="[REQUIRED FAILED] Package or class \""+namespace+"\" is required (failed at \""+ns[j]+"\").";if(Is.str(msg)){_msg+=" [Description] "+msg;}
throw _msg;}
o=o[ns[j]];}
return o;},get:function(elmId,from){var root=from||document;if(root.getElementById){return root.getElementById(elmId);}
else if(document.all){return document.all[elmId];}
return null;},onDomReady:function(func,func_scope){if(Is.fn(func)){Tine.core.addDomReadyListener(func,func_scope);}},onLoad:function(func,func_scope){if(Is.fn(func)){Tine.core.addOnLoadListener(func,func_scope);}}};Tine.Interface=function(ns,name,method){this.name=name;this.ns=ns;if(Is.array(method)&&method.length>0){for(var i in method){if(Is.str(method[i])){this.methods.push(method[i]);}}}
else if(arguments.length>1){for(var i=1;i<arguments.length;i++){if(Is.str(arguments[i])&&!Is.empty(Str.trim(arguments[i]))){this.methods.push(arguments[i]);}}}}
Tine.override(Tine.Interface,{ns:'',name:'',methods:[],getFullName:function(){return!Is.empty(this.ns)?this.ns+'.'+this.name:this.name;},getName:function(){return this.name;},getNamespace:function(){return this.ns;},getMethods:function(){return this.methods;},checkImplementation:function(cl){var errors='';var methods=this.getMethods();if(Is.fn(cl)){if(methods.length>0){for(var i in methods){var method=methods[i];if(Is.str(method)){if(Is.NoU(cl.prototype[method])||!Is.fn(cl.prototype[method])){if(errors!=''){errors+=', ';}
errors+=method+'()';}}}}
if(errors.length>0){throw"(--------["+this.getFullName()+"] not implemented: "+errors+" --------)";}}
if(Is.NoU(cl.__interfaces)){cl.__interfaces=[];}
cl.__interfaces.push(this.getFullName());}});Tine.Interface.create=function(name,methods){var ns=name.split('.');var lev=ns.length;var cname=ns.pop();var $s=window;ns=ns.join('.');if(lev>0){$s=Tine.ns(ns);}
if(!$s[cname]){eval('$s.'+cname+' = new Tine.Interface( ns, cname, methods );');Tine.__interfaces.push($s[cname]);}
return $s[cname];}

Tine.ns("Tine");(function(){var $dr_once=false;var $lr_once=false;var onDomReadyListeners=[];var onLoadListeners=[];function onLoad(){var args=arguments;for(var i=0,l=onLoadListeners.length;i<l;i++){var o=onLoadListeners[i];if(Is.fn(o)){o.apply(window);}
else if(Is.obj(o)&&Is.fn(o.fn)){o.fn.apply(o.scope||window,args);}}}
function onDomReady(){var args=arguments;for(var i=0,l=onDomReadyListeners.length;i<l;i++){var o=onDomReadyListeners[i];if(Is.fn(o)){o.apply(window);}
else if(Is.obj(o)&&Is.fn(o.fn)){o.fn.apply(o.scope||window,args);}}}
Tine.core={addOnLoadListener:function(func,func_scope){onLoadListeners.push({fn:func,scope:func_scope});},addDomReadyListener:function(func,func_scope){onDomReadyListeners.push({fn:func,scope:func_scope});},__observeOnLoad__:function(){var fn=window.onload||(function(){});window.onload=function(){var args=arguments;onLoad.apply(window,args);fn.apply(window,args);};},__observeDocumentReady__:function(){if(document.addEventListener){document.addEventListener("DOMContentLoaded",onDomReady,false);}
if(/WebKit/i.test(navigator.userAgent)){var _timer=setInterval(function(){if(/loaded|complete/.test(document.readyState)){clearInterval(_timer);onDomReady();}},10);}}};})();Tine.core.__observeDocumentReady__();Tine.core.__observeOnLoad__();

Tine.ns("Tine.net");Tine.net.URL={encode:function(params){var str='';if(Is.obj(params)){for(var i in params){var v=params[i];if(!Is.obj(v)&&!Is.fn(v)){str+=i+'='+encodeURIComponent(v)+'&';}
else{str+=i+'=&';}}}
return str;},decode:function(params){var o={};if(Is.str(params)){var parts=params.split('&');for(var i in parts){var part=parts[i].split('=');if(part[0]!=''){if(part.length>=2){o[part[0]]=part[1];}}}}
return o;}}
Tine.net.Ajax=(function(){var xhrVersions=["Microsoft.XMLHttp","MSXML2.XMLHttp","MSXML2.XMLHttp.3.0","MSXML2.XMLHttp.4.0","MSXML2.XMLHttp.5.0","MSXML2.XMLHttp.6.0"];var createConnection=(function(){if(window.XMLHttpRequest){return function(){return new XMLHttpRequest();};}
else{return function(){var xhr=null;if(!arguments.callee.xhrVersion){for(var i=0,l=xhrVersions.length;i<l&&null===xhr;i++){try{xhr=new ActiveXObject(xhrVersions[i]);arguments.callee.xhrVersion=xhrVersions[i];}
catch(e){xhr=null;}}}else{xhr=new ActiveXObject(arguments.callee.xhrVersion);}
return xhr;};}})();var Connection=function(){this.xhr=createConnection();};Tine.extend(Connection,Object,{url:'',method:'POST',async:true,timeout:1000*6,params:{},headers:{},xhr:null,monitor:null,monitorInterval:40,timeoutMonitor:null,timeoutInterval:60000,requestId:1,response:null,setHeader:function(key,value){if(Is.str(key)&&Is.str(value)){this.headers[key]=value;}
else if(Is.obj(key)){for(var i in key){var v=key[i];if(Is.str(i,v)){this.headers[i]=v;}}}},initHeaders:function(){var xhr=this.xhr;var headers=this.headers;if(xhr){for(var i in headers){xhr.setRequestHeader(i,headers[i]);}}},request:function(config){var xhr=this.xhr;if(!xhr){}
if(xhr){Tine.merge(this,config);this.method=(this.method||'POST').toUpperCase();this.async=!!this.async;this.url=this.url||'';this.params=this.params||{};this.timeout=this.timeout||null;var params=Tine.net.URL.encode(this.params);if(this.method==='POST'){this.setHeader({"Content-type":"application/x-www-form-urlencoded","Content-length":params.length,"Connection":"close"});}
else{this.url+=(this.url.indexOf('?')>0?'&':'?')+params;params=null;}
if(this.url!=''){try{xhr.open(this.method,this.url,this.async);this.initHeaders();this.observe();xhr.send(params);}
catch(e){}}
else{throw"Tine.net.Connection: No URL provided";}}},abort:function(){var xhr=this.xhr;if(this.isRunning()){window.clearInterval(this.monitor);window.clearInterval(this.timeoutMonitor);delete this.monitor;delete this.timeoutMonitor;this.close();}},isRunning:function(){var xhr=this.xhr;return xhr&&xhr.readyState!=4&&xhr.readyState!=0;},observe:function(){var conn=this;var xhr=this.xhr;this.timeoutMonitor=window.setTimeout(function(){if(conn.monitor){window.clearInterval(conn.monitor);delete conn.monitor;}
conn.processResponse();},this.timeout||this.timeoutInterval);conn.monitor=window.setInterval(function(){if(xhr&&xhr.readyState==4){window.clearInterval(conn.monitor);delete conn.monitor;if(conn.timeoutMonitor){window.clearTimeout(conn.timeoutMonitor);delete conn.timeoutMonitor;}
conn.processResponse();}},conn.monitorInterval);},close:function(){this.xhr.abort();this.xhr=null;},processResponse:function(){var conn=this;var xhr=this.xhr;var h={};try{var headers=xhr.getAllResponseHeaders().split("\n");for(var i=0,l=headers.length;i<l;i++){var pos=headers[i].indexOf(':');if(pos>=0){h[headers[i].substring(0,pos)]=headers[i].substring(pos+2);}}}
catch(e){}
var status=-1;try{this.response={success:(xhr.status>=200&&xhr.status<300),status:xhr.status,statusText:xhr.statusText,headers:h,responseText:xhr.responseText,responseXML:xhr.responseXML};}
catch(e){this.response={success:false,status:-1,statusText:'',headers:{},responseText:null,responseXML:null};}
if(Is.fn(this.callback)){this.callback.call(window,this.response,conn);}
else if(Is.obj(this.callback)){if(Is.fn(this.callback.fn)){this.callback.fn.call(this.callback.scope||window,this.response,conn);}
if(this.response.success&&Is.fn(this.callback.success)){this.callback.success.call(this.callback.scope||window,this.response,conn);}
else if(!this.response.success){if(Is.fn(this.callback.failure)){this.callback.failure.call(this.callback.scope||window,this.response,conn);}
if(Is.fn(this.callback.error)){this.callback.error.call(this.callback.scope||window,this.response,conn);}}}
this.close();}});return{request:function(config){var conn=new Connection();conn.request(config);return conn;}}})();

