var Rico={Version:"1.1.0",prototypeVersion:parseFloat(Prototype.Version.split(".")[0]+"."+Prototype.Version.split(".")[1])};var RicoUtil={getElementsComputedStyle:function(d,a,b){if(arguments.length==2){b=a}var c=$(d);if(c.currentStyle){return c.currentStyle[a]}else{return document.defaultView.getComputedStyle(c,null).getPropertyValue(b)}},createXmlDocument:function(){if(document.implementation&&document.implementation.createDocument){var a=document.implementation.createDocument("","",null);if(a.readyState==null){a.readyState=1;a.addEventListener("load",function(){a.readyState=4;if(typeof a.onreadystatechange=="function"){a.onreadystatechange()}},false)}return a}if(window.ActiveXObject){return Try.these(function(){return new ActiveXObject("MSXML2.DomDocument")},function(){return new ActiveXObject("Microsoft.DomDocument")},function(){return new ActiveXObject("MSXML.DomDocument")},function(){return new ActiveXObject("MSXML3.DomDocument")})||false}return null}};Rico.Color=Class.create();Rico.Color.prototype={initialize:function(b,c,a){this.rgb={r:b,g:c,b:a}},setRed:function(a){this.rgb.r=a},setGreen:function(a){this.rgb.g=a},setBlue:function(a){this.rgb.b=a},setHue:function(b){var a=this.asHSB();a.h=b;this.rgb=Rico.Color.HSBtoRGB(a.h,a.s,a.b)},setSaturation:function(b){var a=this.asHSB();a.s=b;this.rgb=Rico.Color.HSBtoRGB(a.h,a.s,a.b)},setBrightness:function(a){var b=this.asHSB();b.b=a;this.rgb=Rico.Color.HSBtoRGB(b.h,b.s,b.b)},darken:function(b){var a=this.asHSB();this.rgb=Rico.Color.HSBtoRGB(a.h,a.s,Math.max(a.b-b,0))},brighten:function(b){var a=this.asHSB();this.rgb=Rico.Color.HSBtoRGB(a.h,a.s,Math.min(a.b+b,1))},blend:function(a){this.rgb.r=Math.floor((this.rgb.r+a.rgb.r)/2);this.rgb.g=Math.floor((this.rgb.g+a.rgb.g)/2);this.rgb.b=Math.floor((this.rgb.b+a.rgb.b)/2)},isBright:function(){var a=this.asHSB();return this.asHSB().b>0.5},isDark:function(){return !this.isBright()},asRGB:function(){return"rgb("+this.rgb.r+","+this.rgb.g+","+this.rgb.b+")"},asHex:function(){return"#"+this.rgb.r.toColorPart()+this.rgb.g.toColorPart()+this.rgb.b.toColorPart()},asHSB:function(){return Rico.Color.RGBtoHSB(this.rgb.r,this.rgb.g,this.rgb.b)},toString:function(){return this.asHex()}};Rico.Color.createFromHex=function(d){if(d.length==4){var f=d;var d="#";for(var e=1;e<4;e++){d+=(f.charAt(e)+f.charAt(e))}}if(d.indexOf("#")==0){d=d.substring(1)}var b=d.substring(0,2);var c=d.substring(2,4);var a=d.substring(4,6);return new Rico.Color(parseInt(b,16),parseInt(c,16),parseInt(a,16))};Rico.Color.createColorFromBackground=function(b){var d=RicoUtil.getElementsComputedStyle($(b),"backgroundColor","background-color");if(d=="transparent"&&b.parentNode){return Rico.Color.createColorFromBackground(b.parentNode)}if(d==null){return new Rico.Color(255,255,255)}if(d.indexOf("rgb(")==0){var a=d.substring(4,d.length-1);var c=a.split(",");return new Rico.Color(parseInt(c[0]),parseInt(c[1]),parseInt(c[2]))}else{if(d.indexOf("#")==0){return Rico.Color.createFromHex(d)}else{return new Rico.Color(255,255,255)}}};Rico.Color.HSBtoRGB=function(i,k,g){var b=0;var a=0;var f=0;if(k==0){b=parseInt(g*255+0.5);a=b;f=b}else{var j=(i-Math.floor(i))*6;var h=j-Math.floor(j);var c=g*(1-k);var d=g*(1-k*h);var e=g*(1-(k*(1-h)));switch(parseInt(j)){case 0:b=(g*255+0.5);a=(e*255+0.5);f=(c*255+0.5);break;case 1:b=(d*255+0.5);a=(g*255+0.5);f=(c*255+0.5);break;case 2:b=(c*255+0.5);a=(g*255+0.5);f=(e*255+0.5);break;case 3:b=(c*255+0.5);a=(d*255+0.5);f=(g*255+0.5);break;case 4:b=(e*255+0.5);a=(c*255+0.5);f=(g*255+0.5);break;case 5:b=(g*255+0.5);a=(c*255+0.5);f=(d*255+0.5);break}}return{r:parseInt(b),g:parseInt(a),b:parseInt(f)}};Rico.Color.RGBtoHSB=function(d,k,f){var j;var a;var g;var e=(d>k)?d:k;if(f>e){e=f}var i=(d<k)?d:k;if(f<i){i=f}g=e/255;if(e!=0){a=(e-i)/e}else{a=0}if(a==0){j=0}else{var c=(e-d)/(e-i);var h=(e-k)/(e-i);var b=(e-f)/(e-i);if(d==e){j=b-h}else{if(k==e){j=2+c-b}else{j=4+h-c}}j=j/6;if(j<0){j=j+1}}return{h:j,s:a,b:g}};Rico.Corner={round:function(b,d){var b=$(b);this._setOptions(d);var a=this.options.color;if(this.options.color=="fromElement"){a=this._background(b)}var c=this.options.bgColor;if(this.options.bgColor=="fromParent"){c=this._background(b.offsetParent)}this._roundCornersImpl(b,a,c)},_roundCornersImpl:function(b,a,c){if(this.options.border){this._renderBorder(b,c)}if(this._isTopRounded()){this._roundTopCorners(b,a,c)}if(this._isBottomRounded()){this._roundBottomCorners(b,a,c)}},_renderBorder:function(d,c){var f="1px solid "+this._borderColor(c);var a="border-left: "+f;var b="border-right: "+f;var e="style='"+a+";"+b+"'";d.innerHTML="<div "+e+">"+d.innerHTML+"</div>"},_roundTopCorners:function(d,a,b){var c=this._createCorner(b);for(var e=0;e<this.options.numSlices;e++){c.appendChild(this._createCornerSlice(a,b,e,"top"))}d.style.paddingTop=0;d.insertBefore(c,d.firstChild)},_roundBottomCorners:function(d,a,b){var c=this._createCorner(b);for(var e=(this.options.numSlices-1);e>=0;e--){c.appendChild(this._createCornerSlice(a,b,e,"bottom"))}d.style.paddingBottom=0;d.appendChild(c)},_createCorner:function(b){var a=document.createElement("div");a.style.backgroundColor=(this._isTransparent()?"transparent":b);return a},_createCornerSlice:function(f,e,b,a){var d=document.createElement("span");var g=d.style;g.backgroundColor=f;g.display="block";g.height="1px";g.overflow="hidden";g.fontSize="1px";var c=this._borderColor(f,e);if(this.options.border&&b==0){g.borderTopStyle="solid";g.borderTopWidth="1px";g.borderLeftWidth="0px";g.borderRightWidth="0px";g.borderBottomWidth="0px";g.height="0px";g.borderColor=c}else{if(c){g.borderColor=c;g.borderStyle="solid";g.borderWidth="0px 1px"}}if(!this.options.compact&&(b==(this.options.numSlices-1))){g.height="2px"}this._setMargin(d,b,a);this._setBorder(d,b,a);return d},_setOptions:function(a){this.options={corners:"all",color:"fromElement",bgColor:"fromParent",blend:true,border:false,compact:false};Object.extend(this.options,a||{});this.options.numSlices=this.options.compact?2:4;if(this._isTransparent()){this.options.blend=false}},_whichSideTop:function(){if(this._hasString(this.options.corners,"all","top")){return""}if(this.options.corners.indexOf("tl")>=0&&this.options.corners.indexOf("tr")>=0){return""}if(this.options.corners.indexOf("tl")>=0){return"left"}else{if(this.options.corners.indexOf("tr")>=0){return"right"}}return""},_whichSideBottom:function(){if(this._hasString(this.options.corners,"all","bottom")){return""}if(this.options.corners.indexOf("bl")>=0&&this.options.corners.indexOf("br")>=0){return""}if(this.options.corners.indexOf("bl")>=0){return"left"}else{if(this.options.corners.indexOf("br")>=0){return"right"}}return""},_borderColor:function(a,b){if(a=="transparent"){return b}else{if(this.options.border){return this.options.border}else{if(this.options.blend){return this._blend(b,a)}else{return""}}}},_setMargin:function(c,b,e){var d=this._marginSize(b);var a=e=="top"?this._whichSideTop():this._whichSideBottom();if(a=="left"){c.style.marginLeft=d+"px";c.style.marginRight="0px"}else{if(a=="right"){c.style.marginRight=d+"px";c.style.marginLeft="0px"}else{c.style.marginLeft=d+"px";c.style.marginRight=d+"px"}}},_setBorder:function(c,b,e){var d=this._borderSize(b);var a=e=="top"?this._whichSideTop():this._whichSideBottom();if(a=="left"){c.style.borderLeftWidth=d+"px";c.style.borderRightWidth="0px"}else{if(a=="right"){c.style.borderRightWidth=d+"px";c.style.borderLeftWidth="0px"}else{c.style.borderLeftWidth=d+"px";c.style.borderRightWidth=d+"px"}}if(this.options.border!=false){c.style.borderLeftWidth=d+"px"}c.style.borderRightWidth=d+"px"},_marginSize:function(b){if(this._isTransparent()){return 0}var c=[5,3,2,1];var a=[3,2,1,0];var d=[2,1];var e=[1,0];if(this.options.compact&&this.options.blend){return e[b]}else{if(this.options.compact){return d[b]}else{if(this.options.blend){return a[b]}else{return c[b]}}}},_borderSize:function(b){var c=[5,3,2,1];var e=[2,1,1,1];var a=[1,0];var d=[0,2,0,0];if(this.options.compact&&(this.options.blend||this._isTransparent())){return 1}else{if(this.options.compact){return a[b]}else{if(this.options.blend){return e[b]}else{if(this.options.border){return d[b]}else{if(this._isTransparent()){return c[b]}}}}}return 0},_hasString:function(b){for(var a=1;a<arguments.length;a++){if(b.indexOf(arguments[a])>=0){return true}}return false},_blend:function(b,a){var c=Rico.Color.createFromHex(b);c.blend(Rico.Color.createFromHex(a));return c},_background:function(a){try{return Rico.Color.createColorFromBackground(a).asHex()}catch(b){return"#ffffff"}},_isTransparent:function(){return this.options.color=="transparent"},_isTopRounded:function(){return this._hasString(this.options.corners,"all","top","tl","tr")},_isBottomRounded:function(){return this._hasString(this.options.corners,"all","bottom","bl","br")},_hasSingleTextChild:function(a){return a.childNodes.length==1&&a.childNodes[0].nodeType==3}};