// JavaScript Document

//despliega el evento actual
function despliegaAgenda (idevent) {
    if(document.getElementById('eventoprox'+idevent) != null){
        $('eventoprox'+idevent).morph('width:374px;',{duration:0.3});
        $('eventoprox_info'+idevent).morph('width:215px;',{duration:0.3});
        $('eventoprox_title'+idevent).morph('font-size:17px;',{duration:0.3});
        $('eventoprox_txt'+idevent).appear({duration:0.2}); 
        $('eventoprox_img'+idevent).morph('left:225px;',{duration:0.4});
    }
}

//semipliega todos los eventos al desplegar uno
function semipliegaAgenda () {
    for (var i=0;i<4;i++){ //poner aqui el numero de eventos de agenda
        if(document.getElementById('eventoprox'+i) != null){
	        $('eventoprox'+i).morph('width:74px;',{duration:0.2});
	        $('eventoprox_info'+i).morph('width:65px;',{duration:0.4}); 
	        $('eventoprox_title'+i).morph('font-size:12px;',{duration:0.3});
	        $('eventoprox_txt'+i).hide();
	        $('eventoprox_img'+i).morph('left:-75px;',{duration:0.2});
	    }
    }
}

//vuelve la agenda al estado inicial cuando no hay ninguno desplegado
function pliegaAgenda () { //poner aqui el numero de eventos de agenda
    for (var i=0;i<4;i++){
        if(document.getElementById('eventoprox'+i) != null){
	        $('eventoprox'+i).morph('width:149px;',{duration:0.2}); 
	        $('eventoprox_info'+i).morph('width:65px;',{duration:0.4});
	        $('eventoprox_title'+i).morph('font-size:12px;',{duration:0.3});
	        $('eventoprox_txt'+i).hide();
	        $('eventoprox_img'+i).morph('left:0px;',{duration:0.3});
	     }
	}
}

//ejecuta todo coordinado
function showAgenda(idevent){
	obj=document.getElementById('eventoprox'+idevent);
	if(parseInt(obj.style.width)>149){
		pliegaAgenda();
	}else{
		semipliegaAgenda(); 
		despliegaAgenda(idevent);		
	}
}
//lanza la ampliacion de info
function showAmpliaAgenda(url){
	//document.getElementById('video_int').style.display='none';
	if(document.getElementById('video_int') != null){
	    $('video_int').switchOff();
	}
	$('lightbox_content_int').appear(),{duration:0.3}; 
	cargaAjax('lightbox_content_int', url); 
	pliegaAgenda();
}

function closeAmpliacionAgenda(url){
	$('lightbox_content_int').switchOff(); 
	if(document.getElementById('video_int') != null){
	$('video_int').appear();
	}
	//document.getElementById('video_int').style.display='block';
}

//lanza la ampliacion de barracaplus
function showAmpliaBPlus(url){
	//document.getElementById('video_int').style.display='none';
	if(document.getElementById('video_int') != null){
	    $('video_int').switchOff();
	}
	$('lightbox_bplus_content').appear(),{duration:0.3}; 
	cargaAjax('lightbox_bplus_content', url); 
	pliegaAgenda();
}

function closeAmpliacionBplus(url){
	$('lightbox_bplus_content').switchOff();
	if(document.getElementById('video_int') != null){
	    $('video_int').appear();
	}
	//document.getElementById('video_int').style.display='block';
}
