var paused = false;
var n = 1;
var current = 0;
function fx(){
	var imgList = $$('#container #fotos img');
	if(paused == false){
		imgList[current].fade(1, 0);
		imgList[n].fade(0, 1);
		if(imgList.length == n+1){
			current = n;
			n = 0;
		}else{
			current = n;
			n++;
		}
		gtime = setTimeout("fx()", 3500);
	}
}
window.addEvent('domready', function(){
	if($chk($('fotos'))){
	var imgList = $$('#container #fotos img');
	$each(imgList, function(el){
		el.setStyle('opacity', 0);
		el.setStyle('display', 'inline');
	});
	/*$('pause').addEvent('click', function(ev){
		var ev = new Event(ev).stop();
		if(paused == false){
			clearTimeout(gtime);
			paused = true;
			$('pause').setStyle('background-position', '-20px 0');
		}else{
			paused = false;
			$('pause').setStyle('background-position', '0 0');
			fx();
		}
	});*/
	if($('texto').getStyle('height').toInt() > 400){
		$('container').setStyle('height', $('texto').getStyle('height').toInt() + 40);
	}
	//alert($('fotos').getStyle('height').toInt());
	if($('fotos').getStyle('height').toInt() > $('texto').getStyle('height').toInt() && $('fotos').getStyle('height').toInt() > 400){
		$('container').setStyle('height', $('fotos').getStyle('height').toInt() + 40);
	}
	}
	if($chk($('player'))){
		//$('foto1').setStyle('display', 'none');
		if($chk($('item-1'))) $('item-1').addEvent('click', function(ev){
			ev = new Event(ev).stop();
			$('player').sendEvent("ITEM",0);
		});
		if($chk($('item-2'))) $('item-2').addEvent('click', function(ev){
			ev = new Event(ev).stop();
			$('player').sendEvent("ITEM",1);
		});
		if($chk($('item-3'))) $('item-3').addEvent('click', function(ev){
			ev = new Event(ev).stop();
			$('player').sendEvent("ITEM",2);
		});
	}
	
	var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
	new Asset.javascript(gaJsHost + "google-analytics.com/ga.js", {
	    onload: function(){
			try {
				var pageTracker = _gat._getTracker("UA-8353726-1");
				pageTracker._trackPageview();
			} catch(err) {}
	    }
	});
});
window.addEvent('load', function(){
	if($chk($$('#container #fotos img')[0])){
	var imgList = $$('#container #fotos img');
	imgList[0].fade(0, 1);
	$('fotos').setStyle('background-image', 'none');
	if(imgList.length > 1){
		if(paused == false){
			//$('pause').setStyle('display', 'block');
			gtime = setTimeout("fx()", 3500);
		}
	}
	}
});
