
/*========== engine_lib.js ==========*/

var Browser=new Object();Browser.ua=navigator.userAgent.toLowerCase();Browser.isMozilla=(typeof(document.implementation)!="undefined")&&(typeof(document.implementation.createDocument)!="undefined")&&(typeof(HTMLDocument)!="undefined")&&(typeof(document.all)=="undefined");Browser.isIE=window.ActiveXObject?true:false;Browser.isGecko=(Browser.ua.indexOf("gecko")!=-1);Browser.isFirefox=(Browser.ua.indexOf("firefox")!=-1);Browser.isWebkit=(Browser.ua.indexOf("applewebkit")!=-1);Browser.isChrome=(Browser.isWebkit&&Browser.ua.indexOf("chrome")!=-1);Browser.isSafari=(Browser.isWebkit&&!Browser.isChrome&&Browser.ua.indexOf("safari")!=-1);Browser.isOpera=(typeof(window.opera)!="undefined");if(Browser.isFirefox)
Browser.version=parseFloat(Browser.ua.substr(Browser.ua.indexOf("firefox")+8,3));else if(Browser.isOpera)
Browser.version=(window.opera.version)?parseFloat(window.opera.version()):7.5;else if(Browser.isIE){var re=new RegExp("msie ([0-9]{1,}[\.0-9]{0,})");Browser.version=(re.exec(Browser.ua)!=null)?parseFloat(RegExp.$1):3;}
else if(Browser.isWebkit){var kitName="applewebkit/";var kitVersion=Browser.ua.substring(Browser.ua.indexOf(kitName)+kitName.length,Browser.ua.length);kitVersion=parseInt(kitVersion.substring(0,kitVersion.indexOf(" ")));Browser.version=kitVersion>=500?3.0:kitVersion>=400?2.0:kitVersion>=300?1.3:kitVersion>100?1.2:1.0;}
else{Browser.version=1.0;}
var aDaysPerMonth=new Array(31,28,31,30,31,30,31,31,30,31,30,31);var aDeferredInits=new Array();var UNIT_K=1024;var UNIT_M=1048576;var UNIT_G=1073741824;function getType(obj)
{if(!isDefined(obj))return false;if(obj==null)return null;if(isElement(obj))return'element';var type=typeof obj;if(type=='object'&&obj.nodeName){switch(obj.nodeType){case 1:return'element';case 3:return("/\\S/").test(obj.nodeValue)?'textnode':'whitespace';}}
if(type=='object'||type=='function'){switch(obj.constructor){case Array:return'array';case RegExp:return'regexp';}
if(typeof obj.length=='number'){if(obj.item)return'collection';if(obj.callee)return'arguments';}}
return type;}
function isDefined(val)
{return(typeof(val)!="undefined");}
function isNumeric(val)
{if(typeof(val)=="number")return true;if(!isNaN(parseFloat(val)))return true;return false;}
function isNumber(val)
{return(typeof(val)=="number");}
function isInteger(val)
{if(typeof(val)=="undefined"||val===""||val===null)
return false;val=val.toString();var c;for(var i=0;i<val.length;i++){c=val.charAt(i);if((c<"0"||c>"9")&&((c!="+"&&c!="-")||i>0))
return false;}
return true;}
function isBoolean(val)
{return(typeof(val)=="boolean");}
function isObject(obj)
{return(obj!==null&&typeof(obj)=="object");}
function isElement(obj)
{return(obj!==null&&typeof(obj)=="object"&&obj.nodeType==1);}
function isArray(obj)
{return(obj instanceof Array);}
function varDefault(value,defaultValue)
{return(typeof(value)=="undefined"||value===null||value==="")?defaultValue:value;}
function intVal(value)
{var v=parseInt(value,10);return isNaN(v)?0:v;}
function boolVal(value)
{return(value==true);}
function floatVal(value)
{var v=parseFloat(value);return isNaN(v)?0:v;}
function round(value,decimals)
{var aux=Math.pow(10,intVal(decimals));return Math.round(value*aux)/aux;}
function hex(dec)
{return dec.toString(16);}
function dec(hex)
{return parseInt(hex,16);}
function bitMask(value,mask)
{return((value&mask)==mask);}
function cssToJs(property)
{if(!property)return"";var arr=property.split("-"),str="",word="";for(var i=0;i<arr.length;i++){word=arr[i].toString();if(i>0)
str+=(word.charAt(0).toUpperCase()+word.substr(1));else
str+=word;}
return str;}
function jsToCss(property)
{if(!property)return"";property=property.toString();var str="",ch,capitalize=false;for(var i=0;i<property.length;i++){ch=property.charAt(i);if(ch>="A"&&ch<="Z")
str+=("-"+ch.toLowerCase());else
str+=ch;}
return str;}
function nl2br(str)
{return str.replace(/\r?\n/g,"<br>");}
function obj2Array(obj)
{if(!obj||!obj.length)return null;var res=[];for(var i=0;i<obj.length;i++){res.push(obj[i]);}
return res;}
function arrayMap(arr,func,bind){var results=[];for(var i=0,j=arr.length;i<j;i++){results[i]=func.call(bind,arr[i],i,arr);}
return results;}
function arraySearch(arr,val,using)
{if(arr instanceof Array){if(typeof(using)!="undefined"){for(var i=0;i<arr.length;i++){if(arr[i][using]==val)return i;}}
else{for(var i=0;i<arr.length;i++){if(arr[i]==val)return i;}}}
else{if(typeof(using)!="undefined"){for(var k in arr){if(arr[k][using]==val)return k;}}
else{for(var k in arr){if(arr[k]==val)return k;}}}
return null;}
function inArray(arr,value,ignoreCase,using)
{if(!arr||typeof(arr)!="object"||typeof(value)=="undefined")return null;if(typeof(value)=="string"&&ignoreCase){var val=value.toLowerCase();if(typeof(using)!="undefined")
for(var i in arr){if(arr[i][using].toString().toLowerCase()==val)return true;}
else
for(var i in arr){if(arr[i].toString().toLowerCase()==val)return true;}}
else if(typeof(using)!="undefined")
for(var i in arr){if(arr[i][using]==value)return true;}
else
for(var i in arr){if(arr[i]==value)return true;}
return false;}
function arrayMerge(arr1,arr2,arrN)
{var res=new Array();for(var i=0;i<arguments.length;i++){if(!arguments[i]||typeof(arguments[i])!="object")
throw"arrayMerge: Argument no. "+(i+1)+" must be an Array object";for(var k in arguments[i]){if(isInteger(k))
res.push(arguments[i][k]);else
res[k]=arguments[i][k];}}
return res;}
function arrayIntersect(arr1,arr2)
{if(!arr1||!arr2||arr1.constructor!=Array||arr2.constructor!=Array)return false;var index=0;var intersection=new Array();for(var i=0;i<arr1.length;i++){for(var j=0;j<arr2.length;j++){if(arr1[i]==arr2[j])
intersection[index++]=arr1[k1];}}
return intersection;}
function arrayEquals(arr1,arr2)
{if(!arr1||!arr2||!(arr2 instanceof Array)||!(arr2 instanceof Array))return false;if(arr1.length!=arr2.length)return false;var match;for(var i=0;i<arr1.length;i++){match=false;for(var j=0;j<arr2.length;j++){if(arr1[i]==arr2[j]){match=true;break;}}
if(!match)return false;}
return true;}
function arrayConcat(arr,rowGlue,keyValueGlue)
{if(typeof(arr)!="object")return false;res="";for(var k in arr){res+=k+keyValueGlue+arr[k]+rowGlue;}
return res.trim(rowGlue);}
function arrayInsertAt(arr,item,position)
{if(typeof(arr)!="object"||arr.constructor!=Array)
throw"arrayInsertAt: el primer par?metro debe ser un Array";if(typeof(position)=="undefined"||position>arr.length){arr.push(item);return arr;}
else{var aux=arr.slice(0,position);return aux.concat([item],arr.slice(position,arr.length));}}
function arrayRemove(arr,element)
{var aux=new Array();for(var i=0;i<arr.length;i++)
{if(arr[i]!==element)
aux.push(arr[i]);}
return aux;}
function arrayRemoveAt(arr,index)
{var aux=new Array();for(var i=0;i<arr.length;i++)
{if(i!=index)
aux.push(arr[i]);}
return aux;}
function arrayReduce(arr,callback)
{if(!arr||!callback)
throw"arrayReduce: Debe proporcionar un objeto Array y una funcion que retorne true o false para cada valor";var aux=new Array();for(var i=0;i<arr.length;i++){if(callback(arr[i])==true)aux.push(arr[i]);}
return aux;}
function sprintf(formatString,varArgList)
{var txt=arguments[0];for(var a=1;a<arguments.length;a++){txt=txt.replace('%'+a,arguments[a]);}
return txt;}
function includeOnce(includeFile,constantName)
{var isIncluded=false;if(!isIncluded)
document.writeln('<'+'script language="javascript" src="'+includeFile+'"></'+'script>');else
alert(includeFile+" ya est? incluido");}
function clone(obj,deep)
{if(!isObject(obj))throw"clone: Debe proporcionar un objeto a clonar";var aux=new obj.constructor();for(var k in obj){if(isObject(obj[k])&&deep==true)
aux[k]=clone(obj[k],deep);else
aux[k]=obj[k];}
return aux;}
cloneObject=clone;function getRef(refString,context)
{if(refString==null||refString=="")
throw"getRef: Debe proporcionar un string para obtener la referencia";if(context==null)
context=window;else if(typeof(context)!="object")
throw"getRef: El contexto debe ser un objeto";var refs=refString.split(".");var ref=context;for(var i=0;i<refs.length;i++){ref=ref[refs[i]];if(typeof(ref)=="undefined")return null;}
return ref;}
function getElem(id,context)
{var obj=null;if(isObject(id))return id;if(typeof(context)!="object")
context=document;if(context.getElementById)
obj=context.getElementById(id);else
obj=context.all[id];return obj;}
function getByAttrib(attribute,value,context,getAll)
{if(attribute==""&&value=="")return null;attribute=attribute.toString();value=value.toString();var obj=null;getAll=(getAll==true);var elems=new Array();if(!context)context=document;var getOut=false;var _recurse=function(currentNode){if(currentNode.attributes){var att=currentNode.attributes[attribute];if(att&&att.value==value){elems.push(currentNode);if(getAll==false)return true;}}
for(var i=0;i<currentNode.childNodes.length;i++){if(_recurse(currentNode.childNodes[i])==false){return true;}}}
_recurse(context);return elems;}
function getTag(obj,tag)
{for(var i=0;i<obj.childNodes.length;i++){if(obj.childNodes[i].tagName==tag)
return obj.childNodes[i];}
return null;}
function getAllTags(tagName,context)
{var obj=null;if(!context||typeof(context)!="object")
context=document;if(context.getElementsByTagName)
obj=context.getElementsByTagName(tagName);else
obj=context.all.tags[tagName];return obj;}
function getAttrib(elm,attrib)
{if(attrib==null)
return false;if(typeof(elm)=="string")
elm=getElem(elm);var att=elm.attributes[attrib];if(att!=null&&typeof(att)!="undefined")
return att.value;else
return null;}
function getStyle(elm)
{if(typeof(elm)=="string")
elm=getElem(elm);if(elm==null||typeof(elm)!="object")
return null;return(elm.style)?elm.style:elm;}
function getCurrentStyle(elm)
{if(typeof(elm)=="string")elm=getElem(elm);if(!elm||elm.nodeType!=1)return null;if(elm.currentStyle)
return elm.currentStyle;else if(elm.style)
return document.defaultView.getComputedStyle(elm,null);else
return elm;}
function getCurrentStyleProp(elm,property)
{if(typeof(elm)=="string")elm=getElem(elm);if(!elm||!property||elm.nodeType!=1)return null;if(elm.currentStyle){return elm.currentStyle[property];}
else{var prop=elm.style[property]||"";if(prop!="")
return prop;else
return document.defaultView.getComputedStyle(elm,null).getPropertyValue(jsToCss(property));}}
function getFrameDoc(iframe)
{if(typeof(iframe)=="string")
iframe=getElem(iframe);if(iframe==null||typeof(iframe)!="object")return null;if(Browser.isIE)
return iframe.contentWindow.document;else if(Browser.isMozilla)
return iframe.contentDocument;else if(Browser.isOpera)
return iframe.document;}
function getBounds(htmlNode,relativeTo)
{var xy=getXY(htmlNode,relativeTo);var wh=getSize(htmlNode);return{"x":xy.x,"y":xy.y,"width":wh.width,"height":wh.height};}
function getXY(htmlNode,relativeTo)
{if(!htmlNode)throw"Debe proporcionar un elemento HTML";if(htmlNode.nodeType!=1)throw htmlNode+" no es un elemento HTML";if(!relativeTo)relativeTo=document.body;var x=0,y=0,offsetParent=htmlNode.offsetParent,lastOffsetParent=null,level=0;var nextOffsetParent=htmlNode.offsetParent;while(htmlNode!=null&&htmlNode!=relativeTo)
{if(htmlNode.offsetParent!=lastOffsetParent){x+=htmlNode.offsetLeft+intVal(htmlNode.style.paddingLeft);y+=htmlNode.offsetTop+intVal(htmlNode.style.paddingTop);if(htmlNode!=document.body){x-=htmlNode.scrollLeft;y-=htmlNode.scrollTop;}
lastOffsetParent=htmlNode.offsetParent;}
htmlNode=htmlNode.parentNode;}
return{"x":x,"y":y};}
function getSize(htmlNode)
{if(!htmlNode)throw"Debe proporcionar un elemento HTML";if(htmlNode.nodeType!=1)throw htmlNode+" no es un elemento HTML";var w=htmlNode.offsetWidth;var h=htmlNode.offsetHeight;if(w==0&&h==0){var st;if(Browser.isIE){st=htmlNode.currentStyle||{};}
else{st=document.defaultView.getComputedStyle(htmlNode,null);}
if(st==null)debugger;w=floatVal(st.width);h=floatVal(st.height);}
return{"width":w,"height":h};}
function insertHTML(node,html)
{if(!node)throw"Debe proporcionar un nodo HTML en el cual insertar el contenido";if(!html)return;if(Browser.isIE||Browser.isOpera){node.insertAdjacentHTML("beforeEnd",html);}
else if(Browser.isMozilla){var r=null,df=null;r=document.createRange();r.setStartBefore(document.body.firstChild);df=r.createContextualFragment(html);node.appendChild(df);}}
function createText(text)
{return document.createTextNode(text);}
function openLocation(url,width,height,name,scrollbar,returnHandle)
{if(name!=""){var winHandle=openPopup(url,width,height,name,scrollbar,true,true);if(returnHandle)
return winHandle;}
else
window.location=url;}
function openPopup(url,width,height,name,scrollbars,resizable,returnHandle)
{var params=new Array(),winHandle=null;if(width!=null)params.push("width="+width);if(height!=null)params.push("height="+height);params.push("scrollbars="+(scrollbars==true?1:0));params.push("resizable="+(resizable==true?1:0));try{winHandle=window.open(url,name,params.join(", "));if(winHandle){winHandle.focus();}}catch(e){}
if(returnHandle==true)return winHandle;}
function openWindow(url,target,options,returnHandle)
{var target=target||"_blank";var params=new Array();for(var k in options){params.push(k+"="+options[k].toString());}
try{winHandle=window.open(url,target,params.join(", "));if(winHandle){winHandle.focus();winHandle.onblur=new Function("this.close();");}}
catch(e){}
if(returnHandle==true)return winHandle;}
function populateSelectInterval(target,min,max,sel,nullEntry,keepOld)
{var currIndex,count;if(!target)
throw"populateSelectInterval: Debe proporcionar un elemento SELECT";if(keepOld!=true)
target.options.length=0;if(typeof(nullEntry)!="undefined"&&nullEntry!==null)
target.options[target.options.length]=new Option(nullEntry,"",false,(""==sel));if(min>max)
for(var i=min;i>=max;i--){count=target.options.length;target.options[count]=new Option(i,i,false,(i==sel));if(i==sel)currIndex=count;}
else
for(var i=min;i<=max;i++){count=target.options.length;target.options[count]=new Option(i,i,false,(i==sel));if(i==sel)currIndex=count;}
target.selectedIndex=currIndex;}
function getSelectedValue(targetSel)
{if(typeof(targetSel)=="string")
targetSel=getElem(targetSel);if(typeof(targetSel)!="object"||targetSel==null)return false;var i=targetSel.selectedIndex;if(i<0)
return null;else
return targetSel.options[i].value;}
function setSelectedValue(obj,value){for(var i=0;i<obj.length;i++){if(obj.options[i].value==value){obj.selectedIndex=i;}}}
function selectToArray(obj)
{if(!obj)
return false;if(!obj.options)
return false;var arr=new Array();for(var i=0;i<obj.options.length;i++){arr[i]=new Array(obj.options[i].value,obj.options[i].text);}
return arr;}
function selectToCSV(obj)
{if(!obj)
return false;if(!obj.options)
return false;var arr=new Array();for(var i=0;i<obj.options.length;i++){arr[i]=obj.options[i].value;}
return arr.join(",");}
function getRadioValue(targetRadio)
{if(!isObject(targetRadio))return false;for(var i=0;i<targetRadio.length;i++){if(targetRadio[i].checked)
return targetRadio[i].value;}
return null;}
function setRadioValue(targetRadio,value)
{if(!isObject(targetRadio))return false;for(var i=0;i<targetRadio.length;i++){targetRadio[i].checked=(targetRadio[i].value==value);}}
function getCheckedOptions(obj)
{var arr=new Array(),c=0;if(typeof(obj)!="object"||obj==null)
return false;for(var i=0;i<obj.length;i++){if(obj[i].checked==true)
arr[c++]=obj[i].value;}
return arr;}
function rgb(red,green,blue)
{var f=function(val){return(Math.min(Math.max(0,intVal(val)),255)).toString(16).padLeft(2,'0');};return("#"+f(red)+f(green)+f(blue));}
function pixelsToPoints(pixels)
{return pixels/4*3;}
function pointsToPixels(points)
{return points/3*4;}
function toPixels(value)
{var re=new RegExp("([+\\-.0-9])+(%|pt)");return parseFloat(value);}
function stringToDate(dateString)
{if(!dateString)return null;dateString=dateString.toString().replace(new RegExp("[^0-9]","g"),"");var d={"Y":parseInt(dateString.substr(0,4),10),"M":parseInt(dateString.substr(4,2),10),"D":parseInt(dateString.substr(6,2),10),"h":parseInt(dateString.substr(8,2),10)||0,"m":parseInt(dateString.substr(10,2),10)||0,"s":parseInt(dateString.substr(12,2),10)||0};return new Date(d.Y,d.M-1,d.D,d.h,d.m,d.s);}
function appendToPath(path,append)
{path=varDefault(path,"").toString().replace(new RegExp("\\\\","g"),"/").replace(new RegExp("//","g"),"/");var lastDot=path.lastIndexOf(".");var name=(lastDot>0)?path.substr(0,lastDot):path;var extension=(lastDot>0)?path.substr(lastDot+1):"";var res=name+append;if(extension!="")res+=("."+extension);return res;}
function getBaseName(path)
{path=varDefault(path,"").toString().replace(new RegExp("\\\\","g"),"/").replace(new RegExp("//","g"),"/");var baseName=path.substr(path.lastIndexOf("/")+1);if(stripExtension==true){var lastDot=baseName.lastIndexOf(".");if(lastDot>0)
baseName=baseName.substr(0,lastDot);}
return baseName;}
function splitPath(path)
{path=varDefault(path,"").toString().replace(new RegExp("\\\\","g"),"/").replace(new RegExp("//","g"),"/");var lastSlash=path.lastIndexOf("/");var res=new Object();res.path=path.substr(0,lastSlash+1);res.baseName=path.substr(lastSlash+1);var lastDot=res.baseName.lastIndexOf(".");res.name=(lastDot>0)?res.baseName.substr(0,lastDot):res.baseName;res.extension=(lastDot>0)?res.baseName.substr(lastDot+1):"";return res;}
function ld_error(msg,returnValue)
{alert(msg);return(typeof(returnValue)!="undefined")?retValue:false;}
function doDeferredInits(objId)
{if(objId)
aDeferredInits[objId].init();else
for(var k in aDeferredInits){aDeferredInits[k].init();}}
function newClass(classRefName,baseConstructor,newConstructor,classMembers,instanceMembers,interfaces)
{if(newConstructor==null)
newConstructor=function()
{arguments.callee.superConstructor.apply(this,arguments);}
if(baseConstructor!=null){if(typeof(baseConstructor)!="function")
throw"extend: Must provide a base constructor function";newConstructor.extend(baseConstructor);}
if(classMembers!=null)
aggregate(newConstructor,classMembers);if(instanceMembers!=null)
aggregate(newConstructor.prototype,instanceMembers);classRefName=varDefault(classRefName,"");if(classRefName!="")
newConstructor._className=classRefName;return newConstructor;}
Function.prototype.extend=function(baseClassOrObject)
{var myConstructor=this;inheritAllButConstructor=function(){};inheritAllButConstructor.prototype=baseClassOrObject.prototype;this.prototype=new inheritAllButConstructor();this.prototype.constructor=myConstructor;this.superConstructor=baseClassOrObject;this.superClass=baseClassOrObject.prototype;return this;}
function aggregate(baseObject,aggregatedProperties,preserve)
{for(var k in aggregatedProperties){if(preserve!=true||typeof(baseObject[k])=="undefined")
baseObject[k]=aggregatedProperties[k];}
return baseObject;}
function instanceOf(obj,classesOrInterfaces)
{if(!obj||arguments.length<2)return false;var classOrInterface=null,type,matches;for(var i=1;i<arguments.length;i++){classOrInterface=arguments[i];type=typeof(classOrInterface);if(type=="function"&&(obj instanceof classOrInterface))return true;matches=true;if(classOrInterface&&type=="object"){for(var x in classOrInterface){if(typeof(classOrInterface[x])=="function"&&typeof(obj[x])!="function")
matches=false;}}
if(matches==true)return true;}}
function getQueryVariable(variable)
{var query=window.location.search.substring(1);var vars=query.split("&");var pair;for(var i=0;i<vars.length;i++){pair=vars[i].split("=");if(pair[0]==variable)
return pair[1];}}
function getStaticUrl(baseUrl,path)
{var v=sumOrd(path)%(10);return baseUrl.replace("http://","http://assets"+v+".")+path;}
function getImageURL(path)
{if(!USE_MULTIPLE_STATIC_DOMAINS){return URL_SOURCE_IMAGES+path;}
return getStaticUrl(URL_SOURCE_IMAGES,path);}
function getAvatarURL(path)
{if(!USE_MULTIPLE_STATIC_DOMAINS){return URL_AVATARS+path;}
return getStaticUrl(URL_AVATARS,path);}
function getWallpaperUrl(path)
{if(!USE_MULTIPLE_STATIC_DOMAINS){return URL_WALLPAPERS+path;}
return getStaticUrl(URL_WALLPAPERS,path);}
Function.prototype.assertInterface=function(interfaceObject1,interfaceObjectN)
{var theInterface,missing=new Array();for(var i=0;i<arguments.length;i++){theInterface=arguments[i];if(theInterface&&typeof(theInterface=="object")){for(var x in theInterface){if(typeof(theInterface[x])=="function"&&typeof(this.prototype[x])!="function")
missing.push(x);}}}
if(missing.length>0)
throw"La clase "+this.getName()+" no implementa los siguientes métodos:\r\n"+
missing.join(", ");+"\r\n--------\r\n"+this.toString();}
Function.prototype.getName=function()
{if(this._className&&this._className!="")
return this._className;var code=this.toString();var re=new RegExp("^\\s*function\\s+(\\w+)\\b","i");res=code.match(re);return(res==null)?"":res[1];}
String.prototype.toAnsi=function(replaceWith)
{replaceWith=varDefault(replaceWith,"").substr(0,1);var str="",ch;for(var i=0;i<this.length;i++){ch=(this.charCodeAt(i)<256)?this.charAt(i):replaceWith;str=str.concat(ch);}
return str;}
String.prototype.trim=function(charset,caseInsensitive)
{charset=(charset==null)?"[\\s]+":"["+charset+"\\s]+";var re=new RegExp("(^"+charset+")|("+charset+"$)","g"+((caseInsensitive)?"i":""));return this.replace(re,"");}
String.prototype.lTrim=function(charset,caseInsensitive)
{charset=(charset==null)?"[\\s]+":"["+charset+"\\s]+";var re=new RegExp("^"+charset,"g"+((caseInsensitive==true)?"i":""));return this.replace(new RegExp("^"+charset,"g"+((caseInsensitive)?"i":"")),"");}
String.prototype.rTrim=function(charset,caseInsensitive)
{charset=(charset==null)?"[\\s]+":"["+charset+"\\s]+";var re=new RegExp(charset+"$","g"+((caseInsensitive==true)?"i":""));return this.replace(re,"");}
String.prototype.addSlashes=function(charset)
{return this.replace(new RegExp("\\\\","g"),"\\\\").replace(new RegExp("\r","g"),"\\r").replace(new RegExp("\n","g"),"\\n").replace(new RegExp("\0","g"),"\\0").replace(new RegExp('"',"g"),'\\"');}
String.prototype.stripChars=function(charset,replaceWith,caseInsensitive)
{if(charset==null)return this;var re=new RegExp("["+charset+"]+","g"+((caseInsensitive==true)?"i":""));return this.replace(re,replaceWith);}
String.prototype.repeat=function(loops)
{var result="";for(var i=0;i<loops;i++){result+=this.toString();}
return result;}
String.prototype.padLeft=function(length,filler)
{filler=varDefault(filler,"");var result=""+this;while(result.length<length){result=filler+result;}
return result.substr(result.length-length);}
String.prototype.padRight=function(length,filler)
{filler=varDefault(filler,"");var result=""+this;while(result.length<length){result=result+filler;}
return result.substr(0,length-1);}
String.prototype.htmlSpecialChars=function()
{var aux=this;aux=aux.replace(new RegExp("&","g"),"&amp;");aux=aux.replace(new RegExp("<","g"),"&lt;");aux=aux.replace(new RegExp(">","g"),"&gt;");return aux;}
String.prototype.unHtmlSpecialChars=function()
{var aux=this;aux=aux.replace(new RegExp("&lt;","g"),"<");aux=aux.replace(new RegExp("&gt;","g"),">");aux=aux.replace(new RegExp("&amp;","g"),"&");return aux;}
String.prototype.truncate=function(length,filler)
{if(filler==null)filler="...";if(this.length<=length)return this;return""+this.substr(0,Math.max(1,length-filler.length))+filler;}
String.prototype.parse=function(args)
{var num=arguments.length;if(num<1)return this;var str=this;for(var i=num;i>=0;--i){str=str.replace(new RegExp("%"+(i+1),"g"),arguments[i]);}
return str;}
Date.prototype.toMilitary=function(full,utc)
{var dt,tm;if(utc==true){dt={y:this.getUTCFullYear(),m:(this.getUTCMonth()+1),d:this.getUTCDate()};tm={h:this.getUTCHours(),m:this.getUTCMinutes(),s:this.getUTCSeconds()};}
else{dt={y:this.getFullYear(),m:(this.getMonth()+1),d:this.getDate()};tm={h:this.getHours(),m:this.getMinutes(),s:this.getSeconds()};}
var str=dt.y.toString().padLeft(4,"0")+dt.m.toString().padLeft(2,"0")+dt.d.toString().padLeft(2,"0");if(full)
str+=(tm.h.toString().padLeft(2,"0")+tm.m.toString().padLeft(2,"0")+tm.s.toString().padLeft(2,"0"));return str;}
if(Browser.isMozilla){HTMLElement.prototype.removeNode=function()
{this.parentNode.removeChild(this);}}

/*========== LD.js ==========*/

var LD=new Object();LD.CRLF="\r\n";LD.CR="\r";LD.LF="\n";LD.NODE_ELEMENT=1;LD.NODE_TEXT=3;LD.Proto=function()
{this.parent=null;}
LD.Proto.superConstructor=Object;LD.Proto.prototype.getParent=function()
{return this.parent;}
LD.Proto.prototype.setParent=function(parent)
{if(parent===null){this.parent=null;return;}
else if(!parent||!(parent instanceof LD.Proto))
throw"LD.Proto.setParent: Must provide a LD.Proto object as parent";this.parent=parent;}
LD.Proto.prototype.addListener=function(eventType,callback,listener)
{LD.EventDispatcher.add(this,listener,eventType,callback);}
LD.Proto.prototype.removeListener=function(eventType,listener)
{LD.EventDispatcher.remove(this,listener,eventType);}
LD.Proto.prototype.removeAllListeners=function(eventType)
{LD.EventDispatcher.removeAll(this,eventType);}
LD.Proto.prototype.fireEvent=function(evt,eventType)
{LD.EventDispatcher.fire(this,eventType,evt);}
LD.errors=new Object();LD.assertFreeErrorCodeRange=function(min,max)
{for(var i=min;i<=max;i++){if(LD.errors[i])throw"LD.assertFreeErrorCodeRange: Error code "+i+" is already taken";}}
LD.Event={normalize:function(evt)
{evt=evt||window.event||null;if(evt&&Browser.isIE&&evt.srcElement)
evt.target=evt.srcElement;return evt;},cancel:function(evt,cancelBubble)
{if(!evt&&Browser.isIE)evt=this.normalize(evt);if(document.all)
evt.returnValue=false;else
evt.preventDefault();if(cancelBubble==true)
this.stopPropagation(evt);},stopPropagation:function(evt)
{if(!evt&&Browser.isIE)evt=this.normalize(evt);if(document.all)
evt.cancelBubble=true;else
evt.stopPropagation();}}
LD.EventDispatcher={listenings:new Array(),listeningsIdx:[],add:function(source,listener,eventType,callback)
{if(isArray(source))
{for(var i=0;i<source.length;i++)
{this.add(source[i],listener,eventType,callback);}}
else
{if(!isObject(source)&&typeof(source)!="function"){throw"LD.EventDispatcher.add: Must provide a source object for the event";}
if(typeof(eventType)!="number"){throw"LD.EventDispatcher.add: Must specify the type of event to listen to";}
if(typeof(callback)!="function"){throw"LD.EventDispatcher.add: Must provide a callback function to get the notification";}
var listening={source:source,listener:listener||null,eventType:eventType,callback:callback}
this.listenings.push(listening);if(!this.listeningsIdx[eventType]){this.listeningsIdx[eventType]=[];}
this.listeningsIdx[eventType].push(listening);}},getAllHaving:function(sourceOrListener,eventType)
{var i=0,l=null,aux=new Array();if(isObject(sourceOrListener)){for(i=0;i<this.listenings.length;i++){l=this.listenings[i];if(l.source==sourceOrListener||l.listener==sourceOrListener)
aux.push(l);}}
else if(typeof(eventType=="number")){for(i=0;i<this.listenings.length;i++){l=this.listenings[i];if(l.eventType==eventType)
aux.push(l);}}
else
throw"LD.EventDispatcher.getAllHaving: Must provide the event source/listener or event type";return aux;},fire:function(source,eventType,evt)
{if(typeof(eventType)!="number")
throw"LD.EventDispatcher.fire: Must specify the type of event to fire";evt=evt||null;var l;if(this.listeningsIdx[eventType]){for(var i=0;i<this.listeningsIdx[eventType].length;i++){l=this.listeningsIdx[eventType][i];if(l.eventType==eventType&&(source.constructor==l.source||l.source==source)){l.callback.call(l.listener,evt,eventType,l.source);}}}},remove:function(source,listener,eventType)
{if(!isObject(source)&&typeof(source)!="function"){throw"LD.EventDispatcher.remove: Must provide an event source to stop listening to";}
if(typeof(eventType)!="number")
throw"LD.Proto.remove: Must specify the type of event to stop listening to";listener=listener||null;var i=0,l=null;while(i<this.listenings.length){l=this.listenings[i];if(l.source==source&&l.listener==listener&&l.eventType==eventType){this.listenings.splice(i,1);}else{++i;}}
if(this.listeningsIdx[eventType]){i=0;while(i<this.listeningsIdx[eventType].length){l=this.listeningsIdx[eventType][i];if(l.source==source&&l.listener==listener&&l.eventType==eventType){this.listeningsIdx[eventType].splice(i,1);}else{++i;}}}},removeAll:function(source,eventType)
{if(!isObject(source))
throw"LD.EventDispatcher.removeAll: Must provide an event source to stop listening to";var i=0,l=null;if(typeof(eventType)!="number")eventType=null;while(i<this.listenings.length){l=this.listenings[i];if(l.source==source&&(eventType==null||l.eventType==eventType))
this.listenings.splice(i,1);else
++i;}
this.listeningsIdx[eventType]=[];},removeAllHaving:function(sourceOrListener)
{if(!isObject(sourceOrListener))
throw"LD.EventDispatcher.removeAllHaving: Must provide the event source/listener";var i=0,l=null;while(i<this.listenings.length){l=this.listenings[i];if(l.source==sourceOrListener||l.listener==sourceOrListener){this.listenings.splice(i,1);}else{++i;}}
for(var eventType in this.listeningsIdx){var i=0;while(i<this.listeningsIdx[eventType].length){l=this.listeningsIdx[eventType][i];if(l.source==sourceOrListener||l.listener==sourceOrListener){this.listeningsIdx[eventType].splice(i,1);}else{++i;}}}}}
LD.Element={create:function(tagName,attributes,styles)
{var newElem;var att={"strings":{},"objects":{}};if(Browser.isIE){for(var k in attributes){if(typeof(attributes[k])=="object"||typeof(attributes[k])=="function")
att.objects[k]=attributes[k];else
att.strings[k]=attributes[k];}
var mappings={className:"class"};var html='<'+tagName.toString().toUpperCase();var attribName,attribValue;for(var k in att.strings){attribName=mappings[k]||k;attribValue=att.strings[k].toString().replace("\\","\\\\").replace('"','\\"');html+=(" "+attribName+'="'+attribValue+'"');}
html+='>';newElem=document.createElement(html);}
else{att.objects=attributes;newElem=document.createElement(tagName);}
for(var k in att.objects){newElem[k]=att.objects[k];}
for(var k in styles){newElem.style[k]=styles[k];}
return newElem;},addListener:function(node,evtType,func)
{if(!node)return;if(node instanceof Array){for(var i=0;i<node.length;i++){arguments.callee(node[i],evtType,func);}}
else{if(node.addEventListener)
node.addEventListener(evtType,func,false);else
node.attachEvent("on"+evtType,func);}},remove:function(node)
{if(node!=null&&node.parentNode!=null){node.parentNode.removeChild(node);}},removeChildren:function(node)
{if(!node||node.nodeType!=LD.NODE_ELEMENT)return;while(node.firstChild){node.removeChild(node.firstChild);}},wrapInnerText:function(node,options)
{if(!node||node.nodeType!=LD.NODE_ELEMENT||node.offsetHeight==0)return false;var innerText=node.firstChild;if(!innerText||innerText.nodeType!=LD.NODE_TEXT)return false;if(!isObject(options))
options=new Object();options.filler=varDefault(options.filler,"...").toString();options.tolerance=intVal(varDefault(options.tolerance,1));options.toolTip=varDefault(options.toolTip,true);var step=options.filler.length+1;var aux=innerText.nodeValue,newText;while(innerText.length>step&&((node.offsetHeight+options.tolerance)<node.scrollHeight||(node.offsetWidth+options.tolerance)<node.scrollWidth))
{newText=createText(innerText.nodeValue.substr(0,innerText.nodeValue.length-step)+options.filler);node.replaceChild(newText,innerText);innerText=newText;}
if(options.toolTip!==false&&innerText.nodeValue!=aux){node.title=aux;}},writeText:function(node,text,replace)
{if(!node||node.nodeType!=LD.NODE_ELEMENT)return false;if(replace==true)
this.removeChildren(node);node.appendChild(createText(text));},hasClass:function(node,className)
{return inArray(node.className.split(" "),className);},putClass:function(node,className)
{var classes=node.className.split(" ");if(!inArray(classes,className)){classes.push(className);node.className=classes.join(" ");}},removeClass:function(node,className)
{var classes=node.className.split(" ");node.className=arrayRemove(classes,className).join(" ");},toggleClass:function(node,className)
{var classes=node.className.split(" ");if(inArray(classes,className)){node.className=arrayRemove(classes,className).join(" ");}
else{classes.push(className);}
node.className=classes.join(" ");}}
LD.Con=new Object();LD.Con.print=function(text)
{if(!LD.Con.target)LD.Con.setTarget(document.body);LD.Con.target.appendChild(document.createTextNode(text));}
LD.Con.println=function(text)
{LD.Con.print(text+"\n");}
LD.Con.setTarget=function(target)
{LD.Con.target=(target||document.body);}
LD.Pointer={point:function(x,y,color,desktop)
{if(!desktop)desktop=document.body;if(!this.pointer){this.pointer=document.createElement("DIV");with(this.pointer.style){position="absolute";width="3px";height="3px";border="1px solid red";font="1px normal serif";zIndex=123456789;}}
desktop.appendChild(this.pointer);if(color)this.pointer.style.borderColor=color;this.pointer.style.left=intVal(x)-1;this.pointer.style.top=intVal(y)-1;}}
LD.Cookie=new LD.Proto();LD.Cookie.set=function(name,value,days)
{var expires;if(days){var date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));expires="; expires="+date.toGMTString();}
else
expires="";document.cookie=name+"="+value+expires+"; path=/";}
LD.Cookie.get=function(name)
{var nameEQ=name+"=";var ca=document.cookie.split(';');var c;for(var i=0;i<ca.length;i++){c=ca[i];while(c.charAt(0)==' '){c=c.substring(1,c.length);}
if(c.indexOf(nameEQ)==0)return c.substring(nameEQ.length,c.length);}
return null;}
LD.Cookie.erase=function(name)
{this.set(name,"",-1);}
LD.Validation={isEmail:function(str)
{var re=new RegExp("^[A-Za-z0-9]+([_\\.\\-][A-Za-z0-9]+)*@[A-Za-z0-9]+([_\\.\\-][A-Za-z0-9]+)*\\.([A-Za-z]){2,4}$","i");return re.test(varDefault(str,""));},isUrl:function(str,protocols)
{if(!(protocols instanceof Array))protocols=["tcp","http","https","ftp"];var re=new RegExp("^("+protocols.join("|")+"):\\/\\/(\\w+:{0,1}\\w*@)?(\\S+)(:[0-9]+)?(\\/|\\/([\\w#!:.?+=&%@!\\-\\/]))?$");return re.test(varDefault(str,""));},isIP:function(str)
{var match=str.match(/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/);return match!=null&&match[1]<256&&match[2]<256&&match[3]<256&&match[4]<256;},lengthBetween:function(str,min,max)
{str=varDefault(str,"");if(typeof(min)!="undefined"&&typeof(max)!="undefined")
return(str.length>=min&&str.length<=max);else if(typeof(min)!="undefined")
return(str.length>=min);else if(typeof(max)!="undefined")
return(str.length<=max);else
return true;}}
LD.ScriptLoader=function(callback,callbackObject)
{this.queue=new Array();this.loadedScripts=new Object();this.callback=callback||null;this.callbackObject=(callback&&callbackObject)?callbackObject:null;}
LD.ScriptLoader.prototype.addScript=function(id,url)
{if((id=varDefault(id,"").toString())=="")return false;if(this.isScriptLoaded(id)||this.isScriptInQueue(id))return true;url=varDefault(url,DIR_ROOT+DIR_SCRIPTS+id);this.queue.push({id:id,url:url});return true;}
LD.ScriptLoader.prototype.process=function()
{if(this.queue.length==0){if(this.callback)this.callback.call(this.callbackObject);return;}
var _this=this;var def=this.queue.shift();var script=LD.Element.create("SCRIPT");script.id=def.id;script.src=def.url;script.type="text/javascript";if(Browser.isIE){script.onreadystatechange=function(){if(this.readyState=="complete"||this.readyState=="loaded")
_this.scriptLoaded(this);}}
else{script.onload=function(){_this.scriptLoaded(this);}}
document.body.appendChild(script);}
LD.ScriptLoader.prototype.isScriptLoaded=function(id)
{return(typeof(this.loadedScripts[id])!="undefined");}
LD.ScriptLoader.prototype.isScriptInQueue=function(id)
{for(var i=0;i<this.queue.length;i++){if(this.queue[i].id==id)return true;}
return false;}
LD.ScriptLoader.prototype.scriptLoaded=function(script)
{if(!script)return;this.loadedScripts[script.id]=script;this.process();}

/*========== json.js ==========*/

var Json={toString:function(obj)
{switch(getType(obj)){case'string':return'"'+obj.replace(/(["\\])/g,'\\$1')+'"';case'array':return'['+arrayMap(obj,Json.toString).join(',')+']';case'object':var string=[];for(var property in obj)string.push(Json.toString(property)+':'+Json.toString(obj[property]));return'{'+string.join(',')+'}';case'number':if(isFinite(obj))break;case false:return'null';}
return String(obj);},evaluate:function(str,secure)
{if(str!=null&&str!=""){var res=((getType(str)!='string')||(secure&&!str.test(/^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/)))?null:eval('('+str+')');return res;}
else{return null;}}};

/*========== Ajax.js ==========*/

var Ajax=new Object();Ajax.METHOD_GET="GET";Ajax.METHOD_POST="POST";Ajax.RESPONSE_PLAIN=1;Ajax.RESPONSE_XML=2;Ajax.RESPONSE_HTML=3;Ajax.RESPONSE_SERIALIZED=4;Ajax.RESPONSE_HTML_SERIALIZED=5;Ajax.RESPONSE_JSON=6;Ajax.RESPONSE_HTML_JSON=7;Ajax.STATE_UNINITIALIZED=0;Ajax.STATE_LOADING=1;Ajax.STATE_LOADED=2;Ajax.STATE_INTERACTIVE=3;Ajax.STATE_COMPLETE=4;Ajax.CACHE_NONE="no-cache";Ajax.XML_NODE_DOCUMENT=0;Ajax.XML_NODE_TAG=1;Ajax.XML_NODE_TEXT=2;Ajax.xmlToStruct=function(node,level)
{level=intVal(level);if(!node||typeof(node)!="object")
throw"Ajax.xmlToStruct: must provide an XML node to process";var c=0,aux=null,attrib=null,str="";var nodeStruct=new XMLNodeStruct(node);nodeStruct.level=level;if(node.tagName)
for(var i=0;i<node.attributes.length;i++){attrib=node.attributes[i];nodeStruct.attributes[attrib.nodeName.toLowerCase()]=attrib.nodeValue;}
if(node.tagName||node.parentNode==null)
for(var i=0;i<node.childNodes.length;i++){aux=Ajax.xmlToStruct(node.childNodes[i],level+1);if(aux){if(aux.type==Ajax.XML_NODE_TEXT){str=(aux.value||"").trim("\\n\\r\\t\\s");if(str)
nodeStruct.value=(nodeStruct.value||"")+str;}
else
nodeStruct.nodes[c++]=aux;}}
return nodeStruct;}
Ajax.structToXml=function(value)
{var valueToXml=function(value,entryName)
{var xml="<"+entryName+">";if(value===null)
xml+="[null]";else if(typeof(value)=="function"){xml+="[function]";}
else if(typeof(value)=="object"){for(var k in value){try{xml+=valueToXml(value[k],k);}
catch(e){}}}
else
xml+=value.toString();xml+="</"+entryName+">"+LD.CRLF;return xml;}
return(LD.CRLF+valueToXml(value,"root")+LD.CRLF);}
Ajax.escape=function(str)
{return(str==null)?null:escape(str.toString().toAnsi("_"));}
Ajax.addCommand=function(cmdSpooler,params){var c={'cmdSpooler':cmdSpooler,'params':params};Ajax.cmdSpooler.push(c);}
Ajax.checkEvents=function(objEvents){if(!objEvents)return;for(var i=0;i<objEvents.length;i++){R31DesktopShell.fireEvent(objEvents[i].data,intVal(objEvents[i].event));}}
AjaxSocket.extend(LD.Proto);Ajax.cmdSpooler=new Array();AjaxSocket.extend(LD.Proto);AjaxSocket.EVT_ALL=700;AjaxSocket.EVT_REQUEST_STARTED=701;AjaxSocket.EVT_READY_STATE_CHANGE=702;AjaxSocket.EVT_REQUEST_FINISHED=703;AjaxSocket.EVT_AJAX_WORKING_CHANGED=704;AjaxSocket.EVT_ERROR_TIMEOUT=705;AjaxSocket.EVT_ERROR_NOTLOGGED=706;AjaxSocket.instances=[];AjaxSocket.nextId=1;AjaxSocket.workingInstances=new Array();function AjaxSocket()
{AjaxSocket.superConstructor.call(this);this.id=AjaxSocket.register(this);this.request=null;if(!this.init())
throw"AjaxSocket: Could not create an instance of XMLHttpRequest";this.requestArguments={};this.bodyArguments={};this.method=Ajax.METHOD_GET;this.cacheControl=Ajax.CACHE_NONE;this.callbacks={success:null,failure:null,other:null,progress:null};}
AjaxSocket.getNextId=function()
{return this.nextId++;}
AjaxSocket.register=function(socket)
{if(!(socket instanceof AjaxSocket))
throw"AjaxSocket: Must provide an instance of AjaxSocket";if(!inArray(this.instances,socket))
this.instances.push(socket);var id=this.getNextId();this.instances[id]=socket;return id;}
AjaxSocket.unregister=function(socket)
{if(!(socket instanceof AjaxSocket))
throw"AjaxSocket: Must provide an instance of AjaxSocket";this.instances=arrayRemove(this.instances,socket);this.workingInstances=arrayRemove(this.workingInstances,socket.id);}
AjaxSocket.setSocketWorking=function(socket,working)
{if(!(socket instanceof AjaxSocket))
throw"AjaxSocket: Must provide an instance of AjaxSocket";var initialWorkingStatus=(this.workingInstances.length>0);if(working==true){if(!inArray(this.workingInstances,socket.id))
this.workingInstances.push(socket.id);}
else{this.workingInstances=arrayRemove(this.workingInstances,socket.id);}
AjaxSocket.ajaxWorking=(this.workingInstances.length>0);if(AjaxSocket.ajaxWorking!=initialWorkingStatus){var evt={triggeringSocket:socket,socketWorkingStatus:working};AjaxSocket.fireEvent(evt,AjaxSocket.EVT_AJAX_WORKING_CHANGED,this);}}
AjaxSocket.prototype.answerObject=true;AjaxSocket.prototype.response="";AjaxSocket.prototype.init=function()
{var request=null;if(window.XMLHttpRequest){request=new XMLHttpRequest();}
else if(window.ActiveXObject){try{request=new ActiveXObject("Microsoft.XMLHTTP");}catch(e){}}
if(!request)throw"AjaxSocket: could not initialize HttpRequest object";var _this=this;request.onreadystatechange=function(){if(_this.callbacks.progress)
_this.callbacks.progress(_this);if(_this.getReadyState()==Ajax.STATE_COMPLETE){_this.response=_this.request.responseText;if(_this.answerObject)
{if(_this.response.trim()!="")
{var answer=Json.evaluate(_this.request.responseText);if(answer.hasOwnProperty('original'))
{_this.response=answer.original;Ajax.checkEvents(answer.events);}
else
{_this.response=_this.request.responseText;}}}
var statusCode=intVal(_this.getStatusCode());if(statusCode==401){_this.onError();var evt={triggeringSocket:_this,socketWorkingStatus:statusCode};AjaxSocket.fireEvent(evt,AjaxSocket.EVT_ERROR_NOTLOGGED,this);if(_this.callbacks.failure)
_this.callbacks.failure(_this);}
else if(statusCode>=400&&statusCode<600){_this.onError();var evt={triggeringSocket:_this,socketWorkingStatus:statusCode};AjaxSocket.fireEvent(evt,AjaxSocket.EVT_ERROR_TIMEOUT,this);if(_this.callbacks.failure)
_this.callbacks.failure(_this);}
else if(statusCode>=200&&statusCode<300){_this.onSuccess();if(_this.callbacks.success){_this.callbacks.success(_this);}}
else{if(_this.callbacks.other)
_this.callbacks.other(_this);}
AjaxSocket.setSocketWorking(_this,false);}}
this.request=request;return true;}
AjaxSocket.prototype.setMethod=function(method)
{if(!method)
throw"AjaxSocket.setMethod: Must provide a constant for Ajax request method (POST, GET)";this.method=method;}
AjaxSocket.prototype.setResponseType=function(responseType)
{if(responseType)
this.setArgument("response",intVal(responseType));}
AjaxSocket.prototype.getReadyState=function()
{if(this.request)
return this.request.readyState;else
return null;}
AjaxSocket.prototype.getStatusCode=function()
{if(this.request)
return this.request.status;else
return null;}
AjaxSocket.prototype.clearArguments=function()
{this.requestArguments=new Object();}
AjaxSocket.prototype.getArgument=function(name)
{if(name==null)throw"AjaxSocket.getArgument: Must provide a name for request argument";return this.requestArguments[name.toString()];}
AjaxSocket.prototype.setArgument=function(name,value)
{if(name==null)throw"AjaxSocket.setArgument: Must provide a name for request argument";if(arguments.length==1&&typeof(arguments[0])=="object")
for(var k in arguments[0]){this.requestArguments[k]=arguments[0][k];}
else if(arguments.length==2)
this.requestArguments[name.toString()]=value;}
AjaxSocket.prototype.clearBodyArguments=function()
{this.bodyArguments=new Object();}
AjaxSocket.prototype.setBodyArgument=function(name,value)
{if(!name)throw"AjaxSocket.setArguments: must provide a name for body argument";if(arguments.length==1&&typeof(arguments[0])=="object")
for(var k in arguments[0]){this.bodyArguments[k]=arguments[0][k];}
else if(arguments.length==2)
this.bodyArguments[name.toString()]=value;}
AjaxSocket.prototype.buildRequest=function(scriptUrl,randomize)
{var str="";for(var name in this.requestArguments){if(str!="")str+="&";str+=(Ajax.escape(name)+"="+Ajax.escape(this.requestArguments[name]));}
if(randomize!==false)
str+=((str=="")?("rnd="+Math.random()):("&rnd="+Math.random()));return(scriptUrl+"?"+str);}
AjaxSocket.prototype.buildBody=function()
{var str="";for(var param in this.bodyArguments){if(str!="")str+="&";str+=(Ajax.escape(param)+"="+Ajax.escape(this.bodyArguments[param]));}
return str;}
AjaxSocket.prototype.send=function(url,sync,method,allowCaching)
{AjaxSocket.setSocketWorking(this,true);if(!this.init())
throw"AjaxSocket.send: Could not initialize request object";if(!method)method=this.method;var fullUrl=this.buildRequest(url,(allowCaching!==true));var totalUrl=fullUrl+"&cmdSpool="+Json.toString(Ajax.cmdSpooler);Ajax.cmdSpooler=new Array();this.request.open(method,totalUrl,(sync!==true));this.request.setRequestHeader("Cache-control","no-cache");if(method==Ajax.METHOD_POST)
this.request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");if(this.request.overrideMimeType)
this.request.setRequestHeader("Connection","close");var body=this.buildBody();this.request.send(body);}
AjaxSocket.addListener=function(evtType,callback,listener)
{LD.EventDispatcher.add(this,listener,evtType,callback);}
AjaxSocket.fireEvent=function(evt,type,src)
{LD.EventDispatcher.fire(this,type,evt);}
AjaxSocket.prototype.setSuccessCallback=function(func)
{if(func!=null&&typeof(func)!="function")
throw"AjaxSocket.setSuccessCallback: Must provide a function to handle request response";this.callbacks.success=func||null;}
AjaxSocket.prototype.setCallback=AjaxSocket.prototype.setSuccessCallback;AjaxSocket.prototype.setFailureCallback=function(func)
{if(func!=null&&typeof(func)!="function")
throw"AjaxSocket.setFailureCallback: Must provide a function to handle request response";this.callbacks.failure=func||null;}
AjaxSocket.prototype.setOtherCallback=function(func)
{if(func!=null&&typeof(func)!="function")
throw"AjaxSocket.setOtherCallback: Must provide a function to handle request response";this.callbacks.other=func||null;}
AjaxSocket.prototype.setProgressCallback=function(func)
{if(func!=null&&typeof(func)!="function")
throw"AjaxSocket.setProgressCallback: Must provide a function to handle request response";this.callbacks.progress=func||null;}
AjaxSocket.prototype.onSuccess=function()
{}
AjaxSocket.prototype.onError=function()
{}
function XMLNodeStruct(xmlNode)
{if(xmlNode.parentNode==null){this.type=Ajax.XML_NODE_DOCUMENT;this.tag=null;this.value=null;this.attributes=null;this.nodes=new Array();}
else if(xmlNode.tagName){this.type=Ajax.XML_NODE_TAG;this.tag=xmlNode.tagName.toLowerCase();this.value=null;this.attributes=new Array();this.nodes=new Array();}
else{this.type=Ajax.XML_NODE_TEXT;this.tag=null;this.value=xmlNode.data;this.attributes=null;this.nodes=null;}}
XMLNodeStruct.prototype.getSubnodesByTag=function(tagName)
{if(!tagName)return false;tagName=tagName.toString().toLowerCase();var coll=new Array();for(var i=0;i<this.nodes.length;i++){if(this.nodes[i].tag==tagName)
coll.push(this.nodes[i]);}
return coll;}
XMLNodeStruct.prototype.getSubnode=function(tagOrIndex)
{if(!this.nodes)return null;if(typeof(tagOrIndex)=="undefined"||tagOrIndex===""||tagOrIndex===null)
return null;if(isInteger(tagOrIndex)){var index=intVal(tagOrIndex);if(index>=0&&index<this.nodes.length)
return this.nodes[index];}
else{var tagName=tagOrIndex.toString().toLowerCase();for(var i=0;i<this.nodes.length;i++){if(this.nodes[i].tag==tagName)
return this.nodes[i];}}
return null;}
XMLNodeStruct.prototype.toString=function()
{var str="";if(this.type==Ajax.XML_NODE_TAG){str="<"+this.tag;for(var att in this.attributes){str+=' '+att+'="'+this.attributes[att]+'"';}
if(this.nodes&&this.nodes.length>0){str+=">";for(var i=0;i<this.nodes.length;i++){str+=this.nodes[i].toString();}
str+="</"+this.tag+">";}
else if(this.value){str+=">"+this.value+"</"+this.tag+">";}
else
str+="/>";}
else if(this.type==Ajax.XML_NODE_TEXT){str=this.value;}
return str;}
AjaxTemplate={variables:{},load:function(source,sync,allowCaching,callback)
{if(source=="")return false;if(allowCaching==null)allowCaching=false;var ajax=new AjaxSocket();var _this=this;ajax.answerObject=false;ajax.setSuccessCallback(function(socket){_this.parse(socket.request.responseText,callback);});ajax.setFailureCallback(function(socket){debugger;});ajax.send(source,false,null,allowCaching);},setVar:function(varName,value)
{if(isObject(varName))
for(var k in varName){this.variables[k]=varName[k];}
else if(varName!=null)
this.variables[varName.toString()]=value;},parse:function(data,callback)
{var fragments=Json.evaluate(data);if(!(fragments instanceof Object)){return false;}
var fr;for(var id in fragments){fr=fragments[id];for(var k in this.variables){fr=fr.replace(new RegExp("\\{"+k+"}","g"),this.variables[k]);}
fragments[id]=fr;}
if(typeof(callback)=="function"){callback(fragments);}}}

/*========== Locale.js ==========*/

var Locale={strings:{},locale:"en_US",domain:"default",_ajax:null,_callback:null,getLocale:function(locale)
{return varDefault(LD.Cookie.get("locale"),false);},setLocale:function(locale)
{locale=locale||"en_US";LD.Cookie.set("locale",locale);this.locale=locale;if(!this.strings[locale])this.strings[locale]={};if(!this.strings[locale][this.domain])this.strings[locale][this.domain]={};},fetch:function(url,domain,callback,allowCaching)
{throw"async loading of translation is not supported anymore.";},init:function(){var locale=Locale.getLocale()||Locale.getSystemLocale();if(!this.strings[locale]){if(typeof(LocaleData)!="undefined"&&LocaleData[locale]){Locale.putTable(locale,Locale.domain,LocaleData[locale]);}else{Locale.putTable(locale,Locale.domain,{});}
Locale.setLocale(locale);}},get:function(str,arg1,arg2,argN)
{if(str==null)return false;var res=varDefault(this.strings[this.getLocale()][this.domain][str],str);if(arguments.length>1){var aux=obj2Array(arguments);aux.shift();res=String.prototype.parse.apply(res,aux);}
if(res==''){return str;}
return res;},putTable:function(locale,domain,table,overwrite)
{if(locale==""||!(table instanceof Object))return false;domain=domain||"default";if(!this.strings[locale])this.strings[locale]={};if(!this.strings[locale][domain])this.strings[locale][domain]={};var lst=this.strings[locale][domain];for(var k in table){if(overwrite||lst[k]==null)
lst[k]=table[k];}},getSystemLocale:function()
{var locale=navigator.language||navigator.systemLanguage||"en_US";if(locale.length>2)
locale=locale.substr(0,2).toLowerCase()+"_"+locale.substr(3).toUpperCase();return locale;}}
if(typeof(_)=="undefined"){var _=function()
{return Locale.get.apply(Locale,arguments);}
Locale.init();}
if(typeof(__)=="undefined"){var __=function()
{return window._.apply(window,arguments);}}

/*========== FileSystem.js ==========*/

FileSystem=new LD.Proto();FileSystem.NODE_TYPE_FILE=0;FileSystem.NODE_TYPE_DIR=1;FileSystem.NODE_TYPE_LINK=2;FileSystem.LINK_TYPE_NODE=0;FileSystem.LINK_TYPE_URL=1;FileSystem.FILENAME_MAX_LENGTH=100;FileSystem.ACCESS_NONE=0;FileSystem.ACCESS_READ=1;FileSystem.ACCESS_WRITE=2;FileSystem.ACCESS_READ_WRITE=3;FileSystem.ACCESS_PUBLIC=0;FileSystem.ACCESS_FRIENDS=1;FileSystem.ACCESS_PRIVATE=2;FileSystem.PERMISSIONS_PRIVATE=48;FileSystem.PERMISSIONS_FRIENDS=56;FileSystem.PERMISSIONS_PUBLIC=58;FileSystem.ACTION_COPY=101;FileSystem.ACTION_MOVE=102;FileSystem.ACTION_LINK=103;FileSystem.ACTION_DELETE=104;FileSystem.ACTION_RENAME=105;FileSystem.ACTION_BROWSE=106;FileSystem.ACTION_MOUNT=107;FileSystem.ACTION_CREATE=108;FileSystem.ACTION_DUPLICATE=109;FileSystem.ACTION_UNDELETE=110;FileSystem.ACTION_EMPTY_TRASHBIN=111;FileSystem.ACTION_SET_PERMISSIONS=112;FileSystem.ACTION_OPEN_NODE=113;FileSystem.EVT_NODE_CHANGED=201;FileSystem.EVT_NODE_PARENT_CHANGED=202;FileSystem.EVT_NODE_CHILDREN_CHANGED=203;FileSystem.EVT_NODE_COPIED=204;FileSystem.EVT_NODE_MOVED=205;FileSystem.EVT_NODE_RENAMED=206;FileSystem.EVT_NODE_DELETED=207;FileSystem.EVT_NODE_CREATED=208;FileSystem.EVT_NODE_DUPLICATED=209;FileSystem.EVT_USER_ROOT_MOUNTED=210;FileSystem.EVT_NODE_ACTION_CANCELED=291;FileSystem.EVT_NODE_ACTION_ERROR=292;FileSystem.EVT_NODE_USAGESTATS_CHANGE=293;FileSystem.FILE_UPLOADED=1;FileSystem.FILE_ERROR_XML=2;FileSystem.FILE_XML_RECEIVED=5;FileSystem.FILE_TRANSFERRING=10;FileSystem.FILE_ERROR_TRANSFER=15;FileSystem.FILE_DUPLICATE=20;FileSystem.FILE_WAITING=25;FileSystem.FILE_CONVERTING=50;FileSystem.FILE_CANCELLED=60;FileSystem.FILE_ERROR_ENCODING=65;FileSystem.FILE_REQUEST_PENDING=70;FileSystem.FILE_AVAILABLE=75;LD.ERR_FS_NODE_NOT_FOUND=-1;LD.ERR_FS_READ_ACCESS_DENIED=-2;LD.ERR_FS_WRITE_ACCESS_DENIED=-3;LD.ERR_FS_INVALID_PATH=-4;LD.ERR_FS_ALREADY_EXISTS=-5;LD.ERR_FS_INVALID_USER=-6;LD.ERR_FS_INVALID_URL=-7;LD.ERR_FS_INVALID_TARGET=-8;LD.ERR_FS_INVALID_SOURCE=-9;LD.ERR_FS_INVALID_NAME=-10;LD.ERR_FS_ILLEGAL_OPERATION=-11;LD.ERR_FS_QUOTA_EXCEEDED=-12;LD.ERR_FS_NO_CLEARANCE=-13;LD.ERR_FS_CENSORED_NODE=-14;FileSystem.WIXI_TV_SYS_ID="ea3370336337499e";FileSystem.TRASHBIN_SYS_ID="cf4e21b27e735b55";FileSystem.TRASHBIN_NODE_SYS_ID="3e094484f7b61e22";FileSystem.root=null;FileSystem.debug=false;FileSystem.err=new Object();FileSystem.err[LD.ERR_FS_ALREADY_EXISTS]="File or directory already exists";FileSystem.MIME_TYPE_IMAGE=1;FileSystem.MIME_TYPE_AUDIO=2;FileSystem.MIME_TYPE_VIDEO=3;FileSystem.init=function()
{this.user=null;this.nodeRegistry=new Object();this.nodeTypeDescriptors={};this.nodeTypeDescriptors[FileSystem.NODE_TYPE_FILE]=[];this.nodeTypeDescriptors[FileSystem.NODE_TYPE_DIR]=[];this.nodeTypeDescriptors[FileSystem.NODE_TYPE_LINK]=[];this._ajax=new R31Ajax();this.root=FileSystemRootDirectory.getInstance();this.registerNode(this.root);this.root.mount=function(rootDir)
{var _this=this;var setRootDir=function(fsNode,children)
{if(!(fsNode instanceof FileSystemDirectory))throw"Only directories can be mounted";_this.putChild(fsNode);if(children)fsNode.putChildren(children);var evt={"action":FileSystem.ACTION_MOUNT,"node":fsNode};_this.fireEvent(evt,FileSystem.EVT_NODE_CHILDREN_CHANGED);_this.fireEvent(evt,FileSystem.EVT_USER_ROOT_MOUNTED);return fsNode;};if(isObject(rootDir)){var userRoot=FileSystemNode.build(rootDir);var res=false;if(userRoot instanceof FileSystemDirectory){var children=FileSystemNode.build(rootDir.children);return setRootDir(userRoot,children);}
else{return null;}}
else{this._ajax.setArgument({"cmd":"mount","path":rootDir});this._ajax.setSuccessCallback(function(socket)
{var result=socket.response;if(!result)return false;var fsNode=FileSystemNode.build(result);if(fsNode instanceof FileSystemDirectory){var children=FileSystemNode.build(result.children);res=setRootDir(fsNode,children);}});this._ajax.send("room_provider.php");return null;}}
this.root.unmount=function(rootDir)
{delete this.root;this.root=null;};};FileSystem.mount=function(rootDir)
{if(!isObject(rootDir)){throw"FileSystem.mount: Must provide a FileSystemDirectory or a directory initialization object.";}
if(this.root)
return this.root.mount(rootDir);else
return false;};FileSystem.getUser=function()
{return this.user;};FileSystem.setUser=function(user)
{if(user===null)
this.user=null;else if(isObject(user)&&user.id>0&&user.name!="")
this.user=user;else
throw new FileSystem.InvalidUserException(user);};FileSystem.getRoot=function()
{return this.root;};FileSystem.getUserRoot=function(userName)
{userName=varDefault(userName,"");if(userName=="")return null;return this.getNodeByPath("/"+userName);};FileSystem.getNode=function(id)
{return(this.nodeRegistry[intVal(id)]||null);};FileSystem.getNodeByPath=function(path)
{path=path||"";if(path==""||!this.root)return null;var pathStack=path.toString().toLowerCase().trim("/").split("/");if(pathStack.length<=0)return null;var node=this.root;for(var i=0;i<=pathStack.length;i++){if(i==pathStack.length){return node;}
else{if(node.getType()!=FileSystem.NODE_TYPE_DIR)return null;node=node.getChild(pathStack[i].toLowerCase());}}
return null;};FileSystem.getNodeBySysId=function(sysId,userName)
{if(!sysId)return false;var userRoot=this.getUserRoot(userName);if(!userRoot)return null;var ch=userRoot.getChildren(),sysId;for(var i=0;i<ch.length;i++){if(ch[i].getSysId()==sysId)return ch[i];}
return null;};FileSystem.fetchNode=function(idOrPath,callback,callbackObject)
{var _this=this;this._ajax.clearArguments();this._ajax.setArgument("cmd","getNode");if(isNumeric(idOrPath))
this._ajax.setArgument("id",idOrPath);else
this._ajax.setArgument("path",idOrPath);this._ajax.setSuccessCallback(function(socket)
{var result=socket.response;if(!result)return false;var fsNode=null;if(result.node){if(result.ancestors){var ancestors=new Array();for(var ix=0;ix<result.ancestors.length;ix++){ancestors.push(FileSystemNode.build(result.ancestors[ix]));}
FileSystem.insertBranchInTree(ancestors);}
fsNode=FileSystemNode.build(result.node);FileSystem.insertNodeInTree(fsNode);}
if(callback&&fsNode){callback.call(callbackObject||null,fsNode);}});this._ajax.send("room_provider.php");};FileSystem.registerNode=function(node,preserve)
{if(!(node instanceof FileSystemNode))throw"FileSystem.registerNode: Must provide a FileSystemNode object";node.normalize();nodeId=intVal(node.getId());if(preserve!=true||!this.nodeRegistry[nodeId]){this.nodeRegistry[nodeId]=node;}
if(node.isProcessing()){FileSystemNodeStatusManager.add(node);}
else{FileSystemNodeStatusManager.remove(node);}};FileSystem.insertNodeInTree=function(node)
{if(!node||!(node instanceof FileSystemNode)){throw"FileSystem.insertNodeInTree: Must provide a FileSystemNode object";}
var nodeParent=node.getParent();if(nodeParent==null){throw"FileSystem.insertNodeInTree: There is no FileSystem node "+node.getParentId()+" to insert node "+node.getId()+" into";}
if(nodeParent.getType()!=FileSystem.NODE_TYPE_DIR){throw"FileSystem.insertNodeInTree: Node "+node.getId()+" cannot be inserted into node "+
nodeParent.getId()+" since the latter is not a directory";}
nodeParent.putChild(node);};FileSystem.insertBranchInTree=function(branch)
{if(!branch)throw"FileSystem.insertBranchInTree: Must provide an Array of FileSystemNode objects to insert";var node;for(var i=0;i<branch.length;i++){for(var id in branch){node=branch[id];if(this.getNode(node.id)==null)this.insertNodeInTree(node);}}};FileSystem.getBaseName=function(path,stripExtension)
{path=varDefault(path,"").toString().replace(new RegExp("\\\\","g"),"/");path=path.replace(new RegExp("//","g"),"/");var baseName=path.substr(path.lastIndexOf("/")+1);if(stripExtension==true){var lastDot=baseName.lastIndexOf(".");if(lastDot>0)
baseName=baseName.substr(0,lastDot);}
return baseName;};FileSystem.getExtension=function(fileName)
{fileName=varDefault(fileName,"").toString();var lastDot=fileName.lastIndexOf(".");return(lastDot>=0)?fileName.substr(lastDot+1):"";};FileSystem.getNodesTypeDescriptors=function(){return this.nodeTypeDescriptors[FileSystem.NODE_TYPE_FILE];}
FileSystem.getTypeDescriptor=function(extension)
{if(extension==null||extension=="")return null;var types=this.nodeTypeDescriptors[FileSystem.NODE_TYPE_FILE];if(!types||!(types instanceof Array))return null;for(var i=0;i<types.length;i++){if(!(types[i]instanceof FileTypeDescriptor))continue;if(inArray(types[i].getExtensions(),extension.toString().toLowerCase()))
return types[i];}
return null;};FileSystem.registerNodeTypes=function(nodeType,typeDescriptors)
{if(nodeType==null)
throw"FileSystem.setNodeTypeTable: Must specify the type of node you want to register descriptors for";if(!typeDescriptors||!(typeDescriptors instanceof Array))
throw"FileSystem.setNodeTypeTable: Must provide an Array of NodeTypeDescriptor objects";this.nodeTypeDescriptors[nodeType]=arrayMerge(this.nodeTypeDescriptors,typeDescriptors);};FileSystem.getComputedPermissions=function(permissions)
{if(typeof(permissions)!="string")return null;var perm=0x3f;for(var i=0;i<permissions.length;i++){perm=perm&permissions.charCodeAt(i);}
return perm;};FileSystem.permissionsToAccess=function(permissions)
{if(typeof(permissions)!="string")return null;var perm=intVal(permissions.charCodeAt(permissions.length-1));if(perm==FileSystem.PERMISSIONS_PRIVATE)return FileSystem.ACCESS_PRIVATE;if(perm==FileSystem.PERMISSIONS_FRIENDS)return FileSystem.ACCESS_FRIENDS;if(perm==FileSystem.PERMISSIONS_PUBLIC)return FileSystem.ACCESS_PUBLIC;return null;};FileSystem.accessToPermissions=function(accessLevel)
{if(accessLevel==FileSystem.ACCESS_PRIVATE)return String.fromCharCode(FileSystem.PERMISSIONS_PRIVATE);if(accessLevel==FileSystem.ACCESS_FRIENDS)return String.fromCharCode(FileSystem.PERMISSIONS_FRIENDS);if(accessLevel==FileSystem.ACCESS_PUBLIC)return String.fromCharCode(FileSystem.PERMISSIONS_PUBLIC);return null;};FileSystem.isValidFileName=function(name,allowEmpty)
{if(name==null)return false;if(allowEmpty!=true&&name==""&&!(node instanceof FileSystemRootDirectory))
return false;return!((new RegExp("[*:\\/|\"<>$]")).test(name));};FileSystem.raiseError=function(error,message,details)
{if(!(error instanceof LD.Exception))
error=new FileSystem.IOException(error,message,details);this.fireEvent(error,FileSystem.EVT_NODE_ACTION_ERROR);};FileSystem.makeException=function(errCode,message,details)
{if(typeof(errCode)!="number")
throw"FileSystem.makeException: errCode must be an integer";var ex=null;if(errCode==LD.ERR_FS_INVALID_PATH)
ex=FileSystem.InvalidURLException;if(errCode==LD.ERR_FS_NODE_NOT_FOUND)
ex=FileSystem.NodeNotFoundException;else if(errCode==LD.ERR_FS_READ_ACCESS_DENIED||errCode==LD.ERR_FS_WRITE_ACCESS_DENIED)
ex=FileSystem.AccessDeniedException;else if(errCode==LD.ERR_FS_ALREADY_EXISTS)
ex=FileSystem.NodeAlreadyExistsException;else if(errCode<0)
ex=FileSystem.Exception;if(ex!=null){return new ex(errCode,message,details);}else{return null;}};FileSystem.filterByStatus=function(nodeCollection,validStatus)
{var node,aux=new Array();if(validStatus instanceof Array){for(var i=0;i<nodeCollection.length;i++){node=nodeCollection[i];if(inArray(validStatus,node.getStatus()))
aux.push(node);}}
else{validStatus=intVal(validStatus);for(var i=0;i<nodeCollection.length;i++){node=nodeCollection[i];if(node.getStatus()==validStatus)
aux.push(node);}}
return aux;};FileSystem.getUsageStats=function(user,callMe)
{if(user instanceof R31User)
{user=user.id;}
var response=false;var _this=this;this._ajax.clearArguments();this._ajax.setArgument("cmd","getUsageStats");this._ajax.setArgument("user",user);this._ajax.setSuccessCallback(function(socket)
{var result=socket.response;if(!result)
{response=false;}
else
{response=result;}
callMe(response);});this._ajax.send("room_provider.php");};FileSystem.__isFriendOfAnOriginalUploaderCache={};FileSystem.isFriendOfAnOriginalUploader=function(node,callback,callbackObject)
{var _this=this;var user=R31UserRegistry.getLoggedUser();if(_this.__isFriendOfAnOriginalUploaderCache[user.id]){if(_this.__isFriendOfAnOriginalUploaderCache[user.id][node.hash]){if(callback){callback.call(callbackObject||null,_this.__isFriendOfAnOriginalUploaderCache[user.id][node.hash]);}
return;}}else{_this.__isFriendOfAnOriginalUploaderCache[user.id]={};}
this._ajax.clearArguments();this._ajax.setArgument("cmd","isFriendOfAnOriginalUploader");this._ajax.setArgument("md5_hash",node.hash);this._ajax.setSuccessCallback(function(socket)
{var result=socket.response;if(!result)return false;_this.__isFriendOfAnOriginalUploaderCache[user.id][node.hash]=result;if(callback){callback.call(callbackObject||null,result);}});this._ajax.send("room_provider.php");};FileSystemNode.extend(LD.Proto);FileSystemNode.classId="f023b1c748e6c653";function FileSystemNode(type,name)
{FileSystemNode.superConstructor.call(this);this.id=0;this.setType(type);this.parent=0;this.setName(name);this.permissions=":";this.sysId="";this.sysData="";this.target=null;this.hash="";this.status=0;this.original=true;this.replica=0;this.thumbnail=false;this.thumbnailURL='';this.size=0;this.tags="";this.description="";this.creationTime="00000000000000";this.mimeType='';this.mimeSubType='';this._ajax=new R31Ajax();}
FileSystemNode.prototype.isDirectory=function(){return false;}
FileSystemNode.prototype.isFile=function(){return false;}
FileSystemNode.prototype.isLink=function(){return false;}
FileSystemNode.build=function(obj)
{if(!obj)throw"FileSystemNode.build: Must provide an initialization object";if(obj instanceof Array){var nodes=new Array();for(var i=0;i<obj.length;i++){nodes.push(FileSystemNode.build(obj[i]));}
return nodes;}
else{if(!obj.id||obj.type==null||!obj.name){throw"Malformed FileSystemNode initialization object";}
var nodeConstructor=null;switch(obj.type){case FileSystem.NODE_TYPE_DIR:nodeConstructor=FileSystemDirectory;break;case FileSystem.NODE_TYPE_FILE:nodeConstructor=FileSystemFile;break;case FileSystem.NODE_TYPE_LINK:nodeConstructor=FileSystemLink;break;default:throw"Malformed FileSystemNode initialization object";}
var node=new nodeConstructor(obj.name);node.id=obj.id||0;node.parent=obj.parent||0;node.owner=obj.owner||0;node.permissions=obj.permissions||":";node.sysId=obj.sysId||"";node.sysData=obj.sysData||"";node.target=obj.target||"";node.hash=obj.hash||"";node.status=obj.status||0;node.original=(obj.original==true);node.replica=obj.replica||0;node.thumbnail=(obj.thumbnail==1);node.size=obj.size||0;node.tags=obj.tags||"";node.description=obj.description||"";node.creationTime=obj.creationTime||"00000000000000";if(obj.hasOwnProperty('thumbnailURL'))
{node.thumbnailURL=obj.thumbnailURL;}
else
{node.thumbnailURL=URL_THUMBNAILS+"?target="+node.getTarget();}
if(obj.children&&obj.children.length&&obj.children.length>0){if(node.isDirectory()){for(var childN=0;childN<obj.children.length;childN++){var newChild=FileSystemNode.build(obj.children[childN]);node.putChild(newChild);}}else{throw"Non directory nodes cannot have children"}}
node.mimeType=obj.mimeType;node.mimeSubType=obj.mimeSubType;node.videoDuration=obj.videoDuration;node.viewCount=obj.viewCount;return node;}}
FileSystemNode.nameComparator=function(a,b)
{return a.compareTo(b);}
FileSystemNode.typeComparator=function(a,b)
{var ta=a.getType(),tb=b.getType(),c=FileSystem.NODE_TYPE_DIR;if(ta==c&&tb!=c)
return-1;else if(ta!=c&&tb==c)
return 1;else
return FileSystemNode.nameComparator(a,b);}
FileSystemNode.mimeTypeComparator=function(a,b)
{var ta=a.getType(),tb=b.getType(),c=FileSystem.NODE_TYPE_DIR;if(ta==c&&tb!=c)
return-1;else if(ta!=c&&tb==c)
return 1;else if(a instanceof FileSystemFile&&b instanceof FileSystemFile){var tda=a.getTypeDescriptor();var tdb=b.getTypeDescriptor();var mta="",mtb="";if(tda!=null&&tdb!=null){mta=tda.getFullMimeType();mtb=tdb.getFullMimeType();}
return mta<mtb?-1:(mta>mtb?1:FileSystemNode.nameComparator(a,b));}
else
return FileSystemNode.nameComparator(a,b);}
FileSystemNode.creationTimeComparator=function(a,b)
{var ta=a.getCreationTime(),tb=b.getCreationTime();return ta<tb?-1:(ta>tb?1:0);}
FileSystemNode.prototype.equals=function(node)
{if(!node||!(node instanceof FileSystemNode))return false;if(node===this)return true;if(node.constructor!=this.constructor)return false;if(node.id==this.id&&node.parent==this.parent&&node.name==this.name&&node.type==this.type)
return true;else
return false;}
FileSystemNode.prototype.compareTo=function(b)
{var na=this.name.toLowerCase(),nb=b.getName().toLowerCase();return na<nb?-1:(na>nb?1:0);}
FileSystemNode.prototype.getType=function()
{return this.type;}
FileSystemNode.prototype.setType=function(type)
{this.type=varDefault(type,FileSystem.NODE_TYPE_FILE);}
FileSystemNode.prototype.getId=function()
{return this.id;}
FileSystemNode.prototype.getOwner=function()
{return this.owner;}
FileSystemNode.prototype.getName=function()
{var name=this.name;if(this.sysData.name)
name=this.sysData.name;return name;}
FileSystemNode.prototype.setName=function(name)
{name=varDefault(name,"");if(FileSystem.isValidFileName(name,true)==false)
throw"FileSystemNode: File name is invalid. It cannot be emtpy nor contain any of the following: * \\ | / \" < > ? :";else
this.name=name;}
FileSystemNode.prototype.getBaseName=function()
{return FileSystem.getBaseName(this.name,true);}
FileSystemNode.prototype.getExtension=function()
{return FileSystem.getExtension(this.name);}
FileSystemNode.prototype.getParent=function()
{return FileSystem.getNode(this.parent);}
FileSystemNode.prototype.setParent=function(node)
{if(this instanceof FileSystemRootDirectory)
throw"FileSystemNode.setParent: Root node cannot have ancestors";else if(node!==null&&(!node||!(node instanceof FileSystemDirectory)))
throw"FileSystemNode.setParent: Parent must be a FileSystemDirectory object";var evt={"node":this,"parent":node,"formerParent":this.getParent()};this.parent=node.getId();node.addListener(FileSystem.EVT_NODE_CHANGED,this.parentNodeChanged,this);this.fireEvent(evt,FileSystem.EVT_NODE_CHANGED);}
FileSystemNode.prototype.getPermissions=function()
{return this.permissions;}
FileSystemNode.prototype.getSysId=function()
{return this.sysId;}
FileSystemNode.prototype.getSysData=function(key)
{if(!this.sysData)
this.sysData=new Object();key=varDefault(key,"").toString();if(key!="")
return this.sysData[key];else
return this.sysData;}
FileSystemNode.prototype.hasAncestor=function(ancestor)
{var node=this;var ancestorPath=ancestor.getPath();while(node!=null){if(node.equals(ancestor))return true;node=node.getParent();}
return false;}
FileSystemNode.prototype.getPath=function()
{var path="";var parent=this.getParent();if(parent)path=parent.getPath();path+=("/"+this.name);return path.replace("//","/");}
FileSystemNode.prototype.getAccess=function(userLevel)
{if(userLevel==null){var user=FileSystem.getUser();if(!user||!user.id)return FileSystem.ACCESS_NONE;userLevel=(user.id==this.owner)?2:0;}
else{userLevel=intVal(userLevel);}
return(this.getComputedPermissions()>>(2*userLevel))&FileSystem.ACCESS_READ_WRITE;}
FileSystemNode.prototype.getComputedPermissions=function()
{return FileSystem.getComputedPermissions(this.permissions);}
FileSystemNode.prototype.isOriginal=function()
{return(this.original==true);}
FileSystemNode.prototype.isReplica=function()
{return(this.replica!=0);}
FileSystemNode.prototype.isSystem=function()
{return(this.sysId!=null&&this.sysId!='');}
FileSystemNode.prototype.isPrivate=function()
{return(this.getComputedPermissions()==FileSystem.PERMISSIONS_PRIVATE);}
FileSystemNode.prototype.isFriends=function()
{return(this.getComputedPermissions()==FileSystem.PERMISSIONS_FRIENDS);}
FileSystemNode.prototype.isPublic=function()
{return(this.getComputedPermissions()==FileSystem.PERMISSIONS_PUBLIC);}
FileSystemNode.prototype.isReadable=function(userLevel)
{return bitMask(this.getAccess(userLevel),FileSystem.ACCESS_READ);}
FileSystemNode.prototype.isWritable=function(userLevel)
{return bitMask(this.getAccess(userLevel),FileSystem.ACCESS_WRITE);}
FileSystemNode.prototype.isMovable=function()
{return(this.isSystem()==false||this.getSysId()==FileSystem.TRASHBIN_NODE_SYS_ID);}
FileSystemNode.prototype.isCopiable=function()
{return(this.isSystem()==false);}
FileSystemNode.prototype.isDeletable=function()
{return(this.isSystem()==false||this.sysId==FileSystem.TRASHBIN_NODE_SYS_ID);}
FileSystemNode.prototype.isAvailable=function()
{return(this.type!=FileSystem.NODE_TYPE_FILE||this.status==FileSystem.FILE_AVAILABLE);}
FileSystemNode.prototype.isProcessing=function()
{return((this.type==FileSystem.NODE_TYPE_FILE||this.type==FileSystem.NODE_TYPE_LINK)&&(this.status==FileSystem.FILE_UPLOADED||this.status==FileSystem.FILE_XML_RECEIVED||this.status==FileSystem.FILE_TRANSFERRING||this.status==FileSystem.FILE_WAITING||this.status==FileSystem.FILE_CONVERTING||this.status==FileSystem.FILE_REQUEST_PENDING));}
FileSystemNode.prototype.getTarget=function()
{return this.target;}
FileSystemNode.prototype.getStatus=function()
{return this.status;}
FileSystemNode.prototype.setStatus=function(data)
{var status=data.status;var thumbnail=data.thumbnail;status=intVal(status);thumbnail=boolVal(thumbnail);var evt={status:status,oldStatus:this.status,thumbnail:thumbnail,oldThumbnail:this.thumbnail};this.status=status;this.thumbnail=thumbnail;this.fireEvent(evt,FileSystem.EVT_NODE_CHANGED);}
FileSystemNode.prototype.getHash=function()
{return this.hash;}
FileSystemNode.prototype.hasThumbnail=function()
{return this.thumbnail;}
FileSystemNode.prototype.getSize=function()
{return this.size;}
FileSystemNode.prototype.getTags=function()
{return this.tags;}
FileSystemNode.prototype.getDescription=function()
{return this.description;}
FileSystemNode.prototype.getCreationTime=function()
{return this.creationTime;}
FileSystemNode.prototype.parentNodeChanged=function(evt)
{this.fireEvent(evt,FileSystem.EVT_NODE_CHANGED,this);}
FileSystemNode.prototype.rename=function(newName,callback)
{if(!FileSystem.isValidFileName(newName,false)){var result=LD.ERR_FS_INVALID_NAME;var descrip="Invalid filename";var msg='Cannot rename "'+this.name+'" as "'+newName+'".'+descrip;var evt={"action":FileSystem.ACTION_RENAME,"node":this,"oldName":this.name,"newName":newName,"result":result};result=FileSystem.makeException(result,msg,evt);if(callback){callback(result);}
else{FileSystem.raiseError(result,msg,evt);}
return;}
this._ajax.clearArguments();this._ajax.setArgument({"cmd":"rename","source":this.getId(),"target":newName});var _this=this;var _fsop=new FileSystemOperation(FileSystem.ACTION_RENAME);_fsop.sourceNode=this;_fsop.oldName=this.name;_fsop.oldPath=this.getPath();_fsop.newName=newName;this._ajax.setSuccessCallback(function(socket){var result=socket.response;var evt={"action":FileSystem.ACTION_RENAME,"node":_fsop.sourceNode,"oldName":_fsop.oldName,"newName":_fsop.newName,"result":result};if(result===true){_fsop.sourceNode.setName(_fsop.newName);_this.fireEvent(evt,FileSystem.EVT_NODE_CHANGED,_fsop);}
else{var descrip=(FileSystem.err[result])?("\r\n"+FileSystem.err[result]):"";var msg='Cannot rename "'+_fsop.oldPath+'" as "'+_fsop.newName+'".'+descrip;result=FileSystem.makeException(result,msg,evt);}
if(callback)callback(result);});this._ajax.send("room_provider.php");}
FileSystemNode.prototype.moveTo=function(targetNode,overwrite,callback)
{if(!(targetNode instanceof FileSystemDirectory))
throw"FileSystemNode.moveTo: Must provide a target FileSystemDirectory to move this node into";var evt={"action":FileSystem.ACTION_MOVE,"node":this,"target":targetNode};var msg="",result=null;if(this.isMovable()!=true){msg="Cannot move unmovable item "+this.getName();result=new FileSystem.IllegalOperationException(LD.ERR_FS_ILLEGAL_OPERATION,msg,evt);}
if(targetNode.hasAncestor(this)==true){msg="Cannot move "+this.getName()+" into itself or one of its own subfolders";result=new FileSystem.InvalidTargetException(LD.ERR_FS_INVALID_TARGET,msg,evt);}
if(result instanceof LD.Exception){FileSystem.raiseError(result);return;}
var existing=targetNode.getChildByName(this.getName());if(existing!=null&&!overwrite){var ex=new FileSystem.NodeAlreadyExistsException();if(callback){callback(ex);}
else{var msg="A file named "+this.getName()+" already exists in "+targetNode.getPath();FileSystem.raiseError(result,msg,evt);}
return;}
var _this=this;var _id=this.getId();var _path=this.getPath();this._ajax.clearArguments();this._ajax.setArgument({"cmd":"move","source":_id,"target":targetNode.getId(),"overwrite":(overwrite==true)?1:0});var _fsop=new FileSystemOperation(FileSystem.ACTION_MOVE);_fsop.sourceNode=this;_fsop.sourceParent=this.getParent();_fsop.targetNode=targetNode;this._ajax.setSuccessCallback(function(socket){var result=socket.response;var fsNode=isObject(result)?FileSystemNode.build(result):null;if(result&&fsNode instanceof FileSystemNode){evt.result=fsNode;if(_fsop.sourceParent!=null)
_fsop.sourceParent.removeChild(_fsop.sourceNode);FileSystem.registerNode(fsNode);_fsop.targetNode.addChild(fsNode,overwrite);_this.fireEvent(evt,FileSystem.EVT_NODE_MOVED,_fsop);}
else{evt.result=result;msg="Cannot move "+_path;result=new FileSystem.IllegalOperationException(result,msg,evt);}
if(callback)callback(result);});this._ajax.send("room_provider.php");}
FileSystemNode.prototype.copyTo=function(targetNode,overwrite,callback)
{if(!(targetNode instanceof FileSystemDirectory))
throw"FileSystemNode.copyTo: Must provide a target FileSystemDirectory to copy this node into";if(this.isCopiable()!=true)
throw"FileSystemNode.copyTo: Attempted to copy uncopiable FileSystemNode "+this.getPath();if(targetNode.hasAncestor(this)==true){throw"FileSystemNode.copyTo: Attempted to copy FileSystemNode "+this.getPath()+" into its descendant "+targetNode.getPath();}
var evt={"action":FileSystem.ACTION_COPY,"node":this,"target":targetNode};var msg="";var existing=targetNode.getChildByName(this.getName());if(existing!=null&&!overwrite){var ex=new FileSystem.NodeAlreadyExistsException();if(callback){callback(ex);}
else{var msg="A file named "+this.getName()+" already exists in "+targetNode.getPath();FileSystem.raiseError(result,msg,evt);}
return;}
var _this=this;var _path=this.getPath();var _id=this.getId();this._ajax.clearArguments();this._ajax.setArgument({"cmd":"copy","source":_id,"target":targetNode.getPath(),"overwrite":(overwrite==true)?1:0});var _fsop=new FileSystemOperation(FileSystem.ACTION_COPY);_fsop.sourceNode=this;_fsop.sourceParent=this.getParent();_fsop.targetNode=targetNode;this._ajax.setSuccessCallback(function(socket){var result=socket.response;var fsNode=(isObject(result))?FileSystemNode.build(result):null;if(result&&fsNode instanceof FileSystemNode){evt.result=fsNode;FileSystem.registerNode(fsNode);_fsop.targetNode.addChild(fsNode,overwrite);_this.fireEvent(evt,FileSystem.EVT_NODE_COPIED,_fsop);}
else{evt.result=result;msg="Cannot copy "+_path;result=FileSystem.makeException(result,msg,evt);}
if(callback)callback(result);});this._ajax.send("room_provider.php");}
FileSystemNode.prototype.erase=function(permanent)
{if(!this.isDeletable())
throw new LD.Exception(null,this.getName()+__(" cannot be deleted"));if(!this.isMovable())
throw new LD.Exception(null,this.getName()+__(" cannot be moved to the Trash Bin"));var _this=this;var _path=this.getPath();var _id=this.getId();this._ajax.clearArguments();this._ajax.setArgument({"cmd":permanent==true?"delete":"trash","source":_id});var _fsop=new FileSystemOperation(FileSystem.ACTION_DELETE);_fsop.sourceNode=this;_fsop.sourceParent=this.getParent();this._ajax.setSuccessCallback(function(socket)
{var result=socket.response;var evt={"action":FileSystem.ACTION_DELETE,"node":_this};if(permanent==true){if(result===true){_this.fireEvent(evt,FileSystem.EVT_NODE_DELETED,_this);var parent=_this.getParent();if(parent)parent.removeChild(_this);}
else{var msg="Cannot delete "+_path;result=FileSystem.makeException(result,msg,evt);}}
else{var fsNode=(isObject(result))?FileSystemNode.build(result):null;if(result&&fsNode instanceof FileSystemNode){if(_fsop.sourceParent!=null)
_fsop.sourceParent.removeChild(_fsop.sourceNode);FileSystem.registerNode(fsNode);_fsop.targetNode=FileSystem.getNode(fsNode.getParent().getId())
if(_fsop.targetNode!=null){_fsop.targetNode.addChild(fsNode,true);}
_this.fireEvent(evt,FileSystem.EVT_NODE_MOVED,_fsop);}
else{var msg="Cannot delete "+_path;result=FileSystem.makeException(result,msg,evt);}}});this._ajax.send("room_provider.php");}
FileSystemNode.prototype.unerase=function(callback)
{if(this.sysId!=FileSystem.TRASHBIN_NODE_SYS_ID)throw"Not a trashed node";var _this=this;var _id=this.getId();var _path=this.getPath();var _name=this.getName();var _fsop=new FileSystemOperation(FileSystem.ACTION_UNDELETE);_fsop.sourceNode=this;_fsop.sourceParent=this.getParent();this._ajax.clearArguments();this._ajax.setArgument({"cmd":"untrash","source":_id});this._ajax.setSuccessCallback(function(socket)
{var result=socket.response;var fsNode=(isObject(result))?FileSystemNode.build(result):null;var evt={"action":FileSystem.ACTION_UNDELETE,"node":_this};if(result&&fsNode instanceof FileSystemNode){evt.result=fsNode;_fsop.targetNode=fsNode.getParent();if(_fsop.sourceParent!=null)
_fsop.sourceParent.removeChild(_this);FileSystem.registerNode(fsNode);_fsop.targetNode.addChild(fsNode,true);_this.fireEvent(evt,FileSystem.EVT_NODE_MOVED,_fsop);}
else{evt.result=result;msg="Cannot undelete "+_name;result=FileSystem.makeException(result,msg,evt);}
if(callback)callback(result);});this._ajax.send("room_provider.php");}
FileSystemNode.prototype.emptyTrashBin=function(callback)
{var _this=this;var _id=this.getId();var _path=this.getPath();var _name=this.getName();var _fsop=new FileSystemOperation(FileSystem.ACTION_EMPTY_TRASHBIN);_fsop.sourceNode=this;_fsop.sourceParent=this.getParent();this._ajax.clearArguments();this._ajax.setArgument({"cmd":"emptyTrashBin","source":_id});this._ajax.setSuccessCallback(function(socket)
{var result=socket.response;var evt={"action":FileSystem.ACTION_EMPTY_TRASHBIN,"node":_this};evt.result=result;if(result===true){_this.removeAllChildren();}
else{msg="Cannot empty trashbin";result=FileSystem.makeException(result,msg,evt);}
if(callback)callback(result);});this._ajax.send("room_provider.php");}
FileSystemNode.prototype.getAccessLevel=function()
{return FileSystem.permissionsToAccess(this.permissions);}
FileSystemNode.prototype.setAccessLevel=function(accessLevel)
{var _this=this;var _path=this.getPath();var permissions=FileSystem.accessToPermissions(accessLevel);if(!permissions)throw"FileSystemNode.setAccessLevel: Invalid access level";this._ajax.clearArguments();this._ajax.setArgument({"cmd":"setAccess","id":this.getId(),"access":accessLevel});this._ajax.setSuccessCallback(function(socket)
{var result=socket.response;var evt={"action":FileSystem.ACTION_SET_PERMISSIONS,"node":_this};if(result===true){_this.permissions=_this.permissions.substr(0,_this.permissions.length-1).concat(permissions);_this.fireEvent(evt,FileSystem.EVT_NODE_CHANGED,_this);}
else{if(result==LD.ERR_FS_CENSORED_NODE){FileSystem.raiseError(result,"This node has been marked as inappropriate and cannot be made public",evt);}else{FileSystem.raiseError(result,"Cannot change access to "+_path,evt);}}});this._ajax.send("room_provider.php");}
FileSystemNode.prototype.normalize=function()
{if(this instanceof FileSystemDirectory){if(this.children==null)this.children=new Array();}
else{if(typeof(this.children)!="undefined")
delete this.children;}}
FileSystemNode.prototype.isTrashBin=function()
{return(this.sysId==FileSystem.TRASHBIN_SYS_ID);}
FileSystemNode.prototype.isTrashedNode=function()
{return(this.sysId==FileSystem.TRASHBIN_NODE_SYS_ID);}
FileSystemNode.prototype.toObject=function()
{return{id:this.id,name:this.name,type:this.type,type:this.parent,permissions:this.permissions,sysId:this.sysId,sysData:this.sysData,target:this.target,hash:this.hash,status:this.status,original:this.original,replica:this.replica,thumbnail:this.thumbnail,size:this.size,tags:this.tags,description:this.description,creationTime:this.creationTime};}
FileSystemDirectory.extend(FileSystemNode);FileSystemDirectory.classId='01681596ac366017';function FileSystemDirectory(name)
{FileSystemDirectory.superConstructor.call(this,FileSystem.NODE_TYPE_DIR,name);this.children=new Array();this.loaded=false;}
FileSystemDirectory.prototype.isDirectory=function(){return true;}
FileSystemDirectory.build=function(obj)
{if(!obj||obj.type==null||!obj.name)throw"Malformed node object";var node=new FileSystemDirectory(obj.type,obj.name);node.id=obj.id||0;node.parent=obj.parent||0;node.permissions=obj.permissions||58;node.sysId=obj.sysId||"";node.sysData=obj.sysData||"";node.target=obj.target||"";node.hash=obj.hash||"";node.status=obj.status||0;node.original=(obj.original==true);node.replica=obj.replica||0;node.thumbnail=obj.thumbnail||false;node.size=obj.size||0;node.tags=obj.tags||"";node.description=obj.description||"";node.creationTime=obj.creationTime||"00000000000000";return node;}
FileSystemDirectory.prototype.getChild=function(child)
{var childIndex=-1;if(typeof(child)=="number"){if(!isInteger(child))
throw"FileSystemDirectory.getChild: Index must be an integer number";if(child<0||child>=this.children.length)
throw"FileSystemDirectory.getChild: Index out of bounds ("+child+")";childIndex=child;}
else
childIndex=this.getChildIndex(child);return(childIndex>=0)?FileSystem.getNode(this.children[childIndex]):null;}
FileSystemDirectory.prototype.getChildById=function(nodeId)
{if(typeof(nodeId)!="number"){throw"FileSystemDirectory.getChildById: Must provide the id of the node to retrieve";}
nodeId=intVal(nodeId);var children=this.getChildren();for(var i=0;i<children.length;i++){if(children[i].getId()==nodeId)return node;}
return null;}
FileSystemDirectory.prototype.getChildByName=function(nodeName)
{if(typeof(nodeName)!="string"){throw"FileSystemDirectory.getChildByName: Must provide the name of the node to retrieve";}
nodeName=nodeName.toLowerCase();var children=this.getChildren();for(var i=0;i<children.length;i++){if(children[i].getName().toLowerCase()==nodeName)return children[i];}
return null;}
FileSystemDirectory.prototype.getChildren=function()
{var aux=new Array();for(var i=0;i<this.children.length;i++){var node=FileSystem.getNode(this.children[i]);if(node!=null)aux.push(node);}
return aux;}
FileSystemDirectory.prototype.getChildIndex=function(node)
{if(node==""||typeof(node)=="undefined")
throw"FileSystemDirectory.getChildIndex: Must provide a name or index (integer) to retrieve a node";if(typeof(node)=="object"&&node instanceof FileSystemNode){for(var i=0;i<this.children.length;i++){if(this.children[i]==node.getId())return i;}
return-1;}
else if(typeof(node)=="string"&&node!=""){node=node.toLowerCase();for(var i=0;i<this.children.length;i++){var n=FileSystem.getNode(this.children[i]);if(n&&n.getName().toString().toLowerCase()==node)return i;}
return-1;}
else{throw"FileSystemDirectory.getChildIndex: Must provide the name of the node to get";}}
FileSystemNode.prototype.hasChild=function(child)
{if(!(child instanceof FileSystemNode))
throw"FileSystemDirectory.hasChild: child argument must be a FileSystemNode instance";var childId=child.getId();return inArray(this.children,childId);}
FileSystemDirectory.prototype.putChild=function(node)
{if(!node||!(node instanceof FileSystemNode))
throw"FileSystemDirectory.putChild: Must provide an FileSystemNode object"
if(!this.children)this.children=new Array();if(inArray(this.children,node.getId())==false){this.children.push(node.getId());FileSystem.registerNode(node);node.setParent(this);}}
FileSystemDirectory.prototype.putChildren=function(childNodes)
{if(!childNodes||!(childNodes instanceof Array)){throw"FileSystemDirectory.putChildren: Must provide an Array object with the nodes to be added"}
this.children=new Array();for(var i=0;i<childNodes.length;i++){this.children.push(childNodes[i].getId());FileSystem.registerNode(childNodes[i]);childNodes[i].setParent(this);}}
FileSystemDirectory.prototype.addChild=function(node,replace)
{var name=node.getName();var existing=this.getChild(name);if(existing!=null){var existingParent=existing.getParent();if(replace==true&&existingParent)
existingParent.removeChild(existing);else
throw"FileSystemDirectory.addChild: There already exists a node named "+name;}
var oldParent=node.getParent();if(oldParent&&oldParent!=this)
oldParent.removeChild(node);this.children.push(node.getId());node.setParent(this);FileSystem.registerNode(node);var evt={"node":this,"child":node,"act":"add"};this.fireEvent(evt,FileSystem.EVT_NODE_CHILDREN_CHANGED,this);FileSystem.fireEvent(evt,FileSystem.EVT_NODE_CHILDREN_CHANGED,this);}
FileSystemDirectory.prototype.removeChild=function(node)
{var nodeIndex=this.getChildIndex(node);if(nodeIndex==-1)
throw"FileSystemDirectory.removeChild: Node was not found";if(nodeIndex<0||nodeIndex>=this.children.length)
throw"FileSystemDirectory.removeChild: Index out of bounds ("+node+")";this.children.splice(nodeIndex,1);var evt={"node":this,"child":node,'act':'del'};this.fireEvent(evt,FileSystem.EVT_NODE_CHILDREN_CHANGED,this);FileSystem.fireEvent(evt,FileSystem.EVT_NODE_CHILDREN_CHANGED,this);}
FileSystemDirectory.prototype.removeAllChildren=function()
{var aux=new Array();for(var i=0;i<this.children.length;i++){aux.push(FileSystem.getNode(this.children[i]));}
var evt={"node":this,"children":aux};this.children=new Array();this.fireEvent(evt,FileSystem.EVT_NODE_CHILDREN_CHANGED,this);}
FileSystemDirectory.prototype.fetchChildren=function(callback,callbackObject)
{var user=R31UserRegistry.getLoggedUser();if(!user)return;Ajax.addCommand('getUsageStats',{'user':user.id});this._ajax.clearArguments();this._ajax.setArgument({"cmd":"getChildren","source":this.getId()});var _this=this;this._ajax.setSuccessCallback(function(socket)
{var result=socket.response;if(result&&result.children){var children=FileSystemNode.build(result.children);_this.putChildren(children);}
else{_this.children=new Array();}
_this.loaded=true;var prefs=(result&&result.prefs)?result.prefs:null;var evt={"action":FileSystem.ACTION_BROWSE,"node":_this,"prefs":prefs};_this.fireEvent(evt,FileSystem.EVT_NODE_CHILDREN_CHANGED,_this);if(callback)
callback.call(callbackObject||null,_this);});this._ajax.send("room_provider.php");}
FileSystemDirectory.prototype.createDirectory=function(name)
{if(!FileSystem.isValidFileName(name,true)){throw"FileSystemDirectory: Directory name is invalid. It cannot be emtpy nor contain any of the following: * \\ | / \" < > ? :";}
this._ajax.setArgument({"cmd":"createDirectory","path":this.getPath(),"target":name});var _this=this;this._ajax.setSuccessCallback(function(socket)
{var result=socket.response;var evt={"action":FileSystem.ACTION_CREATE,"node":_this,"target":name,"result":result};if(isObject(result)){var fsNode=(isObject(result))?FileSystemNode.build(result):null;if(fsNode instanceof FileSystemDirectory)
_this.addChild(fsNode);}
else{var msg='Cannot create folder "'+name+'" in "'+_this.getPath()+'"';FileSystem.raiseError(result,msg,evt);}});this._ajax.send("room_provider.php");}
FileSystemRootDirectory.extend(FileSystemDirectory);function FileSystemRootDirectory()
{if(FileSystem.getRoot()!=null){throw"FileSystemRootDirectory: There can only be one instance of Filesystem Root directory. Use getInstance method.";}
FileSystemRootDirectory.superConstructor.call(this,"");}
FileSystemRootDirectory.getInstance=function()
{var fsRoot=FileSystem.getRoot();if(!fsRoot)fsRoot=new FileSystemRootDirectory();return fsRoot;}
FileSystemRootDirectory.prototype.getParent=function()
{return null;}
FileSystemRootDirectory.prototype.setName=function()
{this.name="";}
FileSystemFile.extend(FileSystemNode);FileSystemFile.classId="a42b6e32ec0ab0a3";function FileSystemFile(name)
{FileSystemFile.superConstructor.call(this,FileSystem.NODE_TYPE_FILE,name);}
FileSystemFile.prototype.isFile=function(){return true;}
FileSystemFile.prototype.getTypeDescriptor=function()
{return FileSystem.getTypeDescriptor(this.getExtension());}
FileSystemFile.prototype.isDownloadable=function()
{return(this.hash!=""&&this.status==75);}
FileSystemFile.prototype.isStreamable=function()
{return(this.hash!=""&&this.status==75);}
FileSystemLink.extend(FileSystemNode);function FileSystemLink(name)
{FileSystemLink.superConstructor.call(this,FileSystem.NODE_TYPE_LINK,name);this.target="";}
FileSystemLink.prototype.isLink=function(){return true;}
FileSystemLink.prototype.getTarget=function()
{return this.target;}
FileSystemLink.prototype.setTarget=function(target)
{this.target=varDefault(target,"");}
FileSystemLink.prototype.getTypeDescriptor=function()
{return new FileTypeDescriptor("video/flv","flv","video","x-flv","file_video_flv");}
function FileTypeDescriptor(name,extensions,mimeType,mimeSubtype,defaultIcon)
{if(name==""||extensions==""||extensions==null)
throw"FileTypeDescriptor: Must provide type's name";if(typeof(extensions)=="string"){extensions=extensions.split("|");}
if(!isObject(extensions)){throw"FileTypeDescriptor: Must provide type's associated extension(s)";}
this.name=name;this.extensions=extensions;if(mimeType!=""){this.mimeType=mimeType;this.mimeSubtype=varDefault(mimeSubtype,"");}
else{this.mimeType="application";this.mimeSubtype="octet-stream";}
this.defaultIcon=varDefault(defaultIcon,"icon_file.gif");}
FileTypeDescriptor.prototype.getName=function()
{return this.name;}
FileTypeDescriptor.prototype.getExtensions=function()
{return this.extensions;}
FileTypeDescriptor.prototype.getFullMimeType=function()
{if(this.mimeSubtype!="")
return this.mimeType+"/"+this.mimeSubtype;else
return this.mimeType;}
FileTypeDescriptor.prototype.getMimeType=function()
{return this.mimeType;}
FileTypeDescriptor.prototype.getMimeSubtype=function()
{return this.mimeSubtype;}
FileTypeDescriptor.prototype.getDefaultIcon=function()
{return this.defaultIcon;}
function FileSystemOperation(type)
{this.type=type||null;}
FileSystemOperation.prototype.getType=function()
{return this.type;}
FileSystemStorageRegistry={registry:{},get:function(userId)
{userId=intVal(userId);return this.registry[userId]||null;},put:function(userId,stats)
{userId=intVal(userId);if(userId<1||!isObject(stats)||stats.fileCount==null||stats.storageUsed==null)return;this.registry[userId]=stats;},remove:function(userId)
{userId=intVal(userId);if(userId<1)return;delete this.registry[userId];},getFileCount:function(userId)
{var stats=this.get(userId);return(stats!=null)?stats.fileCount:null;},getStorageUsed:function(userId)
{var stats=this.get(userId);return(stats!=null)?stats.storageUsed:null;},fetch:function(userId,callback)
{userId=intVal(userId);if(userId<1)return false;var _this=this;var ajax=new R31Ajax();ajax.setArgument("cmd","getUsageStats");ajax.setArgument("user",userId);ajax.setSuccessCallback(function(socket){var result=socket.response;if(!result)return;var aux={fileCount:result[0],storageUsed:result[1]};_this.put(userId,aux);if(callback)
callback.call(callbackObject||null,result);});ajax.send("room_provider.php");}}
FileSystemNodeStatusManager={items:new Array(),interval:20,intervalStep:10,intervalMax:40,_timer:null,_ajax:new AjaxSocket(),_fetching:false,add:function(node)
{if(!(node instanceof FileSystemNode)){throw"FileSystemNodeStatusManager.add: Must provide a filesystem node object whose status is to be followed";}
var id=node.getId();if(!inArray(this.items,id)){this.items.push(id);}
if(this._timer==null)
this.initTimer();},remove:function(node)
{if(!(node instanceof FileSystemNode))
throw"FileSystemNodeStatusManager.add: Must provide a filesystem node object whose status is to be followed";var id=node.getId();this.items=arrayRemove(id);},initTimer:function()
{this.clearTimer();this._timer=setInterval(function(){FileSystemNodeStatusManager.fetch();},this.interval*1000);},clearTimer:function()
{if(this._timer){clearTimeout(this._timer);this._timer=null;}},fetch:function()
{if(this._fetching==true||this.items.length==0)return;var _this=this;this._ajax.clearArguments();this._ajax.setArgument("cmd","getNodeStatus");this._ajax.setArgument("id",this.items.join(","));this._ajax.setSuccessCallback(function(socket){_this._fetching=false;var result=socket.response;if(!isObject(result)){throw"FileSystemNodeStatusManager.fetch: status list must be an object";}
var node=null,aux=new Array();for(var i=0;i<_this.items.length;i++){var id=_this.items[i];if(typeof(result[id])!="undefined"){node=FileSystem.getNode(id);if(node){node.setStatus(result[id]);if(node.isProcessing())
aux.push(id);}}
else
aux.push(id);}
_this.items=aux;if(_this.items.length==0)
_this.clearTimer();});this._ajax.send("room_provider.php");this._fetching=true;}};

/*========== StatsLogger.js ==========*/

StatsLogger.extend(LD.Proto);function StatsLogger(storageUrl,interval)
{StatsLogger.superConstructor.call(this);this.stats=null;this.lastChange=null;this.lastUpdate=null;this.storageUrl=varDefault(storageUrl,"");this.ajax=null;this.interval=10;this.thread=null;this.resetAfterSave=true;this.init(interval);}
StatsLogger.prototype.init=function(interval)
{this.stats=new Array();this.ajax=new AjaxSocket();this.sid=LD.Cookie.get("PHPSESSID");this.setInterval(interval||this.interval);}
StatsLogger.prototype.add=function(operation,tag,value)
{this.stats.push({tm:new Date(),operation:operation,tag:tag,value:value});this.statsChanged();}
StatsLogger.prototype.statsChanged=function()
{this.lastChange=new Date();if(!this.thread)
this.start();}
StatsLogger.prototype.clearStats=function()
{this.lastChange=null;this.stats=new Array();var time=new Date().getTime().toString();this.add('ping\tping: '+time+' \t');}
StatsLogger.prototype.save=function(force,callback,callbackObject)
{if(this.storageUrl=="")return false;if(!this.lastChange||(this.lastUpdate&&this.lastUpdate.valueOf()>=this.lastChange.valueOf()))return;var _this=this;this.ajax.setMethod(Ajax.METHOD_POST);this.ajax.setBodyArgument({"stats":this.getStatsString()});this.ajax.setSuccessCallback(function(socket)
{_this.clearStats();var result=socket.response;});this.ajax.send(this.storageUrl);}
StatsLogger.prototype.getStatsString=function()
{var str="",entry;for(var i=0;i<this.stats.length;i++){entry=this.stats[i];str+=([entry.tm.toMilitary(true,true),entry.operation,entry.tag,entry.value].join("\t")+LD.LF);}
return str;}
StatsLogger.prototype.getSessionId=function()
{return LD.Cookie.get("PHPSESSID");}
StatsLogger.prototype.start=function(interval)
{this.stop();if(this.ajax==null)
this.init(interval);else if(interval!=null)
this.setInterval(interval);var _this=this;this.ajax.setArgument("sid",this.sid);this.thread=setInterval(function(){_this.save();},this.interval*1000);}
StatsLogger.prototype.stop=function()
{if(this.thread!=null){clearInterval(this.thread);this.thread=null;}}
StatsLogger.prototype.setInterval=function(interval)
{if(!interval)return;this.interval=intVal(interval);}
StatsLogger.Loggable={getLogInfo:function(){}};

/*========== JUI.js ==========*/

var JUI=new Object();JUI.EVT_MOUSE=100;JUI.EVT_MOUSE_DOWN=101;JUI.EVT_MOUSE_UP=102;JUI.EVT_MOUSE_CLICK=103;JUI.EVT_MOUSE_DBLCLICK=104;JUI.EVT_MOUSE_MOVE=111;JUI.EVT_MOUSE_DRAG=112;JUI.EVT_MOUSE_WHEEL=113;JUI.EVT_MOUSE_OVER=114;JUI.EVT_MOUSE_OUT=115;JUI.EVT_KEY_DOWN=121;JUI.EVT_KEY_DOWN=122;JUI.EVT_KEY_PRESS=123;JUI.EVT_FOCUS=131;JUI.EVT_BLUR=132;JUI.EVT_SCROLL=133;JUI.EVT_RESIZED=134;JUI.EVT_CHANGED=135;JUI.EVT_MODEL_CHANGED=1201;JUI.EVT_VIEW_CHANGED=1202;JUI.MSG_REQUEST_FOCUS=10001;JUI.POS_LEADING=0;JUI.POS_TRAILING=1;JUI.LAYER_DEPTH=65536;JUI.LAYER_DEFAULT=0;JUI.LAYER_UNDERGROUND=-1;JUI.LAYER_WALLPAPER=0;JUI.LAYER_BASE=1;JUI.LAYER_DASHBOARD=2;JUI.LAYER_FLOATING=3;JUI.LAYER_POPUP=4;JUI.LAYER_DRAG=5;JUI.LAYER_GLASS=6;JUI.LAYER_TASKBAR=525200;JUI.EVT_BEFORE_DISPOSE=100001;JUI.EVT_AFTER_DISPOSE=100002;JUI.positioning=["absolute","relative","static"];JUI.POSITION_ABSOLUTE=0;JUI.POSITION_RELATIVE=1;JUI.POSITION_STATIC=2;JUI.SCROLL_NONE=0;JUI.SCROLL_HORIZONTAL=1;JUI.SCROLL_VERTICAL=2;JUI.SCROLL_BOTH=3;JUI.debug=false;JUI.templates={};JUI.templateHolder=null;JUI.topContainer=null;JUI.nullImageSrc=DIR_IMAGES+"spacer.gif";JUI.allowDocumentScroll=true;JUI.DocumentEventHandler=new LD.Proto();JUI.DocumentEventHandler.init=function()
{document.onmousemove=function(evt){JUI.DocumentEventHandler.fireEvent(evt||window.event,JUI.EVT_MOUSE_MOVE);}
window.onscroll=function(evt){evt=LD.Event.normalize(evt);if(JUI.allowDocumentScroll){JUI.DocumentEventHandler.fireEvent(evt,JUI.EVT_SCROLL);}
else{LD.Event.cancel(evt,true);window.scrollTo(0,0);}};document.onmousedown=function(evt){JUI.DocumentEventHandler.fireEvent(evt||window.event,JUI.EVT_MOUSE_DOWN);};document.onmouseup=function(evt){JUI.DocumentEventHandler.fireEvent(evt||window.event,JUI.EVT_MOUSE_UP);};window.onresize=function(evt){try{if(JUI)
JUI.DocumentEventHandler.fireEvent(evt||window.event,JUI.EVT_RESIZED);}catch(e){}}}
JUI.retrieveTemplates=function(fromHtmlNode)
{if(!fromHtmlNode&&fromHtmlNode.nodeType!=LD.NODE_ELEMENT)
throw"JUI.retrieveTemplates: You must provide an HTML Node to extract the templates from";var node,count=0,name;for(var i=0;i<fromHtmlNode.childNodes.length;i++){node=fromHtmlNode.childNodes[i];if(node.nodeType==LD.NODE_ELEMENT){if(node.id.substr(0,11).toLowerCase()=="__template_"){name=node.id.substr(11);JUI.templates[name]=node;++count;}}}
return count;}
JUI.setTemplateHolder=function(templateHolder)
{if(templateHolder==null||typeof(templateHolder)!="object"||templateHolder.nodeType!=LD.NODE_ELEMENT){return false;}
this.templateHolder=templateHolder;}
JUI.addTemplate=function(template)
{if(template==null||template=="")return;if(typeof(template)=="string"){var nodeId="__template_"+template;var rootNode=document.getElementById(nodeId);if(rootNode){JUI.templates[template]=rootNode;}}
else if(template instanceof Array){for(var i=0;i<template.length;i++){JUI.addTemplate(template[i]);}}}
JUI.putTemplate=function(id,source)
{if(!id||id==""||!source||source==""||typeof(source)!="string"){return false;}
this.templates[id]=source;}
JUI.getTemplate=function(name)
{return this.templates[name]||"";}
JUI.getTemplateInstance=function(templateName)
{if(!templateName||!this.templateHolder)return null;var htmlNode=null;var template=this.getTemplate(templateName);if(template!=""){insertHTML(this.templateHolder,template);for(htmlNode=this.templateHolder.lastChild||null;htmlNode!=null&&htmlNode.nodeType!=LD.NODE_ELEMENT;htmlNode=this.templateHolder.lastChild)
{LD.Element.remove(htmlNode);}
if(htmlNode){if(!htmlNode.removeAttribute)debugger;htmlNode.removeAttribute("id");}}
return htmlNode;}
JUI.getTopContainer=function()
{return this.topContainer;}
JUI.setTopContainer=function(container)
{if(this.topContainer!=null)return false;if(!(container instanceof JUIContainer))
throw"JUI.setTopContainer: container must be an instance of JUIContainer";this.topContainer=container;return true;}
JUI.unsetTopContainer=function()
{this.topContainer=null;}
JUI.getComponent=function(htmlNode,bubble,componentClass)
{if(!htmlNode)throw"getComponent: You must provide an HTML Node";if(htmlNode.nodeType!=LD.NODE_ELEMENT)
throw"getComponent: "+htmlNode+" is not an HTML element";var juic=null,c;if(!componentClass)componentClass=JUIComponent;while(htmlNode&&juic==null){c=JUIComponent.getInstance(htmlNode.dhtmlOwner);if(c instanceof componentClass)
juic=c;htmlNode=htmlNode.parentNode;}
return juic;}
JUI.getWidth=function(htmlNode)
{if(htmlNode.style.display=="none")
return getCurrentStyleProp(htmlNode,"width");else
return htmlNode.offsetWidth;}
JUI.getHeight=function(htmlNode)
{if(htmlNode.style.display=="none")
return getCurrentStyleProp(htmlNode,"height");else
return htmlNode.offsetHeight;}
JUI.zIndexCompare=function(a,b)
{return a.getZIndex()-b.getZIndex();}
JUI.makeSelectable=function(htmlNode,selectable,recurse)
{if(!htmlNode||htmlNode.nodeType!=LD.NODE_ELEMENT)return;var tagName=htmlNode.tagName.toUpperCase();var sel,preventBubbling=false;var dhtmlid=htmlNode.dhtmlid||getAttrib(htmlNode,"dhtmlid");if(inArray(["INPUT","SELECT","TEXTAREA","BUTTON","OPTION"],tagName)){sel=(selectable!==false);if(sel==true)preventBubbling=true;}
else
sel=(selectable===true);if(Browser.isIE){if(sel==false)
htmlNode.onselectstart=JUI.cancelSelection;else if(sel==true&&preventBubbling==true)
htmlNode.onselectstart=JUI.preventBubbling;htmlNode.unselectable=(sel)?"off":"on";}
else if(Browser.isMozilla)
htmlNode.style.MozUserSelect=(sel)?"text":"text";else if(Browser.isSafari)
htmlNode.style.KhtmlUserSelect=(sel)?"text":"none";else
htmlNode.style.userSelect=(sel)?"text":"none";if(recurse==true)
for(var i=0;i<htmlNode.childNodes.length;i++){JUI.makeSelectable(htmlNode.childNodes[i],selectable,recurse);}}
JUI.cancelSelection=function()
{return false;}
JUI.preventBubbling=function()
{window.event.cancelBubble=true;}
JUI.cloneNodeHTML=function(htmlNode,deep){if(!htmlNode||!htmlNode.nodeType)return null;deep=(deep==true);var clone;if(Browser.isIE){var nodeHTML=htmlNode.xml||htmlNode.outerHTML;var tmpNode=document.createElement("DIV");tmpNode.innerHTML=nodeHTML;clone=tmpNode.firstChild.cloneNode(deep);tmpNode.removeNode(true);}
else
clone=htmlNode.cloneNode(deep);return clone;}
JUI.setDhtmlOwner=function(htmlNode,owner,recurse)
{if(!htmlNode||htmlNode.nodeType!=LD.NODE_ELEMENT||!(owner instanceof JUIComponent))return;htmlNode.dhtmlOwner=owner.componentId||null;if(htmlNode.nodeType==LD.NODE_ELEMENT&&recurse==true)
for(var i=0;i<htmlNode.childNodes.length;i++){JUI.setDhtmlOwner(htmlNode.childNodes[i],owner,recurse);}}
JUI.getDhtmlNodeByValue=function(htmlNodes,value)
{if(!isObject(htmlNodes))
throw"JUI.getDhtmlNodeByValue: Must provide a collection of DHTML nodes";var node=null,aux,val;for(var k in htmlNodes){node=htmlNodes[k];if(!node||typeof(node)!="object")continue;if(node.nodeType==LD.NODE_ELEMENT){val=node.attributes.dhtmlvalue;if(val&&val.value==value)return node;}
else{aux=JUI.getDhtmlNodeByValue(node,value);if(aux!=null)return aux;}}
return null;}
JUI.getDhtmlRefs=function(htmlNode)
{if(!htmlNode||htmlNode.nodeType!=LD.NODE_ELEMENT)return null;var res={};var aux,aux1,aux2,node;var name,val;for(var i=0;i<htmlNode.childNodes.length;i++){node=htmlNode.childNodes[i];if(!node.nodeType||!node.attributes)continue;name=node.attributes.dhtmlid;if(name&&name.value){if(!res[name.value])
res[name.value]=node;else{if(res[name.value]instanceof Array)
res[name.value].push(node);else
res[name.value]=[res[name.value],node];}
val=node.attributes.dhtmlvalue;node.dhtmlValue=(val!=null)?(val.value||null):null;}
aux=JUI.getDhtmlRefs(node);if(aux)
for(var k in aux){if(!res[k])
res[k]=aux[k];else{if(res[k]instanceof Array){if(aux[k]instanceof Array)
res[k]=arrayMerge(res[k],aux[k]);else
res[k].push(aux[k]);}
else
res[k]=[res[k],aux[k]];}}}
return res;}
JUI.getDhtmlStyles=function(htmlNode)
{var allStyles=new Array(),styles=new Object(),entry,k,v;if(!htmlNode||htmlNode.nodeType!=LD.NODE_ELEMENT)return allStyles;if(htmlNode.attributes&&htmlNode.attributes.dhtmlstyle){var styleString=varDefault(htmlNode.attributes.dhtmlstyle.value,"");if(styleString!=""){var styleDefs=styleString.split(";");for(var i=0;i<styleDefs.length;i++){entry=styleDefs[i].split(":");if(entry.length>=2){k=entry.shift().toString().trim();v=entry.join(":").trim();allStyles.push({node:htmlNode,style:k,formula:v});}}}}
var child,childStyles;for(var i=0;i<htmlNode.childNodes.length;i++){child=htmlNode.childNodes[i];if(child&&child.nodeType==LD.NODE_ELEMENT){childStyles=JUI.getDhtmlStyles(htmlNode.childNodes[i]);if(childStyles instanceof Array&&childStyles.length>0)
allStyles=allStyles.concat(childStyles);}}
return allStyles;}
JUI.getDhtmlValue=function(htmlNode)
{if(!htmlNode)
throw"JUI.getDhtmlValue: Must provide an HTML node";if(!htmlNode.nodeType!=LD.NODE_ELEMENT)return null;var val=htmlNode.attributes.dhtmlvalue;if(!val)return null;return val.value||null;}
JUI.fixDimension=function(value)
{return Math.max(0,intVal(value));}
JUI.makeSpaceHolder=function(width,height)
{var node=document.createElement("DIV");with(node.style){width=intVal(varDefault(width,1));height=intVal(varDefault(height,1));display="inline";}
return node;}
JUI.makeLabel=function(width,height,innerHTML,toolTip,styles)
{width=intVal(varDefault(width,1));height=intVal(varDefault(height,1));var node=document.createElement("DIV");with(node.style){display="inline";overflow="hidden";}
insertHTML(node,innerHTML);var comp=new JUIHtmlNode(node);comp.setPositioning(JUI.POSITION_STATIC);comp.setLocation(0,0);comp.setSize(width,height);comp.setToolTip(toolTip);if(styles!=null)
for(var k in styles){node.style[k]=styles[k];}
return comp;}
JUI.makeButton=function(size,caption,imageUrl,toolTip,callback,object,styles)
{var btn=new JUIButton(caption,size,size);btn.init();btn.setToolTip(toolTip);var btnRoot=btn.getRoot();btnRoot.style.position="absolute";if(imageUrl)
with(btnRoot.style){backgroundImage="url("+imageUrl+")";backgroundPosition=(btn.caption!="")?"center left":"center center";backgroundRepeat="no-repeat";}
if(typeof(callback)=="function"){object=varDefault(object,null);btn.onclick=function(evt,type,src){callback.call(object,evt,type,src);}
btn.addListener(JUI.EVT_MOUSE_CLICK,btn.onclick,btn);}
if(styles!=null)
for(var k in styles){btnRoot.style[k]=styles[k];}
btn.setSize(size,size);return btn;}
JUI.makeImage=function(src,owner,styles)
{var img=document.createElement("IMG");img.src=varDefault(src,JUI.nullImageSrc);if(owner instanceof JUIComponent)
img.dhtmlOwner=owner.componentId;if(styles){for(var k in styles){img.style[k]=styles[k];}}
return img;}
JUI.makeTableCol=function(width,align,bgcolor)
{var col=document.createElement("COL");col.width=width;col.align=varDefault(align,"");col.bgcolor=varDefault(bgcolor,"");return col;}
JUI.currentSkin="wixi";JUI.getCurrentSkin=function()
{return JUI.currentSkin;}
JUI.setCurrentSkin=function(skinName)
{JUI.currentSkin=skinName;}
JUI.noSelect=function(evt)
{evt=evt||window.event;JUI.cancelEvent(evt,true);}
JUI.WithTitle={getTitle:function(){},setTitle:function(title){}}

/*========== JUIComponent.js ==========*/

JUIComponent.extend(LD.Proto);JUIComponent.instances=new Object();JUIComponent.nextId=1;JUIComponent.holder=null;JUIComponent.templates={};JUIComponent.dhtmlStyleWrappers={left:JUI.fixDimension,top:JUI.fixDimension,width:JUI.fixDimension,height:JUI.fixDimension};function JUIComponent()
{JUIComponent.superConstructor.call(this);if(!JUIComponent.holder)JUIComponent.createElementHolder();this.componentId=JUIComponent.registerInstance(this);this.name="";this.visible=true;this.active=false;this.positioning=JUI.POSITION_ABSOLUTE;this.enabled=true;this.displayable=true;this.autoRepaint=true;this.html=new Object();this.prototypes=new Object();this.dhtmlStyles=new Array();this.relatedObjects=new Array();this.dropSources=new Array();this.dropTargets=new Array();this.draggable=false;this.x=0;this.y=0;this.preferredX=0;this.preferredY=0;this.width=null;this.height=null;this._lastWidth=0;this._lastHeight=0;this.preferredWidth=null;this.preferredHeight=null;this.maxWidth=16384;this.maxHeight=16384;this.layer=null;this.zIndex=0;}
JUIComponent.getInstance=function(componentId)
{var id=varDefault(componentId,null);if(id==null)
return null;else
return this.instances[componentId]||null;}
JUIComponent.registerInstance=function(component)
{if(inArray(this.instances,component))return;var id=this.getNextId();this.instances[id]=component;return id;}
JUIComponent.unregisterInstance=function(component)
{for(var k in this.instances){if(this.instances[k]==component)
delete this.instances[k];}}
JUIComponent.getNextId=function()
{return this.nextId++;}
JUIComponent.prototype.getComponentId=function()
{return this.componentId;}
JUIComponent.destroyInstance=function(instanceId)
{var component=this.instances[instanceId];if(!component)return;component.dispose();}
JUIComponent.createElementHolder=function()
{this.holder=document.createElement("DIV");this.holder.id="JUIElementHolder";with(this.holder.style){position="absolute";left="-100px";top="-100px";width="100px";height="100px";visibility="hidden";}
document.body.appendChild(this.holder);}
JUIComponent.prototype.init=function(htmlNode)
{var root=null;if(htmlNode&&htmlNode.nodeType==LD.NODE_ELEMENT){root=htmlNode;if(this.width==null){this.width=this.preferredWidth=getCurrentStyleProp(htmlNode,"width");}
if(this.height==null){this.height=this.preferredHeight=getCurrentStyleProp(htmlNode,"height");}}
else{var classTemplates=this.constructor.templates;if(classTemplates){var templateName=varDefault(classTemplates.base,"");if(templateName!="")
root=JUI.getTemplateInstance(templateName);}}
if(root==null)root=this.createElement("DIV");this.root=root;JUI.makeSelectable(root,null,true);this.html=JUI.getDhtmlRefs(root);this.dhtmlStyles=JUI.getDhtmlStyles(root);JUI.setDhtmlOwner(root,this,true);this.setPositioning(this.positioning);}
JUIComponent.prototype.dispose=function()
{this.beforeDisposal();LD.EventDispatcher.removeAllHaving(this);if(this.root){LD.Element.removeChildren(this.root);with(this.root.style){display="none";width="0px";height="0px";}
if(this.html)
this.html={root:this.root};}
this.displayable=false;}
JUIComponent.prototype.getRoot=function()
{return this.root;}
JUIComponent.prototype.beforeDisposal=function()
{}
JUIComponent.prototype.isDisplayable=function()
{return(this.root!=null&&this.displayable==true);}
JUIComponent.prototype.setMouseEventHandlers=function()
{this.root.onmousedown=this.mouseDown;this.root.onmouseup=this.mouseUp;this.root.onmouseover=this.mouseOver;this.root.onmouseout=this.mouseOut;}
JUIComponent.prototype.getName=function()
{return this.name;}
JUIComponent.prototype.setName=function(name)
{this.name=varDefault(name,"").toString();}
JUIComponent.prototype.isDraggable=function()
{return this.draggable;}
JUIComponent.prototype.setDraggable=function(draggable)
{this.draggable=(draggable==true);}
JUIComponent.prototype.getColor=function()
{return this.root.style.color||"";}
JUIComponent.prototype.setColor=function(color)
{this.root.style.color=varDefault(color,"");}
JUIComponent.prototype.getBackgroundColor=function(color)
{return varDefault(this.root.style.backgroundColor,"");}
JUIComponent.prototype.setBackgroundColor=function(color)
{this.root.style.backgroundColor=varDefault(color,"");}
JUIComponent.prototype.getBackground=function(color)
{return varDefault(this.root.style.background,"");}
JUIComponent.prototype.setBackground=function(background)
{this.root.style.background=varDefault(background,"");}
JUIComponent.prototype.setBorder=function(border)
{if(!this.displayable)return;this.root.style.border=border;}
JUIComponent.prototype.setTransparency=function(transparency)
{var opacity=100-Math.max(0,Math.min(100,intVal(transparency)));if(Browser.isIE){if(this.root.filters["alpha"])
this.root.filters["alpha"].opacity=opacity;else
this.root.style.filter="Alpha(opacity=90)";}
else
this.getRoot().style.opacity=opacity/100;}
JUIComponent.prototype.getRelatedObjects=function()
{return this.relatedObjects;}
JUIComponent.prototype.getScrollBounds=function()
{var pnt=this.getParent();if(pnt)
xy=getXY(this.getRoot(),pnt.getRoot());else
xy=getXY(this.getRoot());wh=this.getSize();return{"x":xy.x,"y":xy.y,"width":wh.width,"height":wh.height};}
JUIComponent.prototype.getOffsetBounds=function()
{var h=(this.root==document.body&&Browser.isMozilla)?this.root.scrollHeight:this.root.offsetHeight;return{"x":this.root.offsetLeft,"y":this.root.offsetTop,"width":this.root.offsetWidth,"height":h};}
JUIComponent.prototype.getScrollLocation=function()
{return getXY(this.getRoot());}
JUIComponent.prototype.getOffsetLocation=function()
{return{"x":this.root.offsetLeft,"y":this.root.offsetTop};}
JUIComponent.prototype.getBounds=function()
{return{x:this.preferredX,y:this.preferredY,width:this.preferredWidth,height:this.preferredHeight};}
JUIComponent.prototype.setBounds=function(x,y,width,height)
{this.setLocation(x,y);this.setSize(width,height);}
JUIComponent.prototype.getLocation=function()
{return{"x":this.preferredX,"y":this.preferredY};}
JUIComponent.prototype.setLocation=function(x,y)
{x=intVal(x);y=intVal(y);this.preferredX=x;this.preferredY=y;this.x=x;this.y=y;if(this.root!=null){this.root.style.left=this.x;this.root.style.top=this.y;}}
JUIComponent.prototype.setAbsolute=function(absolute)
{this.setPositioning(absolute==true?JUI.POSITION_ABSOLUTE:JUI.POSITION_STATIC);}
JUIComponent.prototype.getPositioning=function(positioning)
{return this.positioning;}
JUIComponent.prototype.setPositioning=function(positioning)
{positioning=intVal(positioning);if(positioning<0||positioning>=JUI.positioning.length)return;var pos=this.positioning;this.positioning=positioning;if(this.root==null)return;if(positioning!=pos&&positioning==JUI.POSITION_ABSOLUTE){var xy=getXY(this.getRoot());this.setLocation(xy.x,xy.y);}
this.root.style.position=JUI.positioning[positioning];}
JUIComponent.prototype.getSize=function()
{if(this.root)
return getSize(this.getRoot());else
return{width:0,height:0};}
JUIComponent.prototype.setSize=function(width,height)
{var autoRepaint=this.autoRepaint;this.autoRepaint=false;this.setPreferredWidth(width);this.setPreferredHeight(height);this.autoRepaint=autoRepaint;if(autoRepaint)this.repaint();}
JUIComponent.prototype.setMinSize=function(width,height)
{this.setMinWidth(width);this.setMinHeight(height);if(this.autoRepaint)this.repaint();}
JUIComponent.prototype.setMaxSize=function(width,height)
{this.setMaxWidth(width);this.setMaxHeight(height);if(this.autoRepaint)this.repaint();}
JUIComponent.prototype.getX=function()
{return this.x;}
JUIComponent.prototype.setX=function(x)
{this.x=intVal(x);if(this.autoRepaint)this.repaint();}
JUIComponent.prototype.getY=function()
{return this.y;}
JUIComponent.prototype.setY=function(y)
{this.y=intVal(y);if(this.autoRepaint)this.repaint();}
JUIComponent.prototype.getWidth=function()
{return this.width;}
JUIComponent.prototype.setWidth=function(width)
{width=varDefault(width,"");if(width=="")return;if(new RegExp('[0-9.]+%').test(width.toString())==true)
this.width=width;else
this.width=Math.max(0,Math.min(intVal(width),this.maxWidth));if(this.autoRepaint)this.repaint();}
JUIComponent.prototype.getHeight=function()
{return this.height;}
JUIComponent.prototype.setHeight=function(height)
{height=varDefault(height,"");this.height=Math.max(0,Math.min(height,this.maxHeight));if(this.autoRepaint)this.repaint();}
JUIComponent.prototype.getPreferredWidth=function()
{return this.preferredWidth;}
JUIComponent.prototype.setPreferredWidth=function(width)
{if(this.preferredWidth==width)return;this.preferredWidth=width;this.width=Math.max(0,Math.min(width,this.maxWidth));if(this.autoRepaint)this.repaint();}
JUIComponent.prototype.getPreferredHeight=function()
{return this.preferredHeight;}
JUIComponent.prototype.setPreferredHeight=function(height)
{if(this.preferredHeight==height)return;this.preferredHeight=height;this.height=Math.max(0,Math.min(height,this.maxHeight));if(this.autoRepaint)this.repaint();}
JUIComponent.prototype.setMaxWidth=function(width)
{this.maxWidth=Math.max(0,intVal(width));if(this.width>this.maxWidth){this.width=this.maxWidth;if(this.autoRepaint)this.repaint();}}
JUIComponent.prototype.setMaxHeight=function(height)
{this.maxHeight=Math.max(0,intVal(height));if(this.height>this.maxHeight){this.height=this.maxHeight;if(this.autoRepaint)this.repaint();}}
JUIComponent.prototype.setMinWidth=function(width)
{this.minWidth=Math.max(0,intVal(width));if(this.width<this.minWidth){this.width=this.minWidth;if(this.autoRepaint)this.repaint();}}
JUIComponent.prototype.setMinHeight=function(height)
{this.minHeight=Math.max(0,intVal(height));if(this.height<this.minHeight){this.height=this.minHeight;if(this.autoRepaint)this.repaint();}}
JUIComponent.prototype.createElement=function(tagName,type,name,attributes,styles,selectable)
{if(attributes==null)attributes=new Object();if(type!=null)attributes.type=type;if(name!=null)attributes.name=name;var newElem=LD.Element.create(tagName,attributes,styles);newElem.dhtmlOwner=this.componentId;JUI.makeSelectable(newElem,selectable||null);JUIComponent.holder.appendChild(newElem);return newElem;}
JUIComponent.prototype.repaint=function()
{if(!this.root||!this.visible)return;this.root.style.left=this.x;this.root.style.top=this.y;this.root.style.width=this.width;this.root.style.height=this.height;if(this.width!=this._lastWidth||this.height!=this._lastHeight)
this.fireEvent(null,JUI.EVT_RESIZED);this._lastWidth=this.width;this._lastHeight=this.height;if(this.root.parentNode)
this.recalcDhtmlStyles();}
JUIComponent.prototype.isAutoRepaint=function()
{return this.autoRepaint;}
JUIComponent.prototype.setAutoRepaint=function(autoRepaint)
{this.autoRepaint=(autoRepaint!==false);}
JUIComponent.prototype.recalcDhtmlStyles=function()
{var owner=this,html=this.html;var st,val,wrapper,self,parentNode;var w=JUI.getWidth;var h=JUI.getHeight;for(var i=0;i<this.dhtmlStyles.length;i++){st=this.dhtmlStyles[i];self=st.node;parentNode=self.parentNode;if(!parentNode)continue;try{val=eval(st.formula);}catch(ex){}
if((wrapper=JUIComponent.dhtmlStyleWrappers[st.style])!=null){val=wrapper(val);}
st.node.style[st.style]=val;}}
JUIComponent.prototype.addDhtmlStyle=function(style,formula,htmlNode)
{htmlNode=htmlNode||this.root;if(!htmlNode||!style||!formula)
throw"JUIComponent.addDhtmlStyle: Must specify an HTML node, a style to be applied and its formula";if(htmlNode.dhtmlOwner!=this.componentId)
throw"JUIComponent.addDhtmlStyle: HTML node must belong to the same component";this.dhtmlStyles.push({node:htmlNode,style:style,formula:formula});}
JUIComponent.prototype.toString=function()
{return"{JUIComponent:"+this.componentId+" : "+(this.root?this.root.className:"")+"}";}
JUIComponent.prototype.isEnabled=function()
{return this.enabled;}
JUIComponent.prototype.setEnabled=function(enabled)
{this.enabled=(enabled==true);if(this.autoRepaint)this.repaint();}
JUIComponent.prototype.isVisible=function()
{return this.visible;}
JUIComponent.prototype.setVisible=function(visible)
{var currentlyVisible=this.visible;this.visible=(visible==true);if(this.root){this.root.style.display=(this.visible)?"":"none";if(!currentlyVisible&&visible)this.repaint();}}
JUIComponent.prototype.getToolTip=function()
{return varDefault(this.root?this.root.title:"");}
JUIComponent.prototype.setToolTip=function(toolTip)
{if(this.root)this.root.title=varDefault(toolTip,"");}
JUIComponent.prototype.isFocusable=function()
{if(this.displayable==false||this.visible==false||this.enabled==false)return false;var parent=this.getParent();if(parent&&parent instanceof JUIContainer)
return parent.isFocusable();else
return true;}
JUIComponent.prototype.requestFocus=function()
{if(!this.parent)return;if(this.parent.handleChildFocusRequest(this)==true){this.gotFocus();this.setActive(true);return true;}
else
return false;}
JUIComponent.prototype.gotFocus=function()
{}
JUIComponent.prototype.lostFocus=function()
{}
JUIComponent.prototype.isActive=function()
{return this.active;}
JUIComponent.prototype.setActive=function(active)
{this.active=(active==true);}
JUIComponent.prototype.getLayer=function()
{return(this.displayable)?this.layer:null;}
JUIComponent.prototype.setLayer=function(layer)
{this.layer=layer||null;}
JUIComponent.prototype.getZIndex=function()
{if(!this.displayable)return null;return this.zIndex;}
JUIComponent.prototype.setZIndex=function(zIndex)
{if(!this.displayable)return;this.zIndex=intVal(zIndex);if(this.root)this.root.style.zIndex=this.zIndex;}
JUIComponent.prototype.mouseDown=function(evt)
{if(Browser.isIE)evt=LD.Event.normalize(evt);if(!evt||!evt.target)return;var c=JUIComponent.getInstance(this.dhtmlOwner);if(!c)return;if(c.requestFocus()==true)
c.fireEvent(evt,JUI.EVT_MOUSE_DOWN);}
JUIComponent.prototype.mouseUp=function(evt)
{}
JUIComponent.prototype.mouseOver=function(evt)
{}
JUIComponent.prototype.mouseOut=function(evt)
{}
JUIComponent.prototype.dragGestureRecognized=function(evt,type,src)
{if(!evt||!evt.dragOp)return;document.body.style.cursor="move";if(evt.dragOp.componentStartXY==null)evt.dragOp.componentStartXY=new Object();var xy=getXY(this.root);evt.dragOp.componentStartXY.x=xy.x+document.body.scrollLeft;evt.dragOp.componentStartXY.y=xy.y+document.body.scrollTop;var draggable=this.getVisualDraggable();evt.dragOp.visualDraggable=draggable;if(draggable&&draggable.htmlNode){with(draggable.htmlNode.style){left=evt.dragOp.componentStartXY.x;top=evt.dragOp.componentStartXY.y;}
document.body.appendChild(draggable.htmlNode);if(draggable.component&&draggable.component.getRoot()==draggable.htmlNode)
JUI.DragDrop.putInDragLayer(draggable.component);else
JUI.DragDrop.putInDragLayer(draggable.htmlNode);}}
JUIComponent.prototype.getVisualDraggable=function()
{var draggable=JUI.cloneNodeHTML(this.root,true);if(Browser.isIE)
draggable.style.filter="Alpha(opacity=67)";else
draggable.style.opacity=0.67;return{"component":null,"htmlNode":draggable,"disposeOnFinish":true};}
JUIComponent.prototype.drag=function(evt,type,src)
{if(!evt||!evt.dragOp||!evt.dragOp.visualDraggable)return;var draggable=evt.dragOp.visualDraggable;var x=evt.dragOp.componentStartXY.x+evt.dragOp.deltaX;var y=evt.dragOp.componentStartXY.y+evt.dragOp.deltaY;if(draggable.component)
draggable.component.setLocation(x,y);else if(draggable.htmlNode)
with(evt.dragOp.visualDraggable.htmlNode.style){left=x;top=y;}}
JUIComponent.prototype.dragFinished=function(evt,type,src)
{if(evt.dragOp.visualDraggable&&evt.dragOp.visualDraggable.disposeOnFinish==true){var node=evt.dragOp.visualDraggable.htmlNode;node.parentNode.removeChild(node);}}
JUIComponent.prototype.putTemplate=function(templateName,insertAt,replace,extractRefs)
{if(!insertAt)insertAt=this.getRoot();if(!insertAt||insertAt.nodeType!=LD.NODE_ELEMENT)
throw"Must provide a valid HTML node to insert the content into";var content=JUI.getTemplateInstance(templateName);if(replace)
LD.Element.removeChildren(insertAt);insertAt.appendChild(content);if(extractRefs!==false){var refs=JUI.getDhtmlRefs(content);for(var k in refs){this.html[k]=refs[k];}}
var styles=JUI.getDhtmlStyles(content);for(var k in styles){this.dhtmlStyles[k]=styles[k];}
JUI.makeSelectable(content,null,true);}
JUIComponent.prototype.addHtmlListener=function(htmlNode,evtType,func)
{(function(elm,type,f,id){LD.Element.addListener(elm,type,function(evt){evt=LD.Event.normalize(evt);f.call(JUIComponent.getInstance(id),evt);});})(htmlNode,evtType,func,this.componentId);}
JUIHtmlNode.extend(JUIComponent);function JUIHtmlNode(htmlNode)
{if(!htmlNode||!htmlNode.nodeType)throw"JUIHtmlNode: must provide an HTML node to wrap";JUIHtmlNode.superConstructor.call(this);this.root=htmlNode;var wh=getSize(htmlNode);this.preferredWidth=this.width=wh.width;this.preferredHeight=this.height=wh.height;this.init();}
JUIHtmlNode.prototype.init=function()
{this.html=JUI.getDhtmlRefs(this.root);this.dhtmlStyles=JUI.getDhtmlStyles(this.root);JUI.makeSelectable(this.root,null,true);}

/*========== JUIContainer.js ==========*/

JUIContainer.extend(JUIComponent);function JUIContainer(layout)
{JUIContainer.superConstructor.call(this);this.children=new Array();this.setLayout(layout||null);}
JUIContainer.prototype.dispose=function()
{if(this.children instanceof Array){var ch;for(var i=0;i<this.children.length;i++){ch=this.children[i];if(ch instanceof JUIComponent){ch.dispose();}
else if(ch.parentNode){ch.parentNode.removeChild(ch);}}}
JUIContainer.superClass.dispose.call(this);}
JUIContainer.prototype.getChildren=function()
{return this.children;}
JUIContainer.prototype.getChild=function(index)
{return this.children[intVal(index)];}
JUIContainer.prototype.getChildIndex=function(child)
{if(!(child instanceof JUIComponent))
throw"JUIContainer.getChildIndex: Must provide a child component to look for";return arraySearch(this.children,child);}
JUIContainer.prototype.add=function(component,order,into)
{if(!component||!(component instanceof JUIComponent))
throw"JUIContainer.add: You must provide a JUIComponent object to add";var oldParent=component.getParent();var before=null;if(order!=null){order=Math.max(0,Math.min(intVal(order),this.children.length));into=this.getRoot();if(order<this.children.length)
before=this.children[order].getRoot();}
else{if(!into)
into=this.getRoot();else if(into.nodeType!=LD.NODE_ELEMENT)
throw"JUIContainer.add: component must be inserted into an HTML node";else{var owner=JUIComponent.getInstance(into.dhtmlOwner);if(owner&&owner!=this)
throw"JUIContainer.add: component must be inserted into an HTML node belonging to this component";}
order=this.children.length;}
into.insertBefore(component.getRoot(),before);var oldParent=component.getParent();component.setParent(this);if(oldParent)oldParent.remove(component);this.children=arrayInsertAt(this.children,component,order);}
JUIContainer.prototype.remove=function(component)
{if(typeof(component)=="number")
component=this.children[intVal(component)];if(!component||!(component instanceof JUIComponent))
throw"JUIContainer.remove: You must provide the JUIComponent object to remove";var newChildren=new Array(),aux=null;for(var i=0;i<this.children.length;i++){if(this.children[i]!=component)
newChildren.push(this.children[i]);}
var compRoot=component.getRoot();if(compRoot){var compRootParent=compRoot.parentNode;if(JUIComponent.getInstance(compRootParent.dhtmlOwner)==this)
this.getRoot().removeChild(compRoot);}
this.children=newChildren;}
JUIContainer.prototype.removeAll=function()
{var ch;for(var i=0;i<this.children.length;i++){ch=this.children[i];if(ch instanceof JUIComponent)
ch.dispose();else if(ch.parentNode)
ch.parentNode.removeChild(ch);}
this.children=new Array();}
JUIContainer.prototype.repaint=function()
{if(!this.root)return;JUIContainer.superClass.repaint.call(this);this.doLayout();}
JUIContainer.prototype.doLayout=function()
{if(this.layout)
this.layout.doLayout(this);}
JUIContainer.prototype.getLayout=function(component)
{return this.layout;}
JUIContainer.prototype.setLayout=function(layout)
{if(layout){layout.setClient(this);this.layout=layout;}
else
this.layout=null;}
JUIContainer.prototype.getLayoutChildren=function()
{return this.children;}
JUIContainer.prototype.handleChildFocusRequest=function(source)
{if(!this.parent)return false;if(!(source instanceof JUIComponent))
throw"JUIContainer.handleChildFocusRequest: source must be a JUIComponent";return this.parent.handleChildFocusRequest(source);}
JUIContainer.prototype.getComponentsAt=function(x,y)
{var w,h,x1,y1,x2,y2;var bounds=this.getOffsetBounds();if(x>bounds.width||y>bounds.height)return null;var componentsAt=new JUICoordIntersectionNode(this,x,y);if(this.root.scrollLeft>0)
x+=this.root.scrollLeft;if(this.root.scrollTop>0)
y+=this.root.scrollTop;var ch,chb,comp;for(var i=0;i<this.children.length;i++){ch=this.children[i];if(ch.isDisplayable()==false||ch.isVisible()==false)continue;chb=getBounds(ch.getRoot(),this.root);x1=chb.x;y1=chb.y;x2=x1+chb.width;y2=y1+chb.height;if(x>=x1&&x<=x2&&y>=y1&&y<=y2){if(ch instanceof JUIContainer){comp=ch.getComponentsAt(x-x1,y-y1);if(comp!=null)
componentsAt.push(comp);}
else
componentsAt.push(new JUICoordIntersectionNode(ch,x-x1,y-y1));}}
return componentsAt;}
JUIContainerLayer.extend(LD.Proto);JUIContainerLayer.EVT_COMPONENT_ADDED=11001;JUIContainerLayer.EVT_COMPONENT_REMOVED=11002;function JUIContainerLayer(index)
{JUIContainerLayer.superConstructor.call(this);this.index=intVal(index);this.baseZ=this.index*JUI.LAYER_DEPTH;this.children=new Array();}
JUIContainerLayer.prototype.add=function(component,zIndex)
{if(!component||!(component instanceof JUIComponent))
throw"JUIContainer.add: You must provide a JUIComponent object to add";currentLayer=component.getLayer();if(currentLayer!=null)currentLayer.remove(component);if(zIndex==null)
zIndex=this.getTopZ()%JUI.LAYER_DEPTH;else
zIndex=this.baseZ+intVal(zIndex);this.children.push(component);component.setLayer(this);component.setZIndex(this.baseZ+zIndex+1);var evt={"srcElement":this,"target":this,"component":component,"zIndex":zIndex};this.fireEvent(evt,JUIContainerLayer.EVT_COMPONENT_ADDED);}
JUIContainerLayer.prototype.remove=function(component)
{var i=arraySearch(this.children,component);if(i!=null){this.children.splice(i,1);component.setLayer(null);var evt={"layer":this,"component":component};this.fireEvent(evt,JUIContainerLayer.EVT_COMPONENT_REMOVED);}}
JUIContainerLayer.prototype.getBaseZ=function()
{return this.baseZ;}
JUIContainerLayer.prototype.getTopZ=function()
{var topZ=this.baseZ,compZ=0;for(var i=0;i<this.children.length;i++){compZ=this.children[i].getZIndex();if(compZ>topZ)topZ=compZ;}
return topZ;}
JUIContainerLayer.prototype.moveChildToTop=function(component)
{if(!(component instanceof JUIComponent))
throw"JUIContainerLayer.moveChildToTop: Component is not an instance of JUIComponent";var newStack=new Array();var isChild=false;for(var i=0;i<this.children.length;i++){if(this.children[i]!=component)
newStack.push(this.children[i]);else
isChild=true;}
if(!isChild)return false;newStack.sort(JUI.zIndexCompare);newStack.push(component);for(var i=0;i<newStack.length;i++){newStack[i].setZIndex(this.baseZ+i);}}
JUIContainerLayer.prototype.getChildrenByZ=function()
{var zOrder=clone(this.children);zOrder.sort(JUI.zIndexCompare);return zOrder;}
function JUICoordIntersectionNode(component,x,y)
{if(!(component instanceof JUIComponent))
throw"JUICoordIntersectionNode: Must provide a JUIComponent instance for node";this.component=component;this.ancestor=null;this.targetX=x;this.targetY=y;}
JUICoordIntersectionNode.prototype.getComponent=function()
{return this.component;}
JUICoordIntersectionNode.prototype.getAncestor=function()
{return this.ancestor;}
JUICoordIntersectionNode.prototype.setAncestor=function(node)
{if(node!=null&&!(node instanceof JUICoordIntersectionNode))
throw"JUICoordIntersectionNode.push: Must provide a JUICoordIntersectionNode instance";this.ancestor=node;}
JUICoordIntersectionNode.prototype.isInComponent=function(component)
{if(!(component instanceof JUIComponent))
throw"JUICoordIntersectionNode.isInComponent: Must provide a JUIComponent instance";var node=this;while(node){if(node.ancestor&&node.ancestor.component==component)return true;node=node.getAncestor();}
return false;}
JUICoordIntersectionNode.prototype.push=function(node)
{if(!(node instanceof JUICoordIntersectionNode))
throw"JUICoordIntersectionNode.push: Must provide a JUICoordIntersectionNode instance";if(!this.childrenAt)
this.childrenAt=new Array();this.childrenAt.push(node);node.setAncestor(this);}
JUICoordIntersectionNode.prototype.toSequence=function()
{var aux=new Array(),children;if(this.childrenAt){for(var i=this.childrenAt.length-1;i>=0;i--){children=this.childrenAt[i].toSequence();aux=aux.concat(children);}}
aux.push(this);return aux;}

/*========== JUIDragDrop.js ==========*/

if(!JUI)throw"JUI.DragDrop: Required library JUI not found";JUI.DD_MOUSE_DOWN=1101;JUI.DD_DRAG_STARTED=1102;JUI.DD_DRAGGED=1103;JUI.DD_DRAG_CANCELED=1104;JUI.DD_DROPPED=1105;JUI.DD_DRAG_FINISHED=1106;JUI.DD_ACTION_COPY=1201;JUI.DD_ACTION_MOVE=1202;JUI.DD_ACTION_COPY_OR_MOVE=1203;JUI.DD_ACTION_LINK=1204;JUI.DragDrop=new LD.Proto();JUI.DragDrop.init=function(root)
{if(!(root instanceof JUIContainer))
throw"JUI.DragDrop.init: Must provide a root container (JUIContainer object)";this.root=root;this.dragMoveTolerance=2;this.dragSources=new Object();this.dropTargets=new Object();this.dragRollbacks=new Object();this.dragOp=null;JUI.DocumentEventHandler.addListener(JUI.EVT_MOUSE_MOVE,this.mouseMoveFired,this);JUI.DocumentEventHandler.addListener(JUI.EVT_MOUSE_UP,this.mouseUpFired,this);JUI.DocumentEventHandler.addListener(JUI.EVT_SCROLL,this.windowScrollFired,this);}
JUI.DragDrop.putInDragLayer=function(object)
{var dragLayer=this.root.getLayer(JUI.LAYER_DRAG);if(object instanceof JUIComponent){var currentLayer=object.getLayer();if(currentLayer==null)currentLayer=this.root.getDefaultLayer();JUI.DragDrop.setDragRollback("layer",object,function(object,originalLayer){originalLayer.parent.setComponentLayer(object,originalLayer.layer);},{"parent":this.root,"layer":currentLayer});this.root.setComponentLayer(object,dragLayer);}
else if(object&&object.nodeType==LD.NODE_ELEMENT){object.style.zIndex=1+dragLayer.getTopZ();}
else
throw"JUIDragDrop.putInDragLayer: Must provide a JUIComponent or HTMLElement instance";}
JUI.DragDrop.registerDragSource=function(dragSource)
{if(!(dragSource instanceof JUIDragSource))
throw"JUIDragDrop.registerDragSource: Must provide a JUIDragSource object";var id=dragSource.component.getComponentId();this.dragSources[id]=dragSource;}
JUI.DragDrop.registerDropTarget=function(dropTarget)
{if(!(dropTarget instanceof JUIDropTarget))
throw"JUIDragDrop.registerDropTarget: Must provide a JUIDropTargetObject";var id=dropTarget.component.getComponentId();this.dropTargets[id]=dropTarget;}
JUI.DragDrop.startDrag=function(evt)
{this.dragOp.setStatus(JUI.DD_DRAG_STARTED);this.fireEvent(evt,JUI.DD_DRAG_STARTED);}
JUI.DragDrop.clearDrag=function()
{document.body.style.cursor="auto";this.dragOp=null;document.body.ondrag=null;}
JUI.DragDrop.dragMouseDown=function(evt,type,src)
{if(Browser.isIE)evt=LD.Event.normalize(evt);if(!evt.target)return;var x=evt.clientX;var y=evt.clientY;var component=JUI.getComponent(evt.target);if(!component)return;var ds=this.dragSources[component.getComponentId()];if(!ds||this.dragOp!=null)return;this.dragOp=JUIDragOperation.createInstance(evt,type,component,src);this.dragOp.setStatus(JUI.DD_MOUSE_DOWN);evt.dragOp=this.dragOp;}
JUI.DragDrop.mouseMoveFired=function(evt,type,src)
{if(!this.dragOp)return;var ds=this.dragSources[this.dragOp.component.getComponentId()];if(!ds)return;if(Browser.isIE)evt=LD.Event.normalize(evt);if(!evt.target)return;evt.dragOp=this.dragOp;this.dragOp.type=evt.type;this.dragOp.calculateDelta(evt);if(this.dragOp.status==JUI.DD_MOUSE_DOWN){if(Math.abs(this.dragOp.deltaX)>this.dragMoveTolerance||Math.abs(this.dragOp.deltaY)>this.dragMoveTolerance)
{this.startDrag(evt);this.dragOp.component.dragGestureRecognized(evt);}}
else if(this.dragOp.status==JUI.DD_DRAG_STARTED){this.dragOp.component.drag(evt,type,src);}}
JUI.DragDrop.mouseUpFired=function(evt,type,src)
{if(!this.dragOp)return;if(this.dragOp.status<JUI.DD_DRAG_STARTED)return this.clearDrag();var ds=this.dragSources[this.dragOp.component.getComponentId()];if(!ds)return;if(Browser.isIE)evt=LD.Event.normalize(evt);if(!evt.target)return this.clearDrag();ds.dragFinished({"dragOp":this.dragOp},JUI.DD_DRAG_FINISHED,ds);var x=evt.clientX,y=evt.clientY;var comps=this.root.getComponentsAt(x,y);var n=null,node=null,c=null;if(comps){var sequence=comps.toSequence();for(var i=0;i<sequence.length;i++){n=sequence[i];if(n.component!=this.dragOp.component&&!sequence[i].isInComponent(this.dragOp.component)){node=n;break;}}}
if(node!=null){var dt=this.dropTargets[node.component.getComponentId()];if(dt){this.dragOp.targetX=node.targetX;this.dragOp.targetY=node.targetY;this.dragOp.targetObject=node;evt.dragOp=this.dragOp;dt.drop(evt,this.dragOp.component);}}
this.clearDrag();}
JUI.DragDrop.windowScrollFired=function(evt,type,src)
{if(!this.dragOp)return;if(Browser.isIE)evt=LD.Event.normalize(evt);this.dragOp.calculateDelta(evt);evt.dragOp=this.dragOp;this.dragOp.component.drag(evt,type,src);}
JUI.DragDrop.setDragRollback=function(name,object,callback,value)
{if(typeof(callback)!="functon")throw"JUI.DragDrop.setDragRollback: Must provide a callback function";this.dragRollbacks[name]={"object":object,"callback":callback,"value":value||null};}
JUI.DragDrop.doDragRollback=function(name)
{if(name){if(!this.dragRollbacks[name])return false;var r=this.dragRollbacks[name];r.callback(r.object,r.value);delete this.dragRollbacks[name];}
else{for(var k in this.dragRollbacks){this.doDragRollback(this.dragRollbacks[k]);}}}
JUI.DragDrop.setParent=function(parent)
{};function JUIDragOperation()
{}
JUIDragOperation.createInstance=function(evt,type,component,src)
{if(!evt)
throw"JUIDragOperation.createInstance: Must provide a starting event for drag operation";if(!(component instanceof JUIComponent))
throw"JUIDragOperation.createInstance: Must provide JUIComponent object to be dragged";var dop=new JUIDragOperation();dop.dragStarted=false;dop.component=component;dop.type=evt.type;dop.juiType=type;dop.target=evt.target||evt.srcElement;dop.startScrollX=document.body.scrollLeft;dop.startScrollY=document.body.scrollTop;dop.x=evt.clientX+dop.startScrollX;dop.y=evt.clientY+dop.startScrollY;dop.startX=dop.x;dop.startY=dop.y;dop.targetX=(Browser.isMozilla)?evt.layerX:evt.offsetX;dop.targetY=(Browser.isMozilla)?evt.layerY:evt.offsetY;var cpRoot=component.getRoot();dop.componentStartXY={"x":null,"y":null};dop.targetOwnerX=dop.targetX;dop.targetOwnerY=dop.targetY;if(dop.target!=cpRoot){var dbg=window.debugEnabled;var targetToRootOffset=getXY(dop.target,cpRoot);window.debugEnabled=dbg;dop.targetOwnerX+=targetToRootOffset.x;dop.targetOwnerY+=targetToRootOffset.y;}
dop.deltaX=0;dop.deltaY=0;dop.status=null;dop.dropTarget=null;return dop;}
JUIDragOperation.prototype.calculateDelta=function(evt)
{evt=evt||window.event;if(!evt)return;var deltaScrollX=document.body.scrollLeft-this.startScrollX;var deltaScrollY=document.body.scrollTop-this.startScrollY;this.x=evt.clientX;this.y=evt.clientY;this.deltaX=this.x-this.startX+deltaScrollX;this.deltaY=this.y-this.startY+deltaScrollY;}
JUIDragOperation.prototype.getComponent=function()
{return this.component;}
JUIDragOperation.prototype.getTransferable=function()
{return this.component.getTransferable();}
JUIDragOperation.prototype.getStatus=function()
{return this.status;}
JUIDragOperation.prototype.setStatus=function(status)
{this.status=status;}
JUIDragSource.extend(LD.Proto);function JUIDragSource(component,listener,actions)
{JUIDragSource.superConstructor.call(this);if(!(component instanceof JUIComponent)||!instanceOf(component,JUI.Transferable))
throw"JUIDragSource: Must provide a JUIComponent object that implements the JUI.Transferable interface";if(!listener||!instanceOf(listener,JUI.DragListener))
throw"JUIDragSource: Must provide a listener that implements JUI.DragListener interface";if(!actions)actions=[JUI.DD_ACTION_COPY_OR_MOVE];this.component=component;this.listener=listener;this.actions=actions;component.addListener(JUI.EVT_MOUSE_DOWN,this.dragMouseDown,this);}
JUIDragSource.prototype.dragMouseDown=function(evt,type,src)
{JUI.DragDrop.dragMouseDown(evt,type,src);}
JUIDragSource.prototype.dragFinished=function(evt,type,src)
{this.listener.dragFinished(evt,type,src);}
JUIDropTarget.extend(LD.Proto);function JUIDropTarget(component,listener)
{JUIDropTarget.superConstructor.call(this);if(!(component instanceof JUIComponent))
throw"JUIDropTarget: Must provide a JUIComponent instance";if(!instanceOf(component,JUI.DropListener))
throw"JUIDropTarget: Must provide an object that implements DropListener interface";if(!(listener instanceof LD.Proto))
throw"JUIDropTarget: Must provide a listener implementing LD.Proto interface";this.component=component;this.listener=listener;this.addListener(JUI.DD_DROPPED,component.drop,component);}
JUIDropTarget.prototype.drop=function(evt,droppedComponent)
{this.fireEvent(evt,JUI.DD_DROPPED,droppedComponent);}
JUI.Transferable={getTransferable:function(){}}
JUI.DragListener={dragGestureRecognized:function(evt,type,src){},getVisualDraggable:function(){},drag:function(evt,type,src){},dragFinished:function(evt,type,src){}}
JUI.DropListener={drop:function(evt,type,src){}}

/*========== JUIDesktop.js ==========*/

JUIDesktop.extend(JUIContainer);function JUIDesktop()
{JUIDesktop.superConstructor.call(this);this.activeChild=null;this.layers=new Object();this.layers[JUI.LAYER_UNDERGROUND]=new JUIContainerLayer(JUI.LAYER_UNDERGROUND);this.layers[JUI.LAYER_WALLPAPER]=new JUIContainerLayer(JUI.LAYER_WALLPAPER);this.layers[JUI.LAYER_BASE]=new JUIContainerLayer(JUI.LAYER_BASE);this.layers[JUI.LAYER_DASHBOARD]=new JUIContainerLayer(JUI.LAYER_DASHBOARD);this.layers[JUI.LAYER_FLOATING]=new JUIContainerLayer(JUI.LAYER_FLOATING);this.layers[JUI.LAYER_POPUP]=new JUIContainerLayer(JUI.LAYER_POPUP);this.layers[JUI.LAYER_DRAG]=new JUIContainerLayer(JUI.LAYER_DRAG);this.layers[JUI.LAYER_GLASS]=new JUIContainerLayer(JUI.LAYER_GLASS);this.defaultLayer=this.layers[JUI.LAYER_BASE];this.width=(window.innerWidth!=null)?window.innerWidth:document.body.clientWidth;this.height=(window.innerHeight!=null)?window.innerHeight:document.body.clientHeight;this.preferredWidth=this.width;this.preferredHeight=this.height;this.popupEventCatcher=null;this.childManager=null;}
JUIDesktop.modalChildren=new Array();JUIDesktop.prototype.init=function()
{this.root=document.body;this.root.dhtmlOwner=this.componentId;var catcher=this.createElement("DIV");this.popupEventCatcher=catcher;with(catcher.style){position="absolute";left="0px";top="0px";width="100%";height="100%";backgroundColor="#666666";opacity=0.3;filter="Alpha(opacity=30)";zIndex=this.layers[JUI.LAYER_POPUP].getBaseZ();display="none";align="center";verticalAlign="middle";}
this.root.appendChild(catcher);JUI.DocumentEventHandler.addListener(JUI.EVT_MOUSE_DOWN,this.mouseDown);JUI.DocumentEventHandler.addListener(JUI.EVT_RESIZED,this.resizeToFit,this);JUI.setTopContainer(this);}
JUIDesktop.prototype.resizeToFit=function()
{var clientW=(window.innerWidth!=null)?window.innerWidth:document.body.clientWidth;var clientH=(window.innerHeight!=null)?window.innerHeight:document.body.clientHeight;this.setSize(clientW,clientH);}
JUIDesktop.prototype.add=function(component,layer)
{if(!component||!(component instanceof JUIComponent))
throw"JUIDesktop.add: Must provide a JUIComponent object to add";if(inArray(this.children,component))return;if(isNumeric(layer))layer=this.getLayer(layer);if(!(layer instanceof JUIContainerLayer)){if(component instanceof JUIWindow)
layer=this.layers[JUI.LAYER_FLOATING];else
layer=this.layers[JUI.LAYER_BASE];}
this.children.push(component);component.setParent(this);component.dhtmlOwner=this.componentId;this.root.appendChild(component.getRoot());layer.add(component);component.repaint();if(component instanceof JUIWindow){component.addListener(JUIWindow.EVT_MINIMIZED,this.childMinimized,this);component.addListener(JUIWindow.EVT_RESTORED,this.childRestored,this);component.addListener(JUIWindow.EVT_CLOSED,this.childClosed,this);}}
JUIDesktop.prototype.getLayer=function(layer)
{return this.layers[intVal(layer)];}
JUIDesktop.prototype.getDefaultLayer=function()
{return this.defaultLayer;}
JUIDesktop.prototype.getClientAreaBounds=function()
{return{x:0,y:35,width:this.width,height:this.height-35};}
JUIDesktop.prototype.childClosed=function(evt,type,src)
{if(!(src instanceof JUIComponent))
throw"JUIDesktop.childMinimized: src must be a JUIComponent object";if(inArray(this.tasks,src))return;if(this.childManager)
this.childManager.removeChild(src);}
JUIDesktop.prototype.childMinimized=function(evt,type,src)
{if(!(src instanceof JUIComponent))
throw"JUIDesktop.childMinimized: src must be a JUIComponent object";if(inArray(this.tasks,src))return;if(this.childManager)
this.childManager.addChild(src);}
JUIDesktop.prototype.childRestored=function(evt,type,src)
{if(!(src instanceof JUIComponent))
throw"JUIDesktop.childRestored: component must be a JUIComponent object";if(this.childManager)
this.childManager.removeChild(src);}
JUIDesktop.prototype.childIsFocusable=function(component)
{var focusable=true,ch=null;for(var i=0;i<this.children.length;i++){if(this.children[i]==component){ch=this.children[i];if(ch.isVisible()&&typeof(ch.isModal)=="function"&&ch.isModal())
focusable=(this.activeChild==ch);}}
return focusable;}
JUIDesktop.prototype.setComponentLayer=function(component,layer)
{if(!layer)throw"JUIDesktop.putComponentInLayer: layer "+layer+" does not exist";layer.add(component);}
JUIDesktop.prototype.mouseDown=function(evt,type,src)
{}
JUIDesktop.prototype.handleChildFocusRequest=function(source)
{if(!(source instanceof JUIComponent))
throw"JUIDesktop.handleChildFocusRequest: source must be a JUIComponent";var activate=new Object();var x=source,stack=new Array();while(x!=null){activate[x.getComponentId()]=x;stack.push(x);x=x.getParent();}
if(stack.pop()!=this)return false;var activateChild=stack.pop();if(activateChild){var layer=activateChild.getLayer();if(layer)layer.moveChildToTop(activateChild);}
var c,active;for(var k in JUIComponent.instances){c=JUIComponent.instances[k];active=(activate[k]!=null)
if(c.isActive()!=active)
c.setActive(active);}
return true;}
JUIDesktop.prototype.showPopupWindow=function(popupWindow)
{if(!(popupWindow instanceof JUIWindow))
throw"JUIDesktop.showPopupWindow: Must provide a JUIWindow object to show";this.addModalChild(popupWindow);this.layers[JUI.LAYER_POPUP].add(popupWindow);var bw=document.body.clientWidth;var bh=document.body.clientHeight;var dwh=popupWindow.getSize();popupWindow.setLocation(intVal((bw-dwh.width)/2),intVal((bh-dwh.height)/3));popupWindow.setVisible(true);var _this=this;popupWindow.addListener(JUIWindow.EVT_CLOSED,function(evt,type,src){_this.removeModalChild(src);});popupWindow.setActive(true);}
JUIDesktop.prototype.getChildManager=function()
{return this.childManager;}
JUIDesktop.prototype.setChildManager=function(childManager)
{if(!instanceOf(childManager,DesktopChildManager))
throw"childManager must implement the DesktopChildManager";this.childManager=childManager;}
JUIDesktop.prototype.addModalChild=function(child)
{if(!(child instanceof JUIComponent))
throw"Child must be a JUIComponent instance";if(!inArray(JUIDesktop.modalChildren,child.getComponentId()))
JUIDesktop.modalChildren.push(child.getComponentId());this.refreshEventCatcher();document.body.appendChild(child.getRoot());}
JUIDesktop.prototype.removeModalChild=function(child)
{if(!(child instanceof JUIComponent))
throw"Child must be a JUIComponent instance";JUIDesktop.modalChildren=arrayRemove(JUIDesktop.modalChildren,child.getComponentId());this.refreshEventCatcher();}
JUIDesktop.prototype.refreshEventCatcher=function()
{with(this.popupEventCatcher.style){width=Math.max(0,document.body.scrollWidth-2)+"px";height=Math.max(0,document.body.scrollHeight-2)+"px";display=(JUIDesktop.modalChildren.length>0)?"":"none";}}
DesktopChildManager={addChild:function(child){},getChild:function(child){},removeChild:function(child){}}

/*========== JUILayout.js ==========*/

JUI.LAYOUT_VERTICAL=0;JUI.LAYOUT_HORIZONTAL=1;JUILayout.extend(LD.Proto);function JUILayout()
{JUILayout.superConstructor.call(this);this.client=null;}
JUILayout.prototype.getClient=function()
{return this.client;}
JUILayout.prototype.setClient=function(client)
{if(client!=null&&!(client instanceof JUIContainer))
throw"JUILayout.setClient: You must provide a JUIContainer client";this.client=client;}
JUILayout.prototype.doLayout=function()
{}
JUIStackLayout.extend(JUILayout);function JUIStackLayout(orientation,gap)
{JUIStackLayout.superConstructor.call(this);this.orientation=orientation||JUI.LAYOUT_VERTICAL;if(this.orientation==JUI.LAYOUT_HORIZONTAL){this.hGap=intVal(gap);this.vGap=0;}
else{this.vGap=intVal(gap);this.hGap=0;}}
JUIStackLayout.prototype.setOrientation=function(orientation)
{this.orientation=orientation;this.doLayout();}
JUIStackLayout.prototype.doLayout=function(clientOrIndex)
{var cl=this.client;if(!cl)return false;var ch=cl.getLayoutChildren();var x=0,y=0,node,wh,clientWH,pw,ph;clientWH=cl.getSize();for(var i=0;i<ch.length;i++)
{node=ch[i].getRoot();node.style.position="absolute";ch[i].setLocation(x,y);pw=ch[i].getPreferredWidth();ph=ch[i].getPreferredHeight();var dbg=false;if(this.orientation==JUI.LAYOUT_HORIZONTAL){ch[i].setWidth(pw);ch[i].setHeight(clientWH.height-2);wh=ch[i].getSize();if(wh.width==0)dbg=true;x+=(wh.width+this.hGap);}
else{ch[i].setWidth(clientWH.width-2);ch[i].setHeight(ph);wh=ch[i].getSize();y+=(wh.height+this.vGap);}}}
JUIStackLayout.prototype.getHGap=function()
{return this.hGap;}
JUIStackLayout.prototype.setHGap=function(gap)
{this.hGap=intVal(gap);}
JUIStackLayout.prototype.getVGap=function()
{return this.vGap;}
JUIStackLayout.prototype.setVGap=function(gap)
{this.vGap=intVal(gap);}
JUIMosaicLayout.extend(JUILayout);function JUIMosaicLayout(options)
{JUIMosaicLayout.superConstructor.call(this);options=options||{};this.hGap=intVal(varDefault(options.hGap,0));this.vGap=intVal(varDefault(options.vGap,0));this.totalWidth=0;this.totalHeight=0;}
JUIMosaicLayout.prototype.doLayout=function(clientOrIndex)
{var cl=this.client;if(!cl)return false;var children=cl.getLayoutChildren(),ch=null;var x=0,y=0,chw,chh,wrap=false;var maxHeight=0,th=0;var clientWH=cl.getSize();for(var i=0;i<children.length;i++)
{ch=children[i];chw=ch.getWidth();chh=ch.getHeight();ch.setPositioning(JUI.POSITION_ABSOLUTE);if((x+chw)>clientWH.width){x=0;y+=(maxHeight+this.vGap);maxHeight=0;}
maxHeight=Math.max(maxHeight,chh);ch.setLocation(x,y);x+=(this.hGap+chw);}
this.totalWidth=cl.width;this.totalHeight=y+maxHeight;}
JUIMosaicLayout.prototype.getContentSize=function()
{return{"width":this.totalWidth,"height":this.totalHeight};}
JUIMosaicLayout.prototype.getHGap=function()
{return this.hGap;}
JUIMosaicLayout.prototype.setHGap=function(gap)
{this.hGap=intVal(gap);}
JUIMosaicLayout.prototype.getVGap=function()
{return this.vGap;}
JUIMosaicLayout.prototype.setVGap=function(gap)
{this.vGap=intVal(gap);}

/*========== JUIButton.js ==========*/

JUIButton.extend(JUIComponent);function JUIButton(caption,width,height)
{JUIButton.superConstructor.call(this);this.caption=varDefault(caption,"");this.width=varDefault(width,21);this.height=varDefault(height,21);this.preferredWidth=this.width;this.preferredHeight=this.height;}
JUIButton.prototype.init=function(htmlNode)
{JUIButton.superClass.init.call(this,htmlNode);if(!htmlNode){var root=this.root;root.className="JUIButton";root.innerHTML=this.caption;root.align="center";root.vAlign="middle";with(root.style){width=this.width;height=this.height;}}
this.addEventHandlers();}
JUIButton.prototype.addEventHandlers=function()
{var _this=this;this.root.onmousedown=function(evt){evt=evt||window.event;LD.Event.stopPropagation(evt);}
this.root.onclick=function(evt){evt=evt||window.event;if(_this.enabled)
_this.fireEvent(evt,JUI.EVT_MOUSE_CLICK);LD.Event.stopPropagation(evt);}
this.root.onselectstart=function(evt){evt=evt||window.event;LD.Event.cancel(evt,true);}}
JUIButton.prototype.setEnabled=function(enabled)
{this.enabled=(enabled==true);this.root.enabled=this.enabled;}
JUIButton.prototype.repaint=function()
{JUIButton.superClass.repaint.call(this);if(this.root)LD.Element.wrapInnerText(this.root);}
JUIImageButton.extend(JUIButton);function JUIImageButton(imgSrc,width,height)
{JUIImageButton.superConstructor.call(this);this.imgSrc=varDefault(imgSrc,nullImageSrc);this.width=varDefault(width,21);this.height=varDefault(height,21);this.root=null;}
JUIImageButton.prototype.init=function()
{var root=this.createElement("IMG");this.root=root;root.src=this.imgSrc;with(root.style){width=this.width;height=this.height;}
this.addEventHandlers();}
JUIMixedButton.extend(JUIButton);function JUIMixedButton(caption,imgUrl,imgPos,width,height)
{JUIMixedButton.superConstructor.call(this);this.caption=varDefault(caption,"");this.imgUrl=varDefault(imgUrl,"");this.imgPos=this.imgUrl!=""?intVal(imgPos):0;this.width=varDefault(width,21);this.height=varDefault(height,21);this.normalBorder="1px outset #dddddd";this.pressedBorder="1px inset #dddddd";}
JUIMixedButton.prototype.init=function()
{var root=this.createElement("DIV");this.root=root;root.className="JUIMixedButton";with(root.style){position="absolute";width=this.width;height=this.height;textAlign="center";verticalAlign="middle";overflow="hidden";}
var imgW=0,imgH=0,txtW=0,txtH=0;if(this.imgUrl!=""){var img=this.createElement("IMG");this.imageElement=img;img.src=this.imgUrl;imgW=imgH=Math.min(this.width-2,this.height-2);with(img.style){padding=0;border=0;}
img.align="absmiddle";root.appendChild(img);}
if(this.caption!=""){var txt=createText(this.caption);root.appendChild(txt);}
this.addEventHandlers();this._mouseDown=false;this._mouseOver=false;var _this=this;this.root.onmousedown=function(evt){if(Browser.isIE)evt=LD.Event.normalize(evt);if(!_this.enabled)return LD.Event.cancel(evt,true);this.style.border=_this.pressedBorder;LD.Event.stopPropagation(evt);JUI.DocumentEventHandler.addListener(JUI.EVT_MOUSE_UP,this.onmouseup,this);}
this.root.onmouseup=function(evt){JUI.DocumentEventHandler.removeListener(JUI.EVT_MOUSE_UP,this.onmouseup,this);this.style.border=_this.normalBorder;this._mouseDown=false;}
this.root.onmouseout=function(evt){this.style.border=_this.normalBorder;_this._mouseOver=false;}
this.root.onmouseover=function(evt){this._mouseDown=false;this._mouseOver=true;if(_this._mouseDown==true)
this.style.border=_this.pressedBorder;}}
JUIButtonGroup.extend(JUIContainer);function JUIButtonGroup(caption,width,height)
{this.superConstructor.call(this);}
JUIButtonGroup.add=function(button)
{}

/*========== JUIToolBar.js ==========*/

JUI.TOOLBAR_HANDLE_WIDTH=4;JUIToolBar.extend(JUIContainer);function JUIToolBar(orientation,title,floatable)
{JUIToolBar.superConstructor.call(this);this.orientation=varDefault(orientation,JUI.LAYOUT_HORIZONTAL);this.setTitle(title);this.setFloatable(floatable);this.floating=false;this.width=20;this.height=20;this.setLayout(new JUIStackLayout(this.orientation,0));}
JUIToolBar.prototype.init=function()
{var root=this.createElement("DIV");this.root=root;root.className="JUIToolBar";with(root.style){overflow="hidden";position="absolute";}
this.setPreferredWidth(this.width);this.setPreferredHeight(this.height);var w=0,h=0;if(this.floatable==true){w=(this.orientation==JUI.LAYOUT_VERTICAL)?this.width:JUI.TOOLBAR_HANDLE_WIDTH;h=(this.orientation==JUI.LAYOUT_VERTICAL)?JUI.TOOLBAR_HANDLE_WIDTH:this.height;}
var handle=new JUIComponent();handle.init=function(){var root=this.createElement("DIV");this.root=root;with(root.style){width=w;height=h;border="1px groove #a0b0ee";backgroundColor="#a0b0ee";display=this.floatable?"":"none";overflow="hidden";position="absolute";cursor="move";}};handle.init();handle.setVisible(this.floatable);handle.setPreferredWidth(w);handle.setPreferredHeight(h);this.add(handle);var titleBar=this.createElement("DIV");this.titleBar=titleBar;titleBar.appendChild(createText(this.title));this.views=[new Object(),new Object()];this.setView(0);}
JUIToolBar.prototype.repaint=function()
{JUIToolBar.superClass.repaint.call(this);var ch=this.getChildren();for(var i=0;i<ch.length;i++){if(ch[i]instanceof JUIComponent)
ch[i].setPreferredHeight(20);}}
JUIToolBar.prototype.add=function(component)
{if(!component||!(component instanceof JUIComponent))
throw"JUIDesktop.add: Must provide a JUIComponent object to add";this.children.push(component);this.getRoot().appendChild(component.getRoot());if(this.layout)this.layout.doLayout(this);}
JUIToolBar.prototype.isFloatable=function()
{return this.floatable;}
JUIToolBar.prototype.setFloatable=function(floatable)
{this.floatable=(floatable==true);}
JUIToolBar.prototype.getTitle=function()
{return this.title;}
JUIToolBar.prototype.setTitle=function(title)
{this.title=varDefault(title,"");}
JUIToolBar.prototype.setView=function(view)
{view=intVal(view);if(view>=this.views.length)
throw"JUIToolBar.setView: Index out of bounds "+view;this.setVisible(false);for(var k in this.views[view]){this[k]=this.views[view][k];}
this.setVisible(true);this.repaint();}

/*========== JUIMenu.js ==========*/

JUIMenu.extend(JUIContainer);JUIMenu.templates={base:"JUIMenu"};JUIMenu.MENU_ACTION_NONE="";JUI.EVT_MENU_ITEM_SELECTED=6001;JUI.EVT_MENU_OPEN=6002;JUI.EVT_MENU_CLOSE=6003;function JUIMenu(orientation,gap)
{JUIMenu.superConstructor.call(this);this._rowSize=20;this.orientation=intVal(varDefault(orientation,JUI.LAYOUT_VERTICAL));this.gap=intVal(gap);this.setLayout(new JUIStackLayout(this.orientation,this.gap));this.boundComponent=null;this.closeThread=null;}
JUIMenu.prototype.init=function(htmlNode)
{JUIMenu.superClass.init.call(this,htmlNode);var _this=this;with(this.root.style){height=this.height;width=this.width;overflow="hidden";}
this.root.onmouseover=function(evt){_this.clearTimedClose();}
this.root.onmouseout=function(evt){if(Browser.isIE)evt=LD.Event.normalize(evt);var x=evt.clientX;var y=evt.clientY;var b=getBounds(_this.root);if(x<b.x||x>(b.x+b.width-1)||y<b.y||y>(b.y+b.height-1))
_this.startTimedClose();}
JUI.DocumentEventHandler.addListener(JUI.EVT_MOUSE_DOWN,function(evt){if(_this.visible!=true)return;if(Browser.isIE)evt=LD.Event.normalize(evt);var x=evt.clientX;var y=evt.clientY;var b=getBounds(_this.root);if(x<b.x||x>(b.x+b.width-1)||y<b.y||y>(b.y+b.height-1))
_this.close();});}
JUIMenu.prototype.add=function(component,order)
{if(!(component instanceof JUIMenuItem))
throw"JUIMenu.add: Must provide an instance of JUIMenuItem";JUIMenu.superClass.add.call(this,component,order,this.html.middle);component.setParent(this);component.setSize(this.width-4,this._rowSize);component.setLocation(0,(this.children.length-1)*this._rowSize);component.setVisible(true);this.repaint();}
JUIMenu.prototype.remove=function(component)
{if(!(component instanceof JUIMenuItem))
throw"JUIMenu.add: Must provide an instance of JUIMenuItem";JUIMenu.superClass.remove.call(this,component);this.repaint();}
JUIMenu.prototype.repaint=function()
{var autoRepaint=this.autoRepaint;this.autoRepaint=false;var ch=this.children.length*this._rowSize;var h=this.html.top.offsetHeight+this.html.bottom.offsetHeight+ch;this.setPreferredHeight(h);this.autoRepaint=autoRepaint;JUIMenu.superClass.repaint.call(this);}
JUIMenu.prototype.setEnabledItems=function(enabledItems)
{if(enabledItems===true||enabledItems===false)
for(var i=0;i<this.children.length;i++){this.children[i].setEnabled(enabledItems);}
else
for(var i=0;i<this.children.length;i++){if(typeof(enabledItems[i])!=undefined)
this.children[i].setEnabled(enabledItems[i]==true);}}
JUIMenu.prototype.setBoundComponent=function(component)
{this.boundComponent=component||null;}
JUIMenu.prototype.getBoundComponent=function()
{return this.boundComponent;}
JUIMenu.prototype.itemSelected=function(item)
{var evt={"selected":item.isSelected(),"action":varDefault(item.getActionId()),"boundComponent":this.boundComponent};this.close();this.fireEvent(evt,JUI.EVT_MENU_ITEM_SELECTED);}
JUIMenu.prototype.setVisible=function(visible)
{JUIMenu.superClass.setVisible.call(this,visible);if(this.isVisible()){this.clearTimedClose();this.startTimedClose(2000);}
if(visible){this.fireEvent(this,JUI.EVT_MENU_OPEN);}else{this.fireEvent(this,JUI.EVT_MENU_CLOSE);}}
JUIMenu.prototype.close=function()
{this.clearTimedClose();this.setBoundComponent(null);this.setVisible(false);}
JUIMenu.prototype.startTimedClose=function(milliseconds)
{if(this.closeThread==null){var _this=this;this.closeThread=setTimeout(function(){_this.close();},varDefault(milliseconds,2000));}}
JUIMenu.prototype.clearTimedClose=function()
{if(this.closeThread!=null){clearTimeout(this.closeThread);this.closeThread=null;}}
JUIMenuItem.extend(JUIComponent);JUIMenuItem.TYPE_NORMAL=0;JUIMenuItem.TYPE_RADIO=1;JUIMenuItem.TYPE_CHECKBOX=2;function JUIMenuItem(caption,actionId,type)
{JUIMenuItem.superConstructor.call(this);this.caption=varDefault(caption,"");this.type=intVal(varDefault(type,JUIMenuItem.TYPE_NORMAL));this.select=null;this.selected=false;this.itemGroup=null;this.setActionId(varDefault(actionId,JUI.MENU_ACTION_NONE));this.init();}
JUIMenuItem.prototype.init=function()
{var _this=this;var root=this.createElement("DIV");this.root=root;root.className="JUIMenuItem";with(root.style){position="absolute";width="100%";align="left";verticalAlign="middle";overflow="hidden";padding=0;}
var selectBox=this.createElement("DIV");this.selectBox=selectBox;with(selectBox.style){position="absolute";top=0;left=0;width=18;overflow="hidden";align="left";verticalAlign="middle";}
var select=null;if(this.type==JUIMenuItem.TYPE_RADIO){select=this.createElement("INPUT","radio");select.onclick=function(evt){LD.Event.stopPropagation(evt);if(_this.enabled){_this.setSelected(true);if(_this.parent)
_this.parent.itemSelected(_this);}}}
else if(this.type==JUIMenuItem.TYPE_CHECKBOX){select=this.createElement("INPUT","checkbox");select.onclick=function(evt){LD.Event.stopPropagation(evt);if(_this.enabled)
_this.setSelected(!_this.selected);if(_this.parent)
_this.parent.itemSelected(_this);}}
root.onclick=function(evt){if(_this.enabled!=true){LD.Event.cancel(evt,true);return;}
if(_this.select!=null)
_this.select.onclick(evt);else{_this.setSelected(true);if(_this.parent)
_this.parent.itemSelected(_this);}}
root.ondblclick=function(evt){LD.Event.cancel(evt,true);}
root.onmouseover=function(evt){if(_this.enabled)
_this.root.className="JUIMenuItem JUIMenuItem_over";else
_this.root.className="JUIMenuItem JUIMenuItem_disabled JUIMenuItem_over";}
root.onmouseout=function(evt){if(_this.enabled)
_this.root.className="JUIMenuItem";else
_this.root.className="JUIMenuItem JUIMenuItem_disabled";}
if(select!=null){select.ondblclick=function(evt){LD.Event.cancel(evt,true);}
selectBox.appendChild(select);}
this.select=select;root.appendChild(selectBox);var captionBox=this.createElement("DIV");this.captionBox=captionBox;with(captionBox.style){position="absolute";top=0;left=20;padding=3;width="95%";overflow="hidden";align="left";verticalAlign="middle";}
captionBox.appendChild(createText(this.caption));root.appendChild(captionBox);}
JUIMenuItem.prototype.isSelected=function()
{return this.selected;}
JUIMenuItem.prototype.setSelected=function(selected,noGroupRecurse)
{if(noGroupRecurse!=true&&selected==true&&this.itemGroup!=null)
this.itemGroup.setSelectedItem(this);else{this.selected=(selected==true);if(this.select!=null)
this.select.checked=this.selected;}}
JUIMenuItem.prototype.getItemGroup=function()
{return this.itemGroup;}
JUIMenuItem.prototype.setItemGroup=function(itemGroup)
{this.itemGroup=itemGroup;}
JUIMenuItem.prototype.setActionId=function(actionId)
{this.actionId=actionId;}
JUIMenuItem.prototype.getActionId=function()
{return this.actionId;}
JUIMenuItem.prototype.repaint=function()
{JUIMenuItem.superClass.repaint.call(this);if(this.enabled){this.root.className="JUIMenuItem";if(this.select)
this.select.disabled=false;}
else{this.root.className="JUIMenuItem JUIMenuItem_disabled";if(this.select)
this.select.disabled=true;}}
function JUIMenuItemGroup()
{this.children=new Array();}
JUIMenuItemGroup.prototype.add=function(item)
{if(inArray(this.children,item))return;this.children.push(item);item.setItemGroup(this);}
JUIMenuItemGroup.prototype.setSelectedItem=function(item)
{if(!inArray(this.children,item))return;var ch;for(var i=0;i<this.children.length;i++){ch=this.children[i];ch.setSelected(ch==item,true);}}

/*========== JUIControlPanel.js ==========*/

JUIControlPanel.extend(JUIContainer);function JUIControlPanel()
{JUIControlPanel.superConstructor.call(this);this.width="100%";this.height="100%";}
JUIControlPanel.prototype.init=function(htmlNode)
{if(htmlNode&&htmlNode.nodeType==LD.NODE_ELEMENT){var root=htmlNode;this.root=root;}
else{var root=this.createElement("DIV");this.root=root;root.className="JUIControlPanel";with(root.style){position="absolute";left="0px";top="0px";height=this.height;width=this.width;overflowX="hidden";overflowY="auto";}}
this.setMouseEventHandlers();}
JUIControlPanel.prototype.add=function(component)
{if(!component)
throw"JUIControlPanel.add: Must provide a component to add";if(component.nodeType==LD.NODE_ELEMENT){this.children.push(component);this.getRoot().appendChild(component);}
else if(typeof(component.constructor)=="function"){this.children.push(component);this.getRoot().appendChild(component.getRoot());component.setParent(this);}
if(this.layout)this.layout.doLayout();}
JUIControlPanel.prototype.itemSelected=function(item)
{var evt={"action":varDefault(item.getActionId()),"boundComponent":this.boundComponent};this.fireEvent(evt,JUI.EVT_MENU_ITEM_SELECTED);}
JUIControlPanelItem.extend(JUIComponent);function JUIControlPanelItem(caption,actionId)
{JUIControlPanelItem.superConstructor.call(this);this.caption=varDefault(caption,"");this.setActionId(varDefault(actionId,JUI.MENU_ACTION_NONE));this.init();}
JUIControlPanelItem.prototype.init=function()
{var _this=this;var root=this.createElement("DIV");this.root=root;root.className="JUIControlPanelItem";var link=this.createElement("A");this.link=link;link.href="javascript:;";link.className="JUIControlPanelItem";link.appendChild(createText(this.caption));root.appendChild(link);link.onclick=function(evt){if(_this.parent)
_this.parent.itemSelected(_this);}}
JUIControlPanelItem.prototype.setActionId=function(actionId)
{this.actionId=actionId;}
JUIControlPanelItem.prototype.getActionId=function()
{return this.actionId;}
JUIControlPanelItem.prototype.repaint=function()
{JUIControlPanelItem.superClass.repaint.call(this);if(this.enabled){this.root.className="";if(this.select)
this.select.disabled=false;}
else{this.link.className="disabled";if(this.select)
this.select.disabled=true;}}

/*========== JUIList.js ==========*/

JUIList.extend(JUIContainer);JUIList.EVT_ITEM_SELECTED=1001;JUIList.EVT_ITEM_EXPANDED=1002;JUIList.EVT_ITEM_COLLAPSED=1003;function JUIList(source,width,lineHeight,lineCount)
{JUIList.superConstructor.call(this);this.setSource(source);this.lineHeight=intVal(varDefault(lineHeight,20));this.lineCount=intVal(varDefault(lineCount,10));this.width=intVal(varDefault(width,200));this.height=this.lineHeight*this.lineCount;this.preferredWidth=this.width;this.preferredHeight=this.height;this.absolute=true;this.items=new Array();this.selectedItem=null;}
JUIList.prototype.init=function(htmlNode)
{JUIList.superClass.init.call(this,htmlNode);var _this=this;if(!htmlNode){this.root.className="JUIList";with(this.root.style){width=this.width;height=this.height;}}
with(this.root.style){overflowX="hidden";overflowY="auto";}
this.populate();}
JUIList.prototype.getSource=function()
{return this.source;}
JUIList.prototype.setSource=function(source)
{this.source=source||new Array();if(this.root)
this.populate();}
JUIList.prototype.populate=function()
{if(!this.root||!this.source)return;var stack=new Array();var currLength=this.items?this.items.length:0;var lastId=this._populateStack(stack,this.source,null,1,true);var newLength=stack.length;var item,existing=Math.min(currLength,newLength);for(var i=0;i<existing;i++){item=this.items[i];item.setModel(stack[i]);}
for(var i=existing;i<currLength;i++){item=this.items[i];item.dispose();this.removeChild(item.getRoot());}
for(var i=existing;i<newLength;i++){item=new JUIListItem(stack[i],this.lineHeight,this.width)
this.add(item);this.items.push(item);}
this.repaint();}
JUIList.prototype._populateStack=function(stack,nodes,parent,lastId,defaultExpanded)
{defaultExpanded=(defaultExpanded==true);var node;for(var i=0;i<nodes.length;i++){node=nodes[i];node.id=++lastId
if(parent){node.parent=parent;node.level=parent.level+1;node.visible=(parent.visible&&parent.expanded);if(typeof(node.expanded)=="undefined")node.expanded=defaultExpanded;}
else{node.parent=null;node.level=0;node.visible=true;node.expanded=true;}
stack.push(node);if(node.children)
lastId=this._populateStack(stack,node.children,node,lastId);}
return lastId;}
JUIList.prototype.getItem=function(index)
{return this.items[intVal(index)]||null;}
JUIList.prototype.dispose=function()
{for(var i=0;i<this.items.length;i++){this.items[i].dispose();}
JUIList.superClass.dispose.call(this);}
JUIList.prototype.repaint=function()
{JUIList.superClass.repaint.call(this);var item,model;for(var i=0;i<this.items.length;i++){item=this.items[i];model=item.getModel();item.setVisible(model.visible);item.setExpanded(model.expanded);item.setPreferredWidth(this.width-2);}}
JUIList.prototype.getSelectedItem=function()
{return this.selectedItem;}
JUIList.prototype.getValue=function()
{if(this.selectedItem)
return this.selectedItem.model.value;else
return null;}
JUIList.prototype.setValue=function(value)
{var item;for(var i=0;i<this.items.length;i++){item=this.items[i];if(item.model.value==value){this.selectedItem=this.items[i];var evt={item:item,value:item.model.value};this.fireEvent(evt,JUIList.EVT_ITEM_SELECTED);}}}
JUIList.prototype.itemSelected=function(item)
{if(!item)return;var model=item.model;var evt={item:item,value:model.value};this.fireEvent(evt,JUIList.EVT_ITEM_SELECTED);}
JUIList.prototype.itemExpanded=function(item)
{this.populate();}
JUIListItem.extend(JUIComponent);function JUIListItem(model,height,width)
{JUIListItem.superConstructor.call(this);this.parent=null;this.setModel(model);this.absolute=false;this.width=varDefault(width,"98%");this.height=varDefault(intVal(height),16);this.preferredWidth=this.width;this.preferredHeight=this.height;this.expandable=true;this.collapsable=true;this.imgExpanded="";this.imgCollapsed="";this.subitems=new Array();this.init();}
JUIListItem.prototype.init=function()
{JUIListItem.superClass.init.call(this);var _this=this;this.root.className="JUIListItem";var padX,imgOpen,imgClosed,img,imgW,itemCaption;if(this.model){img=this.model.image||"";padX=this.model.level*16;if(img instanceof Array){this.imgCollapsed=img[0]||"";this.imgExpanded=img[1]||"";}
else
this.imgCollapsed=this.imgExpanded=(img||"");itemCaption=this.model.caption||"";}
else{padX=0;this.imgCollapsed="";this.imgExpanded="";itemCaption="";}
imgW=this.imgCollapsed!=""?this.height:0;with(this.root.style){width="98%";height=this.height;paddingLeft=padX;overflow="hidden";position=this.absolute?"absolute":"static";display="";}
var image=this.createElement("IMG");this.image=image;image.className="JUIListItemImage";image.src=this.imgCollapsed;with(image.style){padding=0;border="none";display=(this.imgCollapsed!="")?"":"none";}
this.root.appendChild(image);var caption=this.createElement("DIV");this.caption=caption;caption.className="JUIListItemCaption";var capX=padX+imgW+1;with(caption.style){top=-this.height+5;left=imgW+2;height=this.height-4;position="relative";}
caption.appendChild(createText(itemCaption));this.root.appendChild(caption);image.onclick=function(evt)
{_this.setExpanded(!_this.isExpanded());LD.Event.stopPropagation(evt||window.event);if(_this.parent)_this.parent.itemExpanded(_this);}
caption.onclick=function()
{if(_this.parent)_this.parent.itemSelected(_this);}}
JUIListItem.prototype.getParentItem=function()
{return this.parentItem;}
JUIListItem.prototype.setParentItem=function(parentItem)
{if(parentItem!=null&&!(parentItem instanceof JUIListItem))
throw"JUIListItem.setParentItem: parentItem must be an instance of JUIListItem";this.parentItem=parentItem;}
JUIListItem.prototype.getModel=function()
{return this.model;}
JUIListItem.prototype.setModel=function(model)
{this.model=model;if(this.root)this.repaint();}
JUIListItem.prototype.getValue=function()
{if(this.model)
return this.model.value||null;else
return null;}
JUIListItem.prototype.repaint=function()
{var exp=this.isExpanded();var src=(exp?this.imgExpanded:this.imgCollapsed)||this.imgCollapsed||"";if(this.image.src!=src)
this.image.src=src;JUIListItem.superClass.repaint.call(this);}
JUIListItem.prototype.isExpanded=function()
{return this.model?this.model.expanded:false;}
JUIListItem.prototype.setExpanded=function(expanded)
{if(this.expandable==false){expanded=false;}
else if(this.collapsable==false){expanded=true;}
else
expanded=(expanded==true);if(this.model)
this.model.expanded=expanded;}
JUIListItem.prototype.isExpandable=function()
{return this.expandable;}
JUIListItem.prototype.setExpandable=function(expandable)
{this.expandable=(expandable!==false);}
JUIListItem.prototype.isCollapsable=function()
{return this.collapsable;}
JUIListItem.prototype.setCollapsable=function(collapsable)
{this.collapsable=(collapsable!==false);}
JUIListItem.prototype.addSubitem=function(subitem)
{if(!(subitem instanceof JUIListItem))
throw"JUIListItem.addSubitem: subitem must be an instance of JUIListItem";this.subitems.push(subitem);}
JUIListItem.prototype.removeSubitem=function(subitem)
{if(typeof(subitem)=="number")
subitem=this.subitems[subitem];if(!(subitem instanceof JUIListItem))
throw"JUIListItem.addSubitem: subitem must be an instance of JUIListItem";this.subitems=arrayRemove(this.subitems,subitem);}

/*========== JUITreeCombo.js ==========*/

JUITreeCombo.extend(JUIComponent);function JUITreeCombo(source,width,listContainer,listLayer)
{JUITreeCombo.superConstructor.call(this);this.list=null;this.setSource(source);this.width=varDefault(intVal(width),200);this.listContainer=listContainer||null;this.listLayer=intVal(varDefault(listLayer,JUI.LAYER_POPUP));this.listHeight=200;this.value=null;}
JUITreeCombo.prototype.init=function(htmlNode)
{JUITreeCombo.superClass.init.call(this,htmlNode);var _this=this;with(this.root.style){border="1px solid #cccccc";padding="0px";margin="0px";overflow="hidden";}
var inputBox=this.createElement("INPUT","text");this.inputBox=inputBox;inputBox.readOnly=true;with(inputBox.style){position="relative";top=-4;left=0;width=Math.max(0,this.width-20);height=18;border="none";margin="0px";padding="0px 2px 0px 2px";}
this.root.appendChild(inputBox);this.addDhtmlStyle("width","this.width-20",inputBox);inputBox.onfocus=function(){_this.setDropDownVisible(false);}
var dropButton=this.createElement("IMG");this.dropButton=dropButton;dropButton.src=getImageURL("/skins/"+JUI.getCurrentSkin()+"/drop_button.gif");with(dropButton.style){position="relative";left=Math.max(0,this.width-32);top=0;width=18;height=18;}
this.root.appendChild(dropButton);dropButton.onmousedown=function(evt){_this.setDropDownVisible(!_this.isDropDownVisible());LD.Event.cancel(evt||window.event);}
var list=new JUIList(this.source,this.width);this.list=list;list.setPositioning(JUI.POSITION_ABSOLUTE);list.init();list.setSize(this.width,this.listHeight);list.setVisible(false);this.populate();this.listContainer.add(list,this.listLayer);var xy=getXY(this.root);list.addListener(JUIList.EVT_ITEM_SELECTED,this.itemSelected,this);JUI.DocumentEventHandler.addListener(JUI.EVT_MOUSE_DOWN,function(evt){if(!_this.list.isVisible())return;if(Browser.isIE)evt=LD.Event.normalize();if(evt.target.dhtmlOwner==_this.componentId)return;var x=evt.clientX;var y=evt.clientY;var b=getBounds(_this.list.getRoot());if(x<b.x||x>(b.x+b.width-1)||y<b.y||y>(b.y+b.height-1))
_this.list.setVisible(false);});}
JUITreeCombo.prototype.getSource=function()
{return this.source;}
JUITreeCombo.prototype.setSource=function(source)
{this.source=source;if(this.list){this.list.setSource(this.source);}}
JUITreeCombo.prototype.populate=function()
{if(this.list)this.list.populate();}
JUITreeCombo.prototype.dispose=function()
{if(this.list)this.list.dispose();JUITreeCombo.superClass.dispose.call(this);}
JUITreeCombo.prototype.isDropDownVisible=function()
{return this.list.isVisible();}
JUITreeCombo.prototype.setDropDownVisible=function(visible)
{visible=(visible==true);if(visible){var bounds=getBounds(this.root);this.list.setBounds(bounds.x,bounds.y+this.inputBox.offsetHeight+1,this.width,this.listHeight);}
this.list.setVisible(visible);}
JUITreeCombo.prototype.itemSelected=function(evt,type,src)
{this.inputBox.value=evt.value;this.value=evt.value;this.setDropDownVisible(false);}
JUITreeCombo.prototype.itemExpanded=function()
{}
JUITreeCombo.prototype.getValue=function()
{return this.value;}
JUITreeCombo.prototype.setValue=function(value)
{return this.list.setValue(value);}

/*========== JUISlidePane.js ==========*/

JUISlidePane.extend(JUIContainer);JUISlidePane.templates={base:"JUISlidePane"};function JUISlidePane(behaviour)
{JUISlidePane.superConstructor.call(this);this.horizontalStep=32;this.verticalStep=32;this.xScrollerWidth=12;this.yScrollerHeight=12;this.handleRepeatTime=150;this.scrollX=0;this.scrollY=0;this.behaviour=behaviour||{};this.scrolling=intVal(this.getBehaviour("scrolling"));this.overlapping=(this.getBehaviour("overlapping")==true);this.scrollers={};this.scrollers.bgColor="white";this.scrollThreadId=null;}
JUISlidePane.prototype.init=function(htmlNode)
{JUISlidePane.superClass.init.call(this,htmlNode);var _this=this;var root=this.root;this.html.scrollerUp.onclick=function(){_this.scrollBy(0,-_this.getVerticalStep());}
this.html.scrollerUp.onmouseover=function(){if(_this.scrollThreadId)clearInterval(_this.scrollThreadId);_this.scrollThreadId=setInterval(function(){_this.scrollBy(0,-_this.getVerticalStep());},_this.handleRepeatTime);}
this.html.scrollerUp.onmouseout=function(){if(_this.scrollThreadId)clearInterval(_this.scrollThreadId);_this.scrollThreadId=null;}
this.html.scrollerDown.onclick=function(){_this.scrollBy(0,_this.getVerticalStep());}
this.html.scrollerDown.onmouseover=function(){if(_this.scrollThreadId)clearInterval(_this.scrollThreadId);_this.scrollThreadId=setInterval(function(){_this.scrollBy(0,_this.getVerticalStep());},_this.handleRepeatTime);}
this.html.scrollerDown.onmouseout=function(){if(_this.scrollThreadId)clearInterval(_this.scrollThreadId);_this.scrollThreadId=null;}
this.html.scrollerLeft.onclick=function(){_this.scrollBy(-_this.getHorizontalStep(),0);}
this.html.scrollerLeft.onmouseover=function(){if(_this.scrollThreadId)clearInterval(_this.scrollThreadId);_this.scrollThreadId=setInterval(function(){_this.scrollBy(-_this.getHorizontalStep(),0);},_this.handleRepeatTime);}
this.html.scrollerLeft.onmouseout=function(){if(_this.scrollThreadId)clearInterval(_this.scrollThreadId);_this.scrollThreadId=null;}
this.html.scrollerRight.onclick=function(){_this.scrollBy(_this.getHorizontalStep(),0);}
this.html.scrollerRight.onmouseover=function(){if(_this.scrollThreadId)clearInterval(_this.scrollThreadId);_this.scrollThreadId=setInterval(function(){_this.scrollBy(_this.horizontalStep,0);},_this.handleRepeatTime);}
this.html.scrollerRight.onmouseout=function(){if(_this.scrollThreadId)clearInterval(_this.scrollThreadId);_this.scrollThreadId=null;}
this.repaint();}
JUISlidePane.prototype.getBehaviour=function(name)
{return this.behaviour[name]||null;}
JUISlidePane.prototype.setBehaviour=function(name,value)
{this.behaviour[name]=value;}
JUISlidePane.prototype.scrollBy=function(x,y)
{if(x==0&&y==0)return;this.scrollX=Math.max(0,Math.min(this.html.contentFrame.scrollWidth,this.scrollX+intVal(x)));this.scrollY=Math.max(0,Math.min(this.html.contentFrame.scrollHeight,this.scrollY+intVal(y)));this.hasScrolled();}
JUISlidePane.prototype.scrollTo=function(x,y)
{if(x==this.scrollX&&y==this.scrollY)return;this.scrollX=Math.min(this.html.contentFrame.scrollWidth,x);this.scrollY=Math.min(this.html.contentFrame.scrollHeight,y);this.hasScrolled();}
JUISlidePane.prototype.hasScrolled=function()
{var evt={x:this.scrollX,y:this.scrollY};this.repaint();this.fireEvent(evt,JUI.EVT_SCROLL);}
JUISlidePane.prototype.getHorizontalStep=function()
{return this.horizontalStep;}
JUISlidePane.prototype.setHorizontalStep=function(step)
{this.horizontalStep=intVal(step);}
JUISlidePane.prototype.getVerticalStep=function()
{return this.verticalStep;}
JUISlidePane.prototype.setVerticalStep=function(step)
{this.verticalStep=intVal(step);}
JUISlidePane.prototype.add=function(component)
{component.setPositioning(JUI.POSITION_ABSOLUTE);JUISlidePane.superClass.add.call(this,component,null,this.html.contentFrame);this.repaint();}
JUISlidePane.prototype.repaint=function()
{if(!this.root)return;JUISlidePane.superClass.repaint.call(this);this.html.contentFrame.scrollLeft=this.scrollX;this.html.contentFrame.scrollTop=this.scrollY;var maxX=this.html.contentFrame.scrollWidth;var maxY=this.html.contentFrame.scrollHeight;if(this.scrolling&JUI.SCROLL_VERTICAL){this.html.scrollerUp.style.height=this.html.scrollerDown.style.height=this.yScrollerHeight+"px";this.html.scrollerDown.style.top=this.height-this.yScrollerHeight;if(this.overlapping==true){this.html.scrollerUp.style.display=(this.scrollY>0)?"":"none";this.html.scrollerDown.style.display=(this.scrollY<(maxY-this.height))?"":"none";}
else
this.html.scrollerUp.style.display=this.html.scrollerDown.style.display="";}
else
this.html.scrollerUp.style.display=this.html.scrollerDown.style.display="none";if(this.scrolling&JUI.SCROLL_HORIZONTAL){this.html.scrollerLeft.style.width=this.html.scrollerRight.style.width=this.xScrollerWidth+"px";this.html.scrollerRight.style.left=this.width-this.xScrollerWidth;if(this.overlapping==true){this.html.scrollerLeft.style.display=(this.scrollX>0)?"":"none";this.html.scrollerRight.style.display=(this.scrollX<(maxX-this.width))?"":"none";}
else
this.html.scrollerLeft.style.display=this.html.scrollerRight.style.display="";}
else
this.html.scrollerLeft.style.display=this.html.scrollerRight.style.display="none";}
JUISlidePane.prototype.setScrollersSize=function(xWidth,yHeight)
{this.xScrollerWidth=intVal(xWidth);this.yScrollerHeight=intVal(yHeight);this.repaint();}
JUISlidePane.prototype.setXScrollersWidth=function(width)
{this.xScrollerWidth=intVal(width);this.repaint();}
JUISlidePane.prototype.setYScrollersHeight=function(height)
{this.yScrollerHeight=intVal(height);this.repaint();}
JUISlidePane.prototype.setScrollersBackgroundImages=function(up,down,left,right)
{if(up)this.html.scrollerUp.style.backgroundImage="url("+up+")";if(down)this.html.scrollerDown.style.backgroundImage="url("+down+")";if(left)this.html.scrollerLeft.style.backgroundImage="url("+left+")";if(right)this.html.scrollerRight.style.backgroundImage="url("+right+")";}
JUISlidePane.prototype.setScrollersBackgroundColor=function(color)
{this.html.scrollerUp.style.backgroundColor=color;this.html.scrollerDown.style.backgroundColor=color;this.html.scrollerLeft.style.backgroundColor=color;this.html.scrollerRight.style.backgroundColor=color;}
JUISlidePane.prototype.setScrollersBorder=function(border)
{this.html.scrollerUp.style.border=border;this.html.scrollerDown.style.border=border;this.html.scrollerLeft.style.border=border;this.html.scrollerRight.style.border=border;}
JUISlidePane.prototype.getScroll=function()
{return{x:this.scrollX,y:this.scrollY};}

/*========== JUITextBox.js ==========*/

JUITextBox.extend(JUIComponent);JUITextBox.EVT_VALUE_CHANGED=2001;JUITextBox.EVT_EDIT_FINISHED=2002;function JUITextBox()
{JUITextBox.superConstructor.call(this);this.root=null;this.originalValue=null;this.inlineEditing=null;this.onDesktopClickEvent=null;}
JUITextBox.prototype.init=function()
{var _this=this;var root=this.createElement("INPUT");this.root=root;root.className="JUITextBox";this.setPositioning(this.positioning);root.onblur=function(evt){_this.editFinished();}
root.onkeypress=function(evt){evt=evt||window.event;var keyCode=evt.keyCode;if(keyCode==13){LD.Event.cancel(evt);_this.editFinished();}
else if(keyCode==27){_this.root.value=_this.originalValue;LD.Event.cancel(evt);_this.editFinished();}}}
JUITextBox.prototype.getValue=function()
{return varDefault(this.root.value,"");}
JUITextBox.prototype.setValue=function(value)
{this.root.value=varDefault(value,"");this.originalValue=this.root.value;}
JUITextBox.prototype.getText=function()
{return this.getValue();}
JUITextBox.prototype.editElementContent=function(element,bounds,minWidth,maxHeight)
{if(!element||element.nodeType!=LD.NODE_ELEMENT)
throw"JUITextBox.editElementContent: element must be an HTML element";if(Browser.isIE){this.onDesktopClickEvent=JUI.DocumentEventHandler.addListener(JUI.EVT_MOUSE_DOWN,function(evt,type,src){this.root.blur();},this)}
if(!bounds)bounds=getBounds(element);this.root.position="absolute";var w=Math.max(intVal(minWidth),bounds.width);var h=20;var dX=intVal((bounds.width-w)/2);var dY=intVal((bounds.height-h)/2);if(element.style.visibility==''){element.style.visibility='visible';}
element._visibility=element.style.visibility;element.style.visibility="hidden";this.setBounds(bounds.x+dX,bounds.y+dY,w,20);this.originalValue=this.value;var val=(element.textContent===undefined?element.innerText:element.textContent).trim();this.setValue(val);this.inlineEditing=element;this.setVisible(true);this.root.focus();if(Browser.isIE){this.root.select();}
else{var range=document.createRange();range.selectNodeContents(this.root);}}
JUITextBox.prototype.clearInlineEdition=function()
{if(!this.root||this.inlineEditing==null)return;this.inlineEditing.style.visibility=this.inlineEditing._visibility;if(this.inlineEditing&&this.inlineEditing._visibility!=null){this.inlineEditing.style.visibility=this.inlineEditing._visibility;this.inlineEditing._visibility=null;}
this.inlineEditing=null;this.root.blur();this.setVisible(false);}
JUITextBox.prototype.editFinished=function()
{if(!this.root)return;if(Browser.isIE){JUI.DocumentEventHandler.removeListener(JUI.EVT_MOUSE_DOWN,this);}
var evt={value:this.root.value,originalValue:this.originalValue};if(this.inlineEditing!=null)this.clearInlineEdition();if(this.root.value!=this.originalValue)
this.fireEvent(evt,JUITextBox.EVT_VALUE_CHANGED);this.fireEvent(evt,JUITextBox.EVT_EDIT_FINISHED);this.root.blur();}
JUITextBox.prototype.setMaxLength=function(maxLen)
{this.root.maxLength=Math.max(0,intVal(maxLen))||"";}

/*========== JUIImageList.js ==========*/

JUIImageList.extend(JUIContainer);JUIImageList.templates={base:"JUIImageList"};function JUIImageList(user,target,friends,anonymousCount)
{JUIImageList.superConstructor.call(this);this.entries=new Array();this.selectedValue=null;this.currentThumbnail=null;}
JUIImageList.prototype.init=function(htmlNode)
{JUIImageList.superClass.init.call(this,htmlNode);var _this=this;if(!htmlNode){this.root.className="JUIImageList";with(this.root.style){width=this.width;height=this.height;}}
this.html.imagePreloader.style.position="relative";this.html.list.onchange=function(evt){var e=_this.getSelectedEntry();if(e&&e.value!=this.selectedValue)
_this.setPreview(e.thumbnail);}}
JUIImageList.prototype.getValue=function()
{var e=this.entries[this.html.list.selectedIndex]||null;if(e!=null)e=e.value;return e;}
JUIImageList.prototype.getSelectedEntry=function()
{return this.entries[this.html.list.selectedIndex]||null;}
JUIImageList.prototype.getEntry=function(value)
{return arraySearch(this.entries,value,"value");}
JUIImageList.prototype.addEntry=function(value,caption,url,thumbnailUrl)
{var entry={value:value,caption:caption||value||"",url:url||"",thumbnailUrl:thumbnailUrl||"",thumbnail:null};if(thumbnailUrl){var img=this.createElement("IMG");img.src=thumbnailUrl;img.style.position="relative";img.style.visibility="hidden";this.html.imagePreloader.appendChild(img);entry.thumbnail=img;}
this.entries.push(entry);this.populate();}
JUIImageList.prototype.populate=function()
{if(this.list)this.list.populate();var e;this.html.list.options.length=0;for(var i=0;i<this.entries.length;i++){e=this.entries[i];this.html.list.options.add(new Option(e.caption,e.value,false,false));}}
JUIImageList.prototype.setPreview=function(thumbnail)
{if(!this.root)return;var pre=this.html.imagePreloader;var thumbs=pre.getElementsByTagName("IMG");if(this.currentThumbnail!=null)
this.currentThumbnail.style.visibility="hidden";var whp=getSize(pre);pre.style.visibility="visible";thumbnail.style.width=whp.width-2;var wh=getSize(thumbnail);with(thumbnail.style){left=intVal((whp.width-wh.width)/2);top=intVal((whp.height-wh.height)/2);visibility="";}
pre.insertBefore(thumbnail,pre.firstChild);this.currentThumbnail=thumbnail;}

/*========== JUIDateSelect.js ==========*/

JUIDateSelect.extend(JUIComponent);function JUIDateSelect(name,dataType,minYear,maxYear,allowNull,defaultValue,reverse)
{JUIDateSelect.superConstructor.call(this);var dt=new Date();if(!name)
return ld_error("No indico un nombre para el elemento del objeto JUIDateSelect");if(!allowNull)
defaultValue=defaultValue||new Date();this.sName=name;this.iMinYear=(minYear)?minYear:intVal(dt.getFullYear());this.iMaxYear=(maxYear)?maxYear:(intVal(dt.getFullYear())+5);this.bAllowNull=(allowNull==true);this.date=defaultValue;this.defaultValue=defaultValue;this.iDaysPerMonth=null;this.dataType=dataType;this.oYear=null;this.oMonth=null;this.oDay=null;this.reverse=(reverse==true);}
JUIDateSelect.prototype.init=function(htmlNode)
{JUIDateSelect.superClass.init.call(this,htmlNode);this.oMonth=this.createElement("SELECT",null,null,{className:"JUIDateSelect"},{width:"40px"});this.oYear=this.createElement("SELECT",null,null,{className:"JUIDateSelect"},{width:"55px"});this.oDay=this.createElement("SELECT",null,null,{className:"JUIDateSelect"},{width:"40px"});this.root.appendChild(this.oMonth);this.root.appendChild(this.oDay);this.root.appendChild(this.oYear);var _this=this;this.oYear.onchange=function(){_this.onChangeYear();}
this.oMonth.onchange=function(){_this.onChangeMonth();}
this.oDay.onchange=function(){_this.onChangeDay();}
var dt=new Date();var currDate=new Array();currDate['y']=dt.getFullYear();currDate['m']=dt.getMonth()+1;currDate['d']=dt.getDate();this.oYear.value=currDate['y'];this.oMonth.value=currDate['m'];this.oDay.value=currDate['d'];var nullEntry=(this.bAllowNull==true)?"--":null;if(this.reverse)
populateSelectInterval(this.oYear,this.iMaxYear,this.iMinYear,currDate['y'],nullEntry);else
populateSelectInterval(this.oYear,this.iMinYear,this.iMaxYear,currDate['y'],nullEntry);populateSelectInterval(this.oMonth,1,12,currDate['m'],nullEntry);this.recalcDays();populateSelectInterval(this.oDay,1,this.iDaysPerMonth,currDate['d'],nullEntry);this.calcDate();}
JUIDateSelect.prototype.recalcDays=function()
{if(this.oMonth.value>0&&this.oYear.value>0)
this.iDaysPerMonth=aDaysPerMonth[this.oMonth.value-1]+
(this.oMonth.value==2&&((this.oYear.value%4)==0));else if(this.oMonth.value>0)
this.iDaysPerMonth=aDaysPerMonth[this.oMonth.value-1];else
this.iDaysPerMonth=30;}
JUIDateSelect.prototype.calcDate=function()
{var d,m,y;var dateString=(""+this.oYear.value).padLeft(4,"0")+
(""+this.oMonth.value).padLeft(2,"0")+
(""+this.oDay.value).padLeft(2,"0");this.date=stringToDate(dateString);}
JUIDateSelect.prototype.setDate=function(val)
{return this.setValue(val);}
JUIDateSelect.prototype.getValue=function()
{return this.date;}
JUIDateSelect.prototype.setValue=function(val)
{if(typeof(val)=="undefined"){var dt=new Date();this.oYear.value=dt.getFullYear();this.oMonth.value=dt.getMonth()+1;this.oDay.value=dt.getDate();}
else{var newDate;if(typeof(val=="string"))
val=stringToDate(val);newDate=this.dateToArray(val);if(typeof(newDate)!="object")return null;this.oYear.value=newDate['y'];this.oMonth.value=newDate['m'];this.oDay.value=newDate['d'];}
this.calcDate();return this.date;}
JUIDateSelect.prototype.setEnabled=function(enabled)
{this.bEnabled=enabled;this.oDay.disabled=!enabled;this.oMonth.disabled=!enabled;this.oYear.disabled=!enabled;}
JUIDateSelect.prototype.setVisible=function(visible)
{this.root.style.display=(visible==true)?"":"none";}
JUIDateSelect.prototype.dateToArray=function(date)
{date=date.toMilitary();return{y:intVal(date.substr(0,4)),m:intVal(date.substr(4,2)),d:intVal(date.substr(6,2))}}
JUIDateSelect.prototype.onChangeYear=function()
{this.onChangeMonth();}
JUIDateSelect.prototype.onChangeMonth=function()
{var currValue=this.oDay.value,nullEntry;nullEntry=(this.bAllowNull==true)?"--":null;this.recalcDays();this.oDay.value=Math.min(currValue,this.iDaysPerMonth);populateSelectInterval(this.oDay,1,this.iDaysPerMonth,this.oDay.value,nullEntry);this.onChangeDay();}
JUIDateSelect.prototype.onChangeDay=function()
{this.calcDate();}

/*========== JUIProgressBar.js ==========*/

JUIProgressBar.extend(JUIComponent);function JUIProgressBar(scale,length,thickness,orientation)
{JUIProgressBar.superConstructor.call(this);this.orientation=intVal(varDefault(orientation,JUI.LAYOUT_HORIZONTAL));this.length=intVal(varDefault(length,100));this.thickness=intVal(varDefault(thickness,20));this.preferredWidth=(this.orientation==JUI.LAYOUT_VERTICAL)?this.thickness:this.length;this.preferredHeight=(this.orientation==JUI.LAYOUT_VERTICAL)?this.length:this.thickness;this.width=this.preferredWidth;this.height=this.preferredHeight;this.scale=varDefault(scale,new Array(0,100));this.scalar=(this.scale.length==2);this.scaleDelta=(this.scalar)?(this.scale[1]-this.scale[0]):1;this.setProgress(this.scale[0]);}
JUIProgressBar.prototype.init=function()
{JUIProgressBar.superClass.init.call(this);var _this=this;with(this.root.style){width=this.width;height=this.height;backgroundColor="#cccccc";border="2px solid #cccccc";overflow="hidden";}
var bar=this.createElement("DIV");this.bar=bar;with(bar.style){position="relative";left="0px";top="0px";backgroundColor="#a91568";}
if(this.scalar){with(bar.style){width=(this.orientation==JUI.LAYOUT_VERTICAL)?this.thickness:0;height=(this.orientation==JUI.LAYOUT_VERTICAL)?0:this.thickness;backgroundImage="url(skins/"+JUI.getCurrentSkin()+"/JUIProgressBar/bg_scalar.gif)";}}
else{this.pbLength=intVal(this.length/100*20);with(bar.style){width=(this.orientation==JUI.LAYOUT_VERTICAL)?this.thickness:this.pbLength;height=(this.orientation==JUI.LAYOUT_VERTICAL)?this.pbLength:this.thickness;backgroundImage="url(skins/"+JUI.getCurrentSkin()+"/JUIProgressBar/bg_non_scalar.gif)";}
this.pbStep=10;this.pbPos=0;}
this.root.appendChild(bar);}
JUIProgressBar.prototype.getProgress=function()
{return this.progress;}
JUIProgressBar.prototype.setProgress=function(progress)
{this.progress=floatVal(progress);this.refresh();}
JUIProgressBar.prototype.setMotion=function(motion)
{if(this.scalar)return;if(motion==true){if(this.pbInterval!=null)return;var _this=this;this.pbInterval=setInterval(function(){_this.pbPos=Math.max(0,Math.min(_this.pbPos+_this.pbStep,80));if(_this.pbPos<=0||_this.pbPos>=80)
_this.pbStep*=-1;_this.refresh();},200);}
else{if(this.pbInterval==null)return;clearInterval(this.pbInterval);this.pbInterval=null;}}
JUIProgressBar.prototype.refresh=function()
{if(!this.root)return;var l;if(this.scalar){var l=Math.min(this.width,intVal((this.progress-this.scale[0])/this.scaleDelta*this.width));if(this.orientation==JUI.LAYOUT_VERTICAL)
this.bar.style.height=l;else
this.bar.style.width=l;}
else{var p=intVal(this.pbPos/100*this.length);if(this.orientation==JUI.LAYOUT_VERTICAL)
this.bar.style.top=p;else
this.bar.style.left=p;}}

/*========== JUIUpload.js ==========*/

JUIUpload.extend(JUIComponent);JUIUpload.EVT_UPLOAD_FINISHED=1;JUIUpload.lastId=0;function JUIUpload(socketName,targetUrl,command,uploadPath,targetParamName)
{JUIUpload.superConstructor.call(this);this.id=JUIUpload.nextId();this.socketName=varDefault(socketName,"upload"+this.id);this.targetUrl=varDefault(targetUrl,"");this.command=varDefault(command,"upload");this.targetParamName=varDefault(targetParamName,"file");this.fileInput=null;this.uploadForm=null;this.uploadFrame=null;this.requestArguments=new Object();this.setUploadPath("/");}
JUIUpload.prototype.init=function()
{var _this=this;var root=this.createElement("DIV");this.root=root;with(root.style){position="absolute";overflow="hidden";width=this.width;height=this.height;padding=1;display="none";}
var legend=this.createElement("DIV");this.legend=legend;legend.appendChild(createText(_("Pick a file, set access level and click on Upload button")));with(legend.style){position="absolute";overflow="hidden";width="100%";height=20;padding=1;}
root.appendChild(legend);var uploadForm=this.createElement("FORM");this.uploadForm=uploadForm;uploadForm.name=uploadForm.id="formUL_"+this.socketName;uploadForm.action=this.targetUrl;uploadForm.method="post";uploadForm.enctype=uploadForm.encoding="multipart/form-data";this.initFileInput();var accessCombo=this.createElement("SELECT");this.accessCombo=accessCombo;accessCombo.name="access";accessCombo.className="JUIUpload";with(accessCombo.style){position="absolute";left=140;top=20;width=96;height=20;}
accessCombo.size=1;var options={"free":new Option("Free","rwr-r-0",true,true),"friends":new Option("Friends Only","rwr---0",false,false),"password":new Option("Password","rwr-r-1",false,false),"private":new Option("Private","rwr-r-0",false,false)}
var count=0;for(var k in options){options[k].className="JUIUpload_access_"+k;accessCombo.options[count++]=options[k];}
var uploadButton=JUI.makeButton(20,"",getImageURL("/skins/"+JUI.currentSkin+"/JUIUpload/upload.gif"),"Upload selected file",function(evt){if(_this.getFilePath()!="")_this.upload();});this.uploadButton=uploadButton;var clearButton=JUI.makeButton(20,"",getImageURL("/skins/"+JUI.currentSkin+"/JUIUpload/clear.gif"),"Clear (cancel file upload)",function(evt){if(_this.getFilePath()!="")_this.initFileInput();});this.clearButton=clearButton;var argumentsInput=this.createElement("INPUT","hidden","extra");this.argumentsInput=argumentsInput;var frameName="frUL_"+this.socketName;var uploadFrame;if(Browser.isIE){uploadFrame=document.createElement('<IFRAME name="'+frameName+'" onload="JUIComponent.getInstance(this.dhtmlOwner).uploadFinished();">');uploadFrame.dhtmlOwner=this.componentId;}
else{uploadFrame=this.createElement("IFRAME",null,frameName);uploadFrame.onload=function(){_this.uploadFinished();}}
this.uploadFrame=uploadFrame;uploadFrame.id=frameName;with(uploadFrame.style){position="absolute";left=0;top=42;width=400;height=this.height-24;display="none";}
root.appendChild(uploadFrame);uploadForm.target=uploadFrame.name;uploadForm.appendChild(argumentsInput);uploadForm.appendChild(accessCombo);uploadForm.appendChild(uploadButton.getRoot());uploadButton.setLocation(240,20);uploadForm.appendChild(clearButton.getRoot());clearButton.setLocation(264,20);this.root.appendChild(uploadForm);}
JUIUpload.prototype.initFileInput=function()
{if(!this.root)return;var oldFileInput=this.fileInput;var fileInput=this.createElement("INPUT","file");this.fileInput=fileInput;fileInput.name=this.targetParamName;fileInput.size=8;fileInput.className="JUIUpload";fileInput.selectable=true;fileInput.title="Click on Browse button to pick a file";with(fileInput.style){position="absolute";left="2px";top="20px";height="20px";width="136px";}
fileInput.onchange=function(evt){if(this.value!="")
this.title=this.value+"\r\nClick Browse button to change";else
this.title="Click on Browse button to pick a file";}
if(oldFileInput&&oldFileInput.parentNode)
oldFileInput.parentNode.replaceChild(this.fileInput,oldFileInput);else if(this.uploadForm)
this.uploadForm.appendChild(fileInput);}
JUIUpload.prototype.repaint=function()
{if(!this.root)return;JUIUpload.superClass.repaint.call(this);this.uploadFrame.style.height=this.height-24;}
JUIUpload.prototype.getFilePath=function()
{if(this.fileInput)
return varDefault(this.fileInput.value,"");else
return"";}
JUIUpload.prototype.setArgument=function(name,value)
{if(!name)throw"JUIUpload.setArgument: must provide a name for request argument";this.requestArguments[name]=value;}
JUIUpload.prototype.clearArguments=function(name)
{if(name!=null)
delete this.requestArguments[name.toString()];else
this.requestArguments=new Object();}
JUIUpload.prototype.getUploadPath=function()
{return this.requestArguments.uploadPath;}
JUIUpload.prototype.setUploadPath=function(path)
{this.requestArguments.uploadPath=varDefault(path,"/");}
JUIUpload.prototype.setCommand=function(cmd)
{this.command=varDefault(cmd,"");}
JUIUpload.prototype.upload=function()
{if(this.uploadForm){this.uploadForm.action=(this.targetUrl+"?cmd="+this.command);this.uploadForm.appendChild(this.fileInput);this.argumentsInput.value=Json.toString(this.requestArguments);this.uploadForm.submit();}}
JUIUpload.prototype.uploadFinished=function()
{if(!this.uploadFrame)return LD.Con.println("noframe");var doc;try{doc=getFrameDoc(this.uploadFrame);}
catch(e){return;}
if(!doc||!doc.body||!doc.body.innerHTML)return;var location=doc.location.href;if(!location||location=="about:blank")return;this.initFileInput();var evt={"result":Json.evaluate(doc.body.innerHTML.trim())};this.fireEvent(evt,JUIUpload.EVT_UPLOAD_FINISHED);}
JUIUpload.nextId=function()
{return++this.lastId;}

/*========== JUIDownload.js ==========*/

JUIDownload.extend(JUIComponent);JUIDownload.lastId=0;JUIDownload.EVT_DOWNLOAD_FINISHED=1;function JUIDownload(socketName,targetUrl,command)
{JUIDownload.superConstructor.call(this);this.id=JUIDownload.nextId();this.socketName=varDefault(socketName,"DL"+this.id);this.targetUrl=varDefault(targetUrl,"");this.command=varDefault(command,"download");this.downloadFrame=null;this.downloadTarget="";}
JUIDownload.prototype.init=function()
{var _this=this;var root=this.createElement("DIV");this.root=root;with(root.style){position="absolute";overflow="hidden";width=this.width;height=this.height;display="none";}
var frameName="frDL_"+this.socketName;var downloadFrame;if(Browser.isIE){downloadFrame=document.createElement('<IFRAME name="'+frameName+'" onload="JUIComponent.getInstance(this.dhtmlOwner).downloadFinished();">');downloadFrame.dhtmlOwner=this.componentId;}
else{downloadFrame=this.createElement("IFRAME",null,frameName);downloadFrame.onload=function(){_this.downloadFinished();}}
this.downloadFrame=downloadFrame;downloadFrame.id=frameName;with(downloadFrame.style){position="absolute";left="0px";top="0px";width="200px";height="100px";backgroundColor="#ffffff";}
root.appendChild(downloadFrame);}
JUIDownload.prototype.repaint=function()
{if(!this.root)return;JUIDownload.superClass.repaint.call(this);this.downloadFrame.style.height=this.height-24;}
JUIDownload.prototype.setArgument=function(name,value)
{if(!name)throw"JUIDownload.setArgument: must provide a name for request argument";this.requestArguments[name]=value;}
JUIDownload.prototype.clearArguments=function(name)
{if(name!=null)
delete this.requestArguments[name.toString()];else
this.requestArguments=new Object();}
JUIDownload.prototype.getDownloadTarget=function()
{return this.downloadTarget;}
JUIDownload.prototype.setDownloadTarget=function(id)
{this.downloadTarget=intVal(id);}
JUIDownload.prototype.setCommand=function(cmd)
{this.command=varDefault(cmd,"");}
JUIDownload.prototype.download=function(downloadTarget)
{if(!this.downloadFrame){return false;}
if(downloadTarget!=null){this.setDownloadTarget(downloadTarget);}
var url=this.targetUrl+"?cmd="+this.command+"&id="+Ajax.escape(this.downloadTarget);this.downloadFrame.style.display="block";this.downloadFrame.src=url;}
JUIDownload.prototype.downloadFinished=function()
{if(!this.downloadFrame)return LD.Con.println("noframe");var doc;try{doc=getFrameDoc(this.downloadFrame);}
catch(e){return;}
if(!doc||!doc.body||!doc.body.innerHTML)return;var location=doc.location.href;if(!location||location=="about:blank")return;var evt={"result":Json.evaluate(doc.body.innerHTML.trim())};this.fireEvent(evt,JUIDownload.EVT_DOWNLOAD_FINISHED);}
JUIDownload.nextId=function()
{return++this.lastId;}

/*========== JUIWindow.js ==========*/

JUIWindow.extend(JUIContainer);JUIWindow.DO_NOTHING_ON_CLOSE=0;JUIWindow.HIDE_ON_CLOSE=1;JUIWindow.DISPOSE_ON_CLOSE=2;JUIWindow.EVT_OPENED=2001;JUIWindow.EVT_CLOSING=2002;JUIWindow.EVT_CLOSED=2003;JUIWindow.EVT_COLLAPSED=2004;JUIWindow.EVT_MINIMIZED=2005;JUIWindow.EVT_MAXIMIZED=2006;JUIWindow.EVT_RESTORED=2007;JUIWindow.EVT_MOVED=2008;JUIWindow.templates={base:"JUIWindow"};JUIWindow.classEventHandler=new LD.Proto();function JUIWindow(title,closable,minimizable,maximizable,collapsable)
{JUIWindow.superConstructor.call(this);this.title=varDefault(title,"");this.absolute=true;this.closable=(closable==true);this.minimizable=(minimizable==true);this.maximizable=(maximizable==true);this.collapsable=(collapsable==true);this.closeAction=JUIWindow.HIDE_ON_CLOSE;this.visible=false;this.active=false;this.collapsed=false;this.minimized=false;this.maximized=false;this.resizable=true;this.modal=false;this.popup=false;this.root=null;this.titleBar=null;this.titleBarVisible=true;this._titleBarHeight=20;this._titleBarIcon="";this.setIcon(getImageURL("/skins/"+JUI.getCurrentSkin()+"/JUIWindow/icon_default.gif"));this.controlButtonVisible=false;this.toolBar=null;this.toolBarVisible=false;this.plugins=new Array();this.activePlugin=null;this.activePluginVisible=false;this._pluginHeight=64;this.contentPane=null;this.html.contentPane1=null;this.contentPaneCell=null;this.resizeHandle=null;this.statusBar=null;this.statusBarVisible=false;this.x=0;this.y=0;this.preferredX=0;this.preferredY=0;this.preferredWidth=400;this.preferredHeight=300;this.width=this.preferredWidth;this.height=this.preferredHeight;this.restoreWidth=this.width;this.restoreHeight=this.height;this.minWidth=150;this.minHeight=60;this.maxWidth=2048;this.maxHeight=2048;this.borderWidth=3;this.visible=false;this.draggable=true;this.dragOriginalX=null;this.dragOriginalY=null;}
JUIWindow.prototype.init=function(htmlNode)
{JUIWindow.superClass.init.call(this,htmlNode);var root=this.root;with(root.style){width=this.width;height=this.height;display="";overflow="hidden";}
this.addTitleBar();this.addToolBar();this.addContentPane();this.addResizeHandle();this.setBounds(this.preferredX,this.preferredY,this.width,this.height);this.setTitle(this.title);this.setIcon(this._titleBarIcon);this.setVisible(this.visible);this.setMouseEventHandlers();this.recalcWindowState();this.recalcDhtmlStyles();}
JUIWindow.prototype.dispose=function()
{this.titleBar.dispose();this.contentPane.dispose();this.resizeHandle.dispose();JUIWindow.superClass.dispose.call(this);}
JUIWindow.prototype.close=function()
{this.fireEvent(null,JUIWindow.EVT_CLOSING);if(this.closeAction==JUIWindow.DO_NOTHING_ON_CLOSE)return;this.setVisible(false);this.fireEvent(null,JUIWindow.EVT_CLOSED);if(this.closeAction==JUIWindow.DISPOSE_ON_CLOSE)
this.dispose();if(typeof Meebo!=='undefined'){Meebo.unhide();}}
JUIWindow.prototype.menuActionFired=function(evt,type,src)
{}
JUIWindow.prototype.getPlugin=function(indexOrName)
{if(typeof(indexOrName)=="number"){return this.plugins[intVal(indexOrName)];}
else{for(var i=0;i<this.plugins.length;i++){if(this.plugins[i].name==indexOrName.toString())
return this.plugins[i];}}}
JUIWindow.prototype.registerPlugin=function(plugin)
{if(!(plugin instanceof JUIWindowPlugin))
throw"JUIWindow.registerPlugin: Must provide a JUIWindowPlugin instance to register";if(inArray(this.plugins,plugin))return;this.plugins.push(plugin);plugin.setVisible(false);plugin.setPositioning(JUI.POSITION_STATIC);this.html.pluginArea.appendChild(plugin.getRoot());}
JUIWindow.prototype.getActivePlugin=function()
{return this.activePlugin;}
JUIWindow.prototype.setActivePlugin=function(pluginOrIndex)
{if(typeof(pluginOrIndex)=="undefined")
throw"JUIWindow.setActivePlugin: Must provide the JUIWindowPlugin instance or index";if(pluginOrIndex===null){this.activePlugin=null;this.setActivePluginVisible(false);return;}
var currentPlugin=this.activePlugin;if(pluginOrIndex instanceof JUIWindowPlugin){if(inArray(this.plugins,pluginOrIndex))
this.activePlugin=pluginOrIndex;else
throw"JUIWindow.setActivePlugin: Given plugin is not registered in this window";}
else{var index=intVal(pluginOrIndex);if(index<0||index>=this.plugins.length)
throw"JUIWindow.setActivePlugin: No plugin was registered with index "+index;this.activePlugin=this.plugins[pluginOrIndex];}
if(currentPlugin!=null&&currentPlugin!=this.activePlugin)
currentPlugin.setVisible(false);var bW=this.borderWidth*2;this.activePlugin.setSize(this.root.offsetWidth-bW,this._pluginHeight);this.activePlugin.setVisible(true);this.setActivePluginVisible(true);}
JUIWindow.prototype.isActivePluginVisible=function()
{return this.activePluginVisible;}
JUIWindow.prototype.setActivePluginVisible=function(visible)
{this.activePluginVisible=(visible==true);if(this.activePluginVisible==true){this.html.pluginArea.style.display="";this.activePlugin.setVisible(true);}
else
this.html.pluginArea.style.display="none";this.repaint();}
JUIWindow.prototype.getTitleBar=function()
{return this.titleBar;}
JUIWindow.prototype.getContentPane=function()
{return this.contentPane;}
JUIWindow.prototype.addTitleBar=function()
{var titleBar=new JUIWindowTitleBar(this,this._titleBarHeight);titleBar.init(this.html.titleBar);this.titleBar=titleBar;this.addTitleBarButtons();this.titleBar.addListener(JUI.EVT_MOUSE_DBLCLICK,this.titleBar_dblClick,this);}
JUIWindow.prototype.addTitleBarButtons=function()
{var _this=this;this.html.buttonClose.onclick=function(){_this.close();}
this.html.buttonMinimize.onclick=function(){_this.setMinimized(!_this.minimized);}
this.html.buttonMaximize.onclick=function(){_this.setMaximized(!_this.maximized);}
this.html.buttonCollapse.onclick=function(){_this.setCollapsed(!_this.collapsed);}
this.html.buttonMinimize.onmouseover=function(){_this.html.buttonMinimize.className="buttonMinimize_hover";}
this.html.buttonMinimize.onmouseout=function(){_this.html.buttonMinimize.className="buttonMinimize";}
this.html.buttonMaximize.onmouseover=function(){_this.html.buttonMaximize.className="buttonMaximize_hover";}
this.html.buttonMaximize.onmouseout=function(){_this.html.buttonMaximize.className="buttonMaximize";}
this.html.buttonClose.onmouseover=function(){_this.html.buttonClose.className="buttonClose_hover";}
this.html.buttonClose.onmouseout=function(){_this.html.buttonClose.className="buttonClose";}}
JUIWindow.prototype.addToolBar=function()
{var toolBar=new JUIToolBar(JUI.LAYOUT_HORIZONTAL,"",false);this.toolBar=toolBar;toolBar.init();toolBar.setLocation(0,1);toolBar.setWidth("100%");toolBar.setHeight(20);this.html.toolBarArea.appendChild(toolBar.getRoot());this.children.push(toolBar);}
JUIWindow.prototype.addControlPanel=function()
{}
JUIWindow.prototype.addContentPane=function()
{var contentPane=new JUIContentPane();this.contentPane=contentPane;contentPane.init();contentPane.setParent(this);contentPane.setVisible(true);this.html.contentPane1.appendChild(contentPane.getRoot());this.children.push(contentPane);}
JUIWindow.prototype.addResizeHandle=function()
{var resizeHandle=new JUIFrameResizeHandle(this,14,14);this.resizeHandle=resizeHandle;resizeHandle.init(this.html.resizeHandle);this.root.appendChild(resizeHandle.getRoot());resizeHandle.setVisible(this.resizable);this.children.push(resizeHandle);}
JUIWindow.prototype.getVisibleButtons=function()
{var buttons=new Array();if(this.closable)buttons.push(this.html.buttonClose);if(this.minimizable)buttons.push(this.html.buttonMinimize);if(this.maximizable)buttons.push(this.html.buttonMaximize);if(this.collapsable)buttons.push(this.html.buttonCollapse);return buttons;}
JUIWindow.prototype.getTitle=function()
{return this.title;}
JUIWindow.prototype.setTitle=function(title)
{this.title=title;if(this.titleBar)this.titleBar.setTitle(title);}
JUIWindow.prototype.setVisible=function(visible)
{var isOpening=(visible==true&&this.visible==false);JUIWindow.superClass.setVisible.call(this,visible);this.recalcWindowState();if(isOpening)
JUIWindow.classEventHandler.fireEvent({window:this},JUIWindow.EVT_OPENED);}
JUIWindow.prototype.isResizable=function()
{return this.resizable;}
JUIWindow.prototype.setResizable=function(resizable)
{this.resizable=(resizable==true);this.recalcWindowState();if(this.resizeHandle)
this.resizeHandle.setVisible(this.resizable);}
JUIWindow.prototype.setActive=function(active)
{this.active=(active==true);this.recalcWindowState();}
JUIWindow.prototype.recalcWindowState=function()
{var root=this.root;if(root==null)return;if(this.active){LD.Element.putClass(root,"active");LD.Element.removeClass(root,"inactive");}
else{LD.Element.putClass(root,"inactive");LD.Element.removeClass(root,"active");}
if(this.titleBarVisible){LD.Element.removeClass(this.root,"noTitleBar");}
else{LD.Element.putClass(this.root,"noTitleBar");}
if(this.toolBarVisible){LD.Element.removeClass(this.root,"noToolBarArea");}
else{LD.Element.putClass(this.root,"noToolBarArea");}
if(this.statusBarVisible){LD.Element.removeClass(this.root,"noStatusBar");}
else{LD.Element.putClass(this.root,"noStatusBar");}
if(this.isCollapsable()){LD.Element.removeClass(this.root,"noCollapsable");}
else{LD.Element.putClass(this.root,"noCollapsable");}
if(this.isMinimizable()){LD.Element.removeClass(this.root,"noMinimizable");}
else{LD.Element.putClass(this.root,"noMinimizable");}
if(this.isMaximizable()){LD.Element.removeClass(this.root,"noMaximizable");}
else{LD.Element.putClass(this.root,"noMaximizable");}
if(this.isClosable()){LD.Element.removeClass(this.root,"noClosable");}
else{LD.Element.putClass(this.root,"noClosable");}}
JUIWindow.prototype.isModal=function()
{return this.modal;}
JUIWindow.prototype.setModal=function(modal)
{this.modal=(modal==true);this.recalcWindowState();}
JUIWindow.prototype.isMinimizable=function()
{return this.minimizable;}
JUIWindow.prototype.setMinimizable=function(minimizable)
{this.minimizable=(minimizable==true);this.recalcWindowState();}
JUIWindow.prototype.isMaximizable=function()
{return this.maximizable;}
JUIWindow.prototype.setMaximizable=function(maximizable)
{this.maximizable=(maximizable==true);this.recalcWindowState();}
JUIWindow.prototype.isClosable=function()
{return this.closable;}
JUIWindow.prototype.setClosable=function(closable)
{this.closable=(closable==true);this.recalcWindowState();}
JUIWindow.prototype.isCollapsable=function()
{return this.collapsable;}
JUIWindow.prototype.setCollapsable=function(collapsable)
{this.collapsable=(collapsable==true);if(this.btnCollapse)
this.btnCollapse.setVisible(this.collapsable);this.recalcWindowState();}
JUIWindow.prototype.getCloseAction=function()
{return this.closeAction;}
JUIWindow.prototype.setCloseAction=function(closeAction)
{this.closeAction=intVal(closeAction);}
JUIWindow.prototype.isMinimized=function()
{return this.minimized;}
JUIWindow.prototype.setMinimized=function(minimized)
{this.minimized=(minimized==true);this.maximized=false;this.collapsed=false;if(this.parent&&this.root){if(!this.tempXY)
this.tempXY=this.getLocation();if(this.parent instanceof JUIDesktop){if(this.minimized){this.tempXY=this.getLocation();this.setLocation(3200,2400);}
else if(this.tempXY)
this.setLocation(this.tempXY.x,this.tempXY.y);}
else{this.setCollapsed(this.minimized);this.minimized=true;}}
this.fireEvent(null,this.minimized?JUIWindow.EVT_MINIMIZED:JUIWindow.EVT_RESTORED);this.fireEvent(null,JUI.EVT_RESIZED);}
JUIWindow.prototype.isMaximized=function()
{return this.maximized;}
JUIWindow.prototype.setMaximized=function(maximized)
{if(!(this.parent instanceof JUIDesktop))return;this.maximized=(maximized==true);this.minimized=false;this.collapsed=false;this.html.contentPane1.style.display="";if(this.maximized){bounds=this.parent.getClientAreaBounds();this.restoreWidth=this.width;this.restoreHeight=this.height;this.tempXY=this.getLocation();this.setBounds(bounds.x,bounds.y,bounds.width,bounds.height);this.resizeHandle.setVisible(false);this.setDraggable(false);}
else{this.setBounds(this.preferredX,this.preferredY,this.restoreWidth,this.restoreHeight);if(this.tempXY)
this.setLocation(this.tempXY.x,this.tempXY.y);this.resizeHandle.setVisible(this.resizable);this.setDraggable(true);}
this.repaint();this.fireEvent(null,this.maximized?JUIWindow.EVT_MAXIMIZED:JUIWindow.EVT_RESTORED);this.fireEvent(null,JUI.EVT_RESIZED);if(typeof Meebo!=='undefined'){if(this.maximized)
Meebo.hide();else
Meebo.unhide();}}
JUIWindow.prototype.isCollapsed=function()
{return this.collapsed;}
JUIWindow.prototype.setCollapsed=function(collapsed)
{this.collapsed=(collapsed==true);this.maximized=false;this.minimized=false;this.autoRepaint=false;this.setLocation(this.preferredX,this.preferredY);this.setWidth(this.preferredWidth);if(this.collapsed==true){this.html.contentPane1.style.display="none";this.html.toolBarArea.style.display="none";this.html.pluginArea.style.display="none";this.setHeight(this.html.titleBar.offsetHeight+this.borderWidth*2-2);this.resizeHandle.setVisible(false);}
else{this.html.contentPane1.style.display="";this.html.toolBarArea.style.display=this.statusBarVisible?"":"none";this.html.pluginArea.style.display="";this.setHeight(this.preferredHeight);this.resizeHandle.setVisible(this.resizable);}
this.autoRepaint=true;this.repaint();this.fireEvent(null,this.collapsed?JUIWindow.EVT_COLLAPSED:JUIWindow.EVT_RESTORED);this.fireEvent(null,JUI.EVT_RESIZED);}
JUIWindow.prototype.isTitleBarVisible=function()
{return this.titleBarVisible;}
JUIWindow.prototype.setTitleBarVisible=function(visible)
{this.titleBarVisible=(visible==true);this.recalcWindowState();}
JUIWindow.prototype.isToolBarVisible=function()
{return this.toolBarVisible;}
JUIWindow.prototype.setToolBarVisible=function(visible)
{this.toolBarVisible=(visible==true);if(this.root&&this.toolBar){this.recalcWindowState();}}
JUIWindow.prototype.isStatusBarVisible=function()
{return this.statusBarVisible;}
JUIWindow.prototype.setStatusBarVisible=function(visible)
{this.statusBarVisible=(visible==true);this.recalcWindowState();this.recalcDhtmlStyles();}
JUIWindow.prototype.setStatusBarText=function(text)
{LD.Element.writeText(this.html.statusBarText,text,true);}
JUIWindow.prototype.setBorder=function(border)
{if(border=="none")
this.setBackgroundColor("transparent");else
this.setBackgroundColor(border);}
JUIWindow.prototype.repaint=function()
{if(this.width!=this._lastWidth||this.height!=this._lastHeight)
this.fireEvent(null,JUI.EVT_RESIZED);JUIWindow.superClass.repaint.call(this);this._lastWidth=this.width;this._lastHeight=this.height;if(this.toolBar){this.toolBar.repaint();}
if(this.resizeHandle){var rhs=this.resizeHandle.getSize();this.resizeHandle.setLocation(this.width-rhs.width-1,this.height-rhs.height-2);}}
JUIWindow.prototype.titleBar_dblClick=function(evt,type,src)
{if(this.collapsed==true)
this.setCollapsed(false);else if(this.minimized==true)
this.setMinimized(false);else if(this.maximized==true)
this.setMaximized(false);else if(this.maximizable)
this.setMaximized(true);}
JUIWindow.prototype.setIcon=function(imageUrl)
{this._titleBarIcon=imageUrl;if(!this.titleBar)return;this.titleBar.setIcon(imageUrl);}
JUIWindow.prototype.getTransferable=function()
{return this;}
JUIWindow.prototype.getVisualDraggable=function()
{var draggable=LD.Element.create("DIV",{className:"JUIWindowDraggable"},{position:"absolute",left:this.x,top:this.y,width:this.width,height:this.height});this.contentPane.getRoot().appendChild(draggable);return{"component":null,"htmlNode":draggable,"disposeOnFinish":true};}
JUIWindow.prototype.dragFinished=function(evt,type,src)
{JUIWindow.superClass.dragFinished.call(this,evt,type,src);var clientH,clientW;if(evt&&evt.dragOp){if(this.parent){clientW=this.parent.getWidth();clientH=this.parent.getHeight();}
else{clientW=(window.innerWidth!=null)?window.innerWidth:document.body.clientWidth;clientH=(window.innerHeight!=null)?window.innerHeight:document.body.clientHeight;}
var x=Math.max(intVal(this.width*(-0.75)),Math.min(clientW-intVal(this.width*0.25),this.x+evt.dragOp.deltaX));var y=Math.max(36,Math.min(intVal(clientH-150),this.y+evt.dragOp.deltaY));this.setLocation(x,y);}}
JUIWindow.prototype.resizeHandleDrag=function(evt,type,src)
{if(!evt||!evt.dragOp)return;var w=Math.max(this.minWidth,this.resizeHandle.parentSize.width+evt.dragOp.deltaX);var h=Math.max(this.minHeight,this.resizeHandle.parentSize.height+evt.dragOp.deltaY);this.setSize(w,h);}
JUIContentPane.extend(JUIContainer);function JUIContentPane()
{JUIContentPane.superConstructor.call(this);this.width="100%";this.height="100%";this.scrolling=JUI.SCROLL_BOTH;}
JUIContentPane.prototype.init=function(htmlNode)
{var root=null;if(htmlNode&&htmlNode.nodeType==LD.NODE_ELEMENT){root=htmlNode;this.root=root;}
else{root=this.createElement("DIV");this.root=root;root.className="JUIWindowContentPane";with(root.style){top=0;left=0;height=this.width;width=this.height;}}
this.setScrolling(this.scrolling);this.setMouseEventHandlers();}
JUIContentPane.prototype.add=function(component)
{if(!component)throw"JUIContentPane.add: Must provide a component to add";if(component.nodeType==LD.NODE_ELEMENT){this.children.push(component);this.getRoot().appendChild(component);}
else if(typeof(component.constructor)=="function"){this.children.push(component);this.getRoot().appendChild(component.getRoot());component.setParent(this);}}
JUIContentPane.prototype.getScrolling=function()
{return this.scrolling;}
JUIContentPane.prototype.setScrolling=function(scrolling)
{this.scrolling=intVal(scrolling);if(!this.root)return;if(Browser.isOpera){this.root.style.overflow=(this.scrolling==JUI.SCROLL_NONE)?"hidden":"auto";}
else{this.root.style.overflowX=(this.scrolling&JUI.SCROLL_HORIZONTAL)?"auto":"hidden";this.root.style.overflowY=(this.scrolling&JUI.SCROLL_VERTICAL)?"auto":"hidden";}}
JUIWindowTitleBar.extend(JUIComponent);function JUIWindowTitleBar(parent,height)
{if(!parent||!instanceOf(parent,JUI.WithTitle))return false;JUIWindowTitleBar.superConstructor.call(this);this.parent=parent;this.title=this.parent.getTitle();this.titleRow=null,this.titleCell=null,this.iconCell=null,this.iconImage=null,this.buttonsCell=null;this._titleBarHeight=varDefault(height,22);this.setPositioning(JUI.POSITION_STATIC);}
JUIWindowTitleBar.prototype.init=function(htmlNode)
{JUIWindowTitleBar.superClass.init.call(this,htmlNode);this.setMouseEventHandlers();JUI.DragDrop.registerDragSource(new JUIDragSource(this,this));}
JUIWindowTitleBar.prototype.setIcon=function(imageUrl)
{if(!this.root)return;if(imageUrl!=""){this.html.iconImage.src=imageUrl;this.html.iconImage.style.display="";}
else{this.html.iconImage.src=imageUrl;this.html.iconImage.style.display="none";}}
JUIWindowTitleBar.prototype.setMouseEventHandlers=function()
{this.root.onmousedown=this.mouseDown;this.root.onmouseup=this.mouseUp;this.root.onclick=this.click;this.root.ondblclick=this.doubleClick;}
JUIWindowTitleBar.prototype.mouseDown=function(evt)
{JUIWindowTitleBar.superClass.mouseDown.call(this,evt);LD.Event.cancel(evt);}
JUIWindowTitleBar.prototype.requestFocus=function()
{return this.parent.requestFocus();}
JUIWindowTitleBar.prototype.click=function(evt)
{if(Browser.isIE)evt=LD.Event.normalize(evt);if(!evt.target)return;var component=JUIComponent.getInstance(evt.target.dhtmlOwner);if(component instanceof JUIComponent)
component.fireEvent(evt,JUI.EVT_MOUSE_CLICK);}
JUIWindowTitleBar.prototype.getTransferable=function()
{return this;}
JUIWindowTitleBar.prototype.doubleClick=function(evt)
{if(Browser.isIE)evt=LD.Event.normalize(evt);if(!evt.target)return;var component=JUIComponent.getInstance(evt.target.dhtmlOwner);if(component instanceof JUIComponent)
component.fireEvent(evt,JUI.EVT_MOUSE_DBLCLICK);LD.Event.cancel(evt);}
JUIWindowTitleBar.prototype.setTitle=function(title)
{this.title=varDefault(title,"");if(!this.root)return;this.html.title.innerHTML=title;}
JUIWindowTitleBar.prototype.addButton=function(button)
{if(button instanceof JUIButton)
this.html.buttonArea.appendChild(button.getRoot());}
JUIWindowTitleBar.prototype.dragGestureRecognized=function(evt,type,src)
{this.parent.dragGestureRecognized(evt,type,src);}
JUIWindowTitleBar.prototype.drag=function(evt,type,src)
{if(!evt||!evt.dragOp||!this.parent)return;document.body.style.cursor=this.root.style.cursor="move";this.parent.drag(evt,type,src);}
JUIWindowTitleBar.prototype.dragFinished=function(evt,type,src)
{document.body.style.cursor="auto";this.root.style.cursor="auto";this.parent.dragFinished(evt,type,src);}
JUIFrameResizeHandle.extend(JUIComponent);function JUIFrameResizeHandle(parent,width,height)
{if(!parent||(!parent instanceof JUIComponent))
throw"JUIFrameResizeHandle: Must provide a JUIComponent object to append the handle to";JUIFrameResizeHandle.superConstructor.call(this);this.setParent(parent);this.preferredWidth=0;this.preferredHeight=0;this.width=width||null;this.height=height||null;}
JUIFrameResizeHandle.prototype.init=function(htmlNode)
{var root=null;if(htmlNode&&htmlNode.nodeType==LD.NODE_ELEMENT){root=htmlNode;JUI.setDhtmlOwner(root,this,true);}
else{root=this.createElement("DIV");with(root.style){width=this.width;height=this.height;backgroundColor="gray";position="absolute";align="right";cursor="nw-resize";zIndex=0;}}
this.root=root;root.onmousedown=this.mouseDown;JUI.DragDrop.registerDragSource(new JUIDragSource(this,this));}
JUIFrameResizeHandle.prototype.getTransferable=function()
{return this;}
JUIFrameResizeHandle.prototype.mouseDown=function(evt)
{JUIFrameResizeHandle.superClass.mouseDown.call(this,evt);LD.Event.cancel(evt);}
JUIFrameResizeHandle.prototype.dragGestureRecognized=function(evt,type,src)
{if(!this.parent)return;this.parentSize=this.parent.getSize();}
JUIFrameResizeHandle.prototype.drag=function(evt,type,src)
{if(!evt||!this.parent)return;if(!evt.dragOp)return false;document.body.style.cursor="nw-resize";this.parent.resizeHandleDrag(evt,type,src);}
JUIFrameResizeHandle.prototype.dragFinished=function(evt,type,src)
{document.body.style.cursor="auto";}

/*========== JUIDialogWindow.js ==========*/

JUIDialogWindow.extend(JUIWindow);JUIDialogWindow.INFO=1;JUIDialogWindow.ALERT=2;JUIDialogWindow.ERROR=3;JUIDialogWindow.QUESTION=4;JUIDialogWindow.INPUT=5;JUIDialogWindow.FREE=6;JUIDialogWindow.YES=1;JUIDialogWindow.NO=0;JUIDialogWindow.WIXI=1001;JUIDialogWindow.CANCEL=null;JUIDialogWindow.templates={base:"JUIWindow",content:"JUIDialogWindow"};function JUIDialogWindow(message,title,options,callback,width,height)
{JUIDialogWindow.superConstructor.call(this,title,true,false,false,false);this.message=varDefault(message,"");this.owner=null;this.callback=callback||null;this.options=varDefault(options,new Object());this.setMessageType(this.options.messageType);this.buttons=new Array();this.resizable=false;this.maximizable=false;this.minimizable=false;this.collapsable=false;this.defaultButton=typeof(this.options.defaultButton)!="undefined"?this.options.defaultButton:null;this.defaultValue=this.options.defaultValue||null;this.returnValue=this.defaultValue;this.statusBarVisible=false;this.preferredWidth=intVal(width||360);this.preferredHeight=intVal(height||200);this.width=this.preferredWidth;this.height=this.preferredHeight;}
JUIDialogWindow.makeDialog=function(msg,title,options,callback,width,height)
{var dlg=new JUIDialogWindow(msg,title,options,callback,width,height);dlg.init();return dlg;}
JUIDialogWindow.prototype.init=function()
{JUIDialogWindow.superClass.init.call(this);var _this=this;this.content=new JUIHtmlNode(JUI.getTemplateInstance(this.constructor.templates.content));var messageArea=this.content.html.messageArea;insertHTML(messageArea,nl2br(this.message));var cp=this.getContentPane();cp.add(this.content);cp.setScrolling(JUI.SCROLL_NONE);this.setSize(this.width,this.height);this.initButtons();this.showIcon();}
JUIDialogWindow.prototype.initButtons=function()
{var _this=this;var cp=this.getContentPane();var button,b,buttonWidth=80,buttonHeight=24;var c=this.options.buttons.length;var w=this.preferredWidth;var h=this.preferredHeight;var interleave=(w-buttonWidth*c)/(c-1+4);for(var i=0;i<c;i++){b=this.options.buttons[i];button=this.createElement("BUTTON");with(button.style){position="absolute";left=interleave*2+i*(buttonWidth+interleave);top=h-(buttonHeight+45+5);width=buttonWidth;height=buttonHeight;}
button.returnValue=b.value;button.appendChild(createText(b.caption));button.onclick=function(){_this.returnValue=this.returnValue;_this.close();};cp.add(button);}}
JUIDialogWindow.prototype.setMessageType=function(messageType)
{this.messageType=intVal(varDefault(messageType,JUIDialogWindow.INFO));if(this.root!=null)this.showIcon();if(this.options.buttons==null){switch(this.messageType){case JUIDialogWindow.INPUT:this.options.buttons=[{value:1,caption:_("OK")},{value:null,caption:_("Cancel")}];break;case JUIDialogWindow.QUESTION:this.options.buttons=[{value:1,caption:_("Yes")},{value:0,caption:_("No")}];break;case JUIDialogWindow.FREE:this.options.buttons=[{value:1,caption:_("Yes")},{value:0,caption:_("No")},{value:1001,caption:_("Visit Wixi")},{value:null,caption:_("Later")}];break;case JUIDialogWindow.INFO:case JUIDialogWindow.ALERT:case JUIDialogWindow.ERROR:default:this.options.buttons=[{value:1,caption:_("OK")}];}}}
JUIDialogWindow.prototype.showIcon=function()
{var iconSrc;if(this.options.icon){iconSrc=this.options.icon;}
else{var iconImages=new Object();iconImages[JUIDialogWindow.INFO]="info_48.gif";iconImages[JUIDialogWindow.ERROR]="error_48.gif";iconImages[JUIDialogWindow.ALERT]="alert_48.gif";iconImages[JUIDialogWindow.QUESTION]="question_48.gif";iconImages[JUIDialogWindow.INPUT]="input_48.gif";iconSrc=iconImages[this.messageType]||"";if(iconSrc!="")
iconSrc=getImageURL("/skins/"+JUI.currentSkin+"/JUIDialogWindow/"+iconSrc);}
this.content.html.icon.src=iconSrc;this.content.html.icon.style.display=(iconSrc!="")?"":"none";}
JUIDialogWindow.prototype.setOwner=function(owner)
{this.owner=owner;}
JUIDialogWindow.prototype.setCallback=function(callback)
{if(callback!=null&&typeof(callback)!="function")
throw"JUIDialogWindow.setCallback: Callback must be a function";this.callback=callback||null;}
JUIDialogWindow.prototype.setResizable=function(resizable){}
JUIDialogWindow.prototype.close=function()
{if(this.callback)this.callback(this,this.returnValue);JUIDialogWindow.superClass.close.call(this);}
JUIInputWindow.extend(JUIDialogWindow);JUIInputWindow.templates={base:"JUIWindow",content:"JUIInputWindow"};function JUIInputWindow(message,title,options,callback,width,height)
{JUIInputWindow.superConstructor.call(this,message,title,options,callback,width,height);this.returnValue="";}
JUIInputWindow.makeDialog=function(msg,title,options,callback,width,height)
{var dlg=new JUIInputWindow(msg,title,options,callback,width,height);dlg.init();return dlg;}
JUIInputWindow.prototype.init=function(htmlNode)
{JUIInputWindow.superClass.init.call(this,htmlNode);var _this=this;var cp=this.getContentPane();this.textInput=this.content.html.textInput;JUI.makeSelectable(this.textInput);this.textInput.onkeypress=function(evt){evt=evt||window.event;var keyCode=evt.keyCode;if(keyCode==13){LD.Event.cancel(evt);_this.returnValue=this.value||"";_this.close();}}
if(!this.width&&!this.height)
this.setSize(400,256);else
this.setSize(this.width,this.height);this.textInput.value=this.defaultValue;this.textInput.select();}
JUIInputWindow.prototype.initButtons=function()
{var _this=this;var cp=this.getContentPane();var button,b,buttonWidth=80,buttonHeight=24;var c=this.options.buttons.length;var w=this.preferredWidth;var h=this.preferredHeight;var interleave=(w-buttonWidth*c)/(c-1+4);for(var i=0;i<c;i++){b=this.options.buttons[i];button=this.createElement("BUTTON");with(button.style){position="absolute";left=interleave*2+i*(buttonWidth+interleave);top=h-(buttonHeight+45+5);width=buttonWidth;height=buttonHeight;}
button.returnValue=b.value;button.appendChild(createText(b.caption));button.onclick=function(){if(this.returnValue!=null)
_this.returnValue=_this.textInput.value||"";else
_this.returnValue="";_this.close();};cp.add(button);}}
JUIInputWindow.prototype.setVisible=function(visible)
{JUIInputWindow.superClass.setVisible.call(this,visible);if(this.visible==true)
this.textInput.focus();}

/*========== JUIWindowPlugin.js ==========*/

JUIWindowPlugin.extend(JUIContainer);function JUIWindowPlugin(id)
{JUIWindowPlugin.superConstructor.call(this);}
JUIWindowPlugin.prototype.init=function()
{var root=this.createElement("DIV");this.root=root;root.className="JUIWindowPlugin";with(root.style){position="absolute";left=0;top=0;display="";overflow="hidden";}
this.initComponents();}
JUIWindowPlugin.prototype.initComponents=function()
{}
JUIWindowPlugin.prototype.reset=function()
{}

/*========== JUISearch.js ==========*/

JUISearch.extend(JUIComponent);JUISearch.EVT_SEARCH_FINISHED=12001;JUISearch.lastId=0;function JUISearch(path,recursive)
{JUISearch.superConstructor.call(this);this.id=JUISearch.nextId();this._ajax=new R31Ajax();this.setPath(varDefault(path,"/"));this.setRecursive(recursive);this.setSearchExpression("");this.searchInput=null;this.goButton=null;}
JUISearch.nextId=function()
{return++this.lastId;}
JUISearch.prototype.init=function(htmlNode)
{JUISearch.superClass.init.call(this,htmlNode);var _this=this,searchInput,searchButton;if(htmlNode){searchInput=this.searchInput=this.html.searchInput;searchButton=this.searchButton=this.html.searchButton;}
else{var root=this.createElement("DIV");this.root=root;with(root.style){position="absolute";overflow="hidden";width="100%";height=this.height;padding=2;}
searchInput=this.createElement("INPUT","text");this.searchInput=searchInput;searchInput.className="JUISearch";with(searchInput.style){width="120px";height="20px";color="#888888";font="normal 10px Verdana, Helvetica, Sans serif";}
var btn=JUI.makeButton(18,"",getImageURL("/skins/"+JUI.currentSkin+"/JUISearch/go.gif"),"Perform Search");this.searchButton=searchButton=btn.getRoot();with(searchButton.style){position="absolute";top="3px";left="125px";}
root.appendChild(searchInput);insertHTML(root,"&nbsp;");root.appendChild(searchButton);}
searchInput.onfocus=function(){if(this.value==_this.emptyText)
this.value="";}
searchInput.onkeypress=function(evt){evt=evt||window.event;var keyCode=evt.keyCode;if(keyCode==13){LD.Event.cancel(evt);_this.searchButton.onclick();}}
searchInput.onblur=function(){if(this.value==""){this.value=_this.emptyText||"";}}
searchButton.onclick=function(){var exp=varDefault(_this.searchInput.value,"");if(exp!=""&&exp!=_this.emptyText)_this.search(exp);}}
JUISearch.prototype.setEmptyText=function(emptyText)
{this.emptyText=emptyText||"";if(!this.root)return;this.searchInput.value=emptyText;}
JUISearch.prototype.setArgument=function(name,value)
{if(!name)throw"JUISearch.setArgument: must provide a name for request argument";this.requestArguments[name]=value;}
JUISearch.prototype.clearArguments=function(name)
{if(name!=null)
delete this.requestArguments[name.toString()];else
this.requestArguments=new Object();}
JUISearch.prototype.getPath=function()
{return this.path;}
JUISearch.prototype.setPath=function(path)
{this.path=varDefault(path,"/");}
JUISearch.prototype.isRecursive=function()
{return this.recursive;}
JUISearch.prototype.setRecursive=function(recursive)
{this.recursive=(recursive==true);}
JUISearch.prototype.getSearchExpression=function()
{return this.searchExpression;}
JUISearch.prototype.setSearchExpression=function(searchExpression)
{searchExpression=varDefault(searchExpression,"");if(this.searchInput)
this.searchInput.value=searchExpression;this.userSearchExpression=searchExpression;searchExpression=searchExpression.replace(new RegExp("\\.","g"),"\\.");searchExpression=searchExpression.replace(new RegExp("\\*","g"),".*");searchExpression=searchExpression.replace(new RegExp("\\?","g"),".");this.searchExpression=searchExpression;}
JUISearch.prototype.search=function(searchExpression)
{this.setSearchExpression(searchExpression);var _this=this;this._ajax.clearArguments();this._ajax.setArgument("cmd","search");this._ajax.setArgument("path",this.path);this._ajax.setArgument("searchExp",this.searchExpression);this._ajax.setArgument("recurse",this.recursive?'1':'0');this._ajax.setSuccessCallback(function(socket)
{var result=socket.response;if(!result)return;var matches=null,match,ancestor,ancestorParent;if(result.matches&&result.ancestors){for(var i=0;i<result.ancestors.length;i++){for(var id in result.ancestors[i]){ancestor=FileSystemNode.build(result.ancestors[i][id]);if(FileSystem.getNode(ancestor.getId())==null)
FileSystem.insertNodeInTree(ancestor);}}
matches=new Array();for(var i=0;i<result.matches.length;i++){match=FileSystemNode.build(result.matches[i]);if(FileSystem.getNode(match.getId())==null)
FileSystem.insertNodeInTree(match);matches.push(match);}}
_this.result=matches;var evt=new JUISearchResult(matches,{"path":_this.path,"searchExpression":_this.userSearchExpression});_this.fireEvent(evt,JUISearch.EVT_SEARCH_FINISHED);});this._ajax.send("room_provider.php");}
function JUISearchResult(matches,searchParams)
{this.matches=matches||new Object();this.searchParams=searchParams||new Object();}
JUISearchResult.prototype.getMatches=function()
{return this.matches||null;}
JUISearchResult.prototype.getChildren=JUISearchResult.prototype.getMatches;JUISearchResult.prototype.getSearchParams=function()
{return this.searchParams||null;}

/*========== JUIFlashClip.js ==========*/

JUIFlashClip.extend(JUIComponent);JUIFlashClip.EVT_MEDIA_LOADED=21001;function JUIFlashClip(source)
{JUIFlashClip.superConstructor.call(this);this.source=varDefault(source,"");this.flashObject=null;this.channel="default";if(this.source.indexOf("cnn")>=0)
this.channel="cnn";this.scriptAccess="sameDomain";}
JUIFlashClip.prototype.init=function(htmlNode,params)
{var root=this.createElement("DIV");this.root=root;if(this.source)this.generateClip(params);}
JUIFlashClip.prototype.dispose=function()
{JUIFlashClip.superClass.dispose.call(this);this.destroyClip();}
JUIFlashClip.prototype.generateClip=function(params)
{if(!this.root)return;params=aggregate({width:"100%",height:"100%"},params);if(typeof(params.allowScriptAccess)=="undefined")
params.allowScriptAccess=this.scriptAccess||"never";if(typeof(params.allowFullScreen)=="undefined")
params.allowFullScreen="true";if(typeof(params.WMODE)=="undefined")
params.WMODE="opaque";var id="JUIFlashClip_"+this.getComponentId();var html="";if(this.channel=="default"){html='<object id="'+id+'" type="application/x-shockwave-flash"'+' pluginspage="http://www.macromedia.com/go/getflashplayer"\r\n';if(!Browser.isIE){html+=' data="'+this.source+'"';}
for(var k in params){html+=(' '+k+'="'+params[k]+'"');}
html+='>';html+='\r\n\t<param name="movie" value="'+this.source+'">\r\n';for(var k in params){html+=('\t<param name="'+k+'" value="'+params[k]+'">\r\n');}
html+='</object>';}
else if(this.channel=="cnn"){html='<iframe src="'+this.source+'" height="393" width="406" allowtransparency="true" frameborder="0" scrolling="no"></iframe>';}
this.root.innerHTML=html;this.flashObject=this.root.firstChild;if(!this.flashObject||this.flashObject.nodeType!=LD.NODE_ELEMENT)
throw"JUIFlashClip.generateClip: Could not get reference to Flash object";this.flashObject.style.zIndex=1;this.waitForAvailability();}
JUIFlashClip.prototype.destroyClip=function()
{if(this.flashObject!=null){for(var x in this.flashObject){if(typeof(this.flashObject[x])=="function")
try{this.flashObject[x]=function(){};}catch(e){}}}
this.flashObject=null;this.root.innerHTML="";}
JUIFlashClip.prototype.loadMedia=function(url)
{this.source=url;this.generateClip();}
JUIFlashClip.prototype.waitForAvailability=function()
{var loopCaller=function(){var _func=arguments.callee;if(_func.player.isAvailable()){var evt=new Object();_func.player.fireEvent(evt,JUIFlashClip.EVT_MEDIA_LOADED);}
else{if(_func.attemptCount++<20)setTimeout(_func,200);}}
loopCaller.attemptCount=0;loopCaller.attemptLimit=40;loopCaller.player=this;loopCaller();}
JUIFlashClip.prototype.isAvailable=function()
{return(this.flashObject!=null&&typeof(this.flashObject.SetVariable)!="undefined");}
JUIFlashClip.prototype.sendVar=function(name,value)
{name=varDefault(name,"").toString();if(name=="")
throw"JUIFlashClip.sendVar: Must provide a variable name";if(!this.flashObject)return false;value=varDefault(value,"").toString();this.flashObject.SetVariable(name,value);return true;}

/*========== R31OS.js ==========*/

var R31ClassRegistry=aggregate(new LD.Proto(),{registry:new Object,get:function(id)
{if(typeof(id)!="string"||id.length!=16)
throw"R31ClassRegistry.get: ID must be a 16-byte hexadecimal string";return this.registry[id]||null;},register:function(id,constructor)
{if(typeof(id)!="string"||id.length!=16)
throw"R31ClassRegistry.register: ID must be a 16-byte hexadecimal string";if(!constructor||typeof(constructor)!="function")
throw"R31ClassRegistry.register: constructor argument must be a constructor function";this.registry[id]=constructor;}});function PreferencePage()
{}
PreferencePage.prototype.get=function(classId,objectId)
{if(!classId||!objectId)
throw"PreferencePage.getPreferences: Must specify classId and objectId";var cp=this[classId];if(!cp)return null;return cp[objectId]||null;}
PreferencePage.prototype.set=function(classId,objectId,value)
{if(!classId||!objectId)
throw"PreferencePage.getPreferences: Must specify classId and objectId";if(typeof(this[classId])=="undefined")this[classId]=new Object();this[classId][objectId]=value||null;}
PreferencePage.prototype.remove=function(classId,objectId)
{if(!classId||!objectId)
throw"PreferencePage.getPreferences: Must specify classId and objectId";var cp=this[classId];if(!cp)return;delete cp[objectId];}
R31DesktopShell=new LD.Proto();R31DesktopShell.actions=new Object();R31DesktopShell.registerAction=function(targetClass,verb,callback,callbackObject,params)
{if(verb==""||typeof(verb)!="string"){throw"R31DesktopShell.registerAction: Must provide a verb that describes the action";}
if(!callback||typeof(callback)!="function"){throw"R31DesktopShell.registerAction: Must provide a callback function to handle the action";}
var className=targetClass?targetClass.getName():"anonymous";params=varDefault(params,null);if(!this.actions[className])this.actions[className]=new Object();this.actions[className][verb]={"callback":callback,"object":callbackObject||null,"params":params};}
R31DesktopShell.doAction=function(verb,object,params,callback)
{if(verb==""||typeof(verb)!="string")
throw"R31DesktopShell.doAction: Must provide the action verb";if(!object||typeof(object)!="object")
throw"R31DesktopShell.doAction: Must provide the object for the action";var match=null;var constructor=object.constructor;var constructorName;var actionClass;while(match==null&&typeof(constructor)=="function"){constructorName=varDefault(constructor.getName(),"anonymous");for(actionClass in this.actions){if(actionClass==constructorName&&this.actions[actionClass][verb]){match=this.actions[actionClass][verb];break;}}
constructor=constructor.superConstructor;}
if(match==null)return false;match.callback.call(match.object,object,params,callback);return true;}
R31DesktopShell.unauthorizedRequest=function(evt)
{if(!evt)return;if(evt.statusCode==401){if(evt.reason=="SessionExpired")
this.fireEvent(evt,R31.EVT_SESSION_EXPIRED);}}
R31User.extend(LD.Proto);R31User.FRIENDSHIP_NONE=0;R31User.FRIENDSHIP_ACCEPTED=1;R31User.FRIENDSHIP_PENDING_SAME_USER=2;R31User.FRIENDSHIP_PENDING_OTHER_USER=3;R31User.PARAMETERS={HIDE_FRIENDSACTIVITY:'hidefriendsactivity'};function R31User(id,name,email,temp,firstName,lastName,avatar,wallpaper,pending,asker,starred)
{R31User.superConstructor.call(this);this.id=id||null;this.name=varDefault(name,"");this.room=this.name;this.email=varDefault(email,"");this.temp=(temp==true);this.premium=false;this.firstName=varDefault(firstName,"");this.lastName=varDefault(lastName,"");this.avatar=varDefault(avatar,"");this.wallpaper=varDefault(wallpaper,"");this.pending=(pending==true);this.asker=intVal(asker);this.gender=0;this.tags="";this.selfDescription="";this.zip="";this.birthDate=null;this.publicProfile=false;this.searchableFiles=false;this.parameters={};this.starred=starred;}
R31User.build=function(data)
{if(!isObject(data))return null;var user=new R31User(data.id,data.name,data.email,data.temp,data.firstName,data.lastName,data.avatar,data.wallpaper,data.pending,data.asker);if(!user)return null;user.premium=(data.premium==true);user.country=intVal(data.country);user.city=data.city||"";user.gender=intVal(data.gender);user.tags=data.tags||"";user.selfDescription=data.selfDescription;user.zip=data.zip||"";user.birthDate=data.birthDate||null;user.publicProfile=(data.publicProfile==true);user.searchableFiles=(data.searchableFiles==true);user.dateRegistered=data.dateRegistered;user.starred=data.starred;return user;}
R31User.prototype.getId=function()
{return this.id;}
R31User.prototype.getName=function()
{return this.name;}
R31User.prototype.getRoom=function()
{return this.room;}
R31User.prototype.isTemp=function()
{return this.temp;}
R31User.prototype.isPremium=function()
{return this.premium;}
R31User.prototype.getAvatar=function()
{return this.avatar;}
R31User.prototype.getWallpaper=function()
{return this.wallpaper;}
R31User.prototype.isPending=function()
{return this.pending;}
R31User.prototype.isStarred=function()
{return this.starred;}
R31User.prototype.getFriendshipStatus=function()
{if(this.pending){if(this.asker==this.id)
return R31User.FRIENDSHIP_PENDING_OTHER_USER;else
return R31User.FRIENDSHIP_PENDING_SAME_USER;}
else{if(this.asker)
return R31User.FRIENDSHIP_ACCEPTED;else
return R31User.FRIENDSHIP_NONE;}}
R31User.prototype.getAsker=function()
{return this.asker;}
var friendsOfCache={};R31User.prototype.isFriend=function(user,callMe)
{if(user instanceof R31User)
{user=user.id;}
if(!friendsOfCache.hasOwnProperty(this.id)){friendsOfCache[this.id]={};}
if(friendsOfCache[this.id].hasOwnProperty(user)){if(typeof(callMe)!="undefined")
{callMe(friendsOfCache[this.id][user]);}
return}
var _this=this;var response;var ajax=new R31Ajax();ajax.clearArguments();ajax.setArgument({"cmd":"isFriend","id":this.id,"user":user});ajax.setSuccessCallback(function(socket)
{response=socket.response;if(response!==true)
{response=false;}
friendsOfCache[_this.id][user]=response;if(typeof(callMe)!="undefined")
{callMe(response);}});ajax.send("room_provider.php");}
R31User.prototype.hasEnoughSpace=function(size,callMe)
{if(typeof(size)!="number")
throw"R31User.isFriend: size must be an integer";var response=false;var storageLimit=R31.getStorageLimit(this);if(storageLimit>0)
{FileSystem.getUsageStats(this.id,function(usageStats)
{if(usageStats!==false)
{var required=usageStats[1]+size;if(required<=storageLimit)
{response=true;}}
callMe(response);});}
else
{response=true;callMe(response);}}
R31User.prototype.setParameter=function(parameter,value,callMe)
{var ajax=new R31Ajax();ajax.clearArguments();ajax.setArgument({"cmd":"setUserParameter","id":this.id,"parameter":parameter,"value":Json.toString([value])});var _this=this;ajax.setSuccessCallback(function(socket)
{if(socket.response)
{_this.parameters[parameter]=value}
if(typeof(callMe)!="undefined")
{callMe(socket.response);}});ajax.send("room_provider.php");}
R31User.prototype.getParameter=function(parameter,callMe)
{if(typeof(callMe)=='undefined')
{return false;}
if(this.parameters.hasOwnProperty(parameter)){callMe(this.parameters[parameter]);}else{var ajax=new R31Ajax();ajax.clearArguments();ajax.setArgument({"cmd":"getUserParameter","id":this.id,"parameter":parameter});_this=this;ajax.setSuccessCallback(function(socket)
{var value=socket.response.pop();_this.parameters[parameter]=value;callMe(value);});ajax.send("room_provider.php");}}
R31User.prototype.preloadParameters=function(parameters)
{this.parameters=parameters;}
var R31UserRegistry=aggregate(new LD.Proto(),{userRegistry:{},loggedUser:null,currentRoom:null,friendshipRegistry:{},register:function(user,replace)
{if(!(user instanceof R31User)){throw"R31UserRegistry.register: must provide a R31User instance to register";}
if(replace==true||this.userRegistry[user.id]==null){this.userRegistry[user.id]=user;}},unregister:function(user)
{if(typeof(user)=="number")
delete this.userRegistry[user];else if(user instanceof R31User)
delete this.userRegistry[user.id];else
throw"R31UserRegistry.unregister: must provide a R31User instance or index to unregister";},getLoggedUser:function()
{return this.userRegistry[this.loggedUser]||null;},updateLoggedUserInfo:function(data)
{if(typeof(data)=='object'){for(var key in data){if(key in this.userRegistry[this.loggedUser])
this.userRegistry[this.loggedUser][key]=data[key];}}},setLoggedUser:function(user)
{if(user!==null&&!(user instanceof R31User))
throw"R31UserRegistry.setLoggedUser: must provide a R31User instance";if(user==null){this.loggedUser=0;}
else{this.register(user,true);this.loggedUser=user.id;}},getCurrentRoom:function()
{return this.userRegistry[this.currentRoom]||null;},setCurrentRoom:function(room)
{if(room!==null&&!(room instanceof R31User))
throw"R31UserRegistry.setCurrentRoom: must provide a R31User instance";if(room==null){this.currentRoom=0;}
else{this.register(room,true);this.currentRoom=room.id;}},changeFriendStatus:function(user,friend,status){if(!(user instanceof R31User)){throw"R31FriendshipRegistry.setFriendship: user and friend must be R31User instances";}
R31UserRegistry.userRegistry[friend].pending=status;},setFriendship:function(user,friend,reciprocate)
{if(!(user instanceof R31User)||!(friend instanceof R31User))
throw"R31FriendshipRegistry.setFriendship: user and friend must be R31User instances";if(this.friendshipRegistry[user.id]==null)
this.friendshipRegistry[user.id]=new Array();if(!inArray(this.friendshipRegistry[user.id],friend.id))
this.friendshipRegistry[user.id].push(friend.id);if(reciprocate==true)
arguments.callee.call(this,friend,user,false);this.register(user);this.register(friend);},removeFriendship:function(user,friend,reciprocate)
{if(!(user instanceof R31User)||!(friend instanceof R31User))
throw"R31FriendshipRegistry.removeFriendship: user and friend must be R31User instances";if(this.friendshipRegistry[user.id])
this.friendshipRegistry[user.id]=arrayRemove(this.friendshipRegistry[user.id],friend.id);if(reciprocate==true)
arguments.callee.call(this,friend,user,false);},starFriend:function(user,friend,star)
{if(!(user instanceof R31User)||!(friend instanceof R31User))
throw"R31FriendshipRegistry.setFriendship: user and friend must be R31User instances";friend.starred=star;this.register(friend,true);},getUserFriends:function(user,pending,onlyPending)
{var reg,aux,friend;if(user instanceof R31User)
reg=this.friendshipRegistry[user.id]||new Array();else
reg=this.friendshipRegistry[intVal(user)]||new Array();aux=new Array();for(var i=0;i<reg.length;i++){friend=this.userRegistry[reg[i]];if(friend!=null&&(friend.isPending()==false||pending==true)){aux.push(friend);}}
return aux;},getUserPendingFriends:function(user){var reg,aux,friend;if(user instanceof R31User)
reg=this.friendshipRegistry[user.id]||new Array();else
reg=this.friendshipRegistry[intVal(user)]||new Array();aux=new Array();for(var i=0;i<reg.length;i++){friend=this.userRegistry[reg[i]];if(friend!=null&&(friend.isPending()==true)){aux.push(friend);}}
return aux;}});var R31UserStats=aggregate(new LD.Proto(),{stats:{},get:function(user)
{var userId=(user instanceof R31User)?user.id:intVal(userId);return this.stats[userId]||null;},put:function(user,stats)
{var userId=(user instanceof R31User)?user.id:intVal(userId);if(userId<1)
throw"R31UserStats.setUserStats: user must be a R31User instance or an integer > 0";if(typeof(stats)!="object")
throw"R31UserStats.setUserStats: stats must be an object or null";this.stats[userId]=stats;}});var R31TrashBin=newClass("R31TrashBin",FileSystemDirectory,function(name)
{arguments.callee.superConstructor.call(this,name);},{displayName:__("Trash Bin")},{getDisplayName:function()
{return R31TrashBin.displayName;}});R31Ajax.extend(AjaxSocket);R31Ajax.EVT_UNAUTHORIZED=7101;function R31Ajax()
{R31Ajax.superConstructor.call(this);}
R31Ajax.prototype.onError=function()
{if(!this.request)return;var statusCode=this.getStatusCode();if(statusCode==401){var evt={statusCode:statusCode,reason:this.request.getResponseHeader("reason")};R31DesktopShell.unauthorizedRequest(evt);}}
var R31SessionKeeper={interval:null,ajax:null,urls:new Array,init:function(interval)
{this.ajax=new AjaxSocket();this.urls=new Array();this.setInterval(interval);this.sid=LD.Cookie.get("PHPSESSID");},addUrl:function(url)
{if(!url)return false;this.urls.push(url);},clearUrls:function(url)
{this.urls=new Array();},start:function(interval)
{this.stop();if(!this.ajax)
this.init(interval);else if(interval!=null)
this.setInterval(interval);var _this=this;this.ajax.setArgument("sid",this.sid);this.thread=setInterval(function(){_this.send();},this.interval);},stop:function()
{if(this.thread!=null){clearInterval(this.thread);this.thread=null;}},setInterval:function(interval)
{this.interval=intVal(interval||600)*1000;},send:function()
{if(!this.ajax)return false;for(var i=0;i<this.urls.length;i++){this.ajax.send(this.urls[i]);}}}
function sumOrd(s){var r=0;for(var i=0;i<s.length;i++){r+=s.charCodeAt(i);}
return r;}

/*========== R31.js ==========*/

R31=new LD.Proto();R31.ACTION_OPEN="open";R31.ACTION_FILE_SAVE_AS="save_as";R31.ACTION_FS_NODE_COPY="copy";R31.ACTION_FS_NODE_ADD="add";R31.ACTION_FS_NODE_DUPLICATE="duplicate";R31.ACTION_FS_NODE_SET_ACCESS="set_access";R31.ACTION_FILE_EDIT="edit";R31.ACTION_FS_NODE_RENAME="rename";R31.ACTION_FS_NODE_MOVE="move";R31.ACTION_FS_NODE_DELETE="delete";R31.ACTION_FS_NODE_UNDELETE="undelete_trash_node";R31.ACTION_FS_NODE_VOTE_INAPPROPRIATE="vote_inappropriate";R31.ACTION_EMPTY_TRASHBIN="empty_trash_bin";R31.ACTION_FILE_SHOW_DETAILS="show_details";R31.ACTION_FOLDER_CREATE="create_dir";R31.ACTION_FS_NODE_PLAY_MEDIA="play_media";R31.ACTION_UPLOAD="upload";R31.ACTION_DND_UPLOAD="dnd_upload";R31.ACTION_INVITE="invite";R31.ACTION_ADD_FRIEND="add_friend";R31.ACTION_DELETE_FRIEND="delete friend";R31.ACTION_SEND_MESSAGE="send_message";R31.ACTION_SEND_FEEDBACK="send_feedback";R31.ACTION_VIEW_PROFILE="view_profile";R31.ACTION_ONLY_VIEW_PROFILE="only_view_profile";R31.ACTION_REQUEST_FRIENDSHIP="ask_for_friendship";R31.ACTION_ANSWER_FRIENDSHIP="answer_friendship";R31.ACTION_REVOKE_FRIENDSHIP="cut_friendship";R31.ACTION_STAR_FRIEND="star_friend";R31.ACTION_SEARCH="search";R31.ACTION_SEARCH_USER="search_user";R31.ACTION_OPEN_TIPS_AND_TRICKS="tips_and_tricks";R31.ACTION_OPEN_WIXI_BOOKMARKLET="open_wixi_bookmarklet";R31.ACTION_BECOME_FRIEND="become_friend";R31.ACTION_OPEN_EXPLORER_WINDOW="open_explorer_window";R31.EVT_ACTION_PERFORMED=7001;R31.EVT_ACTION_CANCELLED=7002;R31.EVT_FILE_DROPPED=3001;R31.EVT_WINDOW_FILTER_CHANGED=3201;R31.EVT_LOGGED_USER_CHANGED=3301;R31.EVT_USER_LOGGED_IN=3302;R31.EVT_USER_LOGGED_OUT=3303;R31.EVT_USER_SIGNED_UP=3304;R31.EVT_USER_PROFILE_CHANGED=3305;R31.EVT_USER_REMOVED=3306;R31.EVT_SESSION_EXPIRED=3401;R31.ITEM_USER=1;R31.ITEM_VIDEO=2;R31.ITEM_IMAGE=3;R31.ITEM_AUDIO=4;R31.ACTIVITY_PLAY=1;R31.ACTIVITY_NODE_ADD=2;R31.ACTIVITY_UPLOAD=3;R31.ERR_NOT_LOGGED_IN=-1;R31.ERR_ALREADY_EXISTS=-2;R31.ERR_WRONG_PASSWORD=-3;R31.ERR_INVALID_DATA=-4;R31.ERR_UPLOAD_FAILED=-5;R31.DEFAULT_AVATAR=DIR_IMAGES+"avatar_default.jpg";R31.MEEBO_ENABLED=true;R31.isPlayableMedia=function(fsNode)
{if(fsNode.type==FileSystem.NODE_TYPE_LINK)
{if(fsNode.getTarget().indexOf('http://')=='0')
return false
else
return true;}
else
{var td=FileSystem.getTypeDescriptor(FileSystem.getExtension(fsNode.getTarget()));if(td==null)return false;var type=td.getMimeType();return(type=="image"||type=="audio"||type=="video");}}
R31.Date={shortWeekDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],longWeekDays:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],longMonths:["January","February","March","April","May","June","July","August","September","October","November","December"],_formatters:{d:function(dt){return dt.getDate().toString().padLeft(2,"0");},D:function(dt){return R31.Date.shortWeekDays[dt.getDay()];},l:function(dt){return R31.Date.longWeekDays[dt.getDay()];},m:function(dt){return(dt.getMonth()+1).toString().padLeft(2,"0");},n:function(dt){return(dt.getMonth()+1);},M:function(dt){return(R31.Date.shortMonths[dt.getMonth()]||"");},F:function(dt){return(R31.Date.longMonths[dt.getMonth()]||"");},y:function(dt){return dt.getYear().toString().padLeft(2,"0");},Y:function(dt){return dt.getFullYear().toString().padLeft(4,"0");},H:function(dt){return dt.getHours().toString().padLeft(2,"0");},h:function(dt){return(dt.getHours()%12).toString().padLeft(2,"0");},i:function(dt){return dt.getMinutes().toString().padLeft(2,"0");},s:function(dt){return dt.getSeconds().toString().padLeft(2,"0");}},format:function(formatter,date)
{formatter=(formatter!=null)?formatter.toString():"m/d/Y";var dt=(date instanceof Date)?date:new Date();var res="",c;for(var i=0;i<formatter.length;i++){c=formatter.charAt(i);res=res.concat((this._formatters[c]!=null)?this._formatters[c](dt):c);}
return res;}}
R31.Gender={toString:function(gender)
{if(gender==1)return __("Male");if(gender==2)return __("Female");return"";}}
R31.Countries={3:__("Afghanistan"),4:__("Albania"),6:__("Algeria"),7:__("American Samoa"),8:__("Andorra"),10:__("Angola"),11:__("Anguilla"),9:__("Antartic"),12:__("Antigua & Barbuda"),14:__("Argentina"),13:__("Armenia"),15:__("Aruba"),17:__("Australia"),18:__("Austria"),16:__("Azerbaijan"),20:__("Bahamas"),19:__("Bahrain"),22:__("Bangladesh"),21:__("Barbados"),23:__("Belarus"),24:__("Belgium"),25:__("Belize"),26:__("Benin"),27:__("Bermuda"),28:__("Bhutan"),29:__("Bolivia"),30:__("Bonaire"),32:__("Bosnia & Herzegovina"),33:__("Botswana"),34:__("Brazil"),35:__("British Indian Ocean Territories"),36:__("Brunei"),37:__("Bulgaria"),38:__("Burkina Faso"),39:__("Burundi"),40:__("Cambodia"),41:__("Cameroon"),42:__("Canada"),43:__("Canary Islands"),44:__("Cape Verde"),46:__("Cayman Islands"),47:__("Central African Republic"),48:__("Chad"),49:__("Channel Islands"),50:__("Chile"),251:__("China"),52:__("Christmas Island"),53:__("Cocos Island"),54:__("Colombia"),55:__("Comoros"),56:__("Congo"),58:__("Cook Islands"),59:__("Costa Rica"),60:__("Cote D'Ivoire"),62:__("Croatia"),63:__("Cuba"),64:__("Curacao"),65:__("Cyprus"),184:__("Czech Republic"),57:__("Denmark"),66:__("Djibouti"),67:__("Dominica"),68:__("Dominican Republic"),69:__("East Timor"),70:__("Ecuador"),61:__("Egypt"),72:__("El Salvador"),75:__("Equatorial Guinea"),76:__("Etrea"),77:__("Estonia"),78:__("Ethiopia"),79:__("Falkland Islands"),80:__("Faroe Islands"),81:__("Fiji"),73:__("Finland"),74:__("France"),88:__("French Guiana"),82:__("French Polynesia"),83:__("French Southern Territory"),84:__("Gabon"),85:__("Gambia"),86:__("Georgia"),5:__("Germany"),87:__("Ghana"),89:__("Gibraltar"),90:__("Great Britain"),91:__("Greece"),92:__("Greenland"),93:__("Grenada"),94:__("Guadeloupe"),95:__("Guam"),98:__("Guatemala"),99:__("Guinea"),100:__("Guyana"),101:__("Haiti"),102:__("Hawaii"),103:__("Honduras"),104:__("Hong Kong"),96:__("Hungary"),106:__("Iceland"),97:__("India"),107:__("Indonesia"),108:__("Iran"),109:__("Iraq"),110:__("Ireland"),111:__("Isle of Man"),112:__("Israel"),113:__("Italy"),114:__("Jamaica"),124:__("Japan"),115:__("Jordan"),116:__("Kazakhstan"),117:__("Kenya"),118:__("Kiribati"),51:__("Korea North"),119:__("Korea South"),120:__("Kuwait"),121:__("Kyrgyzstan"),122:__("Laos"),123:__("Latvia"),125:__("Lebanon"),126:__("Lesotho"),127:__("Liberia"),128:__("Libya"),129:__("Liechtenstein"),139:__("Lithuania"),130:__("Luxembourg"),131:__("Macau"),132:__("Macedonia"),133:__("Madagascar"),134:__("Malaysia"),135:__("Malawi"),136:__("Maldives"),137:__("Mali"),138:__("Malta"),140:__("Marshall Islands"),141:__("Martinique"),142:__("Mauritania"),143:__("Mauritius"),151:__("Mayotte"),144:__("Mexico"),145:__("Midway Islands"),146:__("Moldova"),148:__("Monaco"),149:__("Mongolia"),150:__("Montserrat"),147:__("Morocco"),152:__("Mozambique"),153:__("Myanmar"),154:__("Nambia"),155:__("Nauru"),156:__("Nepal"),157:__("Netherland Antilles"),158:__("Netherlands"),159:__("Nevis"),168:__("New Caledonia"),160:__("New Zealand"),161:__("Nicaragua"),162:__("Niger"),163:__("Nigeria"),164:__("Niue"),165:__("Norfolk Island"),166:__("Norway"),167:__("Oman"),173:__("Pakistan"),169:__("Palau Island"),170:__("Palestine"),171:__("Panama"),172:__("Papua New Guinea"),174:__("Paraguay"),175:__("Peru"),176:__("Philippines"),177:__("Pitcairn Island"),178:__("Poland"),179:__("Portugal"),180:__("Puerto Rico"),181:__("Qatar"),188:__("Reunion"),190:__("Romania"),183:__("Russia"),185:__("Rwanda"),186:__("St Barthelemy"),187:__("St Eustatius"),189:__("St Helena"),191:__("St  Kitts-Nevis"),192:__("St Lucia"),193:__("St Maarten"),194:__("St Pierre & Miquelon"),195:__("St Vincent & Grenadines"),196:__("Saipan"),197:__("Samoa"),198:__("Samoa American"),199:__("San Marino"),200:__("Sao Tome & Principe"),201:__("Saudi Arabia"),203:__("Senegal"),204:__("Seychelles"),202:__("Serbia & Montenegro"),206:__("Sierra Leone"),205:__("Singapore"),207:__("Slovakia"),208:__("Slovenia"),209:__("Solomon Islands"),210:__("Somalia"),211:__("South Africa"),213:__("Spain"),214:__("Sri Lanka"),215:__("Sudan"),216:__("Suriname"),217:__("Swaziland"),218:__("Sweden"),212:__("Switzerland"),219:__("Syria"),220:__("Tahiti"),221:__("Taiwan"),222:__("Tajikistan"),223:__("Tanzania"),224:__("Thailand"),225:__("Togo"),226:__("Tokelau"),228:__("Tonga"),229:__("Trinidad & Tobago"),230:__("Tunisia"),227:__("Turkey"),231:__("Turkmenistan"),232:__("Turks & Caicos Is"),233:__("Tuvalu"),234:__("Uganda"),235:__("Ukraine"),236:__("United Arab Emirates"),182:__("United Kingdom"),1:__("United States of America"),237:__("Uruguay"),238:__("Uzbekistan"),239:__("Vanuatu"),240:__("Vatican City State"),241:__("Venezuela"),242:__("Vietnam"),243:__("Virgin Islands (Brit)"),244:__("Virgin Islands (USA)"),245:__("Wake Island"),246:__("Wallis & Futana Is"),247:__("Yemen"),248:__("Zaire"),249:__("Zambia"),250:__("Zimbabwe")};R31.defaultFilterCallback=function(fsNode,regExp)
{if(fsNode.getType()==FileSystem.NODE_TYPE_DIR)return true;var ok=fsNode.isAvailable();if(regExp!=null)ok=ok&&regExp.test(fsNode.getName());};R31.getStorageLimit=function(user)
{var premium=(user!=null&&user.premium==true);return premium?QUOTA_PREMIUM:QUOTA_FREE;};R31.getStorageMeasure=function(magnitude,decimalPlaces)
{var units=["B","KB","MB","GB","TB"];magnitude=intVal(magnitude);var aux=magnitude;var unitGroup=0;var limit=units.length-1;while(Math.abs(aux)>=1024&&unitGroup<limit){aux=aux/1024;++unitGroup;}
return[round(aux,varDefault(decimalPlaces,3)),units[unitGroup]];}
UserProvider={getLoggedUser:function(){},getLoggedUserRoot:function(){}};UserFriendsProvider={getLoggedUserFriends:function(){}};FriendsProvider={getFriends:function(){}};RoomProvider={getCurrentRoom:function(){},getCurrentRoomRoot:function(){}};RoomFriendsProvider={getCurrentRoomFriends:function(){}};RoomVisitorsProvider={getLastVisitors:function(){}};

/*========== R31Exception.js ==========*/

LD.ExceptionManager=function()
{this.userCallback='';this.userListener='';}
LD.ExceptionManager.addListener=function(source,eventType,callback,listener)
{if(callback&&listener)
{this.userCallback=callback;this.userListener=listener;}
LD.EventDispatcher.add(source,this,eventType,LD.ExceptionManager.handleException);}
LD.ExceptionManager.handleException=function(evt,type,src)
{var handled=false;if(evt instanceof LD.Exception)
{handled=evt.handle();}
if(!handled&&this.userCallback&&this.userListener)
{this.userCallback.call(this.userListener,evt,type,src);}}
LD.Exception=function(code,message,details,serverMessage)
{this.code=intVal(code);this.message=varDefault(message,"");this.details=details||null;this.serverMessage=serverMessage;}
LD.Exception.ERRNO_ENOTSUP=-10000;LD.Exception.ERRNO_ENOENT=-10001;LD.Exception.ERRNO_EACCES=-10002;LD.Exception.ERRNO_EISDIR=-10003;LD.Exception.ERRNO_ENOMEM=-10004;LD.Exception.ERRNO_EFBIG=-10005;LD.Exception.WIXI_SAMENODE=-11003;LD.Exception.WIXI_CENSORED=-11004;LD.Exception.WIXI_NOT_ORIGINAL=-11005;LD.Exception.WIXI_ENOFRIEND=-11000;LD.Exception.WIXI_SAMEUSER=-11001;LD.Exception.WIXI_ENOUSER=-11002;LD.Exception.prototype.getCode=function()
{return this.code;}
LD.Exception.prototype.getMessage=function()
{return this.message;}
LD.Exception.prototype.getDetails=function()
{return this.details;}
LD.Exception.prototype.getServerMessage=function()
{return this.serverMessage;}
LD.Exception.prototype.handle=function(title)
{var win=new R31Window(title,true,false,false,false);win.init();win.setBounds(250,50,550,350);win.setResizable(false);JUI.getTopContainer().add(win);win.setVisible(true);win.requestFocus();return true;}
LD.Exception.build=function(obj,message,details)
{if(!obj)throw"LD.Exception.prototype.build: Must provide an initialization object";var exception;var ex;switch(obj.code)
{case LD.Exception.ERRNO_ENOENT:exception=FileSystem.NodeNotFoundException;break;case LD.Exception.ERRNO_EACCES:exception=FileSystem.AccessDeniedException;break;case LD.Exception.ERRNO_EISDIR:exception=FileSystem.IsDirectoryException;break;case LD.Exception.ERRNO_ENOMEM:exception=FileSystem.NotEnoughSpaceException;break;case LD.Exception.ERRNO_EFBIG:exception=R31User.FileTooBigException;break;case LD.Exception.WIXI_SAMENODE:exception=FileSystem.SameNodeException;break;case LD.Exception.WIXI_CENSORED:exception=FileSystem.CensoredNodeException;break;case LD.Exception.WIXI_ENOFRIEND:exception=R31User.UserNotAFriendException;break;case LD.Exception.WIXI_SAMEUSER:exception=R31User.SameUserException;break;case LD.Exception.WIXI_ENOUSER:case LD.Exception.ERRNO_ENOTSUP:default:exception=LD.Exception;}
var ex=new exception(obj.code,message,details,obj.message);return ex;}
FileSystem.Exception=newClass("FileSystem.Exception",LD.Exception);FileSystem.Exception.prototype.handle=function()
{return false;}
FileSystem.IOException=newClass("FileSystem.IOException",FileSystem.Exception);FileSystem.InvalidUserException=newClass("FileSystem.InvalidUserException",FileSystem.IOException);FileSystem.IllegalOperationException=newClass("FileSystem.InvalidURLException",FileSystem.IOException);FileSystem.InvalidURLException=newClass("FileSystem.InvalidURLException",FileSystem.IOException);FileSystem.InvalidTargetException=newClass("FileSystem.InvalidTargetException",FileSystem.IOException);FileSystem.NodeNotFoundException=newClass("FileSystem.NodeNotFoundException",FileSystem.IOException);FileSystem.AccessDeniedException=newClass("FileSystem.AccessDeniedException",FileSystem.IOException);FileSystem.NodeAlreadyExistsException=newClass("FileSystem.NodeAlreadyExistsException",FileSystem.IOException);FileSystem.NodeNotOriginalException=newClass("FileSystem.NodeNotOriginalException",FileSystem.IOException);FileSystem.IsDirectoryException=newClass("FileSystem.IsDirectoryException",FileSystem.IOException);FileSystem.IsDirectoryException.prototype.handle=function()
{var details=this.details;var user=R31UserRegistry.getLoggedUser();var warning=new R31AddToWixi(details,user);warning.init();warning.setLocation(0,0);warning.setVisible(true);var win=new JUIWindow("Wixi",true,false,false,false);win.init();win.setVisible(true);win.setBounds(250,100,480,305);win.setResizable(false);win.setCloseAction(JUIWindow.DISPOSE_ON_CLOSE);win.getContentPane().add(warning);warning.addListener(R31.EVT_ACTION_PERFORMED,win.close,win);warning.addListener(R31.EVT_ACTION_CANCELLED,win.close,win);win.getContentPane().setScrolling(JUI.SCROLL_NONE);JUI.getTopContainer().add(win);win.requestFocus();}
FileSystem.NotEnoughSpaceException=newClass("FileSystem.NotEnoughSpaceException",FileSystem.IOException);FileSystem.NotEnoughSpaceException.prototype.handle=function()
{return FileSystem.NotEnoughSpaceException.superClass.handle(_('There is not enough space.'));}
FileSystem.CensoredrNodeException=newClass("FileSystem.CensoredNodeException",FileSystem.IOException);FileSystem.CensoredrNodeException.prototype.handle=function()
{return FileSystem.CensoredrNodeException.superClass.handle(_('Source file is censored.'));}
FileSystem.SameNodeException=newClass("FileSystem.SameNodeException",FileSystem.IOException);FileSystem.SameNodeException.prototype.handle=function()
{return FileSystem.SameNodeException.superClass.handle(_('Source and target are the same file.'));}
R31User.Exception=newClass("R31User.Exception",LD.Exception);R31User.SameUserException=newClass("R31User.SameUserException",R31User.Exception);R31User.SameUserException.prototype.handle=function()
{return R31User.SameUserException.superClass.handle(_('Both users are the same one.'));}
R31User.FileTooBigException=newClass("R31User.FileTooBigException",R31User.Exception);R31User.FileTooBigException.prototype.handle=function()
{R31DesktopShell.doAction(R31.ACTION_FS_NODE_ADD,this.details);}
R31User.UserNotAFriendException=newClass("R31User.UserNotAFriendException",R31User.Exception);R31User.UserNotAFriendException.prototype.handle=function()
{var details;if(this.details instanceof FileSystemNode)
{details=this.details;}
else if(this.details.node instanceof FileSystemNode)
{details=this.details.node;}
R31DesktopShell.doAction(R31.ACTION_BECOME_FRIEND,details);}
R31User.OriginalUploaderNotAFriendException=newClass("R31User.OriginalUploaderNotAFriendException",R31User.Exception);

/*========== R31Action.js ==========*/

function R31Action()
{}
R31Action.extend(LD.Proto);R31Action.COPY_NODE='CopyNode';R31Action.PLAY_NODE='PlayNode';R31Action.DOWNLOAD_NODE='DownloadNode';R31Action.DOWNLOAD_FROM_ROOM='DownloadFromRoom';R31Action.EVT_COPY_NODE=666;R31Action.EVT_PLAY_NODE=667;R31Action.EVT_DOWNLOAD_NODE=668;R31Action.EVT_DOWNLOAD_FROM_ROOM=669;R31Action.prototype.raiseError=function(error,eventCode)
{this.fireEvent(error,eventCode);}
R31Action.validate=function()
{var args=Array.prototype.slice.call(arguments);var actionCode=args.shift();if(!actionCode)
{throw"R31Action.validate needs the action id to check.";}
var actionClass=eval('R31Action_'+actionCode);var action=new actionClass;action.init.apply(action,args);action.validate();}
R31Action_CopyNode.extend(R31Action);function R31Action_CopyNode()
{}
R31Action_CopyNode.prototype.init=function(subject,object1,masterCallback)
{if(!(subject instanceof FileSystemNode)||!(object1 instanceof FileSystemNode))
{throw"R31Action_CopyNode: Subject and Object must be FileSystemNode instances.";}
this.subject=subject;this.object=object1;this.rLayer={'valid':true,'sameNode':true,'freeUsers':true,'friendship':false,'visible':true,'enoughSpace':false};this.masterCallback=masterCallback;var _this=this;this.finished=function()
{if(_this.rLayer.valid&&_this.rLayer.sameNode&&_this.rLayer.freeUsers&&_this.rLayer.friendship&&_this.rLayer.visible&&_this.rLayer.enoughSpace&&_this.masterCallback!=null)
{_this.masterCallback();_this.masterCallback=null;}}}
R31Action_CopyNode.prototype.validate=function()
{var _this=this;var error=false;if(this.subject.id<0&&this.subject.getType()!=FileSystem.NODE_TYPE_LINK)
{this.rLayer.valid=false;}
if(this.subject.id==this.object.id)
{this.raiseError(new FileSystem.SameNodeException(LD.Exception.WIXI_SAMENODE,_('Source and target are the same one.')),R31Action.EVT_COPY_NODE);this.rLayer.sameNode=false;error=true;}
var userObject=R31UserRegistry.getLoggedUser();if(!error&&(this.subject instanceof FileSystemDirectory)||(this.subject.getSize()>STREAMING_THRESHOLD))
{var today=new Date();var dateT=new Date();dateT.setFullYear(R31UserRegistry.getLoggedUser().dateRegistered.substr(0,4),(R31UserRegistry.getLoggedUser().dateRegistered.substr(5,2)-1),R31UserRegistry.getLoggedUser().dateRegistered.substr(8,2));dateT.setDate(dateT.getDate()+WIXI_RESTRICTION_WINDOW);if(true)
{if(!error&&(this.subject.owner!=this.object.owner))
{if(!error&&(!userObject.isPremium()&&this.subject instanceof FileSystemDirectory))
{this.raiseError(new FileSystem.IsDirectoryException(LD.Exception.ERRNO_EISDIR,_('Free users can\'t copy directories.'),this.subject),R31Action.EVT_COPY_NODE);this.rLayer.freeUsers=false;error=true;}
if(!error)
{userObject.isFriend(this.subject.owner,function(response)
{if(!response)
{_this.raiseError(new R31User.UserNotAFriendException(LD.Exception.WIXI_ENOFRIEND,_('User is not a friend, must become one first.'),_this.subject),R31Action.EVT_COPY_NODE);error=true;}
else
{_this.rLayer.friendship=true;}
_this.finished();});}
if(!error&&(!this.subject.isFriends()&&!this.subject.isPublic()))
{this.raiseError(new FileSystem.AccessDeniedException(LD.Exception.ERRNO_EACCES,_('Permission denied.')),R31Action.EVT_COPY_NODE);this.rLayer.visible=false;error=true;}}}
else
{this.rLayer.friendship=true;}}
else
{this.rLayer.friendship=true;}
if(!error)
{userObject.hasEnoughSpace(this.subject.getSize(),function(response)
{if(!response)
{_this.raiseError(new FileSystem.NotEnoughSpaceException(LD.Exception.ERRNO_ENOMEM,_('Permission denied.')),R31Action.EVT_COPY_NODE);error=true;}
else
{_this.rLayer.enoughSpace=true;}
_this.finished();});}
this.finished();}
R31Action_PlayNode.extend(R31Action);function R31Action_PlayNode()
{}
R31Action_PlayNode.prototype.init=function(subject,object1,masterCallback)
{if(!(subject instanceof FileSystemNode))
{throw"R31Action_PlayNode: Subject and Object must be a FileSystemNode instance.";}
if(!(object1 instanceof R31User))
{throw"R31Action_PlayNode: Object must be a R31User instances.";}
this.subject=subject;this.object=object1;this.rLayer={'visible':true,'freeUsers':true,'threshold':true};this.masterCallback=masterCallback;var _this=this;this.finished=function()
{if(_this.rLayer.visible&&_this.rLayer.freeUsers&&_this.rLayer.threshold&&_this.masterCallback!=null)
{_this.masterCallback();_this.masterCallback=null;}}}
R31Action_PlayNode.prototype.validate=function()
{var error=false;if(this.subject.owner!=this.object.id)
{var today=new Date();var dateT=new Date();dateT.setFullYear(R31UserRegistry.getLoggedUser().dateRegistered.substr(0,4),(R31UserRegistry.getLoggedUser().dateRegistered.substr(5,2)-1),R31UserRegistry.getLoggedUser().dateRegistered.substr(8,2));dateT.setDate(dateT.getDate()+WIXI_RESTRICTION_WINDOW);if(true)
{if(!this.subject.isFriends()&&!this.subject.isPublic())
{this.raiseError(new FileSystem.AccessDeniedException(LD.Exception.ERRNO_EACCES,_('Permission denied.')),R31Action.EVT_PLAY_NODE);this.rLayer.visible=false;error=true;}
if(!error&&(this.subject instanceof FileSystemDirectory))
{this.raiseError(new FileSystem.IsDirectoryException(LD.Exception.ERRNO_EISDIR,_('Free users can\'t Play directories.')),R31Action.EVT_PLAY_NODE);this.rLayer.freeUsers=false;error=true;}
if(!error&&(this.subject.getSize()>STREAMING_THRESHOLD))
{this.raiseError(new R31User.FileTooBigException(LD.Exception.ERRNO_EFBIG,_('File is too big, must add it to your Wixi first.'),this.subject),R31Action.EVT_PLAY_NODE);this.rLayer.threshold=false;error=true;}}}
this.finished();}
R31Action_DownloadFromRoom.extend(R31Action);function R31Action_DownloadFromRoom()
{}
R31Action_DownloadFromRoom.prototype.init=function(subject,object1,masterCallback)
{if(!(subject instanceof R31User))
{throw"R31Action_DownloadFromRoom: Subject and Object must be a FileSystemNode instance.";}
if(!(object1 instanceof R31User))
{throw"R31Action_DownloadFromRoom: Object must be a R31User instances.";}
this.room=subject;this.user=object1;this.downloadable=false;this.masterCallback=masterCallback;var _this=this;this.finished=function()
{if(_this.downloadable)
{_this.masterCallback();_this.masterCallback=null;}}}
R31Action_DownloadFromRoom.prototype.validate=function()
{this.validateUserRelationship(this.room,this.user)}
R31Action_DownloadFromRoom.prototype.validateUserRelationship=function(user1,user2){var _this=this;var user1_id=user1 instanceof R31User?user1.id:user1
var user2_id=user2 instanceof R31User?user2.id:user2
if(user1_id==user2_id)
{this.downloadable=true;this.finished();}else{user1.isFriend(user2_id,function(isFriend){if(!isFriend){if(_this.node){_this.raiseError(new R31User.OriginalUploaderNotAFriendException(LD.Exception.WIXI_ENOFRIEND,_('User is not a friend, must become one first.'),_this.node),R31Action.EVT_DOWNLOAD_NODE);}
_this.downloadable=false;}else{_this.downloadable=isFriend;_this.finished();}})}}
R31Action_DownloadNode.extend(R31Action_DownloadFromRoom);function R31Action_DownloadNode()
{}
R31Action_DownloadNode.prototype.init=function(subject,object1,masterCallback)
{if(!(subject instanceof FileSystemNode))
{throw"R31Action_DownloadNode: Subject and Object must be a FileSystemNode instance.";}
if(!(object1 instanceof R31User))
{throw"R31Action_DownloadNode: Object must be a R31User instances.";}
this.node=subject;this.user=object1;this.downloadable=false;this.masterCallback=masterCallback;var _this=this;this.finished=function()
{if(_this.downloadable)
{_this.masterCallback();_this.masterCallback=null;}}}
R31Action_DownloadNode.prototype.validate=function()
{var _this=this;if(this.node.isFile()){if(this.node.original&&this.user.id==this.node.owner){return this.validateUserRelationship(this.user,this.node.owner)}else{FileSystem.isFriendOfAnOriginalUploader(this.node,function(is_friend){if(is_friend){_this.downloadable=true;}
_this.finished();});}}}

/*========== R31ContentFilter.js ==========*/

ContentFilter.extend(LD.Proto);ContentFilter.USE_PROPERTY=1;ContentFilter.USE_METHOD=2;ContentFilter.USE_FUNCTION=3;function ContentFilter(mode,using,value)
{ContentFilter.superConstructor.call(this);this.content=null;this.setFilterDef(mode,using);this.setFilterValue(value);}
ContentFilter.prototype.getSource=function()
{return this.source;}
ContentFilter.prototype.setFilterDef=function(mode,using)
{mode=intVal(varDefault(mode,ContentFilter.USE_PROPERTY));switch(mode){case ContentFilter.USE_PROPERTY:if(!using||typeof(using)!="string")
throw"ContentFilter.setFilterMode (USE_PROPERTY): Must provide the name of the property to do the filtering by";this.filterDef={"mode":mode,"using":using};break;case ContentFilter.USE_METHOD:if(!using||typeof(using)!="string")
throw"ContentFilter.setFilterMode (USE_METHOD): Must provide the name of the method within the filtered objects whose return value will be used upon giltering";this.filterDef={"mode":mode,"using":using};break;case ContentFilter.USE_FUNCTION:if(!using||typeof(using)!="function")
throw"ContentFilter.setFilterMode (USE_FUNCTION): Must provide a function to be called upon filtering. Function must accept one argument and return true or false.";this.filterDef={"mode":mode,"using":using};break;default:this.filterDef=null;}}
ContentFilter.prototype.getFilterValue=function(value)
{this.filterValue=value||null;}
ContentFilter.prototype.setFilterValue=function(value)
{this.filterValue=value||null;}
ContentFilter.prototype.filter=function(source)
{if(!source)return null;if(!this.filterDef)return source;function add(stack,k,v){if(stack.constructor==Array){stack.push(v);}else{stack[k]=v;}
return stack}
var res=(source.constructor==Array)?new Array():new Object();switch(this.filterDef.mode){case ContentFilter.USE_PROPERTY:for(var k in source){if(source[k][this.filterDef.using]==this.filterValue){res=add(res,k,source[k])}}
break;case ContentFilter.USE_METHOD:for(var k in source){if(source[k][this.filterDef.using]()==this.filterValue){res=add(res,k,source[k])}}
break;case ContentFilter.USE_FUNCTION:for(var k in source){if(this.filterDef.using(source[k])==true){res=add(res,k,source[k])}}
break;default:this.filterDef=null;}
return res;}

/*========== R31WindowToolBar.js ==========*/

R31WindowToolBar.extend(JUIContainer);R31WindowToolBar.templates={base:"R31WindowToolBar"};R31WindowToolBar.EVT_VIEW_BUTTON_CLICKED=17001;function R31WindowToolBar(orientation,title,floatable)
{R31WindowToolBar.superConstructor.call(this);}
R31WindowToolBar.prototype.init=function()
{R31WindowToolBar.superClass.init.call(this);var _this=this;this.html.viewPlayer.onclick=function(evt){_this.fireEvent({buttonId:"view_player"},R31WindowToolBar.EVT_VIEW_BUTTON_CLICKED);};this.html.viewList.onclick=function(evt){_this.fireEvent({buttonId:"view_list"},R31WindowToolBar.EVT_VIEW_BUTTON_CLICKED);};this.html.viewIcons.onclick=function(evt){_this.fireEvent({buttonId:"view_icons"},R31WindowToolBar.EVT_VIEW_BUTTON_CLICKED);};this.html.cmdAddToWixi.onclick=function(evt){_this.fireEvent({buttonId:"cmd_add"},R31WindowToolBar.EVT_VIEW_BUTTON_CLICKED);};this.html.cmdShare.onclick=function(evt){_this.fireEvent({buttonId:"cmd_share"},R31WindowToolBar.EVT_VIEW_BUTTON_CLICKED);};this.html.cmdDownload.onclick=function(evt){_this.fireEvent({buttonId:"cmd_download"},R31WindowToolBar.EVT_VIEW_BUTTON_CLICKED);};this.html.cmdMore.onclick=function(evt){_this.fireEvent({buttonId:"cmd_more"},R31WindowToolBar.EVT_VIEW_BUTTON_CLICKED);};}
R31WindowToolBar.prototype.setViewButtonsVisible=function(visible)
{if(isObject(visible)){if(isDefined(visible.player)){this.html.viewPlayer.style.display=visible.player?"":"none";}
if(isDefined(visible.list)){this.html.viewList.style.display=visible.list?"":"none";}
if(isDefined(visible.icons)){this.html.viewIcons.style.display=visible.icons?"":"none";}}
else{this.html.viewButtonGroup.style.display=visible?"":"none";}}
R31WindowToolBar.prototype.setCommandButtonsVisible=function(visible)
{if(isObject(visible)){if(isDefined(visible.addToWixi)){this.html.cmdAddToWixi.style.display=visible.addToWixi?"":"none";}
if(isDefined(visible.share)){this.html.cmdShare.style.display=visible.share?"":"none";}
if(isDefined(visible.download)){this.html.cmdDownload.style.display=visible.download?"":"none";}
if(isDefined(visible.more)){this.html.cmdMore.style.display=visible.more?"":"none";}}
else{this.html.cmdButtonGroup.style.display=visible?"":"none";}}

/*========== R31ContextMenu.js ==========*/

R31ContextMenu.extend(JUIMenu);R31ContextMenu.templates={base:"JUIMenu"};function R31ContextMenu()
{R31ContextMenu.superConstructor.call(this);this.items=new Object();}
R31ContextMenu.prototype.init=function()
{R31ContextMenu.superClass.init.call(this);this.setPreferredWidth(112);this.setWidth(112);this.setVisible(false);}
R31ContextMenu.prototype.getItem=function(id)
{return this.items[id]||null;}
R31ContextMenu.prototype.addItem=function(item,id)
{if(!(item instanceof JUIMenuItem))
throw"R31ContextMenu.addItem: Must provide a JUIMenuItem object";if(!id)
throw"R31ContextMenu.addItem: Must provide an ID to associate the item with";var order=null;if(typeof(this.items[id])!="undefined"){var order=this.getChildIndex(this.items[id]);this.removeItem(id);}
if(order==null)order=this.getChildren().length;this.add(item,order);this.items[id]=item;}
R31ContextMenu.prototype.addItems=function(items)
{if(!items||typeof(items)!="object")
throw"R31ContextMenu.addMenuItems: Must provide an object containing JUIMenuItem objects";var item;for(var k in items){item=items[k];if(item instanceof JUIMenuItem)
this.addItem(item,k);}}
R31ContextMenu.prototype.removeItem=function(item)
{var id;if(typeof(item)=="string"){id=item;item=this.items[id];}
else
id=inArray(this.items,item);if(!(item instanceof JUIMenuItem))
throw"R31ContextMenu.remove: Must provide a JUIMenuItem (or its ID) to remove";this.remove(item);delete this.items[id];}
R31ContextMenu.prototype.removeAllItems=function()
{this.removeAll();this.items=new Object();}

/*========== R31WindowToolBar.js ==========*/

R31WindowToolBar.extend(JUIContainer);R31WindowToolBar.templates={base:"R31WindowToolBar"};R31WindowToolBar.EVT_VIEW_BUTTON_CLICKED=17001;function R31WindowToolBar(orientation,title,floatable)
{R31WindowToolBar.superConstructor.call(this);}
R31WindowToolBar.prototype.init=function()
{R31WindowToolBar.superClass.init.call(this);var _this=this;this.html.viewPlayer.onclick=function(evt){_this.fireEvent({buttonId:"view_player"},R31WindowToolBar.EVT_VIEW_BUTTON_CLICKED);};this.html.viewList.onclick=function(evt){_this.fireEvent({buttonId:"view_list"},R31WindowToolBar.EVT_VIEW_BUTTON_CLICKED);};this.html.viewIcons.onclick=function(evt){_this.fireEvent({buttonId:"view_icons"},R31WindowToolBar.EVT_VIEW_BUTTON_CLICKED);};this.html.cmdAddToWixi.onclick=function(evt){_this.fireEvent({buttonId:"cmd_add"},R31WindowToolBar.EVT_VIEW_BUTTON_CLICKED);};this.html.cmdShare.onclick=function(evt){_this.fireEvent({buttonId:"cmd_share"},R31WindowToolBar.EVT_VIEW_BUTTON_CLICKED);};this.html.cmdDownload.onclick=function(evt){_this.fireEvent({buttonId:"cmd_download"},R31WindowToolBar.EVT_VIEW_BUTTON_CLICKED);};this.html.cmdMore.onclick=function(evt){_this.fireEvent({buttonId:"cmd_more"},R31WindowToolBar.EVT_VIEW_BUTTON_CLICKED);};}
R31WindowToolBar.prototype.setViewButtonsVisible=function(visible)
{if(isObject(visible)){if(isDefined(visible.player)){this.html.viewPlayer.style.display=visible.player?"":"none";}
if(isDefined(visible.list)){this.html.viewList.style.display=visible.list?"":"none";}
if(isDefined(visible.icons)){this.html.viewIcons.style.display=visible.icons?"":"none";}}
else{this.html.viewButtonGroup.style.display=visible?"":"none";}}
R31WindowToolBar.prototype.setCommandButtonsVisible=function(visible)
{if(isObject(visible)){if(isDefined(visible.addToWixi)){this.html.cmdAddToWixi.style.display=visible.addToWixi?"":"none";}
if(isDefined(visible.share)){this.html.cmdShare.style.display=visible.share?"":"none";}
if(isDefined(visible.download)){this.html.cmdDownload.style.display=visible.download?"":"none";}
if(isDefined(visible.more)){this.html.cmdMore.style.display=visible.more?"":"none";}}
else{this.html.cmdButtonGroup.style.display=visible?"":"none";}}

/*========== R31DashBoard.js ==========*/

R31DashBoard.extend(JUIContainer);R31DashBoard.templates={base:"R31DashBoard"};function R31DashBoard(autohide)
{R31DashBoard.superConstructor.call(this);this.autohide=(autohide==true);this.absolute=true;this.visible=false;this.collapsed=false;this.height=91;this._collapsedHeight=8;this._collapseThread=null;this.tabs=new Array();this.contentViews=new Object();}
R31DashBoard.prototype.init=function(htmlNode)
{R31DashBoard.superClass.init.call(this,htmlNode);var _this=this;var root=this.root;var tabContainer=new JUIContainer();this.tabContainer=tabContainer;tabContainer.init();this.add(tabContainer,null,this.html.contents);tabContainer.id="tabContainer";var friendsList=new R31FriendsList();this.friendsList=friendsList;friendsList.sortBy('starred','desc',"date","desc");friendsList.init();if(R31UserRegistry.getLoggedUser().id!=R31UserRegistry.getCurrentRoom().id){friendsList.starrable=false;friendsList.readOnlyStar=true;}else{friendsList.starrable=true;friendsList.readOnlyStar=false;}
friendsList.setVisible(true);friendsList.leftMargin=150;this.html.inviteFriend.onclick=function(){R31DesktopShell.doAction(R31.ACTION_INVITE,R31UserRegistry.getCurrentRoom());};this.html.userSearch.onclick=function(){R31DesktopShell.doAction(R31.ACTION_SEARCH_USER,{});};var penddingFriends=new R31FriendsList();this.penddingFriends=penddingFriends;penddingFriends.init();penddingFriends.starrable=false;penddingFriends.setVisible(true);penddingFriends.leftMargin=0;var visitorsList=new R31UserList();this.visitorsList=visitorsList;visitorsList.init();visitorsList.starrable=false;visitorsList.setVisible(true);visitorsList.leftMargin=0;var mostVisitedList=new R31UserList();this.mostVisitedList=mostVisitedList;mostVisitedList.init();mostVisitedList.starrable=false;mostVisitedList.setVisible(true);mostVisitedList.leftMargin=0;this.addTab("friends",_("Friends network"),friendsList,function(selected){if(selected===this.id){_this.html.menuAndSlider.className+=" "+this.id}else{_this.html.menuAndSlider.className=_this.html.menuAndSlider.className.replace(this.id,'');}});if(R31UserRegistry.getCurrentRoom().room==R31UserRegistry.getLoggedUser().room){this.addTab("pendingfriends",_("Pending Friends"),penddingFriends);}
this.addTab("visitors",_("Last visitors"),visitorsList);this.addTab("popular",_("Most popular Wixies"),mostVisitedList);this.showTab("friends");this.refreshInfo();JUI.DocumentEventHandler.addListener(JUI.EVT_SCROLL,this.repaint,this);JUI.DocumentEventHandler.addListener(JUI.EVT_RESIZED,this.resizeToFit,this);}
R31DashBoard.prototype.getRoomVisitors=function()
{if(this.visitorsProvider!=null)
return this.visitorsProvider.getLastVisitors();else
return null;}
R31DashBoard.prototype.getMostVisitedRooms=function()
{if(this.visitorsProvider!=null)
return this.visitorsProvider.getMostVisitedRooms();else
return null;}
R31DashBoard.prototype.getRoomVisitorsProvider=function()
{return this.visitorsProvider||null;}
R31DashBoard.prototype.setRoomVisitorsProvider=function(provider)
{if(provider!=null&&!instanceOf(provider,RoomVisitorsProvider))
throw"R31DashBoard.setVisitorsProvider: provider must implement the RoomVisitorsProvider interface";this.visitorsProvider=provider||null;}
R31DashBoard.prototype.getTab=function(id)
{var i=arraySearch(this.tabs,id,"id");if(i>=0&&i<this.tabs.length)
return this.tabs[i];else
return null;}
R31DashBoard.prototype.addTab=function(id,caption,content,callback)
{id=varDefault(id,"").toString();caption=varDefault(caption,"").toString();if(id==""||caption=="")
throw"R31DashBoard.addTab: Must assign an ID and a caption for the tab";if(content!=null&&!(content instanceof JUIComponent))
throw"R31DashBoard.addTab: Content must be a JUIComponent or JUIContainer instance";var _this=this;var tabHTML=this.createElement("SPAN",null,null,{className:"tab tab"+this.tabs.length});var tabBody=this.createElement("SPAN",null,null,{className:"body"});var tabCornerL=this.createElement("SPAN",null,null,{className:"corner_left"});var tabCornerR=this.createElement("SPAN",null,null,{className:"corner_right"});tabBody.appendChild(createText(caption));tabHTML.value=id;tabHTML.appendChild(tabCornerL);tabHTML.appendChild(tabBody);tabHTML.appendChild(tabCornerR);tabHTML.onclick=function(evt){_this.showTab(this.value);}
this.html.tabHolder.appendChild(tabHTML);if(content){content.setVisible(false);this.tabContainer.add(content);}
this.tabs.push({id:id,caption:caption,selector:tabHTML,captionObject:tabBody,content:content||null,"callback":callback});}
R31DashBoard.prototype.showTab=function(tabId)
{tabId=varDefault(tabId,"");var tab,classes,selClassIndex;if(this.currentTab&&this.currentTab.id!=tabId){if(this.currentTab.content)
this.currentTab.content.setVisible(false);}
for(var i=0;i<this.tabs.length;i++){tab=this.tabs[i];classes=tab.selector.className.split(" ");var newClasses=arrayReduce(classes,function(cl){return(cl!="tab_sel")});if(tab.id==tabId){newClasses.push("tab_sel");if(tab.content)
tab.content.setVisible(true);this.currentTab=tab;}
if(tab.callback){tab.callback(tabId)}
tab.selector.className=newClasses.join(" ");}}
R31DashBoard.prototype.setContentView=function(contentName,showView)
{if(contentName==null||showView==null)return false;var views=this.contentViews[contentName];if(!views)return false;for(var k in views){if(views[k]instanceof JUIComponent)
views[k].setVisible(k==showView);else if(views[k].nodeType==LD.NODE_ELEMENT)
views[k].style.display=(k==showView)?"":"none";}}
R31DashBoard.prototype.putViewContent=function(viewName,contentName,content,container)
{if(viewName==""||contentName==""||content==null)
throw"R31DashBoard.putViewContent failed";if(!this.contentViews[viewName])
this.contentViews[viewName]=new Object();this.contentViews[viewName][contentName]=content;if(container!=null){if(container instanceof JUIContainer)
container.add(content);else if(container.nodeType==LD.NODE_ELEMENT){if(content instanceof JUIComponent)
container.appendChild(content.getRoot());else if(content.nodeType==LD.NODE_ELEMENT)
container.appendChild(content);}}}
R31DashBoard.prototype.putContent=function(contentName,component)
{if(contentName==""||!(component instanceof JUIComponent))
throw"R31DashBoard.putContent: Must provide a node name and a JUIComponent object to append into the node";var nodeName="html_"+contentName;if(this[nodeName]){this.add(component);this[nodeName].appendChild(component.getRoot());component.setParent(this);component.setPositioning(JUI.POSITION_STATIC);component.getRoot().style.overflow="hidden";component.getRoot().style.zIndex=this.children.length+10;component.setLocation(0,0);}
else{LD.Con.println("no existe "+contentName);}}
R31DashBoard.prototype.setCollapsed=function(collapsed)
{if(this.collapsed==collapsed)return;this.collapsed=(collapsed==true);this.repaint();}
R31DashBoard.prototype.refreshUserInfo=function()
{var user=R31UserRegistry.getLoggedUser();var room=R31UserRegistry.getCurrentRoom();var getPendingFriends=(user&&room&&user.id==room.id);this.friendsList.setListSource(R31UserRegistry.getUserFriends(room,false));this.penddingFriends.setListSource(R31UserRegistry.getUserPendingFriends(room));this.visitorsList.setListSource(this.getRoomVisitors());this.mostVisitedList.setListSource(this.getMostVisitedRooms());var tab=this.getTab("friends");if(tab&&tab.content)
tab.content.repaint();}
R31DashBoard.prototype.refreshInfo=function()
{this.refreshUserInfo();var user=R31UserRegistry.getLoggedUser();var room=R31UserRegistry.getCurrentRoom();if(!user||!room)return;var roomName=(room&&room.temp!=true)?room.name:_("anonymous");var avatar;if(room.avatar!=null&&room.avatar!="")
avatar=getAvatarURL(room.avatar);else
avatar=R31.DEFAULT_AVATAR;var friendTab=this.getTab("friends");if(friendTab){if(user.id==room.id){friendTab.captionObject.innerHTML=_("Your friends network");}
else{friendTab.captionObject.innerHTML=_("%1's friends network",room.getName());}
this.repaint();}}
R31DashBoard.prototype.repaint=function()
{var autoRepaint=this.autoRepaint;var meeboBarHeight=(R31.MEEBO_ENABLED)?25:0;this.autoRepaint=false;var clientW=(window.innerWidth!=null)?window.innerWidth:document.body.clientWidth;var clientH=(window.innerHeight!=null)?window.innerHeight:document.body.clientHeight;this.setLocation(0,clientH-this.height-meeboBarHeight);this.autoRepaint=autoRepaint;R31DashBoard.superClass.repaint.call(this);if(!this.root)return;this.root.scrollTop=0;}
R31DashBoard.prototype.resizeToFit=function()
{var clientW=((window.innerWidth!=null)?window.innerWidth:document.body.clientWidth)-20;var clientH=(window.innerHeight!=null)?window.innerHeight:document.body.clientHeight;var tab;for(var i=0;i<this.tabs.length;i++){tab=this.tabs[i];if(tab&&tab.content&&tab.content instanceof JUIComponent)
tab.content.setSize(this.html.contents.offsetWidth-tab.content.leftMargin-18,this.html.contents.offsetHeight);}
this.setBounds(0,clientH-this.height,clientW,this.height);}

/*========== R31Desktop.js ==========*/

R31SideBar.extend(JUIContainer);R31SideBar.templates={base:"R31SideBar"};function R31SideBar()
{this.windowExternalChannels=[];this.statsVisitorsCount=null;R31SideBar.superConstructor.call(this);}
R31SideBar.prototype.init=function(htmlNode)
{R31SideBar.superClass.init.call(this,htmlNode);var searchExp="";var _this=this;var user=R31UserRegistry.getLoggedUser();var room=R31UserRegistry.getCurrentRoom();var path="/"+(room?room.name:"");this.html.viewProfile.onclick=function(){var room=R31UserRegistry.getCurrentRoom();var user=R31UserRegistry.getLoggedUser();if(user&&room){if(user.id==room.id)
R31DesktopShell.doAction(R31.ACTION_VIEW_PROFILE,room);}};this.html.onlyViewProfile.onclick=function(){var room=R31UserRegistry.getCurrentRoom();var user=R31UserRegistry.getLoggedUser();if(user&&room)
R31DesktopShell.doAction(R31.ACTION_ONLY_VIEW_PROFILE,room);};this.html.createFolder.onclick=function(){var user=R31UserRegistry.getLoggedUser();if(!user)return;var rootDir=FileSystem.getNodeByPath("/"+user.name);R31DesktopShell.doAction(R31.ACTION_FOLDER_CREATE,FileSystem.getNodeByPath("/"+user.name));};this.html.addContent.onclick=function(){var user=R31UserRegistry.getLoggedUser();if(!user)return;var rootDir=FileSystem.getNodeByPath("/"+user.name);R31DesktopShell.doAction(R31.ACTION_UPLOAD,rootDir);};this.html.becomeFriend.onclick=function(){var currentRoom=R31UserRegistry.getCurrentRoom();if(currentRoom!=null)
R31DesktopShell.doAction(R31.ACTION_REQUEST_FRIENDSHIP,currentRoom);};this.html.sendMessage.onclick=function(){R31DesktopShell.doAction(R31.ACTION_SEND_MESSAGE,{});};this.html.friendsActivity.onclick=function(){R31DesktopShell.doAction("showFriendsActivity",{});};this.html.sendFeedback.onclick=function(){R31DesktopShell.doAction(R31.ACTION_SEND_FEEDBACK,{});};this.html.friendsActivity.onmouseover=function(){_this.html.channelsSubMenu.style.display="none";};this.html.sendFeedback.onmouseover=function(){_this.html.channelsSubMenu.style.display="none";};this.html.goldenBook.onclick=function(){R31DesktopShell.doAction("openGoldenBook",{});};this.html.goldenBook.onmouseover=function(){_this.html.channelsSubMenu.style.display="none";};this.html.channelsMenu.onmouseover=function(){_this.html.channelsSubMenu.style.display="block";}
this.html.channelsSubMenu.onmouseout=function(){this.style.display="none";}
this.html.explorerWindow.onclick=function(){R31DesktopShell.doAction(R31.ACTION_OPEN_EXPLORER_WINDOW,{});};this.html.youtube.onclick=function()
{var wchannels=new R31ExternalChannels("youtube","YouTube Channel");if(_this.windowExternalChannels!=null&&_this.windowExternalChannels["youtube"]!=undefined){if(_this.windowExternalChannels["youtube"].isMinimized())
_this.windowExternalChannels["youtube"].setMinimized(false);else
_this.showChannel(wchannels,wchannels.template);}
else{_this.showChannel(wchannels,wchannels.template);}}
this.html.dailymotion.onclick=function()
{var dmchannels=new R31ExternalChannels("dailymotion","DailyMotion Channel");if(_this.windowExternalChannels!=null&&_this.windowExternalChannels["dailymotion"]!=undefined){if(_this.windowExternalChannels["dailymotion"].isMinimized())
_this.windowExternalChannels["dailymotion"].setMinimized(false);else
_this.showChannel(dmchannels,dmchannels.template);}
else{_this.showChannel(dmchannels,dmchannels.template);}}
this.html.flickr.onclick=function()
{var flchannels=new R31ExternalChannels("flickr","Flickr Channel");if(_this.windowExternalChannels!=null&&_this.windowExternalChannels["flickr"]!=undefined){if(_this.windowExternalChannels["flickr"].isMinimized())
_this.windowExternalChannels["flickr"].setMinimized(false);else
_this.showChannel(flchannels,flchannels.template);}
else{_this.showChannel(flchannels,flchannels.template);}}
this.html.hulu.onclick=function()
{var hlchannels=new R31ExternalChannels("hulu","Hulu Channel");if(_this.windowExternalChannels!=null&&_this.windowExternalChannels["hulu"]!=undefined){if(_this.windowExternalChannels["hulu"].isMinimized())
_this.windowExternalChannels["hulu"].setMinimized(false);else
_this.showChannel(hlchannels,hlchannels.template);}
else{_this.showChannel(hlchannels,hlchannels.template);}}
this.html.cnnch.onclick=function()
{var cnchannels=new R31ExternalChannels("cnn","Cnn Channel");if(_this.windowExternalChannels!=null&&_this.windowExternalChannels["cnn"]!=undefined){if(_this.windowExternalChannels["cnn"].isMinimized())
_this.windowExternalChannels["cnn"].setMinimized(false);else
_this.showChannel(cnchannels,cnchannels.template);}
else{_this.showChannel(cnchannels,cnchannels.template);}}
this.html.mtvmusic.onclick=function()
{var mchannels=new R31ExternalChannels("mtvmusic","MtvMusic Channel");if(_this.windowExternalChannels!=null&&_this.windowExternalChannels["mtvmusic"]!=undefined){if(_this.windowExternalChannels["mtvmusic"].isMinimized())
_this.windowExternalChannels["mtvmusic"].setMinimized(false);else
_this.showChannel(mchannels,mchannels.template);}
else{_this.showChannel(mchannels,mchannels.template);}}
this.refreshUserInfo();}
R31SideBar.prototype.showChannel=function(obj,name){obj.init();obj.setCloseAction(JUIWindow.DISPOSE_ON_CLOSE);JUI.getTopContainer().add(obj);if(Browser.isSafari)
obj.setSize(830,500);else
obj.setSize(820,500);obj.toolBar.setVisible(false);obj.setLocation(screen.width/4,40);obj.setMinimized(false);this.windowExternalChannels[name]=obj;obj.titleBar.setVisible(true);obj.html.titleBar.style.left="3";obj.setVisible(true);obj.requestFocus();}
R31SideBar.prototype.refreshUserInfo=function()
{if(!this.root)return;var room=R31UserRegistry.getCurrentRoom();if(!room||!room.id)return;var user=R31UserRegistry.getLoggedUser();var roomFriends=R31UserRegistry.getUserFriends(room);var stats=R31UserStats.get(room);var feed=Feeds.replace(room.name,URL_SOURCE_RSS+"?user="+escape(room.name),""+room.name+" files");var rss=feed.toAnchor();rss.className="rss";this.html.roomOwner.innerHTML="";this.html.avatarContainer.appendChild(rss);this.html.roomOwner.appendChild(document.createTextNode(room.name));if(this.html.onlineStatusUser&&room!=null){this.html.onlineStatusUser.src="http://presence.meebo.com/statusimg?uid="+room.name+"&partner=wixi";}
if(user&&!user.isPremium()){}
else{}
if(stats){var aux,total;var u=stats.storageUsed;if(room.isPremium()){aux=R31.getStorageMeasure(stats.storageUsed,2);this.html.statsUsageAvailable.className="statsUsageAvailableUnlimited";this.html.statsUsageAvailable.innerHTML=__("Unlimited");var used=R31.getStorageMeasure(u,2);}
else{aux=R31.getStorageMeasure(R31.getStorageLimit(room)-u,(u>UNIT_G)?2:0);total=R31.getStorageMeasure(QUOTA_FREE);this.html.statsUsageAvailable.innerHTML=(total[0]+" "+total[1]);var used=R31.getStorageMeasure(u,(u>UNIT_G)?2:0);}
if(stats.visitorsTotal==null||stats.visitorsTotal=='undefined')
stats.visitorsTotal=this.statsVisitorsCount;else
this.statsVisitorsCount=stats.visitorsTotal;this.html.statsUsageCount.innerHTML=used[0];this.html.statsUsageUnit.innerHTML=used[1];this.html.statsFiles.innerHTML=stats.fileCount;this.html.statsVisits.innerHTML=stats.visitorsTotal;}
this.refreshGoldenBookPostCount();var inUsersRoom=(room&&user&&room.id==user.id);var inFriendsRoom=inArray(roomFriends,user.id,false,"id");if(inUsersRoom){this.html.viewProfile.style.display="";}
else if(room.publicProfile){if(inFriendsRoom)
this.html.onlyViewProfile.style.display="";else
this.html.onlyViewProfile.style.display="none";}
this.html.statsFriends.innerHTML=roomFriends.length;if(room.avatar!=""){this.html.avatar.src=getAvatarURL(room.avatar);}else
this.html.avatar.src=R31.DEFAULT_AVATAR;if(this.search){var path="/"+(room?room.name:"");this.search.setPath(path);}
if(inUsersRoom){this.html.createFolder.style.display="";this.html.addContent.style.display="";this.html.becomeFriend.style.display="none";this.html.sendMessage.style.display="none";}
else{this.html.createFolder.style.display="none";this.html.addContent.style.display="none";if(inArray(roomFriends,user.id,false,"id"))
this.html.becomeFriend.style.display="none";else
this.html.becomeFriend.style.display="";this.html.sendMessage.style.display="";}
this.recalcDhtmlStyles();}
R31SideBar.prototype.refreshGoldenBookPostCount=function()
{if(!this.root)return;var room=R31UserRegistry.getCurrentRoom();if(!room||!room.goldenBook)return;var postCountText=(room.goldenBook&&room.goldenBook.postCount)?("("+room.goldenBook.postCount+")"):"";LD.Element.writeText(this.html.postCount,postCountText,true);}
R31SideBar.prototype.repaint=function()
{if(!this.root)return;var aux=this.autoRepaint;this.autoRepaint=false;R31SideBar.superClass.repaint.call(this);var room=R31UserRegistry.getCurrentRoom();if(room&&room.premium){this.html.storageMeter.style.display="none";this.html.storageMeterText.style.width="100%";this.html.storageMeterText.style.left="0";this.html.storageMeterText.style.margin="auto";this.html.storageMeterPremium.style.display="none";}
else{this.html.storageMeter.style.display="";this.html.storageMeterText.style.display="";this.html.storageMeterPremium.style.display="none";}}
R31SideBar.prototype.setVisible=function(visible)
{R31SideBar.superClass.setVisible.call(this,visible);if(!this.root)return;var iconOffsetX=(this.visible==true)?210:0;if(this.visible)
this.requestFocus();if(desktopManager&&desktopManager.fsRoomRoot!=null)
desktopManager.showIcons(desktopManager.desktopIconPanel,desktopManager.fsRoomRoot.getChildren(),null,iconOffsetX);}
R31SideBar.prototype.getStorageWidth=function(){var mw=intVal(this.html.storageMeter.offsetWidth)-4;var used=this.getStorageUsed();return mw*used;}
R31SideBar.prototype.getStorageUsed=function()
{var room=R31UserRegistry.getCurrentRoom();if(room.isPremium()){return 0;}
else{var stats=R31UserStats.get(room);return Math.max(0,Math.min(stats.storageUsed/R31.getStorageLimit(room),1));}}
R31SideBar.prototype.close=function()
{this.setVisible(false);}
R31TopBarTab.extend(JUIContainer);R31TopBarTab.templates={base:"R31TopBarTab"};function R31TopBarTab(controller,component,caption)
{if(!controller)
throw"R31TopBarTab: Must provide a controller object";R31TopBarTab.superConstructor.call(this);this.caption=caption||"";this.controller=controller||null;this.boundComponent=component||null;}
R31TopBarTab.prototype.init=function(htmlNode)
{R31TopBarTab.superClass.init.call(this,htmlNode);var _this=this;this.html.caption.innerHTML=this.caption;this.html.caption.onclick=function(){if(_this.controller)
_this.controller.goToTask(_this);}
this.html.close.onclick=function(){if(_this.controller)
_this.controller.endTask(_this);}}
R31TopBarTab.prototype.getController=function()
{return this.boundComponent;}
R31TopBarTab.prototype.getBoundComponent=function()
{return this.boundComponent;}
R31TopBar.extend(JUIContainer);R31TopBar.templates={base:"R31TopBar"};function R31TopBar()
{R31TopBar.superConstructor.call(this);this.upLogo=null;this.taskBar=null;this.userMenu=null;this.sideBar=null;this.windowExternalChannels=null;}
R31TopBar.prototype.init=function(htmlNode)
{R31TopBar.superClass.init.call(this,htmlNode);var searchExpTop="";var _this=this;AjaxSocket.addListener(AjaxSocket.EVT_AJAX_WORKING_CHANGED,this.ajaxWorkingChanged,this);AjaxSocket.addListener(AjaxSocket.EVT_ERROR_TIMEOUT,this.ajaxErrorTimeOut,this);AjaxSocket.addListener(AjaxSocket.EVT_ERROR_NOTLOGGED,this.ajaxErrorNotLogged,this);this.html.searchTopInput.onkeypress=function(evt){evt=LD.Event.normalize(evt);var keyCode=evt.keyCode;if(keyCode==13){LD.Event.cancel(evt);_this.searchExpTop=_this.html.searchTopInput.value;var searchType=getSelectedValue(_this.html.searchTopSelect);var from=0;if(searchType==5)
{searchType=0;from='-1';}
R31DesktopShell.doAction("searchFile",{search:evt.target.value,type:searchType,from:from});}}
_this.html.searchTopInput.value=__("Add video, music, photo or games");this.html.searchTopInput.onfocus=function(){_this.html.searchTopInput.value="";}
this.html.searchTopInput.onblur=function(){_this.searchExpTop=_this.html.searchTopInput.value;if(_this.html.searchTopInput.value=="")_this.html.searchTopInput.value=__("Add video, music, photo or games");}
this.html.searchTopButton.onclick=function(){_this.html.searchTopInput.value=_this.searchExpTop;var searchType=getSelectedValue(_this.html.searchTopSelect);var from=0;var channel='';var page=0;if(searchType==5)
{channel='youtube';searchType=0;from='-1';page=1;}
R31DesktopShell.doAction("searchFile",{search:_this.searchExpTop,type:searchType,from:from});}
this.html.logo.onclick=function(){sideBarTemp=_this.getSideBar();if(sideBarTemp.visible==true)
sideBarTemp.close();else
sideBarTemp.setVisible(true);}
var sideBar=new R31SideBar();this.sideBar=sideBar;sideBar.init();sideBar.setLocation(8,45);JUI.getTopContainer().add(sideBar,JUI.LAYER_DASHBOARD);var taskBar=new JUIContainer(new JUIStackLayout(JUI.LAYOUT_HORIZONTAL));this.taskBar=taskBar;taskBar.init();taskBar.setSize(this.width,24);this.add(taskBar,JUI.LAYER_TASKBAR);taskBar.setTransparency(25);taskBar.setVisible(window.hideTaskBar!==true);taskBar.getLayout().setHGap(4);taskBar.tasks=new Array();taskBar.autoResize=function(){var wixiTabsWidth=135;var clientW=this.getParent().getWidth();var ulb={width:50,height:10};var umb=this.getParent().getUserMenu().getBounds();this.setBounds(10,desktopManager.dashBoard.y-this.height,clientW-wixiTabsWidth-ulb.width-umb.width-30,22);}
taskBar.add=function(component)
{var item;if(component instanceof JUIWindow){var index=this.tasks.length;var item=new R31TopBarTab(this,component,component.getTitle());item.init();item.setBounds(0,0,130,24);this.tasks.push(item);}
else
item=component;this.constructor.prototype.add.call(this,item);this.layout.doLayout();}
taskBar.remove=function(item)
{item.removeListener(JUI.EVT_MOUSE_CLICK,this.goTo,this);this.constructor.prototype.remove.call(this,item);this.tasks=arrayRemove(this.tasks,item);this.layout.doLayout();}
taskBar.getTaskByComponent=function(component)
{for(var i=0;i<this.tasks.length;i++){if(this.tasks[i].boundComponent==component)
return this.tasks[i];}
return null;}
taskBar.endTask=function(item)
{if(!item)return;var c=item.getBoundComponent();if(c instanceof JUIWindow)
c.close();}
taskBar.goToTask=function(item)
{if(!item)return;var c=item.getBoundComponent();if(c instanceof JUIWindow){c.setMinimized(false);c.requestFocus();}}
var userMenu=new JUIContainer();this.userMenu=userMenu;userMenu.init(JUI.getTemplateInstance("R31UserMenu"));var room=R31UserRegistry.getCurrentRoom();var user=R31UserRegistry.getLoggedUser();var rss=Feeds.replace("userMenu",URL_SOURCE_RSS+"?user="+escape(user.name),__("New files for ")+user.name).toAnchor();userMenu.html.rss.appendChild(rss);this.add(userMenu,JUI.LAYER_DASHBOARD);var userMenuBounds=userMenu.getParent().getBounds();var logOutPosition=userMenuBounds.width-300;userMenu.setBounds(logOutPosition,0,200,36);userMenu.setVisible(true);userMenu.autoLocate=function(){var clientW=this.getParent().getWidth();this.setLocation(clientW-this.getWidth(),1);}
userMenu.autoLocate();JUI.DocumentEventHandler.addListener(JUI.EVT_RESIZED,this.repaint,this);taskBar.autoResize();}
R31TopBar.prototype.ajaxWorkingChanged=function(evt,type,src)
{var d=this.html.ajaxStatus;if(d){if(evt.socketWorkingStatus){d.style.display='block';d.style.backgroundColor="#AB2076";}
else d.style.display='none';}}
R31TopBar.prototype.ajaxErrorTimeOut=function(evt,type,src){var d=this.html.ajaxStatus;if(d){d.innerHTML="ARRGHHH...";d.style.backgroundColor="#EFAE00";d.style.display="block";}}
R31TopBar.prototype.ajaxErrorNotLogged=function(evt,type,src){document.location.href="/login.php";};R31TopBar.prototype.refreshUserInfo=function()
{if(!this.root)return;if(this.userMenu){var user=R31UserRegistry.getLoggedUser();this.userMenu.html.avatar.src=(user&&user.avatar)?(getAvatarURL(user.avatar)):R31.DEFAULT_AVATAR;}
this.sideBar.refreshUserInfo();}
R31TopBar.prototype.getSideBar=function()
{return this.sideBar;}
R31TopBar.prototype.setSideBar=function(sideBar)
{this.sideBar=sideBar||null;}
R31TopBar.prototype.repaint=function()
{if(!this.root)return;var aux=this.autoRepaint;this.autoRepaint=false;var clientW=(window.innerWidth!=null)?window.innerWidth:document.body.clientWidth;this.setSize(clientW,this.height);this.taskBar.autoResize();this.userMenu.autoLocate();this.autoRepaint=aux;R31TopBar.superClass.repaint.call(this);}
R31TopBar.prototype.getTaskBar=function()
{return this.taskBar;}
R31TopBar.prototype.addChild=function(child)
{return this.taskBar.add(child);}
R31TopBar.prototype.getChild=function(component)
{if(!(component instanceof JUIComponent))
throw"R31TopBar.getChild: Must provide an instance of JUIComponent that is associated with the task";return this.taskBar.getTaskByComponent(component);}
R31TopBar.prototype.removeChild=function(child)
{var item=(child instanceof JUIComponent)?this.getChild(child):child;if(item!=null)
return this.taskBar.remove(item);else
return null;}
R31TopBar.prototype.getUpLogo=function()
{return this.upLogo;}
R31TopBar.prototype.getUserMenu=function()
{return this.userMenu;}
R31Wallpaper.extend(JUIContainer);function R31Wallpaper(imageUrl)
{R31Wallpaper.superConstructor.call(this);this.setImageUrl(imageUrl);this.absolute=true;}
R31Wallpaper.prototype.init=function()
{R31Wallpaper.superClass.init.call(this);var _this=this;var image=this.createElement("IMG",null,null,{src:this.imageUrl},{position:"absolute",top:0,left:0,width:"100%",height:"100%",zIndex:0});this.image=image;this.root.appendChild(image);image.onmousedown=function(evt){LD.Event.cancel(evt);}
JUI.DocumentEventHandler.addListener(JUI.EVT_RESIZED,this.resizeToFit,this);}
R31Wallpaper.prototype.setImageUrl=function(imageUrl)
{this.imageUrl=varDefault(imageUrl,DIR_IMAGES+"spacer.gif");if(!this.root)return;this.image.src=this.imageUrl;}
R31Wallpaper.prototype.resizeToFit=function()
{if(!this.root)return;this.root.style.zIndex=0;var clientW=document.body.clientWidth;var clientH=document.body.clientHeight;this.setBounds(0,0,clientW,clientH);}
R31WindowInstanceManager.extend(LD.Proto);function R31WindowInstanceManager(desktop)
{this.desktop=(desktop instanceof JUIDesktop)?desktop:null;this.windowInstances=new Object();}
R31WindowInstanceManager.prototype.getWindowByNode=function(fsNode)
{if(!(fsNode instanceof FileSystemNode))return null;var nodeId=fsNode.getId();if(!nodeId)return null;var winName="fs_win_"+fsNode.getId();return this.windowInstances[winName]||null;}
R31WindowInstanceManager.prototype.getWindowByName=function(name)
{if(name="")return null;return this.windowInstances[name]||null;}
R31WindowInstanceManager.prototype.getWindowInstance=function(fsNode,constructor,options,focus)
{if(!(fsNode instanceof FileSystemNode))
throw"R31WindowInstanceManager.getWindowInstance: Must provide a FileSystemNode object to associate the window with";var nodeId=fsNode.getId();if(!nodeId)return null;var name="win_fs_"+nodeId;var win=this.windowInstances[name];if(win!=null){if(win instanceof JUIWindow){if(win.isDisplayable()==true)
return win;}
else if(win.closed===false)
return win;}
var openInternal=function(){constructor=constructor||JUIWindow;options=options||{close:true,minimize:true,maximize:true,collapse:false};win=new constructor(fsNode.getName(),options.close,options.minimize,options.maximize,options.collapse);win.setFileSystemSource(fsNode);}
var openExternal=function(){options=options||{resizable:1,location:1,toolbar:1,menubar:1,scrollbars:1,statusbar:1};win=openWindow(fsNode.getTarget(),"_blank",options,true);}
if(fsNode.getType()==FileSystem.NODE_TYPE_LINK){if(win==null||win.closed==true||(win instanceof JUIWindow&&!win.isDisplayable())){if(R31.isPlayableMedia(fsNode))
openInternal();else
openExternal();}}
else{openInternal();}
this.windowInstances[name]=win;return win;}

/*========== R31Dialog.js ==========*/

R31Dialog.extend(JUIWindow);R31Dialog.templates={base:"JUIWindow",contentBase:"R31Dialog"};function R31Dialog(title)
{R31Dialog.superConstructor.call(this,title,true,false,false,false);this.target=null;this.resizable=false;this.statusBarVisible=false;}
R31Dialog.prototype.init=function()
{R31Dialog.superClass.init.call(this);var content=JUI.getTemplateInstance(R31Dialog.templates.contentBase);this.content=new JUIHtmlNode(content);this.getContentPane().setScrolling(JUI.SCROLL_VERTICAL);this.getContentPane().add(this.content);this.content.setLocation(0,0);}
R31Dialog.prototype.addContent=function(content)
{if(!content)return false;if(content.className&&this.content){var cr=this.content.getRoot();if(cr!=null)
cr.className=((cr.className||"")+" "+(content.className||"")).trim();}
var refs=JUI.getDhtmlRefs(content);var html=this.content.html;for(var k in refs){if(html[k]!=null){if(html[k].parentNode)
html[k].parentNode.replaceChild(refs[k],html[k]);}
html[k]=refs[k];}}
R31Dialog.prototype.getContent=function(content)
{return this.content;}
R31Dialog.prototype.repaint=function()
{R31Dialog.superClass.repaint.call(this);if(!this.content)return;this.content.repaint();}

/*========== R31AccessDialog.js ==========*/

R31AccessDialog.extend(JUIWindow);R31AccessDialog.templates={base:"JUIWindow",content:"R31AccessDialog"};function R31AccessDialog(title)
{R31AccessDialog.superConstructor.call(this,title,true,false,false,false);this.target=null;this.setResizable(false);this.setStatusBarVisible(false);this.setToolBarVisible(false);}
R31AccessDialog.prototype.init=function(htmlNode)
{R31AccessDialog.superClass.init.call(this,htmlNode);var _this=this;this.root.className="JUIWindow R31AccessDialog";var content=JUI.getTemplateInstance(R31AccessDialog.templates.content);this.getContentPane().add(new JUIHtmlNode(content));var refs=JUI.getDhtmlRefs(content);for(var k in refs){if(typeof(this.html[k])!="undefined")
throw"R31AccessDialog.init: Content template collides with class's base template";this.html[k]=refs[k];}
this.accessButtons=[this.html.accessPublic,this.html.accessFriends,this.html.accessPrivate];this.html.accessPublic.onclick=this.html.accessFriends.onclick=this.html.accessPrivate.onclick=function(evt){_this.setAccessLevel(this.value);}
this.html.okButton.onclick=function(){_this.close();_this.callback(_this.target,_this.getAccessLevel());}
this.html.cancelButton.onclick=function(){_this.close();_this.callback(_this.target,null);}
if(this.target)this.refreshTargetData();}
R31AccessDialog.prototype.getTarget=function()
{return this.target;}
R31AccessDialog.prototype.setTarget=function(target)
{if(!(target instanceof FileSystemNode))
throw"R31AccessDialog: Must provide a target FileSystemNode object";this.target=target;if(this.root)this.refreshTargetData();}
R31AccessDialog.prototype.setCallback=function(callback)
{if(callback&&typeof(callback)!="function")
throw"R31AccessDialog.setCallback: Must provide a callback function";this.callback=callback;}
R31AccessDialog.prototype.getAccessLevel=function()
{var val=getRadioValue(this.accessButtons);if(val==null)return null;return intVal(val);}
R31AccessDialog.prototype.setAccessLevel=function(accessLevel)
{this.accessLevel=Math.max(0,Math.min(2,intVal(accessLevel)));var btn=this.accessButtons[i];for(var i=0;i<this.accessButtons.length;i++){var btn=this.accessButtons[i];btn.checked=(btn.value==accessLevel);}}
R31AccessDialog.prototype.refreshTargetData=function()
{if(!this.root||!this.target)return;this.html.targetName.innerHTML=this.target.getName();this.accessLevel=this.target.getAccessLevel();setRadioValue(this.accessButtons,this.accessLevel);}

/*========== R31FriendsList.js ==========*/

R31FriendsList.extend(JUISlidePane);R31FriendsList.templates={base:"JUISlidePane"};function R31FriendsList(scrolling,iconConstructor)
{var behaviour={scrolling:varDefault(scrolling,JUI.SCROLL_HORIZONTAL)};R31FriendsList.superConstructor.call(this,behaviour);this.setIconConstructor(iconConstructor||R31UserIcon);this.initializeViewArea();this.absolute=true;this.visible=false;this.listSource=new Array();this.friendsIconList=new Array();this.horizontalStep=1;this.verticalStep=1;this.setLayout(new JUIStackLayout(JUI.LAYOUT_HORIZONTAL,4));this.selectedUsers=new Array();this.deletable=null;this.starrable=null;this.readOnlyStar=false;this.sortBy('date','desc');this.showHorizontalLeftScroller=true;this.showHorizontalRightScroller=true;this.xScrollerWidth=20;this.renderListQueued=0;}
R31FriendsList.prototype.init=function(htmlNode)
{R31FriendsList.superClass.init.call(this,htmlNode);this.root.className+=" R31FriendsList";}
R31FriendsList.prototype.scrollBy=function(x,y)
{if(!this.root||!this.listSource)return;if(x==0&&y==0)return;this.viewArea.firstCol=Math.max(0,Math.min(this.listSource.length-1,this.viewArea.firstCol+x));this.viewArea.firstRow=Math.max(0,Math.min(this.listSource.length-1,this.viewArea.firstRow+y));this.hasScrolled();}
R31FriendsList.prototype.scrollTo=function(x,y)
{if(!this.root||!this.listSource)return;x=Math.max(0,Math.min(this.listSource.length-1,x));y=Math.max(0,Math.min(this.listSource.length-1,y));if(x==this.viewArea.firstCol&&y==this.viewArea.firstRow)return;this.viewArea.firstCol=x;this.viewArea.firstRow=y;this.hasScrolled();}
R31FriendsList.prototype.hasScrolled=function()
{if(!this.root)return;this.renderList();this.fireEvent(this.viewArea,JUI.EVT_SCROLL);}
R31FriendsList.prototype.initializeViewArea=function()
{this.viewArea={firstCol:0,firstRow:0,colCount:Math.ceil(1600/this.iconConstructor.DEFAULT_WIDTH),rowCount:Math.ceil(1200/this.iconConstructor.DEFAULT_HEIGHT)};}
R31FriendsList.prototype.setViewArea=function(firstCol,firstRow,colCount,rowCount)
{this.viewArea={firstCol:firstCol,firstRow:firstRow,colCount:colCount,rowCount:rowCount};this.renderList();}
R31FriendsList.prototype.repaint=function()
{if(!this.root||!this.viewArea||!this.listSource)return;R31FriendsList.superConstructor.superClass.repaint.call(this);this.html.scrollerRight.style.left=this.width-this.xScrollerWidth;this.html.scrollerDown.style.left=this.height-this.yScrollerHeight;this.repaintScrollers();}
R31FriendsList.prototype.repaintScrollers=function()
{if(this.scrolling&JUI.SCROLL_VERTICAL){this.html.scrollerUp.style.display="";this.html.scrollerDown.style.display="";}
else{this.html.scrollerUp.style.display="none";this.html.scrollerDown.style.display="none";}
if(this.scrolling&JUI.SCROLL_HORIZONTAL){this.html.scrollerLeft.style.display=this.showHorizontalLeftScroller?'':"none";this.html.scrollerRight.style.display=this.showHorizontalRightScroller?'':"none";}
else{this.html.scrollerLeft.style.display="none";this.html.scrollerRight.style.display="none";}}
R31FriendsList.prototype.getListSource=function()
{return this.listSource;}
R31FriendsList.prototype.setListSource=function(source)
{if(source==null)
source=new Array();else if(!(source instanceof Array))
throw"R31FriendsList.setListSource: Must provide an Array containing users";this.listSource=source;this.listSource.sort(this.sort);this.selectedUsers=new Array();if(this.root)this.renderList();}
R31FriendsList.prototype.getSelectedUsers=function(obj)
{if(typeof(obj)!='undefined')
{var users=new Array();for(var i=0;i<this.listSource.length;i++)
{if(inArray(this.selectedUsers,this.listSource[i].id))
{users.push(this.listSource[i]);}}
return users;}
else
{return this.selectedUsers;}}
R31FriendsList.prototype.renderList=function()
{if(this.renderListQueued==0)
{var _this=this;this.renderListQueued=setTimeout(function()
{if(!_this.root)return;if(!_this.viewArea)_this.initializeViewArea();_this.viewArea.colCount=Math.ceil(_this.getWidth()/_this.iconConstructor.DEFAULT_WIDTH);var existingIcons=_this.friendsIconList||new Array();_this.friendsIconList=new Array();var hGap=_this.layout.getHGap();var w=0;var user=R31UserRegistry.getLoggedUser();var room=R31UserRegistry.getCurrentRoom();var isUsersRoom=(user&&room&&user.id==room.id);var friend,icon,isNewIcon,icc=_this.iconConstructor;var last=Math.min(_this.viewArea.firstCol+_this.viewArea.colCount-1,_this.listSource.length-1);for(var i=_this.viewArea.firstCol,iconIndex=0;i<=last;i++){friend=R31User.build(_this.listSource[i]);if(!isUsersRoom&&friend.isPending())continue;if(iconIndex>=_this.children.length){icon=new icc(friend);if(_this.starrable==null){icon.setStarrable(isUsersRoom,_this.readOnlyStar);}else{icon.setStarrable(_this.starrable,_this.readOnlyStar);}
JUI.DragDrop.registerDropTarget(new JUIDropTarget(icon,icon));icon.init();isNewIcon=true;icon.addListener(JUI.EVT_MOUSE_CLICK,_this.iconClicked,_this);icon.addListener(JUI.EVT_CHANGED,_this.iconChanged,_this);}
else{icon=_this.children[iconIndex];if(friend!=icon.getUser())
icon.setUser(friend);isNewIcon=false;}
icon.setSelected(inArray(_this.selectedUsers,friend.id));if(_this.deletable==null){icon.setDeletable(isUsersRoom);}else{icon.setDeletable(_this.deletable);}
icon.setImageDisabled(false);icon.setVisible(true);if(isNewIcon)
_this.add(icon);_this.friendsIconList.push(icon);w+=(R31UserIcon.DEFAULT_WIDTH+(i>0?hGap:0));++iconIndex;}
var icon;var hidden=0;for(var i=iconIndex;i<_this.children.length;i++){icon=_this.children[i];icon.setUser(null);icon.setVisible(false);hidden++;}
var cond1=(last-iconIndex);var cond2=(_this.viewArea.firstCol-hidden);_this.showHorizontalLeftScroller=last+1!=_this.children.length;_this.showHorizontalRightScroller=(_this.friendsIconList.length<_this.listSource.length)&&(cond1<=cond2);if(!_this.showHorizontalRightScroller)
{clearInterval(_this.scrollThreadId);}
_this.repaintScrollers();_this.layout.doLayout();_this.renderListQueued=0;},200);}}
R31FriendsList.prototype.iconClicked=function(evt,type,src)
{}
R31FriendsList.prototype.iconChanged=function(evt,type,src)
{}
R31FriendsList.prototype.setIconConstructor=function(iconConstructor)
{if(iconConstructor!=null&&typeof(iconConstructor)!="function")
throw"R31FriendsList.setIconConstructor: must provide a constructor function";this.iconConstructor=iconConstructor;}
R31FriendsList.prototype.getFriendsIcons=function()
{return this.friendsIconList;}
R31FriendsList.prototype.sortBy=function(field,dir,field2,dir2){dir=(dir=='asc')?-1:1;dir2=(dir2=='asc')?-1:1;this.sort=function(a,b){if(a&&b&&a.hasOwnProperty(field)&&b.hasOwnProperty(field)){if(field2&&dir2){if(a[field]==b[field]){return(a[field2]<b[field2]?1:-1)*dir2}else{return(a[field]<b[field]?1:-1)*dir}}else{return(a[field]<b[field]?1:-1)*dir}}
return 0;}}
R31UserList.extend(R31FriendsList);R31UserList.templates={base:"JUISlidePane"};function R31UserList(scrolling,iconConstructor)
{R31UserList.superConstructor.call(this,scrolling,iconConstructor);this.deletable=false;}

/*========== R31Icon.js ==========*/

R31Icon.extend(JUIComponent);R31Icon.classId="ddb15e77e97ff000";R31Icon.DEFAULT_WIDTH=60;R31Icon.DEFAULT_HEIGHT=80;R31Icon.DEFAULT_IMAGE_WIDTH=48;R31Icon.DEFAULT_IMAGE_HEIGHT=48;function R31Icon()
{R31Icon.superConstructor.call(this);this.iconUrl="";this.iconClass="";this.iconImage=null;this.caption="";this.absolute=true;this.visible=false;this._iconWidth=R31Icon.DEFAULT_IMAGE_WIDTH;this._iconHeight=R31Icon.DEFAULT_IMAGE_HEIGHT;this.setPreferredWidth(R31Icon.DEFAULT_WIDTH);this.setPreferredHeight(this._iconHeight+25);this.setIconImage();}
R31Icon.prototype.init=function()
{var _this=this;var root=this.createElement("DIV");this.root=root;root.className="R31Icon";with(root.style){textAlign="center";position="absolute";width=this.preferredWidth;height=this.preferredHeight;}
var imgBack=this.createElement("DIV");this.imgBack=imgBack;imgBack.className="R31IconBackground";with(imgBack.style){position="absolute";top=0;left=0;width=this.preferredWidth;height=this._iconHeight;}
root.appendChild(imgBack);var iconImage=JUI.makeImage(this.iconUrl,this);this.iconImage=iconImage;iconImage.className="R31IconImage";this.setToolTip();with(iconImage.style){position="absolute";top=0;left=(this.preferredWidth-this._iconWidth)/2;width=this._iconWidth;height=this._iconHeight;}
root.appendChild(iconImage);var captionLabel=this.createElement("DIV");this.captionLabel=captionLabel;captionLabel.appendChild(createText(this.caption));captionLabel.className="R31IconName";with(captionLabel.style){position="absolute";left=0;top=0;width=this.preferredWidth;height=24;textAlign="center";overflow="hidden";padding="0 1 0 1";}
var captionBox=this.createElement("DIV");this.captionBox=captionBox;captionBox.className="caption";with(captionBox.style){position="absolute";top=this._iconHeight+2;left=0;width=this.preferredWidth;height=25;textAlign="center";}
captionBox.appendChild(captionLabel);root.appendChild(captionBox);this.setPositioning(JUI.POSITION_ABSOLUTE);iconImage.ondragstart=function(evt){LD.Event.cancel(evt,true);}
iconImage.onmousedown=function(evt){LD.Event.cancel(evt,false);}
root.onmouseover=function(){_this.imgBack.className="R31IconBackground_over";}
root.onmouseout=function(){_this.imgBack.className="R31IconBackground";}
root.onmousedown=function(evt){_this.fireEvent(evt,JUI.EVT_MOUSE_DOWN);}
root.ondblclick=function(evt){_this.fireEvent(evt,JUI.EVT_MOUSE_DBLCLICK);_this.open();}}
R31Icon.prototype.open=function(evt,type,src)
{}
R31Icon.prototype.setCaption=function(caption)
{this.caption=varDefault(caption,"").toString();if(!this.root)return;this.captionLabel.appendChild(createText(this.caption));this.repaint();}
R31Icon.prototype.setToolTip=function(toolTip)
{this.iconImage.title=varDefault(toolTip,"");}
R31Icon.prototype.setIconImage=function(imageUrl)
{this.iconUrl=imageUrl||"";if(this.iconImage)
this.iconImage.src=this.iconUrl||JUI.nullImageSrc;}
R31Icon.prototype.repaint=function()
{R31Icon.superClass.repaint.call(this);if(this.root)LD.Element.wrapInnerText(this.captionLabel);}
R31FileIcon.extend(JUIComponent);R31FileIcon.classId="ddb15e77e97ff000";R31FileIcon.templates={base:"R31FileIcon"};R31FileIcon.DEFAULT_WIDTH=70;R31FileIcon.DEFAULT_HEIGHT=90;R31FileIcon.DEFAULT_IMAGE_WIDTH=48;R31FileIcon.DEFAULT_IMAGE_HEIGHT=48;R31FileIcon.nameEditBox=null;function R31FileIcon(fileSystemNode)
{R31FileIcon.superConstructor.call(this);this.setFileSystemNode(fileSystemNode);this.iconUrl="";this.iconClass="";this.thumbUrl="";this.iconImage=null;this.caption="";this.absolute=true;this.visible=false;this._iconWidth=R31FileIcon.DEFAULT_IMAGE_WIDTH;this._iconHeight=R31FileIcon.DEFAULT_IMAGE_HEIGHT;this.setPreferredWidth(R31FileIcon.DEFAULT_WIDTH);this.setPreferredHeight(this._iconHeight+40);}
R31FileIcon.prototype.init=function(htmlNode)
{R31FileIcon.superClass.init.call(this,htmlNode);var _this=this;var root=this.root;with(root.style){textAlign="center";position="absolute";width=this.preferredWidth;height=this.preferredHeight;}
this.html.image.src=this.iconUrl||JUI.nullImageSrc;this.html.image.className="image";this.html.thumbnail.src=this.thumbUrl||JUI.nullImageSrc;this.setIconImage();var sysData=this.fsNode.getSysData();this.caption=this.fsNode.getName();this.html.caption.appendChild(createText(this.caption));this.html.caption.onclick=function(evt){if(!_this.fsNode||!_this.fsNode.isWritable())return;_this.html.caption.innerHTML=_this.caption;R31FileIcon.nameEditBox.editElementContent(_this.html.controlLayer,getBounds(_this.html.controlLayer),120);R31FileIcon.nameEditBox.addListener(JUITextBox.EVT_EDIT_FINISHED,_this.nameEditFinished,_this);}
this.setToolTip();root.onmouseover=function(){_this.root.className+=" over ";_this.html.background.className="background background_over";_this.html.image.className=("image image_over "+_this.iconClass).rTrim(" ");_this.html.thumbnail.className="thumbnail thumbnail_over";_this.html.permission.className="permission permission_over";_this.html.caption.className="caption caption_over";_this.html.menu.className="menu menu_over";}
root.onmouseout=function(){_this.root.className=_this.root.className.replace(/[^\w]?over[^\w]?/gi," ");_this.html.background.className="background";_this.html.image.className=("image "+_this.iconClass).rTrim(" ");_this.html.thumbnail.className="thumbnail";_this.html.permission.className="permission";_this.html.caption.className="caption";_this.html.menu.className="menu";}
root.onmousedown=function(evt){_this.fireEvent(evt,JUI.EVT_MOUSE_DOWN);}
root.ondblclick=function(evt){_this.fireEvent(evt,JUI.EVT_MOUSE_DBLCLICK);}
this.html.image.ondragstart=this.html.thumbnail.ondragstart=function(evt){LD.Event.cancel(evt,true);}
this.html.image.onmousedown=this.html.thumbnail.onmousedown=function(evt){LD.Event.cancel(evt,false);}
this.html.menuAccess.onclick=function(evt){R31DesktopShell.doAction(R31.ACTION_INVITE,_this.fsNode);}
this.html.menuPlay.onclick=function(evt){evt=LD.Event.normalize(evt);evt.viewMode="play";_this.open(evt);}
this.html.menuMore.onclick=function(evt){if(_this.menu){_this.menu.setBoundComponent(_this);var xy=getXY(_this.root);var wh=getSize(_this.root);var buttonXY=getXY(this);var menuWH=getSize(_this.menu.getRoot());var menuX=xy.x+wh.width;var menuY=buttonXY.y;var menuParent=_this.menu.getParent();if(menuParent){var pb=menuParent.getBounds();if(menuX+menuWH.width>pb.width)
menuX=xy.x-menuWH.width;if(menuY+menuWH.height>pb.height)
menuY-=(menuY+menuWH.height-pb.height);}
_this.menu.setLocation(menuX,menuY);this.openThread=null;_this.menu.setVisible(true);}}
this.html.menuMore.onmouseover=function(evt){if(this.openThread!=null)return;var _this=this;this.openThread=setTimeout(function(){_this.onclick();},500);}
this.html.menuMore.onmouseout=function(evt){if(this.openThread!=null){clearTimeout(this.openThread);this.openThread=null;}}
if(R31FileIcon.nameEditBox==null){R31FileIcon.nameEditBox=new JUITextBox();R31FileIcon.nameEditBox.init();R31FileIcon.nameEditBox.setVisible(false);R31FileIcon.nameEditBox.setMaxLength=FileSystem.FILENAME_MAX_LENGTH;var top=JUI.getTopContainer();if(top!=null)
top.add(R31FileIcon.nameEditBox,JUI.LAYER_POPUP);}
this.setPermissionImage();this.repaint();}
R31FileIcon.prototype.getModel=function()
{return this.fsNode;}
R31FileIcon.prototype.getFileSystemNode=function()
{return this.fsNode;}
R31FileIcon.prototype.setFileSystemNode=function(node)
{if(!(node instanceof FileSystemNode))
throw"R31FileIcon.setFileSystemNode: node must be a FileSystemNode";if(this.fsNode)
this.fsNode.removeListener(FileSystem.EVT_NODE_CHANGED,this);this.fsNode=node;this.fsNode.addListener(FileSystem.EVT_NODE_CHANGED,this.sourceChanged,this);}
R31FileIcon.prototype.getTransferable=function()
{return this.fsNode;}
R31FileIcon.prototype.nameEditFinished=function(evt,type,src)
{R31FileIcon.nameEditBox.removeListener(JUITextBox.EVT_EDIT_FINISHED,this);if(!evt||!this.fsNode)return false;var newName=varDefault(evt.value);if(newName==""||newName==this.fsNode.getName())return;if(FileSystem.isValidFileName(newName)){this.fsNode.rename(newName,function(result){if(result!==true)FileSystem.raiseError(result);});}
else{var details={action:FileSystem.ACTION_RENAME,node:this.fsNode};FileSystem.raiseError(LD.ERR_FS_INVALID_NAME,"Invalid file name",details);}}
R31FileIcon.prototype.setToolTip=function(toolTip)
{if(!this.root)return;var msg="%1";if(this.fsNode.sysId==FileSystem.TRASHBIN_SYS_ID)
this.html.image.title=__("Trash Bin");else
this.html.image.title=msg.parse((typeof(toolTip)!="undefined")?varDefault(toolTip,""):this.fsNode.getName());}
R31FileIcon.prototype.setIconImage=function(imageUrl)
{imageUrl=varDefault(imageUrl,"").toString();var node=this.fsNode;var type=node.getType();this.thumbUrl="";if(node.status==FileSystem.FILE_REQUEST_PENDING)
{this.iconUrl="";this.iconClass="file_default";}
else if(imageUrl!=""){this.iconUrl=imageUrl||"";this.iconClass="";}
else if(type==FileSystem.NODE_TYPE_FILE){var td=node.getTypeDescriptor();this.iconUrl="";if(td!=null){var mimeType=td.getMimeType();this.iconClass=td.getDefaultIcon();if(node.isAvailable()&&node.hasThumbnail()&&(mimeType=="image"||mimeType=="video")){this.thumbUrl=node.thumbnailURL;}}
else{this.iconClass="file_default";}}
else if(type==FileSystem.NODE_TYPE_DIR)
{var name=node.getName();this.iconUrl="";if(name=='my music'){this.iconClass="folder_music";}
else if(name=='my movies'){this.iconClass="folder_movies";}
else if(name=='my pictures'){this.iconClass="folder_pictures";}
else{this.iconClass="folder";}}
else if(type==FileSystem.NODE_TYPE_LINK)
{if(node.hasThumbnail()&&node.status==FileSystem.FILE_AVAILABLE)
this.thumbUrl=node.thumbnailURL;this.iconUrl=getImageURL("/skins/"+JUI.currentSkin+"/file_web_link_a.png");}
else{this.iconUrl=DIR_IMAGES+"icon_unknown.gif";}
if(this.root!=null){this.html.image.src=this.iconUrl||JUI.nullImageSrc;if(this.iconUrl==""&&this.iconClass!=""){this.html.image.className="image "+this.iconClass;}
else{this.html.image.className="image";}
this.html.thumbnail.src=this.thumbUrl||JUI.nullImageSrc;this.html.thumbnail.style.visibility=(this.thumbUrl!="")?"visible":"hidden";this.setToolTip();}}
R31FileIcon.prototype.open=function(evt,type,src)
{if(!this.fsNode)return;evt=LD.Event.normalize(evt);if(evt.viewMode=='play'&&(this.fsNode.isDirectory()||R31.isPlayableMedia(this.fsNode)))
R31DesktopShell.doAction(R31.ACTION_FS_NODE_PLAY_MEDIA,this.fsNode);else
R31DesktopShell.doAction(R31.ACTION_OPEN,this.fsNode);}
R31FileIcon.prototype.drop=function(evt,type,src)
{var dragOp=evt.dragOp;if(!(dragOp instanceof JUIDragOperation))
throw"R31FileIcon.drop: Must provide an event with a JUIDragOperation object";var comp=evt.dragOp.getComponent();var sourceNode=evt.dragOp.getTransferable();if(sourceNode instanceof FileSystemNode){var targetNode=this.getFileSystemNode();this._dropAction=dragOp;if(evt.ctrlKey==false&&evt.shiftKey==false)
this.moveActionStarted(sourceNode);else
this.copyActionStarted(sourceNode);}}
R31FileIcon.prototype.moveActionStarted=function(sourceNode)
{if(!(sourceNode instanceof FileSystemNode))
throw new LD.Exception(null,"Source node must be a FileSystem node instance");var targetNode=this.getFileSystemNode();sourceNode.addListener(FileSystem.EVT_NODE_MOVED,this.moveActionEnded,this);R31DesktopShell.doAction(R31.ACTION_FS_NODE_MOVE,sourceNode,{target:targetNode});}
R31FileIcon.prototype.moveActionEnded=function(evt,type,src)
{if(this._dropAction)
this._dropAction=null;var sourceNode=evt.node;if(sourceNode instanceof FileSystemNode)
sourceNode.removeListener(FileSystem.EVT_NODE_MOVED,this.moveActionEnded,this);}
R31FileIcon.prototype.copyActionStarted=function(sourceNode)
{if(!(sourceNode instanceof FileSystemNode))
throw new LD.Exception(null,"Source node must be a FileSystem node instance");var targetNode=this.getFileSystemNode();sourceNode.addListener(FileSystem.EVT_NODE_COPIED,this.copyActionEnded,this);R31DesktopShell.doAction(R31.ACTION_FS_NODE_COPY,sourceNode,{target:targetNode});}
R31FileIcon.prototype.copyActionEnded=function(evt,type,src)
{if(this._dropAction)
this._dropAction=null;var sourceNode=evt.node;if(sourceNode instanceof FileSystemNode)
sourceNode.removeListener(FileSystem.EVT_NODE_COPIED,this.copyActionEnded,this);}
R31FileIcon.prototype.sourceChanged=function(evt,type,src)
{if(!this.root)return;this.setFileSystemNode(FileSystem.getNode(this.fsNode.getId()));this.setIconImage();this.caption=this.fsNode.getName();LD.Element.removeChildren(this.html.caption);this.html.caption.appendChild(createText(this.caption));this.setPermissionImage();this.repaint();}
R31FileIcon.prototype.repaint=function()
{R31FileIcon.superClass.repaint.call(this);if(this.root)
LD.Element.wrapInnerText(this.html.caption);}
R31FileIcon.prototype.setMenu=function(menu)
{this.menu=menu;}
R31FileIcon.prototype.getMenu=function()
{return this.menu;}
R31FileIcon.prototype.setPermissionImage=function()
{if(this.fsNode.isPrivate())
{this.html.permission.src=getImageURL("/skins/"+JUI.currentSkin+"/filePrivate.png");this.html.permission.style.visibility="visible";}
else if(this.fsNode.isFriends())
{this.html.permission.src=getImageURL("/skins/"+JUI.currentSkin+"/fileFriends.png");this.html.permission.style.visibility="visible";}
else
{this.html.permission.src=JUI.nullImageSrc;this.html.permission.style.visibility="hidden";}}
R31WixiTVIcon.extend(R31FileIcon);R31WixiTVIcon.templates={base:"R31FileIcon"};function R31WixiTVIcon(fileSystemNode)
{R31TrashBinIcon.superConstructor.call(this,fileSystemNode);}
R31WixiTVIcon.prototype.init=function()
{R31TrashBinIcon.superClass.init.call(this);this.html.title="Create your own TV: all media files in this folder will be seen by visitors when they open your Wixi";}
R31WixiTVIcon.prototype.setIconImage=function(imageUrl)
{var wixiTvIconUrl=getImageURL("/skins/"+JUI.currentSkin+"/folder_wixi_tv.png");R31WixiTVIcon.superClass.setIconImage.call(this,imageUrl||wixiTvIconUrl);}
R31WixiTVIcon.prototype.setToolTip=function(toolTip)
{if(!this.root)return;this.html.image.title=__("All media files in this folder will be seen by visitors when they open your Wixi");}
R31TrashBinIcon.extend(R31FileIcon);R31TrashBinIcon.templates={base:"R31FileIcon"};function R31TrashBinIcon(fileSystemNode)
{R31TrashBinIcon.superConstructor.call(this,fileSystemNode);}
R31TrashBinIcon.prototype.init=function()
{R31TrashBinIcon.superClass.init.call(this);this.caption=__("Trash Bin");LD.Element.removeChildren(this.html.caption);this.html.caption.appendChild(createText(this.caption));}
R31TrashBinIcon.prototype.sourceChanged=function(evt,type,src)
{}
R31TrashBinIcon.prototype.setIconImage=function(imageUrl)
{var node=this.fsNode;imageUrl=varDefault(imageUrl,JUI.nullImageSrc);if(imageUrl!=JUI.nullImageSrc)
this.iconUrl=imageUrl;else
this.iconUrl=getImageURL("/skins/"+JUI.currentSkin+"/icon_trashbin.gif");if(!this.root)return;this.html.image.src=this.iconUrl;this.html.thumbnail.style.visibility="hidden";}
R31TrashNodeIcon.extend(R31FileIcon);R31TrashNodeIcon.templates={base:"R31FileIcon"};function R31TrashNodeIcon(fileSystemNode)
{R31TrashNodeIcon.superConstructor.call(this,fileSystemNode);}
R31TrashNodeIcon.prototype.init=function()
{R31FileIcon.prototype.init.call(this);this.sourceChanged();}
R31TrashNodeIcon.prototype.sourceChanged=function(evt,type,src)
{if(!this.root||!this.fsNode)return;this.caption=this.fsNode.getSysData("name")||this.fsNode.getName();LD.Element.removeChildren(this.html.caption);this.html.caption.appendChild(createText(this.caption));}
R31TrashNodeIcon.prototype.drop=function(evt,type,src)
{}
R31TrashNodeIcon.prototype.moveActionStarted=function(sourceNode)
{}
R31TrashNodeIcon.prototype.moveActionEnded=function(evt,type,src)
{}
R31UserIcon.extend(JUIComponent);R31UserIcon.templates={base:"R31UserIcon"};R31UserIcon.DEFAULT_WIDTH=60;R31UserIcon.DEFAULT_HEIGHT=80;R31UserIcon.DEFAULT_IMAGE_WIDTH=48;R31UserIcon.DEFAULT_IMAGE_HEIGHT=48;function R31UserIcon(user)
{R31UserIcon.superConstructor.call(this);this.setUser(user);this.iconUrl=JUI.nullImageSrc;this.absolute=true;this.visible=false;this.deletable=false;this.starrable=false;this.readOnlyStar=false;this.imageDisabled=true;this._iconWidth=R31UserIcon.DEFAULT_IMAGE_WIDTH;this._iconHeight=R31UserIcon.DEFAULT_IMAGE_HEIGHT;this.setPreferredWidth(R31UserIcon.DEFAULT_WIDTH);this.setPreferredHeight(this._iconHeight+18);this.refreshQueued=0;}
R31UserIcon.prototype.init=function(htmlNode)
{R31UserIcon.superClass.init.call(this,htmlNode);var _this=this;var root=this.root;this.html.image.onclick=function(){_this.doUserAction();}
root.onmouseover=function(){var c=["caption","caption_over"];if(_this.html.selector.checked)
c.push("caption_selected");_this.html.caption.className=c.join(" ");_this.html.revokeFriendship.style.display=_this.deletable?"block":"none";}
root.onmouseout=function(){if(_this.isFriendshipPending())
_this.html.caption.className="caption caption_pending";else{var c=["caption"];if(_this.html.selector.checked)
c.push("caption_selected");_this.html.caption.className=c.join(" ");}
_this.html.revokeFriendship.style.display="none";}
this.html.revokeFriendship.onclick=function(){R31DesktopShell.doAction(R31.ACTION_REVOKE_FRIENDSHIP,_this.user);}
if(this.starrable&&this.html.starFriend){this.html.starFriend.onclick=function(){R31DesktopShell.doAction(R31.ACTION_STAR_FRIEND,_this.user,!_this.user.starred);}}
this.html.caption.onclick=function(){_this.doUserAction();}
if(this.html.onlineStatus&&this.user!=null){this.html.onlineStatus.src="http://presence.meebo.com/statusimg?uid="+this.user.name+"&partner=wixi";}
this.refresh();}
R31UserIcon.prototype.getUser=function()
{return this.user;}
R31UserIcon.prototype.setUser=function(user)
{this.user=user||null;this.refresh();}
R31UserIcon.prototype.isSelected=function()
{return false;}
R31UserIcon.prototype.setSelected=function(selected)
{}
R31UserIcon.prototype.getFriendshipStatus=function()
{return this.user?this.user.getFriendshipStatus():null;}
R31UserIcon.prototype.isFriendshipPending=function()
{return this.user?this.user.isPending():false;}
R31UserIcon.prototype.doUserAction=function()
{if(!this.user)return false;var status=this.getFriendshipStatus();if(status==R31User.FRIENDSHIP_PENDING_OTHER_USER){R31DesktopShell.doAction(R31.ACTION_ANSWER_FRIENDSHIP,this.user);}
else if(status==R31User.FRIENDSHIP_PENDING_SAME_USER){var msg=this.user.name+" has not accepted your friendship request yet. Do you want to visit his/her Wixi ?";var opt={"messageType":JUIDialogWindow.QUESTION};var _this=this;JUI.getTopContainer().showPopupWindow(JUIDialogWindow.makeDialog(msg,"Wixi",opt,function(dialog,returnValue){if(returnValue==1)
R31DesktopShell.doAction(R31.ACTION_OPEN,_this.user);}));}
else{R31DesktopShell.doAction(R31.ACTION_OPEN,this.user);}
this.fireEvent({user:this.user},JUI.EVT_MOUSE_CLICK);}
R31UserIcon.prototype.repaint=function()
{if(!this.root)return;R31UserIcon.superClass.repaint.call(this);LD.Element.wrapInnerText(this.captionLabel);}
R31UserIcon.prototype.isImageDisabled=function(disabled)
{return this.imageDisabled;}
R31UserIcon.prototype.setImageDisabled=function(disabled)
{this.imageDisabled=(disabled==true);this.refresh();}
R31UserIcon.prototype.refresh=function()
{var _this=this;if(this.refreshQueued==0)
{this.refreshQueued=setTimeout(function()
{if(!_this.root)return;var status=_this.getFriendshipStatus();var userName="",avatar="";if(_this.user!=null){userName=_this.user.getName();_this.html.revokeFriendship.style.display=_this.deletable?"":"none";if(_this.imageDisabled!=true){avatar=_this.user.getAvatar();if(avatar!="")
avatar=getAvatarURL(avatar);}}
if(status==R31User.FRIENDSHIP_ACCEPTED){_this.html.revokeFriendship.style.display="";}
else if(status==R31User.FRIENDSHIP_PENDING_SAME_USER){avatar=DIR_IMAGES+"avatar_pending_friend.jpg";_this.html.revokeFriendship.style.display="none";_this.html.caption.className="caption caption_pending";}
else if(status==R31User.FRIENDSHIP_PENDING_OTHER_USER){avatar=DIR_IMAGES+"avatar_pending_user.jpg";_this.html.revokeFriendship.style.display="none";_this.html.caption.className="caption caption_pending";}
if(_this.starrable){LD.Element.putClass(_this.root,"starrable");if(_this.readOnlyStar){LD.Element.putClass(_this.root,"readOnlyStar");}
if(_this.html.starFriend){if(_this.user&&_this.user.starred){LD.Element.putClass(_this.html.starFriend,"starred");}else{LD.Element.removeClass(_this.html.starFriend,"starred");}}}else{LD.Element.removeClass(_this.root,"starrable");}
LD.Element.writeText(_this.html.caption,userName.truncate(15,"..."),true);_this.html.image.src=(avatar!="")?avatar:R31.DEFAULT_AVATAR;if(_this.html.onlineStatus&&_this.user!=null){_this.html.onlineStatus.src="";_this.html.onlineStatus.src="http://presence.meebo.com/statusimg?uid="+_this.user.name+"&partner=wixi";}
_this.refreshQueued=0;},50);}}
R31UserIcon.prototype.isDeletable=function()
{return this.deletable;}
R31UserIcon.prototype.setDeletable=function(deletable)
{this.deletable=(deletable==true);this.refresh();}
R31UserIcon.prototype.isStarrable=function()
{return this.starrable;}
R31UserIcon.prototype.setStarrable=function(starrable,readOnly)
{this.starrable=(starrable==true);this.readOnlyStar=(readOnly==true);this.refresh();}
R31UserIcon.prototype.drop=function(evt,type,src)
{var dragOp=evt.dragOp;if(!(dragOp instanceof JUIDragOperation))
throw"R31FileIcon.drop: Must provide an event with a JUIDragOperation object";var comp=evt.dragOp.getComponent();var sourceNode=evt.dragOp.getTransferable();if(sourceNode instanceof FileSystemNode){var targetNode=this.getFileSystemNode();this._dropAction=dragOp;}}
R31FriendEntry.extend(R31UserIcon);R31FriendEntry.templates={base:"R31FriendEntry"};R31FriendEntry.DEFAULT_WIDTH=80;R31FriendEntry.DEFAULT_HEIGHT=100;R31FriendEntry.DEFAULT_IMAGE_WIDTH=60;R31FriendEntry.DEFAULT_IMAGE_HEIGHT=60;function R31FriendEntry(user)
{R31FriendEntry.superConstructor.call(this,user);}
R31FriendEntry.prototype.init=function(user)
{R31FriendEntry.superClass.init.call(this,user);this._iconWidth=R31FriendEntry.DEFAULT_IMAGE_WIDTH;this._iconHeight=R31FriendEntry.DEFAULT_IMAGE_HEIGHT;this.setPreferredWidth(R31FriendEntry.DEFAULT_WIDTH);this.setPreferredHeight(this._iconHeight+40);var _this=this;this.html.selector.onclick=this.html.selector.onchange=function(evt){evt=LD.Event.normalize(evt);evt.user=_this.user;evt.selected=(this.checked==true);_this.fireEvent(evt,JUI.EVT_CHANGED);}}
R31FriendEntry.prototype.doUserAction=function()
{this.setSelected(!this.isSelected());}
R31FriendEntry.prototype.isSelected=function()
{if(!this.root)return false;return this.html.selector.checked;}
R31FriendEntry.prototype.setSelected=function(selected)
{if(!this.root)return;selected=(selected==true);if(this.html.selector.checked!=selected){this.html.selector.click();}
var c=(this.html.caption.className||"").split(" ");if(this.html.selector.checked&&!inArray(c,"caption_selected"))
c.push("caption_selected");else if(inArray(c,"caption_selected"))
{c.pop();}
this.html.caption.className=c.join(" ");}

/*========== R31FileEntry.js ==========*/

R31FileEntry.extend(JUIComponent);R31FileEntry.templates={base:"R31FileEntry"};function R31FileEntry(fileSystemNode)
{R31FileEntry.superConstructor.call(this);this.fsNode=fileSystemNode||null;this.iconUrl="";this.iconClass="";this.absolute=true;this.visible=false;this.width=200;this.height=22;}
R31FileEntry.prototype.init=function(htmlNode)
{R31FileEntry.superClass.init.call(this,htmlNode);var _this=this;var root=this.root;root.onmousedown=function(evt){_this.fireEvent(evt,JUI.EVT_MOUSE_DOWN);}
var name="",type=null,td=null,path="",size=0;if(this.fsNode){name=this.fsNode.getName();type=this.fsNode.getType();td=FileSystem.getTypeDescriptor(FileSystem.getExtension(name));path=this.fsNode.getPath();size=this.fsNode.getSize();this.fsNode.addListener(FileSystem.EVT_NODE_CHANGED,this.sourceChanged,this);}
LD.Element.writeText(this.html.fileName,name);this.html.fileName.onclick=function(){R31DesktopShell.doAction(R31.ACTION_OPEN,_this.fsNode);}
LD.Element.writeText(this.html.fileSize,(type==FileSystem.NODE_TYPE_FILE)?(Math.round(size/1024)+" k"):"");this.html.menu.onclick=function(evt){var that=_this;if(_this.menu){if(Browser.isIE)evt=LD.Event.normalize(evt);if(!evt.target)return;R31Action.validate(R31Action.DOWNLOAD_NODE,_this.fsNode,R31UserRegistry.getLoggedUser(),function(){that.menu.getItem("save").setEnabled(true);});_this.menu.setBoundComponent(_this);var xy=getXY(evt.target);var wh=getSize(evt.target);_this.menu.setLocation(xy.x,xy.y+wh.height-1);_this.menu.setVisible(true);}}
JUI.makeSelectable(this.root,null,true);this.setIconImage();this.repaint();}
R31FileEntry.prototype.getModel=function()
{return this.fsNode;}
R31FileEntry.prototype.getFileSystemNode=function()
{return this.fsNode;}
R31FileEntry.prototype.setToolTip=function(toolTip)
{if(typeof(toolTip)!="undefined")
this.html.fileType.title=varDefault(toolTip,"");else
this.html.fileType.title=this.fsNode.getPath();this.root.title=this.html.fileType.title;}
R31FileEntry.prototype.setIconImage=function(imageUrl)
{var node=this.fsNode;var iconClass="file_default";var iconUrl="";var type=node.getType();if(node.status==FileSystem.FILE_REQUEST_PENDING){iconClass="file_default";}
else if(imageUrl){iconUrl=imageUrl;}
else if(type==FileSystem.NODE_TYPE_FILE){var td=node.getTypeDescriptor();if(td!=null){iconClass=td.getDefaultIcon();}}
else if(type==FileSystem.NODE_TYPE_DIR){iconClass="folder";}
else if(type==FileSystem.NODE_TYPE_LINK){iconClass="file_web_link";}
if(this.html.fileType){LD.Element.putClass(this.html.fileType,iconClass)
this.setToolTip();}
this.iconClass=iconClass;this.iconUrl=iconUrl;}
R31FileEntry.prototype.open=function(evt,type,src)
{if(this.fsNode)
R31DesktopShell.doAction(R31.ACTION_OPEN,this.fsNode);}
R31FileEntry.prototype.getTransferable=function()
{return this.fsNode;}
R31FileEntry.prototype.getVisualDraggable=function()
{var draggable=LD.Element.create("DIV",{className:"R31FileEntryLayer R31FileEntryName"},{position:"absolute",width:200,height:20,color:"black",backgroundColor:"#dddddd"});draggable.innerHTML=this.fsNode?this.fsNode.getName():"";if(Browser.isIE)
draggable.style.filter="Alpha(opacity=67)";else
draggable.style.opacity=0.67;return{"component":null,"htmlNode":draggable,"disposeOnFinish":true};}
R31FileEntry.prototype.drop=function(evt,type,src)
{var dragOp=evt.dragOp;if(!(dragOp instanceof JUIDragOperation))
throw"R31FileEntry.drop: Must provide an event with a JUIDragOperation object";var comp=evt.dragOp.getComponent();var sourceNode=evt.dragOp.getTransferable();if(sourceNode instanceof FileSystemNode){var targetNode=this.getFileSystemNode();this._dropAction=dragOp;if(evt.ctrlKey==false)
this.moveActionStarted(sourceNode);else{this.copyActionStarted(sourceNode);}}}
R31FileEntry.prototype.moveActionStarted=function(sourceNode)
{if(!(sourceNode instanceof FileSystemNode))
throw new LD.Exception(null,"Source node must be a FileSystem node instance");var targetNode=this.getFileSystemNode();sourceNode.addListener(FileSystem.EVT_NODE_MOVED,this.moveActionEnded,this);R31DesktopShell.doAction(R31.ACTION_FS_NODE_MOVE,sourceNode,{target:targetNode});}
R31FileEntry.prototype.moveActionEnded=function(evt,type,src)
{if(this._dropAction)
this._dropAction=null;var sourceNode=evt.node;if(sourceNode instanceof FileSystemNode)
sourceNode.removeListener(FileSystem.EVT_NODE_MOVED,this.moveActionEnded,this);}
R31FileEntry.prototype.copyActionStarted=function(sourceNode)
{if(!(sourceNode instanceof FileSystemNode))
throw new LD.Exception(null,"Source node must be a FileSystem node instance");var targetNode=this.getFileSystemNode();sourceNode.addListener(FileSystem.EVT_NODE_COPIED,this.copyActionEnded,this);R31DesktopShell.doAction(R31.ACTION_FS_NODE_COPY,sourceNode,{target:targetNode});}
R31FileEntry.prototype.copyActionEnded=function(evt,type,src)
{if(this._dropAction)
this._dropAction=null;var sourceNode=evt.node;if(sourceNode instanceof FileSystemNode)
sourceNode.removeListener(FileSystem.EVT_NODE_COPIED,this.copyActionEnded,this);}
R31FileEntry.prototype.repaint=function()
{if(!this.root)return;R31FileEntry.superClass.repaint.call(this);this.refresh();}
R31FileEntry.prototype.sourceChanged=function(evt,type,src)
{if(!this.root)return;this.setIconImage();this.refresh();}
R31FileEntry.prototype.refresh=function()
{if(this.fsNode){LD.Element.writeText(this.html.fileName,this.getSourceName(),true);LD.Element.wrapInnerText(this.html.fileName);}}
R31FileEntry.prototype.setMenu=function(menu)
{this.menu=menu;}
R31FileEntry.prototype.getMenu=function()
{return this.menu;}
R31FileEntry.prototype.getSourceName=function()
{return(this.fsNode)?this.fsNode.getName():"";}
R31TrashNodeEntry.extend(R31FileEntry);R31TrashNodeEntry.templates={base:"R31FileEntry"};function R31TrashNodeEntry(fileSystemNode)
{R31TrashNodeEntry.superConstructor.call(this,fileSystemNode);}
R31TrashNodeEntry.prototype.getSourceName=function()
{return(this.fsNode)?(this.fsNode.getSysData("name")||this.fsNode.getName()):"";}
R31TrashNodeEntry.prototype.drop=function(evt,type,src)
{}
R31TrashNodeEntry.prototype.moveActionStarted=function(sourceNode)
{}
R31TrashNodeEntry.prototype.moveActionEnded=function(evt,type,src)
{}

/*========== R31MediaPlayer.js ==========*/

R31MediaPlayer.extend(JUIFlashClip);R31MediaPlayer.ADD="add";R31MediaPlayer.REPLACE="replace";R31MediaPlayer.DEFAULT_WIDTH=470;R31MediaPlayer.DEFAULT_HEIGHT=370;R31MediaPlayer.currentVersion=null;R31MediaPlayer.instances=new Array();R31MediaPlayer.nextId=1;R31MediaPlayer.debug=true;function R31MediaPlayer(source)
{R31MediaPlayer.superConstructor.call(this,"wixiplayer.swf?v="+(R31MediaPlayer.currentVersion||""),true,true);this.playerInstanceId=R31MediaPlayer.registerInstance(this);this.fsSource=source;this.playlist=null;this.mediator=null;this.scriptAccess="sameDomain";if(source instanceof FileSystemDirectory){this.putEntries(source.getChildren());}
else if(source instanceof FileSystemFile||source instanceof FileSystemLink){this.putEntries([source]);}
else if(source instanceof Array){this.putEntries(source);}}
R31MediaPlayer.getInstance=function(instanceId)
{instanceId=intVal(instanceId);if(!instanceId)return null;return R31MediaPlayer.instances[instanceId]||null;}
R31MediaPlayer.registerInstance=function(player)
{if(inArray(R31MediaPlayer.instances,player))return;var id=R31MediaPlayer.getNextId();R31MediaPlayer.instances[id]=player;return id;}
R31MediaPlayer.getNextId=function()
{return R31MediaPlayer.nextId++;}
R31MediaPlayer.debug=function(data)
{}
R31MediaPlayer.getEmbeddedPlayerHTML=function(embedValue)
{embedValue=escape(embedValue);var html='<object type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"'+' data="http://beta.wixi.com/wixiplayer.swf?embedplay='+embedValue+'" width="480" height="360"'+' allowfullscreen="true" embedplay="'+embedValue+'" WMODE="opaque">'+'<param name="movie" value="http://beta.wixi.com/wixiplayer.swf?embedplay='+embedValue+'">'+'<param name="width" value="480">'+'<param name="height" value="360">'+'<param name="allowfullscreen" value="true">'+'<param name="WMODE" value="opaque">'+'</object>';return html;}
R31MediaPlayer.prototype.getPlayerInstanceId=function()
{return this.playerInstanceId;}
R31MediaPlayer.prototype.getLogInfo=function()
{var val=(this.fsSource instanceof FileSystemNode)?this.fsSource.getId():"";return{tag:"wixi_player",value:val};}
R31MediaPlayer.prototype.getMediator=function()
{return this.mediator;}
R31MediaPlayer.prototype.setMediator=function(mediator)
{if(mediator!=null&&!instanceOf(mediator,MediaPlayerMediator))
throw"R31MediaPlayer.setMediator: mediator must implement MediaPlayerMediator interface";this.mediator=mediator||null;}
R31MediaPlayer.prototype.putEntries=function(entries)
{if(!(entries instanceof Array))
throw"R31MediaPlayer.putEntries: Must provide an array of items to play";var room=R31UserRegistry.getCurrentRoom();var user=R31UserRegistry.getLoggedUser();var playlist={informations:{wixi:(room?room.name:null),phpsessionid:LD.Cookie.get("PHPSESSID"),command:R31MediaPlayer.REPLACE},media:new Array()}
var entry,mediaEntry,td,type,subtype;for(var i=0;i<entries.length;i++){entry=entries[i];if((entry instanceof FileSystemFile||entry instanceof FileSystemLink)&&entry.isAvailable()){td=FileSystem.getTypeDescriptor(entry.getExtension());if(!td)continue;type=td.getMimeType();subtype=td.getMimeSubtype();if(inArray(["image","video","audio"],type)){try{if(entry.sysData&&typeof(entry.sysData.name)=="string"){entry.name=entry.sysData.name;}
playlist.media.push(new R31MediaPlayerEntry(entry,user));}
catch(e){}}}}
this.playlist=playlist;}
R31MediaPlayer.prototype.waitForAvailability=function()
{}
R31MediaPlayer.prototype.refreshPlaylist=function()
{var loopCaller=function(){var _func=arguments.callee;var xml;if(_func.player.isAvailable()){xml=_func.player.getPlaylistXml();_func.player.sendVar("xmlcontent",xml);var evt={playlist:xml};_func.player.fireEvent(evt,JUIFlashClip.EVT_MEDIA_LOADED);}
else{if(_func.attemptCount++<_func.attemptLimit)setTimeout(_func,200);}}
loopCaller.attemptCount=0;loopCaller.attemptLimit=40;loopCaller.player=this;loopCaller();}
R31MediaPlayer.prototype.getPlaylistXml=function()
{var pl=this.playlist;var user=R31UserRegistry.getLoggedUser();var room=R31UserRegistry.getCurrentRoom();var embedValue="";if(this.fsSource instanceof FileSystemNode)
embedValue="1"+hex(this.fsSource.getOwner()).padLeft(8,"0")+hex(this.fsSource.getId()).padLeft(8,"0");var xml='<xml>'+LD.LF+'<informations>'+LD.LF+
((pl.informations.wixi!=null)?('<wixi>'+pl.informations.wixi+'</wixi>'+LD.LF):'')+'<instanceid>'+this.getPlayerInstanceId()+'</instanceid>'+LD.LF+'<userid>'+(user?user.id:0)+'</userid>'+LD.LF+'<roomid>'+(room?room.id:0)+'</roomid>'+LD.LF+'<phpsessionid>'+pl.informations.phpsessionid+'</phpsessionid>'+LD.LF+'<command>'+pl.informations.command+'</command>'+LD.LF+'<embedvalue>'+embedValue+'</embedvalue>'+LD.LF+'</informations>'+LD.LF+'<playlist>'+LD.LF;for(var i=0;i<pl.media.length;i++){xml+=pl.media[i].toXml()+LD.LF;}
xml+='</playlist>'+LD.LF+'</xml>';return xml;}
R31MediaPlayer.prototype.addMediaToDesktop=function(mediaUrl,type,title)
{if(!this.mediator)return;this.mediator.addMediaFromPlayer(mediaUrl,type,title);}
R31MediaPlayer.prototype.share=function(emailVarList)
{if(!this.mediator)return;this.mediator.shareMedia(arguments);}
R31MediaPlayer.prototype.fitContainerToMedia=function(width,height)
{if(!this.mediator)return;this.mediator.fitContainerToMedia(width,height);}
R31MediaPlayer.prototype.setFullScreen=function(fullScreen)
{if(!this.mediator)return;this.mediator.setFullScreen(fullScreen);}
function R31MediaPlayerEntry(source,user)
{if(!(source instanceof FileSystemNode))
throw"R31MediaPlayerEntry: Must provide a FileSystemNode source object";var td=FileSystem.getTypeDescriptor(source.getExtension());var type=(td!=null)?td.getMimeType():"";if(type=="video")
this.mediaType="vid";else if(type=="image")
this.mediaType="img";else if(type=="audio")
this.mediaType="mp3";else
this.mediaType="";if(source instanceof FileSystemFile){this.id="1"+hex(user?user.id:0).padLeft(8,'0')+hex(source.getId()).padLeft(8,'0');this.fileName=source.getName();this.target=source.getTarget()||"";this.url="";this.title=source.getBaseName();switch(source.getAccessLevel()){case FileSystem.ACCESS_PUBLIC:this.access="public";break;case FileSystem.ACCESS_FRIENDS:this.access="friends";break;case FileSystem.ACCESS_PRIVATE:this.access="private";break;}
this.hash=source.getHash();this.size=source.getSize();this.thumb=source.hasThumbnail()?1:0;var d=stringToDate(source.getCreationTime());this.date=[d.getUTCFullYear().toString().padLeft(4,'0'),(d.getUTCMonth()+1).toString().padLeft(2,'0'),d.getUTCDate().toString().padLeft(2,'0')].join("/");this.tags=source.getTags()||"";this.desc=source.getDescription()||"";}
else if(source instanceof FileSystemLink){this.id="";this.fileName=source.getName();this.url=source.getTarget();this.title=source.getBaseName();switch(source.getAccessLevel()){case FileSystem.ACCESS_PUBLIC:this.access="public";break;case FileSystem.ACCESS_FRIENDS:this.access="friends";break;case FileSystem.ACCESS_PRIVATE:this.access="private";break;}
this.hash="";this.size="";this.thumb=0;var d=stringToDate(source.getCreationTime());this.date=[d.getUTCFullYear().toString().padLeft(4,'0'),(d.getUTCMonth()+1).toString().padLeft(2,'0'),d.getUTCDate().toString().padLeft(2,'0')].join("/");this.tags=source.getTags()||"";this.desc=source.getDescription()||"";}
else{throw"R31MediaPlayerEntry: Invalid source";}
var td=FileSystem.getTypeDescriptor(source.getExtension());var type=(td!=null)?td.getMimeType():"";if(type=="video")
this.mediaType="vid";else if(type=="image")
this.mediaType="img";else if(type=="audio")
this.mediaType="mp3";else
this.mediaType="";var d=stringToDate(source.getCreationTime());this.date=[d.getUTCFullYear().toString().padLeft(4,'0'),(d.getUTCMonth()+1).toString().padLeft(2,'0'),d.getUTCDate().toString().padLeft(2,'0')].join("/");this.tags=source.getTags()||"";this.desc=source.getDescription()||"";}
R31MediaPlayerEntry.prototype.toXml=function()
{var xml='<media>'+LD.LF+
((this.id!="")?('<id>'+this.id+'</id>'+LD.LF):'')+
((this.url!="")?('<url>'+this.url+'</url>'+LD.LF):'')+'<filename>'+this.fileName+'</filename>'+LD.LF+'<target>'+this.target+'</target>'+LD.LF+'<type>'+this.mediaType+'</type>'+LD.LF+'<title>'+this.title+'</title>'+LD.LF+'<access>'+this.access+'</access>'+LD.LF+'<size>'+this.size+'</size>'+LD.LF+'<date>'+this.date+'</date>'+LD.LF+'<thumb>'+this.thumb+'</thumb>'+LD.LF+
((this.tags!="")?('<tags>'+this.tags+'</tags>'+LD.LF):'')+
((this.desc!="")?('<desc>'+this.desc+'</desc>'+LD.LF):'')+'</media>';return xml;}
R31MediaPlayerController.extend(LD.Proto);function R31MediaPlayerController(player,container)
{if(!player instanceof R31MediaPlayer)
throw"R31MediaPlayerController: must provide a R31MediaPlayer instance"
if(!container instanceof JUIContainer)
throw"R31MediaPlayerController: must provide a JUIContainer object that holds the media player";this.player=player;this.playerContainer=container;}
R31MediaPlayerController.prototype.getFileSystemSource=function()
{if(this.playerContainer instanceof R31Window)
return this.playerContainer.getFileSystemSource();else
return null;}
R31MediaPlayerController.prototype.addMediaFromPlayer=function(mediaUrl,type,title)
{var user=R31UserRegistry.getLoggedUser();if(!user)return false;var fsSource=this.getFileSystemSource();if(!fsSource)return false;var name=varDefault(title||mediaUrl,"").toString();var pos=name.indexOf("?");name=name.substr(0,(pos!=-1)?(1+pos):80).trim(".");if(name=="")return false;name=name.replace(new RegExp("[^a-zA-Z0-9,.\\-_ ()]+","gi"),'_');name=name.replace(new RegExp("__","gi"),'_');var extension=FileSystem.getExtension(name);var td=FileSystem.getTypeDescriptor(extension);if(td==null||!inArray(["video","audio","image"],td.getMimeType())){if(type=="IMG")
name+=".jpg";else if(type=="MP3")
name+=".mp3";else if(type=="VID")
name+=".flv";}
var path;if(fsSource instanceof FileSystemDirectory){path=fsSource.getPath();}
else{var parent=fsSource.getParent();path=(parent!=null)?parent.getPath():null;}
if(path==null||path=="")return false;var extra={"target":mediaUrl,"uploadPath":path,"description":title};var _this=this;var ajax=new R31Ajax();ajax.setMethod(Ajax.METHOD_POST);ajax.setArgument({cmd:"addLink",target:mediaUrl,name:name,path:path,user:user.id,session:LD.Cookie.get("PHPSESSID"),access:FileSystem.ACCESS_PUBLIC});ajax.setBodyArgument("extra",Json.toString(extra));ajax.setSuccessCallback(function(socket)
{var result=socket.response;if(result!=null)
_this.mediaLinkAdded(result);});ajax.send("room_provider.php");}
R31MediaPlayerController.prototype.mediaLinkAdded=function(res)
{if(res==null)return;var evt;if(isNumeric(res)&&res>0){var fsSource=this.getFileSystemSource();if(!fsSource)return false;if(!(fsSource instanceof FileSystemDirectory))
fsSource=fsSource.getParent();if(fsSource instanceof FileSystemDirectory)
fsSource.fetchChildren();}}
R31MediaPlayerController.prototype.shareMedia=function(recipients)
{var fsSource=this.getFileSystemSource();if(!(fsSource instanceof FileSystemNode))return;if(!isObject(recipients)||recipients.length==0)return;var user=R31UserRegistry.getLoggedUser();if(!user||!user.id)return false;var _this=this,aux=new Array(),entry;var c=Math.min(recipients.length,3);for(var i=0;i<c;i++){entry=recipients[i];if(LD.Validation.isEmail(varDefault(entry,"").toString()))
aux.push(entry);}
if(aux.length>0){var ajax=new R31Ajax();ajax.setMethod(Ajax.METHOD_POST);ajax.setArgument({cmd:"invitePeople",user:user.id,id:fsSource.getId()});ajax.setBodyArgument("extra",Json.toString({friends:null,anonymous:aux,message:""}));ajax.setSuccessCallback(function()
{var result=ajax.response;});ajax.send("room_provider.php");}}
R31MediaPlayerController.prototype.fitContainerToMedia=function(width,height)
{var minW=400,minH=200;width=Math.max(minW,intVal(width));height=Math.max(minH,intVal(height));var pc=this.playerContainer;if(pc instanceof JUIWindow&&pc.isMaximized()==true)return;var pWH=this.player.getSize();var cWH=pc.getSize();if(pWH&&cWH&&pWH.width>0&&pWH.height>0&&cWH.width>0&&cWH.height>0){pc.setSize(width+(cWH.width-pWH.width),height+(cWH.height-pWH.height));this.player.setSize(width,height);}}
R31MediaPlayerController.prototype.setFullScreen=function(fullScreen)
{if(this.playerContainer instanceof JUIWindow)
this.playerContainer.setMaximized(fullScreen);}
MediaPlayerMediator={addMediaFromPlayer:function(mediaUrl,type,title){},shareMedia:function(recipients){},fitContainerToMedia:function(width,height){},setFullScreen:function(fullScreen){}}

/*========== R31Plugin.js ==========*/

R31UploadPlugin.extend(JUIWindowPlugin);function R31UploadPlugin(targetDirectory,command)
{R31UploadPlugin.superConstructor.call(this,"uploadPlugin");this.name="upload";this.setTargetDirectory(targetDirectory||null);this.uploadPath="";this.command=varDefault(command,"upload");this.upload=null;}
R31UploadPlugin.prototype.init=function()
{R31UploadPlugin.superClass.init.call(this,"uploadPlugin");this.upload.setCommand(this.command);this.upload.setUploadPath(this.uploadPath);this.upload.setArgument("permissions","rwr-r-");}
R31UploadPlugin.prototype.initComponents=function()
{var upload=new JUIUpload(null,"room_provider.php","upload");this.upload=upload;upload.addListener(JUIUpload.EVT_UPLOAD_FINISHED,this.uploadFinished,this);upload.init();this.add(upload);upload.setBounds(0,0,300,120);upload.setVisible(true);}
R31UploadPlugin.prototype.getTargetDirectory=function()
{return this.targetDirectory;}
R31UploadPlugin.prototype.setTargetDirectory=function(targetDirectory)
{if(targetDirectory===null){this.targetDirectory=targetDirectory;this.setUploadPath("");return;}
else if(!(targetDirectory instanceof FileSystemDirectory))
throw"R31UploadPlugin.setTargetDirectory: Must provide a FileSystemDirectory object";this.targetDirectory=targetDirectory;this.setUploadPath(targetDirectory.getPath());targetDirectory.addListener(FileSystem.EVT_NODE_CHANGED,this.targetDirectoryChanged,this);}
R31UploadPlugin.prototype.setUploadPath=function(path)
{this.uploadPath=path;if(this.upload)this.upload.setUploadPath(path);}
R31UploadPlugin.prototype.uploadFinished=function(evt,type,src)
{this.fireEvent(evt,JUIUpload.EVT_UPLOAD_FINISHED);}
R31UploadPlugin.prototype.targetDirectoryChanged=function(evt,type,src)
{this.setUploadPath(this.targetDirectory.getPath());}
R31SearchPlugin.extend(JUIWindowPlugin);function R31SearchPlugin(searchPath,recursive)
{R31SearchPlugin.superConstructor.call(this,"searchPlugin");this.name="search";this.search=null;this.setPath(searchPath);this.setRecursive(recursive);}
R31SearchPlugin.prototype.getPath=function()
{return this.path;}
R31SearchPlugin.prototype.setPath=function(path)
{this.path=varDefault(path,"/");if(this.search)this.search.setPath(path);}
R31SearchPlugin.prototype.isRecursive=function()
{return this.recursive;}
R31SearchPlugin.prototype.setRecursive=function(recursive)
{this.recursive=(recursive==true);if(this.search)this.search.setRecursive(recursive);}
R31SearchPlugin.prototype.initComponents=function()
{var search=new JUISearch(this.path,this.recursive);this.search=search;search.addListener(JUISearch.EVT_SEARCH_FINISHED,this.searchFinished,this);search.init();this.add(search);search.setBounds(0,0,320,120);search.setVisible(true);}
R31SearchPlugin.prototype.searchFinished=function(evt,type,src)
{this.fireEvent(evt,JUISearch.EVT_SEARCH_FINISHED);R31DesktopShell.doAction("showSearchResult",evt);}

/*========== R31Upload.js ==========*/

R31UploadManager.extend(JUIContainer);R31UploadManager.templates={base:"R31UploadManager"};R31UploadManager.METHOD_SINGLE=0;R31UploadManager.METHOD_DND=1;R31UploadManager.METHOD_WEB=2;R31UploadManager.STATUS_IDLE=0;R31UploadManager.STATUS_PROCESSING=1;R31UploadManager.EVT_QUEUE_STARTED=1001;R31UploadManager.EVT_QUEUE_PAUSED=1002;R31UploadManager.EVT_QUEUE_FINISHED=1003;R31UploadManager.ACCESS_PUBLIC=0;R31UploadManager.ACCESS_FRIENDS=1;R31UploadManager.ACCESS_PRIVATE=2;R31UploadManager.ACTION_OPEN_DND_UPLOAD=2001;function R31UploadManager(maxSimultaneous,targetUrl,command)
{R31UploadManager.superConstructor.call(this);this.maxSimultaneous=Math.max(1,intVal(maxSimultaneous));this.targetUrl=varDefault(targetUrl,"");this.command=varDefault(command,"upload");this.uploadMethod=R31UploadManager.METHOD_SINGLE;this.queue=new Array();this.queueStatus=R31UploadManager.STATUS_IDLE;this.targetDirTree=null;this.pathTree=null;}
R31UploadManager.prototype.init=function(htmlNode)
{R31UploadManager.superClass.init.call(this,htmlNode);var _this=this;this.uploadInputPrototype=this.html.uploadInput.cloneNode(false);var desktop=JUI.getTopContainer();var pathTree=new JUITreeCombo(this.targetDirTree,this.width,desktop,JUI.LAYER_POPUP);this.pathTree=pathTree;pathTree.init(this.html.targetDirCombo);pathTree.setSize(160,21);pathTree.setPositioning(JUI.POSITION_STATIC);pathTree.repaint();this.setUploadMethod(this.uploadMethod);this.html.accessRights.value=R31UploadManager.ACCESS_PUBLIC;this.html.uploadItem.style.display="none";this.html.singleUpload.onmouseover=function(){this.className="linkUploadType linkUploadType_over singleUploadButton";}
this.html.singleUpload.onmouseout=function(){this.className="linkUploadType linkUploadType singleUploadButton";}
this.html.dndUpload.onclick=function(){_this.setUploadMethod(R31UploadManager.METHOD_DND);}
this.html.dndUpload.onmouseover=function(){this.className="linkUploadType linkUploadType_over dndUploadButton";}
this.html.dndUpload.onmouseout=function(){this.className="linkUploadType linkUploadType dndUploadButton";}
this.html.webUpload.onmouseover=function(){this.className="linkUploadType linkUploadType_over webUploadButton";}
this.html.webUpload.onmouseout=function(){this.className="linkUploadType linkUploadType webUploadButton";}
this.html.newName.onfocus=function(){if(this.value==""){var value="";if(_this.html.uploadInput&&_this.html.uploadInput.value!="")
value=FileSystem.getBaseName(_this.html.uploadInput.value||"",true)||"";else if(_this.html.linkInput&&_this.html.linkInput.value!="")
value=FileSystem.getBaseName(_this.html.linkInput.value||"",true)||"";if(value!="")
this.value=String(value).toAnsi("_");}
this.select();}
this.html.buttonUpload.onclick=function(){if(_this.html.uploadInput&&_this.html.uploadInput.value!=""){var input=_this.html.uploadInput;var newInput=_this.uploadInputPrototype.cloneNode(false);input.parentNode.insertBefore(newInput,input);input.parentNode.removeChild(input);_this.html.uploadInput=newInput;var item=new R31UploadItem(input,_this.pathTree.getValue(),R31UserRegistry.getLoggedUser(),_this.html.newName.value,_this.html.accessRights.value,_this.html.tags.value,_this.html.description.value);item.init(_this.html.uploadItem.cloneNode(true));item.setSize(_this.width-2,28);_this.addItem(item);}
else if(_this.html.linkInput&&_this.html.linkInput.value!=""){var input=_this.html.linkInput;var item=new R31UploadLinkItem(input.value,_this.pathTree.getValue(),R31UserRegistry.getLoggedUser(),_this.html.newName.value,_this.html.accessRights.value,_this.html.tags.value,_this.html.description.value);item.init(_this.html.uploadItem.cloneNode(true));item.setSize(_this.width-2,28);_this.addItem(item);input.value="";}
else{return;}
_this.processQueue();_this.resetAdvancedOptions();}
this.html.buttonClear.onclick=function(){_this.clearQueue();_this.resetAdvancedOptions();}
var queueHolder=new JUIContainer();this.queueHolder=queueHolder;queueHolder.init(this.html.queueHolder);queueHolder.setPositioning(JUI.POSITION_STATIC);this.add(queueHolder,null,this.html.queueContainer);queueHolder.add=function(item)
{this.constructor.prototype.add.call(this,item,0);}
this.html.linkOptions.onclick=function(){var adv=_this.html.advancedOptions;adv.style.display=(adv.style.display!="none")?"none":"";_this.getParent().getParent().repaint();}
this.html.singleUpload.onclick=function(){_this.setUploadMethod(R31UploadManager.METHOD_SINGLE);}}
R31UploadManager.prototype.setUploadMethod=function(method)
{this.uploadMethod=method;if(method==R31UploadManager.METHOD_SINGLE){this.html.singleUpload.className="linkUploadType linkUploadType_on singleUploadButton";this.html.dndUpload.className="linkUploadType dndUploadButton";this.html.webUpload.className="linkUploadType webUploadButton";this.html.fileUpload.style.display="";this.html.linkUpload.style.display="none";}
else if(method==R31UploadManager.METHOD_DND){R31DesktopShell.doAction(R31.ACTION_DND_UPLOAD,new Object());}
else if(method==R31UploadManager.METHOD_WEB){this.html.singleUpload.className="linkUploadType singleUploadButton";this.html.dndUpload.className="linkUploadType dndUploadButton";this.html.webUpload.className="linkUploadType linkUploadType_on webUploadButton";this.html.fileUpload.style.display="none";this.html.linkUpload.style.display="";}}
R31UploadManager.prototype.setTargetPath=function(targetPath)
{if(!targetPath)return;this.targetDirTree.setValue(targetPath);}
R31UploadManager.prototype.setTargetTree=function(fsNodeTree)
{if(!fsNodeTree)return;this.targetDirTree=fsNodeTree;if(!this.root)return;this.refreshTree();}
R31UploadManager.prototype.getPathTree=function()
{return this.pathTree;}
R31UploadManager.prototype.refreshTree=function()
{var currentValue=this.pathTree.getValue();var itemImg=[getImageURL("/skins/"+JUI.getCurrentSkin()+"/icon_folder_closed.gif"),getImageURL("/skins/"+JUI.getCurrentSkin()+"/icon_folder_open.gif")];var buildTree=function(nodes,parentItem){var tree=new Array(),item,node,children;var basePath=(parentItem!=null?parentItem.value.toString():"")+"/";for(var i=0;i<nodes.length;i++){node=nodes[i].node;item={value:basePath+node.name,caption:node.name,image:itemImg};if(nodes[i].children){item.children=buildTree(nodes[i].children,item);}
tree.push(item);}
return tree;}
this.targetDirTree=buildTree(this.targetDirTree,null);this.pathTree.setSource(this.targetDirTree);this.pathTree.setValue(currentValue);}
R31UploadManager.prototype.getItem=function(index)
{return this.queue[intVal(index)]||null;}
R31UploadManager.prototype.addItem=function(item)
{if(!(item instanceof R31UploadItem))
throw"R31UploadManager.addItem: item must be an instance of R31UploadItem";this.queue.push(item);item.setPositioning(JUI.POSITION_STATIC);item.setVisible(true);this.queueHolder.add(item);item.refreshStatus();item.addListener(R31UploadItem.EVT_FINISHED,this.itemFinished,this);}
R31UploadManager.prototype.removeItem=function(item)
{if(!(item instanceof R31UploadItem))
throw"R31UploadManager.addItem: item must be an instance of R31UploadItem";this.queue=arrayRemove(this.queue,item);item.removeListener(R31UploadItem.EVT_FINISHED,this);this.queueHolder.remove(item);}
R31UploadManager.prototype.itemFinished=function(evt,type,src)
{if(!evt||!src)return;var res=evt.result;var item=src;var status=item.getStatus();if(status==R31UploadItem.COMPLETED){var targetPath=(item.getTargetPath()||"").toString().rTrim("/ ");if(targetPath!=""){var targetNode=FileSystem.getNodeByPath(targetPath);if(targetNode&&targetNode.getType()==FileSystem.NODE_TYPE_DIR)
targetNode.fetchChildren();}}
this.processQueue();}
R31UploadManager.prototype.processQueue=function()
{var activeCount=0,i=0,item,status;while(i<this.queue.length&&activeCount<this.maxSimultaneous){item=this.getItem(i++);status=item.getStatus();if(status==R31UploadItem.NOT_STARTED){item.startUpload(this.targetUrl);this.queueStatus=R31UploadManager.STATUS_PROCESSING;++activeCount;}
else if(status==R31UploadItem.UPLOADING)
++activeCount;}
if(activeCount==0)
this.queueStatus=R31UploadManager.STATUS_IDLE;}
R31UploadManager.prototype.clearQueue=function()
{var aux=0,i=0,item,status;while(i<this.queue.length){item=this.getItem(i);if(item.isFinished())
this.removeItem(item);else
++i;}}
R31UploadManager.prototype.getFilePath=function()
{if(this.fileInput)
return varDefault(this.fileInput.value,"");else
return"";}
R31UploadManager.prototype.resetAdvancedOptions=function()
{if(!this.root)return;this.html.newName.value="";this.html.description.value="";this.html.tags.value="";}
R31UploadItem.extend(JUIContainer);R31UploadItem.lastId=0;R31UploadItem.NOT_STARTED=0;R31UploadItem.UPLOADING=1;R31UploadItem.COMPLETED=2;R31UploadItem.ERROR=3;R31UploadItem.EVT_STARTED=1001;R31UploadItem.EVT_ABORTED=1002;R31UploadItem.EVT_FINISHED=1003;function R31UploadItem(fileInput,targetPath,user,newName,access,tags,description)
{if(!fileInput||fileInput.tagName!="INPUT"||fileInput.value=="")
throw"R31UploadItem: Must provide an INPUT type=file element with a file entry";if(!user||!user.id)
throw"R31UploadItem: Upload operation must have a requesting user";R31UploadItem.superConstructor.call(this);this.id=R31UploadItem.nextId();this.fileInput=fileInput;this.fileName=FileSystem.getBaseName(fileInput.value);this.targetPath=varDefault(targetPath,"").toString();this.user=user;this.newName=FileSystem.getBaseName(varDefault(newName,fileInput.value).toString().toAnsi("_"),true);this.access=varDefault(access,R31UploadManager.ACCESS_PUBLIC).toString();this.tags=varDefault(tags,"").toString().toAnsi("_");this.description=varDefault(description,"").toString().toAnsi("_");this.uploadPercentage=0;this.setStatus(R31UploadItem.NOT_STARTED);this.result=null;}
R31UploadItem.nextId=function()
{return++this.lastId;}
R31UploadItem.prototype.init=function(htmlNode)
{R31UploadItem.superClass.init.call(this,htmlNode);var _this=this;var uploadForm=this.html.uploadForm;uploadForm.acceptCharset="iso-8859-1";uploadForm.insertBefore(this.fileInput,this.html.uploadArgs);this.html.uploadArgs.name="extra";this.html.uploadArgs.value=Json.toString({"name":this.newName,"target":this.targetPath,"uploadPath":this.targetPath,"access":this.access,"tags":this.tags.addSlashes(),"description":this.description.addSlashes()});var frameName="frUL_"+this.id;var uploadFrame;if(Browser.isIE){uploadFrame=document.createElement('<IFRAME name="'+frameName+'" onload="JUIComponent.getInstance(this.dhtmlOwner).uploadFinished();">');uploadFrame.dhtmlOwner=this.componentId;}
else{uploadFrame=this.createElement("IFRAME",null,frameName);uploadFrame.onload=function(){_this.uploadFinished();};}
this.uploadFrame=uploadFrame;uploadFrame.id=frameName;with(uploadFrame.style){position="absolute";left=0;top=42;width=1;height=1;display="none";backgroundColor="white";zIndex=-1;}
uploadForm.target=uploadFrame.name;this.root.appendChild(uploadFrame);this.html.itemName.innerHTML=this.fileName;this.html.target.innerHTML=this.targetPath.rTrim("/")+"/"+this.newName;var pb=new JUIProgressBar(new Array(),90,10);this.progressBar=pb;pb.init();pb.setPositioning(JUI.POSITION_STATIC);this.add(pb);pb.setLocation(0,0);this.html.status.appendChild(pb.getRoot());}
R31UploadItem.prototype.startUpload=function(targetUrl,command)
{command=command||"upload";with(this.html.uploadForm){action=(targetUrl+"?cmd="+command+"&response="+Ajax.RESPONSE_HTML_JSON+"&session="+
LD.Cookie.get("PHPSESSID")+"&user="+this.user.id+"&rnd="+Math.random());method="post";enctype="multipart/form-data";encoding="multipart/form-data";}
this.uploadPercentage=0;this.setStatus(R31UploadItem.UPLOADING);this.html.uploadForm.submit();}
R31UploadItem.prototype.uploadFinished=function()
{if(this.getStatus()==R31UploadItem.NOT_STARTED)return;if(!this.uploadFrame)return LD.Con.println("noframe");var doc,location,body;try{doc=getFrameDoc(this.uploadFrame);location=doc.location.href;if(!location||location=="about:blank")return;if(!doc||!doc.body)return;body=doc.body;}
catch(e){this.setStatus(R31UploadItem.ERROR);this.fireEvent(evt,R31UploadItem.EVT_FINISHED);return;}
var res,evt;try{var txt=(Browser.isIE)?doc.body.innerText:doc.body.textContent;var res=Json.evaluate(txt.trim());if(isNumeric(res)&&res>0){this.setStatus(R31UploadItem.COMPLETED);this.uploadPercentage=100;}
else{this.setStatus(R31UploadItem.ERROR);this.uploadPercentage=0;}
evt={"result":res};}catch(e){this.setStatus(R31UploadItem.ERROR);evt={"result":null};}
this.fireEvent(evt,R31UploadItem.EVT_FINISHED);}
R31UploadItem.prototype.getTargetPath=function()
{return this.targetPath;}
R31UploadItem.prototype.getStatus=function()
{return this.status;}
R31UploadItem.prototype.setStatus=function(status)
{this.status=intVal(status);this.refreshStatus();}
R31UploadItem.prototype.refreshStatus=function()
{if(!this.root)return;var legend="";var legendClass="R31UploadItemStatusLegend";var showBar=false;switch(this.status){case R31UploadItem.UPLOADING:showBar=true;break;case R31UploadItem.ERROR:legendClass+="R31UploadItemStatusLegend R31UploadItemError";legend="Error";break;case R31UploadItem.COMPLETED:legend="Completed";break;case R31UploadItem.NOT_STARTED:default:legend="Queued";break;}
this.progressBar.setMotion(showBar);this.progressBar.setVisible(showBar);this.html.statusLegend.innerHTML=legend;this.html.statusLegend.className=legendClass;}
R31UploadItem.prototype.isFinished=function()
{return(this.status==R31UploadItem.COMPLETED||this.status==R31UploadItem.ERROR);}
R31UploadLinkItem.extend(R31UploadItem);function R31UploadLinkItem(linkUrl,targetPath,user,name,access,tags,description)
{if(linkUrl==null||linkUrl=="")
throw"R31UploadItem: Must provide an URL for the link";if(!user||!user.id)
throw"R31UploadItem: Must provide the ID of the that will upload the link";R31UploadLinkItem.superConstructor.superConstructor.call(this);this.id=R31UploadItem.nextId();this.linkUrl=varDefault(linkUrl,"");this.linkName=FileSystem.getBaseName(varDefault(name,this.linkUrl),true);this.targetPath=varDefault(targetPath,"").toString();this.user=user;this.access=varDefault(access,R31UploadManager.ACCESS_PUBLIC).toString();this.uploadPercentage=0;this.setStatus(R31UploadItem.NOT_STARTED);this.result=null;this.ajax=new R31Ajax();}
R31UploadLinkItem.prototype.init=function(htmlNode)
{R31UploadLinkItem.superConstructor.superClass.init.call(this,htmlNode);var _this=this;this.html.itemName.innerHTML=this.linkUrl;this.html.target.innerHTML=this.targetPath.rTrim("/")+"/"+this.linkName;var pb=new JUIProgressBar(new Array(),90,15);this.progressBar=pb;pb.init();pb.setPositioning(JUI.POSITION_STATIC);this.add(pb);pb.setLocation(0,0);this.html.status.appendChild(pb.getRoot());}
R31UploadLinkItem.prototype.startUpload=function(targetUrl,command)
{if(!targetUrl||!this.root)return;var _this=this;command=command||"addLink";var ajax=this.ajax;ajax.setMethod(Ajax.METHOD_POST);ajax.setArgument({"cmd":command,"target":this.linkUrl,"name":this.linkName,"path":this.targetPath,"user":this.user.id,"session":LD.Cookie.get("PHPSESSID"),"access":this.access});ajax.setBodyArgument("extra",Json.toString(this.extra));ajax.setSuccessCallback(function(socket)
{var result=Json.evaluate(socket.request.responseText);if(result!=null)
_this.uploadFinished(result);});ajax.send(targetUrl);}
R31UploadLinkItem.prototype.uploadFinished=function(res)
{if(res==null)return;var evt;try{if(isNumeric(res)&&res>0){this.setStatus(R31UploadItem.COMPLETED);this.uploadPercentage=100;}
else{this.setStatus(R31UploadItem.ERROR);this.uploadPercentage=0;}
evt={"result":res};}catch(e){this.setStatus(R31UploadItem.ERROR);evt={"result":null};}
this.fireEvent(evt,R31UploadItem.EVT_FINISHED);}
R31DnDUploadManager.extend(JUIContainer);R31DnDUploadManager.instance=null;function R31DnDUploadManager()
{if(R31DnDUploadManager.instance!=null)return R31DnDUploadManager.instance;R31DnDUploadManager.superConstructor.call(this);this.targetDirTree=null;this.pathHolder=null;this.pathTree=null;this.iframe=null;}
R31DnDUploadManager.getInstance=function()
{if(this.instance instanceof R31DnDUploadManager)
return this.instance;else
return new R31DnDUploadManager();}
R31DnDUploadManager.prototype.init=function()
{R31DnDUploadManager.superClass.init.call(this);var desktop=JUI.getTopContainer();this.pathHolder=this.createElement("DIV");this.pathHolder.style.textIndent="4px";this.pathHolder.innerHTML="Upload in";this.root.appendChild(this.pathHolder);var pathTree=new JUITreeCombo(this.targetDirTree,this.width,desktop,JUI.LAYER_POPUP);this.pathTree=pathTree;pathTree.init();pathTree.getRoot().setAttribute("id","jUploadPathTree");pathTree.inputBox.setAttribute("id","jUploadPath");pathTree.setBounds(4,16,200,20);pathTree.setPositioning(JUI.POSITION_ABSOLUTE);pathTree.setZIndex(2);pathTree.repaint();this.root.appendChild(pathTree.getRoot());var link=this.createElement("A",null,null,{href:"javascript: R31DnDUploadManager.getInstance().uploadFinished(null, null, '/Lich');"});link.innerHTML="test uploadFinished()";this.root.appendChild(link);with(link.style){position="absolute";left=230;top=10;}
var dndIframe=this.createElement("IFRAME");this.iframe=dndIframe;with(dndIframe.style){border="none";position="absolute";left="0px";top="40px";width="460px";height="320px";zIndex=1;}
this.root.appendChild(dndIframe);dndIframe.src="jupload.php";}
R31DnDUploadManager.prototype.setTargetTree=function(fsNodeTree)
{if(!fsNodeTree)return;this.targetDirTree=fsNodeTree;if(!this.root)return;this.refreshTree();}
R31DnDUploadManager.prototype.getPathTree=function()
{return this.pathTree;}
R31DnDUploadManager.prototype.refreshTree=function()
{var currentValue=this.pathTree.getValue();var itemImg=[getImageURL("/skins/"+JUI.getCurrentSkin()+"/icon_folder_closed.gif"),getImageURL("/skins/"+JUI.getCurrentSkin()+"/icon_folder_open.gif")];var buildTree=function(nodes,parentItem){var tree=new Array(),item,node,children;var basePath=(parentItem!=null?parentItem.value.toString():"")+"/";for(var i=0;i<nodes.length;i++){node=nodes[i].node;item={value:basePath+node.name,caption:node.name,image:itemImg};if(nodes[i].children)
item.children=buildTree(nodes[i].children,item);tree.push(item);}
return tree;}
this.targetDirTree=buildTree(this.targetDirTree,null);this.pathTree.setSource(this.targetDirTree);this.pathTree.setValue(currentValue);}
R31DnDUploadManager.prototype.uploadFinished=function(evt,type,src)
{src=(src||"").toString().rTrim("/ ");if(src=="")return;var targetNode=FileSystem.getNodeByPath(src);alert("Item uploaded in "+targetNode.getPath()+". Click OK to refresh...");if(targetNode&&targetNode.getType()==FileSystem.NODE_TYPE_DIR)
targetNode.fetchChildren();}
R31MultiUpload.extend(JUIComponent);R31MultiUpload.EVT_UPLOAD_FINISHED=1;R31MultiUpload.lastId=0;function R31MultiUpload(socketName,targetUrl,command,fileInputNames)
{R31MultiUpload.superConstructor.call(this);this.id=R31MultiUpload.nextId();this.socketName=varDefault(socketName,"multiUpload"+this.id);this.setTargetUrl(targetUrl);this.command=varDefault(command,"upload");this.fileInputNames=varDefault(fileInputNames,{file:"file"});this.fileInputs=null;this.fileInputClones=null;this.uploadForm=null;this.uploadFrame=null;this.requestArguments=new Object();this.responseType=Ajax.RESPONSE_HTML_JSON;}
R31MultiUpload.nextId=function()
{return++this.lastId;}
R31MultiUpload.prototype.init=function(htmlNode)
{var _this=this;htmlNode.dhtmlOwner=this.componentId;var root=htmlNode;this.root=root;this.html=JUI.getDhtmlRefs(htmlNode);this.uploadForm=this.html.form;this.uploadForm.acceptCharset="iso-8859-1";this.uploadForm.name=this.uploadForm.id="formMUL_"+this.socketName;this.uploadForm.action=this.targetUrl;this.uploadForm.method="post";this.uploadForm.enctype=this.uploadForm.encoding="multipart/form-data";this.initFileInputs();var argumentsInput=this.createElement("INPUT","hidden","extra");this.argumentsInput=argumentsInput;this.uploadForm.appendChild(argumentsInput);var frameName="frMUL_"+this.socketName;var uploadFrame;if(Browser.isIE){uploadFrame=document.createElement('<IFRAME name="'+frameName+'" onload="JUIComponent.getInstance(this.dhtmlOwner).uploadFinished();">');uploadFrame.dhtmlOwner=this.componentId;}
else{uploadFrame=this.createElement("IFRAME",null,frameName);uploadFrame.onload=function(){_this.uploadFinished();}}
this.uploadFrame=uploadFrame;document.body.appendChild(uploadFrame);uploadFrame.id=frameName;uploadFrame.src="about:blank";with(uploadFrame.style){position="absolute";display="none";visibility="hidden";width="300px";height="100px";}
this.uploadForm.target=uploadFrame.name;}
R31MultiUpload.prototype.initFileInputs=function()
{if(!this.root)return;if(this.fileInputs==null){this.fileInputs=new Object();this.fileInputClones=new Object();for(var id in this.fileInputNames){this.fileInputs[id]=this.html[id];this.fileInputs[id].name=this.fileInputNames[id];this.fileInputClones[id]=this.fileInputs[id].cloneNode(true);}}
else{var oldFileInput,newFileInput;for(var id in this.fileInputNames){oldFileInput=this.fileInputs[id];newFileInput=this.fileInputClones[id].cloneNode(true);this.fileInputs[id]=newFileInput;oldFileInput.parentNode.replaceChild(newFileInput,oldFileInput);this.fileInputs[id].name=this.fileInputNames[id];}}}
R31MultiUpload.prototype.getTargetUrl=function()
{return this.targetUrl;}
R31MultiUpload.prototype.setTargetUrl=function(targetUrl)
{this.targetUrl=varDefault(targetUrl,"");}
R31MultiUpload.prototype.getCommand=function()
{return this.command;}
R31MultiUpload.prototype.setCommand=function(cmd)
{this.command=varDefault(cmd,"");}
R31MultiUpload.prototype.setArgument=function(name,value)
{if(!name)throw"R31MultiUpload.setArgument: must provide a name for request argument";if(typeof(value)=="string")value=value.addSlashes();this.requestArguments[name]=value;}
R31MultiUpload.prototype.clearArguments=function(name)
{if(name!=null)
delete this.requestArguments[name.toString()];else
this.requestArguments=new Object();}
R31MultiUpload.prototype.setResponseType=function(responseType)
{if(!responseType)throw"R31MultiUpload.setResponseType: must provide a constant to indicate response type";this.responseType=responseType;}
R31MultiUpload.prototype.upload=function()
{if(this.uploadForm){this.uploadForm.action=(this.targetUrl+"?cmd="+this.command+"&response="+this.responseType);this.argumentsInput.value=Json.toString(this.requestArguments);this.uploadForm.submit();}}
R31MultiUpload.prototype.uploadFinished=function()
{if(!this.uploadFrame)return LD.Con.println("noframe");var doc=null;try{doc=getFrameDoc(this.uploadFrame);}
catch(e){return;}
if(!doc||!doc.body||!doc.body.innerHTML)return;var location=doc.location.href;if(!location||location=="about:blank")return;this.initFileInputs();try{var evt={"result":Json.evaluate(doc.body.innerHTML.trim())};this.fireEvent(evt,R31MultiUpload.EVT_UPLOAD_FINISHED);}catch(e){}}
R31FlashUpload.extend(JUIFlashClip);R31FlashUpload.EVT_UPLOAD_FINISHED=12101;R31FlashUpload.EVT_UPLOAD_CANCELLED=12102;R31FlashUpload.EVT_UPLOAD_ERROR=12103;R31FlashUpload.version="";function R31FlashUpload(uploadUrl,targetNode)
{if(R31FlashUpload.instance!=null)return R31FlashUpload.instance;R31FlashUpload.superConstructor.call(this,"wixiupload.swf?v="+R31FlashUpload.version);R31FlashUpload.instance=this;this.setUploadUrl(uploadUrl);this.uploadTarget=(targetNode instanceof FileSystemDirectory)?targetNode.id:0;}
R31FlashUpload.prototype.init=function(htmlNode)
{R31FlashUpload.superClass.init.call(this,htmlNode,{height:"460px"});}
R31FlashUpload.getInstance=function(uploadUrl,targetNode)
{if(this.instance==null){this.instance=new R31FlashUpload(uploadUrl,targetNode);}
else{if(uploadUrl!=null)
this.instance.setUploadUrl(uploadUrl);if(targetNode!=null)
this.instance.setUploadTarget(targetNode);}
return this.instance;}
R31FlashUpload.getInitData=function()
{var instance=this.getInstance();if(!instance)return null;var user=R31UserRegistry.getLoggedUser();var tree=instance.getDirectoryTree();return{dirTree:tree,url:instance.uploadUrl,cmd:"upload",session:LD.Cookie.get("PHPSESSID"),user:(user!=null)?user.getId():null,uploadTarget:instance.uploadTarget,uploadPath:instance.uploadTarget};}
R31FlashUpload.setUploadTarget=function(node)
{this.getInstance().setUploadTarget(node);}
R31FlashUpload.fireUploadFinished=function(targetId,returnCode)
{var instance=this.getInstance();if(instance!=null)
return instance.uploadFinished(targetId,returnCode);else
return null;}
R31FlashUpload.cancelUpload=function()
{this.getInstance().cancelUpload();}
R31FlashUpload.uploadCancelFinished=function(){this.getInstance().uploadCancelFinished();}
R31FlashUpload.prototype.getLogInfo=function()
{return{tag:"upload",value:""};}
R31FlashUpload.prototype.setUploadUrl=function(uploadUrl)
{this.uploadUrl=varDefault(uploadUrl,"");}
R31FlashUpload.prototype.setUploadTarget=function(node)
{if(typeof(node)=="number")
node=FileSystem.getNode(node);else if(typeof(node)=="string")
node=FileSystem.getNodeByPath(node);if(!(node instanceof FileSystemDirectory))return false;this.uploadTarget=node.id;if(this.root&&this.flashObject&&this.flashObject.setUploadTarget)
this.flashObject.setUploadTarget(this.uploadTarget);}
R31FlashUpload.prototype.getDirectoryTree=function()
{return this.fsTree;}
R31FlashUpload.prototype.buildDirectoryTree=function(dirTree)
{var entry=dirTree[0];if(!entry||!(entry.node instanceof FileSystemDirectory)||entry.node.isTrashBin())return false;var buildTree=function(entry)
{if(!entry||!(entry.node instanceof FileSystemDirectory)||entry.node.isTrashBin())return null;var packedEntry=entry.node.toObject();if(!packedEntry)return null;var children=new Array();var child,packedChild;for(var i=0;i<entry.children.length;i++){packedChild=arguments.callee(entry.children[i]);if(packedChild!=null){children.push(packedChild);}}
var aux={node:packedEntry,children:children};return aux;}
this.fsTree=new Array();this.fsTree.push(buildTree(entry));}
R31FlashUpload.prototype.uploadFinished=function(targetId,returnCode)
{targetId=intVal(targetId);if(targetId==0||returnCode<1)return;var targetNode=FileSystem.getNode(targetId);if(targetNode&&targetNode.getType()==FileSystem.NODE_TYPE_DIR)
targetNode.fetchChildren();this.fireEvent({targetId:targetId,returnCode:returnCode},R31FlashUpload.EVT_UPLOAD_FINISHED);}
R31FlashUpload.prototype.cancelUpload=function()
{if(!this.root||!this.flashObject||!this.flashObject.closeWixiUpload)return;this.flashObject.closeWixiUpload();}
R31FlashUpload.prototype.uploadCancelFinished=function()
{this.fireEvent({},R31FlashUpload.EVT_UPLOAD_CANCELLED);}

/*========== R31UserManagers.js ==========*/

R31ProfileViewer.extend(JUIWindow);R31ProfileViewer.templates={base:"JUIWindow",content:"R31ViewProfile"};function R31ProfileViewer()
{R31ProfileViewer.superConstructor.call(this,"Profile",true,true,false,false);this._ajax=new R31Ajax();this.contentViews=new Object();this.setResizable(false);this.setDraggable(false);this.multiUpload=null;this.errorCount=0;this.inProgress=false;}
R31ProfileViewer.prototype.init=function(htmlNode)
{R31ProfileViewer.superClass.init.call(this,htmlNode);var content=new JUIHtmlNode(JUI.getTemplateInstance(R31ProfileViewer.templates.content));this.content=content;var cp=this.getContentPane();cp.add(content);}
R31ProfileViewer.prototype.getLogInfo=function()
{var room=R31UserRegistry.getCurrentRoom();return{tag:"profile_view",value:(room?room.id:"")};}
R31ProfileViewer.prototype.refreshUserInfo=function()
{var room=R31UserRegistry.getCurrentRoom();var user=R31UserRegistry.getLoggedUser();if(!room||!user)return;this.content.html.userName.innerHTML=room.name;if(room.gender==1)
this.content.html.gender.innerHTML=__("Male");else if(room.gender==2)
this.content.html.gender.innerHTML=__("Female");else
this.content.html.gender.innerHTML=__("n/a");if(room.city!="")
this.content.html.country.innerHTML=(room.city||__("Not specified"))+", "+
(R31.Countries[room.country]||__("Not specified"));else
this.content.html.country.innerHTML=room.country;this.content.html.birthDate.innerHTML=room.birthDate||"n/a";this.content.html.description.innerHTML=room.selfDescription||__("Not specified");this.content.html.tags.innerHTML=room.tags||__("Not specified");if(room.avatar!=null&&room.avatar!="")
this.content.html.avatar.src=getAvatarURL(room.avatar);else
this.content.html.avatar.src=R31.DEFAULT_AVATAR;}
R31ProfileManager.extend(JUIWindow);R31ProfileManager.templates={base:"JUIWindow"};function R31ProfileManager()
{R31ProfileManager.superConstructor.call(this,"Profile",true,true,false,false);this._ajax=new R31Ajax();this.contentViews=new Object();this.setResizable(false);this.setDraggable(false);this.multiUpload=null;this.errorCount=0;this.inProgress=false;}
R31ProfileManager.prototype.init=function(content)
{if(!content||content.nodeType!=LD.NODE_ELEMENT)
throw"R31ProfileManager: Must provide a root HTML holding apropriate contents";R31ProfileManager.superClass.init.call(this);var _this=this;content.dhtmlOwner=this.componentId;this.contentPane.setBackgroundColor("white");this.contentPane.add(new JUIHtmlNode(content));var refs=JUI.getDhtmlRefs(content);for(var k in refs){this.html[k]=refs[k];}
this.putTemplate("R31Profile_tab1",this.html.tab1);this.putTemplate("R31Profile_tab2",this.html.tab2);this.putTemplate("R31Profile_tab3",this.html.tab3);var y=(new Date()).getFullYear();var birthDate=new JUIDateSelect("birthDate","date",1930,y,true,null,true);this.birthDate=birthDate;birthDate.init();this.add(birthDate,null,_this.html.birthDate);this.multiUpload=new R31MultiUpload("profileUpload","user_provider.php","updateProfile",{avatarFile:"avatar",wallpaperFile:"wallpaper"});this.multiUpload.init(this.html.holder);this.multiUpload.addListener(R31MultiUpload.EVT_UPLOAD_FINISHED,this.updateFinished,this);this.multiUpload.clearArguments();this.clearErrors();this.html.avatarSelector.onchange=function(){if(_this.html.avatarSelector.value==0){_this.html.avatarSlider.style.display="";_this.html.fieldAvatar.style.display="none";}
else{_this.html.avatarSlider.style.display="none";_this.html.fieldAvatar.style.display="";}}
this.html.uploadAvatar.onclick=function(){if(!_this.inProgress&&_this.html.avatarFile.value!=""){_this.setInProgress(true);_this.multiUpload.setCommand("updateUserImages");_this.multiUpload.upload();}}
this.html.uploadWallpaper.onclick=function(){if(!_this.inProgress&&_this.html.wallpaperFile.value!=""){_this.setInProgress(true);_this.multiUpload.setCommand("updateUserImages");_this.multiUpload.upload();}}
var img,av,width,iw=60,ih=60,gap=10;var avatarPane=new JUISlidePane({scrolling:JUI.SCROLL_HORIZONTAL});this.avatarPane=avatarPane;avatarPane.init();avatarPane.setScrollersBackgroundColor("transparent");avatarPane.setScrollersBackgroundImages("","",getImageURL("/skins/"+JUI.currentSkin+"/R31DashBoard/arrow_left.gif"),getImageURL("/skins/"+JUI.currentSkin+"/R31DashBoard/arrow_right.gif"));avatarPane.setHorizontalStep(intVal(iw/2));avatarPane.setXScrollersWidth(20);avatarPane.setVisible(true);var bw=document.body.clientWidth,bh=document.body.clientHeight;avatarPane.setBounds(0,4,262,60);this.add(avatarPane,null,this.html.avatarSlider);this.avatars=['avatar.b5be2783e60f60f2.jpg','avatar.69275e6157cdf2da.jpg','avatar.c3ed75fbb15e08d0.jpg','avatar.79b4d65e729cc81f.jpg','avatar.6dc3a699d081c39a.jpg','avatar.42a5d13f9c70328e.jpg','avatar.7b36b1d4853ab736.jpg','avatar.4a15d26c8e2bc1c9.jpg','avatar.daa864b460bf6439.jpg','avatar.29136a0ea1b4c622.jpg','avatar.1837b4dff1a8408f.jpg','avatar.cda80eabdb16ea3a.jpg','avatar.305998dbc77f3cc9.jpg','avatar.f72298ea2933255c.jpg','avatar.e01e0dbd795b2780.jpg','avatar.5c30bbda75be0a02.jpg','avatar.61134c236e056dcb.jpg','avatar.e6e2e5b659540967.jpg','avatar.11a7930a51fa9c73.jpg','avatar.a55e4f136b444d2f.jpg','avatar.f2f2c9340e707ef2.jpg','avatar.de2d966f0a42ab10.jpg','avatar.2f1cf62066130309.jpg','avatar.b22ec3fc35929bbe.jpg','avatar.aa7e0611f01a03ba.jpg','avatar.0459664a7a2a4b4e.jpg','avatar.a94ee3f654f514aa.jpg','avatar.63317a30648dd4c3.jpg','avatar.20cb592d78df62ad.jpg','avatar.519e1db20ca88b45.jpg','avatar.06053056b703e834.jpg'];var avatarContainer=new JUIContainer(new JUIStackLayout(JUI.LAYOUT_HORIZONTAL,gap));avatarContainer.init();pickAvatarFunc=function(){_this.selectAvatar(this.value);}
var width=0;for(var i=0;i<this.avatars.length;i++){img=JUI.makeImage(DIR_PUBLIC+'avatars/'+this.avatars[i],null,{width:iw+"px",height:ih+"px",border:"none",cursor:"pointer"});img.value=i;img.onclick=pickAvatarFunc;var av=new JUIComponent();av.init(img);av.setSize(iw,ih);avatarContainer.add(av);width+=(iw+gap);}
width-=(iw+gap);avatarContainer.setPositioning(JUI.POSITION_ABSOLUTE);avatarContainer.setBounds(0,4,width,ih);avatarContainer.doLayout();avatarPane.add(avatarContainer);var img,wp,iw=80,ih=60,gap=10,thumbUrl;var wallpaperPane=new JUISlidePane({scrolling:JUI.SCROLL_HORIZONTAL});this.wallpaperPane=wallpaperPane;wallpaperPane.init();wallpaperPane.setScrollersBackgroundColor("transparent");wallpaperPane.setScrollersBackgroundImages("","",getImageURL("/skins/"+JUI.currentSkin+"/R31DashBoard/arrow_left.gif"),getImageURL("/skins/"+JUI.currentSkin+"/R31DashBoard/arrow_right.gif"));wallpaperPane.setHorizontalStep(intVal(iw/2));wallpaperPane.setXScrollersWidth(20);wallpaperPane.setVisible(true);var bw=document.body.clientWidth,bh=document.body.clientHeight;wallpaperPane.setBounds(0,4,262,60);this.add(wallpaperPane,null,this.html.wallpaperSlider);this.wallpapers=['wallpaper.f4159c1f89d29960.jpg','wallpaper.0c56394c5f7793ce.jpg','wallpaper.afc0de38d50dcbe1.jpg','wallpaper.7690825360e4966e.jpg','wallpaper.d26e133323345a41.jpg','wallpaper.9f8cfe14a757dd3e.jpg','wallpaper.ae50138a276ea447.jpg','wallpaper.c5db5158cd692faa.jpg','wallpaper.870795e60ed79af8.jpg','wallpaper.910e514dc7eaafda.jpg','wallpaper.7a09ba40a2e6c442.jpg','wallpaper.a3154b33c99e2d39.jpg','wallpaper.52d5be14a12a1366.jpg','wallpaper.2dc3268429b1df39.jpg','wallpaper.d6b2e788d3705660.jpg','wallpaper.a4e8f4eb86382080.jpg','wallpaper.328fe1911350cda4.jpg','wallpaper.08fdb84ece60ecb1.jpg','wallpaper.f09bc569ad814f5f.jpg','wallpaper.2ed4d33d9ff3d7d4.jpg','wallpaper.6b1e95f1a6fe471c.jpg','wallpaper.eaddc7d44bb842a1.jpg','wallpaper.122deb24355e1bcb.jpg','wallpaper.41c5aee4386e746e.jpg','wallpaper.45c677dd0b04e329.jpg','wallpaper.5a0e21f9d2d4c8f8.jpg','wallpaper.a487d3fb14e56aa3.jpg','wallpaper.a4472b4ea236d786.jpg','wallpaper.9412e0b25f1af7d7.jpg','wallpaper.ce1dd0a6706779f3.jpg','wallpaper.233e3c5cc59b6b66.jpg','wallpaper.a29f4683583087db.jpg','wallpaper.8f873c5e5d806c9e.jpg','wallpaper.f45157f5fd7b002a.jpg','wallpaper.9ceac483aa06337c.jpg','wallpaper.218d906ba6460d8c.jpg'];var wallpaperContainer=new JUIContainer(new JUIStackLayout(JUI.LAYOUT_HORIZONTAL,gap));wallpaperContainer.init();pickWallpaperFunc=function(){_this.selectWallpaper(this.value);}
var width=0;for(var i=0;i<this.wallpapers.length;i++){thumbUrl=DIR_PUBLIC+'wallpapers/'+this.wallpapers[i];thumbUrl=appendToPath(thumbUrl,"_thumb");img=JUI.makeImage(thumbUrl,null,{width:iw+"px",height:ih+"px",border:"none",cursor:"pointer"});img.value=i;img.onclick=pickWallpaperFunc;var wp=new JUIComponent();wp.init(img);wp.setSize(iw,ih);wallpaperContainer.add(wp);width+=(iw+gap);}
width-=(iw+gap);wallpaperContainer.setPositioning(JUI.POSITION_ABSOLUTE);wallpaperContainer.setBounds(0,4,width,ih);wallpaperContainer.doLayout();wallpaperPane.add(wallpaperContainer);this.html.wallpaperSelector.onchange=function(){if(_this.html.wallpaperSelector.value==0){_this.html.wallpaperSlider.style.display="";_this.html.wallpaperField.style.display="none";}
else{_this.html.wallpaperSlider.style.display="none";_this.html.wallpaperField.style.display="";}}
this.html.buttonUpdateProfile.onclick=function(){if(!_this.inProgress){_this.doUpdate();}
_this.refreshUserInfo();}
this.html.buttonCancelProfile.onclick=function(){_this.close();_this.refreshUserInfo();}
this.html.tabButton1.onclick=function(){_this.html.tab1.style.display="";_this.html.tabButton1.style.fontWeight="bold";_this.html.tabButton1.style.color="#000000";_this.html.tab2.style.display="none";_this.html.tabButton2.style.fontWeight="normal";_this.html.tabButton2.style.color="#666666";_this.html.tab3.style.display="none";_this.html.tabButton3.style.fontWeight="normal";_this.html.tabButton3.style.color="#666666";}
this.html.tabButton2.onclick=function(){_this.html.tab2.style.display="";_this.html.tabButton2.style.fontWeight="bold";_this.html.tabButton2.style.color="#000000";_this.html.tab1.style.display="none";_this.html.tabButton1.style.fontWeight="normal";_this.html.tabButton1.style.color="#666666";_this.html.tab3.style.display="none";_this.html.tabButton3.style.fontWeight="normal";_this.html.tabButton3.style.color="#666666";}
this.html.tabButton3.onclick=function(){_this.html.tab3.style.display="";_this.html.tabButton3.style.fontWeight="bold";_this.html.tabButton3.style.color="#000000";_this.html.tab2.style.display="none";_this.html.tabButton2.style.fontWeight="normal";_this.html.tabButton2.style.color="#666666";_this.html.tab1.style.display="none";_this.html.tabButton1.style.fontWeight="normal";_this.html.tabButton1.style.color="#666666";}
this.html.country.options.length=0;for(var h in R31.Countries){this.html.country.options[this.html.country.options.length]=new Option(R31.Countries[h],h,false);}}
R31ProfileManager.prototype.getLogInfo=function()
{return{tag:"profile_edit",value:""};}
R31ProfileManager.prototype.refreshUserInfo=function()
{var room=R31UserRegistry.getCurrentRoom();var user=R31UserRegistry.getLoggedUser();if(!room||!user)return;if(user.id==room.id){this.html.firstName.value=user.firstName||"";this.html.lastName.value=user.lastName||"";this.html.email.value=user.email||"";setRadioValue(this.html.downloadable,user.downloadableFiles?1:0);this.html.defaultAccess.value=user.defaultAccess;setRadioValue(this.html.gender,user.gender);this.html.city.value=user.city;this.birthDate.setValue(user.birthDate);this.html.country.value=user.country;this.html.selfDescription.value=user.selfDescription;this.html.tagList.value=user.tags;this.html.publicProfile.checked=user.publicProfile;this.html.searchableFiles.checked=user.searchableFiles;}
if(user.wallpaper!="")
this.html.wallpaper.src=getWallpaperUrl(user.wallpaper);else
this.html.wallpaper.src=DIR_IMAGES+"spacer.gif";if(user.avatar!=null&&user.avatar!="")
this.html.avatar.src=getAvatarURL(user.avatar);else
this.html.avatar.src=R31.DEFAULT_AVATAR;if(user!=null&&user.id){if(user.avatar!=null&&user.avatar!="")
this.html.avatar.src=getAvatarURL(user.avatar);else
this.html.avatar.src=R31.DEFAULT_AVATAR;}
else{this.html.avatar.src=R31.DEFAULT_AVATAR;}}
R31ProfileManager.prototype.selectAvatar=function(index)
{index=intVal(index);if(index<0||index>=this.avatars.length)return false;var img=this.avatars[index];this.selectedAvatar=img;this.html.avatar.src=DIR_PUBLIC+"avatars/"+img;}
R31ProfileManager.prototype.selectWallpaper=function(index)
{index=intVal(index);if(index<0||index>=this.wallpapers.length)return false;var img=this.wallpapers[index];this.selectedWallpaper=img;var thumbUrl=DIR_PUBLIC+"wallpapers/"+appendToPath(img,"_thumb");this.html.wallpaper.src=thumbUrl;}
R31ProfileManager.prototype.doUpdate=function()
{var _this=this;this.multiUpload.clearArguments();this.clearErrors();var changes=false;if(this.html.email.value!=""){if(!LD.Validation.isEmail(this.html.email.value)){try{this.html.email.focus()}catch(e){};this.setError("email",__("Please enter a valid email address"));}}
if(this.html.newPassword.value!=""){if(this.html.password.value==""){this.html.password.focus();this.setError("password",__("Please enter current password"));}
if(this.html.newPassword.value==""){this.html.newPassword.focus();this.setError("newPassword",__("Please enter new password"));}
else if(!LD.Validation.lengthBetween(this.html.newPassword.value,6)){this.html.newPassword.focus();this.setError("newPassword",__("New password is too short"));}
if(this.html.repeatNewPassword.value==""){this.html.repeatNewPassword.focus();this.setError("repeatNewPassword",__("Confirm your new password"));}
else if(this.html.repeatNewPassword.value!=this.html.newPassword.value){this.html.repeatNewPassword.focus();this.setError("repeatNewPassword",__("Re-type your new password exactly"));}
if(this.errorCount>0)return;changes=true;this.multiUpload.setArgument("password",this.html.password.value);this.multiUpload.setArgument("newPassword",this.html.newPassword.value);}
this.multiUpload.setArgument("firstName",this.html.firstName.value);this.multiUpload.setArgument("lastName",this.html.lastName.value);this.multiUpload.setArgument("email",this.html.email.value);if(this.html.avatarSelector.value==0)
this.multiUpload.setArgument("avatar",this.selectedAvatar||"");if(this.html.wallpaperSelector.value==0)
this.multiUpload.setArgument("wallpaper",this.selectedWallpaper||"");this.multiUpload.setArgument("gender",getRadioValue(this.html.gender));this.multiUpload.setArgument("country",this.html.country.value);this.multiUpload.setArgument("city",this.html.city.value);this.multiUpload.setArgument("birthDate",this.birthDate.getValue().toMilitary());this.multiUpload.setArgument("tags",this.html.tagList.value);this.multiUpload.setArgument("selfDescription",this.html.selfDescription.value);this.multiUpload.setArgument("downloadable",getRadioValue(this.html.downloadable));this.multiUpload.setArgument("defaultAccess",this.html.defaultAccess.value);this.multiUpload.setArgument("publicProfile",this.html.publicProfile.checked);this.multiUpload.setArgument("searchableFiles",this.html.searchableFiles.checked);R31UserRegistry.updateLoggedUserInfo(this.multiUpload.requestArguments);this.multiUpload.setCommand("updateProfile");this.multiUpload.upload();}
R31ProfileManager.prototype.updateFinished=function(evt,type,src)
{if(!evt)return;this.setInProgress(false);var result=evt.result;var changes=false;if(typeof(result.newPassword)!="undefined"){if(result.password==R31.ERR_WRONG_PASSWORD)
this.setError("password",__("Current password is wrong"));if(result.newPassword==R31.ERR_INVALID_DATA)
this.setError("newPassword",__("New password is not valid"));if(result.password==true&&result.newPassword==true)
changes=true;}
if(typeof(result.avatar)!="undefined"){if(result.avatar==R31.ERR_UPLOAD_FAILED)
this.setError("avatar",__("Upload process failed"));else if(typeof(result.avatar)=="string")
changes=true;}
if(typeof(result.wallpaper)!="undefined"){if(result.wallpaper==R31.ERR_UPLOAD_FAILED)
this.setError("wallpaper",__("Upload process failed"));else if(typeof(result.wallpaper)=="string"){changes=true;}}
changes=result.info===true;if(changes==true){this.fireEvent(evt,R31.EVT_USER_PROFILE_CHANGED);this.reset();}}
R31ProfileManager.prototype.reset=function()
{this.multiUpload.initFileInputs();}
R31ProfileManager.prototype.cancel=function()
{this.reset();}
R31ProfileManager.prototype.setError=function(country,message)
{++this.errorCount;this.html["error_"+country].innerHTML=message;}
R31ProfileManager.prototype.clearErrors=function()
{this.errorCount=0;for(var k in this.html){if(k.substr(0,6)=="error_")
this.html[k].innerHTML="";}}
R31ProfileManager.prototype.setInProgress=function(inProgress)
{this.inProgress=(inProgress==true);if(!this.root)return;this.html.uploadAvatar.style.cursor=(this.inProgress?"wait":"");this.html.uploadWallpaper.style.cursor=(this.inProgress?"wait":"");this.html.buttonUpdateProfile.style.cursor=(this.inProgress?"wait":"");}
R31PreferenceManager.extend(LD.Proto);function R31PreferenceManager(desktop)
{this.desktop=(desktop instanceof JUIDesktop)?desktop:null;this.preferences=new Object();}
R31PreferenceManager.prototype.getUserPreferences=function(userId)
{userId=intVal(userId);if(!userId)
throw"R31PreferenceManager.getUserPreferences: Must specify userId";return this.preferences[userId];}
R31PreferenceManager.prototype.setUserPreferences=function(userId,preferences)
{userId=intVal(userId);if(!userId)
throw"R31PreferenceManager.setUserPreferences: Must specify userId";if(!(preferences instanceof PreferencePage))
throw"R31PreferenceManager.setUserPreferences: Must provide a PreferencePage object";this.preferences[userId]=preferences;}
R31EmbedTool.extend(R31Dialog);R31EmbedTool.templates={base:"JUIWindow",contentBase:"R31Dialog",content:"R31EmbedTool"};function R31EmbedTool(title)
{R31EmbedTool.superConstructor.call(this,title);this.invitePane=null;this.prototypes=new Object();}
R31EmbedTool.prototype.init=function(content)
{R31EmbedTool.superClass.init.call(this);var _this=this;var entry,newEntryHtml;if(!content)
content=JUI.getTemplateInstance(R31EmbedTool.templates.content);this.addContent(content);this.content.html.embedCode.value="text code here";this.content.html.buttonClose.onclick=function(){_this.cancel();}}
R31FeedbackTool.extend(R31Dialog);R31FeedbackTool.templates={base:"JUIWindow",contentBase:"R31Dialog",content:"R31FeedbackTool"};function R31FeedbackTool(title)
{R31FeedbackTool.superConstructor.call(this,title);this.invitePane=null;this.prototypes=new Object();}
R31FeedbackTool.prototype.init=function(content)
{R31FeedbackTool.superClass.init.call(this);var _this=this;var entry,newEntryHtml;if(!content)
content=JUI.getTemplateInstance(R31FeedbackTool.templates.content);this.addContent(content);this.content.html.buttonOk.onclick=function(){if(!_this.inProgress)
_this.sendFeedback();}}
R31FeedbackTool.prototype.getLogInfo=function()
{return{tag:"feedback",value:""};}
R31FeedbackTool.prototype.refreshInfo=function()
{}
R31FeedbackTool.prototype.sendFeedback=function()
{var user=R31UserRegistry.getLoggedUser();if(!user)return;var _this=this;var cat=this.content.html.category;var category=cat.options[cat.selectedIndex].text||"";var subject=this.content.html.subject.value||"";var message=this.content.html.description.value||"";if(message==""||subject==""||category=="")return;var ajax=new R31Ajax();ajax.setMethod(Ajax.METHOD_POST);ajax.setArgument("cmd","sendFeedback");ajax.setArgument("user",user.id);ajax.setBodyArgument("extra",Json.toString({subject:subject,category:category,message:message}));ajax.setProgressCallback(function(socket)
{if(socket.getReadyState()==Ajax.STATE_COMPLETE)
_this.setInProgress(false);});ajax.setSuccessCallback(function(socket)
{var result=socket.response;var msg;if(typeof(result)=="number"&&result>0)
msg=__("Your feedback has been sent");else
msg=__("Could not send feedback");_this.content.html.category.selectedIndex=0;_this.content.html.subject.value="";_this.content.html.description.value="";_this.close();var opt={"messageType":JUIDialogWindow.ALERT};JUI.getTopContainer().showPopupWindow(JUIDialogWindow.makeDialog(msg,"Wixi",opt));});this.setInProgress(true);ajax.send("room_provider.php");}
R31FeedbackTool.prototype.setInProgress=function(inProgress)
{this.inProgress=(inProgress==true);if(!this.root)return;this.content.html.buttonOk.style.cursor=(this.inProgress?"wait":"");}

/*========== R31IFrameWindow.js ==========*/

R31IFrameWindow.extend(JUIWindow);R31IFrameWindow.templates={base:"JUIWindow",content:"R31IFrameWindow"};function R31IFrameWindow(title)
{R31IFrameWindow.superConstructor.call(this,title,true,true);this.resizable=false;this.frameSource="";this.directions=new Array();this.directions[0]=DIR_STATIC+"copy/copy_files.html";this.directions[1]=DIR_STATIC+"player/discover_new_content.html";this.directions[2]=DIR_STATIC+"upload/upload.html";this.directions[3]=DIR_STATIC+"manage/manage.html";this.directions[4]=DIR_STATIC+"embed/embed.html";this.directions[5]=DIR_STATIC+"share/share.html";}
R31IFrameWindow.prototype.loadFrame=function(src)
{this.frameSource=src;if(!this.root||!this.content.html.iframe)return;this.content.html.iframe.src=src;}
R31IFrameWindow.prototype.init=function(htmlNode)
{var _this=this;R31IFrameWindow.superClass.init.call(this,htmlNode);this.content=new JUIHtmlNode(JUI.getTemplateInstance(R31IFrameWindow.templates.content));this.content.setLocation(0,0);this.getContentPane().add(this.content);this.loadFrame(_this.directions[intVal(_this.content.html.faqSelector.value)]);this.content.html.faqSelector.onchange=function(){_this.loadFrame(_this.directions[intVal(_this.content.html.faqSelector.value)]);}
this.content.html.next.onclick=function(){var place=intVal(_this.content.html.faqSelector.value)+1;if(place<_this.directions.length){_this.content.html.faqSelector.value=intVal(_this.content.html.faqSelector.value)+1
_this.loadFrame(_this.directions[intVal(_this.content.html.faqSelector.value)]);}}
this.content.html.previous.onclick=function(){var place=intVal(_this.content.html.faqSelector.value);if(place>-1){_this.content.html.faqSelector.value=intVal(_this.content.html.faqSelector.value)-1
_this.loadFrame(_this.directions[intVal(_this.content.html.faqSelector.value)]);}}}

/*========== R31Window.js ==========*/

R31Window.extend(JUIWindow);R31Window.templates={base:"JUIWindow"};R31Window.VIEW_ICONS=0;R31Window.VIEW_LIST=1;R31Window.VIEW_PLAYER=2;R31Window.viewNameMap={"icons":R31Window.VIEW_ICONS,"list":R31Window.VIEW_LIST,"player":R31Window.VIEW_PLAYER};function R31Window(title,closable,minimizable,maximizable,collapsable)
{R31Window.superConstructor.call(this,title,closable,minimizable,maximizable,collapsable);var _this=this;this.setCloseAction(JUIWindow.DISPOSE_ON_CLOSE);this.fsSource=null;this.filterRegExp=null;this.filterCode=0;this.contentFilter=new ContentFilter(ContentFilter.USE_FUNCTION,function(fsNode){if(fsNode.getType()==FileSystem.NODE_TYPE_DIR)return true;var loggedUser=R31UserRegistry.getLoggedUser();if(fsNode instanceof FileSystemFile&&(!loggedUser||loggedUser.id!=fsNode.getOwner())&&!fsNode.isAvailable()){return false;}
var match=true;if(_this.filterRegExp!=null)
match=match&&_this.filterRegExp.test(fsNode.getName());return match;});this.contentComparator=FileSystemNode.typeComparator;this.commonObjects=new Object();this.views=new Array();this.addContentViews();this.activeView=1;this.minWidth=320;this.minHeight=120;this.controlButtonVisible=true;this.preloaderVisible=false;this.titleBarVisible=true;this.toolBarVisible=true;this.statusBarVisible=true;this.mediaPlayerMode=false;this.mediaPlayerData=new Object();}
R31Window.prototype.init=function(htmlNode)
{R31Window.superClass.init.call(this,htmlNode);var isDirectory=(this.fsSource instanceof FileSystemDirectory);var loggedUser=R31UserRegistry.getLoggedUser();var nodeOwnerId=this.fsSource.getOwner();var showViewButtons,showCmdButtons;if(isDirectory){showViewButtons=true;showCmdButtons={addToWixi:false,share:true,download:false,more:true};}
else{showViewButtons=false;showCmdButtons={addToWixi:(loggedUser.id!=nodeOwnerId),share:true,download:false,more:true};var validateDownload=true;}
this.toolBar.setVisible(true);this.toolBar.setViewButtonsVisible(showViewButtons);this.toolBar.setCommandButtonsVisible(showCmdButtons);if(validateDownload){var _this=this;R31Action.validate(R31Action.DOWNLOAD_NODE,this.fsSource,loggedUser,function(){_this.toolBar.setCommandButtonsVisible({download:true});});}
this.html.preloader.style.display=(this.preloaderVisible)?"block":"none";if(this.fsSource instanceof FileSystemDirectory)
this.setStatusBarText(__("Please wait while loading..."));else
this.setStatusBarText("");this.viewFooter();var fsSource=this.fsSource;this.html.textAdsArea.onclick=function(){window.desktopManager.invite(fsSource);}}
R31Window.prototype.addToolBar=function()
{var toolBar=new R31WindowToolBar(JUI.LAYOUT_HORIZONTAL,"",false);this.toolBar=toolBar;toolBar.init();toolBar.setPositioning(JUI.POSITION_STATIC);this.html.toolBarArea.appendChild(toolBar.getRoot());this.children.push(toolBar);var _this=this;toolBar.addListener(R31WindowToolBar.EVT_VIEW_BUTTON_CLICKED,function(evt,type,src){if(!evt||!isDefined(evt.buttonId))return;var id="".concat(evt.buttonId);switch(id){case"view_player":case"view_list":case"view_icons":var viewIndex=R31Window.viewNameMap[id.substr(5)];if(isDefined(viewIndex)){_this.setActiveView(viewIndex);}
break;case"cmd_add":R31DesktopShell.doAction(R31.ACTION_FS_NODE_ADD,_this.getFileSystemSource());break;case"cmd_share":R31DesktopShell.doAction(R31.ACTION_INVITE,_this.getFileSystemSource());break;case"cmd_download":R31DesktopShell.doAction(R31.ACTION_FILE_SAVE_AS,_this.getFileSystemSource());break;case"cmd_more":var menu=_this.commonObjects["windowMenu"];if(menu){menu.setBoundComponent(_this);var xy=getXY(_this.root);var wh=getSize(_this.root);var menuWH=getSize(menu.getRoot());menu.setLocation(xy.x+wh.width,xy.y);menu.setVisible(true);}
break;}});}
R31Window.prototype.viewFooter=function(view)
{}
R31Window.prototype.getLogInfo=function()
{return{tag:"folder",value:(this.fsSource)?this.fsSource.getId():""}}
R31Window.prototype.menuActionFired=function(evt,type,src)
{if(!evt||!type||!this.fsSource)return;switch(evt.action){case R31.ACTION_FOLDER_CREATE:R31DesktopShell.doAction(evt.action,this.fsSource);break;}}
R31Window.prototype.getContentSource=function()
{return this.fsSource;}
R31Window.prototype.getFileSystemSource=function()
{return this.fsSource;}
R31Window.prototype.getFileSystemNode=function()
{return this.fsSource;}
R31Window.prototype.setFileSystemSource=function(fsNode)
{if(!(fsNode instanceof FileSystemNode))
throw"R31Window.setFileSystemSource: Must provide FileSystemNode object to associate with";this.fsSource=fsNode;this.startLoadingAnimation();if(fsNode instanceof FileSystemDirectory){fsNode.addListener(FileSystem.EVT_NODE_CHANGED,this.fileSystemSourceChanged,this);fsNode.addListener(FileSystem.EVT_NODE_CHILDREN_CHANGED,this.fileSystemSourceChildrenChanged,this);this.setIcon(getImageURL("/skins/"+JUI.getCurrentSkin()+"/folder_a.png"));}
else{fsNode.addListener(FileSystem.EVT_NODE_CHANGED,this.fileSystemSourceChanged,this);var td=fsNode.getTypeDescriptor();if(td!=null){var typeIcon=td.getDefaultIcon()||"file_default_a.png";this.setIcon(getImageURL("/skins/"+JUI.getCurrentSkin()+"/"+typeIcon+"_a.png"));}}
this.fileSystemSourceChanged();}
R31Window.prototype.startLoadingAnimation=function()
{this.preloaderVisible=true;if(!this.root)return;this.html.preloader.style.display="block";}
R31Window.prototype.finishLoadingAnimation=function()
{this.preloaderVisible=false;if(!this.root)return;this.html.preloader.style.display="none";}
R31Window.prototype.fileSystemSourceChanged=function()
{if(!this.fsSource||!this.root)return;this.setTitle(this.fsSource.getName());this.toolBar.setVisible(this.fsSource instanceof FileSystemDirectory);}
R31Window.prototype.fileSystemSourceChildrenChanged=function()
{this.finishLoadingAnimation();this.refreshStatusBar();}
R31Window.prototype.refreshStatusBar=function()
{if(this.fsSource instanceof FileSystemDirectory){var dirCount=0,fileCount=0,linkCount=0,sizeCount=0,txt="";var entries=this.fsSource.getChildren(),type;for(var i=0;i<entries.length;i++){type=entries[i].getType();if(type==FileSystem.NODE_TYPE_DIR){++dirCount;}
else if(type==FileSystem.NODE_TYPE_FILE){++fileCount;sizeCount+=entries[i].getSize();}
else if(type==FileSystem.NODE_TYPE_LINK){++linkCount;}}
if(dirCount>0)
txt=_("%1 folders, %2 files (%3 kb)",dirCount,(fileCount+linkCount),Math.ceil(sizeCount/1024));else
txt=_("%1 files (%2 kb)",(fileCount+linkCount),Math.ceil(sizeCount/1024));this.setStatusBarText(txt);}
else{this.setStatusBarText('');}}
R31Window.prototype.getCommonObject=function(key)
{return this.commonObjects[key]||null;}
R31Window.prototype.setCommonObject=function(key,object)
{if(key==""||typeof(key)!="string"||!object||typeof(object)!="object")return;this.commonObjects[key]=object;}
R31Window.prototype.contentChanged=function()
{this.showContent();}
R31Window.prototype.filterChanged=function()
{this.showContent();}
R31Window.prototype.fileUploaded=function(evt,type,src)
{if(!evt||!evt.result)return;if(evt.result!=false&&this.fsSource)
this.fsSource.fetchChildren();}
R31Window.prototype.searchFinished=function(evt,type,src)
{if(!evt||!evt.result)return;this.fireEvent(evt,JUISearch.EVT_SEARCH_FINISHED);}
R31Window.prototype.showContent=function()
{this.contentPane.removeAll();var contentSource=this.getContentSource();if(!contentSource)return;var fsEntries=contentSource.getChildren();var entries=(this.contentFilter)?this.contentFilter.filter(fsEntries):fsEntries;if(this.contentComparator!=null)
entries=entries.sort(this.contentComparator);this.getActiveView().render(entries);}
R31Window.prototype.addContentViews=function()
{var _this=this;this.iconViewLayout=new JUIMosaicLayout({hGap:13,vGap:13,hLimit:300});this.views[R31Window.VIEW_ICONS]={name:"icons",index:0,render:function(entries)
{_this.setMediaPlayerMode(false);var cps=_this.getContentPane().getSize();var holder=new JUIContainer(_this.iconViewLayout);holder.setPositioning(JUI.POSITION_RELATIVE);holder.setBounds(0,0,cps.width-20,cps.height);holder.init();var fsNode=_this.getFileSystemSource(),childNode=null;var isTrashBin=(fsNode!=null&&fsNode.getSysId()=="cf4e21b27e735b55");var iconConstructor=isTrashBin?R31TrashNodeIcon:R31FileIcon;var icon=null;for(var i=0;i<entries.length;i++){childNode=entries[i];icon=new iconConstructor(childNode);icon.setDraggable(true);icon.init();icon.setVisible(true);icon.setName(childNode.getName());if(isTrashBin){icon.setMenu(_this.commonObjects['trashNodeMenu']);}
else{if(childNode.isDirectory()){JUI.DragDrop.registerDropTarget(new JUIDropTarget(icon,icon));if(_this.commonObjects['dirIconMenu'])
icon.setMenu(_this.commonObjects['dirIconMenu']);}
else{if(_this.commonObjects['fileIconMenu'])
icon.setMenu(_this.commonObjects['fileIconMenu']);}}
icon.addListener(JUI.EVT_MOUSE_DBLCLICK,icon.open,icon);JUI.DragDrop.registerDragSource(new JUIDragSource(icon,icon));holder.add(icon);}
_this.contentPane.add(holder);holder.setVisible(true);holder.parentResized=function(){var wh=getSize(this.parent.getRoot());this.setPreferredWidth(wh.width-20);}
_this.addListener(JUI.EVT_RESIZED,holder.parentResized,holder);holder.repaint();}}
this.views[R31Window.VIEW_LIST]={name:"list",index:1,render:function(entries)
{_this.setMediaPlayerMode(false);var holder=new JUIContainer();holder.setPositioning(JUI.POSITION_RELATIVE);holder.init();var fsNode=_this.getFileSystemSource();var isTrashBin=(fsNode!=null&&fsNode.getSysId()=="cf4e21b27e735b55");var iconConstructor=isTrashBin?R31TrashNodeEntry:R31FileEntry;var entry,node,th=1;var pw=_this.contentPane.getPreferredWidth()-20,ph=th*22;for(var i=0;i<entries.length;i++){node=entries[i];entry=new iconConstructor(node);entry.init();entry.setBounds(0,th,pw,ph);entry.setVisible(true);holder.add(entry);entry.setBackgroundColor((i%2)>0?"#eeeeee":"");var type=node.getType();type=node.getType();if(isTrashBin){entry.setMenu(_this.commonObjects['trashNodeMenu']);}
else{if(type==FileSystem.NODE_TYPE_DIR){JUI.DragDrop.registerDropTarget(new JUIDropTarget(entry,entry));if(_this.commonObjects['dirIconMenu'])
entry.setMenu(_this.commonObjects['dirIconMenu']);}
else if(type==FileSystem.NODE_TYPE_FILE){if(_this.commonObjects['fileIconMenu'])
entry.setMenu(_this.commonObjects['fileIconMenu']);}
else if(type==FileSystem.NODE_TYPE_LINK){if(_this.commonObjects['fileIconMenu'])
entry.setMenu(_this.commonObjects['fileIconMenu']);}}
JUI.DragDrop.registerDragSource(new JUIDragSource(entry,entry));th+=(entry.getHeight()+1);}
holder.setBounds(0,0,pw,th);_this.contentPane.add(holder);holder.setVisible(true);holder.repaint=function(){JUIContainer.superClass.repaint.call(this);for(var i=0;i<this.children.length;i++){this.children[i].setPreferredWidth(this.width);}}
holder.parentResized=function(){var wh=getSize(this.parent.getRoot());this.setPreferredWidth(wh.width-20);}
_this.addListener(JUI.EVT_RESIZED,holder.parentResized,holder);holder.parentResized();}}
this.views[R31Window.VIEW_PLAYER]={name:"player",index:2,render:function(entries)
{_this.setMediaPlayerMode(true);var fsSource=_this.getFileSystemSource();var source;if(entries&&fsSource&&arrayEquals(entries,fsSource.getChildren())==false)
source=entries;else
source=fsSource;var player=new R31MediaPlayer(source);player.init(null,{menu:false});_this.contentPane.add(player);_this.player=player.componentId;_this.getLogInfo=function(){var c=JUIComponent.getInstance(this.player);return(c!=null)?c.getLogInfo():null;}
var mediator=new R31MediaPlayerController(player);player.setMediator(mediator);player.refreshPlaylist();}}}
R31Window.prototype.setMediaPlayerMode=function(playerMode)
{if(playerMode==true){if(this.mediaPlayerMode!=true){this.mediaPlayerData.windowWidth=this.width;this.mediaPlayerData.windowHeight=this.height;}
this.setSize(R31MediaPlayer.DEFAULT_WIDTH,R31MediaPlayer.DEFAULT_HEIGHT);this.mediaPlayerMode=true;}
else{if(this.mediaPlayerMode==true){var w=intVal(this.mediaPlayerData.windowWidth);var h=intVal(this.mediaPlayerData.windowHeight);if(w>0&&h>0)
this.setSize(w,h);}
this.mediaPlayerMode=false;}}
R31Window.prototype.getActiveView=function()
{return this.views[this.activeView];}
R31Window.prototype.setActiveView=function(index)
{if(typeof(index)!="number")return false;if(index!=this.activeView){this.activeView=index;this.showContent();}}
R31Window.prototype.getContentFilter=function()
{return this.contentFilter||null;}
R31Window.prototype.setContentFilter=function(filter)
{if(filter!==null&&!(filter instanceof ContentFilter))
throw"R31Window.setContentFilter: Must provide an instance of ContentFilter";this.contentFilter=filter||null;}
R31Window.prototype.clearContentFilter=function()
{this.filterCode=0;this.filterRegExp=new RegExp(".+","i");var evt={"filter":this.contentFilter};this.filterChanged();this.fireEvent(evt,R31.EVT_WINDOW_FILTER_CHANGED);}
R31Window.prototype.filterContentByExtension=function(expression)
{this.filterRegExp=new RegExp("^.+\.("+expression+")$","i");var evt={"filter":this.contentFilter};this.filterChanged();this.fireEvent(evt,R31.EVT_WINDOW_FILTER_CHANGED);}
R31Window.prototype.addDefaultFilterButtons=function(container,height)
{if(!(container instanceof JUIContainer)){throw"R31Window.addDefaultFilterButtons: Must provide a JUIContainer instance to put buttons into";}
var _this=this;height=intVal(varDefault(height,20));container.setPreferredWidth(52+4*24);container.setPreferredHeight(height);container.setBackgroundColor("#eeeeee");container.setBorder("1px outset #eeeeee");container.setLayout(new JUIStackLayout(JUI.LAYOUT_HORIZONTAL));var label=JUI.makeLabel(36,height,"Filters",_("Choose the type of file you want to show"),{"textAlign":"center","padding":"2 1 2 1"});container.add(label);container.add(JUI.makeButton(height,"",getImageURL("/skins/"+JUI.currentSkin+"/icon_all.gif"),_("Show all files"),function(evt,type,src){_this.clearContentFilter();},null,{"border":"none"}));container.add(JUI.makeButton(height,"",getImageURL("/skins/"+JUI.currentSkin+"/icon_mus.gif"),_("Show audio files only"),function(evt,type,src){_this.filterContentByExtension("wav|mp3");},null,{"border":"none"}));container.add(JUI.makeButton(height,"",getImageURL("/skins/"+JUI.currentSkin+"/icon_pic.gif"),_("Show pictures only"),function(evt,type,src){_this.filterContentByExtension("jpeg|jpg|png|ico|bmp|gif|tif|tiff");},null,{"border":"none"}));container.add(JUI.makeButton(height,"",getImageURL("/skins/"+JUI.currentSkin+"/icon_vid.gif"),_("Show video files only"),function(evt,type,src){_this.filterContentByExtension("mpg|mpeg|avi|rm|mov|swf|flv");},null,{"border":"none"}));container.add(JUI.makeButton(height,"",getImageURL("/skins/"+JUI.currentSkin+"/icon_doc.gif"),_("Show documents only"),function(evt,type,src){_this.filterContentByExtension("txt|doc|rtf|pdf|htm|html|xml");},null,{"border":"none"}));}
R31Window.prototype.getContentComparator=function()
{return this.contentComparator||null;}
R31Window.prototype.setContentComparator=function(comparator)
{if(comparator!==null&&typeof(comparator)!="function"){throw"R31Window.setContentComparator: Must provide a comparator function";}
this.contentComparator=comparator;}

/*========== R31SpecialWindows.js ==========*/

R31SearchResultWindow.extend(R31Window);R31SearchResultWindow.templates={base:"JUIWindow"};function R31SearchResultWindow(title,closable,collapsable)
{R31SearchResultWindow.superConstructor.call(this,title,closable,collapsable);this.controlButtonVisible=false;this.preloaderVisible=true;}
R31SearchResultWindow.prototype.init=function()
{R31SearchResultWindow.superClass.init.call(this);this.setIcon(getImageURL("/skins/"+JUI.currentSkin+"/icon_search.gif"));this.toolBar.setVisible(true);}
R31SearchResultWindow.prototype.setSearchResult=function(result)
{if(!result||!(result instanceof JUISearchResult))return;this.searchResult=result;this.finishLoadingAnimation();}
R31SearchResultWindow.prototype.getContentSource=function()
{return this.searchResult;}
R31WarningWindow.extend(JUIWindow);R31WarningWindow.templates={base:"JUIWindow",content:"R31WarningWindow"};function R31WarningWindow(title,warningType)
{R31WarningWindow.superConstructor.call(this,title,true,false);this.controlButtonVisible=false;this.warningType=warningType||"";}
R31WarningWindow.prototype.init=function(htmlNode)
{R31WarningWindow.superClass.init.call(this);this.content=new JUIHtmlNode(JUI.getTemplateInstance(R31WarningWindow.templates.content));this.getContentPane().add(this.content);this.setWarningType(this.warningType);var _this=this;this.content.html.okButton.onclick=function(){_this.close();}}
R31WarningWindow.prototype.getWarningType=function()
{return this.warningType;}
R31WarningWindow.prototype.setWarningType=function(warningType)
{this.warningType=warningType;if(!this.root||!this.content)return;var html=this.content.html;if(html.warningHolder){for(var i=0;i<html.warningHolder.childNodes.length;i++){var child=html.warningHolder.childNodes[i];if(child.nodeType!=LD.NODE_ELEMENT)continue;var id=(child.attributes.dhtmlid)?child.attributes.dhtmlid.value:"";if(id==warningType)
child.style.display="";else
child.style.display="none";}}}
R31SearchWindow.extend(JUIWindow);R31SearchWindow.templates={base:"JUIWindow",content:"R31SearchWindow",item:"R31SearchWindow_item"};function R31SearchWindow(title)
{R31SearchWindow.superConstructor.call(this,title,true,false);this._ajax=new R31Ajax();this.resizable=false;this.collapsedBounds={width:400,height:160};this.expandedBounds={width:400,height:380};this.resultsVisible=false;this.userFriendsProvider=null;this.cmd="search";this.url="";}
R31SearchWindow.prototype.init=function(htmlNode)
{R31SearchWindow.superClass.init.call(this,htmlNode);var _this=this;var tpl=JUI.getTemplateInstance(this.constructor.templates.content);this.content=new JUIHtmlNode(tpl);this.content.setLocation(0,0);var cp=this.getContentPane();cp.setScrolling(JUI.SCROLL_NONE);cp.add(this.content);this.doYouLikeMyNewSocks="";this.sarabasa='aloha';this.content.html.searchExp.onkeypress=function(evt){evt=evt||window.event;var keyCode=evt.keyCode;if(keyCode==13){LD.Event.cancel(evt);_this.content.html.buttonSearch.onclick();}}
this.content.html.buttonSearch.onclick=function(){_this.content.html.err_searchExp.innerHTML="";var searchExp=varDefault(_this.content.html.searchExp.value,"").toString();var ok=true;if(searchExp==""){_this.content.html.err_searchExp.innerHTML=__("Type first name, last name, username or email");return false;}
if(LD.Validation.lengthBetween(searchExp,1,2)){_this.content.html.err_searchExp.innerHTML=__("Enter 3 or more letters");ok=false;}
if(ok)
_this.search(searchExp);}
var resultPane=new JUIContainer();this.resultPane=resultPane;resultPane.init(this.content.html.resultPane);this.setResultsVisible(this.resultsVisible);with(resultPane.getRoot().style){overflowX="hidden";overflowY="auto";}
resultPane.setBounds(10,95,378,244);}
R31SearchWindow.prototype.search=function(token,type,owner,page,friends)
{owner=owner||0;token=varDefault(token,"");type=intVal(varDefault(type,0));var channel='';if(owner==-1)
channel="youtube";if(token=="")return false;page=intVal(varDefault(page,0));friends=intVal(varDefault(friends,0));var _this=this;this._ajax.setArgument({cmd:this.cmd,searchExp:token,type:type,owner:owner,page:page,friends:friends,channel:channel});this._ajax.setProgressCallback(function(socket)
{if(socket.getReadyState()==Ajax.STATE_COMPLETE)
_this.setInProgress(false);});this._ajax.setSuccessCallback(function(socket)
{var result=socket.response;if(result!=null)
_this.searchFinished(token,result,type);});this.setInProgress(true);if(this.url!="")
this._ajax.send(this.url);this.clearResults();}
R31SearchWindow.prototype.searchFinished=function(token,result,type)
{if(result==null||!result.rows)return false;this.setResultsVisible(true);var newItem,colors=["transparent","#f7dfff"];if(result.count>0){this.eventSearchFinished(token,result,type);for(var i=0;i<result.count;i++){newItem=this.renderResultEntry(result.rows[i]);this.resultPane.add(newItem);}}
else
{LD.Element.writeText(this.resultPane.getRoot(),__("No results matching your criteria"));}}
R31SearchWindow.prototype.renderResultEntry=function(entry)
{throw"Must implement renderResultEntry in subclass";}
R31SearchWindow.prototype.eventSearchFinished=function(searchExp,result,type)
{}
R31SearchWindow.prototype.setInProgress=function(inProgress)
{this.inProgress=(inProgress==true);if(!this.root)return;this.content.html.buttonSearch.style.cursor=(this.inProgress?"wait":"pointer");}
R31SearchWindow.prototype.clearResults=function()
{this.resultPane.removeAll();LD.Element.removeChildren(this.resultPane.getRoot());}
R31SearchWindow.prototype.setResultsVisible=function(visible)
{this.resultsVisible=(visible==true);if(this.resultsVisible)
this.setSize(this.expandedBounds.width,this.expandedBounds.height);else
this.setSize(this.collapsedBounds.width,this.collapsedBounds.height);if(!this.root||!this.resultPane)return;this.resultPane.setVisible(this.resultsVisible);}
R31UserSearchWindow.extend(R31SearchWindow);R31UserSearchWindow.templates={base:"JUIWindow",content:"R31UserSearchWindow",item:"R31UserSearchWindow_item"};function R31UserSearchWindow(title)
{R31UserSearchWindow.superConstructor.call(this,title);this._ajax=new R31Ajax();this.resizable=false;this.resultsVisible=false;this.userFriendsProvider=null;this.collapsedBounds={width:400,height:130};this.expandedBounds={width:400,height:380};this.cmd="searchUsers";this.url="search.php";this.searchType=1;}
R31UserSearchWindow.prototype.init=function(htmlNode)
{R31UserSearchWindow.superClass.init.call(this,htmlNode);var _this=this;this.content.html.buttonSearch.onclick=function(){_this.content.html.err_searchExp.innerHTML="";var searchExp=varDefault(_this.content.html.searchExp.value,"").toString();var ok=true;if(searchExp==""){_this.content.html.err_searchExp.innerHTML=__("Please enter first name, last name or username");return false;}
if(LD.Validation.lengthBetween(searchExp,1,2)){_this.content.html.err_searchExp.innerHTML=__("Enter 3 or more letters");ok=false;}
if(ok==true)
_this.search(searchExp,1);}}
R31UserSearchWindow.prototype.getLogInfo=function()
{return{tag:"user_search",value:""};}
R31UserSearchWindow.prototype.renderResultEntry=function(entry)
{if(!entry)return false;var user=R31UserRegistry.getLoggedUser();var newItem=new JUIHtmlNode(JUI.getTemplateInstance(R31UserSearchWindow.templates.item));newItem.setPositioning(JUI.POSITION_RELATIVE);LD.Element.writeText(newItem.html.name,(entry.name).trim());newItem.html.avatar.src=(entry.avatar!="")?getAvatarURL(entry.avatar):R31.DEFAULT_AVATAR;var genderImg=(entry.gender)?(getImageURL("/skins/"+JUI.currentSkin+"/gender_"+entry.gender+".gif")):JUI.nullImageSrc;newItem.html.gender.src=genderImg;var bd=stringToDate(entry.birthDate),now=new Date();var age=(bd&&bd.valueOf()>0)?Math.floor((now.valueOf()-bd.valueOf())/86400000/365.25):0;LD.Element.writeText(newItem.html.age,(age>0)?(__(" (age ")+age+")"):"");LD.Element.writeText(newItem.html.description,(entry.selfDescription).trim()||__("No description"));LD.Element.writeText(newItem.html.country,R31.Countries[entry.country]||"");newItem.html.linkFriends.href="javascript:;";newItem.html.linkFriends.target="_parent";newItem.html.linkFriends.entryUser=entry;if(user==null||(user.id!=entry.id&&!this.isFriend(entry)))
newItem.html.linkFriends.onclick=function(){R31DesktopShell.doAction(R31.ACTION_REQUEST_FRIENDSHIP,this.entryUser);}
else
newItem.html.linkFriends.style.display="none";newItem.html.linkWixi.href=("./?room="+entry.room);newItem.html.linkWixi.target="_parent";newItem.html.linkAvatarWixi.href=("./?room="+entry.room);newItem.html.linkAvatarWixi.target="_parent";newItem.setBounds(0,0,356,60);newItem.setVisible(true);return newItem;}
R31UserSearchWindow.prototype.isFriend=function(user)
{if(!user||!user.id)return false;var friends=R31UserRegistry.getUserFriends(user);if(!friends)return false;for(var i=0;i<friends.length;i++){if(friends[i].id==user.id)
return true;}
return false;}
R31FileSearchWindow.extend(R31SearchWindow);R31FileSearchWindow.templates={base:"JUIWindow",content:"R31FileSearchWindow",item:"R31FileSearchWindow_item",pagerItem:"R31FileSearchWindow_pagerItem"};function R31FileSearchWindow(title)
{R31FileSearchWindow.superConstructor.call(this,title);this.collapsedBounds={width:561,height:150};this.expandedBounds={width:561,height:440};this.cmd="searchFiles";this.url="search.php";this.searchType=1;this.statusBarVisible=false;this.resizeable=false;this.resultsVisible=false;this._searchOwner=0;this._ajax=new R31Ajax();}
R31FileSearchWindow.prototype.init=function(htmlNode,onClick)
{R31FileSearchWindow.superClass.init.call(this,htmlNode);var searchFooter=new JUIContainer();this.searchFooter=searchFooter;searchFooter.init(this.content.html.fileSearchFooter);searchFooter.setPositioning(JUI.POSITION_ABSOLUTE);with(searchFooter.getRoot().style){overflowX="hidden";overflowY="auto";}
searchFooter.setBounds(350,388,200,20);var _this=this;if(typeof(onClick)=='undefined'||onClick)
{this.content.html.buttonSearch.onclick=function(){var searchExp=varDefault(_this.content.html.searchExp.value,"").toString();if(searchExp=="")return false;var ok=true;if(LD.Validation.lengthBetween(searchExp,1,2))
ok=false;if(ok==true){_this.searchFooter.setVisible(false);_this.startLoadingAnimation();var room=R31UserRegistry.getCurrentRoom();var from;var friends=0;if(_this.content.html.searchRadioWixi.checked)
{from="0";_this._searchOwner=0;}
else if(_this.content.html.searchRadioWorld.checked)
{from="-1";_this._searchOwner="-1";}
else if(_this.content.html.searchRadioFriends.checked)
{from=room.id;_this._searchOwner=room.id;friends=1;}
else if(room)
{from=room.id;_this._searchOwner=room.id;}
else
{from="0";_this._searchOwner=0;}
_this.search(searchExp,getSelectedValue(_this.content.html.type),from,0,friends);}}}
this.resultPane.setBounds(2,0,this.expandedBounds.width-4,this.expandedBounds.height-190);this.resultPane.setPositioning(JUI.POSITION_RELATIVE);if(typeof(this.content.html.searchLabelDesktopUser)!='undefined')
{this.content.html.searchLabelDesktopUser.innerHTML=__("in ")+R31UserRegistry.getCurrentRoom().name;}
this.html.contentPane0.style.backgroundColor='transparent';if(typeof(this.content.html.searchLabelDesktopUser)!='undefined')
{this.content.html.searchLabelDesktopUser.innerHTML=__("in ")+R31UserRegistry.getCurrentRoom().name;}
this.html.contentPane0.style.backgroundColor='transparent';this.content.html.buttonSearch.onmouseover=function()
{_this.content.html.buttonSearch.src="skins/"+JUI.getCurrentSkin()+"/R31FileSearch/btn_search_over.png";}
this.content.html.buttonSearch.onmouseout=function()
{_this.content.html.buttonSearch.src="skins/"+JUI.getCurrentSkin()+"/R31FileSearch/btn_search.png";}}
R31FileSearchWindow.prototype.getLogInfo=function()
{return{tag:"file_search",value:""};}
R31FileSearchWindow.prototype.eventSearchFinished=function(searchExp,results,type)
{this.finishLoadingAnimation();this.content.html.fileSearchFooter.innerHTML="";if(typeof(results.pager)!='undefined')
{for(var k in results.pager)
{this.searchFooter.add(this.renderPagerEntry(results.pager[k]));}
this.searchFooter.setVisible(true);}
if(results.count==0){return;}else{if(type==1){typeName='Images';}else if(type==2){typeName='Audio';}else if(type==3){typeName='Videos';}else{typeName='Files';}
var room=R31UserRegistry.getCurrentRoom();var user=(this.content.html.searchRadioUser.checked)?("&user="+room.name):"";var rss=Feeds.replace("FileSearchResults",URL_SOURCE_RSS+"?search="+searchExp+"&category="+type+user,typeName+" matching '"+searchExp+"'").toAnchor();this.content.html.buttonRSSSearch.appendChild(rss);this.content.html.buttonRSSSearch.style.display="inline";rss.firstChild.style.width="20px";rss.firstChild.style.height="20px";rss.firstChild.src=getImageURL("/skins/"+JUI.currentSkin+"/R31FileSearch/rss_21px.png");}
this.resultPane.getRoot().style.position='';}
R31FileSearchWindow.prototype.renderResultEntry=function(entry)
{if(!entry)return false;var fsNode=FileSystemNode.build(entry);if(!fsNode)return;var _this=this;var user=R31UserRegistry.getLoggedUser();var td=fsNode.getTypeDescriptor();var newItem=new JUIHtmlNode(JUI.getTemplateInstance(R31FileSearchWindow.templates.item));var size=fsNode.getSize(),sizeKb=Math.round(size/1024);LD.Element.writeText(newItem.html.name,(fsNode.name).trim());if(fsNode.getType()==FileSystem.NODE_TYPE_LINK)
{newItem.html.viewCount.style.display='';if(_this._searchOwner=="-1")
LD.Element.writeText(newItem.html.viewCount,'Views: '+fsNode.viewCount);if(fsNode.videoDuration)
LD.Element.writeText(newItem.html.size,fsNode.videoDuration);}
else
{LD.Element.writeText(newItem.html.size,sizeKb+" k");newItem.html.viewCount.style.display='none';LD.Element.writeText(newItem.html.viewCount,'');}
var mimeType;if(td!=null){mimeType=td.getMimeType();if(fsNode.isAvailable&&fsNode.hasThumbnail()&&(mimeType=="image"||mimeType=="video")){newItem.html.typeIcon.src=fsNode.thumbnailURL;newItem.html.typeIcon.style.width='88px';newItem.html.typeIcon.style.height='73px';newItem.html.typeIcon.style.marginTop='0px';}
else
newItem.html.typeIcon.src=getImageURL("/skins/"+JUI.currentSkin+"/"+td.getDefaultIcon()+"_a.png");}
else{mimeType="";newItem.html.typeIcon.src=DIR_IMAGES+"spacer.gif";}
newItem.height=86;if(size>STREAMING_THRESHOLD)
{newItem.height=86;newItem.html.srTable.style.height=newItem.height;newItem.html.warningMsg.style.display='block';LD.Element.writeText(newItem.html.warningMsg,'To add or play this file, you should become friend with the owner first!');}
if(entry.ownerUsername!=""&&entry.ownerAvatar){newItem.html.linkWixi.href=("./?room="+entry.ownerUsername);newItem.html.linkWixi.target="_parent";newItem.html.owner.innerHTML=varDefault(entry.ownerUsername,"");newItem.html.avatar.src=getAvatarURL(entry.ownerAvatar);}
else
newItem.html.linkWixi.style.display="none";newItem.html.name.fsNode=fsNode;if(user&&user.id!=fsNode.owner){newItem.html.name.onclick=function(){_this.addEntryToWixi(this.fsNode);}}
else{newItem.html.name.onclick=function(){R31DesktopShell.doAction(R31.ACTION_FS_NODE_PLAY_MEDIA,fsNode);}}
newItem.setPositioning(JUI.POSITION_RELATIVE);newItem.setBounds(0,0,540,newItem.height);newItem.setVisible(true);if(_this._searchOwner=="-1")
{newItem.html.body_User.style.width='10px';}
else
{newItem.html.body_User.style.width='80px';}
return newItem;}
R31FileSearchWindow.prototype.renderPagerEntry=function(entry)
{var _this=this;var newItem=new JUIHtmlNode(JUI.getTemplateInstance(R31FileSearchWindow.templates.pagerItem));var searchFunction=function(){var searchExp=varDefault(_this.content.html.searchExp.value,"").toString();if(searchExp=="")return false;var ok=true;if(LD.Validation.lengthBetween(searchExp,1,2))
ok=false;if(ok==true)
{_this.searchFooter.setVisible(false);_this.startLoadingAnimation();var room=R31UserRegistry.getCurrentRoom();var from;var friends=0;if(_this.content.html.searchRadioWixi.checked)
{from="0";_this._searchOwner=0;}
else if(_this.content.html.searchRadioWorld.checked)
{from="-1";_this._searchOwner="-1";}
else if(_this.content.html.searchRadioFriends.checked)
{from=room.id;_this._searchOwner=room.id;friends=1;}
else if(room)
{from=room.id;_this._searchOwner=room.id;}
else
{from="0";_this._searchOwner=0;}
_this.search(searchExp,getSelectedValue(_this.content.html.type),from,entry.index,friends);}};if(entry.label=='<<')
{newItem.html.pagerEntry.style.display='none';newItem.html.pagerEntry_prev.onclick=searchFunction;newItem.html.pagerEntry_prev.style.display='block';newItem.html.pagerEntry_imgPrev.onmouseover=function()
{newItem.html.pagerEntry_imgPrev.src="skins/"+JUI.getCurrentSkin()+"/R31FileSearch/btn_pag_before_over.png";}
newItem.html.pagerEntry_imgPrev.onmouseout=function()
{newItem.html.pagerEntry_imgPrev.src="skins/"+JUI.getCurrentSkin()+"/R31FileSearch/btn_pag_before.png";}}
else if(entry.label=='>>')
{newItem.html.pagerEntry.style.display='none';newItem.html.pagerEntry_next.onclick=searchFunction;newItem.html.pagerEntry_next.style.display='block';newItem.html.pagerEntry_imgNext.onmouseover=function()
{newItem.html.pagerEntry_imgNext.src="skins/"+JUI.getCurrentSkin()+"/R31FileSearch/btn_pag_after_over.png";}
newItem.html.pagerEntry_imgNext.onmouseout=function()
{newItem.html.pagerEntry_imgNext.src="skins/"+JUI.getCurrentSkin()+"/R31FileSearch/btn_pag_after.png";}}
else
{LD.Element.writeText(newItem.html.pagerEntry,entry.label);}
if(entry.selected)
{newItem.html.pagerEntry.className='pagerEntrySelected';}
else
{newItem.html.pagerEntry.onclick=searchFunction;newItem.html.pagerEntry.onmouseover=function(){newItem.html.pagerEntry.style.color='#BE2681';}
newItem.html.pagerEntry.onmouseout=function(){newItem.html.pagerEntry.style.color='#333333';}}
newItem.getRoot().style.position='';newItem.setVisible(true);newItem.getRoot().style.width='18px';newItem.getRoot().style.height='18px';return newItem;}
R31FileSearchWindow.prototype.isFriend=function(user)
{if(!user||!user.id)return false;var friends=R31UserRegistry.getUserFriends(R31UserRegistry.getLoggedUser());if(!friends)return false;for(var i=0;i<friends.length;i++){if(friends[i].id==user.id)return true;}
return false;}
R31FileSearchWindow.prototype.addEntryToWixi=function(entry)
{if(!(entry instanceof FileSystemNode))return false;R31DesktopShell.doAction(R31.ACTION_FS_NODE_ADD,entry);}
R31FileSearchWindow.prototype.startLoadingAnimation=function()
{this.preloaderVisible=true;if(!this.root)return;this.content.html.preloader2.style.display="block";}
R31FileSearchWindow.prototype.finishLoadingAnimation=function()
{this.preloaderVisible=false;if(!this.root)return;this.content.html.preloader2.style.display="none";}
R31FileSearchWindow.prototype.searchFinished=function(token,result,type)
{this.setResultsVisible(true);var newItem,colors=["transparent","#f7dfff"];if(result.count>0){this.eventSearchFinished(token,result,type);for(var i=0;i<result.count;i++){newItem=this.renderResultEntry(result.rows[i]);this.resultPane.add(newItem);}}
else
{LD.Element.writeText(this.resultPane.getRoot(),__("No results matching your criteria"));this.finishLoadingAnimation();}}

/*========== R31SocialWindows.js ==========*/

R31MessageTool.extend(R31Dialog);R31MessageTool.templates={base:"JUIWindow",contentBase:"R31Dialog",content:"R31MessageTool"};function R31MessageTool(title)
{R31MessageTool.superConstructor.call(this,title);this.invitePane=null;this.prototypes=new Object();}
R31MessageTool.prototype.init=function(content)
{R31MessageTool.superClass.init.call(this);var _this=this;var entry,newEntryHtml;if(!content){content=JUI.getTemplateInstance(R31MessageTool.templates.content);}
this.addContent(content);this.content.html.buttonOk.onclick=function(){_this.sendMessage();}}
R31MessageTool.prototype.getLogInfo=function()
{var room=R31UserRegistry.getCurrentRoom();return{tag:"message",value:(room)?room.id:0}}
R31MessageTool.prototype.refreshInfo=function()
{}
R31MessageTool.prototype.sendMessage=function()
{var room=R31UserRegistry.getCurrentRoom();var user=R31UserRegistry.getLoggedUser();if(!room||!user)return;var message=this.content.html.messageInput.value||"";if(message=="")return;var _this=this;var ajax=new R31Ajax();ajax.setMethod(Ajax.METHOD_POST);ajax.setArgument({cmd:"sendMessage",user:user.id});ajax.setBodyArgument("extra",Json.toString({friends:[room.id],message:message}));ajax.setSuccessCallback(function(socket)
{var result=socket.response;var msg;if(typeof(result)=="number"&&result>0)
msg="Message has been sent";else
msg="Could not send message";_this.close();var opt={"messageType":JUIDialogWindow.ALERT};JUI.getTopContainer().showPopupWindow(JUIDialogWindow.makeDialog(msg,"Wixi",opt));});ajax.send("room_provider.php");}
R31InvitationTool.extend(JUIContainer);R31InvitationTool.templates={base:"R31InvitationTool"};function R31InvitationTool(target,anonymousCount)
{R31InvitationTool.superConstructor.call(this);this.prototypes=new Object();this.target=target||null;this.invitePane=null;this.friendsEntries=new Array();this.anonymousCount=Math.max(0,intVal(varDefault(anonymousCount,3)));this.anonymousEntries=new Array();this._ajax=new R31Ajax();}
R31InvitationTool.prototype.init=function(htmlNode)
{R31InvitationTool.superClass.init.call(this,htmlNode);var _this=this;var entry,newEntryHtml;var friendsList=new R31SelectableFriendsList(null);this.friendsList=friendsList;friendsList.init();this.add(friendsList,null,this.html.friendsPaneHolder);var fpb=getBounds(this.html.friendsPane,this.root);friendsList.setBounds(fpb.x,fpb.y,480,100);friendsList.setVisible(true);friendsList.setListSource(R31UserRegistry.getUserFriends(R31UserRegistry.getLoggedUser()));if(Browser.isIE){JUI.makeSelectable(this.html.embedCodeHolder,true);JUI.makeSelectable(this.html.permalinkCodeHolder,true);}
var fep=(this.html.friendEntry)?this.html.friendEntry.parentNode:null;if(fep)
this.prototypes.friendEntry=fep.removeChild(this.html.friendEntry);this.html.anonymousPane.style.top="128px";var aep=(this.html.anonymousEntry)?this.html.anonymousEntry.parentNode:null;if(aep)
this.prototypes.anonymousEntry=aep.removeChild(this.html.anonymousEntry);this.anonymousEntries=new Array();for(var i=0;i<this.anonymousCount;i++){newEntryHtml=this.prototypes.anonymousEntry.cloneNode(true);entry={html:newEntryHtml,elements:JUI.getDhtmlRefs(newEntryHtml)};this.html.anonymousPane.appendChild(entry.html);this.anonymousEntries.push(entry);}
this.html.inviteButton.onclick=function(){if(!_this.inProgress)
_this.sendInvitations();}
this.refreshInfo();if(this.friends==null)this.loadFriendsList();}
R31InvitationTool.prototype.getLogInfo=function()
{var room=R31UserRegistry.getCurrentRoom();return{tag:"invitation",value:(room)?room.id:0}}
R31InvitationTool.prototype.repaint=function()
{R31InvitationTool.superClass.repaint.call(this);if(this.friendsList){this.friendsList.repaint();this.friendsList.renderList();}}
R31InvitationTool.prototype.getTarget=function()
{return this.target;}
R31InvitationTool.prototype.setTarget=function(target)
{this.target=target||null;this.refreshInfo();}
R31InvitationTool.prototype.loadFriendsList=function()
{this.friendsList.setListSource(R31UserRegistry.getUserFriends(R31UserRegistry.getLoggedUser()));if(!this.user||!this.target){return;}
var _this=this;var ajax=new R31Ajax();ajax.setArgument("cmd","getUserFriends");if(this.user)
ajax.setArgument("user",this.user.id);ajax.setSuccessCallback(function(socket)
{var result=socket.response;if(result)_this.setFriendsList(result);});ajax.send("room_provider.php");}
R31InvitationTool.prototype.refreshInfo=function()
{if(this.target instanceof FileSystemNode){this.html.titleRoom.style.display="none";this.html.titleFile.style.display="";this.html.fileName.innerHTML=this.target.getName();this.html.embedCodeHolder.style.display="";this.html.permalinkCodeHolder.style.display="";this.getPermalink();if(this.target.isPublic()){}
else{this.html.embedCode.style.display='none';this.html.permalinkCodeHolder.style.display='none';}
var user=R31UserRegistry.getLoggedUser();var room=R31UserRegistry.getCurrentRoom();if(room&&user&&user.id==room.id){this.html.embedCodeHolder.style.display="";var embedValue="1"+hex(user?user.id:0).padLeft(8,"0")+hex(this.target.id).padLeft(8,"0");var embedHTML=R31MediaPlayer.getEmbeddedPlayerHTML(embedValue);this.html.embedCode.value=embedHTML;}
if(!this.html.embedCode.value)
{this.html.permalinkCodeHolder.style.display="none";this.html.embedCode.style.display="none";}}
else{this.html.embedCodeHolder.style.display="none";this.html.permalinkCodeHolder.style.display="none";this.html.titleRoom.style.display="";this.html.titleFile.style.display="none";}
this.renderList();}
R31InvitationTool.prototype.renderList=function()
{if(!this.root||!this.friendsList)return;var friends=R31UserRegistry.getUserFriends(R31UserRegistry.getLoggedUser());if(friends&&friends.length>0)
this.html.friendsPaneHolder.style.display="";else
this.html.friendsPaneHolder.style.display="none";this.friendsList.renderList();}
R31InvitationTool.prototype.sendInvitations=function()
{var user=R31UserRegistry.getLoggedUser();if(!user||!user.id)return;var _this=this;var ok=true;var anonymous=new Array();var entry,address,error;for(var i=0;i<this.anonymousEntries.length;i++){entry=this.anonymousEntries[i];address=varDefault(entry.elements.anonymousEntryInput.value,"");error="";if(address!=""){if(!LD.Validation.isEmail(address)){ok=false;error="Invalid address";}
else
anonymous.push(address);}
entry.elements.anonymousEntryError.innerHTML=error;}
var friends=this.friendsList.getSelectedUsers();var message=this.html.messageInput.value||"";if(ok==true){if(friends.length>0||anonymous.length>0){var ajax=new R31Ajax();ajax.setMethod(Ajax.METHOD_POST);ajax.setArgument("cmd","invitePeople");ajax.setArgument("user",user.id);if(this.target instanceof FileSystemNode)
ajax.setArgument("id",this.target.getId());else
ajax.setArgument("room",user.room);ajax.setBodyArgument("extra",Json.toString({friends:friends,anonymous:anonymous,message:message}));ajax.setProgressCallback(function(socket)
{if(socket.getReadyState()==Ajax.STATE_COMPLETE)
_this.setInProgress(false);});ajax.setSuccessCallback(function(socket)
{var result=socket.response;var msg;if(typeof(result)=="number"&&result>0)
msg="Invitation has been sent";else
msg="Could not send invitation";var opt={"messageType":JUIDialogWindow.ALERT};JUI.getTopContainer().showPopupWindow(JUIDialogWindow.makeDialog(msg,"Wixi",opt));});this.setInProgress(true);ajax.send("room_provider.php");}
else{var msg=__("You must select a friend or type an email address to send the invitation to");var opt={"messageType":JUIDialogWindow.ALERT};JUI.getTopContainer().showPopupWindow(JUIDialogWindow.makeDialog(msg,"Wixi",opt));}}}
R31InvitationTool.prototype.setInProgress=function(inProgress)
{this.inProgress=(inProgress==true);if(!this.root)return;this.html.inviteButton.style.cursor=(this.inProgress?"wait":"");}
R31InvitationTool.prototype.getPermalink=function()
{var _this=this;this._ajax.setArgument({cmd:"getPermalink",id:this.target.id});this._ajax.setProgressCallback(function(socket)
{if(socket.getReadyState()==Ajax.STATE_COMPLETE)
_this.setInProgress(false);});this._ajax.setSuccessCallback(function(socket)
{var result=socket.response;_this.updatePermalink(result);});this.setInProgress(true);this._ajax.send("room_provider.php");}
R31InvitationTool.prototype.updatePermalink=function(result)
{this.html.permalinkCode.value=URL_PUBLIC_PAGES+varDefault(result,'');}
R31InvitationTool.prototype.clearAnonymousInputs=function()
{for(var i=0;i<this.anonymousEntries.length;i++){this.anonymousEntries[i].html.value="";}}
R31SelectableFriendsList.extend(R31UserList);R31SelectableFriendsList.templates=R31UserList.templates;function R31SelectableFriendsList(scrolling,iconConstructor)
{R31SelectableFriendsList.superConstructor.call(this,scrolling,iconConstructor||R31FriendEntry);this.starrable=false;}
R31SelectableFriendsList.prototype.iconChanged=function(evt,type,src)
{if(!evt||!evt.user||!src||!this.selectedUsers)return;var id=intVal(evt.user.id);if(evt.selected==true){if(!inArray(this.selectedUsers,id))
this.selectedUsers.push(id);}
else{this.selectedUsers=arrayRemove(this.selectedUsers,id);}}

/*========== R31FriendsActivity.js ==========*/

R31FriendsActivityWindow.extend(JUIWindow);R31FriendsActivityWindow.templates={base:"JUIWindow",content:"R31FriendsActivityWindow",item:"R31FriendsActivityWindow_item"};function R31FriendsActivityWindow(title)
{R31FriendsActivityWindow.superConstructor.call(this,title,true,false);this.resizable=false;this._ajax=new R31Ajax();this.activeResultPane=0;this.filter="";this.commands=["getFriendsActivity","getWixiActivity","getPopularFiles"];this.cachedResults={friendsReport:null,wixiReport:null};}
R31FriendsActivityWindow.prototype.init=function()
{R31FriendsActivityWindow.superClass.init.call(this);var _this=this;var content=new JUIHtmlNode(JUI.getTemplateInstance(this.constructor.templates.content));this.content=content;this.content.setLocation(0,0);var cp=this.getContentPane();cp.setScrolling(JUI.SCROLL_NONE);cp.add(this.content);this.toolBar.setVisible(false);var resultPane=new JUIContainer();this.resultPane=resultPane;resultPane.init(this.content.html.resultPane);with(resultPane.getRoot().style){overflowX="hidden";overflowY="auto";}
resultPane.setBounds(10,105,540,250);this.setSize(560,428);var room=R31UserRegistry.getCurrentRoom();content.html.friendsReport.resultPane=0;content.html.wixiReport.resultPane=1;content.html.popularFiles.resultPane=2;content.html.refreshButton.appendChild(Feeds.replace('friendsActivity1',URL_SOURCE_RSS+'?user='+
escape(room.name)+'&ext=friends',room.name+' friends').toAnchor());rss=Feeds.replace('friendsActivity1',URL_SOURCE_RSS+'?user='+escape(room.name)+'&ext=friends',room.name+' friends').toAnchor();content.html.rssButton.appendChild(rss);var reportTypeClicked=function(evt){evt=LD.Event.normalize(evt);_this.setActiveResultPane(evt.target.resultPane);}
LD.Element.addListener([content.html.friendsReport,content.html.wixiReport,content.html.popularFiles],"click",reportTypeClicked);content.html.filterAll.typeFilter="";content.html.filterImages.typeFilter="image";content.html.filterVideos.typeFilter="video";content.html.filterAudio.typeFilter="audio";content.html.filterOther.typeFilter="other";var typeFilterClicked=function(evt){evt=LD.Event.normalize(evt);_this.setActiveFilter(evt.target.typeFilter);}
LD.Element.addListener([content.html.filterAll,content.html.filterImages,content.html.filterVideos,content.html.filterAudio,content.html.filterOther],"click",typeFilterClicked);content.html.refreshButton.onclick=function(){_this.clearCachedResults();_this.fetch(true);}
var user=R31UserRegistry.getLoggedUser();var room=R31UserRegistry.getCurrentRoom();var isOwner=(user&&room&&user.id==room.id);if(isOwner==true)
{this.content.html.friensActivityShowOption.style.display="block";content.html.friensActivityShowCheckbox.onclick=function(){_this.changeShowOption(this.checked);}
user.getParameter(R31User.PARAMETERS.HIDE_FRIENDSACTIVITY,function(result)
{_this.content.html.friensActivityShowCheckbox.checked=result;});}
else
{this.content.html.friensActivityShowOption.style.display="none";}}
R31FriendsActivityWindow.prototype.getLogInfo=function()
{var room=R31UserRegistry.getCurrentRoom();return{tag:"activity",value:(room)?room.id:0}}
R31FriendsActivityWindow.prototype.getLastResults=function()
{var res;if(this.activeResultPane==0)
res=this.cachedResults.friendsReport;else if(this.activeResultPane==1)
res=this.cachedResults.wixiReport;else if(this.activeResultPane==2)
res=this.cachedResults.popularFiles;else
res=null;return res||null;}
R31FriendsActivityWindow.prototype.clearCachedResults=function(resultPane)
{this.cachedResults={friendsReport:null,wixiReport:null};}
R31FriendsActivityWindow.prototype.setActiveResultPane=function(resultPane)
{switch(resultPane){case 0:this.activeResultPane=0;this.content.html.friendsReport.className="reportType selected";this.content.html.wixiReport.className="reportType";this.content.html.popularFiles.className="reportType";try{Feeds.get("friendsActivity1").toAnchor().style.display="inline";Feeds.get("friendsActivity2").toAnchor().style.display="none";}catch(e){}
break;case 1:this.activeResultPane=1;this.content.html.friendsReport.className="reportType";this.content.html.wixiReport.className="reportType selected";this.content.html.popularFiles.className="reportType";if(!Feeds.get("friendsActivity2")){this.content.html.rssButton.appendChild(Feeds.replace("friendsActivity2",URL_SOURCE_RSS,"New Files").toAnchor());}
try{Feeds.get("friendsActivity2").toAnchor().style.display="inline";Feeds.get("friendsActivity1").toAnchor().style.display="none";}catch(e){}
break;case 2:this.activeResultPane=2;this.content.html.friendsReport.className="reportType";this.content.html.wixiReport.className="reportType";this.content.html.popularFiles.className="reportType selected";break;default:return;}
var results=this.getLastResults();if(results!=null)
this.showResults(results);else
this.fetch();}
R31FriendsActivityWindow.prototype.setActiveFilter=function(filter)
{this.filter=varDefault(filter,"");var h=this.content.html;var f=[h.filterAll,h.filterImages,h.filterVideos,h.filterAudio,h.filterOther];for(var i=0;i<f.length;i++){f[i].className=(f[i].typeFilter==this.filter)?"selected":"";}
this.showResults(this.getLastResults());}
R31FriendsActivityWindow.prototype.fetch=function(clearCache)
{var room=R31UserRegistry.getCurrentRoom();if(!room)return false;var _this=this;this.clearResults();var cmd=this.commands[this.activeResultPane];if(cmd==null)return false;if(clearCache)clearCache=1;else clearCache=0;this._ajax.clearArguments();this._ajax.setArgument({"cmd":cmd,"room":room.name,"clearCache":clearCache});this._ajax.setProgressCallback(function(socket){if(socket.getReadyState()==Ajax.STATE_COMPLETE)
_this.finishLoadingAnimation();});this._ajax.setSuccessCallback(function(socket){var result=socket.response;if(_this.activeResultPane==0)
_this.cachedResults.friendsReport=result;else if(_this.activeResultPane==1)
_this.cachedResults.wixiReport=result;else if(_this.activeResultPane==2)
_this.cachedResults.popularFiles=result;_this.showResults(result);});this.startLoadingAnimation();this._ajax.send("room_provider.php");}
R31FriendsActivityWindow.prototype.showResults=function(entries)
{this.clearResults();if(!(entries instanceof Array))return;var colors=["transparent","#dddddd"];var newItem,addIt;var td,type,types=["image","video","audio"],entryCat;var filterIndex=arraySearch(types,this.filter);var count={all:entries.length,image:0,video:0,audio:0,other:0};for(var i=0;i<entries.length;i++){td=FileSystem.getTypeDescriptor(FileSystem.getExtension(entries[i].name));type=(td!=null)?td.getMimeType():"";if(type!="")
count[type]++;else
count.other++;entryCat=(inArray(types,type))?type:"other";if(this.filter=="")
addIt=true;else
addIt=(entryCat==this.filter);if(addIt==true){newItem=this.renderResultEntry(entries[i]);this.resultPane.add(newItem);}}
count.other=count.all-count.image-count.video-count.audio;LD.Element.writeText(this.content.html.allCount,count.all,true);LD.Element.writeText(this.content.html.imageCount,count.image,true);LD.Element.writeText(this.content.html.videoCount,count.video,true);LD.Element.writeText(this.content.html.audioCount,count.audio,true);LD.Element.writeText(this.content.html.otherCount,count.other,true);}
R31FriendsActivityWindow.prototype.clearResults=function(entry)
{this.resultPane.removeAll();}
R31FriendsActivityWindow.prototype.renderResultEntry=function(entry)
{if(!entry)return false;var fsNode=FileSystemNode.build(entry);if(!fsNode instanceof FileSystemNode)return false;fsNode.added=entry.added||null;var owner=entry.user?R31User.build(entry.user):this.getFriend(fsNode.owner);var _this=this;var user=R31UserRegistry.getLoggedUser();var room=R31UserRegistry.getCurrentRoom();var td=FileSystem.getTypeDescriptor(FileSystem.getExtension(fsNode.name));var newItem=new JUIHtmlNode(JUI.getTemplateInstance(R31FriendsActivityWindow.templates.item));var mimeType;if(td!=null||fsNode.getType()==FileSystem.NODE_TYPE_LINK)
{if(fsNode.getType()==FileSystem.NODE_TYPE_LINK)
{mimeType=fsNode.mimeType;}
else
{mimeType=td.getMimeType();}
if(fsNode.isAvailable&&fsNode.hasThumbnail()&&(mimeType=="image"||mimeType=="video"||mimeType==FileSystem.MIME_TYPE_IMAGE||mimeType==FileSystem.MIME_TYPE_VIDEO))
{newItem.html.thumbnail.src=fsNode.thumbnailURL;newItem.html.thumbnail.style.width='88px';newItem.html.thumbnail.style.height='73px';newItem.html.thumbnail.style.marginTop='0px';}
else
{if(td!=null)
{newItem.html.thumbnail.src=getImageURL("/skins/"+JUI.currentSkin+"/"+td.getDefaultIcon()+"_a.png");}
else
{mimeType="";newItem.html.thumbnail.src=DIR_IMAGES+"spacer.gif";}}}
else
{mimeType="";newItem.html.thumbnail.src=DIR_IMAGES+"spacer.gif";}
LD.Element.writeText(newItem.html.name,(fsNode.name).trim());var size=intVal(fsNode.size),sizeKb=Math.round(size/1024);if(fsNode.getType()==FileSystem.NODE_TYPE_LINK)
LD.Element.writeText(newItem.html.size," ");else
LD.Element.writeText(newItem.html.size,sizeKb+" k");if(size>STREAMING_THRESHOLD)
{newItem.html.warningMsg.style.display='block';LD.Element.writeText(newItem.html.warningMsg,'To add or play this file, you should become friend with the owner first!');}
if(fsNode.owner&&owner)
{newItem.html.linkWixi.href=("./?room="+owner.name);newItem.html.linkWixi.target="_parent";newItem.html.owner.innerHTML=owner.name||"";newItem.html.avatar.src=(owner.avatar!="")?(getAvatarURL(owner.avatar)):R31.DEFAULT_AVATAR;newItem.html.avatar.style.cursor="pointer";newItem.html.avatar.onclick=function(){_this.openUser(owner);};}
newItem.html.added.innerHTML=this.getAddedLapse(fsNode.added);if(user&&user.id!=fsNode.owner){newItem.html.name.fsNode=fsNode;newItem.html.name.onclick=function(){_this.addEntryToWixi(this.fsNode);}
newItem.html.name.style.cursor="pointer";}
newItem.getRoot().style.position="relative";newItem.setBounds(0,0,530,86);newItem.setVisible(true);return newItem;}
R31FriendsActivityWindow.prototype.addEntryToWixi=function(entry)
{if(!(entry instanceof FileSystemNode))return false;R31DesktopShell.doAction(R31.ACTION_FS_NODE_ADD,entry);}
R31FriendsActivityWindow.prototype.getFriend=function(friendId)
{if(!friendId)return false;var friends=R31UserRegistry.getUserFriends(R31UserRegistry.getCurrentRoom());if(!friends)return null;var k=arraySearch(friends,friendId,"id");if(k!==null)
return friends[k];else
return null;}
R31FriendsActivityWindow.prototype.getAddedLapse=function(added)
{if(!added)return null;var aux=added.toString().split(":");var h=intVal(aux[0]),m=intVal(aux[1]),s=intVal(aux[2]);if(h>0)
return h+__(" hours ")+m+__(" mins ago");else
return m+__(" mins ")+s+__(" secs ago");}
R31FriendsActivityWindow.prototype.startLoadingAnimation=function()
{this.preloaderVisible=true;this.html.preloader.style.display="block";}
R31FriendsActivityWindow.prototype.finishLoadingAnimation=function()
{this.preloaderVisible=false;this.html.preloader.style.display="none";}
R31FriendsActivityWindow.prototype.openUser=function(target,params)
{if(!(target instanceof R31User))return;R31DesktopShell.doAction(R31.ACTION_OPEN,target);}
R31FriendsActivityWindow.prototype.changeShowOption=function(option)
{var user=R31UserRegistry.getLoggedUser();user.setParameter(R31User.PARAMETERS.HIDE_FRIENDSACTIVITY,option,function(result)
{var msg;if(result!=null&&result==true)
{msg=_('Your choice has been saved!');}
else
{msg=_('There was an error saving your choice, please try again later.');}
var opt={"messageType":JUIDialogWindow.ALERT};JUI.getTopContainer().showPopupWindow(JUIDialogWindow.makeDialog(msg,"Wixi",opt));});}

/*========== R31GoldenBook.js ==========*/

R31GoldenBook.extend(JUIWindow);R31GoldenBook.templates={base:"JUIWindow",content:"R31GoldenBook",item:"R31GoldenBook_item",pageNumber:"R31GoldenBook_pageNumber"};R31GoldenBook.EVT_POSTS_CHANGED=5101;R31GoldenBook.EVT_POSTS_ADDED=5102;R31GoldenBook.EVT_POSTS_DELETED=5103;function R31GoldenBook(title)
{R31GoldenBook.superConstructor.call(this,title,true);this.resizable=false;this._ajax=new R31Ajax();this.page=1;this.pageCount=1;this.postsPerPage=10;this.pageLimit=3;}
R31GoldenBook.prototype.init=function(htmlNode)
{R31GoldenBook.superClass.init.call(this,htmlNode);var _this=this;var content=new JUIHtmlNode(JUI.getTemplateInstance(this.constructor.templates.content));this.content=content;this.content.setLocation(0,0);var cp=this.getContentPane();cp.setScrolling(JUI.SCROLL_NONE);cp.add(this.content);this.toolBar.setVisible(false);var resultPane=new JUIContainer();this.resultPane=resultPane;resultPane.init(content.html.resultPane);with(resultPane.getRoot().style){overflowX="hidden";overflowY="auto";}
this.resultPane.setBounds(10,186,400,230);LD.Element.addListener(content.html.buttonPost,"click",function(){_this.postMessage();});LD.Element.addListener(this.content.html.pagePrevious,"click",function(){if(_this.page>1)
_this.fetch(_this.page-1);});LD.Element.addListener(this.content.html.pageNext,"click",function(){if(_this.page<_this.pageCount)
_this.fetch(_this.page+1);});this.refreshPager();}
R31GoldenBook.prototype.getLogInfo=function()
{var room=R31UserRegistry.getCurrentRoom();return{tag:"golden_book",value:(room)?room.id:0};}
R31GoldenBook.prototype.isFriend=function(userId)
{userId=intVal(userId);if(!userId)return false;var friends=R31UserRegistry.getUserFriends(R31UserRegistry.getLoggedUser());if(!friends)return false;for(var i=0;i<friends.length;i++){if(friends[i].id==userId)
return true;}
return false;}
R31GoldenBook.prototype.postMessage=function()
{var room=R31UserRegistry.getCurrentRoom();if(!room)return false;var user=R31UserRegistry.getLoggedUser();if(!user)return false;var msg=this.content.html.message.value||"";if(msg=="")return false;var _this=this;this._ajax.clearArguments();this._ajax.setMethod(Ajax.METHOD_POST);this._ajax.setArgument("cmd","addPost");this._ajax.setArgument("roomId",room.id);this._ajax.setArgument("user",user.id);this._ajax.setBodyArgument("extra",Json.toString({message:msg}));this._ajax.setSuccessCallback(function(socket){var result=socket.response;if(typeof(result)=="number"&&result>0)
_this.fetch(1);else{}});this._ajax.send("room_provider.php");this.content.html.message.value="";}
R31GoldenBook.prototype.fetch=function(page)
{var room=R31UserRegistry.getCurrentRoom();if(!room)return false;page=intVal(page);if(page>0&&page<=this.pageCount)
this.page=page;var _this=this;this.clearResults();this._ajax.clearArguments();this._ajax.setMethod(Ajax.METHOD_GET);this._ajax.setArgument("cmd","getPosts");this._ajax.setArgument("roomId",room.id);this._ajax.setArgument("page",this.page);this._ajax.setArgument("fields","id,poster,message,time,posterName,posterCountry,posterAvatar");this._ajax.setSuccessCallback(function(socket){var result=socket.response;_this.fireEvent({result:result},R31GoldenBook.EVT_POSTS_CHANGED);_this.showResults(result);_this.refreshPager();});this._ajax.send("room_provider.php");}
R31GoldenBook.prototype.removeMessage=function(postId)
{postId=intVal(postId);if(postId<1)return false;var room=R31UserRegistry.getCurrentRoom();var user=R31UserRegistry.getLoggedUser();if(!room||!user||user.id!=room.id)return false;var _this=this;this._ajax.clearArguments();this._ajax.setMethod(Ajax.METHOD_GET);this._ajax.setArgument({cmd:"removePost",id:postId});this._ajax.setSuccessCallback(function(socket){var result=socket.response;if(result===true)
_this.fetch();else{}});this._ajax.send("room_provider.php");}
R31GoldenBook.prototype.showResults=function(result)
{this.clearResults();if(!result||!result.posts)return;var room=R31UserRegistry.getCurrentRoom();this.pageCount=Math.max(1,Math.ceil(result.count/this.postsPerPage));this.content.html.postCount.innerHTML=result.count;this.content.html.totalPostCount.innerHTML=result.count;room.goldenBook.postCount=result.count;;desktopManager.topBar.getSideBar().refreshGoldenBookPostCount();var colors=["transparent","#dddddd"];var holder=document.createElement("DIV");this.resultHolder=holder;with(holder.style){display="";position="static";width=(this.width-40)+"px";}
var newItem;for(var i=0;i<result.posts.length;i++){newItem=this.renderResultEntry(result.posts[i]);holder.appendChild(newItem);}
this.resultPane.add(new JUIHtmlNode(holder));}
R31GoldenBook.prototype.clearResults=function(entry)
{LD.Element.removeChildren(this.resultHolder);}
R31GoldenBook.prototype.renderResultEntry=function(entry)
{if(!entry)return false;var _this=this;var user=R31UserRegistry.getLoggedUser();var room=R31UserRegistry.getCurrentRoom();if(!user||!room)return null;var poster=R31User.build({id:entry.poster,name:entry.posterName});var isOwner=(user.id==room.id);var posterIsUser=(poster.id==user.id);var isPostersRoom=(poster.id==room.id);var posterIsFriend=this.isFriend(poster.id);var newItem=JUI.getTemplateInstance(R31GoldenBook.templates.item);with(newItem.style){display="";position="static";top="";left="";}
var refs=JUI.getDhtmlRefs(newItem);if(refs){var dt=stringToDate(entry.time);var dtStr;if(dt!=null)
dtStr=R31.Date.format("M d, Y H:i",dt);else
dtStr="(unknown date)";refs.text.innerHTML=nl2br((""+entry.message).htmlSpecialChars());LD.Element.writeText(refs.posterName,entry.posterName,true);if(entry.avatar!="")
refs.posterAvatar.src=getAvatarURL(entry.posterAvatar);LD.Element.writeText(refs.posterCountry,R31.Countries[entry.posterCountry]||"(unknown country)",true);LD.Element.writeText(refs.date,dtStr,true);refs.remove.setAttribute("postid",entry.id);refs.reply.setAttribute("postid",entry.id);refs.becomeFriend.setAttribute("userid",entry.poster);refs.visitWixi.setAttribute("userid",entry.poster);if(isOwner){LD.Element.addListener(refs.remove,"click",function(evt){evt=LD.Event.normalize(evt);var id=evt.target.getAttribute("postid");_this.removeMessage(id);});}
else{refs.remove.className="actionButton actionButton_disabled";}
if(posterIsUser||posterIsFriend){refs.becomeFriend.className="actionButton actionButton_disabled";}
else{LD.Element.addListener(refs.becomeFriend,"click",function(evt){R31DesktopShell.doAction(R31.ACTION_REQUEST_FRIENDSHIP,poster);});}
if(isPostersRoom){refs.visitWixi.className="actionButton actionButton_disabled";}
else{LD.Element.addListener(refs.visitWixi,"click",function(evt){R31DesktopShell.doAction(R31.ACTION_OPEN,poster);});}}
return newItem;}
R31GoldenBook.prototype.refreshPager=function()
{var pagesToShow=Math.max(1,Math.min(this.pageLimit,this.pageCount));var firstPage=Math.max(1,this.page-(Math.floor(pagesToShow/2)));var lastPage=firstPage+pagesToShow-1;if(lastPage>this.pageCount){firstPage-=(lastPage-this.pageCount);lastPage-=(lastPage-this.pageCount);}
this.content.html.pagePrevious.style.visibility=(this.page>1)?"":"hidden";this.content.html.pageNext.style.visibility=(this.page<this.pageCount)?"":"hidden";LD.Element.removeChildren(this.content.html.pageNumbers);var _this=this;var newItem;for(var i=firstPage;i<=lastPage;i++){newItem=JUI.getTemplateInstance(R31GoldenBook.templates.pageNumber);newItem.setAttribute("pageIndex",i);if(i==this.page)
newItem.className="pageNumber pageNumber_selected";else
LD.Element.addListener(newItem,"click",function(evt){evt=LD.Event.normalize(evt);var i=evt.target.getAttribute("pageIndex");_this.fetch(i);});LD.Element.writeText(newItem,i,true);this.content.html.pageNumbers.appendChild(newItem);}}

/*========== R31AddToWixi.js ==========*/

R31AddToWixi.extend(JUIContainer);R31AddToWixi.VIEW_ADD=0;R31AddToWixi.VIEW_ADD_QUOTA_EXCEEDED=1;R31AddToWixi.VIEW_UPLOAD_QUOTA_EXCEEDED=2;R31AddToWixi.VIEW_ADD_NO_CLEARANCE=3;R31AddToWixi.VIEW_DELETE_NO_CLEARANCE=4;R31AddToWixi.templates={base:"R31AddToWixi"};function R31AddToWixi(sourceNode,user)
{R31AddToWixi.superConstructor.call(this);this.sourceNode=sourceNode||null;this.user=user||null;this.callback=null;this.ajax=new R31Ajax();this.view=R31AddToWixi.VIEW_ADD;this.inProgress=false;}
R31AddToWixi.prototype.init=function(htmlNode)
{R31AddToWixi.superClass.init.call(this,htmlNode);if(this.sourceNode&&this.user){var name=this.sourceNode.getName().truncate(50,"...");var size=R31.getStorageMeasure(this.sourceNode.getSize(),1);var used=intVal(this.user.stats?this.user.stats.storageUsed:0);var free=R31.getStorageMeasure(R31.getStorageLimit(this.user)-used,1);for(var i=0;i<this.html.nodeName.length;i++){LD.Element.writeText(this.html.nodeName[i],name);}
for(var i=0;i<this.html.nodeSize.length;i++){LD.Element.writeText(this.html.nodeSize[i],size[0]+" "+size[1]);}
for(var i=0;i<this.html.freeSpace.length;i++){LD.Element.writeText(this.html.freeSpace[i],_("UNLIMITED"));}
if(this.sourceNode instanceof FileSystemDirectory){LD.Element.writeText(this.html.nodeType,_('Directory'),true);this.html.sizeLegend.style.display="none";if(this.user.isPremium())
this.setView(R31AddToWixi.VIEW_ADD);else
this.setView(R31AddToWixi.VIEW_ADD_NO_CLEARANCE);}
else
this.setView(R31AddToWixi.VIEW_ADD);}
LD.Element.addListener(this.html.buttonAdd,"click",function(evt)
{evt=LD.Event.normalize(evt);var c=JUIComponent.getInstance(evt.target.dhtmlOwner);if(c!=null){c.addNodeToWixi();}});LD.Element.addListener(this.html.buttonUpgrade,"click",function(evt)
{evt=LD.Event.normalize(evt);var c=JUIComponent.getInstance(evt.target.dhtmlOwner);if(c!=null){c.goUpgradePremium();}});LD.Element.addListener(this.html.buttonCancel,"click",function(evt)
{evt=LD.Event.normalize(evt);var c=JUIComponent.getInstance(evt.target.dhtmlOwner);if(c!=null){var e={action:R31.ACTION_FS_NODE_ADD,target:c.target};c.fireEvent(e,R31.EVT_ACTION_CANCELLED);}});}
R31AddToWixi.prototype.addNodeToWixi=function()
{if(!this.user||!this.sourceNode||this.inProgress)return false;var params={component:this,quiet:true};var _this=this;this.showAddMessage(this.sourceNode);return;R31DesktopShell.doAction(R31.ACTION_FS_NODE_DUPLICATE,this.sourceNode,params,function(sourceNode,params,result){if(!sourceNode||!params||!params.component)return;params.component.actionPerformed(sourceNode,params,result);});this.setInProgress(true);}
R31AddToWixi.prototype.showAddMessage=function(node){var sourceNode=node;if(node instanceof FileSystemNode){var msg="";if(sourceNode.getType()==FileSystem.NODE_TYPE_DIR)
msg=_('Folder %1 and all its contents have been added to your Wixi');else
msg=_('File %1 has been added to your Wixi');msg=msg.parse(sourceNode.getName());var opt={"messageType":JUIDialogWindow.INFO};JUI.getTopContainer().showPopupWindow(JUIDialogWindow.makeDialog(msg,"Wixi"));action=true;}}
R31AddToWixi.prototype.actionPerformed=function(sourceNode,params,result)
{this.setInProgress(false);if(!sourceNode||result==null)return;if(!params)params={};var node=result.newNode;if(!node instanceof FileSystemNode){if(result.result==LD.ERR_FS_QUOTA_EXCEEDED)
this.setView(R31AddToWixi.VIEW_ADD_QUOTA_EXCEEDED);else if(result.result==LD.ERR_FS_NO_CLEARANCE)
this.setView(R31AddToWixi.VIEW_ADD_NO_CLEARANCE);else{if(result.result instanceof LD.Exception)
{result.result.handle();}
else
{FileSystem.raiseError(result.result,_('Cannot add %1').parse(sourceNode.getName()),evt);}
cancelled=true;}}
if(this.callback)
this.callback(sourceNode,params,result);}
R31AddToWixi.prototype.setCallback=function(callback)
{this.callback=callback||null;}
R31AddToWixi.prototype.setInProgress=function(inProgress)
{this.inProgress=(inProgress==true);}
R31AddToWixi.prototype.setView=function(view)
{if(!this.root)return;view=intVal(view);this.view=view;for(var i=0;i<this.html.dialogHeader.length;i++){this.html.dialogHeader[i].style.display=(i==view)?"":"none";}
this.html.buttonAdd.style.display=(view==R31AddToWixi.VIEW_ADD)?"":"none";this.html.buttonUpgrade.style.display=(view==R31AddToWixi.VIEW_ADD)?"none":"";}
R31AddToWixi.prototype.goUpgradePremium=function()
{openWindow("http://www.wixi.com/premium.php");}
R31AddToWixi.prototype.refreshTargetDirectory=function(evt)
{if(!this.user)return;var userRoot=FileSystem.getUserRoot(this.user.name);if(userRoot)userRoot.fetchChildren();}

/*========== Feeds.js ==========*/

function Feeds(){Feeds.feeds={}}
Feeds.exists=function(url){if(!Feeds.feeds){Feeds.feeds={}}
for(var name in Feeds.feeds){if(Feeds.feeds[name].url==url){return Feeds.feeds[name];}}
return false;}
Feeds.feedLinked=function(url){var links=top.document.getElementsByTagName('head')[0].getElementsByTagName('link');var from=url.length*-1
for(var i=0;i<links.length;i++){if(links[i].href.substr(from)==url){return links[i];}}
return false;}
Feeds.get=function(name){var ret=Feeds.feeds[name]
return ret;}
Feeds.add=function(name,url,title){var ret;if(!Feeds.feeds){Feeds.feeds={}};if(Feeds.feeds[name]){throw"FeedAlreadyExists";}
Feeds.feeds[name]=new Feed(url,title);Feeds.feeds[name].addToHead();return Feeds.feeds[name];}
Feeds.replace=function(name,url,title){var ret;if(!Feeds.feeds){Feeds.feeds={}}
if(!Feeds.feeds[name]){Feeds.add(name,url,title);}else{Feeds.feeds[name].url=url
Feeds.feeds[name].title=title
Feeds.feeds[name].addToHead();}
return Feeds.feeds[name];}
Feeds.del=function(name){if(!Feeds.feeds){Feeds.feeds={}}
top.document.getElementsByTagName('head')[0].removeChild(Feeds.feeds[name].toLink())}
function Feed(url,title){this.url=url
this.title=title
this.domLink=null;this.domAnchor=null;}
Feed.prototype.toAnchor=function(){if(!this.domAnchor){this.domAnchor=document.createElement('a');this.domAnchor.target="_blank";var img=document.createElement("img");img.src='/img/icon_feed.png';this.domAnchor.appendChild(img)}
this.domAnchor.href=this.url;this.domAnchor.title=this.title;return this.domAnchor;}
Feed.prototype.toLink=function(){if(!this.domLink){this.domLink=document.createElement('link');}
this.domLink.href=this.url;this.domLink.title=this.title;this.domLink.type='application/rss+xml';this.domLink.rel='alternate';return this.domLink;}
Feed.prototype.addToHead=function(){if(Browser.isFirefox){if(!Feeds.feedLinked(this.url)){try{top.document.getElementsByTagName('head')[0].removeChild(this.domLink);}catch(e){}
top.document.getElementsByTagName('head')[0].appendChild(this.toLink());}}}

/*========== Censor.js ==========*/

function Censor(){}
Censor.vote=function(target){var socket=new AjaxSocket();socket.setArgument('cmd','vote');if(target instanceof FileSystemNode){target=target.hash;}
socket.setBodyArgument("id",target);socket.setSuccessCallback(function(socket){var v=Json.evaluate(socket.response);if(v===true||v===false){msg="Thanks for your report";}else if(new Number(v)>=1){msg="Content has been marked as inappropriate";}else if(v==null){msg="There was a problem with your report. Please try later";}
var opt={"messageType":JUIDialogWindow.INFO};window.oDesk.showPopupWindow(JUIDialogWindow.makeDialog(msg,"Flagged content as inappropriate",opt,null,400,170));});socket.send("/vote_inappropriate.php",false,"POST",false);}

/*========== LinkParser.js ==========*/

LinkParser={getMediaLink:function(target)
{var model=target.target.substr(0,target.target.indexOf(':'));var link=eval(model+"Parser.getMediaLink(target)");return link;}}
YouTubeParser={getMediaLink:function(obj)
{var id=obj.target.substr(obj.target.indexOf(':')+1);return'http://www.youtube.com/v/'+id;}}
DailyMotionParser={getMediaLink:function(obj)
{var id=obj.target.substr(obj.target.indexOf(':')+1);return"http://www.dailymotion.com/swf/"+id;}}
FlickrParser={getMediaLink:function(obj)
{var cont=obj.target.split(":");if(5 in cont)
return"http://farm"+cont[3]+".static.flickr.com/"+cont[2]+"/"+cont[1]+"_"+cont[4]+"_o.jpg";else
return"http://farm"+cont[3]+".static.flickr.com/"+cont[2]+"/"+cont[1]+"_"+cont[4]+".jpg";}}
HuluParser={getMediaLink:function(obj)
{var id=obj.target.substr(obj.target.indexOf(':')+1);return"http://www.hulu.com/embed/"+id;}}
CnnParser={getMediaLink:function(obj)
{var id=obj.target.substr(obj.target.indexOf(':')+1);return"http://www.cnn.com/video/savp/evp/?loc=dom&vid="+id;}}
MtvMusicParser={getMediaLink:function(obj)
{var cont=obj.target.split(":");var id=cont[2];return"http://media.mtvnservices.com/mgid:uma:video:api.mtvnservices.com:"+id;}}

/*========== ExternalActivity.js ==========*/

ExternalActivity={flagName:'ExternalActivityFlag',valueCache:0,set:function(value)
{LD.Cookie.set(this.flagName,value);},setCache:function(value)
{this.valueCache=value;},get:function()
{return LD.Cookie.get(this.flagName);},getCache:function()
{return this.valueCache;},show:function()
{alert(this.get());},showCache:function()
{alert(this.getCache());},checkChange:function()
{if(this.get()==null)
return false;if(this.get()==this.getCache())
return false;if(this.get()!=this.getCache())
{this.setCache(this.get());return true;}
return false;},refresh:function()
{if(this.checkChange())
{desktopManager.fsRoomRoot.fetchChildren();this.set(0);this.setCache(0);}},init:function()
{var _this=this;setInterval(function(){_this.refresh();},1*1000);}}

/*========== R31ExternalChannels.js ==========*/

R31ExternalChannels.extend(JUIWindow);var youtube=new Object();var dailymotion=new Object();var flickr=new Object();var hulu=new Object();var cnn=new Object();var mtvmusic=new Object();youtube.feeds={base:"most_viewed",most_viewed:"most_viewed",top_rated:"top_rated",recently_featured:"recently_featured",watch_on_mobile:"watch_on_mobile",most_discussed:"most_discussed",top_favorites:"top_favorites",most_linked:"most_linked",most_responded:"most_responded",most_recent:"most_recent"};youtube.times={base:"this_month",today:"today",this_week:"this_week",this_month:"this_month",all_time:"all_time"};dailymotion.feeds={base:"news",news:"news",fun:"fun",shortfilms:"shortfilms",music:"music",auto:"auto",creation:"creation",videogames:"videogames",webcam:"webcam",travel:"travel",sport:"sport",animals:"animals",people:"people",tech:"tech",school:"school",lifestyle:"lifestyle",sexy:"sexy"};dailymotion.times={base:"most_recent",most_recent:"most_recent",commented:"commented",visited:"visited",rated:"rated"};flickr.feeds={base:"noneex"};flickr.times={base:"noneex"};hulu.feeds={base:"Comedy/Sitcoms",action_and_adventure_espionage:'Action-and-Adventure/Espionage',action_and_adventure_military_and_war:'Action-and-Adventure/Military-and-War',action_and_adventure_westerns:'Action-and-Adventure/Westerns',action_and_adventure_martial_arts:'Action-and-Adventure/Martial-Arts',animation_and_cartoons_anime:'Animation-and-Cartoons/Anime',comedy_sitcoms:'Comedy/Sitcoms',comedy_satire:'Comedy/Satire',comedy_sketch:'Comedy/Sketch',comedy_stand_up:'Comedy/Stand-Up',drama_crime_and_courtroom:'Drama/Crime-and-Courtroom',drama_medical:'Drama/Medical',drama_soap_operas:'Drama/Soap-Operas',food_and_leisure_food_and_beverage:'Food-and-Leisure/Food-and-Beverage',food_and_leisure_fashion_and_beauty:'Food-and-Leisure/Fashion-and-Beauty',food_and_leisure_travel:'Food-and-Leisure/Travel',food_and_leisure_recipes:'Food-and-Leisure/Recipes',food_and_leisure_entertaining:'Food-and-Leisure/Entertaining',home_and_garden_real_estate:'Home-and-Garden/Real-Estate',home_and_garden_decorating:'Home-and-Garden/Decorating',home_and_garden_do_it_yourself:'Home-and-Garden/Do-it-Yourself',home_and_garden_home_improvement:'Home-and-Garden/Home-Improvement',horror_and_suspense_mystery:'Horror-and-Suspense/Mystery',horror_and_suspense_paranormal:'Horror-and-Suspense/Paranormal',news_and_information_documentary_and_biography:'News-and-Information/Documentary-and-Biography',news_and_information_science_and_technology:'News-and-Information/Science-and-Technology',news_and_information_current_news:'News-and-Information/Current-News',news_and_information_live_events_and_specials:'News-and-Information/Live-Events-and-Specials',news_and_information_celebrity_and_gossip:'News-and-Information/Celebrity-and-Gossip',news_and_information_politics:'News-and-Information/Politics',sports_extreme_sports:'Sports/Extreme-Sports',sports_fighting_and_martial_arts:'Sports/Fighting-and-Martial-Arts',sports_gaming:'Sports/Gaming',sports_college_football:'Sports/College-Football',sports_wwe:'Sports/WWE',sports_nba:'Sports/NBA',sports_nhl:'Sports/NHL',talk_and_interview_celebrity_and_gossip:'Talk-and-Interview/Celebrity-and-Gossip',videogames_reviews:'Videogames/Reviews',videogames_previews:'Videogames/Previews',web_web_originals:'Web/Web-Originals'};hulu.times={base:'release',rating:'rating',release:'release'};cnn.feeds={base:'by_section_international',by_section_us:'by_section_us',by_section_crime:'by_section_crime',by_section_international:'by_section_international',by_section_espanol:'by_section_espanol',by_section_politics:'by_section_politics',by_section_showbiz:'by_section_showbiz',by_section_funny_news:'by_section_funny_news',by_section_tech:'by_section_tech',by_section_living:'by_section_living',by_section_student:'by_section_student',by_section_health:'by_section_health',by_section_business:'by_section_business',by_section_sports:'by_section_sports',by_section_weather:'by_section_weather'};cnn.times={base:"noneex"};mtvmusic.feeds={base:"electronic_dance",alternative:'alternative',blues_folk:'blues_folk',country:'country',electronic_dance:'electronic_dance',hip_hop:'hip_hop',jazz:'jazz',latin:'latin',metal:'metal',pop:'pop',randb:'randb',rock:'rock',world_reggae:'world_reggae'};mtvmusic.times={base:"noneex"};function R31ExternalChannels(template,title)
{R31ExternalChannels.templates={base:"JUIWindow",content:template,item:template+"_item",pagerItem:"pagerItem"};R31ExternalChannels.feeds=eval(template+".feeds");R31ExternalChannels.times=eval(template+".times");R31ExternalChannels.superConstructor.call(this,title,true,true);this.titleBarVisible=true;this.statusBarVisible=false;this.collapsable=false;this.resizable=false;this.template=template;this._ajax=new R31Ajax();this._channel=this.template;this._cmd="searchFiles";this._url="search.php";this._owner='-1';this._type=0;if(template!="lastfm"){this._root=R31ExternalChannels.feeds.base;this._time=R31ExternalChannels.times.base;}}
R31ExternalChannels.prototype.init=function(htmlNode)
{var _this=this;R31ExternalChannels.superClass.init.call(this,htmlNode);this.content=new JUIHtmlNode(JUI.getTemplateInstance(R31ExternalChannels.templates.content));this.content.setLocation(0,0);this.getContentPane().add(this.content);var resultPane=new JUIContainer();this.resultPane=resultPane;resultPane.init(this.content.html.resultPane);this.resultPane.setVisible(true);if(this.template=="youtube")
this.resultPane.setBounds(0,80,605,325);if(this.template=="dailymotion")
this.resultPane.setBounds(0,80,605,350);if(this.template=="flickr")
this.resultPane.setBounds(0,80,805,330);if(this.template=="hulu")
this.resultPane.setBounds(0,80,605,350);if(this.template=="cnn")
this.resultPane.setBounds(0,80,605,330);if(this.template=="mtvmusic")
this.resultPane.setBounds(0,80,605,325);this.contentPane.add(this.resultPane);this.content.html.buttonSearch.onclick=function()
{_this._root='';_this._time='';var searchExp=varDefault(_this.content.html.searchExp.value,"").toString();if(searchExp=="")
return false;_this.search(searchExp,_this._root,_this._time);}
this.content.html.searchExp.onkeypress=function(evt)
{_this._root='';_this._time='';evt=LD.Event.normalize(evt);var keyCode=evt.keyCode;if(keyCode==13)
{LD.Event.cancel(evt);var searchExp=varDefault(_this.content.html.searchExp.value,"").toString();if(searchExp=="")
return false;_this.search(searchExp,_this._root,_this._time);}}
var searchFooter=new JUIContainer();this.searchFooter=searchFooter;searchFooter.init(this.content.html.paging);if(this.template=="youtube"){this.content.html.feedType_most_viewed.onclick=function()
{_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.most_viewed;if(!_this._time)
_this._time=R31ExternalChannels.times.today;_this.search('',_this._root,_this._time);}
this.content.html.feedType_top_rated.onclick=function()
{_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.top_rated;if(!_this._time)
_this._time=R31ExternalChannels.times.today;_this.search('',_this._root,_this._time);}
this.content.html.feedType_recently_featured.onclick=function()
{_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.recently_featured;if(!_this._time)
_this._time=R31ExternalChannels.times.today;_this.search('',_this._root,_this._time);}
this.content.html.feedType_watch_on_mobile.onclick=function()
{_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.watch_on_mobile;if(!_this._time)
_this._time=R31ExternalChannels.times.today;_this.search('',_this._root,_this._time);}
this.content.html.feedType_most_discussed.onclick=function()
{_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.most_discussed;if(!_this._time)
_this._time=R31ExternalChannels.times.today;_this.search('',_this._root,_this._time);}
this.content.html.feedType_top_favorites.onclick=function()
{_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.top_favorites;if(!_this._time)
_this._time=R31ExternalChannels.times.today;_this.search('',_this._root,_this._time);}
this.content.html.feedType_most_linked.onclick=function()
{_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.most_linked;if(!_this._time)
_this._time=R31ExternalChannels.times.today;_this.search('',_this._root,_this._time);}
this.content.html.feedType_most_responded.onclick=function()
{_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.most_responded;if(!_this._time)
_this._time=R31ExternalChannels.times.today;_this.search('',_this._root,_this._time);}
this.content.html.feedType_most_recent.onclick=function()
{_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.most_recent;if(!_this._time)
_this._time=R31ExternalChannels.times.today;_this.search('',_this._root,_this._time);}
this.content.html.timeType_today.onclick=function()
{_this.content.html.searchExp.value='';_this._time=R31ExternalChannels.times.today;if(!_this._root)
_this._root=R31ExternalChannels.feeds.most_viewed;_this.search('',_this._root,_this._time);}
this.content.html.timeType_this_week.onclick=function()
{_this.content.html.searchExp.value='';_this._time=R31ExternalChannels.times.this_week;if(!_this._root)
_this._root=R31ExternalChannels.feeds.most_viewed;_this.search('',_this._root,_this._time);}
this.content.html.timeType_this_month.onclick=function()
{_this.content.html.searchExp.value='';_this._time=R31ExternalChannels.times.this_month;if(!_this._root)
_this._root=R31ExternalChannels.feeds.most_viewed;_this.search('',_this._root,_this._time);}
this.content.html.timeType_all_time.onclick=function()
{_this.content.html.searchExp.value='';_this._time=R31ExternalChannels.times.all_time;if(!_this._root)
_this._root=R31ExternalChannels.feeds.most_viewed;_this.search('',_this._root,_this._time);}}
if(this.template=="dailymotion"){this.content.html.feedType_news.onclick=function()
{_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds._news;if(!_this._time)
_this._time=R31ExternalChannels.times.most_recent;_this.search('',_this._root,_this._time);}
this.content.html.feedType_fun.onclick=function()
{_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.fun;if(!_this._time)
_this._time=R31ExternalChannels.times.most_recent;_this.search('',_this._root,_this._time);}
this.content.html.feedType_shortfilms.onclick=function()
{_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.shortfilms;if(!_this._time)
_this._time=R31ExternalChannels.times.most_recent;_this.search('',_this._root,_this._time);}
this.content.html.feedType_music.onclick=function()
{_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.music;if(!_this._time)
_this._time=R31ExternalChannels.times.most_recent;_this.search('',_this._root,_this._time);}
this.content.html.feedType_auto.onclick=function()
{_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.auto;if(!_this._time)
_this._time=R31ExternalChannels.times.most_recent;_this.search('',_this._root,_this._time);}
this.content.html.feedType_creation.onclick=function()
{_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.creation;if(!_this._time)
_this._time=R31ExternalChannels.times.most_recent;_this.search('',_this._root,_this._time);}
this.content.html.feedType_videogames.onclick=function()
{_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.videogames;if(!_this._time)
_this._time=R31ExternalChannels.times.most_recent;_this.search('',_this._root,_this._time);}
this.content.html.feedType_webcam.onclick=function()
{_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.webcam;if(!_this._time)
_this._time=R31ExternalChannels.times.most_recent;_this.search('',_this._root,_this._time);}
this.content.html.feedType_travel.onclick=function()
{_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.travel;if(!_this._time)
_this._time=R31ExternalChannels.times.most_recent;_this.search('',_this._root,_this._time);}
this.content.html.feedType_sport.onclick=function()
{_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.sport;if(!_this._time)
_this._time=R31ExternalChannels.times.most_recent;_this.search('',_this._root,_this._time);}
this.content.html.feedType_animals.onclick=function()
{_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.animals;if(!_this._time)
_this._time=R31ExternalChannels.times.most_recent;_this.search('',_this._root,_this._time);}
this.content.html.feedType_people.onclick=function()
{_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.people;if(!_this._time)
_this._time=R31ExternalChannels.times.most_recent;_this.search('',_this._root,_this._time);}
this.content.html.feedType_tech.onclick=function()
{_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.tech;if(!_this._time)
_this._time=R31ExternalChannels.times.most_recent;_this.search('',_this._root,_this._time);}
this.content.html.feedType_school.onclick=function()
{_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.school;if(!_this._time)
_this._time=R31ExternalChannels.times.most_recent;_this.search('',_this._root,_this._time);}
this.content.html.feedType_lifestyle.onclick=function()
{_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.lifestyle;if(!_this._time)
_this._time=R31ExternalChannels.times.most_recent;_this.search('',_this._root,_this._time);}
this.content.html.feedType_sexy.onclick=function()
{_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.sexy;if(!_this._time)
_this._time=R31ExternalChannels.times.most_recent;_this.search('',_this._root,_this._time);}
this.content.html.timeType_most_recent.onclick=function()
{_this.content.html.searchExp.value='';_this._time=R31ExternalChannels.times.most_recent;if(!_this._root)
_this._root=R31ExternalChannels.feeds.news;_this.search('',_this._root,_this._time);}
this.content.html.timeType_commented.onclick=function()
{_this.content.html.searchExp.value='';_this._time=R31ExternalChannels.times.commented;if(!_this._root)
_this._root=R31ExternalChannels.feeds.news;_this.search('',_this._root,_this._time);}
this.content.html.timeType_visited.onclick=function()
{_this.content.html.searchExp.value='';_this._time=R31ExternalChannels.times.visited;if(!_this._root)
_this._root=R31ExternalChannels.feeds.news;_this.search('',_this._root,_this._time);}
this.content.html.timeType_rated.onclick=function()
{_this.content.html.searchExp.value='';_this._time=R31ExternalChannels.times.rated;if(!_this._root)
_this._root=R31ExternalChannels.feeds.news;_this.search('',_this._root,_this._time);}}
if(this.template=="hulu"){this.content.html.feedType_action_and_adventure.onclick=function()
{if(_this.content.html.feedType_action_and_adventure_espionage.style.display=='none'){_this.content.html.feedType_action_and_adventure_espionage.style.display='block';_this.content.html.feedType_action_and_adventure_military_and_war.style.display='block';_this.content.html.feedType_action_and_adventure_westerns.style.display='block';_this.content.html.feedType_action_and_adventure_martial_arts.style.display='block';}
else{_this.content.html.feedType_action_and_adventure_espionage.style.display='none';_this.content.html.feedType_action_and_adventure_military_and_war.style.display='none';_this.content.html.feedType_action_and_adventure_westerns.style.display='none';_this.content.html.feedType_action_and_adventure_martial_arts.style.display='none';}
_this.content.html.feedType_action_and_adventure_espionage.onclick=function(){_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.action_and_adventure_espionage;if(!_this._time)
_this._time=R31ExternalChannels.times.release;_this.search('',_this._root,_this._time);}
_this.content.html.feedType_action_and_adventure_military_and_war.onclick=function(){_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.action_and_adventure_military_and_war;if(!_this._time)
_this._time=R31ExternalChannels.times.release;_this.search('',_this._root,_this._time);}
_this.content.html.feedType_action_and_adventure_westerns.onclick=function(){_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.action_and_adventure_westerns;if(!_this._time)
_this._time=R31ExternalChannels.times.release;_this.search('',_this._root,_this._time);}
_this.content.html.feedType_action_and_adventure_martial_arts.onclick=function(){_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.action_and_adventure_martial_arts;if(!_this._time)
_this._time=R31ExternalChannels.times.release;_this.search('',_this._root,_this._time);}}
this.content.html.feedType_animation_and_cartoons.onclick=function()
{if(_this.content.html.feedType_animation_and_cartoons_anime.style.display=='none')
_this.content.html.feedType_animation_and_cartoons_anime.style.display='block';else
_this.content.html.feedType_animation_and_cartoons_anime.style.display='none';_this.content.html.feedType_animation_and_cartoons_anime.onclick=function(){_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.animation_and_cartoons_anime;if(!_this._time)
_this._time=R31ExternalChannels.times.release;_this.search('',_this._root,_this._time);}}
this.content.html.feedType_comedy.onclick=function()
{if(_this.content.html.feedType_comedy_sitcoms.style.display=='none'){_this.content.html.feedType_comedy_sitcoms.style.display='block';_this.content.html.feedType_comedy_satire.style.display='block';_this.content.html.feedType_comedy_sketch.style.display='block';_this.content.html.feedType_comedy_stand_up.style.display='block';}
else{_this.content.html.feedType_comedy_sitcoms.style.display='none';_this.content.html.feedType_comedy_satire.style.display='none';_this.content.html.feedType_comedy_sketch.style.display='none';_this.content.html.feedType_comedy_stand_up.style.display='none';}
_this.content.html.feedType_comedy_sitcoms.onclick=function(){_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.comedy_sitcoms;if(!_this._time)
_this._time=R31ExternalChannels.times.release;_this.search('',_this._root,_this._time);}
_this.content.html.feedType_comedy_satire.onclick=function(){_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.comedy_satire;if(!_this._time)
_this._time=R31ExternalChannels.times.release;_this.search('',_this._root,_this._time);}
_this.content.html.feedType_comedy_sketch.onclick=function(){_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.comedy_sketch;if(!_this._time)
_this._time=R31ExternalChannels.times.release;_this.search('',_this._root,_this._time);}
_this.content.html.feedType_comedy_stand_up.onclick=function(){_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.comedy_stand_up;if(!_this._time)
_this._time=R31ExternalChannels.times.release;_this.search('',_this._root,_this._time);}}
this.content.html.feedType_drama.onclick=function()
{if(_this.content.html.feedType_drama_crime_and_courtroom.style.display=='none'){_this.content.html.feedType_drama_crime_and_courtroom.style.display='block';_this.content.html.feedType_drama_medical.style.display='block';_this.content.html.feedType_drama_soap_operas.style.display='block';}
else{_this.content.html.feedType_drama_crime_and_courtroom.style.display='none';_this.content.html.feedType_drama_medical.style.display='none';_this.content.html.feedType_drama_soap_operas.style.display='none';}
_this.content.html.feedType_drama_crime_and_courtroom.onclick=function(){_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.drama_crime_and_courtroom;if(!_this._time)
_this._time=R31ExternalChannels.times.release;_this.search('',_this._root,_this._time);}
_this.content.html.feedType_drama_medical.onclick=function(){_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.drama_medical;if(!_this._time)
_this._time=R31ExternalChannels.times.release;_this.search('',_this._root,_this._time);}
_this.content.html.feedType_drama_soap_operas.onclick=function(){_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.drama_soap_operas;if(!_this._time)
_this._time=R31ExternalChannels.times.release;_this.search('',_this._root,_this._time);}}
this.content.html.feedType_food_and_leisure.onclick=function()
{if(_this.content.html.feedType_food_and_leisure_food_and_beverage.style.display=='none'){_this.content.html.feedType_food_and_leisure_food_and_beverage.style.display='block';_this.content.html.feedType_food_and_leisure_fashion_and_beauty.style.display='block';_this.content.html.feedType_food_and_leisure_travel.style.display='block';_this.content.html.feedType_food_and_leisure_recipes.style.display='block';_this.content.html.feedType_food_and_leisure_entertaining.style.display='block';}
else{_this.content.html.feedType_food_and_leisure_food_and_beverage.style.display='none';_this.content.html.feedType_food_and_leisure_fashion_and_beauty.style.display='none';_this.content.html.feedType_food_and_leisure_travel.style.display='none';_this.content.html.feedType_food_and_leisure_recipes.style.display='none';_this.content.html.feedType_food_and_leisure_entertaining.style.display='none';}
_this.content.html.feedType_food_and_leisure_food_and_beverage.onclick=function(){_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.food_and_leisure_food_and_beverage;if(!_this._time)
_this._time=R31ExternalChannels.times.release;_this.search('',_this._root,_this._time);}
_this.content.html.feedType_food_and_leisure_fashion_and_beauty.onclick=function(){_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.food_and_leisure_fashion_and_beauty;if(!_this._time)
_this._time=R31ExternalChannels.times.release;_this.search('',_this._root,_this._time);}
_this.content.html.feedType_food_and_leisure_travel.onclick=function(){_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.food_and_leisure_travel;if(!_this._time)
_this._time=R31ExternalChannels.times.release;_this.search('',_this._root,_this._time);}
_this.content.html.feedType_food_and_leisure_recipes.onclick=function(){_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.food_and_leisure_recipes;if(!_this._time)
_this._time=R31ExternalChannels.times.release;_this.search('',_this._root,_this._time);}
_this.content.html.feedType_food_and_leisure_entertaining.onclick=function(){_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.food_and_leisure_entertaining;if(!_this._time)
_this._time=R31ExternalChannels.times.release;_this.search('',_this._root,_this._time);}}
this.content.html.feedType_home_and_garden.onclick=function()
{if(_this.content.html.feedType_home_and_garden_real_estate.style.display=='none'){_this.content.html.feedType_home_and_garden_real_estate.style.display='block';_this.content.html.feedType_home_and_garden_decorating.style.display='block';_this.content.html.feedType_home_and_garden_do_it_yourself.style.display='block';_this.content.html.feedType_home_and_garden_home_improvement.style.display='block';}
else{_this.content.html.feedType_home_and_garden_real_estate.style.display='none';_this.content.html.feedType_home_and_garden_decorating.style.display='none';_this.content.html.feedType_home_and_garden_do_it_yourself.style.display='none';_this.content.html.feedType_home_and_garden_home_improvement.style.display='none';}
_this.content.html.feedType_home_and_garden_real_estate.onclick=function(){_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.home_and_garden_real_estate;if(!_this._time)
_this._time=R31ExternalChannels.times.release;_this.search('',_this._root,_this._time);}
_this.content.html.feedType_home_and_garden_decorating.onclick=function(){_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.home_and_garden_decorating;if(!_this._time)
_this._time=R31ExternalChannels.times.release;_this.search('',_this._root,_this._time);}
_this.content.html.feedType_home_and_garden_do_it_yourself.onclick=function(){_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.home_and_garden_do_it_yourself;if(!_this._time)
_this._time=R31ExternalChannels.times.release;_this.search('',_this._root,_this._time);}
_this.content.html.feedType_home_and_garden_home_improvement.onclick=function(){_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.home_and_garden_home_improvement;if(!_this._time)
_this._time=R31ExternalChannels.times.release;_this.search('',_this._root,_this._time);}}
this.content.html.feedType_horror_and_suspense.onclick=function()
{if(_this.content.html.feedType_horror_and_suspense_mystery.style.display=='none'){_this.content.html.feedType_horror_and_suspense_mystery.style.display='block';_this.content.html.feedType_horror_and_suspense_paranormal.style.display='block';}
else{_this.content.html.feedType_horror_and_suspense_mystery.style.display='none';_this.content.html.feedType_horror_and_suspense_paranormal.style.display='none';}
_this.content.html.feedType_horror_and_suspense_mystery.onclick=function(){_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.horror_and_suspense_mystery;if(!_this._time)
_this._time=R31ExternalChannels.times.release;_this.search('',_this._root,_this._time);}
_this.content.html.feedType_horror_and_suspense_paranormal.onclick=function(){_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.horror_and_suspense_paranormal;if(!_this._time)
_this._time=R31ExternalChannels.times.release;_this.search('',_this._root,_this._time);}}
this.content.html.feedType_news_and_information.onclick=function()
{if(_this.content.html.feedType_news_and_information_documentary_and_biography.style.display=='none'){_this.content.html.feedType_news_and_information_documentary_and_biography.style.display='block';_this.content.html.feedType_news_and_information_science_and_technology.style.display='block';_this.content.html.feedType_news_and_information_current_news.style.display='block';_this.content.html.feedType_news_and_information_live_events_and_specials.style.display='block';_this.content.html.feedType_news_and_information_celebrity_and_gossip.style.display='block';_this.content.html.feedType_news_and_information_politics.style.display='block';}
else{_this.content.html.feedType_news_and_information_documentary_and_biography.style.display='none';_this.content.html.feedType_news_and_information_science_and_technology.style.display='none';_this.content.html.feedType_news_and_information_current_news.style.display='none';_this.content.html.feedType_news_and_information_live_events_and_specials.style.display='none';_this.content.html.feedType_news_and_information_celebrity_and_gossip.style.display='none';_this.content.html.feedType_news_and_information_politics.style.display='none';}
_this.content.html.feedType_news_and_information_documentary_and_biography.onclick=function(){_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.news_and_information_documentary_and_biography;if(!_this._time)
_this._time=R31ExternalChannels.times.release;_this.search('',_this._root,_this._time);}
_this.content.html.feedType_news_and_information_science_and_technology.onclick=function(){_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.news_and_information_science_and_technology;if(!_this._time)
_this._time=R31ExternalChannels.times.release;_this.search('',_this._root,_this._time);}
_this.content.html.feedType_news_and_information_current_news.onclick=function(){_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.news_and_information_current_news;if(!_this._time)
_this._time=R31ExternalChannels.times.release;_this.search('',_this._root,_this._time);}
_this.content.html.feedType_news_and_information_live_events_and_specials.onclick=function(){_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.news_and_information_live_events_and_specials;if(!_this._time)
_this._time=R31ExternalChannels.times.release;_this.search('',_this._root,_this._time);}
_this.content.html.feedType_news_and_information_celebrity_and_gossip.onclick=function(){_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.news_and_information_celebrity_and_gossip;if(!_this._time)
_this._time=R31ExternalChannels.times.release;_this.search('',_this._root,_this._time);}
_this.content.html.feedType_news_and_information_politics.onclick=function(){_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.news_and_information_politics;if(!_this._time)
_this._time=R31ExternalChannels.times.release;_this.search('',_this._root,_this._time);}}
this.content.html.feedType_sports.onclick=function()
{if(_this.content.html.feedType_sports_extreme_sports.style.display=='none'){_this.content.html.feedType_sports_extreme_sports.style.display='block';_this.content.html.feedType_sports_fighting_and_martial_arts.style.display='block';_this.content.html.feedType_sports_gaming.style.display='block';_this.content.html.feedType_sports_college_football.style.display='block';_this.content.html.feedType_sports_wwe.style.display='block';_this.content.html.feedType_sports_nba.style.display='block';_this.content.html.feedType_sports_nhl.style.display='block';}
else{_this.content.html.feedType_sports_extreme_sports.style.display='none';_this.content.html.feedType_sports_fighting_and_martial_arts.style.display='none';_this.content.html.feedType_sports_gaming.style.display='none';_this.content.html.feedType_sports_college_football.style.display='none';_this.content.html.feedType_sports_wwe.style.display='none';_this.content.html.feedType_sports_nba.style.display='none';_this.content.html.feedType_sports_nhl.style.display='none';}
_this.content.html.feedType_sports_extreme_sports.onclick=function(){_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.sports_extreme_sports;if(!_this._time)
_this._time=R31ExternalChannels.times.release;_this.search('',_this._root,_this._time);}
_this.content.html.feedType_sports_fighting_and_martial_arts.onclick=function(){_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.sports_fighting_and_martial_arts;if(!_this._time)
_this._time=R31ExternalChannels.times.release;_this.search('',_this._root,_this._time);}
_this.content.html.feedType_sports_gaming.onclick=function(){_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.sports_gaming;if(!_this._time)
_this._time=R31ExternalChannels.times.release;_this.search('',_this._root,_this._time);}
_this.content.html.feedType_sports_college_football.onclick=function(){_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.sports_college_football;if(!_this._time)
_this._time=R31ExternalChannels.times.release;_this.search('',_this._root,_this._time);}
_this.content.html.feedType_sports_wwe.onclick=function(){_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.sports_wwe;if(!_this._time)
_this._time=R31ExternalChannels.times.release;_this.search('',_this._root,_this._time);}
_this.content.html.feedType_sports_nba.onclick=function(){_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.sports_nba;if(!_this._time)
_this._time=R31ExternalChannels.times.release;_this.search('',_this._root,_this._time);}
_this.content.html.feedType_sports_nhl.onclick=function(){_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.sports_nhl;if(!_this._time)
_this._time=R31ExternalChannels.times.release;_this.search('',_this._root,_this._time);}}
this.content.html.feedType_talk_and_interview.onclick=function()
{if(_this.content.html.feedType_talk_and_interview_celebrity_and_gossip.style.display=='none'){_this.content.html.feedType_talk_and_interview_celebrity_and_gossip.style.display='block';}
else{_this.content.html.feedType_talk_and_interview_celebrity_and_gossip.style.display='none';}
_this.content.html.feedType_talk_and_interview_celebrity_and_gossip.onclick=function(){_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.talk_and_interview_celebrity_and_gossip;if(!_this._time)
_this._time=R31ExternalChannels.times.release;_this.search('',_this._root,_this._time);}}
this.content.html.feedType_videogames.onclick=function()
{if(_this.content.html.feedType_videogames_reviews.style.display=='none'){_this.content.html.feedType_videogames_reviews.style.display='block';_this.content.html.feedType_videogames_previews.style.display='block';}
else{_this.content.html.feedType_videogames_reviews.style.display='none';_this.content.html.feedType_videogames_previews.style.display='none';}
_this.content.html.feedType_videogames_reviews.onclick=function(){_this.content.html.searchExp.value='';_this._root=R31ExternalChannels.feeds.videogames_reviews;if(!_this._time)
_this._time=R31ExternalChannels.times.release;_this.search('',_this._root,_this._time);}
_this.content.html.feed