function cambiarsplash(nuevo){
	$('div.novedades div.textos div.active').removeClass("active");
	$('div.splash div.actual a.active').removeClass("active");
	$('div.novedades div.textos div#novedades-textos-'+nuevo).addClass("active");
	$('div.splash div.actual a.#splash-'+nuevo).addClass("active");
	var nuevotop = (nuevo-1)*180;
	
	$('div.splash div.imagenes').animate({
		top: '-'+nuevotop+'px'
	}, 200, function() {
		// Animation complete.
	})
	
	$('div.novedades div.textos div#novedades-textos-'+nuevo+' h2').fadeIn('slow');

}
$(document).ready(function() {
	base();
	$('.buscador').submit(function() {
		var b_stock = '';
		if($("input#b_stock:checked").length > 0){
			b_stock = ',productos.stock-not0';
		}
		
		location.href = 'productos/?es=productos.titulo-like'+$("input#b_contenido").val().replace(/ /g, "+")+b_stock;
		return false;
	});
	$('.miniusuarios img').tip({defaultPosition: 'top', attribute: 'alt', delay: 0});
	$('#social a.social').attr('target', '_blank');
	$('#social a.social img').tip({defaultposition: "bottom", attribute: 'alt'});
	$('#social .Microsoft_Live_Messenger_PresenceButton div div').css({'height':'18px','padding': '6px 0px'});
	$('#social .Microsoft_Live_Messenger_PresenceButton span').css({'font-family':'arial','font-size': '7pt', 'font-weight': 'bold'}).html("CHAT EN VIVO");
	$('#m_marca').change(function() {
		if($(this).val() == ''){
			location.href = 'productos/';
		}else{
			location.href = 'productos/?es=productos.marca-'+$(this).val();
		}
	});
	if ($("div.novedades").length > 0) {
		$('div.splash div.actual a').click(function(event){var numnuevo = $(this).attr('id').split("splash-").slice(1);cambiarsplash(numnuevo);event.preventDefault();});
		rotateSwitch = function(){
				play = setInterval(function(){ //Set timer - this will repeat itself every 7 seconds
				$active = $('div.splash div.actual a.active').next(); //Move to the next paging
				if ( $active.length === 0) { //If paging reaches the end...
					$active = $('div.splash div.actual a:first'); //go back to first
				}
				var numnuevo = $active.attr('id').split("splash-").slice(1)
				cambiarsplash(numnuevo); //Trigger the paging and slider function
				}, 5000); //Timer speed in milliseconds (7 seconds)
			};
		$("div.novedades").hover(function() {
			clearInterval(play); //Stop the rotation
		}, function() {
			rotateSwitch(); //Resume rotation timer
		});	
		rotateSwitch();
		
	}
});
$(window).load(function () {
	baseload();
});
