jQuery(document).ready(function() {

		var Tamanyo = [0, 0];
    Tamanyo = 
		[ 
			document.documentElement.clientWidth,
			document.documentElement.clientHeight
    ];
		var mitad = Tamanyo[0];	
		
	//	alert('La ventana mide: [width:' + Tamanyo[0] + ', height: ' + Tamanyo[1] + ']');

	$(window).resize(function(){
			widthMenu();
		}
	);
	
	function widthMenu() {
	 //$('body').prepend('<div style="background:#055">' + $(window).width() + '</div>');
		var window_x = $(window).width();
		if(window_x > 1000){
			$('#ulMenu').css({'margin-left':'100px'});
			$('#logo').css({'width':'189px','height':'62px','margin':'0 0px 0 0 '});
			$('#imgSeccion1').css({'width':'auto','height':'auto','margin-left':'10px'});
			$('#imgSeccion2').css({'width':'auto','height':'auto','margin-left':'10px'});
			$('#imgSeccion3').css({'width':'auto','height':'auto','margin-left':'10px'});
			$('#imgSeccion4').css({'width':'auto','height':'auto','margin-left':'10px'});
			$('#imgSeccion5').css({'width':'auto','height':'auto','margin-left':'10px'});
			$('.header').css({'margin-left':'50%','left':'-460px'});
			//$('#people').css({'margin-left':'50%','left':'-490px'});
			//$('.contBrands').css({'margin-left':'50%','left':'-308px'});
			//$('#contenedorSliderCategorias').css({'margin-left':'50%','left':'-400px'});
			//$('#contMenuClientes').css({'margin-left':'50%'});
		}
		if(window_x <= 1000){
			$('#ulMenu').css({'margin-left':'120px'});
			$('#logo').css({'width':'120px','height':'42px','margin':'10px 0px 0 0px'});
			$('#imgSeccion1').css({'width':'55px','height':'18px','margin-left':'0px'});	
			$('#imgSeccion2').css({'width':'93px','height':'18px','margin-left':'0px'});
			$('#imgSeccion3').css({'width':'94px','height':'18px','margin-left':'0px'});
			$('#imgSeccion4').css({'width':'80px','height':'18px','margin-left':'0px'});
			$('#imgSeccion5').css({'width':'80px','height':'18px','margin-left':'0px'});			
			$('.header').css({'margin-left':'0%','left':'0px'});
			//$('#people').css({'margin-left':'auto','margin-right':'auto','left':'0'});			
			//$('.contBrands').css({'margin-left':'auto','margin-right':'auto','left':'0'});
			//$('#contenedorSliderCategorias').css({'margin-left':'0%','left':'0px'});
		//	$('#contMenuClientes').css({'margin-left':'35%'});
		}
	}
	var scrollTop = $(window).scrollTop();			
	var scroll_actually= new Array();// identifica valoares del background X y Y
		
	$(window).scroll(function(){
	//this is not the cleanest way to do this, I'm just keeping it short.
	//top del scroll
		
		document.getElementById('consola').innerHTML = $(this).scrollTop();
		var top = parseFloat($(window).scrollTop());
	
		
		if (top >= 0 && top <= 382){
			$('#seccion1').css('background-position','0 '+(top/3)*(-1)+'px');
			$('.contenedorMove').css('top', +top/2*(-1)+'px');
			$('.menu').removeClass('menuHover');
			$('#imgSeccion1').addClass('menuHover');
			
		}
		if (top >= 0 ){
			$('.bk_inter1').css('margin-top',(top)*(-1)+'px');
			//$('.bk_inter1').css('background-position','0 '+(top/2)*(-1)+'px');
		}
		if (top >= 246){
			$('#seccion2').css('background-position','0 '+(top/2)*(-1)+'px');
			$('.menu').removeClass('menuHover');
			$('#imgSeccion2').addClass('menuHover');
		}
		if (top >= 246 ){
			$('#people').css('top', +top/5*(-1)+'px');			
		}	
		if (top >= 0 ){
			$('.bk_inter2').css('margin-top',760+(top)*(-1)+'px');
		}			
		if (top >= 1005){
			$('#seccion3').css('background-position','0 '+(top/9)*(-1)+'px');
			$('.menu').removeClass('menuHover');
			$('#imgSeccion3').addClass('menuHover');
		}	
		if (top >= 1005 ){
			$('.contBrands').css('top', +top/10*(-1)+'px');
		}
		if (top >= 0 ){
			$('.bk_inter3').css('margin-top',1520+(top)*(-1)+'px');
		}	
		if (top >= 1766	&& top <= 2682){
			$('#seccion4').css('background-position','0 '+(top/50)*(-1)+'px');
			$('.menu').removeClass('menuHover');
			$('#imgSeccion4').addClass('menuHover');
		}
		if (top >= 1766){
			$('#contenedorSliderCategorias').css('top', +(top/20)*(-1)+'px');
			$('#contMenuClientes').css('top',+(top/20)*(-1)+'px');			
			$('.bk_inter4').css('margin-top',2280+(top)*(-1)+'px');
		}	
		if (top >= 0	&& top <= 2530){
			$('#seccion5').css('background-position','0 -760px');
		}
		if (top >= 2530){
			$('#seccion5').css('background-position','0 '+(top/100)*(-1)+'px');
			$('.menu').removeClass('menuHover');
			$('#imgSeccion5').addClass('menuHover');
		}
		var initPos=0;			
		
	    
		if (getScrollTop()==0)
		// ajusta la posiciones y las reseatea en cero cuando hace 
		//scroll havciaa arriba
		{
			a=parseFloat(initPos);
			b=parseFloat(0);
			c=parseFloat(initPos);
			d=parseFloat(0);
			e=parseFloat(initPos);
			f=parseFloat(0);
			g=parseFloat(initPos);
			h=parseFloat(0);
			i=parseFloat(initPos);
			j=parseFloat(0);
			$('.bk_0').css('backgroundPosition', '0 0');	
			$('.bk_1').css('backgroundPosition', '0 0');
			$('.bk_2').css('backgroundPosition', '0 0');		
			$('.bk_3').css('backgroundPosition', '0 0');		
			$('.bk_4').css('backgroundPosition', '0 0');							
			$('.img_1').css('backgroundPosition', '50% 0');
			//$('.contenedorMove').css('top', '100px');
		}
	  scrollTop = $(this).scrollTop();		
	});
});
function getScrollTop(){ // verifica el calculo total en pixeles de toda la pagina

    if(typeof pageYOffset!= 'undefined'){
        //most browsers
        return pageYOffset;
    }
    else{
        var B= document.body; //IE 'quirks'
        var D= document.documentElement; //IE with doctype
        D= (D.clientHeight)? D: B;
        return D.scrollTop;
    }
}

function currentYPosition() {
	if (self.pageYOffset)
		 return self.pageYOffset;
	if (document.documentElement && document.documentElement.scrollTop)
		return document.documentElement.scrollTop;
	if (document.body.scrollTop)
		 return document.body.scrollTop;
	return 0;
}
function elmYPosition(eID) {
	var elm  = document.getElementById(eID);
	var y    = elm.offsetTop;
	var node = elm;
	while (node.offsetParent && node.offsetParent != document.body) {
		node = node.offsetParent;
		y   += node.offsetTop;
	} return y;
}
function smoothScroll(eID) {
	var startY   = currentYPosition();
	var stopY    = elmYPosition(eID);
	var distance= stopY-startY;
	var c_y=startY;
	var timer = 0;
	
	while (((stopY-c_y)>1)||(stopY-c_y<(-1)))	{
				
		var endPos = c_y+((stopY-c_y)/4);
		//alert("endPos " +endPos + " c_y " +c_y + " final "+stopY);
		
		$('.themshock_banner').css({'display':'none'});
		setTimeout("window.scrollTo(0,"+endPos+")",timer * 60);
		timer++
		c_y=endPos;
		
		//alert("distan " +distance + " c_y " +c_y);
	}
	$('.themshock_banner').delay(1500).fadeIn('fast');

}




