﻿var strNombreDivLocal="";
		function MM_goToURL()
		{
			//v3.0
			var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
			for (i=0; i<(args.length-1); i+=2)
				eval(args[i]+".location='"+args[i+1]+"'");
		}

		function insertarHTML(html,strDiv)
		{		
			document.getElementById(strDiv).focus();
			var range = document.selection.createRange();
			range.pasteHTML(html);
		}

		function getSelectedHTML()
		{
			var range = document.selection.createRange();
			var existing = null;
			existing = range.htmlText;
			return existing;
		};

		function envolverHTML(antes,despues,strDiv)
		{
			var cadena=null;
			cadena=antes + getSelectedHTML() + despues;
			insertarHTML(cadena,strDiv);
		};

		function AddLink(strDiv)
		{
			//Identify selected text
			var sText = document.selection.createRange();
			if (!sText=="")
			{
				var url=prompt("Introduzca un hipervínculo","http://");
				if (url!=null && url!="http://")
					envolverHTML("<a class=\"textoazul\" href=\"" + url + "\" >","</a>",strDiv);
			}
			else
			{
				alert("Por favor, seleccione un texto antes!");
			}   
		}
		
		function insertarTabla(strDiv)
		{	
			strNombreDivLocal=strDiv;
			if (window.showModalDialog)
			{
				window.showModalDialog("PopUpDatosTabla.htm",this,	"dialogWidth:255px;dialogHeight:250px;center=yes;status=no");
			}
			else
			{
				window.open('PopUpDatosTabla.htm','name', 'height=255,width=250,toolbar=no,directories=no,status=no, menubar=no,scrollbars=no,resizable=no ,modal=yes');
			}
		}

		function generarTabla()
		{
			var argv = generarTabla.arguments;
			var argc = argv.length;
			//for (var i = 0; i < argc; i++)
			//{
			//	alert("Argument " + i + " = " + argv[i]);
			//}

			var numFilas = argv[0];
			var numCols = argv[1];
			var s_cabecera = argv[2];
			
			//DEBUG: Datos estáticos (excepto cabecera)
			//var s_cabecera = prompt("Texto de cabecera de la tabla","");
			//var numFilas = 4;
			//var numCols = 6;
			
			var s_html_Tabla = "<table class=tablaproducto cellspacing=0 cellpadding=5><tbody>";
			var contFilas = 1;
			var contCols = 1;
			
			if (s_cabecera != "")
			{
				s_html_Tabla = s_html_Tabla + "<th align=center colspan=" + numCols + ">" + s_cabecera + "</th>";
				contFilas = 2;
			}
			
			for(; contFilas <= numFilas; contFilas++)
			{
				s_html_Tabla = s_html_Tabla + "<tr class=trproductocolor" + ((contFilas&1==1)?"1":"2") + ">";
				for(; contCols <= numCols; contCols++)
				{
					s_html_Tabla = s_html_Tabla + "<td>&nbsp;</td>";
				}
				contCols = 1;
				s_html_Tabla = s_html_Tabla + "</tr>";
			}

			s_html_Tabla = s_html_Tabla + "</tbody></table>";
			insertarHTML(s_html_Tabla,strNombreDivLocal);
		}
		
		function seleccionarFormato(formSeleccion,strDiv)
		{
			if ( formSeleccion.value != "Destacado")
			{
				document.getElementById(strDiv).document.execCommand('FormatBlock', false, formSeleccion.value);
			}
			else
			{
				//alert("Destacado seleccionado");
				envolverHTML("<span class='destacado1'>","</span>",strDiv);
			}
			formSeleccion.value=0;
		}
		
	
	
		function toggleLayer1(strDiv,strTaHTML)
		{
			var estilo = document.getElementById(strDiv).style;
			if (estilo.display != "none")
			{
				estilo.display = "none";
				document.getElementById(strTaHTML).value = document.getElementById(strDiv).innerHTML;
			}
			else
			{
				estilo.display = "block";
			}
			
		}
		function toggleLayer2(strDiv,strDivHTML,strTaHTML)
		{
			var estilo = document.getElementById(strDivHTML).style;
			if (estilo.display != "none")
			{
				estilo.display = "none";
				document.getElementById(strDiv).innerHTML = document.getElementById(strTaHTML).value;
			}
			else
			{
				estilo.display = "block";
			}
						
		}
		function mostrarHTML(strDiv,strDivHTML,strTaHTML)
		{				    
			toggleLayer1(strDiv,strTaHTML);
			toggleLayer2(strDiv,strDivHTML,strTaHTML)
		}
		
		function actualizarRutaHTML()
		{
			//alert("evento!!\n" + getSelectedHTML());
		}
		function actualizarRutaHTMLI()
		{
			//alert("evento!!\n" + getSelectedHTML());
		}
		function actualizarRutaHTMLP()
		{
			//alert("evento!!\n" + getSelectedHTML());
		}
		function actualizarRutaHTMLF()
		{
			//alert("evento!!\n" + getSelectedHTML());
		}
		function actualizarRutaHTMLG()
		{
			//alert("evento!!\n" + getSelectedHTML());
		}

		function precarga()
		{
			// Inicializamos los formatos del sistema

			// Tipos:

			// No estándar
				oOpcion = document.createElement("option");
				oOpcion.value = "Destacado";
				oOpcion.text = "Destacado";

				document.getElementById("sltFormatos").add(oOpcion);

			// Estándar
			for (iCont = 1 ; iCont <= document.getElementById("dialogHelper").blockFormats.count ; iCont++)
			{
				sElemento = document.getElementById("dialogHelper").blockFormats.item(iCont);

				oOpcion = document.createElement("option");
				oOpcion.value = sElemento;
				oOpcion.text = sElemento;

				document.getElementById("sltFormatos").add(oOpcion);
			}
			
			//Estas líneas son VITALES y no sé por qué (supuestamente están bien en el css)
			document.getElementById("ctl00_ContentPlaceHolder1_diveditor").style.display = "block";
			document.getElementById("divHTML").style.display = "none";
			document.getElementById("taHTML").value= "";
		}			
		function precargaI()
		{
			// Inicializamos los formatos del sistema

			// Tipos:

			// No estándar
				oOpcion = document.createElement("option");
				oOpcion.value = "Destacado";
				oOpcion.text = "Destacado";

				document.getElementById("sltFormatosI").add(oOpcion);

			// Estándar
			for (iCont = 1 ; iCont <= document.getElementById("dialogHelper").blockFormats.count ; iCont++)
			{
				sElemento = document.getElementById("dialogHelperI").blockFormats.item(iCont);

				oOpcion = document.createElement("option");
				oOpcion.value = sElemento;
				oOpcion.text = sElemento;

				document.getElementById("sltFormatosI").add(oOpcion);
			}
			
			//Estas líneas son VITALES y no sé por qué (supuestamente están bien en el css)
			document.getElementById("ctl00_ContentPlaceHolder1_diveditorI").style.display = "block";
			document.getElementById("divHTMLI").style.display = "none";
			document.getElementById("taHTMLI").value= "";
		}
		function precargaP()
		{
			// Inicializamos los formatos del sistema

			// Tipos:

			// No estándar
				oOpcion = document.createElement("option");
				oOpcion.value = "Destacado";
				oOpcion.text = "Destacado";

				document.getElementById("sltFormatosP").add(oOpcion);

			// Estándar
			for (iCont = 1 ; iCont <= document.getElementById("dialogHelperP").blockFormats.count ; iCont++)
			{
				sElemento = document.getElementById("dialogHelperP").blockFormats.item(iCont);

				oOpcion = document.createElement("option");
				oOpcion.value = sElemento;
				oOpcion.text = sElemento;

				document.getElementById("sltFormatosP").add(oOpcion);
			}
			
			//Estas líneas son VITALES y no sé por qué (supuestamente están bien en el css)
			document.getElementById("ctl00_ContentPlaceHolder1_diveditorP").style.display = "block";
			document.getElementById("divHTMLP").style.display = "none";
			document.getElementById("taHTMLP").value= "";
		}

		function precargaF()
		{
			// Inicializamos los formatos del sistema

			// Tipos:

			// No estándar
				oOpcion = document.createElement("option");
				oOpcion.value = "Destacado";
				oOpcion.text = "Destacado";

				document.getElementById("sltFormatosF").add(oOpcion);

			// Estándar
			for (iCont = 1 ; iCont <= document.getElementById("dialogHelperF").blockFormats.count ; iCont++)
			{
				sElemento = document.getElementById("dialogHelperF").blockFormats.item(iCont);

				oOpcion = document.createElement("option");
				oOpcion.value = sElemento;
				oOpcion.text = sElemento;

				document.getElementById("sltFormatosF").add(oOpcion);
			}
			
			//Estas líneas son VITALES y no sé por qué (supuestamente están bien en el css)
			document.getElementById("ctl00_ContentPlaceHolder1_diveditorF").style.display = "block";
			document.getElementById("divHTMLF").style.display = "none";
			document.getElementById("taHTMLF").value= "";
		}

		function precargaG()
		{
			// Inicializamos los formatos del sistema

			// Tipos:

			// No estándar
				oOpcion = document.createElement("option");
				oOpcion.value = "Destacado";
				oOpcion.text = "Destacado";

				document.getElementById("sltFormatosG").add(oOpcion);

			// Estándar
			for (iCont = 1 ; iCont <= document.getElementById("dialogHelperG").blockFormats.count ; iCont++)
			{
				sElemento = document.getElementById("dialogHelperG").blockFormats.item(iCont);

				oOpcion = document.createElement("option");
				oOpcion.value = sElemento;
				oOpcion.text = sElemento;

				document.getElementById("sltFormatosG").add(oOpcion);
			}
			
			//Estas líneas son VITALES y no sé por qué (supuestamente están bien en el css)
			document.getElementById("ctl00_ContentPlaceHolder1_diveditorG").style.display = "block";
			document.getElementById("divHTMLG").style.display = "none";
			document.getElementById("taHTMLG").value= "";
		}

	function GuardarContenido()
	{
		var contenidoHTML = document.getElementById("ctl00_ContentPlaceHolder1_diveditor").innerHTML;
	   document.getElementById("ctl00$ContentPlaceHolder1$hdContenido").value = contenidoHTML; 
	}
	function GuardarContenidoI()
	{
		var contenidoHTML = document.getElementById("ctl00_ContentPlaceHolder1_diveditorI").innerHTML;
	   document.getElementById("ctl00$ContentPlaceHolder1$hdContenidoI").value = contenidoHTML; 
	}		
	function GuardarContenidoP()
	{
		var contenidoHTML = document.getElementById("ctl00_ContentPlaceHolder1_diveditorP").innerHTML;
	   document.getElementById("ctl00$ContentPlaceHolder1$hdContenidoP").value = contenidoHTML; 
	}			

	function GuardarContenidoF()
	{
		var contenidoHTML = document.getElementById("ctl00_ContentPlaceHolder1_diveditorF").innerHTML;
	   document.getElementById("ctl00$ContentPlaceHolder1$hdContenidoF").value = contenidoHTML; 
	}
	function GuardarContenidoG()
	{
		var contenidoHTML = document.getElementById("ctl00_ContentPlaceHolder1_diveditorG").innerHTML;
	   document.getElementById("ctl00$ContentPlaceHolder1$hdContenidoG").value = contenidoHTML; 
	}

/**
* Valida una seccion especifica del formulario de alta de ficheros.
**/
function validarIdioma(idioma) {
//colaMP = "ctl00_ContentPlaceHolder1_";
//    if (((document.getElementById(colaMP + "txtTitulo" + idioma).value != "") 
//       && (document.getElementById(colaMP + "fupFichero" + idioma).value == "")) || 
//       ((document.getElementById(colaMP + "txtTitulo" + idioma).value == "") 
//       && (document.getElementById(colaMP + "fupFichero" + idioma).value != "")))       
//    { return false;
//    } else {
//    return true; }

}
function validarAltaFicheros() {  
//    colaMP = "ctl00_ContentPlaceHolder1_";     
//    if (validarIdioma("CAS") == false) {
//        alert('Rellena correctamente los datos de castellano.');
//        window.event.returnValue = false;	
//    } else {
//        if (document.getElementById(colaMP+"ckIngles").checked == true) {        
//            if (document.getElementById(colaMP+"txtTituloING").value == "") {
//                alert('El fichero necesita un titulo para el idioma inglés.');
//                window.event.returnValue = false;
//            }           
//        } else {
//            if (validarIdioma("ING") == false) {
//                alert('Rellena correctamente los datos de inglés.');
//                window.event.returnValue = false;	
//            }
//        } // del else del ckIngles
//        if (window.event.returnValue != false) {
//            if (validarIdioma("POR") == false) {
//                alert('Rellena correctamente los datos de portugués.');
//                window.event.returnValue = false;	
//            }
//        } // del if de POR
//    } // del else de CAS
    return 1;
}

/**
* Dado un elemento valido del HTML del documento se visualiza u oculta dependiendo del estado actual.
**/
    function visualizar (elemento) {                
        if (document.getElementById(elemento).style.display=='none') {
            document.getElementById(elemento).style.display='inline';
        } else {
            document.getElementById(elemento).style.display='none';
        }
    }
/**
* Carga la imagen del modelo en el elemento idImagen
**/

function cargarImagen (modelo) {
    //document.getElementById('idImagen').src = "descargarImagenModelo.aspx?idModelo=" + modelo    
    document.getElementById('idImagen').src = modelo    
    document.getElementById('idImagen').visible = true
}

function anadirFavoritos(url) { 
	if (window.sidebar && window.sidebar.addPanel) 
		window.sidebar.addPanel("Arteche",url,""); 
	else 
		window.external.AddFavorite(url,"Arteche") ;
} 

function changeSector(seleccion,idioma){
	document.location="verRsdoBusquedaGeneral.aspx?idioma=" + idioma + "&sector=" + seleccion.value;
}
function changeAplicacion(seleccion,idioma){
	document.location="verRsdoBusquedaGeneral.aspx?idioma=" + idioma + "&aplicacion=" + seleccion.value;
}