﻿/*
* jQuery Round Corners 1.0.0
* Author: Matthew Reeve
*
* Depends:
*	jquery.js
*   RoundCorners.css
*/
$.fn.roundTabCorners = function() {
    var html = '<b class="b1h"></b><b class="b2h"></b><b class="b3h"></b><b class="b4h"></b>';
    var $li = $(this).children("li");
    $li.prepend(html);
    $li.eq(0).addClass("firstTab");

    var widthOfContainer = $(this).width();
    $li.css("width", widthOfContainer / $li.length + 'px');

    var $a = $li.children("a");
    $a.wrap("<div class='headh'></div>");
    $a.click(function() {
        $(this).blur();
    });
};


$.fn.roundCorners = function(roundTop, roundBottom, color) {
    if(color === undefined)
        color = $(this).css('backgroundColor');
    var style = 'style="background-color:' + color + '"';
    $(this).wrap('<div style="width:100%; background-color:inherit"></div>');
    if (roundTop) {
        $(this).parent().prepend('<b class="rcLine1" ' + style + '></b><b class="rcLine2" ' + style + '></b><b class="rcLine3" ' + style + '></b><b class="rcLine4" ' + style + '></b>');
    }
    if (roundBottom) {
        $(this).parent().append('<b class="rcLine4" ' + style + '></b><b class="rcLine3" ' + style + '></b><b class="rcLine2" ' + style + '></b><b class="rcLine1" ' + style + '></b>');
    }
};

$.fn.removeRoundCorners = function () {
    $parent = $(this).parent().parent();
    $parent.find(".rcLine1").remove();
    $parent.find(".rcLine2").remove();
    $parent.find(".rcLine3").remove();
    $parent.find(".rcLine4").remove();
}

$.fn.roundBorderCorners = function (roundTop, roundBottom, color) {
    if (color === undefined)
        color = $(this).css('border-color');
    var style = 'style="border-color:' + color + '"';
    var style1 = 'style="background-color:' + color + ';border-color:' + color + ';"';
    $(this).wrap('<div style="width:100%; background-color:inherit"></div>');
    if (roundTop) {
        $(this).parent().prepend('<b class="b1h" ' + style1 + '></b><b class="b2h" ' + style + '></b><b class="b3h" ' + style + '></b><b class="b4h" ' + style + '></b>');
    }
    if (roundBottom) {
        $(this).parent().append('<b class="b4h" ' + style + '></b><b class="b3h" ' + style + '></b><b class="b2h" ' + style + '></b><b class="b1h" ' + style1 + '></b>');
    }
    $(this).css('border-top', '0');
    $(this).css('border-bottom', '0');
    $(this).css('border-left', '1px solid ' + color);
    $(this).css('border-right', '1px solid ' + color);
};

$.fn.roundFittedTabCorners = function() {
    var html = '<b class="b1h"></b><b class="b2h"></b><b class="b3h"></b><b class="b4h"></b>';
    var $li = $(this).children("li");
    $li.prepend(html);
    $li.eq(0).addClass("firstTab");


    var $a = $li.children("a");
    $a.wrap("<div class='headh' style='padding-left:8px;padding-right:8px;'></div>");
    $a.click(function() {
        $(this).blur();
    });
};

(function($) {
    $.fn.extend({
        roundMyCorners: function(options) {
            var defaults = {
                top: true,
                bottom: true,
                borderColor: 'red',
                topBackgroundColor: $(this).css('backgroundColor'),
                bottomBackgroundColor: $(this).css('backgroundColor'),
                border: $(this).css('borderLeft')
            };
            
            var options = $.extend(defaults, options);

            return this.each(function() {
                var o = options;
                o.width = $(this).css('width').replace("px", "");
                if (o.borderColor != "") {
                    o.width = parseInt(o.width) + 2;
                }
                var paddingLeft = parseInt($(this).css('paddingLeft').replace("px", ""));
                var paddingRight = parseInt($(this).css('paddingRight').replace("px", ""));
                o.width = (o.width + paddingLeft + paddingRight) + "px";
                o.float = $(this).css('float');
                var rcLine1Style = 'style="background-color:' + o.borderColor + ';"';
                var toprcLine2Style = 'style="background-color:' + o.topBackgroundColor + ';border-left:2px solid ' + o.borderColor + ';border-right:2px solid ' + o.borderColor + ';"';
                var toprcLine3Style = 'style="background-color:' + o.topBackgroundColor + ';border-left:1px solid ' + o.borderColor + ';border-right:1px solid ' + o.borderColor + ';"';
                var bottomrcLine2Style = 'style="background-color:' + o.bottomBackgroundColor + ';border-left:2px solid ' + o.borderColor + ';border-right:2px solid ' + o.borderColor + ';"';
                var bottomrcLine3Style = 'style="background-color:' + o.bottomBackgroundColor + ';border-left:1px solid ' + o.borderColor + ';border-right:1px solid ' + o.borderColor + ';"';
                $(this).wrap('<div style="float:' + o.float + ';width:' + o.width + '; background-color:inherit"></div>');

                if (o.top) {
                    $(this).parent().prepend('<b class="rcLine1" ' + rcLine1Style + '></b><b class="rcLine2" ' + toprcLine2Style + '></b><b class="rcLine3" ' + toprcLine3Style + '></b><b class="rcLine4" ' + toprcLine3Style + '></b>');
                }
                if (o.bottom) {
                    $(this).parent().append('<b class="rcLine4" ' + bottomrcLine3Style + '></b><b class="rcLine3" ' + bottomrcLine3Style + '></b><b class="rcLine2" ' + bottomrcLine2Style + '></b><b class="rcLine1" ' + rcLine1Style + '></b>');
                }
            });
        }
    });
})(jQuery);




