
//equal heights function - matches heights of a group of elements to the largest 
function equalHeight(group) {
    tallest = 0;
    group.each(function() {
        thisHeight = $(this).height();
        if(thisHeight > tallest) {
            tallest = thisHeight;
        }
    });
    group.height(tallest);
}

$.fn.fadeToggle = function(speed, easing, callback) {
return this.animate({opacity: 'toggle'}, speed, easing, callback);  
};

$(document).ready(function() {

    /* Open external links in a new window */
    $("a[href^='http']").attr('target','_blank');
    $("form[action^='http']").attr('target','_blank');
	
	

    /**************************************
    set equalHeights on content and sidebar
    ***************************************/
    // set equal heights on sidebar and content
    //equalHeight($('#sidebar, #content'));
    equalHeight($('#home-column-left, #home-column-center, #home-column-right'));

    /* Home page photo cycling */
    $('#photos').cycle({
	timeout:       5500,
	speed:         500	
    });


    /* Video gallery lightbox */
    $(".video-gallery-item a").click(function() {
	$.fancybox({
	    'padding'		: 0,
	    'autoScale'		: false,
	    'transitionIn'	: 'none',
	    'transitionOut'	: 'none',
	    'title'			: this.title,
	    'width'			: 680,
	    'height'		: 495,
	    'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
	    'type'			: 'swf',
	    'swf'			: {
		'wmode'			: 'transparent',
		'allowfullscreen'	: 'true'
	    }
	});
	
	return false;
    });

    $('#fancybox-close').append('Close');


    /* Home page video & photo gallery popup */
    $("a.iframeBox").fancybox({
	'width'				: 660,
	'height'			: 568,
        'autoScale'     	: false,
        'transitionIn'		: 'none',
	'transitionOut'		: 'none',
	'type'				: 'iframe',
	'titleShow'			: false,
	'showCloseButton'	: true
    });

    $('#emaillink').hide();

    $('#email, input.close').click(function(event) {
       event.preventDefault;
       $('#emaillink').fadeToggle('slow');
       return false;
    });

    $('ul.gallery li a').fancybox();
});

