var scrollItems;
var scrollPos = 0;
var itemWidth = 0;
var timmer;

$(document).ready(function(){
	$("#flashContador").flash({
		swf : 'swf/contador.swf',
		width: 282,
		height: 13,
		params : {
			wmode : 'transparent',
			flashvars: {
				day : 18,
				month : 10,
				year : 2010,
				txt1 : $("#flashContador").attr("faltan"),
				txt2 : $("#flashContador").attr("dias"),
				txt3 : $("#flashContador").attr("horas"),
				txt4 : $("#flashContador").attr("minutos"),
				txt5 : $("#flashContador").attr("segundos"),
				baseColor : "#4E9EFB",
				otherColor : "#FFFFFF",
				titleColor : "#F4C836"
			}	
		}
	});
	
	$("#flashVideo").flash({
		swf : 'swf/Video.swf',
		width: 225,
		height: 150,
		params : {
			wmode : 'transparent'	
		}
	});
	
	$("#flashHome").flash({
		swf : 'swf/'+$("#flashHome").attr("idioma")+'/fotos_int.swf',
		width: 774,
		height: 273,
		params : {
			wmode : 'transparent'	
		}
	});
	
	initScroll();
});

function initScroll(){
	scrollItems = $("#ticker .items .item").length;
	itemWidth = parseInt($("#ticker .items .item").css("width"));
	$("#ticker").mouseover(function(){
		$(document).stopTime();
	}).mouseout(function(){
		startTime();
	});
	
	startTime();
}

function startTime(){
	$(document).everyTime(3000, function(i) {
		moveScroll();
	});
}

function moveScroll(){
	scrollPos++;
	if(scrollPos == scrollItems){
		scrollPos = 0;
	}
	gotoItem(scrollPos);
}

function gotoItem(position){
	posLeft = position * itemWidth;

	$("#ticker div.items").animate({
		left : 0 - posLeft
	}, 250);
}