var catNoImprimir = "No se puede imprimir";

function buscarSeleccion(){
	comboGama = document.getElementById("form1").gama;
	comboFamilia = document.getElementById("form1").familia;
	comboModelo = document.getElementById("form1").modelo;
	destino = '';
	seleccion = document.getElementById("form1").SELECCION.value;
	idGama = comboGama.options[comboGama.selectedIndex].value;
	idFamilia = comboFamilia.options[comboFamilia.selectedIndex].value;
	idModelo = comboModelo.options[comboModelo.selectedIndex].value;
	idCatalogo = document.getElementById("form1").ID_CATALOGO.value;
	var gamaNueva = idGama;
	var indiceModelo = comboModelo.selectedIndex -1;
	if ( gamaNueva == ''){
		gamaNueva = document.getElementById("form1").ID_GAMA.value;
	}

	if ( idFamilia!= '' && idModelo != ''){
		//jsp detalle del modelo
		destino = "modelo"+tipoProducto+".jsp";
		var ancho=750;
		var alto=500;
		var xMax = screen.width, yMax = screen.height;
		
		var xOffset = (xMax - ancho)/2, yOffset = (yMax - alto)/2 - 30;
		while(idModelo.indexOf(" ")!=-1){
			idModelo = idModelo.replace(" ","");
		}
		if(idFamilia=="MULTISCOMBINABLESINVERTER"){
			destino = "modeloClimaMultisCombinables.jsp";
			window.open(destino+'?SELECCION='+seleccion+'&ID_MODELO='+idModelo+'&ID_FAMILIA='+idFamilia+'&ID_CATALOGO='+idCatalogo+'&ID_GAMA='+gamaNueva+'&idSet='+idModelo+'&indice='+indiceModelo,'FlotanteDetalleModelo'+tipoProducto,'scrollbars=yes,width='+ancho+',height='+alto+',top='+yOffset+',left='+xOffset);
		}else{
			destino = "modelo"+tipoProducto+".jsp";
			window.open(destino+'?SELECCION='+seleccion+'&ID_MODELO='+idModelo+'&ID_FAMILIA='+idFamilia+'&ID_CATALOGO='+idCatalogo+'&ID_GAMA='+gamaNueva,'FlotanteDetalleModelo'+tipoProducto,'scrollbars=yes,width='+ancho+',height='+alto+',top='+yOffset+',left='+xOffset);
		}
	}else{
		if ( idFamilia!= ''){
			//jsp de familia
			if(idFamilia=="MULTISCOMBINABLESINVERTER"){
				destino = "familiaClimaMultisCombinables.jsp";
			}else{
				destino = "familia"+tipoProducto+".jsp";
			}
			document.form1.action=destino;
			if (idGama!= ''){
				document.getElementById("form1").ID_GAMA.value=idGama;
			}
			document.getElementById("form1").ID_FAMILIA.value=idFamilia;
			document.form1.submit();
		}else{
			if (idGama!= ''){
				//jsp de gama
				destino = "catalogo"+tipoProducto+".jsp";
				document.form1.action=destino;
				document.getElementById("form1").ID_GAMA.value=idGama;
				document.form1.submit();
			}
		}
	}
}

function buscarSeleccionSinModelos(){
	comboGama = document.getElementById("form1").gama;
	comboFamilia = document.getElementById("form1").familia;
	destino = '';
	idGama = comboGama.options[comboGama.selectedIndex].value;
	idFamilia = comboFamilia.options[comboFamilia.selectedIndex].value;
	idCatalogo = document.getElementById("form1").ID_CATALOGO.value;
	var gamaNueva = idGama;
	if ( gamaNueva == ''){
		gamaNueva = document.getElementById("form1").ID_GAMA.value;
	}

        if ( idFamilia!= ''){
        	//jsp de familia
		if (idGama!= ''){
			document.getElementById("form1").ID_GAMA.value=idGama;
		}
		if(tipoProducto=="Solar"){
			if(idFamilia=="CaptadorSolar"){
				destino = "familiaCaptadores.jsp";
			}else if(idFamilia=="DepositosSolares"){
				destino = "familiaDepositos.jsp";
			}else if(idFamilia=="GruposHidraulicos"){
				destino = "familiaGrupos.jsp";
			}else{
				destino = "familiaHelioPack.jsp";
			}
		}else if(tipoProducto=="AA"){
			if(idFamilia=="MULTISCOMBINABLESINVERTER"){
				destino = "familiaClimaMultisCombinables.jsp";
			}else{
				destino = "familia"+tipoProducto+".jsp";
			}
		}else{
                	destino = "familia"+tipoProducto+".jsp";
		}
		document.form1.action=destino;

		document.getElementById("form1").ID_FAMILIA.value=idFamilia;
		document.form1.submit();
        }else{
		if (idGama!= ''){
			//jsp de gama
			destino = "catalogo"+tipoProducto+".jsp";
			document.form1.action=destino;
			document.getElementById("form1").ID_GAMA.value=idGama;
			document.form1.submit();
		}
        }
}

function buscarModelo1(){
	idModelo = document.getElementById("form1").modelos1.options[document.getElementById("form1").modelos1.selectedIndex].value;
	document.getElementById("form1").ID_FAMILIA.value=idFamiliaMOD;
	document.getElementById("form1").ID_MODELO.value =idModelo;
	document.getElementById("form1").ID_CATALOGO.value=idCatalogo;
	destino = "modelo"+tipoProducto+".jsp";
	document.form1.action = destino;
	document.form1.submit();
}

function buscarModelo2(){
	idModelo = document.form2.modelos2.options[document.form2.modelos2.selectedIndex].value;
	document.form2.ID_FAMILIA.value=idFamiliaMOD;
	document.form2.ID_MODELO.value =idModelo;
	document.form2.ID_CATALOGO.value=idCatalogo;
	destino = "modelo"+tipoProducto+".jsp";
	document.form2.action = destino;
	document.form2.submit();
}

function buscarSeleccionCalentadores(){
	comboGama = document.getElementById("form1").gama;
	comboModelo = document.getElementById("form1").modelo;
	destino = '';
	idGama = comboGama.options[comboGama.selectedIndex].value;
	idModelo = comboModelo.options[comboModelo.selectedIndex].value;
	idCatalogo = document.getElementById("form1").ID_CATALOGO.value;
	var gamaNueva = document.getElementById("form1").ID_GAMA.value;

	if ( idModelo != ''){
		var ancho=750;
		var alto=500;
		var xMax = screen.width, yMax = screen.height;
		
		var xOffset = (xMax - ancho)/2, yOffset = (yMax - alto)/2 - 30;
		//jsp detalle del modelo
		destino = "modelo"+tipoProducto+".jsp";
		window.open(destino+'?ID_MODELO='+idModelo+'&ID_FAMILIA='+idGama+'&ID_CATALOGO='+idCatalogo+'&ID_GAMA='+gamaNueva,'detalleModeloFlotante'+tipoProducto,'scrollbars=yes,width='+ancho+',height='+alto+',top='+yOffset+',left='+xOffset);

	}else{
		if (idGama!= ''){
			//jsp de gama
			destino = "familia"+tipoProducto+".jsp";
			document.form1.action=destino;
			document.getElementById("form1").ID_GAMA.value=idGama;
			document.getElementById("form1").ID_FAMILIA.value=idGama;
			document.form1.submit();
		}
	}
}

function buscarSeleccionReguladores(seleccion){
	comboGama = document.getElementById("form1").gama;
	comboModelo = document.getElementById("form1").modelo;
	destino = '';
	idGama = comboGama.options[comboGama.selectedIndex].value;
	idModelo = comboModelo.options[comboModelo.selectedIndex].value;
	idCatalogo = document.getElementById("form1").ID_CATALOGO.value;
	var gamaNueva = document.getElementById("form1").ID_GAMA.value;

	if ( idModelo != ''){
		var ancho=750;
		var alto=500;
		var xMax = screen.width, yMax = screen.height;
		
		var xOffset = (xMax - ancho)/2, yOffset = (yMax - alto)/2 - 30;
		//jsp detalle del modelo
		destino = "modelo"+tipoProducto+".jsp";
		window.open(destino+'?ID_MODELO='+idModelo+'&ID_FAMILIA='+idGama+'&ID_CATALOGO='+idCatalogo+'&ID_GAMA='+gamaNueva+'&SELECCION='+seleccion,'detalleModeloFlotante'+tipoProducto,'scrollbars=yes,width='+ancho+',height='+alto+',top='+yOffset+',left='+xOffset);

	}else{
		if (idGama!= ''){
			//jsp de gama
			destino = "familia"+tipoProducto+".jsp";
			document.form1.action=destino;
			document.getElementById("form1").ID_GAMA.value=idGama;
			document.getElementById("form1").ID_FAMILIA.value=idGama;
			document.form1.submit();
		}
	}
}

function buscarSeleccionHep2o(){
	comboGama = document.getElementById("form1").gama;
	comboFamilia = document.getElementById("form1").familia;
	destino = '';
	idGama = comboGama.options[comboGama.selectedIndex].value;
	idFamilia = comboFamilia.options[comboFamilia.selectedIndex].value;

	if ( idFamilia!= ''){
		//jsp de familia
		destino = "familia"+tipoProducto+".jsp";
		document.form1.action=destino;
		if (idGama!= ''){
			document.getElementById("form1").ID_GAMA.value=idGama;
		}
		document.getElementById("form1").ID_FAMILIA.value=idFamilia;
		document.form1.submit();
	}else{
		if (idGama!= ''){
			//jsp de gama
			destino = "catalogo"+tipoProducto+".jsp";
			document.form1.action=destino;
			document.getElementById("form1").ID_GAMA.value=idGama;
			document.form1.submit();
		}
	}
}

function buscarSeleccionSolar(){
	comboGama = document.getElementById("form1").gama;
	comboFamilia = document.getElementById("form1").familia;
	comboModelo = document.getElementById("form1").modelo;
	destino = '';
	idGama = comboGama.options[comboGama.selectedIndex].value;
	idFamilia = comboFamilia.options[comboFamilia.selectedIndex].value;
	idModelo = comboModelo.options[comboModelo.selectedIndex].value;
	idCatalogo = document.getElementById("form1").ID_CATALOGO.value;
	var gamaNueva = idGama;
	if ( gamaNueva == ''){
		gamaNueva = document.getElementById("form1").ID_GAMA.value;
	}

	if ( idFamilia!= '' && idModelo != ''){
		//jsp detalle del modelo
		//En la posición 3 del array se guarda la jsp del modelo
		destino = buscarJspFamilia(idFamilia,3);
		//idFamilia = idFamilia.substring(0,idFamilia.indexOf("$$"));
		if ( destino != '' && destino != 'null'){
			var ancho=750;
			var alto=500;
			var xMax = screen.width, yMax = screen.height;
			
			var xOffset = (xMax - ancho)/2, yOffset = (yMax - alto)/2 - 30;
			window.open(destino+'?ID_MODELO='+idModelo+'&ID_FAMILIA='+idFamilia+'&ID_CATALOGO='+idCatalogo+'&ID_GAMA='+gamaNueva,'FlotanteDetalleModelo'+tipoProducto,'scrollbars=yes,width='+ancho+',height='+alto+',top='+yOffset+',left='+xOffset);
		}
	}else{
		if ( idFamilia!= ''){
			//jsp de familia
			//En la posición 2 del array se guarda la jsp de la familia
			destino = buscarJspFamilia(idFamilia,2);
			document.form1.action=destino;
			if (idGama!= ''){
				document.getElementById("form1").ID_GAMA.value=idGama;
			}
			document.getElementById("form1").ID_FAMILIA.value=idFamilia;
			document.form1.submit();
		}else{
			if (idGama!= ''){
				//jsp de gama
				destino = "catalogo"+tipoProducto+".jsp";
				document.form1.action=destino;
				document.getElementById("form1").ID_GAMA.value=idGama;
				document.form1.submit();
			}
		}
	}
}

//**********************************************************************************************************
// * Función: setOverStyle ()										   *
// * Autor: Alvaro V.S.								                           *
// * Fecha Creación: 17/6/2004									           *
// * Objetivo:   Cambia el estilo de un enlace cuando se pasa el raton por encima			   *
// * Parámetros: 								                           *
//**********************************************************************************************************//
function setOverStyle(id,estilo){
   	id.className=estilo;
}

//**********************************************************************************************************
// * Función: removeOverStyle ()									   *
// * Autor: Alvaro V.S.								                           *
// * Fecha Creación: 17/6/2004									           *
// * Objetivo:   Cambia el estilo de un enlace cuando se quita el raton de encima			   *
// * Parámetros: 								                           *
//**********************************************************************************************************//
function removeOverStyle(id,estilo)
{
	id.className=estilo;
}

//**********************************************************************************************************
// * Función: imagenOver()									 	   *
// * Autor: Alvaro V.S.								                           *
// * Fecha Creación: 24/6/2004									           *
// * Objetivo:   Cambia el estilo de la image cuando se pone el raton de encima			           *
// * Parámetros: 								                           *
//**********************************************************************************************************//
var anchoImagen;
var altoImagen;

function imagenOver(id){
	id.style.cursor='pointer';
}

/*
* Método que busca en el array de familias el valor de una determinada posición
*   valor --> valor del combo familia de  solar, está formado por la idFamilia+ $$+ idGama
*   posicion --> posición dentro del array de familia que se quiere recuperar
*/
function buscarJspFamilia(valor, posicion){
	indice=parseInt(idFamilia.indexOf("$$"));
	idGama = valor.substring(indice+2,idFamilia.length);
	idFamilia = valor.substring(0,indice);
	if ( arrayFamilias && arrayFamilias[idGama]){
		for(i=0;i<arrayFamilias[idGama].length;i++){
			if(arrayFamilias[idGama][i]){
				if ( arrayFamilias[idGama][i][0]==valor){
					valorDevolver = arrayFamilias[idGama][i][posicion];
					return valorDevolver;
				}
			}
		}
	}
}

/*
* Método para buscar modelos desde el combo de la jsp de modelos en el catálogo solar
*/
function buscarModeloSolar(jsp){
	idModelo = document.getElementById("form1").modelos1.options[document.getElementById("form1").modelos1.selectedIndex].value;
	document.getElementById("form1").ID_FAMILIA.value=idFamiliaMOD;
	document.getElementById("form1").ID_MODELO.value =idModelo;
	document.getElementById("form1").ID_CATALOGO.value=idCatalogo;
	destino = jsp;
	document.form1.action = destino;
	document.form1.submit();
}

/*
* Método para imprimir
*/
function imprimirVentana(){
	if (window.print)
    		window.print();
  	else
	    alert(catNoImprimir);
}

/**
* Método usado en las pantallas flotantes para link "mas información"
* cierra la ventana flotante y envía a la pantalla padre a la página de contacto
* correspondiente
*/
function buscarInformacion (jsp){
    window.opener.location.href=jsp;
    window.close();
}

//funciones javascript del catalogo
// ya no hay apartado de gama, estan englobadas las de catalogo y gama
function irDetalleGama(valor, jsp){
	document.formulario.action=jsp;
	document.getElementById("formulario").ID_GAMA.value=valor;
	document.getElementById("formulario").ID_CATALOGO.value=valor_ID_CATALOGO;
	document.formulario.submit();
}

function irDetalleGamaCalentadores(valor){
	document.formulario.action='catalogoCalentadores.jsp';
	document.getElementById("formulario").ID_GAMA.value=valor;
	document.getElementById("formulario").ID_CATALOGO.value=valor_ID_CATALOGO;
	document.getElementById("formulario").ID_FAMILIA.value=valor;
	document.formulario.submit();
}

function irDetalleGamaCalentadores(valor){
	document.formulario.action='catalogoCalentadores.jsp';
	document.getElementById("formulario").ID_GAMA.value=valor;
	document.getElementById("formulario").ID_CATALOGO.value=valor_ID_CATALOGO;
	document.getElementById("formulario").ID_FAMILIA.value=valor;
	document.formulario.submit();
}

function irDetalleGamaReguladores(valor){
	document.formulario.action='familiaReguladores.jsp';
	document.getElementById("formulario").ID_GAMA.value=valor;
	document.getElementById("formulario").ID_CATALOGO.value=valor_ID_CATALOGO;
	document.getElementById("formulario").ID_FAMILIA.value=valor;
	document.formulario.submit();
}
function irDetalleGamaTermos(valor,valorGama){
	document.formulario.action='familiaTermos.jsp';
	document.getElementById("formulario").ID_GAMA.value=valorGama;
	document.getElementById("formulario").ID_CATALOGO.value=valor_ID_CATALOGO;
	document.getElementById("formulario").ID_FAMILIA.value=valor;
	document.formulario.submit();
}
function irDetalleGamaReguladores(valor){
	document.formulario.action='familiaReguladores.jsp';
	document.getElementById("formulario").ID_GAMA.value=valor;
	document.getElementById("formulario").ID_CATALOGO.value=valor_ID_CATALOGO;
	document.getElementById("formulario").ID_FAMILIA.value=valor;
	document.formulario.submit();
}

function irDetalleGamaHep2O(valor, jsp){
	document.formulario.action=jsp;
	document.getElementById("formulario").ID_GAMA.value=valor;
	document.getElementById("formulario").ID_CATALOGO.value=valor_ID_CATALOGO;
	document.formulario.submit();
}

function irDetalle(valor){
	document.getElementById("formulario").ID_GAMA.value=valor_ID_GAMA;
	document.getElementById("formulario").ID_CATALOGO.value=valor_ID_CATALOGO;
	document.getElementById("formulario").ID_FAMILIA.value=valor;
	document.formulario.submit();
}

function irDetalleCatalogo(valor, valorGama){
	document.getElementById("formulario").ID_GAMA.value=valorGama;
	document.getElementById("formulario").ID_CATALOGO.value=valor_ID_CATALOGO;
	document.getElementById("formulario").ID_FAMILIA.value=valor;
	document.formulario.submit();
}

function irDetalleCatalogoAA(valor, valorGama, jsp){
	if (jsp!=undefined && jsp!='undefined' && jsp!='null' && jsp!='') document.formulario.action=jsp;
	document.getElementById("formulario").ID_GAMA.value=valorGama;
	document.getElementById("formulario").ID_CATALOGO.value=valor_ID_CATALOGO;
	document.getElementById("formulario").ID_FAMILIA.value=valor;
	document.formulario.submit();
}
//function irDetalleCatalogoFriendly(friendlyUrl, valor_ID_CATALOGO,valorGama, valor){
function irDetalleCatalogoFriendly(friendlyUrl){
    alert("friendlyUrl vale: " +friendlyUrl);
	var formu = document.createElement("form");
    formu.id="FORMPRU";
    formu.action=friendlyUrl;
    document.body.appendChild(formu);
    formu.submit();
}

function irDetalle(valor,jsp){
	if (jsp!=undefined && jsp!='undefined' && jsp!='null' && jsp!='') document.formulario.action=jsp;
	document.getElementById("formulario").ID_GAMA.value=valor_ID_GAMA;
	document.getElementById("formulario").ID_CATALOGO.value=valor_ID_CATALOGO;
	document.getElementById("formulario").ID_FAMILIA.value=valor;
	document.formulario.submit();
}

function irDetalleSolar(valor,jsp){
	document.getElementById("formulario").ID_GAMA.value=valor_ID_GAMA;
	document.getElementById("formulario").ID_CATALOGO.value=valor_ID_CATALOGO;
	document.getElementById("formulario").ID_FAMILIA.value=valor;
	document.formulario.action=jsp;
	document.formulario.submit();
}

//**********************************************************************************************************
// * Función: incluirEnPedido ()									   	*
// * Autor: Alvaro V.S.								                           	*
// * Fecha Creación: 30/6/2004									           	*
// * Objetivo:   Renavega a la página donde se mostrarán los pedidos               			   	*
// * Parámetros: idMarca - identificativo de la marca a la cual pertenece el artículo a añadir al pedido   	*
// *             idArticulo - identificativo del artículo a añadir al pedido                               	*
//**********************************************************************************************************//

function incluirEnPedido(idMarca,numArticulos,destino,tipoArticulo){	
	var seleccion=false;		
	for(a=0;a<numArticulos;a++){
		objeto=document.getElementById("checkbox"+a);
		if(objeto==null)
			seleccion=true;
		else{
			valor=objeto.checked;
			if(valor==false){
				eval('document.mformArticulos.checkbox'+a+'.value=\'\'');
			}else{
				eval('document.mformArticulos.checkbox'+a+'.value=document.mformArticulos.articulo'+a+'.value');
			}
			if(valor==true)	seleccion=true;
		}
	}	
	if(seleccion==true){	    
		document.mformArticulos.action=destino;		
		document.mformArticulos.idMarca.value=idMarca;
		document.mformArticulos.tipoArticulo.value=tipoArticulo;
		if(window.opener){
			document.mformArticulos.target = "padre";
			document.mformArticulos.submit();
			window.close();
		}else{
			document.mformArticulos.target='';
			document.mformArticulos.submit();
		}
	}
}

//**********************************************************************************************************
// * Función: incluirModeloEnPedido ()									   	*
// * Autor: Alvaro V.S.								                           	*
// * Fecha Creación: 22/6/2004									          	*
// * Objetivo:   Renavega a la página donde se mostrarán los pedidos               			   	*
// * Parámetros: idMarca - identificativo de la marca a la cual pertenece el artículo a añadir al pedido   	*
// *             idArticulo - identificativo del artículo a añadir al pedido                               	*
//**********************************************************************************************************//
function incluirModeloEnPedido(idMarca,idArticulo,seleccion,destino,tipoArticulo,modelo){
	window.location.href=destino+'?idMarca='+idMarca+"&idArticulo="+idArticulo+"&tipoArticulo="+tipoArticulo+"&modelo="+modelo+"&SELECCION="+seleccion;
}

function abrirVentanaAccesorios(idModelo,idFamilia,indice){
	document.mformArticulos.modelo.value=idModelo;
	document.mformArticulos.familia.value=idFamilia;
	document.mformArticulos.indice.value=indice;
	var ancho = 550;
	var alto = 550;
	var xMax = screen.width, yMax = screen.height;
	
	var xOffset = (xMax - ancho)/2, yOffset = (yMax - alto)/2;
	var retorno = 'width='+ancho+',height='+alto+',top='+yOffset+',left='+xOffset;
	var ventana = window.open('about:blank','FlotanteDetalleAccesorio','scrollbars=yes,resizable=yes,'+retorno);
	document.mformArticulos.action='AccEnfriadoraClimaFlotante.jsp';
	document.mformArticulos.target='FlotanteDetalleAccesorio';
	document.mformArticulos.submit();
	ventana.focus();
}
// también se usa en la Búsqueda Avanzada
function openCombiMulti(idModeloCombi, indice, origen){
	if((document.getElementById("checkbox"+indice).checked && origen == "check") || origen == "noCheck"){
		var retorno = popupPosition(820, 550);
		var parametros = 'scrollbars=yes,resizable=yes,'+retorno;
		var ventana = window.open("CombinacionesMultiFlotante.jsp?idSet="+idModeloCombi+"&indice="+indice,'CombinacionesMultiFlotante',parametros);
	}else if(!document.getElementById("checkbox"+indice).checked && origen == "check"){
		if(document.getElementById("numMultisCombinables_"+idModeloCombi)){
			document.getElementById("numMultisCombinables_"+idModeloCombi).value = "0";
		}
		var parame="";
		var elemEliminar = new Array();
		var j=0;
		for(var i=0;i<document.mformArticulos.elements.length;i++){
			var temp = document.mformArticulos.elements[i].name;
			if(temp.lastIndexOf(idModeloCombi)!=-1 && temp.lastIndexOf("numMultisCombinables_" + idModeloCombi)==-1){
				elemEliminar[j]=document.mformArticulos.elements[i];
				j++;
			}
		}
		for(var k=0;k<j;k++){
			document.mformArticulos.removeChild(elemEliminar[k]);
		}
	}
}

// Busqueda Avanzada

/*
* Función que busca la página que se le pasa como parámetro
*/
function damePagina(pagina,jsp){
	document.getElementById('mformArticulos').action = jsp;
	document.getElementById('pagina').value = pagina;
	if(document.mformArticulos.descripcion)
		if(document.mformArticulos.descripcion.value=='buscar...'){document.mformArticulos.descripcion.value='';}
	if(document.mformArticulos.expresionBusqueda)
		if(document.mformArticulos.expresionBusqueda.value=='buscar...'){document.mformArticulos.expresionBusqueda.value='';}
	if(document.mformArticulos.textoConsulta)
		if(document.mformArticulos.textoConsulta.value=='buscar...'){document.mformArticulos.textoConsulta.value='';}
	
	document.getElementById('mformArticulos').submit();
}

/*
* Función que reordena los resultados en función del criterio seleccionado.
*/
function reordenaPagina(criterio,jsp){
	document.getElementById('mformArticulos').action = jsp;
	document.getElementById('criterioOrdenacion').value = criterio;

	if(document.mformArticulos.descripcion)
		if(document.mformArticulos.descripcion.value=='buscar...'){document.mformArticulos.descripcion.value='';}
	if(document.mformArticulos.expresionBusqueda)
		if(document.mformArticulos.expresionBusqueda.value=='buscar...'){document.mformArticulos.expresionBusqueda.value='';}
	if(document.mformArticulos.textoConsulta)
		if(document.mformArticulos.textoConsulta.value=='buscar...'){document.mformArticulos.textoConsulta.value='';}
	
	document.getElementById('mformArticulos').submit();
}

/*
* Función que elimina las opciones seleccionadas
*/
function limpiarSeleccion(){
	document.getElementById('mformArticulos').action = "BusqAvanzada.jsp?borrarCantidades=si";

	if(document.mformArticulos.descripcion)
		if(document.mformArticulos.descripcion.value=='buscar...'){document.mformArticulos.descripcion.value='';}
	if(document.mformArticulos.expresionBusqueda)
		if(document.mformArticulos.expresionBusqueda.value=='buscar...'){document.mformArticulos.expresionBusqueda.value='';}
	if(document.mformArticulos.textoConsulta)
		if(document.mformArticulos.textoConsulta.value=='buscar...'){document.mformArticulos.textoConsulta.value='';}
	
	document.getElementById('mformArticulos').submit();
}

/*
* Función que elimina las opciones seleccionadas
*/
function anyadirAlPedido(){
	for(var i=0;i<document.mformArticulos.elements.length;i++){
		if(document.mformArticulos.elements[i].name.indexOf("checkbox")!=-1){
			var pos = document.mformArticulos.elements[i].name.substring(8);
			if(document.mformArticulos.elements[i].checked){
				document.getElementById("cantidad"+pos).value = "1";
			}else{
				document.getElementById("cantidad"+pos).value = "";
			}
		}
	}
	document.getElementById('mformArticulos').action = "detalleCesta.jsp?operacion=" + incluirEnPedidoBusq;

	if(document.mformArticulos.descripcion)
		if(document.mformArticulos.descripcion.value=='buscar...'){document.mformArticulos.descripcion.value='';}
	if(document.mformArticulos.expresionBusqueda)
		if(document.mformArticulos.expresionBusqueda.value=='buscar...'){document.mformArticulos.expresionBusqueda.value='';}
	if(document.mformArticulos.textoConsulta)
		if(document.mformArticulos.textoConsulta.value=='buscar...'){document.mformArticulos.textoConsulta.value='';}
	
	document.getElementById('mformArticulos').submit();
}

function habilitarCampo(){
	if (document.getElementById('idCatalogo').value == consIdCatalogoHep2o || document.getElementById('idCatalogo').value == consIdCatalogoSueloRadiante){
		lineaDim.style.visibility = 'visible';
	}else{
		document.getElementById('dimension').value = '';
		lineaDim.style.visibility = "hidden";
	}
}

function enviar(objeto){
	if(document.all){
		if(event.keyCode == 13){
			var valor = trim(objeto.value);
		 	var enteroValidado = validarEntero2(valor);
	    	if (enteroValidado != ""){
				anyadirAlPedido();
			}
		}
	}
}

function buscarProductos(boton){
	if(boton==''){
		if(document.all){
			if(event.keyCode == 13){
				if(document.mformArticulos.descripcion)
					if(document.mformArticulos.descripcion.value=='buscar...'){document.mformArticulos.descripcion.value='';}
				if(document.mformArticulos.expresionBusqueda)
					if(document.mformArticulos.expresionBusqueda.value=='buscar...'){document.mformArticulos.expresionBusqueda.value='';}
				if(document.mformArticulos.textoConsulta)
					if(document.mformArticulos.textoConsulta.value=='buscar...'){document.mformArticulos.textoConsulta.value='';}
				document.getElementById('mformArticulos').submit();
			}
		}
	}else{
		if(document.mformArticulos.descripcion)
			if(document.mformArticulos.descripcion.value=='buscar...'){document.mformArticulos.descripcion.value='';}
		if(document.mformArticulos.expresionBusqueda)
			if(document.mformArticulos.expresionBusqueda.value=='buscar...'){document.mformArticulos.expresionBusqueda.value='';}
		if(document.mformArticulos.textoConsulta)
			if(document.mformArticulos.textoConsulta.value=='buscar...'){document.mformArticulos.textoConsulta.value='';}
		document.getElementById('mformArticulos').submit();
	}
}

function abrirCapa(idCapa, pos){
	var capa=document.getElementById('seleccionKit'+idCapa);
	var capaIntermedia;
	for(var i=0; i<=document.mformArticulos.numArticulos.value; i++){
		if(document.getElementById('seleccionKit'+i)){
			capaIntermedia = document.getElementById('seleccionKit'+i);
			capaIntermedia.style.visibility='hidden';
		}
	}

	capa.style.visibility='visible';
	if(pos!='noMover')
		setLyr(pos,'seleccionKit' + idCapa);

	var irA = "#pos" + idCapa
}

function abrirVentana(opcion,idErp,marca){
	var posicion = popupPosition(650, 500);
	var parametros = 'scrollbars=yes,status=no,toolbar=no,location=no,directories=no,menubar=no,resizable=0,' + posicion;
	var url='ElementosEvacuacion.jsp?idERP='+idErp+"&marca="+marca+"&opcion="+opcion+"&esCatalogo=si";
	var ventana=window.open(url,'ElementosEvacuacion',parametros);
	ventana.focus();
}

function openCombiCaudal(idModeloCombi, indice, origen){
	if((document.getElementById("checkbox"+indice).checked && origen == "check") || origen == "noCheck"){
		var retorno = popupPosition(630, 550);
		var parametros = 'scrollbars=yes,resizable=yes,'+retorno;
		var ventana = window.open("CombinacionesSistemaCaudalVariableFlotante.jsp?idSet="+idModeloCombi+"&indice="+indice,'CombinacionesMultiFlotante',parametros);
	}else if(!document.getElementById("checkbox"+indice).checked && origen == "check"){
		if(document.getElementById("numMultisCombinables_"+idModeloCombi)){
			document.getElementById("numMultisCombinables_"+idModeloCombi).value = "0";
		}
		var parame="";
		var elemEliminar = new Array();
		var j=0;
		for(var i=0;i<document.mformArticulos.elements.length;i++){
			var temp = document.mformArticulos.elements[i].name;
			if(temp.lastIndexOf(idModeloCombi)!=-1 && temp.lastIndexOf("numMultisCombinables_" + idModeloCombi)==-1){
				elemEliminar[j]=document.mformArticulos.elements[i];
				j++;
			}
		}
		for(var k=0;k<j;k++){
			document.mformArticulos.removeChild(elemEliminar[k]);
		}
	}
}

function buscarModeloMultis1(){
	idModelo = document.getElementById("form1").modelos1.options[document.getElementById("form1").modelos1.selectedIndex].value;
	document.getElementById("form1").ID_FAMILIA.value = idFamiliaMOD;
	document.getElementById("form1").ID_MODELO.value = idModelo;
	document.getElementById("form1").ID_CATALOGO.value = idCatalogo;
	document.form1.submit();
}

function buscarModeloMultis2(){
	idModelo = document.form2.modelos2.options[document.form2.modelos2.selectedIndex].value;
	document.form2.ID_FAMILIA.value = idFamiliaMOD;
	document.form2.ID_MODELO.value = idModelo;
	document.form2.ID_CATALOGO.value = idCatalogo;
	document.form2.submit();
}


function enviarSeleccion(){
	var formulario=document.getElementById("formModelo");
	var kitEvacuacion=document.getElementById("kitEvacuacion");
	window.opener.name="paginaPadre";
	document.formulario.submit();
	window.opener.focus();
	window.close();
}

function abrirVentanaElemEvac(idErp,marca,idMarca,idArticulo,tipoArticulo,modelo, seleccion){
	var posicion = popupPosition(650, 500);
	var parametros = 'scrollbars=yes,status=no,toolbar=no,location=no,directories=no,menubar=no,resizable=0,' + posicion;
	var url="ElementosEvacuacion.jsp?idERP="+idErp+"&marca="+marca+"&esCatalogo=si&esModelo=si&SELECCION="+seleccion+"&idMarca="+idMarca+"&idArticulo="+idArticulo+"&tipoArticulo="+tipoArticulo+"&modelo="+modelo;
	var ventana=window.open(url,'ElementosEvacuacion',parametros);
	ventana.focus();
}

function abrirCapaKit(idCapa,idModelo,pos){
	var idArticulo=document.getElementById("idArticulo");
	idArticulo.value=idModelo;
	var objCheck=document.getElementById("checkbox"+idCapa);
	var objInputHidden=document.getElementById("cantidadArt"+idCapa);
	if((objCheck!=null && !objCheck.checked) && objInputHidden==null){
		// Pongo a blanco el kit de evacuacion porque se está deschequeando
		document.getElementById("kitEvacuacion"+idCapa).value='';
	}
	else{
		var capaIntermedia;
		for(var i=1; i<3; i++){
			if(document.getElementById('seleccionKit'+i)){
				capaIntermedia = document.getElementById('seleccionKit'+i);
				capaIntermedia.style.visibility='hidden';
			}
		}
		var capa=document.getElementById('seleccionKit'+idCapa);
		capa.style.visibility='visible';
		setLyr(pos,'seleccionKit' + idCapa);
	}
}
function irABusquedaProductos(seleccionadoHijo){
	
	var descripcion = document.mformArticulos.expresionBusqueda.value;
	if (descripcion == "buscar..." || descripcion == " "){
		descripcion = "";
	}
	
	window.location.href = "BusqAvanzada.jsp?primeraVez=si&SELECCION="+seleccionadoHijo+"&descripcion="+descripcion+"&desdeModulo=si";

}
function irABusquedaWeb(seleccionadoHijo){
	
	var descripcion = document.mformArticulos.descripcion.value;
	if (descripcion == "buscar..." || descripcion == " "){
		descripcion = "";
	}
	
	window.location.href = "BusqWeb.jsp?primeraVez=si&SELECCION="+seleccionadoHijo+"&expresionBusqueda="+descripcion+"&funcion=busquedaWeb";

}