/*
 * jQuery corner plugin: simple corner rounding
 * Examples and documentation at: http://jquery.malsup.com/corner/
 * version 2.08 (02-MAR-2010)
 * Requires jQuery v1.3.2 or later
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 * Authors: Dave Methvin and Mike Alsup
 */
(function(h){function l(m,d){return parseInt(h.css(m,d))||0}function a(d){d=parseInt(d).toString(16);return d.length<2?"0"+d:d}function i(m){for(;m&&m.nodeName.toLowerCase()!="html";m=m.parentNode){var d=h.css(m,"backgroundColor");if(d!="rgba(0, 0, 0, 0)"){if(d.indexOf("rgb")>=0){m=d.match(/\d+/g);return"#"+a(m[0])+a(m[1])+a(m[2])}if(d&&d!="transparent"){return d}}}return"#ffffff"}function e(m,d,n){switch(m){case"round":return Math.round(n*(1-Math.cos(Math.asin(d/n))));case"cool":return Math.round(n*(1+Math.cos(Math.asin(d/n))));case"sharp":return Math.round(n*(1-Math.cos(Math.acos(d/n))));case"bite":return Math.round(n*Math.cos(Math.asin((n-d-1)/n)));case"slide":return Math.round(n*Math.atan2(d,n/d));case"jut":return Math.round(n*Math.atan2(n,n-d-1));case"curl":return Math.round(n*Math.atan(d));case"tear":return Math.round(n*Math.cos(d));case"wicked":return Math.round(n*Math.tan(d));case"long":return Math.round(n*Math.sqrt(d));case"sculpt":return Math.round(n*Math.log(n-d-1,n));case"dogfold":case"dog":return d&1?d+1:n;case"dog2":return d&2?d+1:n;case"dog3":return d&3?d+1:n;case"fray":return d%2*n;case"notch":return n;case"bevelfold":case"bevel":return d+1}}var g=document.createElement("div").style,f=g.MozBorderRadius!==undefined,k=g.WebkitBorderRadius!==undefined,c=g.borderRadius!==undefined||g.BorderRadius!==undefined;g=document.documentMode||0;var b=h.browser.msie&&(h.browser.version<8&&!g||g<8),j=h.browser.msie&&function(){var m=document.createElement("div");try{m.style.setExpression("width","0+0");m.style.removeExpression("width")}catch(d){return false}return true}();h.fn.corner=function(m){if(this.length==0){if(!h.isReady&&this.selector){var d=this.selector,n=this.context;h(function(){h(d,n).corner(m)})}return this}return this.each(function(){var A=h(this),G=[A.attr(h.fn.corner.defaults.metaAttr)||"",m||""].join(" ").toLowerCase(),J=/keep/.test(G),B=(G.match(/cc:(#[0-9a-f]+)/)||[])[1],z=(G.match(/sc:(#[0-9a-f]+)/)||[])[1],D=parseInt((G.match(/(\d+)px/)||[])[1])||10,H=(G.match(/round|bevelfold|bevel|notch|bite|cool|sharp|slide|jut|curl|tear|fray|wicked|sculpt|long|dog3|dog2|dogfold|dog/)||["round"])[0],r=/dogfold|bevelfold/.test(G),F={T:0,B:1};G={TL:/top|tl|left/.test(G),TR:/top|tr|right/.test(G),BL:/bottom|bl|left/.test(G),BR:/bottom|br|right/.test(G)};if(!G.TL&&!G.TR&&!G.BL&&!G.BR){G={TL:1,TR:1,BL:1,BR:1}}if(h.fn.corner.defaults.useNative&&H=="round"&&(c||f||k)&&!B&&!z){if(G.TL){A.css(c?"border-top-left-radius":f?"-moz-border-radius-topleft":"-webkit-border-top-left-radius",D+"px")}if(G.TR){A.css(c?"border-top-right-radius":f?"-moz-border-radius-topright":"-webkit-border-top-right-radius",D+"px")}if(G.BL){A.css(c?"border-bottom-left-radius":f?"-moz-border-radius-bottomleft":"-webkit-border-bottom-left-radius",D+"px")}if(G.BR){A.css(c?"border-bottom-right-radius":f?"-moz-border-radius-bottomright":"-webkit-border-bottom-right-radius",D+"px")}}else{A=document.createElement("div");h(A).css({overflow:"hidden",height:"1px",minHeight:"1px",fontSize:"1px",backgroundColor:z||"transparent",borderStyle:"solid"});z={T:parseInt(h.css(this,"paddingTop"))||0,R:parseInt(h.css(this,"paddingRight"))||0,B:parseInt(h.css(this,"paddingBottom"))||0,L:parseInt(h.css(this,"paddingLeft"))||0};if(typeof this.style.zoom!=undefined){this.style.zoom=1}if(!J){this.style.border="none"}A.style.borderColor=B||i(this.parentNode);J=h(this).outerHeight();for(var o in F){if((B=F[o])&&(G.BL||G.BR)||!B&&(G.TL||G.TR)){A.style.borderStyle="none "+(G[o+"R"]?"solid":"none")+" none "+(G[o+"L"]?"solid":"none");var v=document.createElement("div");h(v).addClass("jquery-corner");var E=v.style;B?this.appendChild(v):this.insertBefore(v,this.firstChild);if(B&&J!="auto"){if(h.css(this,"position")=="static"){this.style.position="relative"}E.position="absolute";E.bottom=E.left=E.padding=E.margin="0";if(j){E.setExpression("width","this.parentNode.offsetWidth")}else{E.width="100%"}}else{if(!B&&h.browser.msie){if(h.css(this,"position")=="static"){this.style.position="relative"}E.position="absolute";E.top=E.left=E.right=E.padding=E.margin="0";if(j){var w=l(this,"borderLeftWidth")+l(this,"borderRightWidth");E.setExpression("width","this.parentNode.offsetWidth - "+w+'+ "px"')}else{E.width="100%"}}else{E.position="relative";E.margin=!B?"-"+z.T+"px -"+z.R+"px "+(z.T-D)+"px -"+z.L+"px":z.B-D+"px -"+z.R+"px -"+z.B+"px -"+z.L+"px"}}for(E=0;E<D;E++){w=Math.max(0,e(H,E,D));var I=A.cloneNode(false);I.style.borderWidth="0 "+(G[o+"R"]?w:0)+"px 0 "+(G[o+"L"]?w:0)+"px";B?v.appendChild(I):v.insertBefore(I,v.firstChild)}if(r&&h.support.boxModel){if(!(B&&b)){for(var u in G){if(G[u]){if(!(B&&(u=="TL"||u=="TR"))){if(!(!B&&(u=="BL"||u=="BR"))){E={position:"absolute",border:"none",margin:0,padding:0,overflow:"hidden",backgroundColor:A.style.borderColor};w=h("<div/>").css(E).css({width:D+"px",height:"1px"});switch(u){case"TL":w.css({bottom:0,left:0});break;case"TR":w.css({bottom:0,right:0});break;case"BL":w.css({top:0,left:0});break;case"BR":w.css({top:0,right:0});break}v.appendChild(w[0]);E=h("<div/>").css(E).css({top:0,bottom:0,width:"1px",height:D+"px"});switch(u){case"TL":E.css({left:D});break;case"TR":E.css({right:D});break;case"BL":E.css({left:D});break;case"BR":E.css({right:D});break}v.appendChild(E[0])}}}}}}}}}})};h.fn.uncorner=function(){if(c||f||k){this.css(c?"border-radius":f?"-moz-border-radius":"-webkit-border-radius",0)}h("div.jquery-corner",this).remove();return this};h.fn.corner.defaults={useNative:true,metaAttr:"data-corner"}})(jQuery);
