/////////////// ANCHORS ANIMADOS//////////////////
	var scrollInt;
	var scrTime, scrSt, scrDist, scrDur, scrInt;
	
	
	function replaceAnchorLinks()
	{
		
		var anchors, i, targ, targarr;
	
		if (!document.getElementById)
			return;
		
		// get all anchors
		anchors = document.getElementsByTagName("a");
		
		for (i=0;i<anchors.length;i++)
		{
			// check if href links to an anchor on this page
			if ( (anchors[i].href.indexOf("#")!=-1 && anchors[i].href.indexOf( document.URL )!=-1) && (anchors[i].href.indexOf("#") == 0 || anchors[i].href.indexOf( document.URL ) == 0) && anchors[i].className!="anclano" && anchors[i].href.indexOf("perfil_contratante")==-1)
			{
				
				// get name of target anchor
				targ = anchors[i].href.substring( anchors[i].href.indexOf("#")+1 );
				// find target anchor
				if(targ!=""){
					targarr = $( targ );
						//anchors[i].className = (targarr[0].offsetTop < anchors[i].offsetTop) ? "up" : "down";
						
						anchors[i].id = "__" + targ;	// save target as id with prefix (used in onclick function below)
						anchors[i].onmousedown = function () { scrollToAnchor( this.id.substring( 2 ) ); return false; };
						//anchors[i].href = "#";			// rewrite href
				}
			}
			
		}
	}
	
	
	/*
	SCROLL FUNCTIONS
	*/
	
	
	
	
	function scrollPage()
	{
		scrTime += scrInt;
		if (scrTime < scrDur) {
			window.scrollTo( 0, easeInOut(scrTime,scrSt,scrDist,scrDur) );
		}else{
			window.scrollTo( 0, scrSt+scrDist );
			clearInterval(scrollInt);
		}
	}
	
	function scrollToAnchor(aname)
	{
		var anchors, i, ele;
	
		if (!document.getElementById)
			return;
		
		// get anchor
		ele=$(aname);

		
		// set scroll target
		if (window.scrollY)
			scrSt = window.scrollY;
		else if (document.documentElement.scrollTop)
			scrSt = document.documentElement.scrollTop;	
		else
			scrSt = document.body.scrollTop;
		if(aname!="cont")
			scrDist = ele.offsetTop - scrSt + 162;
		else
			scrDist = ele.offsetTop - scrSt;
		scrDur = 500;
		scrTime = 0;
		scrInt = 10;
		
		// set interval
		clearInterval(scrollInt);
		scrollInt = setInterval( scrollPage, scrInt );
	}
	
	
	
	
	/*
	EASING FUNCTIONS
	*/
	
	function easeInOut(t,b,c,d)
	{
		return c/2 * (1 - Math.cos(Math.PI*t/d)) + b;
	}




///////////////////////////////////////MENU/////////////////////////////////////////////////////

//Variables a configurar:
var colores={
		menunosotros: "#3d9114",
		menuactualidad: "#076abb",
		menuactividades_y_proyectos: "#ea4a12",
		menuseguridad_y_medioambiente: "#84a21e",
		menupublicaciones_y_audiovisuales: "#624181",
		esinseleccionar:"#3C3E0D",
		eseleccionado:"#fff",
		transparente:"transparent"
};
//Retardo (milesimas seg)
var retardo=400;
//Posiciones  Y que hace que salgamos del menú
var arribaY=65;
var abajoY=125;

//Fin variables a configurar.


//Ver donde está el ratón
var IE = document.all?true:false
if (!IE) document.captureEvents(Event.MOUSEMOVE)

document.onmousemove = posicratonxy;
var posicX = 0;
var posicY = 0;

function posicratonxy(e) {
if (IE) { posicX = event.clientX + document.body.scrollLeft;
posicY = event.clientY + document.body.scrollTop}
else { posicX = e.pageX; posicY = e.pageY };
if (posicX < 0) {posicX = 0};
if (posicY < 0) {posicY = 0};
return true;
} 

//Hack para añadir evento onmouseover y onmouseout a Firefox
var xb =
{	evtHash: [],
	ieGetUniqueID: function(_elem)
	{
		if (_elem === window) { return 'theWindow'; }
		else if (_elem === document) { return 'theDocument'; }
		else { return _elem.uniqueID; }
	},
	addEvent: function(_elem, _evtName, _fn, _useCapture)
	{
		if (typeof _elem.addEventListener != 'undefined')
		{
			if (_evtName == 'mouseenter')
				{ _elem.addEventListener('mouseover', xb.mouseEnter(_fn), _useCapture); }
			else if (_evtName == 'mouseleave')
				{ _elem.addEventListener('mouseout', xb.mouseEnter(_fn), _useCapture); } 
			else
				{ _elem.addEventListener(_evtName, _fn, _useCapture); }
		}
		else if (typeof _elem.attachEvent != 'undefined')
		{
			var key = '{FNKEY::obj_' + xb.ieGetUniqueID(_elem) + '::evt_' + _evtName + '::fn_' + _fn + '}';
			var f = xb.evtHash[key];
			if (typeof f != 'undefined')
				{ return; }
			
			f = function()
			{
				_fn.call(_elem);
			};
		
			xb.evtHash[key] = f;
			_elem.attachEvent('on' + _evtName, f);
	
			window.attachEvent('onunload', function()
			{
				_elem.detachEvent('on' + _evtName, f);
			});
		
			key = null;
		}
		else
			{ _elem['on' + _evtName] = _fn; }
	},	
	removeEvent: function(_elem, _evtName, _fn, _useCapture)
	{
		if (typeof _elem.removeEventListener != 'undefined')
			{ _elem.removeEventListener(_evtName, _fn, _useCapture); }
		else if (typeof _elem.detachEvent != 'undefined')
		{
			var key = '{FNKEY::obj_' + xb.ieGetUniqueID(_elem) + '::evt' + _evtName + '::fn_' + _fn + '}';
			var f = xb.evtHash[key];
			if (typeof f != 'undefined')
			{
				_elem.detachEvent('on' + _evtName, f);
				delete xb.evtHash[key];
			}
		
			key = null;
		}
	},	
	mouseEnter: function(_pFn)
	{
		return function(_evt)
		{
			var relTarget = _evt.relatedTarget;				
			if (this == relTarget || xb.isAChildOf(this, relTarget))
				{ return; }

			_pFn.call(this, _evt);
		}
	},	
	isAChildOf: function(_parent, _child)
	{
		if (_parent == _child) { return false };
		
		while (_child && _child != _parent)
			{ _child = _child.parentNode; }
		
		return _child == _parent;
	}	
};


//Array para saber cuales están seleccionados
var seleccionado=new Array();

//Cambia el estilo del enlace de seccion dependiendo de si está seleccionado o no
function secselec(que,como){
	if(como==1){
		color="eseleccionado";
		colorf=que;
	}
	else{
		color="esinseleccionar";
		colorf="transparente";
	}	
	var elementos=$(que.substring(4)).getElementsByClassName("main");
	$(que.substring(4)).style.backgroundColor=colores[colorf];
	elementos[0].style.color=colores[color];	
}

//Llamada definitiva a ocultar comprobando que ya no esté seleccionada la sección
function ocultar2(que){
	if(seleccionado[que]==0 ){
			$(que).style.zIndex=1;
			secselec(que,0);	
			$(que).style.display="none";				
			seleccionado[que]=500;
	}
 }

//Primera llamada a ocultar, comprueba por donde se sale y se da un retardo de X tiempo para poder acceder a una subseccion 
function ocultarefecto(que){
		var maxzindex=1;
		var enlacesmenu=$$('li.roll');
		var enlacehrf=new Array();
		for(var i=0; i<enlacesmenu.length; i++){
				enlacemenu=enlacesmenu[i];
				if($("menu"+enlacemenu.id).style.zIndex>maxzindex){
					actual=enlacemenu.id;
					maxzindex=$("menu"+enlacemenu.id).style.zIndex;
				}
		}	
		seleccionado[que]=0;
		if(posicY<arribaY || posicY>abajoY || "menu"+actual!=que){
			secselec(que,0);
			ocultar2(que);
		}
		else{
			setTimeout("ocultar2('"+que+"');",retardo);
		}
}

function copiar_portapapeles(que){
   window.clipboardData.setData("Text", que);
}

function genera_url(desde,para){
	var sinconvertir = new Array('Á','É','Í','Ó','Ñ','Ú','á','é','í','ó','ú','.',' ',',','ñ','ç',':',';','/','?','¿','ü','Ü','"','\'');
    var convertir = new Array('A','E','I','O','N','U','a','e','i','o','u','_','_','_','n','c','_','_','_','_','_','u','U','_','_');
	var texto=$(desde).value.toLowerCase();
	if($(para).value==""){
		for(i=0; i<sinconvertir.length; i++){
			texto=replaceAll(texto,sinconvertir[i],convertir[i]);
		}
		$(para).value=texto;
	}
}

function replaceAll( text, busca, reemplaza ){
   while (text.toString().indexOf(busca) != -1){
       text = text.toString().replace(busca,reemplaza);
   }
   return text;
}
//Llamada para mostrar, se controla si hay alguna seleccionada actualmente en cuyo caso la nueva seleccionada queda en un segundo plano a la espera de que esta desaparezca
function mostrarefecto(que){
	var alguno=0;
	var zind=99;
	for(var v in seleccionado){
		if(seleccionado[v]==0){
			alguno++;
			zind=$(v).style.zIndex;
		}	
	}
	if(alguno==0){
		seleccionado[que]=500;
		if($(que).style.display=="none"){
			mostrarblock(que);
			$(que).style.zIndex=zind;
		}	
	}
	else{
		if($(que).style.display=="block"){
			seleccionado[que]=500;
		}	
		else{
			seleccionado[que]=500;
			mostrarblock(que);
			$(que).style.zIndex=zind-1+(alguno-1);
			secselec(que,1);	
		}
	}
	var maxzindex=1;
	var enlacesmenu=$$('li.roll');
	var enlacehrf=new Array();
	for(var i=0; i<enlacesmenu.length; i++){
			enlacemenu=enlacesmenu[i];
			if($("menu"+enlacemenu.id).style.zIndex>maxzindex){
				actual=enlacemenu.id;
				maxzindex=$("menu"+enlacemenu.id).style.zIndex;
			}
	}	
	secselec("menu"+actual,1);	
}

//Inicialización de los elementos del menú
function cambiaonmouse(enlace,onmouse){
	ocultar("menu"+onmouse);
	xb.addEvent(enlace,'mouseenter', function() { mostrarefecto("menu"+onmouse); },false);
	xb.addEvent($("menu"+onmouse),'mouseenter', function(){seleccionado["menu"+onmouse]=500;} ,false);
	xb.addEvent(enlace,'mouseleave', function() { ocultarefecto("menu"+onmouse); },false);
}

///////////////////////////////////////FIN MENU/////////////////////////////////////////////////////

//Elimina archivos de contratos con AJAX
function dropfile(codigo,id,eldiv){
	new Ajax.Updater(eldiv,path+"contratos/borrarfile/"+codigo+"/"+id, {asynchronous:true, evalScripts:true, onLoading:function(request){$(eldiv).update("<p>Espere unos segundos, el archivo se está eliminando...</p>");}, onComplete:function(request){ $(eldiv).style.display="none";}, requestHeaders:['X-Update', eldiv]});
 }
 

//TRAE TODAS LAS SUBSECCIONES PARA EL EDITOR
function traesubsecciones(direccion){
	new Ajax.Updater('Subseccion',direccion+"/"+$('Seccion').value, {asynchronous:true, evalScripts:true, onComplete:function(request){ $('Subseccion').disabled=false;}, requestHeaders:['X-Update', 'Subseccion']});
 }
 
 //MOSTRAR Y OCULTAR DIV COMPARTIR
 function compartir(){
	if($('compartir').style.display!="inline")
		$('compartir').style.display="inline";
	else
		$('compartir').style.display="none";
 }

 //MOSTRAR ELEMENTOS OCULTOS
  function mostrar(que){
	$(que).style.display="inline";
 }
   function mostrarblock(que){
	$(que).style.display="block";
 }
 //OCULTAR ELEMENTOS
  function ocultar(que){
	$(que).style.display="none";
 }

 //CAMBIAR METODO DEL FORMULARIO
 function formularioch(id,publicar){
	$('form'+id).action=path+"preguntas/guardar/"+id+"/"+publicar;
	$('form'+id).submit();
 }
 //VOTAR, SE EJECUTA CON AJAX LA FUNCION PARA VOTAR Y SE OBTIENE EL RESULTADO IMPRIMIENDOSE EN LUGAR DE LOS VOTOS, SE OCULTAN LOS DIVS PARA VOTAR Y SE ELIMINAN LOS ENLACES
 function votando(enlace){
	new Ajax.Request( enlace , {method: 'get',
	onSuccess: function(transport) {
		var gracias="¡Gracias por votar!";
		if($('envot').className=="english")
			var gracias="Thanks for vote!";
		$('numvotos').update(transport.responseText);
		if($("numvotos2"))
			$('numvotos2').update(transport.responseText);
		$('voteres').style.display="none";
		if($("voteres2"))
			$('voteres2').style.display="none";
		$('votar').update("<span>"+gracias+"</span>");
		$('svot').update(gracias);
	}
	});
 }
var swfu = new Array();
//PREGUNTAR SI SE DESEA BORRAR
function aceptarborrar(){
	return confirm('Estas seguro de que deseas eliminar este contenido?');
}
function contratodesierto(){
	return confirm('Estas seguro de que deseas declarar desierta esta licitación');
}
//GOOGLE MAPS
function objetoMap(){
	this.mapa;
	this.tipov;
	this.centro;
	this.nuevolistener=nuevolistener;
}
function nuevolistener(html,centro1){
	GEvent.addListener(centro1, "click", function() {	
						centro1.openInfoWindowHtml(html);
					});
}
function objetotr(){
	this.fila;
	this.columnas;
	this.htmlor;
	this.activo=0;
	this.sobre=spami;
	//this.ocultacabecera=ocultacabecera;
	//this.columna.onmouseover=function(){alert(filas[i].columna);};
	//this.alerta=spam(fila.cells[2].title);
}

function queEs(){
	if($('tipo').value=="Estudiante"){
		ocultar("profesional");
		mostrarblock("estudiante");
	}
	else if($('tipo').value=="Profesional"){
		ocultar("estudiante");
		mostrarblock("profesional");
	}
	else{
		ocultar("estudiante");
		ocultar("profesional");
	}
	return false;
}
function spami(lafila){
	
	lafila.fila.onmouseover=function(){
			
			if(lafila.activo==0){
				
				if(ultimobj.fila)
					ocultacabecera(ultimobj);

				for(var n=0; n<lafila.columnas.length; n++){
					lafila.columnas[n].className="ptn";
					lafila.columnas[n].innerHTML="<span>"+lafila.columnas[n].title+"</span>"+lafila.columnas[n].innerHTML;
				}
				lafila.activo=1;
				ultimobj=lafila;
			}
			
	}
	
}	

function ocultacabecera(lafila){
		//lafila.fila.update(lafila.htmlor);
		for(var n=0; n<lafila.columnas.length; n++){
			//alert(lafila.htmlor);
			lafila.columnas[n].innerHTML=lafila.columnas[n].innerHTML.substring((lafila.columnas[n].innerHTML.toLowerCase().indexOf("</span>")+7));
			lafila.columnas[n].className="";
		}
		
		lafila.activo=0;
			
}
function var_dump(obj) {
   if(typeof obj == "object") {
      return "Type: "+typeof(obj)+((obj.constructor) ? "\nConstructor: "+obj.constructor : "")+"\nValue: " + obj;
   } else {
      return "Type: "+typeof(obj)+"\nValue: "+obj;
   }
}
function desactright(e){
return true;
}
function desactivaright(){
	$("enresalogo").oncontextmenu=desactright;
	document.cookie = 'elright=desactiva; '+document.cookie;
	$("menucontextual").style.display="none";
	return false;
}
function right(e) { 
	$("menucontextual").style.display="block";
	$("menucontextual").style.top=posicY+"px";
	$("menucontextual").style.left=posicX+"px";
	return false;
	
}
document.onclick = function (e) {
 e = e || event
 var target = e.target || e.srcElement
 var elemento = document.getElementById('menucontextual');
 do {
  if (elemento == target) {
   // El click se ha producido dentro del elemento, no se hace nada.
   return;
  }
  target = target.parentNode;
 } while (target)
 // Se ha clicado fuera del elemento, se realiza una acción.
 elemento.style.display = 'none';
}
function entrada(hacer,que){
		nohacer="block";
		claseno="";
		if(hacer=="block"){
			nohacer="none";
			claseno="Off";
		}
		$(que).style.display=hacer;
		$("a"+que).href="javascript:entrada('"+nohacer+"','"+que+"');";
		$("a"+que).className=claseno;	
}
//SE SOBRE-ESCRIBEN LOS ENLACES CON JAVASCRIPT EN CASO DE QUE EXISTAN
function enlacesjv(){
		if($("enresalogo")){
			//InitContext();
			if(document.cookie.indexOf('elright=desactiva')==-1){
				$("enresalogo").oncontextmenu=right;
				//document.onclick=ocultarmen("menucontextual");
			}
		}
		if($('miercoles')){
			muestradia("viernes");

			
			var dias=$$("a.enlacesemana");
			for(var i=0; i<dias.length; i++){
					diasem=dias[i].id.replace("enl","");
					dias[i].href="javascript:muestradia('"+diasem+"');";
			}
			
			var textos=$$("p.txt");
			for(var i=0; i<textos.length; i++){
					textos[i].style.display="none";
					$("a"+textos[i].id).href="javascript:entrada('block','"+textos[i].id+"');";
			}		
		}
		if($('tabcontratos')){
			var filas=new Array();
			ultimobj=new objetotr();
			for (var i=1; i<$("tabcontratos").rows.length; i++) {
				filas[i]=new objetotr();
				filas[i].fila=$("tabcontratos").rows[i];
				filas[i].columnas=filas[i].fila.cells;
				filas[i].htmlor=filas[i].fila.innerHTML;
				filas[i].sobre(filas[i]);
			}
		}encodeURIComponent(document.title.replace(/ /g,"+"))
		
		if($('encomp')){
			$('compartir').innerHTML='<a href="https://twitter.com/intent/tweet?text='+document.title+'&amp;url='+location.href+'&amp;hashtags=enresa"><img src="'+path+'img/share6.gif" alt="Twitter" /></a><a href="http://meneame.net/submit.php?url='+location.href+'&ei=UTF"><img src="'+path+'img/share1.gif" alt="Meneame" /></a>\n<a href="http://del.icio.us/post?v=4&noui&jump=close&url='+location.href+'&title='+encodeURIComponent(document.title.replace(/ /g,"+"))+'"><img src="'+path+'img/share2.gif" alt="del.icio.us" /></a>\n<a href="http://tec.fresqui.com/post?url='+location.href+'&title='+encodeURIComponent(document.title.replace(/ /g,"+"))+'"><img src="'+path+'img/share3.gif" alt="Fresqui" /></a>\n<a href="http://www.facebook.com/share.php?u='+location.href+'"><img src="'+path+'img/share4.gif" alt="Facebook" /></a>\n<a href="http://digg.com/submit?url='+location.href+'"><img src="'+path+'img/share5.gif" alt="Digg" /></a>\n';
			$('encomp').href="javascript:compartir();";
		}
		/*if($('archivo1')){
				swfu[swfu.length]=inicio("archivo1","spanButtonPlaceholder1","fsUploadProgress1","hidFileID1");
				if($('formcontratos1'))
					formulariosw='formcontratos1';
				else
					formulariosw='formcontratos';
		}*/	
		if($('eresq')){
			if($('tipo').value!="Profesional")
				ocultar("profesional");
			if($('tipo').value!="Estudiante")	
				ocultar("estudiante");			
			$('eresq').className="row";
			$('tipo').onchange=queEs;
		}
		if($('envot')){
			var paraenlaces= tipo+"/"+$('envot').href.substr($('envot').href.indexOf("votos/pagina/")+13);
			var arrayenlaces=paraenlaces.split("/");
			var enlacesdef="";
			for(i=0;i<3;i++){
				if(arrayenlaces[i]=="blog")
					arrayenlaces[i]="post";
				enlacesdef+=arrayenlaces[i]+"/";
			}
			if($('envot').className=="english"){
				var htmlvotos="<div>\n<h3>Vote for this content</h3><p>If you have found this content interesting, please select your profile to vote for it:</p>\n<a href=\""+path+"votos/vota/"+enlacesdef+"investigador\">Student or research worker</a>\n<a href=\""+path+"votos/vota/"+enlacesdef+"profesional\">Professional working in the sector</a>\n<a href=\""+path+"votos/vota/"+enlacesdef+"periodista\">Professional working for the media</a>\n<a href=\""+path+"votos/vota/"+enlacesdef+"otro\">None of the above</a>\n";
				$("voteres").innerHTML=htmlvotos+"<p><a href='#voteres' class='cancela'>Cancel</a></p></div>";
				if($("voteres2"))
					$("voteres2").innerHTML=htmlvotos+"<p><a href='#voteres2' class='cancela'>Cancel</a></p></div>";			
			}
			else{
				var htmlvotos="<div>\n<h3>Votar este contenido</h3><p>Si este contenido te ha parecido interesante selecciona tu perfil para votarlo:</p>\n<a href=\""+path+"votos/vota/"+enlacesdef+"investigador\">Un estudiante o investigador</a>\n<a href=\""+path+"votos/vota/"+enlacesdef+"profesional\">Un profesional del sector</a>\n<a href=\""+path+"votos/vota/"+enlacesdef+"periodista\">Un profesional de los medios de comunicación</a>\n<a href=\""+path+"votos/vota/"+enlacesdef+"otro\">Ninguno de los anteriores</a>\n";
				$("voteres").innerHTML=htmlvotos+"<p><a href='#voteres' class='cancela'>Cancelar</a></p></div>";
				if($("voteres2"))
					$("voteres2").innerHTML=htmlvotos+"<p><a href='#voteres2' class='cancela'>Cancelar</a></p></div>";
			}
			 $('envot').href="javascript:mostrar('voteres');";
			 if($("envot2"))
				$('envot2').href="javascript:mostrar('voteres2');";
			 //Enlaces dentro del div de votos
			 enlaces1=$$('#voteres a');
			 enlaces2=$$('#voteres2 a');
			 enlaces=enlaces1.concat(enlaces2);
			 for (var i = 0; i < enlaces.size(); i++) {
				if(enlaces[i].className=="cancela")
					enlaces[i].href="javascript:ocultar('"+enlaces[i].href.substr(enlaces[i].href.indexOf("#")+1)+"')";
				else
					enlaces[i].href="javascript:votando('"+enlaces[i].href+"')";
			 }
		}

		if($('bpreguntas')){
			laspreguntas=$$('div.respuestares');
			var cadena=document.location.search;
			cadena=cadena.substring(1,cadena.length);
			var parametros=cadena.split("&"); 
			for (var i = 0; i < laspreguntas.size(); i++) {
				if (i>1 || (parametros[0]!="pag=1" && parametros[0]!="")){
					laspreguntas[i].style.display="none";
					ehtml='<span id="en'+laspreguntas[i].id+'"><a href="#" onClick="mostrarpreg(\''+laspreguntas[i].id+'\'); return false;" alt="mostrar respuesta" ><img src="'+path+'img/mas.gif" alt="mas" align="absmiddle" /></a></span>&nbsp;&nbsp;'+$(laspreguntas[i].id.replace("larespuesta","pregunta")).innerHTML;
					$(laspreguntas[i].id.replace("larespuesta","pregunta")).innerHTML=ehtml;
				}
				else{
					ehtml='<span id="en'+laspreguntas[i].id+'"><a href="#" onClick="ocultarpreg(\''+laspreguntas[i].id+'\'); return false;" alt="ocultar respuesta" ><img src="'+path+'img/menos.gif" alt="menos" align="absmiddle" /></a></span>&nbsp;&nbsp;'+$(laspreguntas[i].id.replace("larespuesta","pregunta")).innerHTML;
					$(laspreguntas[i].id.replace("larespuesta","pregunta")).innerHTML=ehtml;
				}
			 }
		}
		var enlacesmenu=$$('li.roll');
		var enlacehrf=new Array();
		for(var i=0; i<enlacesmenu.length; i++){
			var enlacemenu=enlacesmenu[i];
			enlacehrf=enlacemenu.id;
			seleccionado["menu"+enlacehrf]=500;
			cambiaonmouse(enlacemenu,enlacehrf);
		}
		replaceAnchorLinks();
	  //google maps
	  var anchors = $$('div.mapaG');
	  if(anchors.length>0){
		  if (GBrowserIsCompatible()) {
		
	//posiciones
			var map= new Array();
			var elcabrilpos=new GLatLng(38.087207,-5.424811);
				var velcabrilpos=new GLatLng(38.085257,-5.419092);
				var vandellospos=new GLatLng(40.955048,0.874615);
				var vvandellospos=new GLatLng(40.954705,0.875843);
				var zoritapos=new GLatLng(40.347722,-2.885542);
				var sedepos=new GLatLng(40.448255,-3.654443);
				var mundipos=new GLatLng(60.413852,69.257813);
				var santamariapos=new GLatLng(42.774381,-3.206506);
				var almarazpos=new GLatLng(39.810085,-5.694823);
				var vandellos2pos=new GLatLng(40.950684,0.865796);
				var ascopos=new GLatLng(41.199904,0.569444);
				var cofrentespos=new GLatLng(39.216661,-1.05001);
				var trillopos=new GLatLng(40.700276,-2.624295);
				var espanapos=new GLatLng(40.396764,-3.713379);
				var ahaupos=new GLatLng(52.076763,7.003269);
				var gorlebenpos=new GLatLng(53.048231,11.359348);
				var desselpos=new GLatLng(51.239781,5.112762);
				var mayakpos=new GLatLng(54.697522,83.136764);
				var krasnopos=new GLatLng(56.001597,92.885628);
				var lahayapos=new GLatLng(49.677737,-1.873727);
				var cascadpos=new GLatLng(43.698162,5.735335);
				var rokkapos=new GLatLng(40.971085,141.357651);
				var sellapos=new GLatLng(54.420328,-3.497429);
				var clabpos=new GLatLng(57.415193,16.671066);
				var habogpos=new GLatLng(51.458419,3.705268);
				var zwilagpos=new GLatLng(47.551434,8.22818);
				var cordobapos=new GLatLng(37.886531,-4.788376);
				var html=new Array('',
'<div>Instalación Vandellós I<p>Centro Tecnológico Mestral<br/>Ctra. N-340, Km 1123,7<br/>43890 L\'Hospitalet de L\'Infant (Tarragona)<br/>Tlf: 977 818 500<br/>Fax : 977 818 527</p></div>',
'<div>Almacén centralizado de RBMA El Cabril<p>Carretera A- 447 dirección Fuenteobejuna- Cazalla de la Sierra Km 17, 8<br/>14740 Hornachuelos (Córdoba)<br/>Tlf: 957 57 51 00<br/>Fax: 957 57 51 30</p></div>',
'<div>Central nuclear José Cabrera<p><b>Localización</b>19118, Almonacid de Zorita, Guadalajara<br /><b>Propietarios:</b> Unión Fenosa  100%<br /><b>Inicio Operación:</b> 1968<br /><b>Potencia Eléctrica:</b> 150,1MW</p></div>',
'<div>Madrid. Sede social<p>C/ Emilio Vargas, 7<br/>28043 Madrid<br/>Tlf: 915 66 81 00<br/>Fax: 915 66 81 69</p></div>',
'',
'<div>Central nuclear Santamaría de Garoña<p><b>Localización:</b> 09212 Sta. María de Garoña (Burgos)<br/><b>Propietarios:</b> Nuclenor* 100%<br /><b>Inicio Operación:</b> 1971<br /><b>Potencia Eléctrica:</b> 466MW</p><p><i>* Nuclenor se encuentra participada por Endesa (50%) e Iberdrola (50%)</i></p></div>',
'<div>Central nuclear Almaraz I y Almaraz II<p><b>Localización: </b> 10300 Navalmoral de la Mata (Cáceres)<br /><b>Propietarios:</b> Iberdrola 53%, Endesa 36% y Unión Fenosa 11% <br /><b>Inicio Operación:</b> 1981 (I) y 1983 (II)<br /><b>Potencia Eléctrica:</b> 977MW(I) y 980MW(II)</p></div>',
'<div>Central nuclear Ascó I y Ascó II<p><b>Localización:</b> 43791 Ascó (Tarragona)<br/><b>Propietarios:</b><br/>Ascó I: Endesa 100%<br />Ascó II: Endesa 85% e Iberdrola 15%<br /><b>Inicio Operación:</b> 1984 (I) y 1986(II)<br /><b>Potencia Eléctrica:</b> 1.032MW(I) y 1.027MW(II)</p></div>',
'<div>Central nuclear Cofrentes<p><b>Localización:</b> 46625 Cofrentes (Valencia)<br/><b>Propietarios:</b> Iberdrola 100%<br /><b>Inicio Operación:</b> 1985<br /><b>Potencia Eléctrica:</b> 1.092MW</p></div>',
'<div>Central nuclear Vandellós II<p><b>Localización:</b> 43890 Hospitalet de l\'Infant (Tarragona)<br /><b>Propietarios:</b> Endesa 72% y Iberdrola 28%<br /><b>Inicio Operación:</b> 1985<br /><b>Potencia Eléctrica:</b> 1.087 MW</p></div>',
'<div>Central nuclear Trillo<p><b>Localización:</b> 19450 Trillo (Guadalajara)<br /><b>Propietarios:</b><br/>Unión Fenosa 34,5%, Iberdrola 48%, Hidrocantábrico 15,5% y Nuclenor* 2% <br /><b>Inicio Operación:</b> 1988<br /><b>Potencia Eléctrica:</b> 1.066MW</p><p><i>* Nuclenor se encuentra participada por Endesa (50%) e Iberdrola (50%)</i></p></div>',
'',
'<div>Ahaus<p><b>País:</b> Alemania<br /><b>Tecnología:</b> Contenedores metálicos<br /><b>Material almacenado:</b> Combustible gastado</div>',
'<div>Gorleben<p><b>País:</b> Alemania<br /><b>Tecnología:</b> Contenedores metálicos<br /><b>Material almacenado:</b> Combustible gastado y vidrios</div>',
'<div>Dessel<p><b>País:</b> Bélgica<br /><b>Tecnología:</b> CBóveda<br /><b>Material almacenado:</b> Vidrios</div>',
'<div>Mayak<p><b>País:</b> Federación Rusa<br /><b>Tecnología:</b> Piscina<br /><b>Material almacenado:</b> Combustible gastado</div>',
'<div>Krasnoyarsk<p><b>País:</b> Federación Rus<br /><b>Tecnología:</b> Piscina<br /><b>Material almacenado:</b> Combustible gastado</div>',
'<div>La Hague<p><b>País:</b> Francia<br /><b>Tecnología:</b> Dos instalaciones: Piscina y Bóveda<br /><b>Material almacenado:</b> Combustible gastado y vidrios</div>',
'<div>Cascad<p><b>País:</b> Francia<br /><b>Tecnología:</b> Bóveda<br /><b>Material almacenado:</b> Vidrios</div>',
'<div>Rokkasho<p><b>País:</b> Japón<br /><b>Tecnología:</b> Dos instalaciones: Piscina y Bóveda<br /><b>Material almacenado:</b> Combustible gastado y vidrios</div>',
'<div>Sellafield<p><b>País:</b> Reino Unido<br /><b>Tecnología:</b> Dos instalaciones: Piscinas<br /><b>Material almacenado:</b> Combustible gastado y vidrios</div>',
'<div>Clab<p><b>País:</b> Suecia<br /><b>Tecnología:</b> Piscina<br /><b>Material almacenado:</b> Combustible gastado</div>',
'<div>Central Nuclear José Cabrera<p>Almonacid de Zorita<br />19118 Guadalajara</p></div>',
'<div>Zwilag<p><b>País:</b> Suiza<br /><b>Tecnología:</b> Contenedores metálicos<br /><b>Material almacenado:</b> Combustible gastado y vidrios</div>',
'<div>Delegación Córdoba<p>C/ Le Corbusier, s/n<br />14005 Córdoba<br />Tlf: 957 45 01 64<br />Fax: 957 23 43 39</p></div>');
	
		for (var i = 0; i < anchors.length; i++) {
				var anchor = anchors[i];
				var tipov=0
				if($(anchor).id=="allmap")
					tipov=0;
				else if($(anchor).id=="vandellosmap")
					tipov=1;
				else if($(anchor).id=="cabrilmap")
					tipov=2;
				else if($(anchor).id=="zoritamap")
					tipov=3;
				else if($(anchor).id=="madridmap")
					tipov=4;
				else if($(anchor).id=="centralesmap")
					tipov=5
				else if($(anchor).id=="mundimap")
					tipov=12
				//Cargo el mapa por el div
				map[i] = new objetoMap();
				map[i].mapa=new GMap2($(anchor));
								//Centro del mapa
				if (tipov==0 || tipov==5)
					map[i].mapa.setCenter(espanapos, 5);
				else if(tipov==1)
					map[i].mapa.setCenter(vandellospos, 15);
				else if(tipov==2)
					map[i].mapa.setCenter(elcabrilpos, 15);
				else if(tipov==3)
					map[i].mapa.setCenter(zoritapos, 15);
				else if(tipov==4)
					map[i].mapa.setCenter(sedepos, 15);	
				else if(tipov==12)
					map[i].mapa.setCenter(mundipos, 15);	
				map[i].tipov=tipov;
				var centro=new GMarker(map[i].mapa.getCenter());
				map[i].centro=centro;
				//Mapas para superponer
				if(tipov==0){
					var elcabril=new GMarker(velcabrilpos);
					GEvent.addListener(elcabril, "click", function() {
						elcabril.openInfoWindowHtml(html[2]);
					});
					var vandellos=new GMarker(vvandellospos);
					GEvent.addListener(vandellos, "click", function() {
						vandellos.openInfoWindowHtml(html[1]);
					});	
					var sede=new GMarker(sedepos);
					GEvent.addListener(sede, "click", function() {
						sede.openInfoWindowHtml(html[4]);
					});
					var cordoba=new GMarker(cordobapos);
					GEvent.addListener(cordoba, "click", function() {
						cordoba.openInfoWindowHtml(html[25]);
					});	
					var zorita=new GMarker(zoritapos);
					GEvent.addListener(zorita, "click", function() {
						zorita.openInfoWindowHtml(html[23]);
					});
				}
				else if(tipov==5){
					var santamaria=new GMarker(santamariapos);
					GEvent.addListener(santamaria, "click", function() {
						santamaria.openInfoWindowHtml(html[6]);
					});
					var almaraz=new GMarker(almarazpos);
					GEvent.addListener(almaraz, "click", function() {
						almaraz.openInfoWindowHtml(html[7]);
					});
					var asco=new GMarker(ascopos);
					GEvent.addListener(asco, "click", function() {
						asco.openInfoWindowHtml(html[8]);
					});
					var cofrentes=new GMarker(cofrentespos);
					GEvent.addListener(cofrentes, "click", function() {
						cofrentes.openInfoWindowHtml(html[9]);
					});
					var vandellos2=new GMarker(vandellos2pos);
					GEvent.addListener(vandellos2, "click", function() {
						vandellos2.openInfoWindowHtml(html[10]);
					});
					var trillo=new GMarker(trillopos);
					GEvent.addListener(trillo, "click", function() {
						trillo.openInfoWindowHtml(html[11]);
					});	
					var zorita=new GMarker(zoritapos);
					GEvent.addListener(zorita, "click", function() {
						zorita.openInfoWindowHtml(html[3]);
					});						
				}
				else if (tipov==12){
					var ahau=new GMarker(ahaupos);
					GEvent.addListener(ahau, "click", function() {
						ahau.openInfoWindowHtml(html[13]);
					});	
					var gorleben=new GMarker(gorlebenpos);
					GEvent.addListener(gorleben, "click", function() {
						gorleben.openInfoWindowHtml(html[14]);
					});	
					var dessel=new GMarker(desselpos);
					GEvent.addListener(dessel, "click", function() {
						dessel.openInfoWindowHtml(html[15]);
					});	
					var mayak=new GMarker(mayakpos);
					GEvent.addListener(mayak, "click", function() {
						mayak.openInfoWindowHtml(html[16]);
					});	
					var krasno=new GMarker(krasnopos);
					GEvent.addListener(krasno, "click", function() {
						krasno.openInfoWindowHtml(html[17]);
					});	
					var lahaya=new GMarker(lahayapos);
					GEvent.addListener(lahaya, "click", function() {
						lahaya.openInfoWindowHtml(html[18]);
					});	
					var cascad=new GMarker(cascadpos);
					GEvent.addListener(cascad, "click", function() {
						cascad.openInfoWindowHtml(html[19]);
					});	
					var rokka=new GMarker(rokkapos);
					GEvent.addListener(rokka, "click", function() {
						rokka.openInfoWindowHtml(html[20]);
					});	
					var sella=new GMarker(sellapos);
					GEvent.addListener(sella, "click", function() {
						sella.openInfoWindowHtml(html[21]);
					});	
					var clab=new GMarker(clabpos);
					GEvent.addListener(clab, "click", function() {
						clab.openInfoWindowHtml(html[22]);
					});						
					var habog=new GMarker(habogpos);
					GEvent.addListener(habog, "click", function() {
						habog.openInfoWindowHtml(html[23]);
					});	
					var zwilag=new GMarker(zwilagpos);	
					GEvent.addListener(zwilag, "click", function() {
						zwilag.openInfoWindowHtml(html[24]);
					});	
				}
				else{
					map[i].nuevolistener(html[tipov],centro);
				}
				
				//Cargo los controles del mapa
				map[i].mapa.addControl(new GSmallMapControl());
				map[i].mapa.addControl(new GMapTypeControl());
				//Añadir iconos en el mapa
				if(tipov==0){
					map[i].mapa.setMapType(G_SATELLITE_MAP);
					map[i].mapa.addOverlay(elcabril);
					map[i].mapa.addOverlay(sede);
					map[i].mapa.addOverlay(vandellos);
					map[i].mapa.addOverlay(cordoba);
					map[i].mapa.addOverlay(zorita);
				}
				else if(tipov==5){
					map[i].mapa.setMapType(G_SATELLITE_MAP);
					map[i].mapa.addOverlay(santamaria);
					map[i].mapa.addOverlay(almaraz);
					map[i].mapa.addOverlay(asco);
					map[i].mapa.addOverlay(cofrentes);
					map[i].mapa.addOverlay(zorita);					
					map[i].mapa.addOverlay(vandellos2);	
					map[i].mapa.addOverlay(trillo);					
				}
				else if(tipov==12){
					map[i].mapa.setZoom(2);
					map[i].mapa.addOverlay(ahau);
					map[i].mapa.addOverlay(gorleben);
					map[i].mapa.addOverlay(dessel);
					map[i].mapa.addOverlay(mayak);
					map[i].mapa.addOverlay(krasno);
					map[i].mapa.addOverlay(lahaya);	
					map[i].mapa.addOverlay(cascad);
					map[i].mapa.addOverlay(rokka);
					map[i].mapa.addOverlay(sella);
					map[i].mapa.addOverlay(clab);
					map[i].mapa.addOverlay(habog);	
					map[i].mapa.addOverlay(zwilag);							
				}
				else{
					map[i].mapa.addOverlay(centro);
				}				
			}
		  }
		} 

 }
 
 function mostrarpreg(que){
	new Effect.BlindDown(que);
	$("en"+que).innerHTML='<a  href="#" onclicK="ocultarpreg(\''+que+'\'); return false;" alt="ocultar respuesta"><img src="'+path+'img/menos.gif" alt="menos" align="absmiddle" /></a>';
 }
 function ocultarpreg(que){
	new Effect.BlindUp(que);
	$("en"+que).innerHTML='<a  href="#" onclicK="mostrarpreg(\''+que+'\'); return false;" alt="mostrarr respuesta"><img src="'+path+'img/mas.gif" alt="mas" align="absmiddle" /></a>';
 } 
 
 function aniadeAdjuntos(){
	cuantos=parseInt($("contador").value)+1;
	$("contador").value=cuantos;
	contenedor=document.createElement("div");
	contenedor.id="file"+cuantos;
	contenedor.className="nuevodoc";
	contenedor.innerHTML='<p class="bold">Datos del archivo</p><div class="row"><label for="titulo'+cuantos+'" class="bold">Titulo </label><input type="text" id="titulo'+cuantos+'" name="titulo['+cuantos+']" size=70 /></div><div class="row"><select id="paratitulo'+cuantos+'" class="selectorn" onChange="javascript:$(\'titulo'+cuantos+'\').value=$(\'paratitulo'+cuantos+'\').value" size="6">	<option value="Anuncio DOUE">Anuncio DOUE</option><option value="Anuncio BOE">Anuncio BOE</option><option value="Anuncio Web">Anuncio Web</option><option value="Pliego de Cláusulas Administrativas">Pliego de Cláusulas Administrativas</option><option value="Pliego de Prescripciones Técnicas">Pliego de Prescripciones Técnicas</option><option value="Pliego de Condiciones">Pliego de Condiciones</option></select></div><div class="row"><label for="description'+cuantos+'" class="bold">Descripci&oacute;n </label><textarea id="description'+cuantos+'" name="description['+cuantos+']"  rows="2" cols="55" /></textarea></div><div class="row"><label for="archivo'+cuantos+'" class="bold">Archivo</label><input name="archivo['+cuantos+']" id="archivo'+cuantos+'" type="file" class="boton" /></div><p class="bold"><a href="#" onclick="dropAdjunto('+cuantos+'); return false;">Eliminar</a></p>';
	$("listfiles").appendChild(contenedor);
}
function aniadeUpload(){
	cuantos=parseInt($("contador").value)+1;
	$("contador").value=cuantos;
	contenedor=document.createElement("div");
	contenedor.id="file"+cuantos;
	contenedor.className="nuevodoc";
	contenedor.innerHTML='<p class="bold">Datos del archivo</p><div class="row"><label for="titulo'+cuantos+'" class="bold">Titulo </label><input type="text" id="titulo'+cuantos+'" name="titulo['+cuantos+']" size=70 /></div><div class="row"><label for="description'+cuantos+'" class="bold">Descripci&oacute;n </label><textarea id="description'+cuantos+'" name="description['+cuantos+']"  rows="2" cols="55" /></textarea></div><div class="row"><label for="archivo'+cuantos+'" class="bold">Archivo </label><input type="text" id="archivo'+cuantos+'" disabled="true" class="boton" /><span id="spanButtonPlaceholder'+cuantos+'"></span><input type="hidden" name="hidFileID'+cuantos+'" id="hidFileID'+cuantos+'" value="" /></div><div class="row"><div class="flash" id="fsUploadProgress'+cuantos+'"></div><p class="bold"><a href="#" onclick="dropAdjunto('+cuantos+'); return false;">Eliminar</a></p>';
	$("listfiles").appendChild(contenedor);	
	swfu[(cuantos-1)]=inicio("archivo"+cuantos,"spanButtonPlaceholder"+cuantos,"fsUploadProgress"+cuantos,"hidFileID"+cuantos);
	
}
function muestradia (dia){
		var dias=$$("span.semana");
		var enlacehrf=new Array();
		for(var i=0; i<dias.length; i++){
				dias[i].style.fontSize="12px";
				$("enl"+dias[i].id).style.textDecoration="underline";
				//dias[i].style.color="#67683f";
		}
		$(dia).style.fontSize="16px";
		$("enl"+dia).style.textDecoration="none";
		
		var dias=$$("div.diasemana");
		var enlacehrf=new Array();
		for(var i=0; i<dias.length; i++){
				dias[i].style.display="none";
		}
		$("dia"+dia).style.display="block";
}
function dropAdjunto(numero){
	var borrado=$("file"+numero);
	$("listfiles").removeChild(borrado);
}
function marcarpregunta(que){
	$('spr'+que).className="marcada";
	$('enl'+que).innerHTML="<img class='marcar' src='"+path+"img/boton_marcada.gif' alt='Desmarcar pregunta'/>";
	$('enl'+que).onclick=function(){desmarcarpregunta(que); return false;};	
	new Ajax.Request( path+"preguntas/marcar/"+que+"/1" , {method: 'get',
	onSuccess: function(transport) {	
		
	}
	});
	return false;
}
function desmarcarpregunta(que){
	$('spr'+que).className="";
	$('enl'+que).innerHTML="<img class='marcar' src='"+path+"img/boton_marcar.gif' alt='Marcar pregunta'/>";
	$('enl'+que).onclick=function(){marcarpregunta(que); return false;};
	new Ajax.Request( path+"preguntas/marcar/"+que+"/0" , {method: 'get',
	onSuccess: function(transport) {
				
	}
	});
	return false;
}
function enviarnews(que,cuantas){
	new Ajax.Updater('envianew',path+'posts/enviarnewsletter/'+que+"/"+cuantas, {asynchronous:true, evalScripts:true, onLoading:function(request){$("envianew").update("<p>"+((que-1)*100)+" emails enviados, enviando siguiente paquete de 100..."+"</p>")}, requestHeaders:['X-Update', 'envianew']});
	//return false;
	}
 window.onload=enlacesjv;

