// JavaScript Document

function NewWindow(mypage,myname,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
win = window.open(mypage,myname,settings)
if(win.window.focus){win.window.focus();}
}

function chkLongitudCadenaForm(cadena,formulario){
	if (cadena=="") {longitud = 0}else{longitud = cadena.length}
	if (longitud <=2 ){
		event.returnValue=false;
		alert("Debe proporcionar información más precisa");
	}else{
		eval("document." + formulario + ".submit();")
	}

}

	function checkOpinionNoticia(){
		if(document.formCarta.nom.value=="" || document.formCarta.nom.value.length < 3){
			event.returnValue=false;
			alert("Por favor, rellenar el campo Nombre");
		}
		else if(document.formCarta.email.value=="" || document.formCarta.email.value.length < 4){
			event.returnValue=false;
			alert("Por favor, rellenar el campo Email");
		}
		else if(document.formCarta.ciudad.value=="" || document.formCarta.ciudad.value.length < 4){
			event.returnValue=false;
			alert("Por favor, rellenar el campo Ciudad");
		}
		else if(document.formCarta.apellidos.value=="" || document.formCarta.apellidos.value.length < 3){
			event.returnValue=false;
			alert("Por favor, rellenar el campo Apellidos");
		}
		else if(document.formCarta.pais.value=="" || document.formCarta.pais.value.length < 4){
			event.returnValue=false;
			alert("Por favor, rellenar el campo Pais");
		}
		else if(document.formCarta.opinion.value=="" || document.formCarta.opinion.value.length < 4){
			event.returnValue=false;
			alert("Por favor, rellenar el campo Comentarios");
		}
		else if(document.formCarta.opinion.value.length >580){
			event.returnValue=false;
			alert("El comentario no debe superar las 10 líneas");
		}
		
		else if(document.formCarta.email.value.indexOf("@",0)<0 ||  ! isNaN(document.formCarta.email.value.substring(0,1)) || document.formCarta.email.value.indexOf(".",0)<0)
			{
			event.returnValue=false;
			alert("El campo E-mail es incorrecto");
		}
	}

	function checkCarta(){
		if(document.formCarta.nom.value==""){
			event.returnValue=false;
			alert("Por favor, rellenar el campo Nombre");
		}
		else if(document.formCarta.email.value==""){
			event.returnValue=false;
			alert("Por favor, rellenar el campo Email");
		}
		else if(document.formCarta.lugar.value==""){
			event.returnValue=false;
			alert("Por favor, rellenar el campo Ciudad");
		}
		else if(document.formCarta.pais.value==""){
			event.returnValue=false;
			alert("Por favor, rellenar el campo Pais");
		}
		else if(document.formCarta.carta.value==""){
			event.returnValue=false;
			alert("Por favor, rellenar el campo Carta");
		}
		else if(document.formCarta.asunto.value==""){
			event.returnValue=false;
			alert("Por favor, rellenar el campo Asunto");
		}
		else if(document.formCarta.email.value.indexOf("@",0)<0 ||  ! isNaN(document.formCarta.email.value.substring(0,1)) || document.formCarta.email.value.indexOf(".",0)<0)
			{
			event.returnValue=false;
			alert("El campo E-mail es incorrecto");
		}
	}
	function checkSugerir(){
		if(document.formSugerir.nom.value==""){
			event.returnValue=false;
			alert("Por favor, rellenar el campo Nombre");
		}
		else if(document.formSugerir.ape.value==""){
			event.returnValue=false;
			alert("Por favor, rellenar el campo Apellido");
		}
		else if(document.formSugerir.ema.value==""){
			event.returnValue=false;
			alert("Por favor, rellenar el campo Email");
		}
		else if(document.formSugerir.ciu.value==""){
			event.returnValue=false;
			alert("Por favor, rellenar el campo Ciudad");
		}
		else if(document.formSugerir.pai.value==""){
			event.returnValue=false;
			alert("Por favor, rellenar el campo Pais");
		}
		else if(document.formSugerir.sug.value==""){
			event.returnValue=false;
			alert("Por favor, rellenar el campo Sugerencia");
		}
		else if (!isNaN(document.formSugerir.nom.value)){
			event.returnValue=false;
			alert("El campo Nombre no es numerico. Por favor, introducir solo letras.");
		}
		else if (!isNaN(document.formSugerir.ape.value)){
			event.returnValue=false;
			alert("El campo Apellido no es numerico. Por favor, introducir solo letras.");
		}
		else if (!isNaN(document.formSugerir.ciu.value)){
			event.returnValue=false;
			alert("El campo Ciudad no es numerico. Por favor, introducir solo letras.");
		}
		else if (!isNaN(document.formSugerir.pai.value)){
			event.returnValue=false;
			alert("El campo Pais no es numerico. Por favor, introducir solo letras.");
		}
		else if(document.formSugerir.ema.value.indexOf("@",0)<0 ||  ! isNaN(document.formSugerir.ema.value.substring(0,1)) || document.formSugerir.ema.value.indexOf(".",0)<0){
				event.returnValue=false;
				alert("Su dirección de correo electrónico falta @ o el punto, o empieza con un número.");	
		}
	}

	function checkSuscripcion(){
		if(document.formsuscripcion.nom.value=="" || document.formsuscripcion.nom.value.length <3){

			event.returnValue=false;
			alert("Por favor, rellenar el campo Nombre");
		}
		else if(document.formsuscripcion.apellidos.value=="" || document.formsuscripcion.apellidos.value.length <3){

			event.returnValue=false;
			alert("Por favor, rellenar el campo Apellidos");
		}
		else if(document.formsuscripcion.email.value==""){

			event.returnValue=false;
			alert("Por favor, rellenar el campo E-mail");
		}
		else if(document.formsuscripcion.lugar.value==""){
			event.returnValue=false;
			alert("Por favor, rellenar el campo Ciudad/Pais");
		}
		else if(document.formsuscripcion.email.value.indexOf("@",0)<0 ||  ! isNaN(document.formsuscripcion.email.value.substring(0,1)) || document.formsuscripcion.email.value.indexOf(".",0)<0){
			event.returnValue=false;
			alert("El campo E-mail es incorrecto");
		}
		else if(document.formsuscripcion.okpolitica.checked == false){
				event.returnValue = false;
				alert("Debe aceptar la 'Política de Privacidad'");
		}
	}

	function checkBusquedaav(){
	var palabras = new Array("es","as","yo","tu","el","ella","nosotros","vosotros","nosotras","vosotras","ellos","ellas","the", "and", "he", "or", "it", "an", "of", "if", "me", "is", "to", "no", "in", "la", "las", "lo", "les", "le", "se", "si", "los", "el", "de", "yo", "tu", "que", "del", "en", "con", "al");
	var contador = 0;
		x="http://www.canalsocial.net/GER/enciclopedia.asp?";
		txt = document.formbusquedaav.texto.value
		switch(document.formbusquedaav.donde.options.selectedIndex){
			case 0:
				sdonde = "TITULO"
				break;
			case 1:
				sdonde = "CONTENIDO"
			break;
			case 2:
				sdonde = "TODO"
			break;
		}
			
		contador = 0;
		ok = true;
		if(txt == "" || txt.length < 2){
			ok = false;
			event.returnValue=false;
			alert("Por favor, introduzca información mas precisa");	
		}
		while (contador < palabras.length){
			if(document.formbusquedaav.texto.value.toLowerCase() == palabras[contador]){
				ok=false;
				event.returnValue=false;
				alert("Por favor, introduzca información mas precisa");
			}
			contador = contador + 1;
		}
		seleccionado = false;
		catselec = ""
		strcatselec = ""
		for (var i=0;i<document.formbusquedaav.elements.length;i++)
      { 
         var e = document.formbusquedaav.elements[i];
         if (e.type == 'checkbox' && e.name != 'allbox' && e.name != 'idem'){
			if (e.checked){
				seleccionado = true;
				switch(e.value){
					case "biografiasuelta":
						catselec = catselec + "biografiasuelta$"
						//strcatselec = strcatselec + "Biografía$"
						break;
					case "antropologia":
						catselec = catselec + "antropologia$"
						//strcatselec = strcatselec + "Antropología$"
						break;
					case "arte":
						catselec = catselec + "arte$"
						//strcatselec = strcatselec + "Arte$"
						break;
					case "biologia":
						catselec = catselec + "biologia$"
						//strcatselec = strcatselec + "Biología$"
						break;
					case "ciencia":
						catselec = catselec + "ciencia$"
						//strcatselec = strcatselec + "Ciencia$"
						break;
					case "cultura":
						catselec = catselec + "cultura$"
						//strcatselec = strcatselec + "Cultura$"
						break;
					case "derecho":
						catselec = catselec + "derecho$"
						//strcatselec = strcatselec + "Derecho$"
						break;
					case "economia":
						catselec = catselec + "economia$"
						//strcatselec = strcatselec + "Economía$"
						break;
					case "educacion":
						catselec = catselec + "educacion$"
						//strcatselec = strcatselec + "Educación$"
						break;
					case "etica":
						catselec = catselec + "etica$"
						//strcatselec = strcatselec + "Ética$"
						break;
					case "filosofia":
						catselec = catselec + "filosofia$"
						//strcatselec = strcatselec + "Filosofía$"
						break;
					case "fisica":
						catselec = catselec + "fisica$"
						//strcatselec = strcatselec + "Física$"
						break;
					case "geografia":
						catselec = catselec + "geografia$"
						//strcatselec = strcatselec + "Geografía$"
						break;
					case "geologia":
						catselec = catselec + "geologia$"
						//strcatselec = strcatselec + "Geología$"
						break;
					case "historia":
						catselec = catselec + "historia$"
						//strcatselec = strcatselec + "Historia$"
						break;
					case "historiaiglesia":
						catselec = catselec + "historiaiglesia$"
						//strcatselec = strcatselec + "Historia de la Iglesia$"
						break;
					case "literatura":
						catselec = catselec + "literatura$"
						//strcatselec = strcatselec + "Literatura$"
						break;
					case "matematicas":
						catselec = catselec + "matematicas$"
						//strcatselec = strcatselec + "Matemáticas$"
						break;
					case "medicina":
						catselec = catselec + "medicina$"
						//strcatselec = strcatselec + "Medicina$"
						break;
					case "medioinformacion":
						catselec = catselec + "medioinformacion$"
						//strcatselec = strcatselec + "Medios de información$"
						break;
					case "musica":
						catselec = catselec + "musica$"
						//strcatselec = strcatselec + "Música$"
						break;
					case "politica":
						catselec = catselec + "politica$"
						//strcatselec = strcatselec + "Política$"
						break;
					case "quimica":
						catselec = catselec + "quimica$"
						//strcatselec = strcatselec + "Química$"
						break;
					case "religioncristiana":
						catselec = catselec + "religioncristiana$"
						//strcatselec = strcatselec + "Religión Cristiana$"
						break;
					case "religionnocristiana":
						catselec = catselec + "religionnocristiana$"
						//strcatselec = strcatselec + "Religión No Cristiana$"
						break;
					case "sociologia":
						catselec = catselec + "sociologia$"
						//strcatselec = strcatselec + "Sociología$"
						break;
					case "tecnologia":
						catselec = catselec + "tecnologia$"
						//strcatselec = strcatselec + "Tecnología$"
						break;
					case "teologia":
						catselec = catselec + "teologia$"
						//strcatselec = strcatselec + "Teología$"
						break;
					case "varios":
						catselec = catselec + "varios$"
						//strcatselec = strcatselec + "Varios$"
						break;
				}
			}
			}
    	}

		if (seleccionado == false){
			ok = false;
			event.returnValue=false;
			alert("Debe seleccionar almenos una categoría");
		}
		if (ok== true){
			x+="texto=" + txt + "&catselec=" + catselec + "&donde=" + sdonde + "&wh=AV"
				document.location.href = x;
				event.returnValue=false;
		}
	}

function CheckAll()
   { 
     for (var i=0;i<document.formbusquedaav.elements.length;i++)
      { 
         var e = document.formbusquedaav.elements[i];
         if (e.type == 'checkbox' && e.name != 'allbox' && e.name != 'idem')
            e.checked = document.formbusquedaav.allbox.checked;
    }
   }
   
   
   
   
   

// Parte para el GER del admin

function checkBusquedaav_admin(){
	var palabras = new Array("es","as","yo","tu","el","ella","nosotros","vosotros","nosotras","vosotras","ellos","ellas","the", "and", "he", "or", "it", "an", "of", "if", "me", "is", "to", "no", "in", "la", "las", "lo", "les", "le", "se", "si", "los", "el", "de", "yo", "tu", "que", "del", "en", "con", "al");
	var contador = 0;
		x="http://www.canalsocial.net/admin/GER/enciclopedia.asp?";
		txt = document.formbusquedaav.texto.value
		switch(document.formbusquedaav.donde.options.selectedIndex){
			case 0:
				sdonde = "TITULO"
				break;
			case 1:
				sdonde = "CONTENIDO"
			break;
			case 2:
				sdonde = "TODO"
			break;
		}
			
		contador = 0;
		ok = true;
		if(txt == "" || txt.length < 2){
			ok = false;
			event.returnValue=false;
			alert("Por favor, introduzca información mas precisa");	
		}
		while (contador < palabras.length){
			if(document.formbusquedaav.texto.value.toLowerCase() == palabras[contador]){
				ok=false;
				event.returnValue=false;
				alert("Por favor, introduzca información mas precisa");
			}
			contador = contador + 1;
		}
		seleccionado = false;
		catselec = ""
		strcatselec = ""
		for (var i=0;i<document.formbusquedaav.elements.length;i++)
      { 
         var e = document.formbusquedaav.elements[i];
         if (e.type == 'checkbox' && e.name != 'allbox' && e.name != 'idem'){
			if (e.checked){
				seleccionado = true;
				switch(e.value){
					case "biografiasuelta":
						catselec = catselec + "biografiasuelta$"
						//strcatselec = strcatselec + "Biografía$"
						break;
					case "antropologia":
						catselec = catselec + "antropologia$"
						//strcatselec = strcatselec + "Antropología$"
						break;
					case "arte":
						catselec = catselec + "arte$"
						//strcatselec = strcatselec + "Arte$"
						break;
					case "biologia":
						catselec = catselec + "biologia$"
						//strcatselec = strcatselec + "Biología$"
						break;
					case "ciencia":
						catselec = catselec + "ciencia$"
						//strcatselec = strcatselec + "Ciencia$"
						break;
					case "cultura":
						catselec = catselec + "cultura$"
						//strcatselec = strcatselec + "Cultura$"
						break;
					case "derecho":
						catselec = catselec + "derecho$"
						//strcatselec = strcatselec + "Derecho$"
						break;
					case "economia":
						catselec = catselec + "economia$"
						//strcatselec = strcatselec + "Economía$"
						break;
					case "educacion":
						catselec = catselec + "educacion$"
						//strcatselec = strcatselec + "Educación$"
						break;
					case "etica":
						catselec = catselec + "etica$"
						//strcatselec = strcatselec + "Ética$"
						break;
					case "filosofia":
						catselec = catselec + "filosofia$"
						//strcatselec = strcatselec + "Filosofía$"
						break;
					case "fisica":
						catselec = catselec + "fisica$"
						//strcatselec = strcatselec + "Física$"
						break;
					case "geografia":
						catselec = catselec + "geografia$"
						//strcatselec = strcatselec + "Geografía$"
						break;
					case "geologia":
						catselec = catselec + "geologia$"
						//strcatselec = strcatselec + "Geología$"
						break;
					case "historia":
						catselec = catselec + "historia$"
						//strcatselec = strcatselec + "Historia$"
						break;
					case "historiaiglesia":
						catselec = catselec + "historiaiglesia$"
						//strcatselec = strcatselec + "Historia de la Iglesia$"
						break;
					case "literatura":
						catselec = catselec + "literatura$"
						//strcatselec = strcatselec + "Literatura$"
						break;
					case "matematicas":
						catselec = catselec + "matematicas$"
						//strcatselec = strcatselec + "Matemáticas$"
						break;
					case "medicina":
						catselec = catselec + "medicina$"
						//strcatselec = strcatselec + "Medicina$"
						break;
					case "medioinformacion":
						catselec = catselec + "medioinformacion$"
						//strcatselec = strcatselec + "Medios de información$"
						break;
					case "musica":
						catselec = catselec + "musica$"
						//strcatselec = strcatselec + "Música$"
						break;
					case "politica":
						catselec = catselec + "politica$"
						//strcatselec = strcatselec + "Política$"
						break;
					case "quimica":
						catselec = catselec + "quimica$"
						//strcatselec = strcatselec + "Química$"
						break;
					case "religioncristiana":
						catselec = catselec + "religioncristiana$"
						//strcatselec = strcatselec + "Religión Cristiana$"
						break;
					case "religionnocristiana":
						catselec = catselec + "religionnocristiana$"
						//strcatselec = strcatselec + "Religión No Cristiana$"
						break;
					case "sociologia":
						catselec = catselec + "sociologia$"
						//strcatselec = strcatselec + "Sociología$"
						break;
					case "tecnologia":
						catselec = catselec + "tecnologia$"
						//strcatselec = strcatselec + "Tecnología$"
						break;
					case "teologia":
						catselec = catselec + "teologia$"
						//strcatselec = strcatselec + "Teología$"
						break;
					case "varios":
						catselec = catselec + "varios$"
						//strcatselec = strcatselec + "Varios$"
						break;
				}
			}
			}
    	}

		if (seleccionado == false){
			ok = false;
			event.returnValue=false;
			alert("Debe seleccionar almenos una categoría");
		}
		if (ok== true){
			x+="texto=" + txt + "&catselec=" + catselec + "&donde=" + sdonde + "&wh=AV"
				document.location.href = x;
				event.returnValue=false;
		}
	}


