var intervaloProximo;
var proximoActual = 1;
var totalProximo;
var segundos = 6; 

var intervaloProximoInterior;
var proximoActualInterior = 1;
var totalProximoInterior;

$(document).ready(inicia);


function inicia() {
	

	$('.box').corners();
	cajas();
	cajasInterior();
	caja();
	$("#abreinfo").click(masInfo);
	$("#mas").click(masInfo);
	$("#menos").click(menosInfo);
	$("#contenidoInfo").hide();
 

}


function cajas(){
	
	var myFluidGrid = {
				COLNUMBER : 2, // Minimum column number.
				COLMARGIN : 10, // Margin (in pixel) between columns/boxes.
				COLWIDTH : 242, // Fixed width of all columns.
				doLayout : function() {
					var self = this;
					var pointer = 0;
					var arr = [];
					var columns = Math.max(this.COLNUMBER, parseInt($('body').innerWidth() / (this.COLWIDTH + this.COLMARGIN)));

					$('.box').css('position', 'absolute').css('width', this.COLWIDTH  + 'px');
					$('.box').each(function() {
						var tempLeft = (pointer * (self.COLWIDTH + self.COLMARGIN));
						$(this).css('left', tempLeft + 'px');

						var tempTop = 0;
						if (arr[pointer]) { tempTop = arr[pointer];	}
						$(this).css('top', tempTop + 'px');

						arr[pointer] = tempTop + $(this).outerHeight() + self.COLMARGIN;
						pointer++;
						if (pointer === columns) { pointer = 0; }
					});
				}
			};
			$(window).ready(function() {
				myFluidGrid.doLayout();
			}).resize(function() {
				myFluidGrid.doLayout();
			});
	
}

function cajasInterior(){
	
	var myFluidGrid2 = {
				COLNUMBER2 : 1, // Minimum column number.
				COLMARGIN2 : 10, // Margin (in pixel) between columns/boxes.
				COLWIDTH2 : 316, // Fixed width of all columns.
				doLayout : function() {
					var self = this;
					var pointer = 0;
					var arr = [];
					var columns2 = Math.max(this.COLNUMBER2, parseInt($('body').innerWidth() / (this.COLWIDTH2 + this.COLMARGIN2)));

					$('.boxInterior').css('position', 'absolute').css('width', this.COLWIDTH2  + 'px');
					$('.boxInterior').each(function() {
						var tempLeft2 = (pointer * (self.COLWIDTH2 + self.COLMARGIN2));
						$(this).css('left', tempLeft2 + 'px');

						var tempTop2 = 0;
						if (arr[pointer]) { tempTop2 = arr[pointer];	}
						$(this).css('top', tempTop2 + 'px');

						arr[pointer] = tempTop2 + $(this).outerHeight() + self.COLMARGIN2;
						pointer++;
						if (pointer === columns2) { pointer = 0; }
					});
				}
			};
			$(window).ready(function() {
				myFluidGrid2.doLayout();
			}).resize(function() {
				myFluidGrid2.doLayout();
			});
	
}



function caja(){

 //menu
   
   $(".box").hover(
      function () {
        $(this).stop().animate({ backgroundColor: "#363636"}, 300);
      }, 
      function () {
        $(this).stop().animate({ backgroundColor: "#2d2d2d"}, 550);
      }
    );
   
}


function masInfo(){
	 $(this).hide()
	 $("#abreinfo").show()
	 $("#menos").show()
	 $("#info").stop().animate({ marginTop: "0"}, 500);
	 $("#fancybox-wrap").css({ marginTop:"0"});
	 $("#contenidoInfo").fadeIn(500);
}

function menosInfo(){
	 $(this).hide()
	 $("#mas").show()
	 $("#info").stop().animate({ marginTop: "-271px"}, 500);
	 $("#fancybox-wrap").css({ marginTop:"270px"});
	 $("#contenidoInfo").fadeOut(500);
}





