jQuery(document).ready(function(){
	jQuery.espazoPrincipal = { 
		auto : true,
		activo : 0
	}

	setTimeout(function() {
		if(jQuery.espazoPrincipal.auto){
			jQuery(".containerSlider").animate({ scrollLeft: (960) }, "slow");
			jQuery('.control span').removeClass('step-on');
			jQuery('.control span').removeClass('stepvideo-on');
			jQuery('.control span').addClass('step');
			jQuery('.control .2').addClass('step-on');
			jQuery.espazoPrincipal.activo = 1;
		}
		}, 18000);
	setTimeout(function() {
		if(jQuery.espazoPrincipal.auto){
			jQuery(".containerSlider").animate({ scrollLeft: (1920) }, "slow");
			jQuery('.control span').removeClass('step-on');
			jQuery('.control span').removeClass('stepvideo-on');
			jQuery('.control span').addClass('step');
			jQuery('.control .3').addClass('step-on');
			jQuery.espazoPrincipal.activo = 2;
		}
		}, 29000);
	setTimeout(function() {
		if(jQuery.espazoPrincipal.auto){
			jQuery(".containerSlider").animate({ scrollLeft: (2880) }, "slow");
			jQuery('.control span').removeClass('step-on');
			jQuery('.control span').removeClass('stepvideo-on');
			jQuery('.control span').addClass('step');
			jQuery('.control .4').addClass('stepvideo-on');
			jQuery.espazoPrincipal.activo = 3;
		}
		}, 38000);


	jQuery('.step.derecha').live('click',function(event) {
		var target = jQuery(this);
		var slide = jQuery.espazoPrincipal.activo + 1;
		if (slide > 3) slide = 3;
		jQuery.espazoPrincipal.activo = slide;
		jQuery.espazoPrincipal.auto = false;
		jQuery(".containerSlider").animate({ scrollLeft: (960*slide) }, "slow");
		jQuery('.control span').removeClass('stepvideo-on');
		jQuery('.control span:last-child').removeClass('step');
		jQuery('.control span:last-child').addClass('stepvideo');

		if (slide == 3) jQuery('.control span:last-child').addClass('stepvideo-on');
	});

	jQuery('.step.izquierda').live('click',function(event) {
		var target = jQuery(this);
		var slide = jQuery.espazoPrincipal.activo - 1;
		jQuery.espazoPrincipal.activo = slide ;
		jQuery.espazoPrincipal.auto = false;
		jQuery(".containerSlider").animate({ scrollLeft: (960*slide) }, "slow");

		jQuery('.control span').removeClass('stepvideo-on');
		jQuery('.control span:last-child').removeClass('step');
		jQuery('.control span:last-child').addClass('stepvideo');

	});

	jQuery('.stepvideo').live('click',function(event) {
		var target = jQuery(this);
		jQuery(".containerSlider").animate({ scrollLeft: (2880) }, "slow");
		jQuery.espazoPrincipal.auto = false;
		jQuery('.control span').removeClass('step-on');
		jQuery('.control span').addClass('step');
		target.removeClass('step');

		target.removeClass('stepvideo');
		target.addClass('stepvideo-on');

	});
	jQuery('span.home').live('click',function(event) {
		var target = jQuery(this);
		jQuery(".containerSlider").animate({ scrollLeft: (960) }, "slow");
		jQuery.espazoPrincipal.auto = false;
		jQuery.espazoPrincipal.activo = 1;
		jQuery('.control span').removeClass('step-on');
		jQuery('.control span.2').addClass('step');
		var target2 = jQuery('.control .stepvideo-on');
		target2.removeClass('stepvideo-on');
		target2.addClass('stepvideo');

	});	
	jQuery("input[type=text]").focus(function(){
		// Select field contents
		this.value = "";
	});							
});
