// Documento JavaScript

			function MM_openBrWindow(theURL,winName,features) { //v2.0
  				window.open(theURL,winName,features);
			}

			function MM_reloadPage(init) {  //reloads the window if Nav4 resized
			  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
				document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
			  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
			}
			MM_reloadPage(true);

// Esta función cargará las paginas
function llamarasincrono(url, id_contenedor){
	

var pagina_requerida = false

if (window.XMLHttpRequest) {// Si es Mozilla, Safari etc
	pagina_requerida = new XMLHttpRequest()
	
} 
else if (window.ActiveXObject){ // pero si es IE
	try {
		pagina_requerida = new ActiveXObject("Msxml2.XMLHTTP")
	} 
	catch (e){ // en caso que sea una versión antigua
		try{
			pagina_requerida = new ActiveXObject("Microsoft.XMLHTTP")
			
		}
		catch (e)
		{}
	}
}
else
	return false

pagina_requerida.onreadystatechange=function(){ // función de respuesta
	cargarpagina(pagina_requerida, id_contenedor)
	
}

pagina_requerida.open('GET', url, true) // asignamos los métodos open y send

pagina_requerida.send(null)

} //fin llamarasincrono

// todo es correcto y ha llegado el momento de poner la información requerida
// en su sitio en la pagina xhtml
function cargarpagina(pagina_requerida, id_contenedor){

	if (pagina_requerida.readyState == 4 && (pagina_requerida.status==200 || window.location.href.indexOf("http")==-1))
		document.getElementById(id_contenedor).innerHTML=pagina_requerida.responseText
	}

function llamar2asincronos(url, id_contenedor, url2, id_contenedor2){
	
var pagina_requerida = false
var pagina_requerida2 = false

if (window.XMLHttpRequest) {// Si es Mozilla, Safari etc
	pagina_requerida = new XMLHttpRequest()
	pagina_requerida2 = new XMLHttpRequest()
} 
else if (window.ActiveXObject){ // pero si es IE
	try {
		pagina_requerida = new ActiveXObject("Msxml2.XMLHTTP")
		pagina_requerida2 = new ActiveXObject("Msxml2.XMLHTTP")
	} 
	catch (e){ // en caso que sea una versión antigua
		try{
			pagina_requerida = new ActiveXObject("Microsoft.XMLHTTP")
			pagina_requerida2 = new ActiveXObject("Microsoft.XMLHTTP")
		}
		catch (e){}
	}
}
else
	return false

pagina_requerida.onreadystatechange=function(){ // función de respuesta
cargarpagina(pagina_requerida, id_contenedor)
}

pagina_requerida2.onreadystatechange=function(){ // función de respuesta
cargarpagina(pagina_requerida2, id_contenedor2)
}

pagina_requerida.open('GET', url, true) // asignamos los métodos open y send
pagina_requerida.send(null)
pagina_requerida2.open('GET', url2, true) // asignamos los métodos open y send
pagina_requerida2.send(null)
}

function cargar2paginas(pagina_requerida, id_contenedor, pagina_requerida2, id_contenedor2){
if ((pagina_requerida.readyState == 4 && (pagina_requerida.status==200 || window.location.href.indexOf("http")==-1))&&(pagina_requerida2.readyState == 4 && (pagina_requerida2.status==200 || window.location.href.indexOf("http")==-1))){
	document.getElementById(id_contenedor).innerHTML=pagina_requerida.responseText
	document.getElementById(id_contenedor2).innerHTML=pagina_requerida2.responseText
}
}

function cargardiv(url, idpag, iddiv_origen, iddiv_destino, lang){
	
	return llamarasincrono(url+'?idpag='+idpag+'&iddiv='+iddiv_origen+'&lang='+lang, iddiv_destino);
	
}

function cargardivnoticia(url, idnot, iddiv_destino, lang){
	
	return llamarasincrono(url+'?idnot='+idnot+'&lang='+lang, iddiv_destino);
	
}

function cargardivtodasnoticias(url, iddiv_destino, lang){
	
	return llamarasincrono(url+'?lang='+lang, iddiv_destino);
	
}

//function cargardivenlaces(url, categoria, subcategoria, iddiv_destino, lang){
//	
//	return llamarasincrono(url+'?categoria='+categoria+'&subcategoria='+subcategoria+'&lang='+lang, iddiv_destino);
//	//return alert(url+'?categoria='+categoria+'&subcategoria='+subcategoria);
//}

function cargardivenlaces(url, categoria, subcategoria, iddiv_destino){
	
	//alert(url+'?categoria='+categoria+'&subcategoria='+subcategoria);
	return llamarasincrono(url+'?categoria='+categoria+'&subcategoria='+subcategoria, iddiv_destino);
	
}
function cargardivparticipantes(url, letra, iddiv_destino, lang){
	
	//alert(url+'?letra='+letra);
	return llamarasincrono(url+'?letra='+letra+'&lang='+lang, iddiv_destino);
	
}
function cargardocumentos(url, categoria, subcategoria,lang,iddiv_destino){
	
	//alert(url+'?categoria='+categoria+'&subcategoria='+subcategoria+'&lang='+lang);
	//alert(iddiv_destino);
	return llamarasincrono(url+'?categoria='+categoria+'&subcategoria='+subcategoria+'&lang='+lang, iddiv_destino);
	
}
function cargareventos(){
	
	document.getElementById('eventoscontenido').style.display = 'block';
	document.getElementById('columnacentro').style.display = 'none';
	document.getElementById('columnaderecha').style.display = 'none';
}

function ocultareventos(){
	
	document.getElementById('eventoscontenido').style.display = 'none';
	document.getElementById('columnacentro').style.display = 'block';
	document.getElementById('columnaderecha').style.display = 'block';
}

function ocultarparticipantes(){
	
	document.getElementById('content').style.display = 'none';
	document.getElementById('grupos').style.display = 'block';
}

function cargarparticipantes(){
	
	document.getElementById('content').style.display = 'block';
	document.getElementById('grupos').style.display = 'none';
}

function cargaradmindoc(){
	
	document.getElementById('listadodocumentos').style.display = 'block';
	document.getElementById('noticiasimgtitulo').style.display = 'none';
	document.getElementById('noticiasimgcontenido').style.display = 'none';
}

function ocultaradmindoc(){
	
	document.getElementById('listadodocumentos').style.display = 'none';
	document.getElementById('noticiasimgtitulo').style.display = 'block';
	document.getElementById('noticiasimgcontenido').style.display = 'block';
}

function ocultarnot(){
	
	//document.getElementById('listadodocumentos').style.display = 'none';
	document.getElementById('noticiasimgtitulo').style.display = 'none';
	document.getElementById('noticiasimgcontenido').style.display = 'none';
}

function cargararnot(){
	
	//document.getElementById('listadodocumentos').style.display = 'none';
	document.getElementById('noticiasimgtitulo').style.display = 'block';
	document.getElementById('noticiasimgcontenido').style.display = 'block';
}

function verMenu(numero,menuTotales){ 
	for ( i= 1; i<=menuTotales; i++ ){ 
		nombre = "tabla" + i 
		var menu = document.getElementById(nombre); 
		if ( i != numero ){ 
			menu.style.display = "none"; 
		} 
		else{ 
			if(menu.style.display == "none"){ 
				menu.style.display = "block"; 
			} 
			else{ 
				menu.style.display = "none"; 
			} 
		} 
	} 
}

function capturaruta(nombre,idgal){
//alert(nombre.value);
//alert(idgal.value);
var caracter,i;
i=nombre.value.length;

while(i>0){
	caracter=nombre.value.charAt(i);
	if (caracter=='\\'){
		//alert(nombre.value.substring(i+1,nombre.value.length));
		return false;
	}
	i=i-1;
}
		//alert(idgal.value);
		document.forms[0].action = 'admingaleria.asp?idgal='+idgal.value+'&cadena='+nombre.value;
		document.forms[0].submit();
        return true;

}

function comprobarSiBisisesto(anio){
if ( ( anio % 100 != 0) && ((anio % 4 == 0) || (anio % 400 == 0))) {
    return true;
    }
else {
    return false;
    }
}

function esFechaValida(fecha,idioma){
    if (fecha != undefined && fecha.value != "" ){
//        if (!/^\d{2}\/\d{2}\/\d{4}$/.test(fecha.value)){
//        if (!/^\d{2}-\d{2}-\d{4}$/.test(fecha.value)){
        if (!/^\d{2}-\d{2}-\d{4}$/.test(fecha.value)){
            alert("formato de fecha no válido (dd-mm-aaaa)");
            return false;
        }
        
		var primerdigitodia=parseInt(fecha.value.substring(0,1),10);
		var primerdigitomes=parseInt(fecha.value.substring(3,4),10);

		var dia  =  parseInt(fecha.value.substring(0,2),10);
	    var mes  =  parseInt(fecha.value.substring(3,5),10);
		var anio =  parseInt(fecha.value.substring(6),10);
 
    	switch(mes){
        	case 1:
        	case 3:
		    case 5:
    		    	case 7:
        			case 8: 
        			case 10:
	        		case 12:
    	        		numDias=31;
	        	    	break;
    	    		case 4: case 6: case 9: case 11:
        	    		numDias=30;
	        	    	break;
    	    		case 2:
        	    		if (comprobarSiBisisesto(anio)){ numDias=29 }else{ numDias=28};
	            		break;
		        	default:
    		        	alert("Fecha introducida errónea");
        	    	return false;
	    }
		
		
		if (primerdigitodia==0){	
			dia  =  parseInt(fecha.value.substring(1,2),10);
		}
		
		if (primerdigitomes==0){	
			mes  =  parseInt(fecha.value.substring(4,5),10);
		}

    	if (dia>numDias || dia==0){
       		alert("Fecha introducida errónea");
            return false;
	    }
		fecha.value=dia+"-"+mes+"-"+anio
		var b;
		b=getValue(idioma);
		//alert(b);
		document.forms[0].action = 'Addevento.asp?lang='+b;
		document.forms[0].submit();
        return true;
	}
}//function

function esFechaValidaNoticia(fecha){
	//alert(fecha.value);
    if (fecha != undefined && fecha.value != "" ){
        if (!/^\d{2}\/\d{2}\/\d{4}$/.test(fecha.value)){
//        if (!/^\d{2}-\d{2}-\d{4}$/.test(fecha.value)){
//        if (!/^\d{2}-\d{2}-\d{4}$/.test(fecha.value)){
            alert("formato de fecha no válido (dd/mm/aaaa)");
            return false;
        }
        
		var primerdigitodia=parseInt(fecha.value.substring(0,1),10);
		var primerdigitomes=parseInt(fecha.value.substring(3,4),10);

		var dia  =  parseInt(fecha.value.substring(0,2),10);
	    var mes  =  parseInt(fecha.value.substring(3,5),10);
		var anio =  parseInt(fecha.value.substring(6),10);
 
    	switch(mes){
        	case 1:
        	case 3:
		    case 5:
    		    	case 7:
        			case 8: 
        			case 10:
	        		case 12:
    	        		numDias=31;
	        	    	break;
    	    		case 4: case 6: case 9: case 11:
        	    		numDias=30;
	        	    	break;
    	    		case 2:
        	    		if (comprobarSiBisisesto(anio)){ numDias=29 }else{ numDias=28};
	            		break;
		        	default:
    		        	alert("Fecha introducida errónea");
        	    	return false;
	    }
		
		
//		if (primerdigitodia==0){	
//			dia  =  parseInt(fecha.value.substring(1,2),10);
//		}
//		
//		if (primerdigitomes==0){	
//			mes  =  parseInt(fecha.value.substring(4,5),10);
//		}

    	if (dia>numDias || dia==0){
       		alert("Fecha introducida errónea");
            return false;
	    }
		fecha.value=dia+"/"+mes+"/"+anio
		//document.forms[0].action = 'Addevento.asp?lang='+b;
		document.forms[0].submit();
        return true;
	}
}//function



function esFechaValidaDocumento(fecha){
	//alert(fecha.value);
    if (fecha != undefined && fecha.value != "" ){
        if (!/^\d{2}\/\d{2}\/\d{4}$/.test(fecha.value)){
//        if (!/^\d{2}-\d{2}-\d{4}$/.test(fecha.value)){
//        if (!/^\d{2}-\d{2}-\d{4}$/.test(fecha.value)){
            alert("formato de fecha no válido (dd/mm/aaaa)");
            return false;
        }
        
		var primerdigitodia=parseInt(fecha.value.substring(0,1),10);
		var primerdigitomes=parseInt(fecha.value.substring(3,4),10);

		var dia  =  parseInt(fecha.value.substring(0,2),10);
	    var mes  =  parseInt(fecha.value.substring(3,5),10);
		var anio =  parseInt(fecha.value.substring(6),10);
 
    	switch(mes){
        	case 1:
        	case 3:
		    case 5:
    		    	case 7:
        			case 8: 
        			case 10:
	        		case 12:
    	        		numDias=31;
	        	    	break;
    	    		case 4: case 6: case 9: case 11:
        	    		numDias=30;
	        	    	break;
    	    		case 2:
        	    		if (comprobarSiBisisesto(anio)){ numDias=29 }else{ numDias=28};
	            		break;
		        	default:
    		        	alert("Fecha introducida errónea");
        	    	return false;
	    }
		
		
//		if (primerdigitodia==0){	
//			dia  =  parseInt(fecha.value.substring(1,2),10);
//		}
//		
//		if (primerdigitomes==0){	
//			mes  =  parseInt(fecha.value.substring(4,5),10);
//		}

    	if (dia>numDias || dia==0){
       		alert("Fecha introducida errónea");
            return false;
	    }
		fecha.value=dia+"/"+mes+"/"+anio
		//document.forms[0].action = 'Addevento.asp?lang='+b;
		//document.forms[0].submit();
        return true;
	}
}//function

function setCheckedValue(radioObj, newValue) {
	if(!radioObj)
		return;
	var radioLength = radioObj.length;
	if(radioLength == undefined) {
		radioObj.checked = (radioObj.value == newValue.toString());
		return;
	}
	for(var i = 0; i < radioLength; i++) {
		radioObj[i].checked = false;
		if(radioObj[i].value == newValue.toString()) {
			radioObj[i].checked = true;
		}
	}
}

function getValue(radioObj){
    
      	 //alert('hola');
		 var radioLength = radioObj.length;
         for(var i = 0; i < radioLength; i++){
    
               if(radioObj[i].checked == true){
				   	   //alert(radioObj[i].value);
                       return radioObj[i].value;
               }
         
               else{}
      }                             
                
    }  

function envia(url,lang,t){
	
//alert(url);
//location.href=url+'?lang='+lang+'&t='+t;
//alert(location.href=url+'?lang='+lang+'&t='+t);
document.forms[0].action = url+'?lang='+lang+'&t='+t;
document.forms[0].submit();
return true;

}

function validagrupo(esp,eng){

if((esp.length>0)&&(eng.length>0))
	document.forms[0].submit();

else{
alert('debe introducir el título del grupo de imágenes para los 2 idiomas');
	return false;
}
}

function controla(){

    //valido el interés 
    if (document.forms[0].empresa.value.length<=0){ 
       alert("Debe escribir el nombre de la empresa") 
       return 0; 
    } 

    //el formulario se envia 
    //alert("Muchas gracias por enviar el formulario"); 
	document.forms[0].action = 'boletin.asp';
	document.forms[0].submit();
}

function validacatsub(categoria,subcategoria,titulo,url){

//alert(url.value);
//alert(titulo.value);

if((categoria.value != 0) && (subcategoria.value != 0) && (url.value != '') && (titulo.value != ''))
	document.forms[0].submit();

else{
alert('debe rellenar todos los campos');
	return false;
}
}


function htmlEncode(source, display, tabs)
{
	function special(source)
	{
		var result = '';
		for (var i = 0; i < source.length; i++)
		{
			var c = source.charAt(i);
			if (c < ' ' || c > '~')
			{
				c = '&#' + c.charCodeAt() + ';';
			}
			result += c;
		}
		return result;
	}
	
	function format(source)
	{
		// Use only integer part of tabs, and default to 4
		tabs = (tabs >= 0) ? Math.floor(tabs) : 4;
		
		// split along line breaks
		var lines = source.split(/\r\n|\r|\n/);
		
		// expand tabs
		for (var i = 0; i < lines.length; i++)
		{
			var line = lines[i];
			var newLine = '';
			for (var p = 0; p < line.length; p++)
			{
				var c = line.charAt(p);
				if (c === '\t')
				{
					var spaces = tabs - (newLine.length % tabs);
					for (var s = 0; s < spaces; s++)
					{
						newLine += ' ';
					}
				}
				else
				{
					newLine += c;
				}
			}
			// If a line starts or ends with a space, it evaporates in html
			// unless it's an nbsp.
			newLine = newLine.replace(/(^ )|( $)/g, '&nbsp;');
			lines[i] = newLine;
		}
		
		// re-join lines
		var result = lines.join('<br />');
		
		// break up contiguous blocks of spaces with non-breaking spaces
		result = result.replace(/  /g, ' &nbsp;');
		
		// tada!
		return result;
	}

	var result = source;
	
	// ampersands (&)
	result = result.replace(/\&/g,'&amp;');

	// less-thans (<)
	result = result.replace(/\</g,'&lt;');

	// greater-thans (>)
	result = result.replace(/\>/g,'&gt;');
	
	if (display)
	{
		// format for display
		result = format(result);
	}
	else
	{
		// Replace quotes if it isn't for display,
		// since it's probably going in an html attribute.
		result = result.replace(new RegExp('"','g'), '&quot;');
	}

	// special characters
	result = special(result);
	
	// tada!
	return result;
}

function convertiracentos(titulo,resumen,contenido){
var a,b,c;
//alert(346543);

document.forms[0].titulo.value = htmlEncode(titulo, 'false', 1);
document.forms[0].resumen.value = htmlEncode(resumen, 'false', 1);
document.forms[0].contenido.value = htmlEncode(contenido, 'false', 1);

//alert(titulo);alert(resumen);

//titulo=a;
//resumen=b;
//contenido=c;
		//document.forms[0].action = 'noticias2.asp?titulo='+titulo+'&resumen='+resumen+'&contenido='+contenido;
		document.forms[0].submit();
        return true;

}

function convertiracentos2(titulo,resumen){
var a,b,c;

document.forms[0].elements[1].value = htmlEncode(titulo, 'false', 1);
document.forms[0].elements[2].value = htmlEncode(resumen, 'false', 1);

//alert(titulo);alert(resumen);alert(contenido);

//titulo=a;
//resumen=b;
//contenido=c;

		//document.forms[0].submit();
        return true;

}

function convertiracentos3(titulo,resumen){
var a,b,c;

document.forms[0].elements[0].value = htmlEncode(titulo, 'false', 1);
document.forms[0].elements[1].value = htmlEncode(resumen, 'false', 1);

//alert(titulo);alert(resumen);alert(contenido);

//titulo=a;
//resumen=b;
//contenido=c;

		//document.forms[0].submit();
        return true;

}

function verificar(nombre_campo){
	//alert(nombre_campo1.value);
	if(nombre_campo.value.replace(/ /g, '') == ''){
		alert("Debe ingresar un nombre de empresa");
		//nombre_campo.focus();
		//nombre_campo.select();
		return false;
	}
	else{
		document.forms[0].action = 'boletin2.asp';
		document.forms[0].submit();
		return true;
	}
}

function confirmarform (){
	alert(123234);
	document.forms[0].action = 'boletin2.asp';
	document.forms[0].submit();
        return false;
}

function limpia(elemento)
{
elemento.value = "";
}

function verifica(elemento,lang)
{
if(elemento.value == "")
	if (lang==2)
		elemento.value = "buscar...";
	else
		elemento.value = "search...";
}

function checkEnter(e){ //e is event object passed from function invocation
var characterCode //literal character code will be stored in this variable

if(e && e.which){ //if which property of event object is supported (NN4)
e = e
characterCode = e.which //character code is contained in NN4's which property
}
else{
e = event
characterCode = e.keyCode //character code is contained in IE's keyCode property
}

if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
//alert('has pulsado enter'); //submit the form
return false
}
else{
return true
}

}