function urlActual(){
	url = document.location.href;
	partes = url.split('..\\..\\index.html');
	// obtención del nombre de la página, la última parte de la url y sus parámetros.
	return partes[partes.length-1]+partes[partes.length-2];
}
		
/////////* inicio formulario contacto */
	// MOSTRAR FORMULARIO
	if(navigator.appName == "Netscape"){
		function mostrar_ocultar(){
			if(urlActual().match("contacto") != null || urlActual().match("informacion-de-contacto") != null || urlActual().match("ayuda-y-soporte") != null || urlActual().match("diseno-web") != null || urlActual().match("dominios-tel") != null){
				cargarVacio();
				document.location.href="..\\corporativo\\contacto.html";
				return;
			}
			
			maxInterval=0;
			minInterval=0;
			if(document.getElementById('micontactoform').style.display == "none"){
				opfx = 0.1;
				document.getElementById('micontactoform').style.opacity = opfx;
				document.getElementById('micontactoform').style.display = "";
				maxInterval=window.setInterval("maxOpacidad()", 100);
			}else{
				opfx = 1;
				minInterval=window.setInterval("minOpacidad()", 100);
			}
			
		}
		function maxOpacidad(){
			if(opfx <= 1){
				opfx = opfx + 0.25;
				document.getElementById('micontactoform').style.opacity = opfx;
			}else{
				maxInterval=window.clearInterval(maxInterval);
			}
		}
		function minOpacidad(){
			if(opfx >= 0){
				opfx = opfx - 0.25;
				document.getElementById('micontactoform').style.opacity = opfx;
			}else{
				minInterval=window.clearInterval(minInterval);
				document.getElementById('micontactoform').style.display="none";
			}
		}
	} // if Netscape
	if(navigator.appName == "Microsoft Internet Explorer"){
		function mostrar_ocultar(){
			if(urlActual().match("contacto") != null || urlActual().match("informacion-de-contacto") != null || urlActual().match("ayuda-y-soporte") != null || urlActual().match("diseno-web") != null || urlActual().match("dominios-tel") != null){
				cargarVacio();
				document.location.href="..\\corporativo\\contacto.html";
				return;
			}

			cadena_version = navigator.appVersion;
			pos_version = navigator.appVersion.indexOf("MSIE");
			cadena_version = cadena_version.substr(pos_version,8);
			version = cadena_version.substr(5,3);
			if(version == "8.0"){ // sin efecto Alpha // Explorer 8.0
				if(document.getElementById('micontactoform').style.display == "none"){
					document.getElementById('micontactoform').style.display = "";
				}else{
					document.getElementById('micontactoform').style.display = "none";
				}
			}else{
				maxInterval=0;
				minInterval=0;
				if(document.getElementById('micontactoform').style.display == "none"){
					opie = 10;
					document.getElementById("micontactoform").filters.item("DXImageTransform.Microsoft.Alpha").Opacity = opie;
					document.getElementById('micontactoform').style.display = "";
					maxInterval=window.setInterval("maxOpacidad()", 100);
				}else{
					opie = 100;
					minInterval=window.setInterval("minOpacidad()", 100);
				}
			}
		}
		function maxOpacidad(){
			if(opie <= 100){
				opie = opie + 25;
				document.getElementById("micontactoform").filters.item("DXImageTransform.Microsoft.Alpha").Opacity = opie;
			}else{
				maxInterval=window.clearInterval(maxInterval);
			}
		}
		function minOpacidad(){
			if(opie >= 0){
				opie = opie - 25;
				document.getElementById("micontactoform").filters.item("DXImageTransform.Microsoft.Alpha").Opacity = opie;
			}else{
				minInterval=window.clearInterval(minInterval);
				document.getElementById('micontactoform').style.display="none";
			}
		}
	} // Explorer 6.0 - 7.0
	// FIN MOSTRAR FORMULARIO
	
	// rollovers campos formulario
	function over(id){
		document.getElementById(id).style.background="#fff";
		document.getElementById(id).style.color="#3e8313";
	}
	function out(id){
		document.getElementById(id).style.background="#e0e0e0";
		document.getElementById(id).style.color="#666";
	}
	// fin rollovers campos formulario
	
	// vaciar campos al pulsar en ellos y llenarlos al soltarlos vacios
	function vaciar(id){
		switch (id){
			case "nombre":
				if(document.getElementById(id).value == "Nombre y Apellidos...")document.getElementById(id).value="";
				break;
			case "email":
				if(document.getElementById(id).value == "Email...")document.getElementById(id).value="";
				break;
			case "telefono":
				if(document.getElementById(id).value == "Teléfono...")document.getElementById(id).value="";
				break;
			case "empresa":
				if(document.getElementById(id).value == "Empresa...")document.getElementById(id).value="";
				break;
			case "provincia":
				if(document.getElementById(id).value == "Provincia...")document.getElementById(id).value="";
				break;
			case "cargo":
				if(document.getElementById(id).value == "Cargo...")document.getElementById(id).value="";
				break;
			case "codigo":
				if(document.getElementById(id).value == "Introduce el código de la imagen...")document.getElementById(id).value="";
				break;
			case "dominio":
				if(document.getElementById(id).value == "dominio...")document.getElementById(id).value="";
				break;
			case "form_email_alta":
				if(document.getElementById(id).value == "Email...")document.getElementById(id).value="";
				break;
			case "form_email_baja":
				if(document.getElementById(id).value == "Email...")document.getElementById(id).value="";
				break;
		}
		//document.getElementById(id).value="";
	}
	function llenar(id,valor){
		if(document.getElementById(id).value==""){
			document.getElementById(id).value=valor;
		}
	}
	// fin vaciar campos al pulsar en ellos y llenarlos al soltarlos vacios
	
	function ValidarForm(form) {
		var form = document.forms[form.id];
		var errors='';
		var nom = form.nombre.value;
		var com = form.comentarios.value;
		var nom_valido=nom.match(/[^a-zA-Z áéíóúüÁÉÍÓÚÜÑñÇç·.]/);
		var com_valido=com.match(/[^a-zA-Z0-9 áéíóúüÁÉÍÓÚÜÑñÇç·.()-_\n][\n]/);
		if (form.motivo.value == ""){
			document.getElementById("f_motivo").style.background = "#fec141";
			document.getElementById("f_motivo").style.border = "1px solid #fec141";
			errors = true;
		}else{
			document.getElementById("f_motivo").style.background = "";
			document.getElementById("f_motivo").style.border = "";
		}
		if (form.nombre.value == "" || nom_valido != null || form.nombre.value == "Nombre y Apellidos..."){
			document.getElementById("f_nombre").style.background = "#fec141";
			errors = true;
		}else{
			document.getElementById("f_nombre").style.background = "";
		}
		if ((form.email.value == "")||(!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(form.email.value)))){
			document.getElementById("f_email").style.background = "#fec141";
			errors = true;
		}else{
			document.getElementById("f_email").style.background = "";
		}
		if (form.telefono.value == ""){
			document.getElementById("f_telefono").style.background = "#fec141";
			errors = true;
		}else{
			// Puede empezar con + o con un numero
			elemOk1 = form.telefono.value.substr(0,1) == "+" || !isNaN(form.telefono.value.substr(0,1));
			// Tiene entre 9 y 20 caracteres
			elemOk2 = form.telefono.value.length >= 9 && form.telefono.value.length <= 20;
			// Todos los caracteres son numeros excepto el primero que podia ser un +
			for(j=1;j<form.telefono.value.length;j++){
				if(form.telefono.value.substr(j,1) == " " || !isNaN(form.telefono.value.substr(j,1))){
					elemOk3 = true;
				}else{
					elemOk3	= false;
					break;
				}
			}
			elemOk = elemOk1 && elemOk2 && elemOk3;
		}
		if (!elemOk) {
			document.getElementById("f_telefono").style.background = "#fec141";
			errors = true;
		} else {
			document.getElementById("f_telefono").style.background = "";
		}
			
		if (form.empresa.value == "" || form.empresa.value == "Empresa..."){
			document.getElementById("f_empresa").style.background = "#fec141";
			errors = true;
		}else{
			document.getElementById("f_empresa").style.background = "";
		}
		if (form.provincia.value == "" || form.provincia.value == "Provincia..."){
			document.getElementById("f_provincia").style.background = "#fec141";
			errors = true;
		}else{
			document.getElementById("f_provincia").style.background = "";
		}
		if ((form.comentarios.value == "")||(com_valido != null)){
			document.getElementById("f_comentarios").style.background = "#fec141";
			document.getElementById("f_comentarios").style.color = "#ffffff";
			errors = true;
		}else{
			document.getElementById("f_comentarios").style.background = "";
			document.getElementById("f_comentarios").style.color = "";
		}
		if (form.codigo.value == "" || form.codigo.value.length != 6){
			document.getElementById("f_codigo").style.background = "#fec141";
			errors = true;
		}else{
			document.getElementById("f_codigo").style.background = "";
		}
		if (form.acepta.checked == false){
			document.getElementById("f_acepta").style.background = "#fec141";
			document.getElementById("f_acepta").style.color = "#ffffff";
			errors = true;
		}else{
			document.getElementById("f_acepta").style.background = "";
			document.getElementById("f_acepta").style.color = "";
		}

		if (errors) {
			return false;
		}else{
			cargarContenidoContactoOk(form);
		}
	}
	function nuevoAjax(){
		var xmlhttp=false;
		try {
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (E) {
				xmlhttp = false;
			}
		}
		if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
			xmlhttp = new XMLHttpRequest();
		}
		return xmlhttp;
	}
	function cargarContenidoContactoOk(form){
		t1 = document.getElementById("motivo").value;
		t2 = document.getElementById("nombre").value;
		t3 = document.getElementById("email").value;
		t4 = document.getElementById("telefono").value;
		t5 = document.getElementById("empresa").value;
		t6 = document.getElementById("provincia").value;
		t7 = document.getElementById("comentarios").value;
		t8 = document.getElementById("codigo").value;
		t9 = document.getElementById("agente").value;
		t10 = document.getElementById("seccion").value;
		t11 = document.getElementById("idioma").value;
		t12 = document.getElementById("charset").value;
		t13 = document.getElementById("dpto").value;
		t14 = form.acepta.checked;
		t15 = document.getElementById("formulario").value;
		if(document.getElementById("formulario").value == "Cabecera"){
			id = document.getElementById('contaj_cab');
		}else{
			id = document.getElementById('contaj');
			if(document.getElementById("formulario").value == "Legal"){
				t16 = document.getElementById("cargo").value;
				t17 = form.chk_mcomunitaria.checked;
				t18 = form.chk_mnacional.checked;
				t19 = form.chk_minternacional.checked;
				t20 = form.chk_pdatos.checked;
				t21 = form.chk_psoftware.checked;
				t22 = form.chk_pweb.checked;
				t23 = form.chk_auditoria.checked;
			}else if(document.getElementById("formulario").value == "Dominios tel"){
				t16 = document.getElementById("dominio").value;
			}
		}
		ajax=nuevoAjax();
		ajax.open("POST", "f_contactoOk.php.html",true);
		ajax.onreadystatechange=function() {
			if (ajax.readyState==4) {
				id.innerHTML = ajax.responseText
			}
		}
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; text/html; charset=iso-8859-1");
		
		if(document.getElementById("formulario").value == "Legal"){
			ajax.send("motivo="+t1+"&nombre="+t2+"&email="+t3+"&telefono="+t4+"&empresa="+t5+"&provincia="+t6+"&comentarios="+t7+"&codigo="+t8+"&agente="+t9+"&seccion="+t10+"&idioma="+t11+"&charset="+t12+"&dpto="+t13+"&acepta="+t14+"&formulario="+t15+"&cargo="+t16+"&chk_mcomunitaria="+t17+"&chk_mnacional="+t18+"&chk_minternacional="+t19+"&chk_pdatos="+t20+"&chk_psoftware="+t21+"&chk_pweb="+t22+"&chk_auditoria="+t23);
		}else if(document.getElementById("formulario").value == "Dominios tel"){
			ajax.send("motivo="+t1+"&nombre="+t2+"&email="+t3+"&telefono="+t4+"&empresa="+t5+"&provincia="+t6+"&comentarios="+t7+"&codigo="+t8+"&agente="+t9+"&seccion="+t10+"&idioma="+t11+"&charset="+t12+"&dpto="+t13+"&acepta="+t14+"&formulario="+t15+"&dominio="+t16);
		}else{
			ajax.send("motivo="+t1+"&nombre="+t2+"&email="+t3+"&telefono="+t4+"&empresa="+t5+"&provincia="+t6+"&comentarios="+t7+"&codigo="+t8+"&agente="+t9+"&seccion="+t10+"&idioma="+t11+"&charset="+t12+"&dpto="+t13+"&acepta="+t14+"&formulario="+t15);
		}
		
	}
	function cargarContenidoContactoError(){
		t1 = document.getElementById("motivo").value;
		t2 = document.getElementById("nombre").value;
		t3 = document.getElementById("email").value;
		t4 = document.getElementById("telefono").value;
		t5 = document.getElementById("empresa").value;
		t6 = document.getElementById("provincia").value;
		t7 = document.getElementById("comentarios").value;
		t8 = document.getElementById("seccion").value;
		if(document.getElementById("formulario").value == "Cabecera"){
			id = document.getElementById('contaj_cab');
		}else{
			id = document.getElementById('contaj');
		}
		ajax=nuevoAjax();
		ajax.open("POST", "f_contacto.php.html",true);
		ajax.onreadystatechange=function() {
			if (ajax.readyState==4) {
				id.innerHTML = ajax.responseText
			}
		}
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; text/html; charset=iso-8859-1");
		ajax.send("motivo="+t1+"&nombre="+t2+"&email="+t3+"&telefono="+t4+"&empresa="+t5+"&provincia="+t6+"&comentarios="+t7+"&seccion="+t8);
	}
	function cargarContenidoContacto(){
		id = document.getElementById('contaj_cab');
		ajax=nuevoAjax();
		ajax.open("POST", "f_contacto.php.html",true);
		ajax.onreadystatechange=function() {
			if (ajax.readyState==4) {
				id.innerHTML = ajax.responseText
			}
		}
		ajax.send(null);
	}
	function cargarVacio(){	
		id = document.getElementById('contaj_cab');
		ajax=nuevoAjax();
		ajax.open("POST", "f_contactoVacio.php.html",true);
		ajax.onreadystatechange=function() {
			if (ajax.readyState==4) {
				id.innerHTML = ajax.responseText
			}
		}
		ajax.send(null);
	}
	random_img=0;
	function cargarContenidoImgSec(){
	   id = document.getElementById('img-php');
		random_img++;
	   ajax=nuevoAjax();
	   ajax.open("POST","f_contactoImgSec.php.html",true);
	   ajax.onreadystatechange=function() {
		  if (ajax.readyState==4) {
			 id.innerHTML = ajax.responseText;
		   }
	   }
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; text/html; charset=iso-8859-1");
		ajax.send("random_img="+random_img);
	}
		/* fin formulario contacto */

/* noticias home */		
	/*function cargarDatosNoticias(num,limit,maxchars,tipo){
		t1 = num;
		t2 = limit;
		t3 = maxchars;
		t4 = tipo;
		if(tipo == "noticias"){
			id = document.getElementById('noti');
		}else if(tipo == "eventos"){
			id = document.getElementById('even');
		}
		ajax=nuevoAjax();
		ajax.open("POST", "noticias_conn.php.html",true);
		ajax.onreadystatechange=function() {
			if (ajax.readyState==4) {
				id.innerHTML = ajax.responseText
			}
		}
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; text/html; charset=iso-8859-1");
		ajax.send("num="+t1+"&limit="+t2+"&maxchars="+t3+"&tipo="+t4);
	}
	function cargarNoticiaHome(num,tipo){
		t1 = num;
		t2 = tipo;
		if(tipo == "noticias"){
			id = document.getElementById('noti');
		}else if(tipo == "eventos"){
			id = document.getElementById('even');
		}
		ajax=nuevoAjax();
		ajax.open("POST", "noticias.php.html",true);
		ajax.onreadystatechange=function() {
			if (ajax.readyState==4) {
				id.innerHTML = ajax.responseText
			}
		}
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; text/html; charset=iso-8859-1");
		ajax.send("num="+t1+"&tipo="+t2);
	}*/
/* fin noticias home */	

/* noticias home */		
	function cargarNoticiaHome(num,tipo){
		t1 = num;
		t2 = tipo;
		if(tipo == "Actualidad"){
			id = document.getElementById('noti');
		}else if(tipo == "Eventos"){
			id = document.getElementById('even');
		}
		ajax=nuevoAjax();
		ajax.open("POST", "noticias2.php.html",true);
		ajax.onreadystatechange=function() {
			if (ajax.readyState==4) {
				id.innerHTML = ajax.responseText
			}
		}
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; text/html; charset=iso-8859-1");
		if(tipo == "Actualidad"){
			ajax.send("numNot="+t1+"&tipo="+t2);
		}else if(tipo == "Eventos"){
			ajax.send("numEve="+t1+"&tipo="+t2);
		}
	}
	function cargarDatosNoticias2(limitNot,limitEve,maxchars){
		t3 = limitNot;
		t4 = limitEve;
		t5 = maxchars;
		id = document.getElementById('noti');
		id2 = document.getElementById('even');
		ajax=nuevoAjax();
		ajax.open("POST", "noticias_conn2.php.html",true);
		ajax.onreadystatechange=function() {
			if (ajax.readyState==4) {
				id.innerHTML = ajax.responseText
			}
		}
		ajax2=nuevoAjax();
		ajax2.open("POST", "noticias_conn2.php.html",true);
		ajax2.onreadystatechange=function() {
			if (ajax2.readyState==4) {
				id2.innerHTML = ajax2.responseText
			}
		}
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; text/html; charset=iso-8859-1");
		ajax.send("limitNot="+t3+"&limitEve="+t4+"&maxchars="+t5+"&tipo=Actualidad");
		ajax2.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; text/html; charset=iso-8859-1");
		ajax2.send("limitNot="+t3+"&limitEve="+t4+"&maxchars="+t5+"&tipo=Eventos");
	}
	function cargarNoticiaHome2(numNot,numEve){
		t1 = numNot;
		t2 = numEve;
		id = document.getElementById('noti');
		id2 = document.getElementById('even');
		ajax=nuevoAjax();
		ajax.open("POST", "noticias2.php.html",true);
		ajax.onreadystatechange=function() {
			if (ajax.readyState==4) {
				id.innerHTML = ajax.responseText
			}
		}
		ajax2=nuevoAjax();
		ajax2.open("POST", "noticias2.php.html",true);
		ajax2.onreadystatechange=function() {
			if (ajax2.readyState==4) {
				id2.innerHTML = ajax2.responseText
			}
		}
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; text/html; charset=iso-8859-1");
		ajax.send("numNot="+t1+"&numEve="+t2+"&tipo=Actualidad");
		ajax2.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; text/html; charset=iso-8859-1");
		ajax2.send("numNot="+t1+"&numEve="+t2+"&tipo=Eventos");
	}
/* fin noticias home */	
