// JavaScript Document
function sendTaf(){
	var minom=document.getElementById('nombre_ori').value;
	var tunom=document.getElementById('nombre_dest').value;
	var tumail=document.getElementById('email_dest').value;
	var promo=document.getElementById('pid').value;
	var bpath=document.getElementById('bp').value;
	var filter=/^[A-Za-z][A-Za-z0-9_]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/;
	var Err=0;
	if (minom.length==0) Err=1;
	if (tunom.length==0) Err=1;
	if (tumail.length > 0 ) {
		if (!filter.test(tumail)) Err=1;
	}else{
		Err=1;
	}
	if (Err==1) {
		alert('Se han producido errores en el formulario. Verifique.');
	}else{
		var nn= new Array('minom',minom, 'tunom', tunom, 'tumail',tumail, 'promo', promo,'basepath',bpath,'error', Err);
		xx=bpath+'includes/taf.php';
		LNSR_ejecutar('taf','','GET',xx,'', nn);
	}
}



function showTaf(ac){
	var area=document.getElementById('taf');
	var mini=document.getElementById('minitaf');
	if (area && mini){

		if (ac==1){
			mini.style.display='none';
			area.style.display='block';
			document.getElementById('nombre_ori').focus();
		}
		if (ac==0){
			mini.style.display='block';
			area.style.display='none';
		}
	}
}

function checkHeight(){
	var a1=0;
	var a2=0
	var a3=0
	var c1=document.getElementById('not1');
	var c2=document.getElementById('not2');
	var c3=document.getElementById('not3');
	if (c1) a1=c1.offsetHeight;
	if (c2) a2=c2.offsetHeight;
	if (c3) a3=c3.offsetHeight;
	var a4=Math.max(a1,a2);
	var mx=Math.max(a4,a3);
	if (c1) c1.style.height=mx+'px';
	if (c2) c2.style.height=mx+'px';
	if (c3) c3.style.height=mx+'px';
}



function verFaq(id,todas){
	var i=1;
	while (i<=todas){
		var capa=document.getElementById('faq'+i);
		if (capa){
			if (i==id){
				capa.style.display='block';
				var boton1=document.getElementById('showitem'+i).style.display='none';
				var boton2=document.getElementById('hideitem'+i).style.display='block';
			}else{
				capa.style.display='none';
				var boton1=document.getElementById('showitem'+i).style.display='block';
				var boton2=document.getElementById('hideitem'+i).style.display='none';
			}
		}
		i++;
	}
}

function hideFaq(id){
	var capa=document.getElementById('faq'+id).style.display='none';
	var boton1=document.getElementById('showitem'+id).style.display='block';
	var boton2=document.getElementById('hideitem'+id).style.display='none';

}

function showPreHome(b,p){
	document.getElementById("toShowPromo").innerHTML = '<div class="home-ajax" style="background:url(img/ani.gif) center no-repeat;"><div id="texto2"><h2>&nbsp;</h2><p>&nbsp;</p></div></div>';
	document.getElementById("hb").style.display ='none';
	setTimeout("showPromoHome("+b+",'"+p+"');",900);
}

function showPromoHome(id,p){
	var caja=document.getElementById('toShowPromo');
	document.getElementById("hb").style.display ='block';
	if (caja){
		var nn= new Array('pid',id, 'basepath',p);
		xx=p+'includes/ajaxShowPromo.php';
		LNSR_ejecutar('toShowPromo','','GET',xx,'', nn);
	}
}


/* AJAX */
function RMT_inicializa() {
var xx=null;
 try {
  xx = new XMLHttpRequest();
 } catch (e) {
  xx=null;
  var msxmlhttp = new Array('Msxml2.XMLHTTP.5.0',
                      'Msxml2.XMLHTTP.4.0',
                      'Msxml2.XMLHTTP.3.0',
                      'Msxml2.XMLHTTP',
                      'Microsoft.XMLHTTP');
  var success = false;
  for (var i=0; i<msxmlhttp.length && !success;i++) {
   try {
    xx = new ActiveXObject(msxmlhttp[i]);
    success = true;
   } catch (e) { xx=null; }
  }
 }
 return xx;
}

var LNSR_layer='';
var LNSR_funcion='';

function LNSR_ejecutar(lay,reg,metodo,uri,funcion, args) {
 var i, n;
 var post_data;
 var retorno=true;
 LRMT_ResultadoError='';
 LRMT_ResultadoHttp='';
 LNSR_layer=lay;
 LNSR_funcion=reg;
 if (typeof(metodo) == "undefined" || metodo== "") 	metodo = "GET";
 if (metodo == "GET") {
  if (uri.indexOf("?") == -1) uri += "?fn=" + escape(funcion);
  else uri += "&fn=" + escape(funcion);
  uri += "&fnrnd=" + new Date().getTime();
  for (i = 0; i < args.length-1; i+=2) uri += "&" + args[i] + "=" + escape(args[i+1]);
  post_data = null;
 } else if (metodo == "POST") {
  post_data = "fn=" + escape(funcion);
  post_data += "&fnrnd=" + new Date().getTime();
  for (i = 0; i < args.length-1; i+=2) {
		post_data += "&" + args[i] + "=" + escape(args[i+1]);
	}
 } else {
  alert("Tipo de Petición Ilegal: " + LRMT_tipopeticion);
  LNSR_funcion();
  return false;
 }
 if (LRMT_conector == null) {
  //alert("Imposible Crear Objeto de conexión Remota al Servidor.");
  return false;
  LNSR_funcion();
 } else {
	bComplete = false;
  LRMT_conector.open(metodo, uri, true);
  if (metodo == "POST") {
   LRMT_conector.setRequestHeader("Method", "POST " + uri + " HTTP/1.1");
   LRMT_conector.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=iso-8859-1");
  }
  LRMT_conector.onreadystatechange = function(){
   if (LRMT_conector.readyState == 4 && !bComplete) {
     bComplete = true
     LNSR_ejecutar2(LRMT_conector)
   }
  };
  LRMT_conector.send(post_data);
  return retorno;
 }
}
function LNSR_ejecutar2(a) {
		var reto = false;
		try {
			switch(a.status) {
				case 200:
					document.getElementById(LNSR_layer).innerHTML=a.responseText;
					reto = true;
					break;
				case 400:
					//alert('El servidor envió el código de Error: '+a.status+' (Petición errónea. Se ha introducido una URL mal formada.) a la petición solicitada');
					break;
				case 401:
					//alert('El servidor envió el código de Error: '+a.status+' (No autorizado. El visitante no tiene autorización para acceder a esa página.) a la petición solicitada');
					break;
				case 403:
					//alert('El servidor envió el código de Error: '+a.status+' (Prohibido. Permisos insuficientes para leer esa página o directorio.) a la petición solicitada');
					break;
				case 404:
					//alert('El servidor envió el código de Error: '+a.status+' (No encontrado. La página solicitada no se ha encontrado.) a la petición solicitada');
					break;
				default:
					//alert('El servidor envió el código de Error: '+a.status+' (Error interno del servidor Ocurrió un error interno mientras se intentaba mostrar la página solicitada.) a la petición solicitada');
					break;
			}
		} catch (e) {
			//alert("Unable connect to server.")
		}
	if (!reto) LNSR_funcion();
	return reto;
}

var LRMT_conector = RMT_inicializa();
var LRMT_ResultadoHttp="";
var LRMT_ResultadoError="";
/*final Funciones Remotas*/






