﻿$('.enmain').live('click', function(e) {
					if($(this).attr('href').indexOf('#')==-1 && $(this).attr('target')==""){
						$('#main').load($(this).attr('href'), function(){
							$('#main').scrollTop(0);
							if ($('h1:first',this).length > 0){
								$('#slogo').html('<span>'+$('h1:first',this).html()+'</span>');
							}else{
								$('#slogo').html(' ');
							}
							actcoveflow(); 
							
						});
						
				cargamenu();
				actcoveflow(); 
				return false;
				}
});	
 
function actcoveflow(){
	$("img", ".moveme").each(function() {
		$(this).attr("href",$(this).attr("src").split('/mini/').join('/galerias/'));
		$(this).attr('style',' ');
		$(this).attr("src",$(this).attr("src").split('/galerias/').join('/mini/'));
		$(this).attr('clicka','false');
	});	
		$('h1:first','#main').each(function() {
			$(this).html($(this).html().toUpperCase());
		});	
	

	
			$(".coverflow").prepend('<div class="cotit"></div><div><a href="#" id="previousi"><img src="images/izq_off.png" border=0></a></div><div><a href="#" id="nexti"><img src="images/der_off.png" border=0></a></div>');
			
			$(".coverflow").css({
				position: 'absolute',
				'margin-bottom': '60px',
				width: $("#main").width()*0.6
			});
			$(".cotit").css({
				position: 'absolute',
				height:'20px',
				left:'-80px',
				padding:'5px',
				top:'210px',
				'background-color': '#535353',
				color: '#fff',
				'font-size': '15px',
				'font-weight': 'bold',
				'text-align': 'center',
				zIndex: '1100',
				width: $(".coverflow").width()+150
			});									
			$("#previousi").css({
				position: 'absolute',
				left: '-80px',
				top: '13px'
			});
			$("#nexti").css({
				position: 'absolute',
				left: $(".coverflow").width()+50,
				top: '13px'
			});

			$("#previousi").mousedown( function() {
				veloc=-10;
			});
			$("#previousi").mouseup( function() {
				veloc=-5;
			});
			$("#nexti").mousedown( function() {
				veloc=10;
			});
			$("#nexti").mouseup( function() {
				veloc=5;
			});
			$("#previousi").mouseover( function() {
			
				veloc=-5;
				$('.moveme').each(function() {
					$(this).attr('clicka','false');
					$('img',this).unbind();
				});
				$("img","#previousi").attr("src","images/izq_on.png");
				timer=setInterval( function() {$('.coverflow').roundabout_adjustBearing(veloc);}, 1);
			});
			$("#nexti").mouseover( function() {
				veloc=5;
				$('.moveme').each(function() {
					$(this).attr('clicka','false');
					$('img',this).unbind();
				});
				$("img","#nexti").attr("src","images/der_on.png");
				timer=setInterval( function() {$('.coverflow').roundabout_adjustBearing(veloc);}, 1);
			});
			$("#previousi").mouseout( function() {
				veloc=0;
				$("img","#previousi").attr("src","images/izq_off.png");
				clearInterval(timer);

			});
			$("#nexti").mouseout( function() {
				veloc=0;
				$("img","#nexti").attr("src","images/der_off.png");
				clearInterval(timer);

			});	
			$('.moveme').focus(function(e) {
			//hacer un for con opacidades de los elementos
				if ($(this).css('opacity')==1){
					$('.cotit').html($('img',this).attr('title'));
					$('img',this).lightBox();
					if ($(this).attr('clicka')=='true'){
						$('img',this).click();
					}
				}else{
					$('.cotit').html('');
					$('img',this).unbind();
				}
				
			});
			$('.moveme').click(function(e) {
				$('.moveme').attr('clicka','false');
				$(this).attr('clicka','true');
			});	
		$('.coverflow').roundabout({
			childSelector: '.moveme',
			easing: 'swing',
			duration: 1600,
			tilt: -2,
			clickToFocus:true
		});

	


}
