// JavaScript Document

var centrod=false;
var muevder=0;
var hacia=-1; //1 derecha, -1 izquierda
var eltiempob=5000;
var sipuedo=true;
var sigmov=0;
var tamimg=933;
var elugar=0;
var eltmout=0;

$(document).ready(function(e) {
	$('#bizq').click(function () {
		if(sipuedo&&parseInt($('#divmov').css("left"))!=0) {
			clearTimeout(eltmout);
			hacia=1;
			movBanner();
		}
	});
	$('#bder').click(function () {
		if(sipuedo&&parseInt($('#divmov').css("left"))!=-2799) {
			clearTimeout(eltmout);
			hacia=-1;
			movBanner();
		}
	});
	eltmout=setTimeout("movBanner()",eltiempob);
	//setTimeout("mueveCentro()",10000);
});

function mueveCentro() {
	if(centrod) {
		$('.denin').animate({
			"top":"-430px"
		},1500,function () { 
			setTimeout("mueveCentro()",10000);
		});
		centrod=false;	
	}
	else {
		$('.denin').animate({
			"top":"0px"
		},1500,function () { 
			setTimeout("mueveCentro()",10000);
		});
		centrod=true;
	}
}

function movBanner() {
	if((parseInt($('#divmov').css("left"))+tamimg*hacia)==-3732) {
		hacia*=-1;	
	}
	else if((parseInt($('#divmov').css("left"))+tamimg*hacia)>0) {
		hacia*=-1;
	}
	elugar=parseInt($('#divmov').css("left"))+tamimg*hacia;
	sipuedo=false;
	$('#divmov').animate({"left":elugar+"px"},1500,"linear", function () {
		sipuedo=true;
		eltmout=setTimeout("movBanner()",eltiempob);
	})
}


