/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
$(document).ready(function(){

    /* Recalculate on Load */
    $(window).load(function() {
        $(window).jaxolotlCorners();
    });
    /* Recalculate on Resize */
    $('#imagePanel').bind('resize',  function() {
        $(window).jaxolotlCorners();
    });
    /* Recalculate on Resize */
    $(window).resize(function() {
        $(window).jaxolotlCorners();
    });


    /**
    * Positionate and move rounded corners
    * and some other staff undocumented yet
    */

    $.fn.jaxolotlCorners = function () {
        $('.canibal').remove();
        /*$('input.rounded').each(function(){
        var inputRounded = $(this);
        var inputRoundedPos = inputRounded.position() ;
        $(this).css({'border':'#ffffff 1px solid'});
        $(this).before('<img src="immagini/layout_images/bg_smooth_buttons_left_corner.png" class="canibal" border="0" style="position:absolute;top:'+ (inputRoundedPos.top  + 1) +'px;left:'+inputRoundedPos.left+'px;" >');
    });*/

        if(jQuery.browser.msie) {
            $('.boxCorners').remove();

                var bound1Fix = 8;
                var bound2Fix = 3;

            var count = 1
            $.each($('body').find('.box'), function() {


                $('.familyListItem, .bottomBanners').css({margin:'3px'});
 
                $('body').prepend('<img src="immagini/rounded_corners/tl.png"  alt="Peirano"  id="boxCornerTL'+ count+'" class="boxCorners" >');
                $('body').prepend('<img src="immagini/rounded_corners/tr.png"  alt="Peirano"  id="boxCornerTR'+ count+'" class="boxCorners" >');
                $('body').prepend('<img src="immagini/rounded_corners/bl.png"  alt="Peirano"  id="boxCornerBL'+ count+'" class="boxCorners" >');
                $('body').prepend('<img src="immagini/rounded_corners/br.png"  alt="Peirano"  id="boxCornerBR'+ count+'" class="boxCorners" >');

                var roundedBox = $(this);
                var roundedBoxPos = roundedBox.position() ;
                var roundedBoxRight = roundedBox.outerWidth();

                /* INFO PANEL */
                $('#boxCornerTL' + count).css({
                    'left' : roundedBoxPos.left + bound2Fix ,
                    'top' : roundedBoxPos.top + bound2Fix
                }).show();

                $('#boxCornerTR' + count).css({
                    'left' : roundedBoxPos.left + roundedBoxRight - bound1Fix,
                    'top' : roundedBoxPos.top + bound2Fix
                }).show();

                $('#boxCornerBL' + count).css({
                    'left' : roundedBoxPos.left + bound2Fix,
                    'top' : roundedBoxPos.top + roundedBox.outerHeight() - bound1Fix
                }).show();

                $('#boxCornerBR' + count).css({
                    'left' : roundedBoxPos.left + roundedBoxRight - bound1Fix,
                    'top' : roundedBoxPos.top + roundedBox.outerHeight() - bound1Fix
                }).show();


                count++;
            });
        }
    }
});


