// Spersonalizowane dla OMP
//----------------------------------------
// You can Predefined values for all Class "rounded" divs here:
// -----------------
topGradientColor="#EFD4D9";
botGradientColor="#FFFFFF";
borderWidth=2;
borderColor="#D3BEC3";
cornerRadius=10;
direction="vertical";
//rel="#EFD4D9|#FFFFFF|2|#D3BEC3|10|vertical"

///////////////////////////////////////////////
//--------------- rounded --------------------
$(document).ready(function(){
         $(".rounded").each(function(){
             $(this).backgroundCanvas();
             DrawBackground($(this));
         });
});

// Draw the background  on load:
$(window).load(function(){
     $(".rounded").each(function(){
         $(this).backgroundCanvas();
         DrawBackground($(this));
     });
});

// Redraw on window Resize:
$(window).resize(function(){
     $(".rounded").each(function(){
         $(this).backgroundCanvas();
         DrawBackground($(this));
     });
});

///////////////////////////////////////////////
//--------------- roundedLong ----------------
$(document).ready(function(){
         $(".roundedLong").each(function(){
             $(this).backgroundCanvas();
             DrawBackground($(this));
         });
});

// Draw the background  on load:
$(window).load(function(){
     $(".roundedLong").each(function(){
         $(this).backgroundCanvas();
         DrawBackground($(this));
     });
});

// Redraw on window Resize:
$(window).resize(function(){
     $(".roundedLong").each(function(){
         $(this).backgroundCanvas();
         DrawBackground($(this));
     });
});
///////////////////////////////////////////////

//--------------- roundedGrey ----------------
$(document).ready(function(){
         $(".roundedGrey").each(function(){
             $(this).backgroundCanvas();
             DrawBackground($(this));
         });
});

// Draw the background  on load:
$(window).load(function(){
     $(".roundedGrey").each(function(){
         $(this).backgroundCanvas();
         DrawBackground($(this));
     });
});

// Redraw on window Resize:
$(window).resize(function(){
     $(".roundedGrey").each(function(){
         $(this).backgroundCanvas();
         DrawBackground($(this));
     });
});
///////////////////////////////////////////////

//--------------- roundedNews ----------------
$(document).ready(function(){
         $(".roundedNews").each(function(){
             $(this).backgroundCanvas();
             DrawBackground($(this));
         });
});

// Draw the background  on load:
$(window).load(function(){
     $(".roundedNews").each(function(){
         $(this).backgroundCanvas();
         DrawBackground($(this));
     });
});

// Redraw on window Resize:
$(window).resize(function(){
     $(".roundedNews").each(function(){
         $(this).backgroundCanvas();
         DrawBackground($(this));
     });
});
///////////////////////////////////////////////
//--------------- roundedNews ----------------
$(document).ready(function(){
         $(".roundedNewsEn").each(function(){
             $(this).backgroundCanvas();
             DrawBackground($(this));
         });
});

// Draw the background  on load:
$(window).load(function(){
     $(".roundedNews").each(function(){
         $(this).backgroundCanvas();
         DrawBackground($(this));
     });
});

// Redraw on window Resize:
$(window).resize(function(){
     $(".roundedNewsEn").each(function(){
         $(this).backgroundCanvas();
         DrawBackground($(this));
     });
});
///////////////////////////////////////////////

//--------------- roundedRightLong ----------------
$(document).ready(function(){
         $(".roundedLongRight").each(function(){
             $(this).backgroundCanvas();
             DrawBackground($(this));
         });
});

// Draw the background  on load:
$(window).load(function(){
     $(".roundedLongRight").each(function(){
         $(this).backgroundCanvas();
         DrawBackground($(this));
     });
});

// Redraw on window Resize:
$(window).resize(function(){
     $(".roundedLongRight").each(function(){
         $(this).backgroundCanvas();
         DrawBackground($(this));
     });
});
///////////////////////////////////////////////


function DrawBackground($obj)
{
   $($obj).backgroundCanvasPaint(container);
}

function container(context, width, height, canvas, $canvas, $canvasDiv, $content, $element){
                var hgt = $($element).height();
                var wdth = $($element).width();
                var options = { x: 0, height: hgt, width: wdth, radius: 0, border: 0 };
                if(typeof $($element).attr('rel') != 'undefined'){
                    var vals = $($element).attr('rel').split('|');
                    topGradientColor = vals[0];
                    botGradientColor = vals[1];
                    borderWidth = parseFloat(vals[2]);
                    borderColor = borderWidth > 0 ? vals[3] : "transparent";
                    cornerRadius = vals[4];
                    direction = vals[5];
                }
                var v = direction=='vertical' ? height-2 : 0;
                var h = direction=='horizontal' ? width : 0;
                var c = borderColor ? borderColor : "#FFFFFF";
                var backgroundGradient = context.createLinearGradient(0, 0, h, v);
                context.fillStyle = c;
                var t = topGradientColor ? topGradientColor : "#FFFFFF";
                var b = botGradientColor ? botGradientColor : "#FFFFFF";
                backgroundGradient.addColorStop(0 ,t);
                backgroundGradient.addColorStop(1, b);
                options.radius = cornerRadius ? cornerRadius : 0;
                
                // Draw the blue border rectangle
                $.canvasPaint.roundedRect(context,options);
                
                // Draw the gradient filled inner rectangle
                options.border = borderWidth ? borderWidth : 0;
                context.fillStyle = backgroundGradient;
                $.canvasPaint.roundedRect(context,options);
}
