<!--//
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function menu(a){
	document.getElementById("m"+a).style.color = "#000";	
}
function idioma(a){
	document.getElementById("l"+a).style.fontWeight = "bold";	
}
var abierta=new Array();
for(var i=0;i<5;i++){
	abierta[i]=0;	
}
/*function display(a,t){
	for(var i=0;i<t;i++){
		if(i==a){
			if(abierta[i]==0){
				document.getElementById("dp"+i).style.display = "block";
				abierta[i]=1;
			}
			else{
				document.getElementById("dp"+i).style.display = "none";
				abierta[i]=0;	
			}
		}
		else{
			document.getElementById("dp"+i).style.display = "none";
			abierta[i]=0;	
		}
	}
}*/
/*var totalLateral=30;
function menuLateral(a,totalLateral){
	for(var i=0;i<totalLateral;i++){
		if(i==a){
			document.getElementById("md"+i).style.backgroundColor = "#dbdbdb";
		}else{
			document.getElementById("md"+i).style.backgroundColor = "#f6f6f6";	
		}
	}
}*/
function display(a){
	var x=document.getElementsByClassName('display','div');
	//var x=document.getElementsByClassName('display');   no funciona en explorer 6 
	for(var i=0;i<x.length;i++){
		if(i==a){
			if(abierta[i]==0){
				document.getElementById("dp"+i).style.display = "block";
				abierta[i]=1;
			}
			else{
				document.getElementById("dp"+i).style.display = "none";
				abierta[i]=0;	
			}
		}
		else{
			document.getElementById("dp"+i).style.display = "none";
			abierta[i]=0;	
		}
	}
}

function menuLateral(a){
	var x=document.getElementsByName("md");

	for(var i=0;i<x.length;i++){
		if(i==a){
			document.getElementById("md"+i).style.backgroundColor = "#dbdbdb";
		}else{
			document.getElementById("md"+i).style.backgroundColor = "#f6f6f6";	
		}
	}
}	

document.getElementsByClassName = function(cl, sTagName) {
    var retnode = [];
    var myclass = new RegExp('\\b'+cl+'\\b');
    var elem = this.getElementsByTagName((sTagName===""||sTagName===null)?"*":sTagName);
    for (var i = 0; i < elem.length; i++) {
        var classes = elem[i].className;
        if (myclass.test(classes)) retnode.push(elem[i]);
    }
    return retnode;
};

function CambiarIdioma(i) {
	document.getElementById('hdnIdioma').value=i;
	document.getElementById('frmIdioma').submit();
}

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)
}
// 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)){
		try{	
			document.getElementById(id_contenedor).innerHTML=pagina_requerida.responseText;
		}catch(e){			
		}	
	}
	
}

function envioBuscador(idioma){	
	switch(idioma){
		case 2: txt = "You must insert all the date fields."; break;
		default: txt = "No olvide rellenar todos los campos para la búsqueda";
	}
	//dia = document.getElementById("txtDia").value;
	from = document.getElementById("txtFrom").value;
	to = document.getElementById("txtTo").value;
	if (from != "" && to != ""){ 
	//	llamarasincrono('buscador_noticias.asp?tipo=5&p=1&m=0&from='+from+'&to='+to ,'texto');		
		llamarasincrono('contenido_noticias.asp?tipo=5&p=1&m=0&from='+from+'&to='+to ,'texto');
	}else{
		alert(txt);	return false;
	}
}
function resetBuscador(){
	//document.getElementById("txtDia").value  = "";
	document.getElementById("txtFrom").value = "";
	document.getElementById("txtTo").value   = "";
	//llamarasincrono('buscador_noticias.asp?from=&to=','texto');
}
function comprobarFrom(idioma){
	switch(idioma){
		case 2: txt = "Incorrect date format in 'From'. The correct format of 'From' is dd/mm/yyyy"; break;
		default: txt = "El formato de 'Desde' es incorrecto. El correcto es (dd/mm/aaaa)";
	}
	
	if(document.getElementById('txtFrom').value != '') {
		var aux = document.getElementById('txtFrom').value; 
		var reg=new RegExp("^[0-9]{2}[/]{1}[0-9]{2}[/]{1}[0-9]{4}$");
	   
		if(!reg.test(aux)){ alert(txt);return false; }
	}
}
function comprobarTo(idioma){
	switch(idioma){
		case 2: txt = "Incorrect date format. The correct format of 'To' is dd/mm/yyyy"; break;
		default: txt = "El formato de 'Hasta' es incorrecto. El correcto es (dd/mm/aaaa)";
	}
	if(document.getElementById('txtTo').value != '') {
		var aux = document.getElementById('txtTo').value; 
		var reg=new RegExp("^[0-9]{2}[/]{1}[0-9]{2}[/]{1}[0-9]{4}$");
	   
		if(!reg.test(aux)){ alert(txt);return false; }
	}
}
function EnviarFormPrensa(i) {		
	switch(i){
		case "1":
			if (!vacio(document.getElementById('txtNombre').value)){
				alert('Por favor, introduzca un nombre.');
				document.getElementById('txtNombre').focus();
				return false;
			}	
			if (!vacio(document.getElementById('txtMedio').value)) {
				alert('Por favor, introduzca un medio de comunicación.');
				document.getElementById('txtMedio').focus();
				return false;		
			}
			if (!vacio(document.getElementById('txtCargo').value)) {
				alert('Por favor, inserte su cargo.');
				document.getElementById('txtCargo').focus();
				return false;		
			}
			if (isNaN(document.getElementById('txtTelefono').value) || !vacio(document.getElementById('txtTelefono').value)) {
				alert('Por favor, introduzca un telefóno numérico.');
				document.getElementById('txtTelefono').focus();
				return false;		
			}				
			if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById('txtEmail').value)) || !vacio(document.getElementById('txtEmail').value)){
				alert("Por favor, introduzca una dirección de correo electrónico válida.");
				document.getElementById('txtEmail').focus();
				return false;
			}	
			if (!vacio(document.getElementById('txtInformacion').value)){
				alert('Por favor, introduzca el tipo de información que le gustaría recibir.');
				document.getElementById('txtInformacion').focus();
				return false;
			}	
			document.getElementById('accion').value="solicitar";																																									
			document.getElementById('frmPrensa').submit();			
		break;						
		case "2":
			if (!vacio(document.getElementById('txtNombre').value)){
				alert('Please, insert a name.');
				document.getElementById('txtNombre').focus();
				return false;
			}	
			if (!vacio(document.getElementById('txtMedio').value)) {
				alert('Please, insert a media.');
				document.getElementById('txtMedio').focus();
				return false;		
			}
			if (!vacio(document.getElementById('txtCargo').value)) {
				alert('Please, insert your job.');
				document.getElementById('txtCargo').focus();
				return false;		
			}
			if (isNaN(document.getElementById('txtTelefono').value) || !vacio(document.getElementById('txtTelefono').value)) {
				alert('Please, insert a numerical telephone.');
				document.getElementById('txtTelefono').focus();
				return false;		
			}				
			if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById('txtEmail').value)) || !vacio(document.getElementById('txtEmail').value)){
				alert("Please, insert a valid email");
				document.getElementById('txtEmail').focus();
				return false;
			}	
			if (!vacio(document.getElementById('txtInformacion').value)){
				alert('Please, insert the type of information that you would like to receive.');
				document.getElementById('txtInformacion').focus();
				return false;
			}	
			document.getElementById('accion').value="solicitar";																																									
			document.getElementById('frmPrensa').submit();			
		break;																																						
		}
}
function vacio(q) {
	for ( i = 0; i < q.length; i++ ) {
		if ( q.charAt(i) != " " ) {
			return true;
		}
	}
	return false;
}
//-->
