jQuery(function($){

});
$(document).ready(function() {
	$('a[rel^="lightbox"]').each(function(index,element) {
		$(element).attr('rel',$(element).attr('rel').replace(/[^0-9a-z]/gi,'_'));
	});
	$('a[rel^="lightbox"]').fancybox({
		'titlePosition':'inside',
		'titleFormat': function formatTitle(title, currentArray, currentIndex, currentOpts) {
			return '<div id="tip7-title">' + (title && title.length ? '<b>' + title + '</b>' : '' ) + 'Image ' + (currentIndex + 1) + ' of ' + currentArray.length + '</div>';
		}
	});

	if (galleryImg.length) {
		var html='<ul class="thumbs noscript">';
		$.each(galleryImg, function(index, value) {
			html+='<li><a class="thumb" name="leaf" href="' + value.img + '"><img src="' + value.thumb + '" alt="" /></a></li>';
		});
		html+='</ul>';
		$('#thumbs').html(html);
	}

	// Initially set opacity on thumbs and add
	// additional styling for hover effect on thumbs
	var onMouseOutOpacity = 0.67;
	$('#thumbs ul.thumbs li').opacityrollover({
		mouseOutOpacity:   onMouseOutOpacity,
		mouseOverOpacity:  1.0,
		fadeSpeed:         'fast',
		exemptionSelector: '.selected'
	});

	// Initialize Advanced Galleriffic Gallery
	var gallery = $('#thumbs').galleriffic({
		delay:                     4000,
		numThumbs:                 10,
		preloadAhead:              10,
		enableTopPager:            false,
		enableBottomPager:         true,
		maxPagesToShow:            3,
		imageContainerSel:         '#slideshow',
		controlsContainerSel:      '#controls',
		captionContainerSel:       '#caption',
		loadingContainerSel:       '#loading',
		renderSSControls:          false,
		renderNavControls:         false,
		playLinkText:              'Play Slideshow',
		pauseLinkText:             'Pause Slideshow',
		prevLinkText:              '&lsaquo; Previous Photo',
		nextLinkText:              'Next Photo &rsaquo;',
		nextPageLinkText:          '&rsaquo;&rsaquo;&rsaquo;',
		prevPageLinkText:          '&lsaquo;&lsaquo;&lsaquo;',
		enableHistory:             false,
		autoStart:                 true,
		syncTransitions:           true,
		defaultTransitionDuration: 1500,
		onSlideChange:             function(prevIndex, nextIndex) {
			// 'this' refers to the gallery, which is an extension of $('#thumbs')
			this.find('ul.thumbs').children()
				.eq(prevIndex).fadeTo('fast', onMouseOutOpacity).end()
				.eq(nextIndex).fadeTo('fast', 1.0);
		},
		onPageTransitionOut:       function(callback) {
			this.fadeTo('fast', 0.0, callback);
		},
		onPageTransitionIn:        function() {
			this.fadeTo('fast', 1.0);
		}
	});



	/*if(!jQuery.support.boxModel) {
		$('#footer').css('position','absolute');
		$('#footer').css('top',$(window).scrollTop()+$(window).height()-70);
		$(window).scroll(function(){
			$('#footer').css('top',$(window).scrollTop()+$(window).height()-70);
		});
		$(window).resize(function(){
			$('#footer').css('top',$(window).scrollTop()+$(window).height()-70);
		});
	}*/

});
function shuffle (inputArr) {
    var valArr = [],
        k = '',
        i = 0,
        strictForIn = false,
        populateArr = [];

    for (k in inputArr) { // Get key and value arrays
        if (inputArr.hasOwnProperty(k)) {
            valArr.push(inputArr[k]);
            if (strictForIn) {
                delete inputArr[k];
            }
        }
    }
    valArr.sort(function () {
        return 0.5 - Math.random();
    });

    // BEGIN REDUNDANT
    this.php_js = this.php_js || {};
    this.php_js.ini = this.php_js.ini || {};
    // END REDUNDANT
    strictForIn = this.php_js.ini['phpjs.strictForIn'] && this.php_js.ini['phpjs.strictForIn'].local_value && this.php_js.ini['phpjs.strictForIn'].local_value !== 'off';
    populateArr = strictForIn ? inputArr : populateArr;

    for (i = 0; i < valArr.length; i++) { // Repopulate the old array
        populateArr[i] = valArr[i];
    }
    return strictForIn || populateArr;
}
