//pngfix
 $(document).ready(function(){ 
        $(document).pngFix(); 
    }); 

// slider
    $(document).ready(function() {
        jQuery(document).ready(function() {
            try {                
                jQuery('#bannercarousel').css({ visibility: "visible" });
                jQuery('#slider').jcarousel({ auto: 0, wrap: 'last', scroll: 1, animation: 1500, easing: 'easeInOutExpo',
                    initCallback: mycarousel_initCallback
                });

            } catch (err) { }
        });

        function mycarousel_initCallback(carousel) {
            var changeTime = jQuery('#slider').attr("changeTime");
            if (!changeTime) {
                changeTime = 8;
            }
            setTimeout(function() {
                carousel.startAuto(changeTime);
            }, 1000);
            carousel.clip.hover(function() {
                carousel.stopAuto();
            }, function() {
                carousel.startAuto();
            });
        };
    });

//xform
$(document).ready(function() {
    //find all form with class jqtransform and apply the plugin
    $("#id_matrix").jqTransform();
});


// lightbox (not working with jquery 1.3.2!!)
$(document).ready(function() {

    $('img.imageScale').wrap(function() {
           
        var src = $(this).attr('src');

        var txt = ($(this).attr('title') ? $(this).attr('title') : '');
        
        var largeSrc = src.substring(0, src.lastIndexOf('.')) + '_large.' + /[^.]+$/.exec(src);
        return '<a class="imagepopup" href="' + largeSrc + '" title="' + txt + '" />';
    });
    // lightBox2
    $("a.imagepopup").append("<div style='background-color:none;background:transparent;'><div style='background-color:none;background:transparent;margin-top:-30px;margin-left:2px;'><img style='background-color:none;background:transparent;border:none;' src='/Templates/AnnualReport/Images/zoomi.png'></div></div>");
    // lightBox2 
    $('a.imagepopup').fancybox({
        'titlePosition': 'inside',
        'titleFormat': function(title, currentArray, currentIndex, currentOpts) {
            var txt = $(this).attr('title');
            if (txt)
                return '<span id="fancybox-title-over">' + (txt.length ? ' &nbsp; ' + txt : '') + '</span>'
            else
                return '';
        }
    });
});
