﻿(function($)
{
$.extend
(
$,
{
ZeroIfNaN:function(x){return isNaN(x)?0:x;}
}
);
})(jQuery);
(function($)
{
$.extend
(
$,
{
resizableRoundedCorners:function(options)
{
var defaults=
{
sSelector:".resizableRoundedCorners",
iImageHeight:4,
iImageWidth:5,
sCornerTopLeftImagePath:"corner-topleft.gif",
sCornerTopRightImagePath:"corner-topright.gif"
};
options=$.extend(defaults,options);
$(options.sSelector).each(function()
{
var elParent=$(this);
this._iBorderWidth=Math.round($.ZeroIfNaN(parseFloat(elParent.css('border-left-width'))));
var sBorderStyle=elParent.css('border-left-style');
var sBorderColor=elParent.css('border-left-color');
var sBackgroundColor;
elParent.css({'border-top':'none',
'padding-top':'0px'});
if(this.elRoundedTop)this.elRoundedTop.remove();
var elRoundedTop=$(document.createElement("DIV"));
elRoundedTop._iImageWidth=options.iImageWidth;
if(elParent.is('table'))
{
var elCell=$(elParent.find('th, td')[0]);
sBackgroundColor=elCell.css('background-color');
elCell.siblings().andSelf().each(function(){$(this).css({'border-top':'none',
'margin-top':'0px'});});
elRoundedTop.css({'width':(elParent.width()+(this._iBorderWidth*2)-(options.iImageWidth*2))+'px',
'padding-left':options.iImageWidth+'px',
'padding-right':options.iImageWidth+'px',
'top':'-'+options.iImageHeight+'px',
'margin-left':elParent.css('margin-left'),
'margin-right':elParent.css('margin-right'),
'float':elParent.css('float'),
'clear':elParent.css('clear'),
'position':'relative'});
elParent.css('margin-top','0px');
elParent.before(elRoundedTop);
}
else
{
elParent.css('position','relative');
sBackgroundColor=elParent.css('background-color');
this._iPadding=Math.round($.ZeroIfNaN(parseFloat(elParent.css('padding-left'))));
elRoundedTop.css({'position':'absolute',
'width':(elParent.width()+(this._iPadding*2)-(options.iImageWidth*2)+(this._iBorderWidth*2))+'px',
'padding-left':options.iImageWidth+'px',
'padding-right':options.iImageWidth+'px',
'top':'-'+options.iImageHeight+'px',
'left':'-'+this._iBorderWidth+'px'});
elParent.append(elRoundedTop);
}
this.elRoundedTop=elRoundedTop;
var elImgTopLeft=$('<img src="'+options.sCornerTopLeftImagePath
+'" border="0" alt="" style="position:absolute; top:0; left:0; z-index: 1;" />');
elRoundedTop.append(elImgTopLeft);
var elImgTopRight=$('<img src="'+options.sCornerTopRightImagePath
+'" border="0" alt="" style="position:absolute; top:0; right:0; z-index: 1;" />');
elRoundedTop.append(elImgTopRight);
var elTopBorder=$(document.createElement("DIV"))
elTopBorder.css({'position':'absolute',
'z-index':-1,
'width':(elRoundedTop.width())+'px',
'height':options.iImageHeight+'px',
'background-color':sBackgroundColor,
'border-top':this._iBorderWidth+'px '+sBorderStyle+' '+sBorderColor});
elRoundedTop.append(elTopBorder);
elRoundedTop.elTopBorder=elTopBorder;
});
if(!window._fnResizableRoundedCorners)
{
window._fnResizableRoundedCorners=
$(window).resize(
function()
{
$(document.body).find("[elRoundedTop]").each(
function()
{
var elParent=$(this);
var iNewWidth;
if(elParent.is('table'))
{
iNewWidth=elParent.width()+(this._iBorderWidth*2)-(this.elRoundedTop._iImageWidth*2);
}
else
{
iNewWidth=elParent.width()+(this._iPadding*2)-(this.elRoundedTop._iImageWidth*2)+(this._iBorderWidth*2);
}
if(Math.round(this.elRoundedTop.width())!=iNewWidth)
{
this.elRoundedTop.width(iNewWidth);
this.elRoundedTop.elTopBorder.width(iNewWidth);
}
}
);
}
);
if(window.Sys)
{
var prm=Sys.WebForms.PageRequestManager.getInstance();
if(prm)
{
prm.add_endRequest(function(){$.resizableRoundedCorners(options);});
}
}
}
}
}
);
})(jQuery);
