var currentBG = 1;
var totalBG = 3;
jQuery(function($){
	currentBG = Math.ceil(Math.random()*3);
	var bg = "images/bg/bg"+currentBG+".jpg";
	
	$(".bg").css({ top:0, left:0, position:"absolute" ,zIndex:"-9999" , center:false });			
	$("img.bg").attr({src:bg});		
	
	$("#fondoAtras").click(function()
	{
		currentBG--;
		if( currentBG < 1 )
			currentBG = totalBG;
		var bgNew = "images/bg/bg"+currentBG+".jpg";
		$(".bg").fadeTo("slow", 0, function()
		{
			$("img.bg").attr({src:bgNew}).fadeTo("slow",1);
		});				
	});
	$("#fondoSiguiente").click(function()
	{
		currentBG++;
		if( currentBG > totalBG )
			currentBG = 1;
		var bgNew = "images/bg/bg"+currentBG+".jpg";
		$(".bg").fadeTo("slow", 0, function()
		{
			$("img.bg").attr({src:bgNew}).fadeTo("slow",1);
		});				
	});
});
function alturasIguales(objetos) {
	var currentTallest = 0;
	$(objetos).each(function(){
		if ($(this).height() > currentTallest) { currentTallest = $(this).height(); }
	});
	// for ie6, set height since min-height isn't supported
	if ($.browser.msie && $.browser.version == 6.0) { $(objetos).css({'height': currentTallest+'px'}); }
	$(objetos).css({'min-height': currentTallest+'px'});
	return this;
}
