/*
http://tympanus.net/codrops/2009/11/23/jcapslide-a-jquery-image-caption-plugin/
Free to use plugin.
-----------------------------------------------------------------------------------------------------
About us
Codrops is a web development blog that publishes articles and tutorials about web design, programming 
and usability. The team of Codrops is dedicated to provide useful and qualitative content that is 
free of charge.

If you want to contact or hire us, feel free to use our contact form on our main page tympanus.net
-----------------------------------------------------------------------------------------------------



Modified as noted below.
*/

(function ($) {
    $.fn.capslide = function (options) {
        var opts = $.extend({}, $.fn.capslide.defaults, options);
        return this.each(function () {
            $this = $(this);
            var o = $.meta ? $.extend({}, opts, $this.data()) : opts;

            if (!o.showcaption) $this.find('.ic_caption').css('display', 'none');
            else $this.find('.ic_text').css('display', 'none');

            var _img = $this.find('object:first'); // looking for object instead of img
            var w = _img.css('width');
            var h = _img.css('height');

            $('.ic_caption', $this).css({ 'color': o.caption_color, 'background-color': o.caption_bgcolor, 'bottom': '0px' });
            $('.overlay', $this).css('background-color', o.overlay_bgcolor);
            // scw - moved this code here from the hover function below
            if ((navigator.appVersion).indexOf('MSIE 7.0') > 0)
                $('.overlay', $(this)).show();
            else
                $('.overlay', $(this)).fadeIn();
            $this.css({ 'width': w, 'height': h, 'border': o.border });
            $this.hover(
				function () {
				    // scw - copied this code from below
				    if ((navigator.appVersion).indexOf('MSIE 7.0') > 0)
				        $('.overlay', $(this)).hide();
				    else
				        $('.overlay', $(this)).fadeOut();
				    //added the next bit
				    if ((navigator.appVersion).indexOf('MSIE 7.0') > 0)
				        $('.ic_caption', $(this)).hide();
				    else
				        $('.ic_caption', $(this)).fadeOut();
				    //				    if (!o.showcaption)
				    //				        $(this).find('.ic_caption').slideDown(500);
				    //				    else
				    //				        $('.ic_text', $(this)).slideDown(500);
				},
				function () {
				    if ((navigator.appVersion).indexOf('MSIE 7.0') > 0)
				        $('.overlay', $(this)).hide();
				    else
				        $('.overlay', $(this)).fadeOut();
				    //added the next bit
				    if ((navigator.appVersion).indexOf('MSIE 7.0') > 0)
				        $('.ic_caption', $(this)).hide();
				    else
				        $('.ic_caption', $(this)).fadeOut();
				}
            //				function () {
            //				    if ((navigator.appVersion).indexOf('MSIE 7.0') > 0)
            //				        $('.overlay', $(this)).hide();
            //				    else
            //				        $('.overlay', $(this)).fadeOut();
            //				    if (!o.showcaption)
            //				        $(this).find('.ic_caption').slideUp(200);
            //				    else
            //				        $('.ic_text', $(this)).slideUp(200);
            //				}
			);
        });
    };
    $.fn.capslide.defaults = {
        caption_color: 'white',
        caption_bgcolor: 'black',
        overlay_bgcolor: 'blue',
        border: '1px solid #fff',
        showcaption: true
    };
})(jQuery);
