<!--
/*
*	Autor: Pablo Salaberri
*	Descripción:
*		Módulo gestor de menus
*
*
*
*/






/*
 * 	función de gestión gráfica de listados
 * 		modifica el estilo CSS del elemento elegido por nombre y
 * 		nombre de estilo
 */
 

//****************************Gestión de un menu

var array_menu = new Array();

function register_menu_element(boton){
	
	var a = arguments;
	
	if (a.length>5){
			alert('Error in arguments number '+boton);
			return;
	}
	
	var imenu = array_menu.length;
	array_menu[imenu] = new Array(5);
	array_menu[imenu][0]=boton;
	array_menu[imenu][1]=false; //Estado del boton
	if (a.length == 3) {
		
		array_menu[imenu][2]='cssbutton';
		array_menu[imenu][3]=a[1];
		array_menu[imenu][4]=a[2];

	}
	else{
		for (i=1; i< a.length;i++){
			
			array_menu[imenu][i+1]=a[i];
			
		}
		
		if (array_menu[imenu][i]=='selected'){
			array_menu[imenu][1]=true;
			
		}
	}
	
	set_actions(boton);
	
}

function set_menu_image(boton,number){
	
	for (i=0; i< array_menu.length;i++){
		
		if(boton.id==array_menu[i][0]){
				
					if (array_menu[i][2]=='cssbutton'){
								
						if (number==2){
							
							boton.className = array_menu[i][3];
						}
						else {
							
							boton.className = array_menu[i][4];
						}
					}
					else{
						//alert(array_menu[i]+"  NUMERO:"+number);
						if (array_menu[i][1]==true) return;
						boton.src=array_menu[i][number];
						
					}
					
		}
	}
}
function refresh_menu(boton){

	for (i=0; i< array_menu.length; i++){

			array_menu[i][1]=false;
			var objBoton = findObj(array_menu[i][0]);
			objBoton.src=array_menu[i][2];
	}
}
function set_pressed(boton){
	refresh_menu(boton);
	var i = get_menu_index(boton);
	
	if (i != null){
		
		set_menu_image(boton,4);
		array_menu[i][1]=true;
	}
	
}
function get_menu_index(boton){
	
	for (i=0; i< array_menu.length; i++){
			if (boton.id==array_menu[i][0]){
				return i;
			}
			
	}
	return null;	
}

function menu_over(boton){
	var i = get_menu_index(boton);
	
	if (array_menu[i][1]==true) return;
	set_menu_image(boton,4);
	
	
}
function menu_out(boton){
	var i = get_menu_index(boton);
	
	if (array_menu[i][1]==true) return;
	set_menu_image(boton,2);
	
}


function set_actions(boton){
	
	var botonobj = getObject(boton);
	
	botonobj.onmouseover = function(){
			
			menu_over(this);
	}
	botonobj.onmouseout = function(){
			menu_out(this);
	}
	botonobj.onmousedown = function(){
			set_pressed(this);
	}
	

}

function menuaction(action,form){
	var current = window.location;
	var uri_path = current.toString();
	var path = uri_path.split("?");
	//Obtenemos el elemento _file_
	action = set_ssn_action(action);
	var new_path=path[0]+'?'+action;
	window.location = new_path.toString();
	return true;
}
function set_element_value(id,valor){
	var act = findObj(id);
	if(act != null){
		act.value = valor;
	}
	
	return true;
	
	
}
function get_element_value(id){
	var act = findObj(id);
	
	return act.value;
	
}
function set_action_value(id,valor){
	var act = findObject(id);
	if(act != null){
		act.value = valor;
	}
	return true;
	
	
}
var getvalue = new Array();

function set_get_value(variable,valor){
	var nueva = true;
	
	for (var i=0; i<getvalue.length;i++){
		if(getvalue[i][0]==variable){
	
			nueva = false;
			getvalue[i][1]=valor;
		}
	}
	if (nueva){
	
		getvalue[getvalue.length] =new Array(variable,valor);
	}
	
	return void(0);
}
function implode_array(glue,array){
	var ret='';
	
	for (var i = 0; i < array.length; i++){
		
		ret = ret+array[i][0]+'='+array[i][1];
		if (i < (array.length-1)){
			ret +=glue;
		}
	}
	return ret;
}
function go_get(){
	var current = window.location;
	var uri_path = current.toString();
	var path = uri_path.split("?");
	//Obtenemos el elemento _file_
	var get=implode_array('&',getvalue);
	var new_path=path[0]+'?'+get;
	
	window.location = new_path.toString();
	return true;
	
	
}
//-->