/* fancy zoom */
function readyFancyBox ()
{
    var img = $('.entry .wp-caption > a > img');
    
    if (img != null)
    {
	    var patt=/[jpg|png|gif]$/i;
	    var href=img.parent('a').attr('href');
	    
	    // content posts
	    if ((href != undefined) && (href.match(patt)))
	    {
	    	img.parent().addClass('fancyboxZoom');
	    }
	    
	    $('.fancyboxZoom').fancybox();
    }
}

function readyTumblrFancyBox()
{
    // do it again for Tumblr
    var tumblrhref = $('.Tumblr li.photo > a');
    var patt=/[jpg|png|gif]$/i;
    if (tumblrhref.attr('href').match(patt))
    {
    	tumblrhref.addClass('fancyboxZoom');
    }
    $('.fancyboxZoom').fancybox();
}

/* group fancy zoom */
function readyGroupFancyBox ()
{
    var img = $('.entry .wp-caption > a > img');
    if (img != null) 
    {
	    var patt=/[jpg|png|gif]$/i;
	    var href=img.parent('a').attr('href');
	    
	    if ((href != undefined) && (href.match(patt)))
	    {
	    	img.parent().attr('rel','group')
	    }
	    $('.fancyboxZoom').fancybox();
    }
}

function readyHomeBannerImage (url)
{
	var img = $('.entry .wp-caption > a > img');
	img.parent('a').attr('href',url);
	img.parent('a').removeClass('fancyboxZoom');
}

function readyCaptionNumbers ()
{
	var captions = $('.wp-caption-text');
	
	if (captions != null)
	{
		captions.each(function (index) {
			picNum = index + 1;
			outText = '<span class="picnum">' + picNum.toString() + '</span> ' + $(this).html();
			$(this).html(outText);
		});
	}
}

function readyDHOSlideShow ()
{
	$('#dhoslideshow').css('margin','auto');
	$('#dhoslideshow').css('width','100%');
	$('#dhoslideshow').css('height','433px');

	Galleria.loadTheme('/wp/wp-content/themes/dho.ca-2/galleria/themes/classic/galleria.classic.min.js');
	//Galleria.loadTheme('/wp/wp-content/themes/dho.ca-2/galleria/themes/twelve/galleria.twelve.min.js');
	$('#dhoslideshow').galleria(
		{
			lightbox: true,
		    dataConfig: function(img) {
		        return {
		            title: $(img).attr('title'),
		            description: $(img).attr('alt')
		        };
		    }
		});
}

function readyDHOSlideShow12 ()
{
	$('#dhoslideshow').css('height','433px');
	$('#dhoslideshow').css('width','100%');
	
	//Galleria.loadTheme('/wp-content/themes/dho.ca-wpmain/galleria/themes/classic/galleria.classic.min.js');
	//Galleria.loadTheme('/wp-content/themes/dho.ca-wpmain/galleria/themes/twelve/galleria.twelve.min.js?ts=' + new Date());
	Galleria.loadTheme('/wp-content/themes/dho.ca-wpmain/galleria/themes/twelve/galleria.twelve.min.js');
	$('#dhoslideshow').galleria({
		transition: "slide",
	    transitionSpeed: 500,
	    imageCrop: false,
	    thumbCrop: false,
	    carousel: false,
	    // Toggles the fullscreen button
	    _showFullscreen: false,
	    // Toggles the lightbox button
	    _showPopout: false,
	    // Toggles the progress bar when playing a slideshow
	    _showProgress: true,
	    // Toggles tooltip
	    _showTooltip: false,
	    dataConfig: function(img) {
	        return {
	            title: $(img).attr('title'),
	            description: $(img).attr('alt')
	        };
	    }
	});
	/*$('#dhoslideshow').galleria(
		{
			lightbox: false,
		    dataConfig: function(img) {
		        return {
		            title: $(img).attr('title'),
		            description: $(img).attr('alt')
		        };
		    }
		});*/
}
