/**
 * @author hector.garcia
 */

function showOptions(section){
	var options = document.getElementById("optionsMenu_|"+section);
	var active_section = document.getElementById('currentsection');
	var active_options = document.getElementById('optionsMenu_|'+active_section.value);
	
	//Primero hacemos fadeout de las opciones asociadas ( en caso de que haya)
	if (active_options) {
		Ext.fly(active_options).slideOut('t', {useDisplay: true});
		//Le quitamos el visibility para que no "ocupe" espacio
		var a_identificator = active_options.id.split("_|");
	}	
	if(!a_identificator){
		var a_identificator  = Array();
		a_identificator [1] = active_section.value;
	}
	var a_selected = document.getElementById("a_" + a_identificator[1]);
	if (active_section.value != 'home') {
		if (a_selected && (a_selected.className = 'section_selected')) 
			a_selected.className = '';
	}
	
	if (section != active_section.value || (active_options && active_options.style.display=="none")) {
		var new_a_selected = document.getElementById("a_" + section);
		new_a_selected.className = "section_selected";
		Ext.fly(options).slideIn('t', {
			useDisplay: true
		});
		active_section.value = section;
	}

}

function fixHomeLaRioja(){
	var homeImage = document.getElementById("home_image");
	if (homeImage) {
		if (navigator.appVersion.indexOf("MSIE 6.0") != -1) {
			homeImage.style.marginLeft = 0;
		}
	}
}
/*function fixImprimir(){
	//funcion para arreglar en caso de que fuera necesario
	//javascript:wprinter('contenidos','ficheros');
	var url = parent.document.location.href;
	var section;
	var option = "";
	var a_imprimir = document.getElementById('a_printer');
	if(a_imprimir){
		url = url.split('?');
		url = url[1];
		section = url.split('&');
		section = section[0];
		section = section.split("=");
		section = section[1];
		url = url.split('&');
		for(i=1;i<=(url.length-1);i++){
			var tempOption = '';
			if(url[i].indexOf("option")!=-1){
					url[i] = url[i].split("=");
					url[i] = url[i][1];
			}
			if(option=='')
				option = url[i];
			else	
				option = option + "&" + url[i];
		}
		a_imprimir.href = "javascript:wprinter('"+section+"','"+option+"')";
	}
}
*/
addEvent(window, 'load', fixHomeLaRioja);
//addEvent(window, 'load', fixImprimir);