var version = 0; var marginTop = 0;
if (navigator.appVersion.indexOf("MSIE")!=-1){
	temp=navigator.appVersion.split("MSIE")
	version=parseFloat(temp[1])
}
var cont = 1;

var language = "es";
if (document.location.href.indexOf("language") != -1){
	aux_language = document.location.href.split("language=");
	language = aux_language[1].substring(0,2);
}
function accionImprimir(){window.print(); return false;}
function accionVolver(){history.go(-(contGoTo)); return false;}
function accionVolverOrganigrama(){ 
	document.getElementById("imagenOrganigrama").src = "StaticFiles/ENAGAS/img/"+ organigramalang +"/organigramaQuienes1_3.gif";
	document.getElementById("capa1").style.display = 'block';
	document.getElementById("capa2").style.display = 'none';
	document.getElementById("capa3").style.display = 'block';
	document.getElementById("capa4").style.display = 'block';
	document.getElementById("capa5").style.display = 'block';
	document.getElementById("capa6").style.display = 'block';
	document.getElementById("capa7").style.display = 'block';
	document.getElementById("capa8").style.display = 'block';	
	document.getElementById("capa9").style.display = 'block';	
	document.getElementById("enlaceVolverOrganigrama").style.display = 'none';
	//se incializa a 0 de nuevo el padding
	objlstOrganigrama = document.getElementsByClassName("lista_organigrama")[0];
	objlstOrganigrama.style.paddingTop=0+"px";
	if (version==6) { objlstOrganigrama.style.marginTop = "-145px";}
	var contenidoImagen = document.getElementsByClassName("contenidoImagen")[0];
	contenidoImagen.style.height="380px";
	return false;
}

function accionMostrarImagen(evt){
	evt = (evt) ? evt : ((event) ? event : null);		
    if(evt){
		// para obtener el origen del evento (en este caso, el id del li que coincide con el nombre de la imagen)
	    var aux = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
    }
	who = aux.id;
	if((window.document.getElementById("mapaInfraestructuras")) || (window.document.getElementById("mapaInfraestructurasTransporte"))){
		document.getElementById("imagen").src = "StaticFiles/ENAGAS/img/imgMapa" + who + ".jpg";
		var au = document.getElementById("leyendaMapa").getElementsByTagName("ul")[0].getElementsByTagName("li");
		for(var i = 0; i < au.length; i++){ 
			au[i].className = au[i].getElementsByTagName("a")[0].id;	
			au[i].id = "";	
		}
		document.getElementById(who).parentNode.className = who;
		document.getElementById(who).parentNode.id = 'sel';
	}
	return false;
}
var para = 0;
var MostrarLista = {
	ItemSel : null,
	accionMostrarLista : function(evt){
		evt = (evt) ? evt : ((event) ? event : null);		
	    if(evt){
		    var aux = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
	    }
		who = aux.parentNode.parentNode; // Como el evento se propaga, nos situa en el nieto, por lo que hay que preguntar por el abuelo
		// si existe un valor, significa que hay un "ul" desplegado as&iacute; que lo ocultamos
		if(who.tagName == "LI"){
			if(MostrarLista.ItemSel) {
				MostrarLista.ItemSel.getElementsByTagName("ul")[0].style.display = 'none';
				para++
			}
			if(MostrarLista.ItemSel != who){
				who.getElementsByTagName("ul")[0].style.display = 'block';
				MostrarLista.ItemSel = who;
			}
			if(para > 1){
				who.getElementsByTagName("ul")[0].style.display = 'block';
				MostrarLista.ItemSel = who;
				para = 0;
			}
			return false;
		}
		else{
			return false;
		}
	}
}	

// devuelve un array con todos los objetos que tengan la clase que se le pase como parametro, se utiliza en el listado de los cargos
document.getElementsByClassName = function(className){
   var data = [];
   var node=(document.getElementById("cargos"))? document.getElementById("cargos"):document;
   var tags = (document.all) ? document.all  : node.getElementsByTagName("*");
   for(var i=0;i<tags.length;i++) { if(tags[i].className == className) data[data.length]=tags[i];}
   return data;
}

function accionMostrarCapa(evt){
	evt = (evt) ? evt : ((event) ? event : null);		
    if(evt){
    // para obtener el origen del evento (en este caso, la capa)
	    var aux = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
    }
	//who = aux.parentNode.id;
	who = aux.id;
	if(who + "Capa" == "graficoCapa"){
		document.getElementById("datosCapa").style.display = 'none';
		document.getElementById(who + "Capa").style.display = 'block';
		document.getElementById("grafico").className = 'sel';
		document.getElementById("datos").className = '';
	}
	if(who + "Capa" != "graficoCapa"){
		document.getElementById("graficoCapa").style.display = 'none';
		document.getElementById(who + "Capa").style.display = 'block';
		document.getElementById("grafico").className = '';
		document.getElementById("datos").className = 'sel';
	}
	return false;
}

function accionCambiarImagen(evt){ // para cambiar las imagenes en la seccion de organigramas
	evt = (evt) ? evt : ((event) ? event : null);		
    if(evt){
    // para obtener el origen del evento (en este caso, el id del li que coincide con el nombre de la imagen)
	    var aux = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
    }
	who = aux.parentNode.id;
	if(window.document.getElementById("imagenOrganigrama")){
		var altoImg = 0; var numItems = 9;
		document.getElementById("imagenOrganigrama").src = "StaticFiles/ENAGAS/img/"+ organigramalang +"/orgQuienes1_3" + who + ".gif";		
		document.getElementById("enlaceVolverOrganigrama").style.display = 'block';
		for (var i=1;i<=numItems;i++) { document.getElementById("capa"+i).style.display = 'none';}
		altoImg = document.getElementById("imagenOrganigrama").offsetHeight;
		objlstOrganigrama = document.getElementsByClassName("lista_organigrama")[0];
		objlstOrganigrama.style.paddingTop = altoImg + "px";
		//Solo para Firefox e IE7
		if (version !=6) {
			contenidoImagen = document.getElementsByClassName("contenidoImagen")[0];
			contenidoImagen.style.height="0px";
			if(who== "capa8"){ objlstOrganigrama.style.paddingTop = (altoImg + 40) +"px";}
		}
		else {
			//Si es explorer 6
			
			switch (who){
				case "capa1": diferencia=(cont == 1)?20:400;break;
				case "capa3": diferencia=(cont == 1)?25:400;break;
				case "capa4": diferencia=(cont == 1)?95:400;break;
				case "capa5": diferencia=(cont == 1)?-35:345;break;
				case "capa6": diferencia=(cont == 1)?-10:375;break;
				case "capa7": diferencia=(cont == 1)?-90:290;break;
				case "capa8": diferencia=(cont == 1)?-280:400;break;
				case "capa9": diferencia=(cont == 1)?125:400;break;
			}
			objlstOrganigrama.style.marginTop = (-diferencia)+"px";
			cont++;
		}
	}
	if(window.document.getElementById("enlaceVolverOrganigrama")){
		document.getElementById("enlaceVolverOrganigrama").onclick = function() { accionVolverOrganigrama(); return false;}
		//e.addEvent(document.getElementById("enlaceVolverOrganigrama"),'click',accionVolverOrganigrama,false)
		//e.addEvent(document.getElementById("enlaceVolverOrganigrama"),'keypress',accionVolverOrganigrama,false)	
	}
	return false;
}
 
function accionNada() {
	if(document.getElementById("agrandarCombo").value == -1){
		alert("Esta opcion no esta disponible");	
	}
	else{
		document.formFiltro.submit();
	}
}

var aniade = {
	cadListadoProductos:"",
	contProductos:1,
	item:function(){
		
		if(document.getElementById("f_prodserv_p2").value=="" || document.getElementById("f_desc2_p2").value==""){	
			alert("Debe de rellenar los campos obligatorios");
			return false;
		}else{
			errorComillas = valida.esAlfanumerico(document.getElementById("f_prodserv_p2").value);
			if (!errorComillas){
				alert("Debe introducir caracteres alfanuméricos sin comillas");
				return false;
			}
			if(document.getElementById("f_adj_p2_if_"+aniade.contProductos).value==""){
				aniade.cadListadoProductos += '<div id="dProductos'+aniade.contProductos+'" class="f_listado_productos">';
				aniade.cadListadoProductos += '<span class="f_prod_tit">'+document.getElementById("f_prodserv_p2").value+'</span>';
				aniade.cadListadoProductos += '<input type="hidden" id="h_prodserv_p2'+aniade.contProductos+'" name="h_prodserv_p2'+aniade.contProductos+'" value="'+document.getElementById("f_prodserv_p2").value+'" />';
				aniade.cadListadoProductos += '<div class="f_prod_padd">';
					aniade.cadListadoProductos += document.getElementById("f_desc2_p2").value;
					var ihcomillas = document.getElementById("f_desc2_p2").value;
						ihcomillas = ihcomillas.replace(/["]|[']/g, "´");	
					aniade.cadListadoProductos += '<input type="hidden" name="h_desc2_p2'+aniade.contProductos+'" value="'+ihcomillas+'" />';	
				aniade.cadListadoProductos += '</div>';
				aniade.cadListadoProductos += '<p class="refe">'+document.getElementById("f_ref2_p2").value+'</p>';
				aniade.cadListadoProductos += '<input type="hidden" name="f_ref2_p2'+aniade.contProductos+'" value="'+document.getElementById("f_ref2_p2").value+'" />';
				aniade.cadListadoProductos += '<p><a onclick="elimina.item('+aniade.contProductos+');return false;" href="#" class="eliminarlistprod"><img src="StaticFiles/ENAGAS/img/'+language+'/btn_eliminar.gif" alt="eliminar" class="ftr"/></a></p>';
				aniade.cadListadoProductos += '</div>';
				aniade.cadListadoProductos += '<input type="hidden" name="numMax" value="'+aniade.contProductos+'" />';
				aniade.contProductos++;
				document.getElementById("adjuntar").innerHTML = aniade.cadListadoProductos;
			}else{
				aniade.cadListadoProductos += '<div id="dProductos'+aniade.contProductos+'" class="f_listado_productos">';
				aniade.cadListadoProductos += '<span class="f_prod_tit">'+document.getElementById("f_prodserv_p2").value+'</span>';
				aniade.cadListadoProductos += '<input type="hidden" name="h_prodserv_p2'+aniade.contProductos+'" value="'+document.getElementById("f_prodserv_p2").value+'" />';
				aniade.cadListadoProductos += '<div class="f_prod_padd">';
					aniade.cadListadoProductos += document.getElementById("f_desc2_p2").value;
						var ihcomillas = document.getElementById("f_desc2_p2").value;
						ihcomillas = ihcomillas.replace(/["]|[']/g, "´");			
					aniade.cadListadoProductos += '<input type="hidden" name="h_desc2_p2'+aniade.contProductos+'" value="'+ihcomillas+'" />';
					aniade.cadListadoProductos += '<ul>';
						aniade.cadListadoProductos += '<li><a href="#"><img src="StaticFiles/ENAGAS/img/descarga.gif" alt="Fichero adjunto"/>'+document.getElementById("f_adj_p2_if_"+aniade.contProductos).value+'</a></li>';
						aniade.cadListadoProductos += '<input type="hidden" name="h_adj_p2'+aniade.contProductos+'" value="'+document.getElementById("f_adj_p2_if_"+aniade.contProductos).value+'" />';
					aniade.cadListadoProductos += '</ul>';
				aniade.cadListadoProductos += '</div>';
				aniade.cadListadoProductos += '<p class="refe">'+document.getElementById("f_ref2_p2").value+'</p>';
				aniade.cadListadoProductos += '<input type="hidden" name="f_ref2_p2'+aniade.contProductos+'" value="'+document.getElementById("f_ref2_p2").value+'" />';
				aniade.cadListadoProductos += '<p><a onclick="elimina.item('+aniade.contProductos+');return false;" href="#" class="eliminarlistprod"><img src="StaticFiles/ENAGAS/img/'+language+'/btn_eliminar.gif" alt="eliminar" class="ftr"/></a></p>';
			aniade.cadListadoProductos += '</div>';
			aniade.cadListadoProductos += '<input type="hidden" name="numMax" value="'+aniade.contProductos+'" />';
			
			aniade.contProductos++;
			document.getElementById("adjuntar").innerHTML = aniade.cadListadoProductos;
			}
		}
		newFile.addFileInput();
		document.getElementById("f_prodserv_p2").value="";
		document.getElementById("f_desc2_p2").value="";
		document.getElementById("f_ref2_p2").value="";
	}
}
var newFile = {
	incremento:2,
	cadenaTexto:"",
	addFileInput : function() {
		var p = document.createElement("div");
		p.setAttribute("id", "newif"+ newFile.incremento);
		document.getElementById("contenedorNewif").appendChild(p);
		newFile.cadenaTexto += '<p class="fila_if">'
		newFile.cadenaTexto += 		'<label for="f_adj_p2_if_'+ newFile.incremento +'">'
		newFile.cadenaTexto += 			'Documentaci&oacute;n'
		newFile.cadenaTexto += 			'<input type="file" name="f_adj_p2_if_'+ newFile.incremento +'" id="f_adj_p2_if_'+ newFile.incremento +'" class="typefiles"/>'
		newFile.cadenaTexto += 		'</label>'
		newFile.cadenaTexto += '</p>'
		document.getElementById("newif"+newFile.incremento).innerHTML = newFile.cadenaTexto;
		newFile.cadenaTexto = "";
		newFile.incremento++;
		var fila_if = document.getElementsByClassName("fila_if");
		for(var i=0;i<fila_if.length-1;i++){
			fila_if[i].style.display="none";
		}
	}
}

var aniade2 = {
	cadListadoProductosli:"",
	contProductosli:1,
	item2:function(incremento){
		objInc = "f_sum_p2_"+incremento;
		if(document.getElementById(objInc).value==""){
			alert("Por favor rellene el campo de 'Suministro'");
		}else{
			aniade2.cadListadoProductosli += '<li id="eliminaLi'+aniade2.contProductosli+'"><a href="#" class="ftl"><img src="StaticFiles/ENAGAS/img/descarga.gif" alt="Fichero adjunto"/>'+ document.getElementById("f_sum_p2_"+aniade2.contProductosli).value +'</span></a><a onclick="elimina2.item('+aniade2.contProductosli+');return false;" href="#" class="borralidescarg"><img src="StaticFiles/ENAGAS/img/'+language+'/btn_eliminar.gif" alt="Eliminar" class="ftr"/></a></li>';
			aniade2.cadListadoProductosli += '<input type="hidden" name="f_sum_p2_'+aniade2.contProductosli+'" value="'+document.getElementById("f_sum_p2_"+aniade2.contProductosli).value+'" />';
			aniade2.contProductosli++;
			document.getElementById("f_descargas").innerHTML = aniade2.cadListadoProductosli;
			newFile2.addFileInput();
		}
	}
}
var newFile2 = {
	incremento:2,
	cadenaTexto:"",
	addFileInput:function() {
		var p = document.createElement("div");
		p.setAttribute("id", "newifb"+ newFile2.incremento);
		document.getElementById("contenedorNewifb").appendChild(p);
		newFile2.cadenaTexto += '<p class="f_sum">'
		newFile2.cadenaTexto += 		'<label for="f_sum_p2_'+ newFile2.incremento +'">'
		newFile2.cadenaTexto += 			'Suministro'
		newFile2.cadenaTexto += 			'<input type="file" name="f_sum_p2_'+newFile2.incremento+'" id="f_sum_p2_'+ newFile2.incremento +'" class="typefiles2"/>&nbsp;'
		newFile2.cadenaTexto +=				'<a href="#" class="borralidescarg" onclick="aniade2.item2('+newFile2.incremento+');return false;"><img src="StaticFiles/ENAGAS/img/'+language+'/boton_f_anadir.gif" alt="Añadir"/></a>';
		newFile2.cadenaTexto += 		'</label>'
		newFile2.cadenaTexto += '</p>'
		document.getElementById("newifb"+newFile2.incremento).innerHTML = newFile2.cadenaTexto;
		newFile2.cadenaTexto = "";
		newFile2.incremento++;
		var fila_if = document.getElementsByClassName("f_sum");
		for(var i=0;i<fila_if.length-1;i++){
			fila_if[i].style.display="none";
		}
	}
}

var elimina = {
	item:function(qItem) {
		for (var i=0;i<document.getElementById("adjuntar").childNodes.length;i++){
			if (document.getElementById("adjuntar").childNodes[i].id == ("dProductos"+qItem)){
				document.getElementById("adjuntar").removeChild(document.getElementById("adjuntar").childNodes[i]);
			}
			aniade.cadListadoProductos = "";
			aniade.cadListadoProductos = document.getElementById("adjuntar").innerHTML;
		}
	}
}
var elimina2 = {
	item:function(qItem) {
		for (var i=0;i<document.getElementById("f_descargas").childNodes.length;i++){
				if (document.getElementById("f_descargas").childNodes[i].id == ("eliminaLi"+qItem)){
					document.getElementById("f_descargas").removeChild(document.getElementById("f_descargas").childNodes[i]);
			}
			aniade2.cadListadoProductosli = "";
			aniade2.cadListadoProductosli = document.getElementById("f_descargas").innerHTML;
		}
	}
}
var limpiar = {
	comillas : function(){
		var textAreas = document.getElementById("form_Proveedores_3p").getElementsByTagName("textarea");
		var inputs = document.getElementById("form_Proveedores_3p").getElementsByTagName("input");
		for(c=0;c<textAreas.length;c++){
			var valorTextar = textAreas[c].value;
			valorTextar.replace(/["]|[']/g, "´");
		}
	}
}
function funciones() {
	if(window.document.getElementById("titular")){
		if (document.getElementById("enlaceImprimir") != null){
			document.getElementById("enlaceImprimir").style.display = 'block';
			e.addEvent(document.getElementById("enlaceImprimir"),'click',accionImprimir,false);
			e.addEvent(document.getElementById("enlaceImprimir"),'keypress',accionImprimir,false);
		}
	}
	if(window.document.getElementById("enlaceVolver")){
		document.getElementById("enlaceVolver").style.display = 'block';
		e.addEvent(document.getElementById("enlaceVolver"),'click',accionVolver,false)
		e.addEvent(document.getElementById("enlaceVolver"),'keypress',accionVolver,false)
	}
	if(window.document.getElementById("imagenMapaSinJavascript")){
		document.getElementById("imagenMapaSinJavascript").style.display = 'none';
	}
	var listaOrganigrama = document.getElementsByClassName("lista_organigrama")[0];
	if (listaOrganigrama != null) { listaOrganigrama.style.marginTop = marginTop;}
	
	if(document.getElementById("voltie")){
		document.getElementById("voltie").style.display = 'block';
		e.addEvent(document.getElementById("voltie"),'click',accionVolver,false)
		e.addEvent(document.getElementById("voltie"),'keypress',accionVolver,false)
	}
/*******************/	
	if(window.document.getElementById("f_bloq")){
		capa = document.getElementById("motivosSiguientes");
		capa.style.display = "none";
		document.getElementById("f_vencim").checked = true;
		document.getElementById("f_bloq").onclick = function(){
			capa.style.display = "block";
		}
		document.getElementById("f_vencim").onclick = function(){
			capa.style.display = "none";
		}
	}
/*******************/	
	if(window.document.getElementById("leyendaMapa") && window.document.getElementById("mapaInfraestructuras")){
				
		e.addEvent(document.getElementById("existentes"),'click',accionMostrarImagen,false)
		e.addEvent(document.getElementById("existentes"),'keypress',accionMostrarImagen,false)
		
		e.addEvent(document.getElementById("plantas"),'click',accionMostrarImagen,false)
		e.addEvent(document.getElementById("plantas"),'keypress',accionMostrarImagen,false)
	}
	//Añadido al duplicar la plantilla
	if(window.document.getElementById("leyendaMapa") && window.document.getElementById("mapaInfraestructurasTransporte")){
		e.addEvent(document.getElementById("enagas"),'click',accionMostrarImagen,false)
		e.addEvent(document.getElementById("enagas"),'keypress',accionMostrarImagen,false)
				
	}
	
	var ind = 1;
	while (document.getElementById("cargos"+ind) != null){
		if(window.document.getElementById("cargos"+ind)){
			varLista = document.getElementById("cargos"+ind).getElementsByTagName("ul"); // varLista son los ul que hay dentro de la capa
			for(var i = 0; i < varLista.length; i++){
				if(varLista[i].className == "cargos"){// varLista son los ul con clase cargos que hay dentro de la capa
					for(var j = 0; j < varLista[i].getElementsByTagName("ul").length; j++) {
						varLista[i].getElementsByTagName("ul")[j].style.display = "none"; // se ocultan los ul que hay dentro de los ul con clase cargos que hay
					}
					for(var j = 0; j < varLista[i].getElementsByTagName("li").length; j++){// nos posicionamos en los li hijos de los ul con clase cargos
						if(varLista[i].getElementsByTagName("li")[j].parentNode == varLista[i] && varLista[i].getElementsByTagName("li")[j].getElementsByTagName("ul").length != 0){
							e.addEvent(varLista[i].getElementsByTagName("li")[j],'click',MostrarLista.accionMostrarLista,false)
							e.addEvent(varLista[i].getElementsByTagName("li")[j],'keypress',MostrarLista.accionMostrarLista,false)
						}
					}												
				}
			}
		}
		ind++;
	}
	if(window.document.getElementById("pestanasFlotante")){	
		document.getElementById("datosCapa").style.display = 'none';
		e.addEvent(document.getElementById("grafico"),'click',accionMostrarCapa,false)
		e.addEvent(document.getElementById("grafico"),'keypress',accionMostrarCapa,false)
		e.addEvent(document.getElementById("datos"),'click',accionMostrarCapa,false)
		e.addEvent(document.getElementById("datos"),'keypress',accionMostrarCapa,false)
	}
	if(window.document.getElementById("mapacanarias")){	
		if(screen.width==1280){
			window.document.getElementById("mapacanarias").style.left="797px";
		}
	}
	if(window.document.getElementById("organigrama")){	
		document.getElementById("imagenOrganigrama").style.display = 'block';
		document.getElementById("enlaceVolverOrganigrama").style.display = 'none';	
		if(window.document.getElementById("organigrama")){	
			var contenidoImagen = document.getElementsByClassName("contenidoImagen")[0];
			var version = 0;
			if (navigator.appVersion.indexOf("MSIE")!=-1){
				temp=navigator.appVersion.split("MSIE")
				version=parseFloat(temp[1])
			}
			contenidoImagen.style.height="380px"
			//Si es explorer 6
			if (version==6){
				contenidoImagen.style.height="1px";
				var listaOrganigrama = document.getElementsByClassName("lista_organigrama")[0];
				listaOrganigrama.style.marginTop = "-145px";
			}
			document.getElementById("organigramaAdyacentes").style.display = 'none';
		}
		e.addEvent(document.getElementById("capa1"),'click',accionCambiarImagen,false)
		//e.addEvent(document.getElementById("capa1"),'keypress',accionCambiarImagen,false)
		e.addEvent(document.getElementById("capa2"),'click',accionCambiarImagen,false)
		//e.addEvent(document.getElementById("capa2"),'keypress',accionCambiarImagen,false)
		e.addEvent(document.getElementById("capa3"),'click',accionCambiarImagen,false)
		//e.addEvent(document.getElementById("capa3"),'keypress',accionCambiarImagen,false)
		e.addEvent(document.getElementById("capa4"),'click',accionCambiarImagen,false)
		//e.addEvent(document.getElementById("capa4"),'keypress',accionCambiarImagen,false)
		e.addEvent(document.getElementById("capa5"),'click',accionCambiarImagen,false)
		//e.addEvent(document.getElementById("capa5"),'keypress',accionCambiarImagen,false)
		e.addEvent(document.getElementById("capa6"),'click',accionCambiarImagen,false)
		//e.addEvent(document.getElementById("capa6"),'keypress',accionCambiarImagen,false)
		e.addEvent(document.getElementById("capa7"),'click',accionCambiarImagen,false)
		//e.addEvent(document.getElementById("capa7"),'keypress',accionCambiarImagen,false)		
		e.addEvent(document.getElementById("capa8"),'click',accionCambiarImagen,false)
		//e.addEvent(document.getElementById("capa8"),'keypress',accionCambiarImagen,false)
		e.addEvent(document.getElementById("capa9"),'click',accionCambiarImagen,false)
		//e.addEvent(document.getElementById("capa9"),'keypress',accionCambiarImagen,false)
	}
	if(window.document.getElementById("agrandarCombo")){
		document.getElementById("agrandarCombo").style.width = "35em";
		if(document.getElementById("botonOption1")){
			e.addEvent(document.getElementById("botonOption1"),'click',accionNada,false)
			e.addEvent(document.getElementById("botonOption1"),'keypress',accionNada,false)
		}
	}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	//Fonde de titular a 100%
	if(document.getElementById("contenidoQuienes")){
		var menuLateral = document.getElementById("menuLateral");
		if(menuLateral<=0){
			document.getElementById("contenidoQuienes").className ="nomenuv_prove";
		}
	}
	//Para los pasos de Formulario largo de proveedores PAP
	if(document.getElementById("formPasos")){
		var lnVolver = document.getElementsByClassName("f_back");
		var capaUno  = document.getElementById("f_paso_uno");
		var capaDos  = document.getElementById("f_paso_dos");
		var capaTres = document.getElementById("f_paso_tres");
		var atras_2 = document.getElementById("btn_at2");
		var fFecha = document.getElementById("f_fecha_desac_p1");
		var btnAccion = document.getElementsByClassName("btnaccion");
		var Botonera = document.getElementsByClassName("ocultosinjs");
		//Variables fecha
		var rfecha=new Date();
		var diames=rfecha.getDate();
		var mes=rfecha.getMonth()+1;
		var anio=rfecha.getFullYear();
		
		//Ponemos la fecha de hoy en el form
		diames = (diames<10)?"0"+diames:diames;
		mes = (mes<10)?"0"+mes:mes;
		fFecha.value= diames + "/" + mes + "/" + anio;
	
		//Mostramos los enlaces de Volver
		for(i=0;i<lnVolver.length;i++){
			lnVolver[i].style.display="block";
			lnVolver[i].onclick = function(){
				history.back();
			}
		}
		//Ocultamos capa 2 y 3 de inicio
		capaDos.style.display="none";
		capaTres.style.display="none";
		atras_2.style.display="block";
		//Mostramos los Botones de Continuar
		for(i=0;i<Botonera.length;i++){
			Botonera[i].style.display="block";
		}
	}//fin de pasos
	
	//Anade nodo form
	if (document.getElementById("aniade")){
		document.getElementById("aniade").onclick = function(){
			aniade.item(); return false;
		}
	}
	//Anade nodo form
	if (document.getElementById("aniade2")){
		document.getElementById("aniade2").onclick = function(){
			aniade2.item2(1); return false;
		}
	}
//PARA LA VALIDACION DE FORMULARIOS		
	//Validacion formulario de Contacto	
	if(document.getElementById("form_contacto")){
		document.getElementById("btnEnviof").onclick=function(){
			var formContact =valida.captura(document.getElementById("form_contacto"))
				if(formContact){
				document.getElementById("f_mens_aviso").style.display = 'block';
				if (document.getElementById("f_mens_error"))
					document.getElementById("f_mens_error").style.display = 'none';	
				document.getElementById("form_contacto").submit()
			}else{
				return false;
			}
		}
	}
	//Validacion formulario de Facturacion
	if(document.getElementById("form_facturacion")){
		document.getElementById("btnEnviof").onclick=function(){
		var formFact =valida.captura(document.getElementById("form_facturacion"))
			if(formFact){
				document.getElementById("f_mens_aviso").style.display = 'block';
				if (document.getElementById("f_mens_error"))
					document.getElementById("f_mens_error").style.display = 'none';
				document.getElementById("form_facturacion").submit()
			}else{
				return false;
			}
		}
	}
	//Validacion formulario de Facturacion segunda opcion
	if(document.getElementById("form_facturaciono_p2")){
		document.getElementById("btnEnviof").onclick=function(){
		var formFact2 =valida.captura(document.getElementById("form_facturaciono_p2"))
			if(formFact2){
				document.getElementById("f_mens_aviso").style.display = 'block';
				if (document.getElementById("f_mens_error"))
					document.getElementById("f_mens_error").style.display = 'none';
				document.getElementById("form_facturaciono_p2").submit()
			}else{
				return false;
			}
		}
	}
	//Validacion formulario de pedidos
	if(document.getElementById("form_pedidos")){
		document.getElementById("btnEnviof").onclick=function(){
			var formPedidos=valida.captura(document.getElementById("form_pedidos"))
			if(formPedidos){
				document.getElementById("f_mens_aviso").style.display = 'block';
				if (document.getElementById("f_mens_error"))
					document.getElementById("f_mens_error").style.display = 'none';
				document.getElementById("form_pedidos").submit()
			}else{
				return false;
			}
		}
	}
	//Validacion formulario de proceso de homologacion
	if(document.getElementById("form_Proveedores_3p")){
		document.getElementById("btn_ad1").onclick=function(){
			var formProveedores=valida.captura(document.getElementById("form_Proveedores_3p"))
			if(formProveedores){
				valida.datos=subForm2;
				document.getElementById("capaValidaErr").innerHTML="";
				capaUno.style.display="none";
				capaDos.style.display="block";
				capaTres.style.display="none";
			}
		}
		document.getElementById("btn_ad2").onclick=function(){
			var typefiles_f = document.getElementsByClassName("typefiles");
			var typefiles_f2 = document.getElementsByClassName("typefiles2");
			if(typefiles_f.length==1){
				var formProveedores=valida.captura(document.getElementById("form_Proveedores_3p"))
			}else{
				var formProveedores= true;
			}
			var totalFiles = document.createElement("input");
			totalFiles.setAttribute("type","hidden");
			totalFiles.setAttribute("value", newFile.incremento-1);
			if(formProveedores){
				document.form_Proveedores_3p.contador.value = parseInt(typefiles_f.length);
				document.form_Proveedores_3p.contador2.value = parseInt(typefiles_f2.length);
				valida.datos=subForm3;
				document.getElementById("capaValidaErr").innerHTML="";
				capaUno.style.display="none";
				capaDos.style.display="none";
				capaTres.style.display="block";
			}
		}
		document.getElementById("enviafpaso3").onclick=function(){
			limpiar.comillas();
			var formProveedores=valida.captura(document.getElementById("form_Proveedores_3p"));
			if(formProveedores){
				document.getElementById("capaValidaErr").innerHTML="";
				document.getElementById("f_mens_aviso").style.display = 'block';
				if (document.getElementById("f_mens_error"))
					document.getElementById("f_mens_error").style.display = 'none';
				document.getElementById("form_Proveedores_3p").submit();
			}
			return false;
		}
		document.getElementById("btn_at1").onclick=function(){
			valida.datos=subForm1;
			capaUno.style.display="block";
			capaDos.style.display="none";
			capaTres.style.display="none";
			return false;
		}
		document.getElementById("btn_at2").onclick=function(){
			valida.datos=subForm2;
			capaUno.style.display="none";
			capaDos.style.display="block";
			capaTres.style.display="none";
			return false;
		}
	}
	//FIN DE VALIDACIONES//**************************************************************************************************************************
	//Para incluir el numero de pedido
	var tipoReg = document.getElementById("f_tiporeg");
	if(tipoReg){
		tipoReg.onchange = function(){
			cambia();
		}
	}	
}
//gestor de eventos eventos
var e = {
	addEvent : function(obj, evType, fn, useCapture){
		if (obj.addEventListener){
			obj.addEventListener(evType, fn, useCapture);
			return true;
		}else if (obj.attachEvent){
			var r = obj.attachEvent("on"+evType, fn);
			return r;
		}else {
			return false; 
		}
	}
}
e.addEvent(window,'load',funciones,false)