jQuery.fn.randomChild = function(settings) {
	return this.each(function(){
		var c = $(this).children().length;
		var r = Math.ceil(Math.random() * c);
		$(this).children().hide().parent().children(':nth-child(' + r + ')').show().attr('id', 'bigbg');
	});
};

$(document).ready(function() {

	$('#bgvideos').randomChild();

	var windowH = $(window).height();
	var windowW = $(window).width();
	
	$('#bigbg, .bg').attr({'width':windowW,'height':windowH});


	$(window).resize(function() {
		var windowH = $(window).height();
		var windowW = $(window).width();
		$('#bigbg, .bg').attr({'width':windowW,'height':windowH});
	});

});

$(window).load(function() {
	
	$('object:not("#bigbg")').remove();
	
});
