(function($){var o=new Array();$.fn.fontchange=function(a){o[o.length]=a;return this};var p='';$(window).bind('load',function(){$emEL=$('<div></div>').css({'position':'absolute','left':'-100em','width':'0px','height':'0px','background':'none','border:':'none','padding':'0px','margin':'0px'}).prependTo('body');var a=$emEL.offset().left;$(window).keyup(function(){checkEM()})});function checkEM(){var a=$emEL.offset().left;if(a!=p){for(var i=0;i<o.length;i++)o[i]()};p=a};$.fn._html=$.fn.html;$.fn.html=function(a){if(a||typeof a=='string'){$(this).each(function(){if(this.canvas)$('span.inner',this)._html(a);else $(this)._html(a)});return this}else{return this.canvas?$('span.inner',this)._html():$(this)._html()}};$.fn._offset=$.fn.offset;$.fn.offset=function(a){return a?this.setXY(a):this._offset()};$.fn.setXY=function(f){$(this).each(function(){var a=this;var b=false;if($(a).css('display')=='none'){b=true;$(a).show()};var c=$(a).css('position');if(c=='static'){$(a).css('position','relative');c='relative'};var d=$(a).offset();if(d){var e={left:parseInt($(a).css('left')),top:parseInt($(a).css('top'))};if(isNaN(e.left))e.left=(c=='relative')?0:a.offsetLeft;if(isNaN(e.top))e.top=(c=='relative')?0:a.offsetTop;f.left=Math.floor(f.left);f.top=Math.floor(f.top);if(f.left||f.left===0)$(a).css('left',f.left-d.left+e.left+'px');if(f.top||f.top===0)$(a).css('top',f.top-d.top+e.top+'px')};if(b)$(a).show()});return this};$.fn._css=$.fn.css;$.fn.css=function(a,b){var c=this;var d=c;if(arguments.length==1&&typeof a=='string'){var e,style,result=false;if(a.search(':')!=-1){e=a.split(':')[0].replace(' ','');style=a.split(':')[1].replace(' ','')}else{d=c._css(a,b)};if(e&&style){var f=style.split('-');style=f[0];for(var s=1;s<f.length;s++){style+=f[s].substring(0,1).toUpperCase();style+=f[s].substring(1,f[s].length)};var g=c.getCSSRules(':'+e);result=c._css(style);if(e=='active'){var h=c.getCSSRules(':hover');for(var i=0;i<h.length;i++){if(h[i].style[style])result=h[i].style[style]}};if(result)for(var r=0;r<g.length;r++)if(g[r].style[style])result=g[r].style[style];d=result}else d=c._css(a,b)}else d=this._css(a,b);return d};$.fn.getCSSRules=function(a){var b=this;var c=new Array();if(a==null)a='';for(var d=0;d<document.styleSheets.length;d++){if($.browser.msie)var e=document.styleSheets[d].rules;else var e=document.styleSheets[d].cssRules;for(var r=0;r<e.length;r++){if(!e[r].selectorText||e[r].selectorText.search(a)==-1)continue;var f=e[r].selectorText.replace(':hover','').replace(':active','').replace(':focus','');if($(f)){$(f).each(function(){if($(this)[0]==$(b)[0]){c[c.length]=e[r]}})}}};return c};$.fn.canvas=function(){$(this).each(function(){var g=this;if(g.canvas)return;var h=false;if($(g).css('display')=='none'){h=true;$(g).show()};var i=false;var j='insertBefore';if(g.tagName=='INPUT'||g.tagName=='TEXTAREA'||g.tagName=='IMG')i=true;var k='inline';if($.browser.msie)k=$(g).css('display');if($.browser.opera)k='block';if(!i){$(g).wrapInner('<span style="display: '+k+';position: relative; z-index: 1; background: none; border: none; margin: 0px; padding: 0px;" class="inner" />');if($.browser.safari)$('span.inner',g).children().css('position','relative');if($.browser.msie)j='appendTo';else j='prependTo'};var l;if($.browser.msie){l=document.createElement('canvas');g.canvas=G_vmlCanvasManager.initElement(l)}else{l=$('<canvas/>');g.canvas=l[0]};$(l)[j](g).attr({'width':$(g).outerWidth(),'height':$(g).outerHeight()}).css({'position':'absolute','background':'none','border':'none','padding':'0px'}).offset($(g).offset());if(i)$(g).css('position','relative');g.canvas.ctx=g.canvas.getContext('2d');g.canvas.roundCornersEvent=false;g.canvas.ctx.roundRect=function(a,b,x,y,c,d,e,f){this.beginPath();if(c>0)this.moveTo(c+x,y);else this.moveTo(x,y);if(c>0)this.quadraticCurveTo(x,y,x,c+y);if(e>0)this.lineTo(x,(b+y)-e);else this.lineTo(x,b+y);if(e>0)this.quadraticCurveTo(x,b+y,e+x,b+y);if(f>0)this.lineTo((a+x)-f,b+y);else this.lineTo(a+x,b+y);if(f>0)this.quadraticCurveTo(a+x,b+y,a+x,(b+y)-f);if(d>0)this.lineTo(a+x,d+y);else this.lineTo(a+x,y);if(d>0)this.quadraticCurveTo(a+x,y,a+x-d,y);if(c>0)this.lineTo(c,y);else this.lineTo(x,y)};g.focused=false;g.styles={bgColor:$(g).css('background-color'),radius:[0,0,0,0],border:{top:{width:parseInt($(g).css('border-top-width')),color:$(g).css('border-top-color')},left:{width:parseInt($(g).css('border-left-width')),color:$(g).css('border-left-color')},bottom:{width:parseInt($(g).css('border-bottom-width')),color:$(g).css('border-bottom-color')},right:{width:parseInt($(g).css('border-right-width')),color:$(g).css('border-right-color')}},hover:{bgColor:$(g).css('hover:background-color'),border:{top:{width:parseInt($(g).css('hover:border-top-width')),color:$(g).css('hover:border-top-color')},left:{width:parseInt($(g).css('hover:border-left-width')),color:$(g).css('hover:border-left-color')},bottom:{width:parseInt($(g).css('hover:border-bottom-width')),color:$(g).css('hover:border-bottom-color')},right:{width:parseInt($(g).css('hover:border-right-width')),color:$(g).css('hover:border-right-color')}}},active:{bgColor:$(g).css('active:background-color'),border:{top:{width:parseInt($(g).css('active:border-top-width')),color:$(g).css('active:border-top-color')},left:{width:parseInt($(g).css('active:border-left-width')),color:$(g).css('active:border-left-color')},bottom:{width:parseInt($(g).css('active:border-bottom-width')),color:$(g).css('active:border-bottom-color')},right:{width:parseInt($(g).css('active:border-right-width')),color:$(g).css('active:border-right-color')}}},focus:{bgColor:$(g).css('focus:background-color'),opacity:$(g).css('opacity'),border:{top:{width:parseInt($(g).css('focus:border-top-width')),color:$(g).css('focus:border-top-color')},left:{width:parseInt($(g).css('focus:border-left-width')),color:$(g).css('focus:border-left-color')},bottom:{width:parseInt($(g).css('focus:border-bottom-width')),color:$(g).css('focus:border-bottom-color')},right:{width:parseInt($(g).css('focus:border-right-width')),color:$(g).css('focus:border-right-color')}}}};if(h)$(g).hide()});return this};$.fn.getCanvas=function(){var a=this;$(a).canvas();var b=$(a)[0].canvas;if($.browser.msie){$(b).children().css({'position':'relative','background':'none','border':'none','padding':'0px','margin':'0px','left':'0px','top':'0px'})};return b};$.fn.draw=function(n){$(this).each(function(){var a=this;var b=false;if($(a).css('display')=='none'){b=true;$(a).show()};var c=$(a).getCanvas(d,e,f,g,i,j);var d=a.styles.radius[0];var e=a.styles.radius[1];var f=a.styles.radius[2];var g=a.styles.radius[3];var h,bgColor;switch(n){case'hover':h=a.styles.hover.border;bgColor=a.styles.hover.bgColor;break;case'active':h=a.styles.active.border;bgColor=a.styles.active.bgColor;break;case'focus':h=a.styles.focus.border;bgColor=a.styles.focus.bgColor;break;default:h=a.styles.border;bgColor=a.styles.bgColor};var i=$(a).outerWidth();var j=$(a).outerHeight();$(c).attr({'width':i,'height':j}).offset($(a).offset());var k=c.ctx;if(c.oldWidth&&c.oldHeight)k.clearRect(0,0,c.oldWidth,c.oldHeight);c.oldWidth=i;c.oldHeight=j;var l=h.top.width;if(h.right.width>l)l=h.right.width;if(h.bottom.width>l)l=h.bottom.width;if(h.left.width>l)l=h.left.width;if(l>0){k.roundRect(i,j,0,0,d,e,g,f);k.fillStyle=h.top.color;k.fill();if(l>d&&l>e&&l>f&&l>g){k.roundRect(i-(h.right.width+h.left.width),j-(h.bottom.width+h.top.width),h.left.width,h.top.width,0,0,0,0)}else{k.roundRect(i-(h.right.width+h.left.width),j-(h.bottom.width+h.top.width),h.left.width,h.top.width,d-h.left.width,e-h.right.width,g-h.left.width,f-h.right.width)};if(bgColor=='rgba(0, 0, 0, 0)'||bgColor=='transparent'){var m='#ffffff';$(a).parents().each(function(){if($(this).css('background-color')!='rgba(0, 0, 0, 0)'&&$(this).css('background-color')!='transparent'){m=$(this).css('background-color');return false}});k.fillStyle=m}else{k.fillStyle=bgColor}}else{k.roundRect(i,j,0,0,d,e,g,f);k.fillStyle=bgColor};k.fill();$(a).css({'background':'none','border-color':'transparent'});if($.browser.msie&&parseInt($.browser.version)==6){$(a).css({'padding-top':parseInt($(a).css('padding-top')+h.top.width)+'px','padding-left':parseInt($(a).css('padding-left')+h.left.width)+'px','border':'none'})};if(b)$(a).hide()});return this};function getGradient(a,b,c){var d=a.createLinearGradient(0,0,0,c);var g=0;for(var i=0;i<b.length;i++){var e=i/(b.length-1);d.addColorStop(e,b[g]);g++};return d}$.fn.bg=function(h,j,k){$(this).each(function(){var a=this;var b=$(this);if(typeof(b.attr('radius'))!='undefined')alert('hi');if(typeof(b.attr('gradient'))!='undefined')j=eval(b.attr('gradient'));b.canvas();a.canvas.args={radius:h,gradient:j};if(j){if(typeof j[0]=='object'){var c=j[0];if(j[1]){if(j[1].length>0)var d=j[1];else d=c};if(j[2]){if(j[2].length>0)var e=j[2];else{if(d)var e=d;else var e=c}};if(j[3]){if(j[3].length>0)var f=j[3];else{var f=c}}}else{var c=j;var d=j;var e=j;var f=j};if(c)a.styles.bgColor=getGradient(a.canvas.ctx,c,b.outerHeight());if(d)a.styles.hover.bgColor=getGradient(a.canvas.ctx,d,b.outerHeight());if(e)a.styles.active.bgColor=getGradient(a.canvas.ctx,e,b.outerHeight());if(f)a.styles.focus.bgColor=getGradient(a.canvas.ctx,f,b.outerHeight())};if(h){if(typeof h!='object')h=[h,h,h,h]}else{h=[0,0,0,0]};if(h[0]==null){h[0]=14};for(var i=0;i<4;i++){if(h[i]==null){h[i]=h[0]};if(typeof h[i]=='string'){if(h[i].search('em')!=-1){h[i]=parseFloat(h[i]);h[i]=h[i]*14};h[i]=parseInt(h[i])}};a.styles.radius=h;var g=a.canvas;if(!g.roundCornersEvent){g.roundCornersEvent=true;$(window).resize(function(){$(a).bg(h,j)});$(a).mouseenter(function(){if(!a.focused)$(a).bg(h,j,'hover')});$(a).mouseleave(function(){if(!a.focused)$(a).bg(h,j)});$(a).mousedown(function(){if(!a.focused)$(a).bg(h,j,'active')});$(a).mouseup(function(){if(!a.focused)$(a).bg(h,j,'hover')});$(a).focus(function(){a.focused=true;$(a).bg(h,j,'focus')});$(a).blur(function(){a.focused=false;$(a).bg(h,j)});o[o.length]=function(){if(!a.focused)$(a).bg(h,j);else $(a).bg(h,j,'focus')}};$(a).draw(k)});return this};$.fn.roundCorners=function(a,b,c,d){return $(this).bg([a,b,c,d])}})(jQuery);