(function($) { $.fn.corner = function(a) { var b = { tl: { radius: 8 }, tr: { radius: 8 }, bl: { radius: 8 }, br: { radius: 8 }, antiAlias: true, autoPad: true, validTags: ["div"] }; if (a && typeof (a) != 'string') $.extend(b, a); return this.each(function() { if (!$(this).is('.hasCorners')) { $(this).addClass('hasCorners'); new curvyObject(b, this).applyCorners() } }) }; function curvyObject() { this.box = arguments[1]; this.settings = arguments[0]; this.topContainer = null; this.bottomContainer = null; this.masterCorners = new Array(); this.contentDIV = null; var G = $(this.box).css("position"); var H = $(this.box).css("backgroundImage"); this.boxHeight = strip_px($(this.box).css("height")) ? strip_px($(this.box).css("height")) : this.box.scrollHeight; this.boxWidth = strip_px($(this.box).css("width")) ? strip_px($(this.box).css("width")) : this.box.scrollWidth; this.borderWidth = strip_px($(this.box).css("borderTopWidth")) ? strip_px($(this.box).css("borderTopWidth")) : 0; this.boxPaddingTop = strip_px($(this.box).css("paddingTop")); this.boxPaddingBottom = strip_px($(this.box).css("paddingBottom")); this.boxPaddingLeft = strip_px($(this.box).css("paddingLeft")); this.boxPaddingRight = strip_px($(this.box).css("paddingRight")); this.boxColour = format_colour($(this.box).css("backgroundColor")); this.bgImage = (H != "none" && H != "initial") ? H : ""; this.boxContent = $(this.box).html(); this.borderColour = format_colour($(this.box).css("borderTopColor")); this.borderString = this.borderWidth + "px" + " solid " + this.borderColour; $(this.box).css({ "padding": "0px", "borderColor": this.borderColour, 'overflow': 'visible' }); if (G != "absolute") $(this.box).css("position", "relative"); if (($.browser.msie && $.browser.version == 6) && this.boxWidth == "auto" && this.boxHeight == "auto") $(this.box).css("width", "100%"); if (($.browser.msie)) { $(this.box).css("zoom", "1"); $(this.box + " *").css("zoom", "normal") } if (this.settings.autoPad == true) $(this.box).html(""); this.applyCorners = function() { var a = Math.max(this.settings.tl ? this.settings.tl.radius : 0, this.settings.tr ? this.settings.tr.radius : 0); var b = Math.max(this.settings.bl ? this.settings.bl.radius : 0, this.settings.br ? this.settings.br.radius : 0); for (var t = 0; t < 2; t++) { switch (t) { case 0: if (this.settings.tl || this.settings.tr) { var c = document.createElement("div"); this.topContainer = this.box.appendChild(c); $(this.topContainer).css({ width: "100%", "font-size": "1px", overflow: "hidden", position: "absolute", "padding-left": this.borderWidth, "padding-right": this.borderWidth, height: a + "px", top: 0 - a + "px", left: 0 - this.borderWidth + "px" }) }; break; case 1: if (this.settings.bl || this.settings.br) { var c = document.createElement("div"); this.bottomContainer = this.box.appendChild(c); $(this.bottomContainer).css({ width: "100%", "font-size": "1px", overflow: "hidden", position: "absolute", "padding-left": this.borderWidth, "padding-right": this.borderWidth, height: b, bottom: 0 - b + "px", left: 0 - this.borderWidth + "px" }) }; break } }; if (this.settings.autoPad == true) { var d = document.createElement("div"); var e = document.createElement("div"); var f = document.createElement("div"); $(e).css({ margin: "0", "padding-bottom": this.boxPaddingBottom, "padding-top": this.boxPaddingTop, "padding-left": this.boxPaddingLeft, "padding-right": this.boxPaddingRight }).addClass('hasBackgroundColor'); $(d).css({ position: "relative", 'float': "left", width: "100%", "margin-top": "-" + (a - this.borderWidth) + "px", "margin-bottom": "-" + (b - this.borderWidth) + "px" }).html(this.boxContent).addClass = "autoPadDiv"; $(f).css("clear", "both"); this.contentdiv = this.box.appendChild(e); e.appendChild(d); e.appendChild(f) }; if (this.topContainer) $(this.box).css("border-top", 0); if (this.bottomContainer) $(this.box).css("border-bottom", 0); var g = ["tr", "tl", "br", "bl"]; for (var i in g) { if (i > -1 < 4) { var h = g[i]; if (!this.settings[h]) { if (((h == "tr" || h == "tl") && this.topContainer != null) || ((h == "br" || h == "bl") && this.bottomContainer != null)) { var l = document.createElement("div"); $(l).css({ position: "relative", "font-size": "1px", overflow: "hidden" }); if (this.bgImage == "") $(l).css("background-color", this.boxColour); else $(l).css("background-image", this.bgImage).css("background-color", this.boxColour); switch (h) { case "tl": $(l).css({ height: a - this.borderWidth, "margin-right": this.settings.tr.radius - (this.borderWidth * 2), "border-left": this.borderString, "border-top": this.borderString, left: -this.borderWidth + "px", "background-repeat": $(this.box).css("background-repeat"), "background-position": this.borderWidth + "px 0px" }); break; case "tr": $(l).css({ height: a - this.borderWidth, "margin-left": this.settings.tl.radius - (this.borderWidth * 2), "border-right": this.borderString, "border-top": this.borderString, left: this.borderWidth + "px", "background-repeat": $(this.box).css("background-repeat"), "background-position": "-" + (a + this.borderWidth) + "px 0px" }); break; case "bl": if (a > 0) $(l).css({ height: b - this.borderWidth, "margin-right": this.settings.br.radius - (this.borderWidth * 2), "border-left": this.borderString, "border-bottom": this.borderString, left: -this.borderWidth + "px", "background-repeat": $(this.box).css("background-repeat"), "background-position": "0px -" + ($(this.box).height() + a - this.borderWidth + 1) + "px" }); else $(l).css({ height: b - this.borderWidth, "margin-right": this.settings.br.radius - (this.borderWidth * 2), "border-left": this.borderString, "border-bottom": this.borderString, left: -this.borderWidth + "px", "background-repeat": $(this.box).css("background-repeat"), "background-position": "0px -" + ($(this.box).height()) + "px" }); break; case "br": if (a > 0) $(l).css({ height: b - this.borderWidth, "margin-left": this.settings.bl.radius - (this.borderWidth * 2), "border-right": this.borderString, "border-bottom": this.borderString, left: this.borderWidth + "px", "background-repeat": $(this.box).css("background-repeat"), "background-position": "-" + this.settings.bl.radius + this.borderWidth + "px -" + ($(this.box).height() + a - this.borderWidth + 1) + "px" }); else $(l).css({ height: b - this.borderWidth, "margin-left": this.settings.bl.radius - (this.borderWidth * 2), "border-right": this.borderString, "border-bottom": this.borderString, left: this.borderWidth + "px", "background-repeat": $(this.box).css("background-repeat"), "background-position": "-" + this.settings.bl.radius + this.borderWidth + "px -" + ($(this.box).height()) + "px" }); break } } } else { if (this.masterCorners[this.settings[h].radius]) { var l = this.masterCorners[this.settings[h].radius].cloneNode(true) } else { var l = document.createElement("DIV"); $(l).css({ height: this.settings[h].radius, width: this.settings[h].radius, position: "absolute", "font-size": "1px", overflow: "hidden" }); var m = parseInt(this.settings[h].radius - this.borderWidth); for (var n = 0, j = this.settings[h].radius; n < j; n++) { if ((n + 1) >= m) var o = -1; else var o = (Math.floor(Math.sqrt(Math.pow(m, 2) - Math.pow((n + 1), 2))) - 1); if (m != j) { if ((n) >= m) var p = -1; else var p = Math.ceil(Math.sqrt(Math.pow(m, 2) - Math.pow(n, 2))); if ((n + 1) >= j) var q = -1; else var q = (Math.floor(Math.sqrt(Math.pow(j, 2) - Math.pow((n + 1), 2))) - 1) }; if ((n) >= j) var r = -1; else var r = Math.ceil(Math.sqrt(Math.pow(j, 2) - Math.pow(n, 2))); if (o > -1) this.drawPixel(n, 0, this.boxColour, 100, (o + 1), l, -1, this.settings[h].radius, 0); if (m != j) { for (var s = (o + 1); s < p; s++) { if (this.settings.antiAlias) { if (this.bgImage != "") { var u = (pixelFraction(n, s, m) * 100); if (u < 30) { this.drawPixel(n, s, this.borderColour, 100, 1, l, 0, this.settings[h].radius, 1) } else { this.drawPixel(n, s, this.borderColour, 100, 1, l, -1, this.settings[h].radius, 1) } } else { var v = BlendColour(this.boxColour, this.borderColour, pixelFraction(n, s, m)); this.drawPixel(n, s, v, 100, 1, l, 0, this.settings[h].radius, h, 1) } } }; if (this.settings.antiAlias) { if (q >= p) { if (p == -1) p = 0; this.drawPixel(n, p, this.borderColour, 100, (q - p + 1), l, 0, 0, 1) } } else { if (q >= o) { this.drawPixel(n, (o + 1), this.borderColour, 100, (q - o), l, 0, 0, 1) } }; var w = this.borderColour } else { var w = this.boxColour; var q = o }; if (this.settings.antiAlias) { for (var s = (q + 1); s < r; s++) { this.drawPixel(n, s, w, (pixelFraction(n, s, j) * 100), 1, l, ((this.borderWidth > 0) ? 0 : -1), this.settings[h].radius, 1) } } }; this.masterCorners[this.settings[h].radius] = l.cloneNode(true) }; if (h != "br") { for (var t = 0, k = l.childNodes.length; t < k; t++) { var x = l.childNodes[t]; var y = strip_px($(x).css("top")); var A = strip_px($(x).css("left")); var B = strip_px($(x).css("height")); if (h == "tl" || h == "bl") { $(x).css("left", this.settings[h].radius - A - 1 + "px") }; if (h == "tr" || h == "tl") { $(x).css("top", this.settings[h].radius - B - y + "px") }; switch (h) { case "tr": $(x).css("background-position", "-" + Math.abs((this.boxWidth - this.settings[h].radius + this.borderWidth) + A) + "px -" + Math.abs(this.settings[h].radius - B - y - this.borderWidth) + "px"); break; case "tl": $(x).css("background-position", "-" + Math.abs((this.settings[h].radius - A - 1) - this.borderWidth) + "px -" + Math.abs(this.settings[h].radius - B - y - this.borderWidth) + "px"); break; case "bl": if (a > 0) $(x).css("background-position", "-" + Math.abs((this.settings[h].radius - A - 1) - this.borderWidth) + "px -" + Math.abs(($(this.box).height() + a - this.borderWidth + 1)) + "px"); else $(x).css("background-position", "-" + Math.abs((this.settings[h].radius - A - 1) - this.borderWidth) + "px -" + Math.abs(($(this.box).height())) + "px"); break } } } }; if (l) { switch (h) { case "tl": if ($(l).css("position") == "absolute") $(l).css("top", "0"); if ($(l).css("position") == "absolute") $(l).css("left", "0"); if (this.topContainer) this.topContainer.appendChild(l); break; case "tr": if ($(l).css("position") == "absolute") $(l).css("top", "0"); if ($(l).css("position") == "absolute") $(l).css("right", "0"); if (this.topContainer) this.topContainer.appendChild(l); break; case "bl": if ($(l).css("position") == "absolute") $(l).css("bottom", "0"); if (l.style.position == "absolute") $(l).css("left", "0"); if (this.bottomContainer) this.bottomContainer.appendChild(l); break; case "br": if ($(l).css("position") == "absolute") $(l).css("bottom", "0"); if ($(l).css("position") == "absolute") $(l).css("right", "0"); if (this.bottomContainer) this.bottomContainer.appendChild(l); break } } } }; var C = new Array(); C["t"] = Math.abs(this.settings.tl.radius - this.settings.tr.radius); C["b"] = Math.abs(this.settings.bl.radius - this.settings.br.radius); for (z in C) { if (z == "t" || z == "b") { if (C[z]) { var D = ((this.settings[z + "l"].radius < this.settings[z + "r"].radius) ? z + "l" : z + "r"); var E = document.createElement("div"); $(E).css({ height: C[z], width: this.settings[D].radius + "px", position: "absolute", "font-size": "1px", overflow: "hidden", "background-color": this.boxColour }); switch (D) { case "tl": $(E).css({ "bottom": "0", "left": "0", "border-left": this.borderString }); this.topContainer.appendChild(E); break; case "tr": $(E).css({ "bottom": "0", "right": "0", "border-right": this.borderString }); this.topContainer.appendChild(E); break; case "bl": $(E).css({ "top": "0", "left": "0", "border-left": this.borderString }); this.bottomContainer.appendChild(E); break; case "br": $(E).css({ "top": "0", "right": "0", "border-right": this.borderString }); this.bottomContainer.appendChild(E); break } }; var F = document.createElement("div"); $(F).css({ position: "relative", "font-size": "1px", overflow: "hidden", "background-color": this.boxColour, "background-image": this.bgImage, "background-repeat": $(this.box).css("background-repeat") }); switch (z) { case "t": if (this.topContainer) { if (this.settings.tl.radius && this.settings.tr.radius) { $(F).css({ height: a - this.borderWidth + "px", "margin-left": this.settings.tl.radius - this.borderWidth + "px", "margin-right": this.settings.tr.radius - this.borderWidth + "px", "border-top": this.borderString }).addClass('hasBackgroundColor'); if (this.bgImage != "") $(F).css("background-position", "-" + (a + this.borderWidth) + "px 0px"); this.topContainer.appendChild(F) }; $(this.box).css("background-position", "0px -" + (a - this.borderWidth + 1) + "px") }; break; case "b": if (this.bottomContainer) { if (this.settings.bl.radius && this.settings.br.radius) { $(F).css({ height: b - this.borderWidth + "px", "margin-left": this.settings.bl.radius - this.borderWidth + "px", "margin-right": this.settings.br.radius - this.borderWidth + "px", "border-bottom": this.borderString }); if (this.bgImage != "" && a > 0) $(F).css("background-position", "-" + (this.settings.bl.radius - this.borderWidth) + "px -" + ($(this.box).height() + a - this.borderWidth + 1) + "px"); else $(F).css("background-position", "-" + (this.settings.bl.radius - this.borderWidth) + "px -" + ($(this.box).height()) + "px").addClass('hasBackgroundColor'); this.bottomContainer.appendChild(F) } }; break } } } }; this.drawPixel = function(a, b, c, d, e, f, g, h, i) { var j = document.createElement("div"); $(j).css({ height: e, width: "1px", position: "absolute", "font-size": "1px", overflow: "hidden" }); var k = Math.max(this.settings["tr"].radius, this.settings["tl"].radius); if (g == -1 && this.bgImage != "") { if (k > 0) $(j).css("background-position", "-" + ((this.boxWidth - h - this.borderWidth) + a) + "px -" + (($(this.box).height() + k - this.borderWidth) - b) + "px"); else $(j).css("background-position", "-" + ((this.boxWidth - h - this.borderWidth) + a) + "px -" + (($(this.box).height()) - b) + "px"); $(j).css({ "background-image": this.bgImage, "background-repeat": $(this.box).css("background-repeat"), "background-color": c }) } else { if (!i) $(j).css("background-color", c).addClass('hasBackgroundColor'); else $(j).css("background-color", c) }; if (d != 100) setOpacity(j, d); $(j).css({ top: b + "px", left: a + "px" }); f.appendChild(j) } }; function BlendColour(a, b, c) { var d = parseInt(a.substr(1, 2), 16); var e = parseInt(a.substr(3, 2), 16); var f = parseInt(a.substr(5, 2), 16); var g = parseInt(b.substr(1, 2), 16); var h = parseInt(b.substr(3, 2), 16); var i = parseInt(b.substr(5, 2), 16); if (c > 1 || c < 0) c = 1; var j = Math.round((d * c) + (g * (1 - c))); if (j > 255) j = 255; if (j < 0) j = 0; var k = Math.round((e * c) + (h * (1 - c))); if (k > 255) k = 255; if (k < 0) k = 0; var l = Math.round((f * c) + (i * (1 - c))); if (l > 255) l = 255; if (l < 0) l = 0; return "#" + IntToHex(j) + IntToHex(k) + IntToHex(l) }; function IntToHex(a) { base = a / 16; rem = a % 16; base = base - (rem / 16); baseS = MakeHex(base); remS = MakeHex(rem); return baseS + '' + remS }; function MakeHex(x) { if ((x >= 0) && (x <= 9)) { return x } else { switch (x) { case 10: return "A"; case 11: return "B"; case 12: return "C"; case 13: return "D"; case 14: return "E"; case 15: return "F" } } }; function pixelFraction(x, y, r) { var a = 0; var b = new Array(1); var c = new Array(1); var d = 0; var e = ""; var f = Math.sqrt((Math.pow(r, 2) - Math.pow(x, 2))); if ((f >= y) && (f < (y + 1))) { e = "Left"; b[d] = 0; c[d] = f - y; d = d + 1 }; var f = Math.sqrt((Math.pow(r, 2) - Math.pow(y + 1, 2))); if ((f >= x) && (f < (x + 1))) { e = e + "Top"; b[d] = f - x; c[d] = 1; d = d + 1 }; var f = Math.sqrt((Math.pow(r, 2) - Math.pow(x + 1, 2))); if ((f >= y) && (f < (y + 1))) { e = e + "Right"; b[d] = 1; c[d] = f - y; d = d + 1 }; var f = Math.sqrt((Math.pow(r, 2) - Math.pow(y, 2))); if ((f >= x) && (f < (x + 1))) { e = e + "Bottom"; b[d] = f - x; c[d] = 0 }; switch (e) { case "LeftRight": a = Math.min(c[0], c[1]) + ((Math.max(c[0], c[1]) - Math.min(c[0], c[1])) / 2); break; case "TopRight": a = 1 - (((1 - b[0]) * (1 - c[1])) / 2); break; case "TopBottom": a = Math.min(b[0], b[1]) + ((Math.max(b[0], b[1]) - Math.min(b[0], b[1])) / 2); break; case "LeftBottom": a = (c[0] * b[1]) / 2; break; default: a = 1 }; return a }; function rgb2Hex(a) { try { var b = rgb2Array(a); var c = parseInt(b[0]); var d = parseInt(b[1]); var f = parseInt(b[2]); var g = "#" + IntToHex(c) + IntToHex(d) + IntToHex(f) } catch (e) { alert("There was an error converting the RGB value to Hexadecimal in function rgb2Hex") }; return g }; function rgb2Array(a) { var b = a.substring(4, a.indexOf(")")); var c = b.split(", "); return c }; function setOpacity(a, b) { b = (b == 100) ? 99.999 : b; if ($.browser.safari && a.tagName != "IFRAME") { var c = rgb2Array(a.style.backgroundColor); var d = parseInt(c[0]); var e = parseInt(c[1]); var f = parseInt(c[2]); a.style.backgroundColor = "rgba(" + d + ", " + e + ", " + f + ", " + b / 100 + ")" } else if (typeof (a.style.opacity) != "undefined") { a.style.opacity = b / 100 } else if (typeof (a.style.MozOpacity) != "undefined") { a.style.MozOpacity = b / 100 } else if (typeof (a.style.filter) != "undefined") { a.style.filter = "alpha(opacity:" + b + ")" } else if (typeof (a.style.KHTMLOpacity) != "undefined") { a.style.KHTMLOpacity = b / 100 } }; function format_colour(a) { var b = "transparent"; if (a != "" && a != "transparent") { if (a.substr(0, 3) == "rgb") { b = rgb2Hex(a) } else if (a.length == 4) { b = "#" + a.substring(1, 2) + a.substring(1, 2) + a.substring(2, 3) + a.substring(2, 3) + a.substring(3, 4) + a.substring(3, 4) } else { b = a } }; return b }; function strip_px(a) { return parseInt(((a != "auto" && a.indexOf("%") == -1 && a != "" && a.indexOf("px") !== -1) ? a.slice(0, a.indexOf("px")) : 0)) } })(jQuery);