var scrollSpeed = 100;       // Speed in milliseconds
var scrollSpeed2 = 170;       // Speed in milliseconds
var step = 1;               // How many pixels to move per step
var currentGblo = 960;            // The current pixel row
var imageWidthGlo = 45;     // Background image height
var headerWidthGlo = 960;     // How tall the header is.
var restartPositionGlo = - ( headerWidthGlo - imageWidthGlo);

var currentPara = 20;            // The current pixel row
var imageWidthPara = 45;     // Background image height
var headerWidthPara = 960;     // How tall the header is.
var restartPositionPara = - ( headerWidthPara - imageWidthPara);

var currentPara2 = 960;            // The current pixel row
var imageWidthPara2 = 45;     // Background image height
var headerWidthPara2 = 960;     // How tall the header is.
var restartPositionPara2 = - ( headerWidthPara2 - imageWidthPara2);

function scrollBg(){
	currentPara2 -= step;
	if (currentPara2 == restartPositionPara2){
			currentPara2 = 960;
	}
	currentPara += step;
	if (currentPara == restartPositionPara){
			currentPara = 20;
	}
	$('#parapentitoDiv').css("background-position",currentPara+"px"+" 0 ");
	$('#parapenteDiv').css("background-position",currentPara2-5+"px"+" 0 ");
}
function scrollBg2(){
	currentGblo -= step;
	if (currentGblo == restartPositionGlo){
			currentGblo = 960;
	}
	$('#parapenteGloboDiv').css("background-position",currentGblo+"px"+" 0 ");
}
var init = setInterval("scrollBg()", scrollSpeed);
var init2 = setInterval("scrollBg2()", scrollSpeed2);

$(document).ready(function(){
  $(".fotoMiniatura a").prepend("<span></span>");
	$(".fotoMiniatura a").colorbox();

  $("a.linkVideo").prepend("<span></span>");
	$("a.linkVideo").colorbox();

});



$(document).ready(function () {
		var pageTracker;													
    $.getScript('http://www.google-analytics.com/ga.js', function () {
			if (typeof(_gat) == 'object') {
					pageTracker = _gat._getTracker('UA-3294314-1');
					pageTracker._initData();
					pageTracker._trackPageview();
					var fin = new Date;

					mlsegundos = fin.getTime() - inicio.getTime();
					valoracion = "";
					if (mlsegundos < 2000) {
							valoracion = "Muy Rapido";
					} else if (mlsegundos < 5000) {
							valoracion = "Rapido";
					} else if (mlsegundos < 10000) {
							valoracion = "Medio-Lento";
					} else if (mlsegundos < 30000) {
							valoracion = "Lento";
					} else {
							valoracion = "Catastrofe";
					}
					pageTracker._trackEvent("Tiempo Carga", valoracion, document.location.pathname, Math.round(mlsegundos / 1000));
			} 
    });

		$('img').error(function () {
        pageTracker._trackEvent('Error', 'Imagen_rota', $(this).attr('src'));
    });

		$('a').each(function () {
        var href = $(this).attr('href');
        if ((href) && (href.match(/^https?\:/i)) && (!href.match(document.domain))) {
            $(this).click(function () {
                var destino = href.replace(/^https?\:\/\//i, '');
                pageTracker._trackEvent('External', 'Click', destino);
            });
        }
    });
	$('.bubble a').each(function () {
		$(this).attr({
			target: "_blank"
		})	
	});
});
