// JavaScript Document

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 MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
	}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
	}

function MM_nbGroup(event, grpName) { //v6.0
var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])?args[i+1] : img.MM_up);
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) { img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    nbArr = document[grpName];
    if (nbArr) for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
      nbArr[nbArr.length] = img;
  } }
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
	}
//-------------------------------------------------------------------------------
function checkIt(string){
	var detect = navigator.userAgent.toLowerCase();
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
	}
	

/*function resizeContentFrame() {
	if (checkIt('opera')){
		document.getElementById("contentFrame").height = document.getElementById("contentFrame").document.body.scrollHeight;
 		}
		alert(document.getElementById("contentFrame").contentWindow.document.body.scrollHeight >= 600);
	if (document.getElementById("contentFrame").contentWindow.document.body.scrollHeight >= 600) {
	 	document.getElementById("contentFrame").height = document.getElementById("contentFrame").contentWindow.document.body.scrollHeight;
	} else {
		document.getElementById("contentFrame").height = 600;
	}
}*/

function resizeContentFrame() {
	if (checkIt('opera')){
		document.getElementById("paginact").height = document.getElementById("paginact").document.body.scrollHeight;
 		}
 	document.getElementById("paginact").height = document.getElementById("paginact").contentWindow.document.body.scrollHeight;
	}

function getPage(id, act) {
	document.getElementById("pageAnt").value = document.getElementById("pageId").value;
	document.getElementById("pageId").value = id;
	document.getElementById("pageAction").value = act;
	document.getElementById("pageSection").value = 0;	
	document.getElementById("pageTemplate").value = 0;
	//document.images.logme.src = 'logme.asp?'+id;
	document.getElementById("parser").submit();
}

/*function getMediaPage(id, act,mediaType) {
	document.parser.pageId.value = 800;
	document.parser.pageMediaId.value = id;
	document.parser.pageMediaType.value = mediaType;
	document.parser.pageAction.value = act;
	document.parser.pageSection.value = 0;	
	document.parser.pageTemplate.value = 0;
	document.parser.submit();
}*/

function getSearch(id, act) {
	document.getElementById("pageSearch").value = document.getElementById("searchPara").value
	document.getElementById("searchPara").value = ""
	document.getElementById("pageId").value = id;
	document.getElementById("pageAction").value = act;
	document.getElementById("pageTemplate").value = 0;
	document.getElementById("pageSection").value = 0;
	document.getElementById("parser").submit();	
}

function addPage(templ, sec, act) {
	document.getElementById('pageTemplate').value = templ
	document.getElementById('pageId').value = 0;
	document.getElementById('pageAction').value = act;
	document.getElementById('pageSection').value = sec;	
	document.getElementById('parser').submit();
}	
//-------------------------------------------------------------------------------
/*function setMenuLtr(menuNum) {
	if (document.getElementById('navLtr').value == 0 && menuNum == 0) { 
		document.getElementById('menuLtr').innerHTML = menuLtr[1];
		document.getElementById('navLtr').value = 1;
		}
		
	if (document.getElementById('navLtr').value != menuNum && menuNum != 0) { 
		document.getElementById('menuLtr').innerHTML = menuLtr[menuNum];
		document.getElementById('navLtr').value = menuNum;
		}
	}
	
function setMenuInf(menuNum) {
	if (document.getElementById('navFoot').value == 0 && menuNum == 0) { 
		document.getElementById('menuInf').innerHTML = menuLtr[1];
		document.getElementById('navFoot').value = 1;
		}
	
	if (document.getElementById('navFoot').value != menuNum && menuNum != 0) { 
		document.getElementById('menuInf').innerHTML = menuInf[menuNum];
		document.getElementById('navFoot').value = menuNum;
		}
	}*/

function setMediaTool(menuId) {
	document.getElementById('mediaControl').innerHTML = media[menuId];
	document.getElementById('mediaStatus').value = 0;
	}
	
function setMediaIcon(iconAction, iconId, pageId) {
	var mediaIcon = new Array();
	var iconSource = new Array();
	var mediaElement = new Array();
	var mediaLayer = new Array();
	var iconHTML = new Array()
	
	mediaIcon[1] = "mediaAudio"
	mediaIcon[2] = "mediaVideo"
	mediaIcon[3] = "mediaImagen"
	mediaIcon[4] = "mediaPdf"
	
	iconSource[1] = "images/media/audio.gif"
	iconSource[2] = "images/media/video.gif"
	iconSource[3] = "images/media/imagen.gif"
	iconSource[4] = "images/media/pdf.gif"
	
	mediaElement[1] = "audio"
	mediaElement[2] = "video"
	mediaElement[3] = "imagen"
	mediaElement[4] = "pdf"
	
	mediaLayer[1] = "audioLayer"
	mediaLayer[2] = "videoLayer"
	mediaLayer[3] = "imagenLayer"
	mediaLayer[4] = "pdfLayer"
	
	if (document.getElementById('mediaStatus').value == 0) {
		setMediaTool(1);
		document.getElementById('mediaStatus').value = 1;
		}
	
	iconHTML[0]= "<img src=\"images/media/"+mediaElement[iconId]+".gif\" alt=\""+mediaElement[iconId]+"\" name=\""+mediaIcon[iconId]+"\" height=\"21\" border=\"0\" id=\""+mediaIcon[iconId]+"\" />"	
		
	iconHTML[1] = "<a href=\"javascript:MM_openBrWindow('mod/mod_media/showmedia.asp?pid="+pageId+"&media="+iconId+"','media','width=550,height=400,scrollbars=yes')\" onmouseout=\"MM_swapImgRestore();MM_nbGroup('out')\" onmouseover=\"MM_swapImage('espect','','images/media/espect_"+mediaElement[iconId]+".gif',0);MM_nbGroup('over','"+mediaIcon[iconId]+"','images/media/"+mediaElement[iconId]+"_roll.gif','images/media/"+mediaElement[iconId]+".gif',1);\"><img src=\"images/media/"+mediaElement[iconId]+"_act.gif\" alt=\""+mediaElement[iconId]+"\" name=\""+mediaIcon[iconId]+"\" height=\"21\" border=\"0\" id=\""+mediaIcon[iconId]+"\" /></a>"	
	
	
	document.getElementById(mediaLayer[iconId]).innerHTML = iconHTML[iconAction];
	
	}
function setMailLayer(pageId) {
	mailLayerHtml = "<a href=\"javascript:MM_openBrWindow('mod/mod_contact/mod_contact_0.asp?pid="+pageId+"','contacto','width=580,height=475')\" onmouseout=\"MM_swapImgRestore();MM_nbGroup('out')\" onmouseover=\"MM_nbGroup('over','mediaMail','images/media/mail_roll.gif','images/media/mail.gif',1);MM_swapImage('espect','','images/media/espect_mail.gif',1)\"><img src=\"images/media/mail_act.gif\" alt=\"Contactar\" name=\"mediaMail\" height=\"21\" border=\"0\" id=\"mediaMail\" /></a>"
	document.getElementById('mailLayer').innerHTML = mailLayerHtml;
}
function setSec(sec) {
		document.getElementById('pageSection').value = sec;
}

function preloadImages() {

	MM_preloadImages('images/media/mail.gif');
	MM_preloadImages('images/media/mail_roll.gif');
	MM_preloadImages('images/media/mail_act.gif');
	
	MM_preloadImages('images/media/audio.gif');
	MM_preloadImages('images/media/audio_roll.gif');
	MM_preloadImages('images/media/audio_act.gif');
	
	MM_preloadImages('images/media/video.gif');
	MM_preloadImages('images/media/video_roll.gif');
	MM_preloadImages('images/media/video_act.gif');
	
	MM_preloadImages('images/media/imagen.gif');
	MM_preloadImages('images/media/imagen_roll.gif');
	MM_preloadImages('images/media/imagen_act.gif');
	
	MM_preloadImages('images/media/pdf.gif');
	MM_preloadImages('images/media/pdf_roll.gif');
	MM_preloadImages('images/media/pdf_act.gif');
	
	MM_preloadImages('images/media/impres.gif');
	MM_preloadImages('images/media/impres_roll.gif');
	MM_preloadImages('images/media/impres_act.gif');
	
	MM_preloadImages('images/media/lat.gif');
	MM_preloadImages('images/media/enun.gif');
	MM_preloadImages('images/media/espect.gif');
	MM_preloadImages('images/media/espect_audio.gif');
	MM_preloadImages('images/media/espect_video.gif');
	MM_preloadImages('images/media/espect_imagen.gif');
	MM_preloadImages('images/media/espect_pdf.gif');
	MM_preloadImages('images/media/espect_impres.gif');
	MM_preloadImages('images/media/espect_mail.gif');
	
}
// Funciones de comprobación
content="<%= ID%>";
useIndx=0;
use100=0;
usoBat=0;
use110=0;
useGral=0;
useCongr=0;
useInmem=0;
useNoti=0;
useDisc=0;
useent=0;
useSede=0;
usegest=0;
usecom=0;
useRet=0;
usePortalA=0;
usePortalB=0;
usePortalC=0;
function comprobar (pid, act) {
	var error;
	error='ERRORES\n';
	if ((act == 1) || (act == 3)) {
		if (useIndx == 1 ) {
			error=check_index(error);
			}
		if (use100 == 1) {
			error=check_title(error);
			}
		if (usoBat == 1) {
			error=check_bat(error);
			}
		if (useent == 1) {
			error=check_ent(error);
			}
		if (useGral == 1) {
			error=check_gral(error);
			}
		if (useCongr == 1) {
			error=check_congr(error);
			}
		if (useInmem == 1) {	
			error=check_inmem(error);
			}
		if (useNoti == 1) {
			error=check_noti(error);
			}
		if (useDisc == 1) {
			error=check_disc(error);
			}
		if (useSede == 1) {
			error=check_sede(error);
			}
		if (usegest == 1) {
			error=check_gest(error);
			}
		if (usecom == 1) {
			error=check_com(error);
			}
		if (usePortalA == 1 ) {
			error=check_portalA(error);
			}
		if (usePortalB == 1 ) {
			error=check_portalB(error);
			}
		if (useRet == 1) {
			error=check_ret(error);
			}
		if ( error.length < 20) {
			document.getElementById('parserForm').submit();
			} else { 
			alert (error);
			}
		}
	}

function isDate(obj) {
 	var date_regex = /^\d{1,2}\/\d{1,2}\/\d{4}$/;
	 if (!date_regex.test(obj.value)) {
	  	return 1;
 		} else {
		return 0;
		}
	}
	
function isTime(obj) {
 	var time_regex = /^\d{1,2}\:\d{1,2}/;
	 if (!time_regex.test(obj.value)) {
	  	return 1;
 		} else {
		return 0;
		}
	}

function check_ret(error) {
	cont=0;
	if (isDate(document.getElementById('indx_date_ret')) == 1 ) {
		cont=cont+1;
		if (cont==1) {
			error=error+"Información de la retransmisión:\n";
			}
		error=error+"     Formato de fecha incorrecto\n";
		}  else {
			var fecha=document.getElementById('indx_date_ret').value.split('/');
			if (fecha[2] < 1900) {
				cont=cont+1;
				if (cont==1) {
					error=error+"Información de la retransmisión:\n";
				}
				error=error+"     El año debe ser superior al 1900\n";
			}
			if ((fecha[1] < 1) || (fecha[1] > 12)) {
				cont=cont+1;
				if (cont==1) {
					error=error+"Información de la retransmisión:\n";
				}
				error=error+"     El mes debe estar comprendido entre 1 y 12\n";
			}
			if ((fecha[0] < 1) || (fecha[0] > 31)) {
				cont=cont+1;
				if (cont==1) {
					error=error+"Información de la retransmisión:\n";
				}
				error=error+"     El día debe estar comprendido entre 1 y 31\n";
			}
		}
	if (isTime(document.getElementById('indx_ini_ret')) == 1 ) {
		cont=cont+1;
		if (cont==1) {
			error=error+"Información de la retransmisión:\n";
			}
		error=error+"     Formato de hora incorrecto\n";
		}  else {
			var hora=document.getElementById('indx_ini_ret').value.split(':');
			if ((hora[0] == 0) && (hora[1] == 0)) {
				alert ("No se admite la hora 0:00");
				return false;
			}
			if ((hora[0] < 0) || (hora[0] > 23)) {
				cont=cont+1;
				if (cont==1) {
					error=error+"Información de la retransmisión:\n";
				}
				error=error+"     La hora debe estar comprendida entre 0 y 23\n";
			}
			if ((hora[1] < 0) || (hora[1] > 59)) {
				cont=cont+1;
				if (cont==1) {
					error=error+"Información de la retransmisión:\n";
				}
				error=error+"     Los minutos deben estar comprendidos entre 0 y 59\n";
			}
		}
	if (isTime(document.getElementById('indx_fin_ret')) == 1 ) {
		cont=cont+1;
		if (cont==1) {
			error=error+"Información de la retransmisión:\n";
			}
		error=error+"     Formato de hora incorrecto\n";
		}  else {
			var hora=document.getElementById('indx_fin_ret').value.split(':');
			if ((hora[0] == 0) && (hora[1] == 0)) {
				alert ("No se admite la hora 0:00");
				return false;
			}
			if ((hora[0] < 0) || (hora[0] > 23)) {
				cont=cont+1;
				if (cont==1) {
					error=error+"Información de la retransmisión:\n";
				}
				error=error+"     La hora debe estar comprendida entre 0 y 23\n";
			}
			if ((hora[1] < 0) || (hora[1] > 59)) {
				cont=cont+1;
				if (cont==1) {
					error=error+"Información de la retransmisión:\n";
				}
				error=error+"     Los minutos deben estar comprendidos entre 0 y 59\n";
			}
		}
		if (document.getElementById('indx_url_ret').value.length == 0) {
			cont=cont+1;
			if (cont==1) {
				error=error+"Información de la retransmisión:\n";
			}
			error=error+"     La URL no puede estar vacía\n";
		}
		if (document.getElementById('indx_url_ret').value.length > 2000) {
			cont=cont+1;
			if (cont==1) {
				error=error+"Información de la retransmisión:\n";
			}
			error=error+"     La URL no puede superar los 2000 carácteres\n";
		}
	if (document.getElementById('indx_ini_ret').value > document.getElementById('indx_fin_ret').value) {
		cont=cont+1;
		if (cont==1) {
			error=error+"Información de la retransmisión:\n";
		}
		error=error+"     La hora de inicio no puede superar la hora de fin\n";
	}
	return error;
}


function check_portalA(error) {
	cont=0;
	if (document.getElementById('portal_img').value == 0) {
		cont=cont+1;
		if (cont==1) {
			error=error+"Subindex Portal:\n";
			}
		error=error+"     Debe seleccionar la imagen destacada\n";
		}
	if (document.getElementById('disc').value == 0) {
		cont=cont+1;
		if (cont==1) {
			error=error+"Subindex Portal:\n";
			}
		error=error+"     Debe seleccionar el discurso destacado\n";
		}
	if (document.getElementById('pie_img').value.length == 0) {
		cont=cont+1;
		if (cont==1) {
			error=error+"Subindex Portal:\n";
			}
		error=error+"     Debe introducir el pie de la imagen\n";
		}
	if (document.getElementById('pie_img').value.length > 500) {
		cont=cont+1;
		if (cont==1) {
			error=error+"Subindex Portal:\n";
			}
		error=error+"     El pie de la imagen no puede superar los 500 caracteres\n";
		}
	return error;
}

function check_portalB(error) {
	cont=0;
	if (document.getElementById('portal_img').value == 0) {
		cont=cont+1;
		if (cont==1) {
			error=error+"Subindex Portal:\n";
			}
		error=error+"     Debe seleccionar la imagen destacada\n";
		}
	if (document.getElementById('disc').value == 0) {
		cont=cont+1;
		if (cont==1) {
			error=error+"Subindex Portal:\n";
			}
		error=error+"     Debe seleccionar el discurso destacado\n";
		}
	return error;
}
		
function check_com (error) {
	cont=0;
	if (document.getElementById('indx_cargo_com').value.length == 0) {
		cont=cont+1;
		if (cont==1) {
			error=error+"Subindex Comité Ejecutivo:\n";
			}
		error=error+"     Debe introducir el cargo del miembro\n";
		}
	if (document.getElementById('indx_nom_com').value.length == 0) {
		cont=cont+1;
		if (cont==1) {
			error=error+"Subindex Comité Ejecutivo:\n";
			}
		error=error+"     Debe introducir el nombre del miembro\n";
		}
	if (document.getElementById('indx_cargo_com').value.length > 150) {
		cont=cont+1;
		if (cont==1) {
			error=error+"Subindex Comité Ejecutivo:\n";
			}
		error=error+"     El cargo del miembro no puede superar los 150 carácteres\n";
		}
	if (document.getElementById('indx_nom_com').value.length > 500) {
		cont=cont+1;
		if (cont==1) {
			error=error+"Subindex Comité Ejecutivo:\n";
			}
		error=error+"     El nombre del miembro no puede superar los 500 carácteres\n";
		}
	return error;
	}
	
function check_gest (error) {
	cont=0;
	if (document.getElementById('ccaa').value == 0) {
		cont=cont+1;
		if (cont==1) {
			error=error+"Subindex Gestión Pública:\n";
			}
		error=error+"     Debe seleccionar la Comunidad Autónoma\n";
		}
	if (document.getElementById('indx_autor_gest').value.length == 0) {
		cont=cont+1;
		if (cont==1) {
			error=error+"Subindex Gestión Pública:\n";
			}
		error=error+"     Debe introducir el nombre del autor\n";
		}
	if (document.getElementById('indx_tema_gest').value.length == 0) {
		cont=cont+1;
		if (cont==1) {
			error=error+"Subindex Gestión Pública:\n";
			}
		error=error+"     Debe introducir el tema\n";
		}
	if (document.getElementById('indx_autor_gest').value.length > 500) {
		cont=cont+1;
		if (cont==1) {
			error=error+"Subindex Gestión Pública:\n";
			}
		error=error+"     El nombre del autor no debe superar los 500 carácteres\n";
		}
	if (document.getElementById('indx_tema_gest').value.length > 500) {
		cont=cont+1;
		if (cont==1) {
			error=error+"Subindex Gestión Pública:\n";
			}
		error=error+"     El tema no puede superar los 500 carácteres\n";
		}
	return error;
	}	
	
function check_sede (error) {
	cont=0;
	if (document.getElementById('ccaa').value == 0 && document.getElementById('prov').value == 0 ) {
		cont=cont+1;
		if (cont==1) {
			error=error+"Subindex Sedes:\n";
			}
		error=error+"     Debe seleccionar el tipo de sede\n";
		}
	if (document.getElementById('indx_resp_sede').value.length == 0 ) {
		cont=cont+1;
		if (cont==1) {
			error=error+"Subindex Sedes:\n";
			}
		error=error+"     Debe introducir el nombre del responsable de la sede\n";
		}
	if (document.getElementById('indx_resp_sede').value.length > 500 ) {
		cont=cont+1;
		if (cont==1) {
			error=error+"Subindex Sedes:\n";
			}
		error=error+"     El nombre del responsable no puede superar los 500 carácteres\n";
		}
	return error;
	}	
	
	
function check_ent (error) {
	cont=0;
	if (document.getElementById('ccaa').value == 0 ) {
		cont=cont+1;
		if (cont==1) {
			error=error+"Subindex Entidades locales:\n";
			}
		error=error+"     Debe seleccionar una Comunidad Autónoma\n";
		}
	if (document.getElementById('prov').value == 0 ) {
		cont=cont+1;
		if (cont==1) {
			error=error+"Subindex Entidades locales:\n";
			}
		error=error+"     Debe seleccionar una Provincia\n";
		}
	if (document.getElementById('loc').value == 0 ) {
		cont=cont+1;
		if (cont==1) {
			error=error+"Subindex Entidades locales:\n";
			}
		error=error+"     Debe seleccionar una Localidad\n";
		}		
	if (document.getElementById('ent').value == 0 ) {
		cont=cont+1;
		if (cont==1) {
			error=error+"Subindex Entidades locales:\n";
			}
		error=error+"     Debe seleccionar el tipo de entidad\n";
		}		
	if (document.getElementById('resp').value.length > 500 ) {
		cont=cont+1;
		if (cont==1) {
			error=error+"Subindex Entidades Locales:\n";
			}
		error=error+"     El nombre del responsable no puede superar los 500 carácteres\n";
		}
	if (document.getElementById('resp').value.length == 0 ) {
		cont=cont+1;
		if (cont==1) {
			error=error+"Subindex Entidades Locales:\n";
			}
		error=error+"     El nombre del responsable no puede estar vacío\n";
		}	
		return error;
}

function check_disc (error) {
	cont=0;
	if (document.getElementById('indx_desc_disc').value.length == 0 ) {
		cont=cont+1;
		if (cont==1) {
			error=error+"Subindex Discursos, Articulos, Entrevistas:\n";
			}
		error=error+"     La descripción no puede estar vacía\n";
		}
	if (document.getElementById('indx_desc_disc').value.length > 500 ) {
		cont=cont+1;
		if (cont==1) {
			error=error+"Subindex Discursos, Articulos, Entrevistas:\n";
			}
		error=error+"     La descripción no puede superar los 500 carácteres\n";
		}
	if (document.getElementById('indx_autor_disc').value.length == 0 ) {
		cont=cont+1;
		if (cont==1) {
			error=error+"Subindex Discursos, Articulos, Entrevistas:\n";
			}
		error=error+"     El nombre del autor no puede estar vacío\n";
		}
	if (document.getElementById('indx_autor_disc').value.length > 150 ) {
		cont=cont+1;
		if (cont==1) {
			error=error+"Subindex Discursos, Articulos, Entrevistas:\n";
			}
		error=error+"     El nombre del autor no puede superar los 150 carácteres\n";
		}
	if (isDate(document.getElementById('indx_date_disc')) == 1) {
		cont=cont+1;
		if (cont==1) {
			error=error+"Subindex Discursos, Articulos, Entrevistas:\n";
			}
		error=error+"     Formato de fecha incorrecto\n";
		} else {
			var fecha=document.getElementById('indx_date_disc').value.split('/');
			if (fecha[2] < 1900) {
				cont=cont+1;
				if (cont==1) {
					error=error+"Subindex Discursos, Articulos, Entrevistas:\n";
				}
				error=error+"     El año debe ser superior al 1900\n";
			}
			if ((fecha[1] < 1) || (fecha[1] > 12)) {
				cont=cont+1;
				if (cont==1) {
					error=error+"Subindex Discursos, Articulos, Entrevistas:\n";
				}
				error=error+"     El mes debe estar comprendido entre 1 y 12\n";
			}
			if ((fecha[0] < 1) || (fecha[0] > 31)) {
				cont=cont+1;
				if (cont==1) {
					error=error+"Subindex Discursos, Articulos, Entrevistas:\n";
				}
				error=error+"     El día debe estar comprendido entre 1 y 31\n";
			}
		}
	return error;
}

function check_noti (error) {
	cont=0;
	if (document.getElementById('indx_desc_noti').value.length > 500 ) {
		cont=cont+1;
		if (cont==1) {
			error=error+"Subindex Noticias:\n";
			}
		error=error+"     El subtítulo de la noticia no puede superar los 500 carácteres\n";
		}
	if (isDate(document.getElementById('indx_date_noti')) == 1) {
		cont=cont+1;
		if (cont==1) {
			error=error+"Subindex Noticias:\n";
			}
		error=error+"     Formato de fecha incorrecto\n";
		} else {
			var fecha=document.getElementById('indx_date_noti').value.split('/');
			if (fecha[2] < 1900) {
				cont=cont+1;
				if (cont==1) {
					error=error+"Subindex Noticias:\n";
				}
				error=error+"     El año debe ser superior al 1900\n";
			}
			if ((fecha[1] < 1) || (fecha[1] > 12)) {
				cont=cont+1;
				if (cont==1) {
					error=error+"Subindex Noticias:\n";
				}
				error=error+"     El mes debe estar comprendido entre 1 y 12\n";
			}
			if ((fecha[0] < 1) || (fecha[0] > 31)) {
				cont=cont+1;
				if (cont==1) {
					error=error+"Subindex Noticias:\n";
				}
				error=error+"     El día debe estar comprendido entre 1 y 31\n";
			}
		}
	return error;
}

function check_inmem (error) {
	cont=0;
	if (document.getElementById('indx_desc_inmem').value.length == 0 ) {
		cont=cont+1;
		if (cont==1) {
			error=error+"Subindex In Memoriam:\n";
			}
		error=error+"     La descripción no puede estar vacía\n";
		}
	if (document.getElementById('indx_desc_inmem').value.length > 500 ) {
		cont=cont+1;
		if (cont==1) {
			error=error+"Subindex In Memoriam:\n";
			}
		error=error+"     La descripción no puede superar los 500 carácteres\n";
		}
	return error;
}

function check_congr (error) {
	cont=0;
	if (document.getElementById('indx_desc_congr').value.length == 0 ) {
		cont=cont+1;
		if (cont==1) {
			error=error+"Subindex Congresos:\n";
			}
		error=error+"     La descripción del congreso no puede estar vacía\n";
		}
	if (document.getElementById('indx_desc_congr').value.length > 500 ) {
		cont=cont+1;
		if (cont==1) {
			error=error+"Subindex Congresos:\n";
			}
		error=error+"     La descripción del congreso no puede superar los 500 carácteres\n";
		}
	if (document.getElementById('indx_president_congr').value.length == 0 ) {
		cont=cont+1;
		if (cont==1) {
			error=error+"Subindex Congresos:\n";
			}
		error=error+"     El nombre del presidente electo no puede estar vacío\n";
		}
	if (document.getElementById('indx_president_congr').value.length > 250 ) {
		cont=cont+1;
		if (cont==1) {
			error=error+"Subindex Congresos:\n";
			}
		error=error+"     El nombre del presidente electo no superar los 250 carácteres\n";
		}
	if (isDate(document.getElementById('indx_date_congr')) == 1) {
		cont=cont+1;
		if (cont==1) {
			error=error+"Subindex Congresos:\n";
			}
		error=error+"     Formato de fecha incorrecto\n";
		} else {
			var fecha=document.getElementById('indx_date_congr').value.split('/');
			if (fecha[2] < 1900) {
				cont=cont+1;
				if (cont==1) {
					error=error+"Subindex Congresos:\n";
				}
				error=error+"     El año debe ser superior al 1900\n";
			}
			if ((fecha[1] < 1) || (fecha[1] > 12)) {
				cont=cont+1;
				if (cont==1) {
					error=error+"Subindex Congresos:\n";
				}
				error=error+"     El mes debe estar comprendido entre 1 y 12\n";
			}
			if ((fecha[0] < 1) || (fecha[0] > 31)) {
				cont=cont+1;
				if (cont==1) {
					error=error+"Subindex Congresos:\n";
				}
				error=error+"     El día debe estar comprendido entre 1 y 31\n";
			}
		}
	return error;
}

function check_gral (error) {
	cont=0;
	if (document.getElementById('indx_desc_gral').value.length == 0) {
		cont=cont+1;
		if (cont == 1) {
			error=error+"Subindex general:\n";
			}
		error=error+"     La descripción del subindex no puede estar vacía.\n";
		}
	if (document.getElementById('indx_desc_gral').value.length > 500) {
		cont=cont+1;
		if (cont == 1) {
			error=error+"Subindex general:\n";
			}
		error=error+"     La descripción del subindex no puede superar los 500 carácteres.\n";
		}
	return error;
	}

function check_110 (error) {
	cont=0;
	if (document.getElementById('cont_html_110').value.length == 0) {
		cont=cont+1;
		if (cont == 1) {
			error=error+"Texto HTML con Imagen:\n"
			}
		error=error+"     El contenido de la página no puede estar vacío.\n";
		}
	if (document.getElementById('cont_html_110').value.length > 8000) {
		cont=cont+1;
		if (cont == 1) {
			error=error+"Texto HTML con Imagen:\n"
			}
		error=error+"     El contenido de la página no puede superar los 8000 carácteres\n";
		}
	return error;
	}
	
function check_bat (error) {
	cont=0;
	if (document.getElementById('mod_bat_name').value.length == 0) {
		cont=cont+1;
		if (cont == 1) {
			error=error+"Batería de imagenes:\n"
			}
		error=error+"     El nombre de la batería no puede estar vacío\n";
		}
	if (document.getElementById('mod_bat_name').value.length > 500) {
		cont=cont+1;
		if (cont == 1) {
			error=error+"Batería de imagenes:\n"
			}
		error=error+"     El nombre de la bateria no puede superar los 500 carácteres\n";
		}
	for (i=1; i<=5; i++) {
		if (document.getElementById('bat_img'+i).value == 0) {
			cont=cont+1;
			if (cont == 1) {
				error=error+"Batería de imagenes:\n"
				}
			error=error+"     La imagen número "+i+" de la batería no puede estar vacía\n";
			}
		}
	return error;
}

function check_index (error) {
	cont=0;
	if (document.getElementById('indx_title').value.length == 0) {
		cont=cont+1;
		if (cont == 1) {
			error=error+"Index general de la página:\n"
			}
		error=error+"     El titulo de la página no puede estar vacío\n";
		}
	if (document.getElementById('indx_title').value.length > 250) {
		cont=cont+1;
		if (cont == 1) {
			error=error+"Index general de la página:\n"
			}
		error=error+"     El titulo de la página no puede superar los 250 caracteres\n";
		}
	return error;
	}

function check_title (error) {
	cont=0;
	if (document.getElementById('cont_html_100').value.length == 0) {
		cont=cont+1;
		if (cont == 1) {
			error=error+"Título:\n"
			}
		error=error+"     El título no puede estar vacío\n";
		}
	if (document.getElementById('cont_html_100').value.length > 500) {
		cont=cont+1;
		if (cont == 1) {
			error=error+"Título:\n"
			}
		error=error+"     El título no puede superar los 500 carácteres\n";
		}
	return error;
	}
	
function addBookmark()
{
  if (window.external)
    external.AddFavorite("http://www.codenet.es", "www.codenet.es")
  else
	alert("Su navegador no soporta esta caracteristica");
}

function CapturaTecla(e) {
	var tecla;
	/*if(document.all)
		tecla=event.keyCode;
	else {
		tecla=e.which; 
	}*/
	var code; 
	if(document.all) code = event.keyCode; 
	else code = e.which;
	if(code==13) {
		//alert('si');
		getSearch(200,0);
	}
	return true;
} 

/*function validateForm() {
	
	var formObj = 'document.parserForm';		
	arrayLen = formElement.length;
	//validation routine
	for (a = 0; a < arrayLen; a++) {
		if (eval(formObj+'.'+formElement[a]) && !document.getElementById(formElement[a]).disabled) {
//			if (eval(formObj+'.'+formElement[a]).name.indexOf("mail") > -1){
//				 if (validateEmail(eval(formObj+'.'+formElement[a]).value) == false) {
//				 	return false;
//					}
//				}
		/*	if (!eval(formObj+'.'+formElement[a]).value){
				alert(alertMsg[a]);
				eval(formObj+'.'+formElement[a]).focus();
				return false;				
				}
			}
		}
	//submitting data
	eval(formObj).submit();
}*/

function validateForm(formDesc) {
	var formObj = 'document.'+formDesc.name;
	arrayLen = formElement.length;
	//validation routine
	for (a = 0; a < arrayLen; a++) {
		if (eval(formObj+'.'+formElement[a]) && !document.getElementById(formElement[a]).disabled) {
			if (eval(formObj+'.'+formElement[a]).name.indexOf("mail") > -1){
				 if (validateEmail(eval(formObj+'.'+formElement[a]).value) == false) {
				 	return false;
				 	}
				}
			if (!eval(formObj+'.'+formElement[a]).value){
				alert(alertMsg[a]);
				eval(formObj+'.'+formElement[a]).focus();
				return false;				
				}
			}
		}
	//submitting data
	eval(formObj).submit();
}

/*function validateEmail(email){
	var error;
	error = false;
	posicion = email.indexOf("@");
	switch (posicion) {
		case -1:
			error = true;
		case 0:
			error = true;
		case email.length-1:
			error = true;
		default:
			email = email.substr(posicion+1);
			posicion = email.indexOf("@");
			if (posicion>-1) {
				error = true;
				}
		posicion=email.indexOf(".");
		if (posicion==-1)
		{
//			window.alert("La parte del servidor debe contener un carácter ''.''");
			error = true;
		}
		if (posicion==0)
		{
//			window.alert("El carácter ''.'' no puede estar al principio de la parte del servidor");
			error = true;
		}
		while (posicion>-1)
		{				
			if (posicion==email.length-1)
			{
//				window.alert("El carácter ''.'' no puede estar al final de la parte del servidor");
				error = true;
			}
			email=email.substr(posicion+1);
			posicion=email.indexOf(".");
		}
	}
	if (error == true){ 
		alert("Debe proveer una dirección de correo electrónico válida.")
		return false;
	}
	else return true;
}*/

function validateEmail(email){
	var error;
	error = false;
	posicion = email.indexOf("@");
	switch (posicion) {
		case -1:
			error = true;
		case 0:
			error = true;
		case email.length-1:
			error = true;
		default:
			email = email.substr(posicion+1);
			posicion = email.indexOf("@");
			if (posicion>-1) {
				error = true;
				}
		posicion=email.indexOf(".");
		if (posicion==-1)
		{
//			window.alert("La parte del servidor debe contener un carácter ''.''");
			error = true;
		}
		if (posicion==0)
		{
//			window.alert("El carácter ''.'' no puede estar al principio de la parte del servidor");
			error = true;
		}
		while (posicion>-1)
		{				
			if (posicion==email.length-1)
			{
//				window.alert("El carácter ''.'' no puede estar al final de la parte del servidor");
				error = true;
			}
			email=email.substr(posicion+1);
			posicion=email.indexOf(".");
		}
	}
	if (error == true){ 
		alert("Debe proveer una dirección de correo electrónico válida.")
		return false;
	}
	else return true;
}

function valida_nif_cif_nie(cif) {
//returns: 1 = NIF ok, 2 = CIF ok, 3 = NIE ok, -1 = NIF bad, -2 = CIF bad, -3 = NIE bad, 0 = ??? bad
//función creada por David Vidal Serra, Copyleft 2005
		var suma, aux, n, n1, n2;
		var num = new Array;
        cif = cif.toUpperCase();
		var date_regex = /^[A-Z]{1}[0-9]{7}[A-Z0-9]{1}$|^[T]{1}[A-Z0-9]{8}$|^[0-9]{8}[A-Z]{1}$/;
        if (!date_regex.test(cif)) {
			return 0;
		}
        for (i=0;i<9;i++) {
			num[i]=cif.substr(i,1);
		}
        suma=parseInt(num[2])+parseInt(num[4])+parseInt(num[6]);
        for (i=1;i<8;i+=2) {
			aux = (2*parseInt(num[i])).toString();
			if (aux < 10) {
				aux = '0' + aux;
			}
			n1 = aux.toString();
			suma += parseInt(n1.substr(0,1)) + parseInt(n1.substr(1,1));
		}
		n2 = suma.toString();
		n = 10 - parseInt(n2.substr(n2.length-1,1));
		date_regex = /^[ABCDEFGHNPQS]{1}/;
        if (date_regex.test(cif)) {
			n = n.toString();
            if (num[8] == String.fromCharCode(n + 64) || num[8] == n.substr(n.length-1,1)){
				return 2;
			} else {
				return -2;
			}
		}
		date_regex = /^[KLM]{1}/;
        if (date_regex.test(cif)) {
			n = n.toString();
			if (num[8] == String.fromCharCode(n + 64)) {
				return 2;
			} else {
				return -2;
			}
		}
		
		date_regex = /^[TX]{1}/;
        if (date_regex.test(cif)) {
			cif = cif.replace('X', '0');
			date_regex = /^[T]{1}[A-Z0-9]{8}$/;
			if (num[8]=='TRWAGMYFPDXBNJZSQVHLCKE'.substr(cif.substr(0,8)%23,1) || date_regex.test(cif)) {
			//substr('TRWAGMYFPDXBNJZSQVHLCKE',substr(ereg_replace('X','0',cif),0,8)%23,1) || ereg('^[T]{1}[A-Z0-9]{8}$',cif))
				return 3;
			} else {
				return -3;
			}
		}
		date_regex = /^[0-9]{8}[A-Z]{1}$/;
        if (date_regex.test(cif)) {
            if ( num[8] == 'TRWAGMYFPDXBNJZSQVHLCKE'.substr(cif.substr(0,8)%23,1)) {
				return 1;
			} else {
				return -1;
			}
		}
        return 0;
} 
