/////////////// 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 genera_url_form(desde,para, formu){
	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=document.forms[formu][desde].value.toLowerCase();
	//if($(para).value==""){
		for(i=0; i<sinconvertir.length; i++){
			texto=replaceAll(texto,sinconvertir[i],convertir[i]);
		}
		document.forms[formu][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);
		$('numvotos2').update(transport.responseText);
		$('voteres').style.display="none";
		$('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;
			
}



//SE SOBRE-ESCRIBEN LOS ENLACES CON JAVASCRIPT EN CASO DE QUE EXISTAN
function enlacesjv(){
		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]);
			}
		}
		if($('encomp')){
			$('compartir').innerHTML='<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>";
				$("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>";
				$("voteres2").innerHTML=htmlvotos+"<p><a href='#voteres2' class='cancela'>Cancelar</a></p></div>";
			}
			 $('envot').href="javascript:mostrar('voteres');";
			 $('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($('bloquep2')){
			new Ajax.Updater("bloquep2", path+"pages/ajax_get_grafica", {asynchronous:true, evalScripts:true, requestHeaders:['X-Update', "bloquep2"]});
		}
		if($('contengraf')){
			new Ajax.Updater("contengraf", path+"pages/ajax_get_grafica_mini", {asynchronous:true, evalScripts:true, requestHeaders:['X-Update', "contengraf"]});
		}
		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()) {
			for (var i = 0; i < anchors.length; i++) {	
				var anchor = anchors[i];
				var parametrosmap=anchor.innerHTML.split(";");
				$("adonde").update(parametrosmap[0]);
				var cord1=parseFloat(parametrosmap[1]);
				var cord2=parseFloat(parametrosmap[2]);
				var elzoom=parseInt(parametrosmap[3]);
				var map = new GMap2(anchor);
				var posicion=new GLatLng(cord1, cord2);
				//var map2 = new GMap2(document.getElementById("map2"));
				map.setCenter(posicion, elzoom); 
				map.addOverlay(new GMarker(posicion));
				/*map.setCenter(new google.maps.LatLng(cord1, cord2), elzoom);*/
				map.setUIToDefault();
				$("cord1").value=cord1;
				$("cord2").value=cord2;
				$("aliasmap").value=parametrosmap[0];
				gdir = new GDirections(map, document.getElementById("directions"));
		        //Listener para los errores que se produzcan cuando procese la petición
		        GEvent.addListener(gdir, "error", handleErrors);
				GEvent.addListener(gdir, "load", aniadeOcultar);
				//anchor.style.display="block";
			}
		  }
	} 
 }
 
 
	function setDirections(fromAddress) {
		$("directions").style.display="none";
      gdir.load("from: " + fromAddress + " to: "+$("aliasmap").value+"@"+$("cord1").value+", "+$("cord2").value,
                { "locale": "es" });
        //Como es de suponer la opción locale:es hace que la ruta que  
        //nos escriba esté en español.
    }

    //Manejo de errores
    function handleErrors(){
       if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
         alert("No se puede calcular la ruta desde la dirección indicada, compruebe que está bien escrita o esta no sa ambigua");
       else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)
         alert("Error desconocido");

       else if (gdir.getStatus().code == G_GEO_MISSING_QUERY)
         alert("No se ha introducido una dirección de inicio");

       else if (gdir.getStatus().code == G_GEO_BAD_KEY)
         alert("Clave usada por el mapa no valida o no corresponde con el dominio desde el que se usa.");

       else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)
         alert("La dirección no puede ser parseada.");

       else alert("No se ha podido calcular la ruta.");

    }

	function aniadeOcultar(){
		$("directions").update("<div class='ocultaruta'><a href='' onclick='Effect.BlindUp(\"directions\"); return false;'>Ocultar ruta</a></div>");
		$("directions").style.display="block";
	}
	
    function onGDirectionsLoad(){ 
    }
 
 function formgrafica(pagina,contenedor,portada){
	new Ajax.Updater(contenedor,path+"pages/"+pagina+"/"+$("BuscarMercasId").options[$("BuscarMercasId").selectedIndex].value+"?portada="+portada, {asynchronous:true, onLoading:function(request){$(contenedor).update('<p>Cargando gráfica...<img src="'+path+'img/ajaxload.gif" alt="cargando..." /></p>')}, evalScripts:true, requestHeaders:['X-Update', contenedor]});
 }
 
 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 dropAdjunto(numero){
	var borrado=$("file"+numero);
	$("listfiles").removeChild(borrado);
}

 window.onload=enlacesjv;

