/*!
 * 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(d){function u(f,a){return parseInt(d.css(f,a))||0}function r(f){f=parseInt(f).toString(16);return f.length<2?"0"+f:f}function z(f){for(;f&&f.nodeName.toLowerCase()!="html";f=f.parentNode){var a=d.css(f,"backgroundColor");if(a!="rgba(0, 0, 0, 0)"){if(a.indexOf("rgb")>=0){f=a.match(/\d+/g);return"#"+r(f[0])+r(f[1])+r(f[2])}if(a&&a!="transparent")return a}}return"#ffffff"}function A(f,a,e){switch(f){case "round":return Math.round(e*(1-Math.cos(Math.asin(a/e))));case "cool":return Math.round(e*
(1+Math.cos(Math.asin(a/e))));case "sharp":return Math.round(e*(1-Math.cos(Math.acos(a/e))));case "bite":return Math.round(e*Math.cos(Math.asin((e-a-1)/e)));case "slide":return Math.round(e*Math.atan2(a,e/a));case "jut":return Math.round(e*Math.atan2(e,e-a-1));case "curl":return Math.round(e*Math.atan(a));case "tear":return Math.round(e*Math.cos(a));case "wicked":return Math.round(e*Math.tan(a));case "long":return Math.round(e*Math.sqrt(a));case "sculpt":return Math.round(e*Math.log(e-a-1,e));case "dogfold":case "dog":return a&
1?a+1:e;case "dog2":return a&2?a+1:e;case "dog3":return a&3?a+1:e;case "fray":return a%2*e;case "notch":return e;case "bevelfold":case "bevel":return a+1}}var m=document.createElement("div").style,n=m.MozBorderRadius!==undefined,v=m.WebkitBorderRadius!==undefined,o=m.borderRadius!==undefined||m.BorderRadius!==undefined;m=document.documentMode||0;var B=d.browser.msie&&(d.browser.version<8&&!m||m<8),w=d.browser.msie&&function(){var f=document.createElement("div");try{f.style.setExpression("width","0+0");
f.style.removeExpression("width")}catch(a){return false}return true}();d.fn.corner=function(f){if(this.length==0){if(!d.isReady&&this.selector){var a=this.selector,e=this.context;d(function(){d(a,e).corner(f)})}return this}return this.each(function(){var i=d(this),b=[i.attr(d.fn.corner.defaults.metaAttr)||"",f||""].join(" ").toLowerCase(),s=/keep/.test(b),h=(b.match(/cc:(#[0-9a-f]+)/)||[])[1],j=(b.match(/sc:(#[0-9a-f]+)/)||[])[1],g=parseInt((b.match(/(\d+)px/)||[])[1])||10,x=(b.match(/round|bevelfold|bevel|notch|bite|cool|sharp|slide|jut|curl|tear|fray|wicked|sculpt|long|dog3|dog2|dogfold|dog/)||
["round"])[0],C=/dogfold|bevelfold/.test(b),y={T:0,B:1};b={TL:/top|tl|left/.test(b),TR:/top|tr|right/.test(b),BL:/bottom|bl|left/.test(b),BR:/bottom|br|right/.test(b)};if(!b.TL&&!b.TR&&!b.BL&&!b.BR)b={TL:1,TR:1,BL:1,BR:1};if(d.fn.corner.defaults.useNative&&x=="round"&&(o||n||v)&&!h&&!j){if(b.TL)i.css(o?"border-top-left-radius":n?"-moz-border-radius-topleft":"-webkit-border-top-left-radius",g+"px");if(b.TR)i.css(o?"border-top-right-radius":n?"-moz-border-radius-topright":"-webkit-border-top-right-radius",
g+"px");if(b.BL)i.css(o?"border-bottom-left-radius":n?"-moz-border-radius-bottomleft":"-webkit-border-bottom-left-radius",g+"px");if(b.BR)i.css(o?"border-bottom-right-radius":n?"-moz-border-radius-bottomright":"-webkit-border-bottom-right-radius",g+"px")}else{i=document.createElement("div");d(i).css({overflow:"hidden",height:"1px",minHeight:"1px",fontSize:"1px",backgroundColor:j||"transparent",borderStyle:"solid"});j={T:parseInt(d.css(this,"paddingTop"))||0,R:parseInt(d.css(this,"paddingRight"))||
0,B:parseInt(d.css(this,"paddingBottom"))||0,L:parseInt(d.css(this,"paddingLeft"))||0};if(typeof this.style.zoom!=undefined)this.style.zoom=1;if(!s)this.style.border="none";i.style.borderColor=h||z(this.parentNode);s=d(this).outerHeight();for(var q in y)if((h=y[q])&&(b.BL||b.BR)||!h&&(b.TL||b.TR)){i.style.borderStyle="none "+(b[q+"R"]?"solid":"none")+" none "+(b[q+"L"]?"solid":"none");var l=document.createElement("div");d(l).addClass("jquery-corner");var c=l.style;h?this.appendChild(l):this.insertBefore(l,
this.firstChild);if(h&&s!="auto"){if(d.css(this,"position")=="static")this.style.position="relative";c.position="absolute";c.bottom=c.left=c.padding=c.margin="0";if(w)c.setExpression("width","this.parentNode.offsetWidth");else c.width="100%"}else if(!h&&d.browser.msie){if(d.css(this,"position")=="static")this.style.position="relative";c.position="absolute";c.top=c.left=c.right=c.padding=c.margin="0";if(w){var k=u(this,"borderLeftWidth")+u(this,"borderRightWidth");c.setExpression("width","this.parentNode.offsetWidth - "+
k+'+ "px"')}else c.width="100%"}else{c.position="relative";c.margin=!h?"-"+j.T+"px -"+j.R+"px "+(j.T-g)+"px -"+j.L+"px":j.B-g+"px -"+j.R+"px -"+j.B+"px -"+j.L+"px"}for(c=0;c<g;c++){k=Math.max(0,A(x,c,g));var t=i.cloneNode(false);t.style.borderWidth="0 "+(b[q+"R"]?k:0)+"px 0 "+(b[q+"L"]?k:0)+"px";h?l.appendChild(t):l.insertBefore(t,l.firstChild)}if(C&&d.support.boxModel)if(!(h&&B))for(var p in b)if(b[p])if(!(h&&(p=="TL"||p=="TR")))if(!(!h&&(p=="BL"||p=="BR"))){c={position:"absolute",border:"none",
margin:0,padding:0,overflow:"hidden",backgroundColor:i.style.borderColor};k=d("<div/>").css(c).css({width:g+"px",height:"1px"});switch(p){case "TL":k.css({bottom:0,left:0});break;case "TR":k.css({bottom:0,right:0});break;case "BL":k.css({top:0,left:0});break;case "BR":k.css({top:0,right:0});break}l.appendChild(k[0]);c=d("<div/>").css(c).css({top:0,bottom:0,width:"1px",height:g+"px"});switch(p){case "TL":c.css({left:g});break;case "TR":c.css({right:g});break;case "BL":c.css({left:g});break;case "BR":c.css({right:g});
break}l.appendChild(c[0])}}}})};d.fn.uncorner=function(){if(o||n||v)this.css(o?"border-radius":n?"-moz-border-radius":"-webkit-border-radius",0);d("div.jquery-corner",this).remove();return this};d.fn.corner.defaults={useNative:true,metaAttr:"data-corner"}})(jQuery);
