//Acordeon //Crea un acordeon para mostrar y ocultar elementos
//Se usa en  Pacientes->Información general
function accordion(detectId,openId,expandId,closeId,clase) {
    fadeDur = 0.15 // Fade out duration
    AppearDur = 0.15 // Fade in duration
    SlideDur = 0.3 // Panel slide duration
    detectId = $(detectId); // So we can detect if the panel is currently visible or not before we run the condition
    openId = $(openId); // The element we click on to open a panel,
    expandId = $(expandId); // The panel we want to expand
    closeId = $(closeId); // The element we click on to close a panel, 
    if(detectId.visible(detectId))
        Effect.BlindUp(expandId,{duration: SlideDur});
    else
    {
        var x = document.getElementsByClassName(clase);
        for(var i=0;i<x.length; i++)
        {
            if(Element.visible(x[i])){
                Effect.BlindUp(x[i],{duration: 0.2});
            }
        }
        Effect.BlindDown(expandId,{duration: 0.2, afterFinish: function(obj){new Effect.ScrollTo(expandId)}});
    }
}
function creaPopupEnlace(txt,event){
	var x;
	var y;
	Element.hide('popupEnlace');
	y=event.clientY + document.documentElement.scrollTop  -20;
	x=event.clientX + document.documentElement.scrollLeft +20 ;
	Element.setStyle('popupEnlace',{top: ' '+y+'px'});
	Element.setStyle('popupEnlace',{left: ' '+x+'px'});
	$('popupEnlace').innerHTML=txt;
	Element.show('popupEnlace');


}
function ponerEnlacesGrisesyMarcarEste(clase,llamador){
	var x = document.getElementsByClassName(clase);
	for(var i=0; i<x.length; i++)
	{
		Element.setStyle(x[i],{color: '#555'});
	}
		Element.setStyle(llamador,{color: '#000'});

}
/*function updateDiv(div,url) {
	Effect.Fade(div,{ duration: 0.3, afterFinish: function (obj) { new Ajax.Updater(div,url,{asynchronous:true, evalScripts:true});new
	Effect.Appear(div,{duration: 0.3}) }});
}
*/
function hidecampos(){
	var x = document.getElementsByClassName('sl');
	for(var i=0; i<x.length; i++)
	{
		Element.hide(x[i]);
	}
}

