$(function () {
	
	//var $movies = $('.movies .trailer');
	//$movies.slice(0,2).equalHeight();
	//$movies.slice(2,4).equalHeight();
	//$movies.slice(4,6).equalHeight();
	//$movies.slice(6,8).equalHeight();
	//$('.games .trailer').equalHeight();
	
	//$('.entry').masonry({ singleMode: true, itemSelector: '.trailer' });
	$('.entry').masonry({ columnWidth: 290, itemSelector: '.trailer' });
		
	// easy toggle for categories
	$('#triggerCatID').click(function() {
		$(this).toggleClass('focus');
		$('#headerStrip').animate({ height: 'toggle', opacity: '100'}, 100);
		return false;
	});
	$('#triggerCatID2').click(function() {
		$(this).toggleClass('focus');
		$('#footerStrip').animate({ height: 'toggle', opacity: '100'}, 100);
		return false;
	});

	$('.trailer .thumbnail img').animate({opacity: 1 });

	$('.trailer .thumbnail .enlarge').hover(function() {
		$(this).prev('img').stop().animate({opacity: .5 }, 300);
	},function() {
		$(this).prev('img').stop().animate({opacity: 1}, 300);
	});
});


$(jQuery.sibling(this).prev).css("border","solid 1px red");
$("UL", jQuery.sibling(this).next).css("border","solid 1px red"); 

$(function() {
	$('a[rel=youtube]').fancybox({
		overlayShow: true,
		//frameWidth:680,
		//frameHeight:385
		frameWidth:854,
		frameHeight:505
	});

    $('a[rel=ign]').fancybox({
        overlayShow: true,
        frameWidth: 433,
        frameHeight: 360
    });
    
    $('a[rel=ign2]').fancybox({
        overlayShow: true,
        //frameWidth: 480,
        //frameHeight: 270
        frameWidth: 680,
        frameHeight: 380
    });
});

/* jQuery elementReady plugin
* Version 0.6
* Copyright (C) 2007-08 Bennett McElwee.
* Licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License (http://creativecommons.org/licenses/by-sa/3.0/)
* Permissions beyond the scope of this license may be available at http://www.thunderguy.com/semicolon/.
*/
(function($) {
    var interval = null;
    var checklist = [];

    $.elementReady = function(id, fn) {
        checklist.push({ id: id, fn: fn });
        if (!interval) {
            interval = setInterval(check, $.elementReady.interval_ms);
        }
        return this;
    };

    // Plugin settings
    $.elementReady.interval_ms = 23; // polling interval in ms

    // Private function
    function check() {
        var docReady = $.isReady; // check doc ready first; thus ensure that check is made at least once _after_ doc is ready
        for (var i = checklist.length - 1; 0 <= i; --i) {
            var el = document.getElementById(checklist[i].id);
            if (el) {
                var fn = checklist[i].fn; // first remove from checklist, then call function
                checklist[i] = checklist[checklist.length - 1];
                checklist.pop();
                fn.apply(el, [$]);
            }
        }
        if (docReady) {
            clearInterval(interval);
            interval = null;
        }
    };
})(jQuery);