/*
 * jQuery Plugin: DivCorners
 * http://www.roydukkey.com/divcorners
 *
 * Copyright (c) 2009 Rory Dueck
 *
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 *
 * Date: 2009-09-01 (Tue, 01 Sept 2009)
 * Version: 1.5.1
 */
(function($){var dc={dcCreate:function(s,e){var o=$.extend({imgPrefix:"/images/",fileType:".gif",expand:10,radius:0,position:"inside",resize:"",exclude:""},s);o.e=$.isArray(o.expand)?o.expand.length==2?{t:o.expand[0],r:o.expand[1],b:o.expand[0],l:o.expand[1]}:{t:o.expand[0],r:o.expand[1],b:o.expand[2],l:o.expand[3]}:{t:o.expand,r:o.expand,b:o.expand,l:o.expand};o.r=$.isArray(o.radius)?o.radius.length==2?{t:o.radius[0]>o.e.t?o.radius[0]-o.e.t:0,r:o.radius[1]>o.e.r?o.radius[1]-o.e.r:0,b:o.radius[0]>o.e.b?o.radius[0]-o.e.b:0,l:o.radius[1]>o.e.l?o.radius[1]-o.e.l:0}:{t:o.radius[0]>o.e.t?o.radius[0]-o.e.t:0,r:o.radius[1]>o.e.r?o.radius[1]-o.e.r:0,b:o.radius[2]>o.e.b?o.radius[2]-o.e.b:0,l:o.radius[3]>o.e.l?o.radius[3]-o.e.l:0}:{t:o.radius>o.e.t?o.radius-o.e.t:0,r:o.radius>o.e.r?o.radius-o.e.r:0,b:o.radius>o.e.b?o.radius-o.e.b:0,l:o.radius>o.e.l?o.radius-o.e.l:0};o.x=o.exclude.replace(/\s/g,"").split(",");return this.each(function(){var g=$(this),u=g.find(">.dcContent"),x,a,v,y,b,c;g.addClass("dCorner").css({"height":g.height(),"width":g.width()});u.css({"height":u.height(),"width":u.width()});if(o.resize!="")g.find(o.resize).each(function(){$(this).load(function(){$(this).parents(".dCorner").dcResize("r")})});for(x in a=[["t","top"],["r","right"],["b","bottom"],["l","left"]]){v=g.append('<div class="dcItem dc'+a[x][1]+'">'+($.inArray(a[x][1],o.x)==-1?'<img src="'+o.imgPrefix+a[x][1]+o.fileType+'" />':"")+"</div>").find(">.dc"+a[x][1]);if(x!=1&&x!=3){o.position=="inside"?v.css("margin-left",o.e.l+o.r.l).width(g.innerWidth()-(o.r.l+o.e.l+o.r.r+o.e.r)):v.css(a[x][1],-eval("o.e."+a[x][0])).css("margin-left",o.r.l).width(g.innerWidth()-(o.r.l+o.r.r));v.height(eval("o.e."+a[x][0])).css("display","block");for(y in b=[["l","left"],["r","right"]]){c=g.append('<div class="dcItem dc'+a[x][1]+"-"+b[y][1]+'">'+($.inArray(a[x][1]+"-"+b[y][1],o.x)==-1?'<img src="'+o.imgPrefix+a[x][1]+"-"+b[y][1]+o.fileType+'" />':"")+"</div>").find(">.dc"+a[x][1]+"-"+b[y][1]);if(o.position!="inside")c.css(a[x][1],-eval("o.e."+a[x][0])).css(b[y][1],-eval("o.e."+b[y][0]));c.height(eval("o.e."+a[x][0])+eval("o.r."+a[x][0])).width(eval("o.e."+b[y][0])+eval("o.r."+b[y][0])).css("display","block");if($.inArray(a[x][1]+"-"+b[y][1],o.x)==-1)png(c,o.fileType)}}else{o.position=="inside"?v.css("margin-top",o.e.t+o.r.t).height(g.innerHeight()-(o.r.t+o.e.t+o.r.b+o.e.b)):v.css(a[x][1],-eval("o.e."+a[x][0])).css("margin-top",o.r.t).height(g.innerHeight()-(o.r.t+o.r.b));v.width(eval("o.e."+a[x][0])).css("display","block")}if($.inArray(a[x][1],o.x)==-1)png(v,o.fileType)}widthFix(g);if(e!=false)g.parents(".dCorner").dcResize("r")})},dcResize:function(e){return this.each(function(){var g=$(this),c=g.find(">.dctop-left"),d=g.find(">.dctop-right");if(g.hasClass("dCorner")){g.css("zoom","0");if(e=="r")g.css({"height":"","width":""});g.find(">.dctop,>.dcbottom").width(g.innerWidth()-(c.width()+parseInt(c.css("left").replace("px"))+d.width()+parseInt(d.css("right").replace("px"))));g.find(">.dcleft,>.dcright").height(g.innerHeight()-(c.height()+parseInt(c.css("top").replace("px"))+(d=g.find(">.dcbottom-left")).height()+parseInt(d.css("bottom").replace("px"))));widthFix(g);if(e == "r")g.css({"height":g.height(),"width":g.width()});g.css("zoom","1");if(e!=false)g.parents(".dCorner").dcResize("r")}})},dcClear:function(e){return this.each(function(){$(this).removeClass("dCorner").find(">.dcItem").remove();if(e!=false)$(this).parents(".dCorner").dcResize("r")})}};$.each(dc,function(i){$.fn[i]=this});function png(p,n){if($.browser.msie&&n==".png"){var i=(p=$(p)).find("img");p.css("filter","progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+i.attr("src")+"',sizingMethod='scale')");i.css("filter","alpha(opacity=0)")}}function widthFix(c){if($.browser.version<7.0&&$.browser.msie){with(c){find(">.dctop-right,>.dcright,>.dcbottom-right").css("margin-right",innerWidth()%2!=0?"-1px":"0px");find(">.dcbottom-left,>.dcbottom,>.dcbottom-right").css("margin-bottom",innerHeight()%2!=0?"-1px":"0px")}}}})(jQuery);