// jquery-roundcorners-canvas
// www.meerbox.nl

(function($){

	var _corner = function(options) {

		// nothing to do, so return
		if (this.length==0) return this;

		// excanvas.js not loaded
		if ($.browser.msie && typeof G_vmlCanvasManager == 'undefined') return this;

		// get lowest number from array
		var asNum = function(a, b) { return a-b; };
		var getMin = function(a) {
			var b = a.concat();
			return b.sort(asNum)[0];
		};

		// get CSS value as integer
		var getCSSint = function(el, prop) {
			return parseInt($.css(el.jquery?el[0]:el,prop))||0;
		};

		// draw the round corner in Canvas object
		var drawRoundCornerCanvasShape = function(canvas,radius,r_type,bg_color,border_width,border_color) {

			// change rgba(1,2,3,0.9) to rgb(1,2,3)
			var reg = /^rgba\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/;
			var bits = reg.exec(bg_color);
			if (bits) {
				channels = new Array(parseInt(bits[1]),parseInt(bits[2]),parseInt(bits[3]));
				bg_color = 'rgb('+channels[0]+', '+channels[1]+', '+channels[2]+')';
			}

			var border_width = parseInt(border_width);

			var ctx = canvas.getContext('2d');

			if (radius == 1) {
				ctx.fillStyle = bg_color;
				ctx.fillRect(0,0,1,1);
				return;
			}

			if (r_type == 'tl') {
				var steps = new Array(0,0,radius,0,radius,0,0,radius,0,0);
			} else if (r_type == 'tr') {
				var steps = new Array(radius,0,radius,radius,radius,0,0,0,0,0);
			} else if (r_type == 'bl') {
				var steps = new Array(0,radius,radius,radius,0,radius,0,0,0,radius);
			} else if (r_type == 'br') {
				var steps = new Array(radius,radius,radius,0,radius,0,0,radius,radius,radius);
			}

			ctx.fillStyle = bg_color;
	    	ctx.beginPath();
	     	ctx.moveTo(steps[0],steps[1]);
	     	ctx.lineTo(steps[2], steps[3]);
	    	if(r_type == 'br') ctx.bezierCurveTo(steps[4], steps[5], radius, radius, steps[6], steps[7]);
	    	else ctx.bezierCurveTo(steps[4], steps[5], 0, 0, steps[6], steps[7]);
			ctx.lineTo(steps[8], steps[9]);
	        ctx.fill();

	        // draw border
	        if (border_width > 0 && border_width < radius) {

		        // offset caused by border
		        var offset = border_width/2;

		        if (r_type == 'tl') {
					var steps = new Array(radius-offset,offset,radius-offset,offset,offset,radius-offset);
					var curve_to = new Array(0,0);
				} else if (r_type == 'tr') {
					var steps = new Array(radius-offset,radius-offset,radius-offset,offset,offset,offset);
					var curve_to = new Array(0,0);
				} else if (r_type == 'bl') {
					var steps = new Array(radius-offset,radius-offset,offset,radius-offset,offset,offset,offset,radius-offset);
					var curve_to = new Array(0,0);
				} else if (r_type == 'br') {
					var steps = new Array(radius-offset,offset,radius-offset,offset,offset,radius-offset,radius-offset,radius-offset);
					var curve_to = new Array(radius, radius);
				}

		        ctx.strokeStyle = border_color;
		        ctx.lineWidth = border_width;
	    		ctx.beginPath();
	    		// go to corner to begin curve
	     		ctx.moveTo(steps[0], steps[1]);
	     		// curve from righttop to leftbottom (for the tl canvas)
	    		ctx.bezierCurveTo(steps[2], steps[3], curve_to[0], curve_to[1], steps[4], steps[5]);
				ctx.stroke();

		    }
		};

		var creatCanvas = function(p,radius) {
			var elm = document.createElement('canvas');
			elm.setAttribute("height", radius);
    		elm.setAttribute("width", radius);
			elm.style.display = "block";
			elm.style.position = "absolute";
			elm.className = "cornercanvas";
			elm = p.appendChild(elm);
			if (!elm.getContext && typeof G_vmlCanvasManager != 'undefined') {
				elm = G_vmlCanvasManager.initElement(elm);
			}
			return elm;
		};

		// interpret the (string) argument
   		var o = (options || "").toLowerCase();
   		var radius = parseInt((o.match(/(\d+)px/)||[])[1]) || null; // corner width
   		var bg_color = ((o.match(/(#[0-9a-f]+)/)||[])[1]);  // strip color
   		if (radius == null) { radius = "auto"; }

   		var edges = { T:0, B:1 };
    	var opts = {
        	tl:  /top|tl/.test(o),
        	tr:  /top|tr/.test(o),
        	bl:  /bottom|bl/.test(o),
        	br:  /bottom|br/.test(o)
    	};
    	if ( !opts.tl && !opts.tr && !opts.bl && !opts.br) {
        	opts = { tl:1, tr:1, bl:1, br:1 };
        }

		return this.each(function() {

			var elm = $(this);
			var hover = /hover/.test(o);

			if (hover) {

				options = options.replace(/hover/i, "");

				elm.hover(function(){
					$(this).addClass('jrcHover');
					$(this).corner(options);
				},function(){
					$(this).removeClass('jrcHover');
					$(this).corner(options);
				});

			}

	   		if ($.browser.msie) {

		   		// give element 'haslayout'
		   		elm.css('zoom','1');
		   		// give the child elements 'haslayout'
		   		elm.children().css('zoom','1');

		   		// msie6 rendering bugs :(
				if ($.browser.msie && typeof document.body.style.maxHeight == "undefined") {
					if (elm.css('height') == 'auto') elm.height(elm.height());
				 	if (elm.width()%2 != 0) { elm.width(elm.width()+1); }
				 	if (elm.height()%2 != 0) { elm.height(elm.height()+1); }
				 	if (elm.css('lineHeight') != 'normal' && elm.height() < elm.css('lineHeight')) {
					 	elm.css('lineHeight', elm.height());
					}
					if (elm.css('lineHeight') == 'normal') elm.css('lineHeight','1'); // dont ask
				}
		   	}

			var arr = new Array(elm.get(0).offsetHeight,elm.get(0).offsetWidth);
			if (elm.height() != 0) arr[arr.length] = elm.height();
			if (elm.width() != 0) arr[arr.length] = elm.width();
			var widthheight_smallest = getMin(arr);

			// the size of the corner is not defined...
			if (radius == "auto") {
				radius = widthheight_smallest/2;
				if (radius > 10) { radius = 10; }
			}

			// the size of the corner can't be to high
			if (radius > widthheight_smallest/2) {
				radius = (widthheight_smallest/2);
			}

			radius = Math.floor(radius);

			// some css thats required in order to position the canvas elements
			if (elm.css('position') == 'static') {
				elm.css('position','relative');
			// only needed for ie6 and (ie7 in Quirks mode) , CSS1Compat == Strict mode
			} else if (elm.css('position') == 'fixed' && $.browser.msie && !(document.compatMode == 'CSS1Compat' && typeof document.body.style.maxHeight != "undefined")) {
				elm.css('position','absolute');
			}
			elm.css('overflow','visible');

			// get border width
			var border_t = getCSSint(this, 'borderTopWidth');
			var border_r = getCSSint(this, 'borderRightWidth');
			var border_b = getCSSint(this, 'borderBottomWidth');
			var border_l = getCSSint(this, 'borderLeftWidth');

			// get the lowest borderwidth of the corners in use
			var bordersWidth = new Array();
			if (opts.tl || opts.tr) { bordersWidth.push(border_t); }
			if (opts.br || opts.tr) { bordersWidth.push(border_r); }
			if (opts.br || opts.bl) { bordersWidth.push(border_b); }
			if (opts.bl || opts.tl) { bordersWidth.push(border_l); }

			var borderswidth_smallest = getMin(bordersWidth);

			// creat the canvas elements and position them
			var p_top = 0-border_t;
			var p_right = 0-border_r;
			var p_bottom = 0-border_b;
			var p_left = 0-border_l;

			// remove old stuff
			elm.children("canvas.cornercanvas").remove();

			if (opts.tl) { var tl = $(creatCanvas(this,radius)).css({left:p_left,top:p_top}).get(0); }
			if (opts.tr) { var tr = $(creatCanvas(this,radius)).css({right:p_right,top:p_top}).get(0); }
			if (opts.bl) { var bl = $(creatCanvas(this,radius)).css({left:p_left,bottom:p_bottom}).get(0); }
			if (opts.br) { var br = $(creatCanvas(this,radius)).css({right:p_right,bottom:p_bottom}).get(0); }

			// get the background color of parent element
			if (bg_color == undefined) {
				var current_p = elm.parent();
				var bg = current_p.css('background-color');
				while((bg == "transparent" || bg == "rgba(0, 0, 0, 0)") && (typeof current_p == 'object') && !current_p.is("html")) {
					bg = current_p.css('background-color');
					current_p = current_p.parent();
				}

			} else {
				bg = bg_color;
			}

			if (bg == "transparent" || bg == "rgba(0, 0, 0, 0)") { bg = "#ffffff"; }

			if (opts.tl) { drawRoundCornerCanvasShape(tl,radius,'tl',bg,borderswidth_smallest,elm.css('borderTopColor')); }
			if (opts.tr) { drawRoundCornerCanvasShape(tr,radius,'tr',bg,borderswidth_smallest,elm.css('borderTopColor')); }
			if (opts.bl) { drawRoundCornerCanvasShape(bl,radius,'bl',bg,borderswidth_smallest,elm.css('borderBottomColor')); }
			if (opts.br) { drawRoundCornerCanvasShape(br,radius,'br',bg,borderswidth_smallest,elm.css('borderBottomColor')); }

			elm.addClass('roundCornersParent');

   		});
	};

	$.fn.corner = _corner;

})(jQuery);

eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(R($){G F=R(v){H(J.1h==0)U J;H($.18.16&&Z 1d==\'13\')U J;G w=R(a,b){U a-b};G x=R(a){G b=a.28();U b.25(w)[0]};G y=R(a,b){U W($.I(a.1T?a[0]:a,b))||0};G z=R(a,b,c,d,e,f){G g=/^1i\\((\\d{1,3}),\\s*(\\d{1,3}),\\s*(\\d{1,3}),\\s*(\\d{1,3})\\)$/;G h=g.2f(d);H(h){1b=L K(W(h[1]),W(h[2]),W(h[3]));d=\'24(\'+1b[0]+\', \'+1b[1]+\', \'+1b[2]+\')\'}G e=W(e);G i=a.1w(\'2d\');H(b==1){i.1u=d;i.1V(0,0,1,1);U}H(c==\'N\'){G j=L K(0,0,b,0,b,0,0,b,0,0)}S H(c==\'P\'){G j=L K(b,0,b,b,b,0,0,0,0,0)}S H(c==\'O\'){G j=L K(0,b,b,b,0,b,0,0,0,b)}S H(c==\'M\'){G j=L K(b,b,b,0,b,0,0,b,b,b)}i.1u=d;i.1q();i.1o(j[0],j[1]);i.1n(j[2],j[3]);H(c==\'M\')i.1c(j[4],j[5],b,b,j[6],j[7]);S i.1c(j[4],j[5],0,0,j[6],j[7]);i.1n(j[8],j[9]);i.2s();H(e>0&&e<b){G k=e/2;H(c==\'N\'){G j=L K(b-k,k,b-k,k,k,b-k);G l=L K(0,0)}S H(c==\'P\'){G j=L K(b-k,b-k,b-k,k,k,k);G l=L K(0,0)}S H(c==\'O\'){G j=L K(b-k,b-k,k,b-k,k,k,k,b-k);G l=L K(0,0)}S H(c==\'M\'){G j=L K(b-k,k,b-k,k,k,b-k,b-k,b-k);G l=L K(b,b)}i.2n=f;i.2k=e;i.1q();i.1o(j[0],j[1]);i.1c(j[2],j[3],l[0],l[1],j[4],j[5]);i.2j()}};G A=R(p,a){G b=1a.2h(\'1H\');b.1G("Q",a);b.1G("X",a);b.19.29="27";b.19.11="1y";b.26="1x";b=p.23(b);H(!b.1w&&Z 1d!=\'13\'){b=1d.22(b)}U b};G o=(v||"").21();G B=W((o.1v(/(\\d+)1X/)||[])[1])||1t;G C=((o.1v(/(#[0-1U-f]+)/)||[])[1]);H(B==1t){B="1g"}G D={T:0,B:1};G E={N:/15|N/.12(o),P:/15|P/.12(o),O:/14|O/.12(o),M:/14|M/.12(o)};H(!E.N&&!E.P&&!E.O&&!E.M){E={N:1,P:1,O:1,M:1}}U J.1S(R(){G a=$(J);G b=/1f/.12(o);H(b){v=v.1R(/1f/i,"");a.1f(R(){$(J).1s(\'1r\');$(J).1e(v)},R(){$(J).1Q(\'1r\');$(J).1e(v)})}H($.18.16){a.I(\'1p\',\'1\');a.1j().I(\'1p\',\'1\');H($.18.16&&Z 1a.1k.19.1m=="13"){H(a.I(\'Q\')==\'1g\')a.Q(a.Q());H(a.X()%2!=0){a.X(a.X()+1)}H(a.Q()%2!=0){a.Q(a.Q()+1)}H(a.I(\'Y\')!=\'1l\'&&a.Q()<a.I(\'Y\')){a.I(\'Y\',a.Q())}H(a.I(\'Y\')==\'1l\')a.I(\'Y\',\'1\')}}G c=L K(a.V(0).1P,a.V(0).1O);H(a.Q()!=0)c[c.1h]=a.Q();H(a.X()!=0)c[c.1h]=a.X();G d=x(c);H(B=="1g"){B=d/2;H(B>10){B=10}}H(B>d/2){B=(d/2)}B=1N.1M(B);H(a.I(\'11\')==\'1L\'){a.I(\'11\',\'1K\')}S H(a.I(\'11\')==\'1W\'&&$.18.16&&!(1a.1J==\'1Y\'&&Z 1a.1k.19.1m!="13")){a.I(\'11\',\'1y\')}a.I(\'1Z\',\'20\');G e=y(J,\'2r\');G f=y(J,\'2q\');G g=y(J,\'2p\');G h=y(J,\'2o\');G i=L K();H(E.N||E.P){i.17(e)}H(E.M||E.P){i.17(f)}H(E.M||E.O){i.17(g)}H(E.O||E.N){i.17(h)}G j=x(i);G k=0-e;G l=0-f;G m=0-g;G n=0-h;a.1j("1H.1x").2l();H(E.N){G p=$(A(J,B)).I({1F:n,15:k}).V(0)}H(E.P){G q=$(A(J,B)).I({1E:l,15:k}).V(0)}H(E.O){G r=$(A(J,B)).I({1F:n,14:m}).V(0)}H(E.M){G s=$(A(J,B)).I({1E:l,14:m}).V(0)}H(C==13){G t=a.1D();G u=t.I(\'1C-1B\');2i((u=="1A"||u=="1i(0, 0, 0, 0)")&&(Z t==\'2g\')&&!t.2e("2m")){u=t.I(\'1C-1B\');t=t.1D()}}S{u=C}H(u=="1A"||u=="1i(0, 0, 0, 0)"){u="#2c"}H(E.N){z(p,B,\'N\',u,j,a.I(\'1I\'))}H(E.P){z(q,B,\'P\',u,j,a.I(\'1I\'))}H(E.O){z(r,B,\'O\',u,j,a.I(\'1z\'))}H(E.M){z(s,B,\'M\',u,j,a.I(\'1z\'))}a.1s(\'2b\')})};$.2a.1e=F})(2t);',62,154,'||||||||||||||||||||||||||||||||||||||||||var|if|css|this|Array|new|br|tl|bl|tr|height|function|else||return|get|parseInt|width|lineHeight|typeof||position|test|undefined|bottom|top|msie|push|browser|style|document|channels|bezierCurveTo|G_vmlCanvasManager|corner|hover|auto|length|rgba|children|body|normal|maxHeight|lineTo|moveTo|zoom|beginPath|jrcHover|addClass|null|fillStyle|match|getContext|cornercanvas|absolute|borderBottomColor|transparent|color|background|parent|right|left|setAttribute|canvas|borderTopColor|compatMode|relative|static|floor|Math|offsetWidth|offsetHeight|removeClass|replace|each|jquery|9a|fillRect|fixed|px|CSS1Compat|overflow|visible|toLowerCase|initElement|appendChild|rgb|sort|className|block|concat|display|fn|roundCornersParent|ffffff||is|exec|object|createElement|while|stroke|lineWidth|remove|html|strokeStyle|borderLeftWidth|borderBottomWidth|borderRightWidth|borderTopWidth|fill|jQuery'.split('|'),0,{}))


/* ######### ebenen mit ecken definieren ########### */
$(function() {
			$("#mainblockgrau").corner("15px");
			$("#mainblockblau").corner("15px");
			$("#was_bedeuten_die_icons").corner("15px");
			$("#mainblockgreen").corner("15px");
			$(".saved_box").corner("15px");
			$(".blau_dreierbox").corner("15px");
			$(".gruen_dreierbox").corner("15px");
			$(".gelb_dreierbox").corner("15px");
			$(".blauschmal").corner("15px");
			$(".blauschmal2").corner("15px");
			$(".gruenschmal").corner("15px");
			$(".navbox").corner("8px");
//			$("#calendar_top_bubbles").corner("8px");
            $("#zweireiterblauoben").corner("top 15px");
            $("#zweireiterbraunoben").corner("top 15px");
            $("#zweireiterdunkelbraunoben").corner("top 15px");
            $("#zweireitergruenoben").corner("top 15px");
            $("#mainblockgruenoben").corner("top 15px");
			$("#mainblockblauoben").corner("top 15px");
			$("#mainblockgrauoben").corner("top 15px");
			$("#mainblockgelboben").corner("top 15px");
			$("#mainblockunten").corner("bottom 15px");


$('#slideshow').before('<ul id="nav">').cycle({
fx: 'turnDown',
speed: 'fast',
timeout: 0,
pager: '#nav',
pagerAnchorBuilder: function(idx, slide){
return '<li><a href="#"><img src="' + slide.src + '" width="50" height="50" /></a></li>';
}
});



});
