function collapseAllFrames(){
	collapseAll()
}


function collapseAll(){
	collapseMenu("menu_Centros");
}


function collapseMenu(id) {
    var obj = document.getElementById(id);
	if (obj!=null)
	{
		if (obj.style.display == '')
		{
			if(id == 'actualizarDatosMenu'){
				document.getElementById('consultas').style.display='';
			}

			obj.style.display = 'none';
		}
		    
	}
}

function collapsableMenuAction(menu_id){
	var menu = document.getElementById(menu_id);
	if (menu.style.display==''){
            menu.style.display='none';

     }else{            
			collapseAllFrames();
			menu.style.display='';

     }
}


   function displayDropDownMenu (menu_id){


		var link_id=menu_id+"_lnk";
		var menu = document.getElementById(menu_id);
		var link = document.getElementById(link_id);

        if (menu.style.display==''){
            menu.style.display='none';

        }
        else{      
			collapseAllFrames();
			collapseAllFrames();			
			menu.zIndex='10';		
            menu.style.left=findPosX(link)-10+'px';
            menu.style.top=findPosY(link)+18+'px';
			
            menu.style.display='';
        }
    }

function displayDropUpMenu (menu_id,modif_x,modif_y){
		
		var body =window.frames[0];
		
		var link_id=menu_id+"_lnk";
		var menu = document.getElementById(menu_id);
		var link = document.getElementById(link_id);
		

        if (menu.style.display==''){
            menu.style.display='none';

			document.getElementById('consultas').style.display='';
        }
        else{      		
			collapseAllFrames();
			collapseAllFrames();			
            menu.style.left=findPosX(link)+modif_x+'px';
            menu.style.top=findPosY(link)-modif_y+'px';

            menu.style.display='';
        }
    }



function marcarOpcionMenu(opcion){
    if (document.getElementById(opcion)){
        document.getElementById(opcion).className="menuOptionRowOver";        
    }
}
                                                                                
function resetOpcionMenu(opcion){
        if (document.getElementById(opcion)){
            document.getElementById(opcion).className="menuOptionRow";            
        }
}

function marcarOpcionMenuVG(opcion){
    if (document.getElementById(opcion)){
        document.getElementById(opcion).className="menuOptionRowOverVanGogh";        
    }
}
                                                                                
function resetOpcionMenuVG(opcion){
        if (document.getElementById(opcion)){
            document.getElementById(opcion).className="menuOptionRowVanGogh";            
        }
}

function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}



/*Funciones a utilizar por el reminder de cierre de sesion*/
function opacity(id, opacStart, opacEnd, millisec) {
		//speed for each frame
		var speed = Math.round(millisec / 100);
		var timer = 0;

		//determine the direction for the blending, if start and end are the same nothing happens
		if(opacStart > opacEnd) {
			for(i = opacStart; i >= opacEnd; i--) {
				setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
				timer++;
				
			}
		} else if(opacStart < opacEnd) {
			for(i = opacStart; i <= opacEnd; i++)
				{
				setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
				timer++;
			}
		}
	}

	//change the opacity for different browsers
	function changeOpac(opacity, id) {
		if(opacity==0){
			document.getElementById(id).style.display = 'none';
		}else{
			document.getElementById(id).style.display = '';
		}
		var object = document.getElementById(id).style;
		object.opacity = (opacity / 100);
		object.MozOpacity = (opacity / 100);
		object.KhtmlOpacity = (opacity / 100);
		object.filter = "alpha(opacity=" + opacity + ")";
	} 

	function shiftOpacity(id, millisec) {
		//if an element is invisible, make it visible, else make it ivisible
		
		if(document.getElementById(id).style.opacity == 0) {			
			opacity(id, 0, 100, millisec);
			//document.getElementById('sessionReminder').style.display='none';
		} else {			
			opacity(id, 100, 0, millisec);
		}
	}

function displayReminder (){

		var reminder = document.getElementById('sessionReminder');
		var link = document.getElementById('logoutLink');

		reminder.zIndex='10';		
		reminder.style.left=findPosX(link)-160+'px';
		reminder.style.top=findPosY(link)-18+'px';

		changeOpac(0,'sessionReminder'); //Seteo opacidad a 0
	
		
		setTimeout("opacity('sessionReminder', 0, 100, 500)",0);

		setTimeout("opacity('sessionReminder', 100, 0, 500)",10000); //Fade out
    }