// JESS - Javascript-Enhanced Style Sheets
// Copyright (c) 2009 Petr Stanicek, http://pixy.cz

var JE$$=function(){if(!jQuery){return}if(b!=jQuery){var b=jQuery}function c(e,g,f){this.apply=g;this.applyAll=function(){for(var h in this.List){if(h!="default"){this.apply(h)}}};this.add=function(h){this.List[h.id]=h};this.ParentClass=e;this.List={};this.add(f)}var d={};d.styledBox=new c("JESS-styledbox-",function(g,k){var m,l,p,n,q,o,r,f,h;if(!k){k=b("."+this.ParentClass+g)}if(k.length==0){return}r=this.List[g]||this.List["default"];if(r.img){if(k.css("position")=="static"){k.css({position:"relative"})}if(r.padding){k.css({padding:r.padding})}q=(r.minWidth||0)-parseInt(k.css("padding-left"),10)-parseInt(k.css("padding-right"),10);if(q<0){q=0}o=(r.minHeight||0)-parseInt(k.css("padding-top"),10)-parseInt(k.css("padding-bottom"),10);if(o<0){o=0}k.css({border:"none",background:"transparent","min-width":q+"px","min-height":o+"px"});h=r.order||this.List["default"].order;for(m=0;m<9;m++){l=h[m];p=this.ParentClass+"-x-"+l;if(k.children("."+p).length==0){n=a("DIV",{className:p});k.append(n)}f={position:"absolute","z-index":-1,background:"url("+r.img+"/"+(l+1)+"."+r.ext+") 0 0 repeat"};switch(l){case 0:f.left=0;f.right="auto";f.top=0;f.bottom="auto";f.width=r.width.left+"px";f.height=r.width.top+"px";f.backgroundPosition="top left";break;case 1:f.left=r.width.left+"px";f.right=r.width.right+"px";f.top=0;f.bottom="auto";f.width="auto";f.height=r.width.top+"px";f.backgroundPosition="top left";break;case 2:f.left="auto";f.right=0;f.top=0;f.bottom="auto";f.width=r.width.right+"px";f.height=r.width.top+"px";f.backgroundPosition="top right";break;case 3:f.left=0;f.right="auto";f.top=r.width.top+"px";f.bottom=r.width.bottom+"px";f.width=r.width.left+"px";f.height="auto";f.backgroundPosition="top left";break;case 4:f.left=r.width.left+"px";f.right=r.width.right+"px";f.top=r.width.top+"px";f.bottom=r.width.bottom+"px";f.width="auto";f.height="auto";f.backgroundPosition="top left";break;case 5:f.left="auto";f.right=0;f.top=r.width.top+"px";f.bottom=r.width.bottom+"px";f.width=r.width.right+"px";f.height="auto";f.backgroundPosition="top right";break;case 6:f.left=0;f.right="auto";f.top="auto";f.bottom=0;f.width=r.width.left+"px";f.height=r.width.bottom+"px";f.backgroundPosition="bottom left";break;case 7:f.left=r.width.left+"px";f.right=r.width.right+"px";f.top="auto";f.bottom=0;f.width="auto";f.height=r.width.bottom+"px";f.backgroundPosition="bottom left";break;case 8:f.left="auto";f.right=0;f.top="auto";f.bottom=0;f.width=r.width.right+"px";f.height=r.width.bottom+"px";f.backgroundPosition="bottom right";break}k.children("."+p).css(f)}}else{k.css({border:r.border,background:r.bgColor})}},{id:"default",border:"1px solid black",bgColor:"transparent",img:null,ext:"",width:{},minWidth:0,minHeight:0,order:[0,1,2,3,4,5,6,7,8]});function a(f,h){var g,i=document.createElement(f);if(h){for(g in h){i[g]=h[g]}}return i}jQuery(function(){JE$$.apply("","styledBox")});return{styledBox:function(e){if(!!!e.id||e.id==="default"){return}d.styledBox.add(e)},styledBoxReplace:function(e,g,h){var f=b(e);if(f.length>0){f.removeClass(d.styledBox.ParentClass+g).addClass(d.styledBox.ParentClass+h);d.styledBox.apply(h,f)}},apply:function(e,g,f){if(f){d[g].apply(e,f)}else{d[g].applyAll(e)}}}}();
