/** * corner.js 2.1 (22-apr-2011) (c) by christian effenberger * all rights reserved. source: corner.netzgesta.de * distributed under netzgestade software license agreement. * this license permits free of charge use on non-commercial * and private web sites only under special conditions. * read more at... http://www.netzgesta.de/cvi/license.html * commercial licenses available via... cvi[at]netzgesta[dot]de **/ var tmp = navigator.appname == 'microsoft internet explorer' && navigator.useragent.indexof('opera') < 1 ? 1 : 0; if(tmp) var isie = document.namespaces && ( !document.documentmode || document.documentmode < 9 ) ? 1 : 0; if(isie) { if(document.namespaces['v']==null) { var e=["shape","shapetype","group","background","path","formulas","handles","fill","stroke","shadow","textbox","textpath","imagedata","line","polyline","curve","roundrect","oval","rect","arc","image"],s=document.createstylesheet(); for(var i=0; i0?0.25:0.2); tmp.addcolorstop(0,'rgba('+color+','+color+','+color+',0.9)'); tmp.addcolorstop(val,'rgba('+color+','+color+','+color+','+opacity+')'); tmp.addcolorstop(0.75,'rgba('+color+','+color+','+color+',0)'); tmp.addcolorstop(1,'rgba('+color+','+color+','+color+',0)'); return tmp; } function addradialstyle(ctx,x1,y1,r1,x2,y2,r2,opacity) { var tmp = ctx.createradialgradient(x1,y1,r1,x2,y2,r2); var opt = math.min(parsefloat(opacity+0.1),1.0); tmp.addcolorstop(0,'rgba(0,0,0,'+opt+')'); tmp.addcolorstop(0.25,'rgba(0,0,0,'+opacity+')'); tmp.addcolorstop(1,'rgba(0,0,0,0)'); return tmp; } function addlinearstyle(ctx,x,y,w,h,opacity) { var tmp = ctx.createlineargradient(x,y,w,h); var opt = math.min(parsefloat(opacity+0.1),1.0); tmp.addcolorstop(0,'rgba(0,0,0,'+opt+')'); tmp.addcolorstop(0.25,'rgba(0,0,0,'+opacity+')'); tmp.addcolorstop(1,'rgba(0,0,0,0)'); return tmp; } function addshine(ctx,width,height,radius,opacity,extra) { var style; var color = (extra!=1?254:0); style = addgradient(ctx,0,radius,radius,radius,color,opacity); ctx.beginpath(); ctx.moveto(0,0); ctx.lineto(0,height); ctx.lineto(radius,height); ctx.lineto(radius,radius); ctx.closepath(); ctx.fillstyle = style; ctx.fill(); style = addgradient(ctx,radius,0,radius,radius,color,opacity); ctx.beginpath(); ctx.moveto(0,0); ctx.lineto(width,0); ctx.lineto(width,radius); ctx.lineto(radius,radius); ctx.closepath(); ctx.fillstyle = style; ctx.fill(); } function addshade(ctx,width,height,radius,opacity) { var style; style = addgradient(ctx,width,radius,width-radius,radius,0,opacity); ctx.beginpath(); ctx.moveto(width,0); ctx.lineto(width,height); ctx.lineto(width-radius,height-radius); ctx.lineto(width-radius,0); ctx.closepath(); ctx.fillstyle = style; ctx.fill(); style = addgradient(ctx,radius,height,radius,height-radius,0,opacity); ctx.beginpath(); ctx.moveto(width,height); ctx.lineto(0,height); ctx.lineto(0,height-radius); ctx.lineto(width-radius,height-radius); ctx.closepath(); ctx.fillstyle = style; ctx.fill(); } function roundedshadow(ctx,x,y,width,height,radius,opacity){ var style; ctx.beginpath(); ctx.rect(x,y+height-radius,radius,radius); ctx.closepath(); style = addradialstyle(ctx,x+radius,y+height-radius,radius-x,x+radius,y+height-radius,radius,opacity); ctx.fillstyle = style; ctx.fill(); ctx.beginpath(); ctx.rect(x+radius,y+height-y,width-(radius*2.25),y); ctx.closepath(); style = addlinearstyle(ctx,x+radius,y+height-y,x+radius,y+height,opacity); ctx.fillstyle = style; ctx.fill(); ctx.beginpath(); ctx.rect(x+width-(radius*1.25),y+height-(radius*1.25),radius*1.25,radius*1.25); ctx.closepath(); style = addradialstyle(ctx,x+width-(radius*1.25),y+height-(radius*1.25),(radius*1.25)-1.5-x,x+width-(radius*1.25),y+height-(radius*1.25),radius*1.25,opacity); ctx.fillstyle = style; ctx.fill(); ctx.beginpath(); ctx.rect(x+width-x,y+radius,x,height-(radius*2.25)); ctx.closepath(); style = addlinearstyle(ctx,x+width-x,y+radius,x+width,y+radius,opacity); ctx.fillstyle = style; ctx.fill(); ctx.beginpath(); ctx.rect(x+width-radius,y,radius,radius); ctx.closepath(); style = addradialstyle(ctx,x+width-radius,y+radius,radius-x,x+width-radius,y+radius,radius,opacity); ctx.fillstyle = style; ctx.fill(); } function addiecorners() { var theimages = getimages('corner'); var image; var object; var vml; var div; var pos; var i; var classes = ''; var iradius = null; var ishadow = null; var ishade = null; var inverse = null; var newclasses = ''; var maxdim = null; var offset = null; var radius = null; var display = ""; var flt = null; var width = null; var height = null; var start, head, soft, shadow, fill, foot, end; var left, top, bottom, right, lt, br, linear, inset; for (i=0;i0?(inverse>0?0:math.min(math.max(offset,iradius/2),16)):0); radius = getradius(iradius,width,height); display = (image.currentstyle.display.tolowercase()=='block')?'block':'inline-block'; vml = document.createelement([''].join('')); flt = image.currentstyle.stylefloat.tolowercase(); display = (flt=='left'||flt=='right')?'inline-block':display; start = ''; fill = ''; foot = (iradius>0?'':''); end = ''; soft = ''; shadow = ''; lt = ''; left = ''; top = ''; bottom = ''; right = ''; if(iradius<=0) { if (ishadow>0) { if(inverse<=0) { ishadow = ishadow/50; offset = 8; inset = 4; soft = ''; head = ''; }else if(inverse>0) { ishadow = ishadow/50; iradius = 12; linear = "linear"; head = ''; shadow = ''; top = ''; left = ''; } }else { head = ''; } if(ishade>0) { ishade = ishade/50; iradius = 12; top = ''; left = ''; bottom = ''; right = ''; } } else { if(ishadow>0) { linear = "linear sigma"; pos = 2; if(inverse<=0) { ishadow = ishadow/50; inset = math.round(offset*0.5); soft = ''; head = ''; }else if(inverse>0) { ishadow = ishadow/50; head = ''; shadow = ''; top = ''; left = ''; lt = ''; } }else { pos = 1; offset = 0; head = ''; } if(ishade>0) { ishade = ishade/50; linear = "linear"; top = ''; left = ''; lt = ''; } } vml.innerhtml = start + soft + head + fill + shadow + foot + right + bottom + top + left + lt + end; vml.classname = newclasses; vml.style.csstext = image.style.csstext; vml.style.height = image.height+'px'; vml.style.width = image.width+'px'; vml.height = image.height; vml.width = image.width; vml.src = image.src; vml.alt = image.alt; if(image.id!='') vml.id = image.id; if(image.title!='') vml.title = image.title; if(image.getattribute('onclick')!='') vml.setattribute('onclick',image.getattribute('onclick')); if(image.getattribute("usemap")) { if (iradius>0){pos = offset;}else {pos = 0;} object.style.position = 'relative'; object.style.height = height+'px'; object.style.width = width+'px'; image.left = 0; image.top = 0; image.style.position = 'absolute'; image.style.height = height+'px'; image.style.width = width+'px'; image.style.left = 0 + 'px'; image.style.top = 0 + 'px'; image.style.filter = "alpha(opacity=0)"; object.insertbefore(vml,image); }else { object.replacechild(vml,image); } } } function addcorners() { var theimages = getimages('corner'); var image; var object; var canvas; var context; var i; var iradius = null; var ishade = null; var ishadow = null; var inverse = null; var classes = ''; var newclasses = ''; var maxdim = null; var style = null; var offset = null; for (i=0;i0?(inverse>0?0:math.min(math.max(offset,iradius/2),16)):0); context = canvas.getcontext("2d"); if(image.getattribute("usemap")) { object.style.position = 'relative'; object.style.height = image.height+'px'; object.style.width = image.width+'px'; canvas.left = 0; canvas.top = 0; canvas.style.position = 'absolute'; canvas.style.left = 0 + 'px'; canvas.style.top = 0 + 'px'; image.left = 0; image.top = 0; image.style.position = 'absolute'; image.style.height = image.height+'px'; image.style.width = image.width+'px'; image.style.left = 0 + 'px'; image.style.top = 0 + 'px'; image.style.opacity = 0; object.insertbefore(canvas,image); }else { object.replacechild(canvas,image); } context.clearrect(0,0,canvas.width,canvas.height); context.save(); if (ishadow>0 && inverse<=0) { ishadow = ishadow/100; if (iradius>0) { roundedshadow(context,offset,offset,canvas.width-offset,canvas.height-offset,iradius,ishadow); }else { offset = 8; roundedshadow(context,offset,offset,canvas.width-offset,canvas.height-offset,offset,ishadow); } } if (iradius<=0) { context.beginpath(); context.rect(0,0,canvas.width-offset,canvas.height-offset); context.closepath(); }else { roundedrect(context,0,0,canvas.width-offset,canvas.height-offset,iradius); } context.clip(); context.fillstyle = 'rgba(0,0,0,0)'; context.fillrect(0,0,canvas.width,canvas.height); context.drawimage(image,0,0,canvas.width-offset,canvas.height-offset); if (ishadow>0 && inverse>0) { ishadow = ishadow/100; if (iradius>0) { addshine(context,canvas.width,canvas.height,iradius,ishadow,1); roundedrect(context,0,0,canvas.width,canvas.height,iradius); }else { iradius = 16; addshine(context,canvas.width,canvas.height,iradius,ishadow,1); context.beginpath(); context.rect(0,0,canvas.width,canvas.height); context.closepath(); } context.strokestyle = 'rgba(0,0,0,'+ishadow+')'; context.linewidth = 2; context.stroke(); } if (ishade>0) { ishade = ishade/100; if (iradius<=0) iradius = 16; addshade(context,canvas.width-offset,canvas.height-offset,iradius,ishade); addshine(context,canvas.width-offset,canvas.height-offset,iradius,ishade); } canvas.style.visibility = 'visible'; } } } if(window.addeventlistener) window.addeventlistener("load",addcorners,false); else window.attachevent("onload",addiecorners);