	var ua = navigator.userAgent.toLowerCase();
	function detect(text) {
	   stringposition = ua.indexOf(text) + 1;
	   data = text;
	   return stringposition;
	}


/*--MAQUETACION---------------------------------------------------------------------------------------*/
function ActivarBuscador() {
	document.getElementById('Buscador').style.border = "2px solid #00824a";
	document.getElementById('Buscador').style.padding= "2px";	
	if (document.getElementById('Buscador').value == "Texto a buscar...") {
		document.getElementById('Buscador').value = "";
	}
	document.getElementById('Buscador').style.color = "#000";
	document.getElementById('Buscador').style.color = "#000";
}

function DesactivarBuscador() {
	document.getElementById('Buscador').style.border = "1px solid #939394";
	document.getElementById('Buscador').style.padding= "3px";
	if (document.getElementById('Buscador').value == "") {
		document.getElementById('Buscador').style.color = "#888";
		document.getElementById('Buscador').value = "Texto a buscar...";
	}
}

function ConpruebaBusqueda() {
	if (document.getElementById('Buscador').value == "Texto a buscar...") {
		document.getElementById('Buscador').value ="";
	}	
}


/*---------------------------------------------------------------------*/

/* FUNCION QUE MUESTRA UN CUBREPAGINAS. */
/* ---- Abel Tena - 26 marzo 2009 ---- */

function mostrarFoto(NombreFoto,TextoFoto){
	if (detect('msie')){ 	
		var ScrollDePantalla =  window.document.documentElement.scrollTop;
	}else{
		var ScrollDePantalla =  window.pageYOffset;	
	}	
	document.getElementById('FotoPopUp').src=NombreFoto;
	document.getElementById('FotoPopUp').alt=TextoFoto;
	if (TextoFoto!="") {
		document.getElementById('TextoFotoPopUp').style.display = 'block';
	}
	document.getElementById('TextoFotoPopUp').innerHTML=TextoFoto;
	document.getElementById('Cubrepaginas').style.marginTop=(ScrollDePantalla)+"px";	
	document.getElementById('Cubrepaginas').style.display = 'block';
	
	if (detect('msie')){ 
		document.getElementById('CuerpoPrincipal').scroll = 'no';
		document.getElementById('Cubrepaginas').style.filter= "alpha(opacity=80)";
	}else{	
		document.getElementById('CuerpoPrincipal').style.overflow = 'hidden';
	}	
	
	document.getElementById('PopUpFoto').style.display = 'block';	
	centradoEnPagina();
}

function ocultarCubrepaginas(){
	document.getElementById('FotoPopUp').src="/img/Loader.gif";
	document.getElementById('FotoPopUp').alt="";
	document.getElementById('Cubrepaginas').style.display = 'none';
	document.getElementById('PopUpFoto').style.display = 'none';
	document.getElementById('TextoFotoPopUp').style.display = 'none';
	document.getElementById('EnlaceFoto').style.marginTop= "0px";
	
	if (detect('msie')){ 
		document.getElementById('CuerpoPrincipal').scroll = 'yes';	
	}else{	
		document.getElementById('CuerpoPrincipal').style.overflow = 'auto';
	}
	
}

function centradoEnPagina() {
	setTimeout("CalcularCentradodeFoto()",700);
}


function CalcularCentradodeFoto() {
	var altoImagen = document.getElementById('FotoPopUp').clientHeight;
	if (detect('msie')){ 	
		var altoDePantalla = document.body.clientHeight;
		var altoDePantalla = document.documentElement.clientHeight;
		var ScrollDePantalla =  window.document.documentElement.scrollTop;
	}else{
		var altoDePantalla =  window.innerHeight;	
		var ScrollDePantalla =  window.pageYOffset;	
	}

	if (altoDePantalla-altoImagen>0) {
		var margenImagen = ((altoDePantalla-altoImagen)/2);
	}else{
		var margenImagen = 0;
	}
	var espaciadoSuperior=parseInt(ScrollDePantalla)+parseInt(margenImagen)-20;
	document.getElementById('PopUpFoto').style.marginTop= ""+espaciadoSuperior+"px";
}
















function openwindowActualidad(id){
	window.open('/noticias/popup.php?id='+id,'Imagen','resizable=yes,menubar=no,toolbar=no,scrollbars=yes,width=468,height=300,top=50,left=50');
}

function openwindowExporta(id){
	window.open('/exportarusia/popup.php?id='+id,'Imagen','resizable=yes,menubar=no,toolbar=no,scrollbars=yes,width=468,height=300,top=50,left=50');
}

function openwindowOfertaDem(id){
	window.open('/ofertasydemandas/popup.php?id='+id,'Imagen','resizable=yes,menubar=no,toolbar=no,scrollbars=yes,width=468,height=300,top=50,left=50');
}

/*--VALIDACION---------------------------------------------------------------------------------------*/		
function parseToEntero(valor){
	if(valor.length>0){
		if(valor!=0){
		  valor = parseInt(valor);
		  if (isNaN(valor)) {
			return 0;
		  }
		}		
	}else{
		valor = 0;
	}

	return valor;
}

function VerificarMail(strMail) {
//La siguiente funcion da error si se introduce algo.usuario@dominio.es
	var patMail = /^(.+)@(.+)$/;
	var patUser = /^[a-zA-Z\d_-]+(\.[a-zA-Z\d_-]+)*$/;
	var patDomainIP = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;
	var patDomain = /^[a-zA-Z\d_-]+(\.[a-zA-Z\d_-]+)+$/;
	var matchArray = strMail.match(patMail);
	if(matchArray == null){return false;}
	var user = new String(matchArray[1]);
	var domain = new String(matchArray[2]); 
	if(user.match(patUser) == null){return false;}
	var IPArray = domain.match(patDomainIP);
	if(IPArray != null){ 
		 for (var i=1;i<=4;i++) {
		  if(IPArray[i]>255){return false;}
		 }
		 return true; 
	}
	var domainArray = domain.match(patDomain);
	if(domainArray == null) {return false;}
	if(domainArray[domainArray.length - 1].length < 3 || domainArray[ domainArray.length - 1].length > 5) { return false;}
	return true;
}

function restrictLetraNum(idElementoPasarFoco){//funcion para onKeypress
	//if (event.keyCode == 13) document.getElementById(idElementoPasarFoco).focus();
	//Sólo numerico
	//if (event.keyCode < 48) event.returnValue = false;
	//if (event.keyCode > 57 && event.keyCode < 65) event.returnValue = false;
	//if (event.keyCode > 90 && event.keyCode < 97) event.returnValue = false;
	//if (event.keyCode > 122) event.returnValue = false;
}

function dateToIngles(strFecha){
	//Esta funcion cambia el formato dd/mm/yyyy por yyyy/mm/dd
	//Es util para comparar fechas como cadenas (para ver cual es mayor o menor)
	var arrayFecha = strFecha.split("/");
	var dia =  arrayFecha[0];
	var mes =  arrayFecha[1];
	var anio =  arrayFecha[2];
	return anio + "/" + mes + "/" + dia;
}



function MostrarSubmenu(IdMenu) {

}

function OcultarSubmenu(IdMenu) {

}

function ActivarPestanna(IdMenu) {
	document.getElementById(IdMenu).className='Activo';
}

var tamanoAncho=2;
var tamanoAlto=2;
var TamanoFuente=1;

function AumentarFuente() {
	if (TamanoFuente<1.2) {
		TamanoFuente=TamanoFuente+0.1;
		document.getElementById('Pagina').style.fontSize=TamanoFuente+"em";
	}
}

function ReducirFuente() {
	if (TamanoFuente>1) {
		TamanoFuente=TamanoFuente-0.1;
		document.getElementById('Pagina').style.fontSize=TamanoFuente+"em";
	}
}

function charactermax(id,idreturn){
	var longit = document.getElementById(id).value.length;
	if(!longit) {longit = '0';}
	document.getElementById(idreturn).innerHTML = longit;

	if (longit>2500) {
		document.getElementById('Contador').style.color= '#990000';
		document.getElementById('Contador').style.fontWeight= 'bold';
	}else{
		if (longit>2200 && longit<2500) {
			document.getElementById('Contador').style.color= '#ff6000';
		}else{
			document.getElementById('Contador').style.color= '#999999';
		}
		document.getElementById('Contador').style.fontWeight= 'normal';
	}
}


function CorregirFormulario(elemento,Variable) {
	if (document.getElementById(elemento).value==Variable) {
		document.getElementById(elemento).value="";
	}
}

/* EFECTO BUSCADOR */

function ActivarBuscador() {
	document.getElementById('Buscador').style.border = "2px solid #00a7ed";
	document.getElementById('Buscador').style.padding= "2px";	
	if (document.getElementById('Buscador').value == "Texto a buscar...") {
		document.getElementById('Buscador').value = "";
	}
	document.getElementById('Buscador').style.color = "#000";
	document.getElementById('Buscador').style.color = "#000";
}

function DesactivarBuscador() {
	document.getElementById('Buscador').style.border = "1px solid #939394";
	document.getElementById('Buscador').style.padding= "3px";
	if (document.getElementById('Buscador').value == "") {
		document.getElementById('Buscador').style.color = "#888";
		document.getElementById('Buscador').value = "Texto a buscar...";
	}
}

function ConpruebaBusqueda() {
	if (document.getElementById('Buscador').value == "Texto a buscar...") {
		document.getElementById('Buscador').value ="";
	}	
}