/*!
 * jQuery corner plugin: simple corner rounding
 * Examples and documentation at: http://jquery.malsup.com/corner/
 * version 2.09 (11-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
 */

/**
 *  corner() takes a single string argument:  $('#myDiv').corner("effect corners width")
 *
 *  effect:  name of the effect to apply, such as round, bevel, notch, bite, etc (default is round). 
 *  corners: one or more of: top, bottom, tr, tl, br, or bl.  (default is all corners)
 *  width:   width of the effect; in the case of rounded corners this is the radius. 
 *           specify this value using the px suffix such as 10px (yes, it must be pixels).
 */
(function(c){var a=document.createElement("div").style;var h=a.MozBorderRadius!==undefined;var j=a.WebkitBorderRadius!==undefined;var e=a.borderRadius!==undefined||a.BorderRadius!==undefined;var d=document.documentMode||0;var l=c.browser.msie&&((c.browser.version<8&&!d)||d<8);var i=c.browser.msie&&(function(){var n=document.createElement("div");try{n.style.setExpression("width","0+0");n.style.removeExpression("width")}catch(m){return false}return true})();function g(m,n){return parseInt(c.css(m,n))||0}function k(m){var m=parseInt(m).toString(16);return(m.length<2)?"0"+m:m}function b(o){while(o){var m=c.css(o,"backgroundColor");if(m&&m!="transparent"&&m!="rgba(0, 0, 0, 0)"){if(m.indexOf("rgb")>=0){var n=m.match(/\d+/g);return"#"+k(n[0])+k(n[1])+k(n[2])}return m}o=o.parentNode}return"#ffffff"}function f(o,m,n){switch(o){case"round":return Math.round(n*(1-Math.cos(Math.asin(m/n))));case"cool":return Math.round(n*(1+Math.cos(Math.asin(m/n))));case"sharp":return Math.round(n*(1-Math.cos(Math.acos(m/n))));case"bite":return Math.round(n*(Math.cos(Math.asin((n-m-1)/n))));case"slide":return Math.round(n*(Math.atan2(m,n/m)));case"jut":return Math.round(n*(Math.atan2(n,(n-m-1))));case"curl":return Math.round(n*(Math.atan(m)));case"tear":return Math.round(n*(Math.cos(m)));case"wicked":return Math.round(n*(Math.tan(m)));case"long":return Math.round(n*(Math.sqrt(m)));case"sculpt":return Math.round(n*(Math.log((n-m-1),n)));case"dogfold":case"dog":return(m&1)?(m+1):n;case"dog2":return(m&2)?(m+1):n;case"dog3":return(m&3)?(m+1):n;case"fray":return(m%2)*n;case"notch":return n;case"bevelfold":case"bevel":return m+1}}c.fn.corner=function(m){if(this.length==0){if(!c.isReady&&this.selector){var n=this.selector,o=this.context;c(function(){c(n,o).corner(m)})}return this}return this.each(function(v){var u=c(this);var D=[u.attr(c.fn.corner.defaults.metaAttr)||"",m||""].join(" ").toLowerCase();var K=/keep/.test(D);var C=((D.match(/cc:(#[0-9a-f]+)/)||[])[1]);var p=((D.match(/sc:(#[0-9a-f]+)/)||[])[1]);var G=parseInt((D.match(/(\d+)px/)||[])[1])||10;var E=/round|bevelfold|bevel|notch|bite|cool|sharp|slide|jut|curl|tear|fray|wicked|sculpt|long|dog3|dog2|dogfold|dog/;var r=((D.match(E)||["round"])[0]);var s=/dogfold|bevelfold/.test(D);var q={T:0,B:1};var z={TL:/top|tl|left/.test(D),TR:/top|tr|right/.test(D),BL:/bottom|bl|left/.test(D),BR:/bottom|br|right/.test(D)};if(!z.TL&&!z.TR&&!z.BL&&!z.BR){z={TL:1,TR:1,BL:1,BR:1}}if(c.fn.corner.defaults.useNative&&r=="round"&&(e||h||j)&&!C&&!p){if(z.TL){u.css(e?"border-top-left-radius":h?"-moz-border-radius-topleft":"-webkit-border-top-left-radius",G+"px")}if(z.TR){u.css(e?"border-top-right-radius":h?"-moz-border-radius-topright":"-webkit-border-top-right-radius",G+"px")}if(z.BL){u.css(e?"border-bottom-left-radius":h?"-moz-border-radius-bottomleft":"-webkit-border-bottom-left-radius",G+"px")}if(z.BR){u.css(e?"border-bottom-right-radius":h?"-moz-border-radius-bottomright":"-webkit-border-bottom-right-radius",G+"px")}return}var H=document.createElement("div");c(H).css({overflow:"hidden",height:"1px",minHeight:"1px",fontSize:"1px",backgroundColor:p||"transparent",borderStyle:"solid"});var N={T:parseInt(c.css(this,"paddingTop"))||0,R:parseInt(c.css(this,"paddingRight"))||0,B:parseInt(c.css(this,"paddingBottom"))||0,L:parseInt(c.css(this,"paddingLeft"))||0};if(typeof this.style.zoom!=undefined){this.style.zoom=1}if(!K){this.style.border="none"}H.style.borderColor=C||b(this.parentNode);var F=c(this).outerHeight();for(var I in q){var y=q[I];if((y&&(z.BL||z.BR))||(!y&&(z.TL||z.TR))){H.style.borderStyle="none "+(z[I+"R"]?"solid":"none")+" none "+(z[I+"L"]?"solid":"none");var O=document.createElement("div");c(O).addClass("jquery-corner");var B=O.style;y?this.appendChild(O):this.insertBefore(O,this.firstChild);if(y&&F!="auto"){if(c.css(this,"position")=="static"){this.style.position="relative"}B.position="absolute";B.bottom=B.left=B.padding=B.margin="0";if(i){B.setExpression("width","this.parentNode.offsetWidth")}else{B.width="100%"}}else{if(!y&&c.browser.msie){if(c.css(this,"position")=="static"){this.style.position="relative"}B.position="absolute";B.top=B.left=B.right=B.padding=B.margin="0";if(i){var L=g(this,"borderLeftWidth")+g(this,"borderRightWidth");B.setExpression("width","this.parentNode.offsetWidth - "+L+'+ "px"')}else{B.width="100%"}}else{B.position="relative";B.margin=!y?"-"+N.T+"px -"+N.R+"px "+(N.T-G)+"px -"+N.L+"px":(N.B-G)+"px -"+N.R+"px -"+N.B+"px -"+N.L+"px"}}for(var J=0;J<G;J++){var x=Math.max(0,f(r,J,G));var M=H.cloneNode(false);M.style.borderWidth="0 "+(z[I+"R"]?x:0)+"px 0 "+(z[I+"L"]?x:0)+"px";y?O.appendChild(M):O.insertBefore(M,O.firstChild)}if(s&&c.support.boxModel){if(y&&l){continue}for(var P in z){if(!z[P]){continue}if(y&&(P=="TL"||P=="TR")){continue}if(!y&&(P=="BL"||P=="BR")){continue}var A={position:"absolute",border:"none",margin:0,padding:0,overflow:"hidden",backgroundColor:H.style.borderColor};var t=c("<div/>").css(A).css({width:G+"px",height:"1px"});switch(P){case"TL":t.css({bottom:0,left:0});break;case"TR":t.css({bottom:0,right:0});break;case"BL":t.css({top:0,left:0});break;case"BR":t.css({top:0,right:0});break}O.appendChild(t[0]);var Q=c("<div/>").css(A).css({top:0,bottom:0,width:"1px",height:G+"px"});switch(P){case"TL":Q.css({left:G});break;case"TR":Q.css({right:G});break;case"BL":Q.css({left:G});break;case"BR":Q.css({right:G});break}O.appendChild(Q[0])}}}}})};c.fn.uncorner=function(){if(e||h||j){this.css(e?"border-radius":h?"-moz-border-radius":"-webkit-border-radius",0)}c("div.jquery-corner",this).remove();return this};c.fn.corner.defaults={useNative:true,metaAttr:"data-corner"}})(jQuery);
