function nuevoAjax(){ 
	/* Crea el objeto AJAX. Esta funcion es generica para cualquier utilidad de este tipo */
	var xmlhttp=false; 

	try{ 
		xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); // Creacion del objeto AJAX para navegadores no IE
	}
	catch(e){ 
		try	{ 
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); // Creacion del objet AJAX para IE 
		}
		catch(E){
			xmlhttp=false;
		}
	}
	if (!xmlhttp && typeof XMLHttpRequest!='undefined'){
		xmlhttp=new XMLHttpRequest();
	} 
	return xmlhttp; // retornar el objeto AJAX
}

function cargaContenido(valor1,valor2,respuesta,acc){ // funcion generica, utilizada principalmente para los productos de la cotizacion
	ajax=nuevoAjax();

	if(acc == 9 || acc == 10){
		var tabla = 'cat_galeria';
		var cod_tabla = 'id_cat';
	}else
	if(acc == 14 || acc == 15){
		var tabla = 'cat_noticias';
		var cod_tabla = 'id_cat';
	}else
	if(acc == 19 || acc == 20){
		var tabla = 'cat_encuestas';
		var cod_tabla = 'id_cat';
	}else
	if(acc == 30 || acc == 31){
		var tabla = 'cuentas_bancarias';
		var cod_tabla = 'id_cuenta';
	}else{
		var tabla = '';
		var cod_tabla = '';
	}
	
	ajax.open("GET", "include/ajax_resp.php?acc="+acc+"&valor1="+valor1+"&valor2="+valor2+"&tabla="+tabla+"&cod_tabla="+cod_tabla, true);
	ajax.onreadystatechange=function(){ 
		if (ajax.readyState==4){
		    switch(acc){
                case 3:	case 4: case 9:	case 10:  case 14: case 15:  case 19: case 20:
					var datos = ajax.responseText.split('-');
					if(datos[0].trim() == 1)
						actualizar_lista();
					
					if(acc == 4 || acc == 9 || acc == 14 || acc == 19){
						document.getElementById('btn_insertar').style.display  = '';
						document.getElementById('btn_modificar').style.display = 'none';
					}
					document.getElementById(respuesta).innerHTML=datos[1]; 
				break;
				default:
					document.getElementById(respuesta).innerHTML=ajax.responseText; 
				break;
	       	}
		}else{
			if(acc == 29) document.getElementById(respuesta).innerHTML="<img src='images/cargar.gif' alt='Cargando' width='16' height='16' /> <b>Cargando.... </b>";
		}
	}
	ajax.send(null);
}

function cargaContenido2(valor1,valor2,valor3,respuesta,acc){ 
	ajax=nuevoAjax();

	ajax.open("GET", "include/ajax_resp.php?acc="+acc+"&valor1="+valor1+"&valor2="+valor2+"&valor3="+valor3, true);

	ajax.onreadystatechange=function(){ 
		if (ajax.readyState==4){
		    switch(acc){
                case 22: case 23: case 30: case 31:	
					var datos = ajax.responseText.split('-');
					if(datos[0].trim() == 1)
						actualizar_lista(valor3);
					
					if(acc == 22 || acc == 32){
						document.getElementById('btn_insertar').style.display  = '';
						document.getElementById('btn_modificar').style.display = 'none';
					}
					document.getElementById(respuesta).innerHTML=datos[1]; 
				break;
         	}
		}
	}
	ajax.send(null);
}

function cargaZonaGeo(valor,respuesta,acc){ // funcion generica, utilizada principalmente para los productos de la cotizacion
	ajax=nuevoAjax();
	ajax.open("GET", "include/ajax_resp.php?acc="+acc+"&valor="+valor, true);

	ajax.onreadystatechange=function(){ 
		if (ajax.readyState==4)	{
			document.getElementById(respuesta).innerHTML=ajax.responseText;
		}else{
			document.getElementById(respuesta).innerHTML="<img src='images/cargar.gif' alt='Cargando' width='16' height='16' /> <b>Cargando.... </b>";
		}
	}
	ajax.send(null);
}

function reload_list(resp, id, tabla, opciones, id_tabla, mostrar, funcion){
	ajax=nuevoAjax();
	ajax.open("GET", "include/ajax_resp.php?acc=8&tabla="+tabla+"&opciones="+opciones+"&id="+id+"&mostrar="+mostrar+"&id_tabla="+id_tabla+"&funcion="+funcion, true);
	ajax.onreadystatechange=function()	{ 
		if (ajax.readyState==4)	{
			document.getElementById(resp).innerHTML=ajax.responseText;
		}else{
			document.getElementById(resp).innerHTML="<img src='images/cargar.gif' alt='Cargando' width='16' height='16' /> <b>Cargando.... </b>";
		}
	}
	ajax.send(null);
}

function removeWin(frm_down){
	var fx = document.getElementById(frm_down);
	if(fx){
		for (i = 0; i < fx.elements.length; i++) {
			if(fx.elements[i].type == "select" || fx.elements[i].type == "select-one" || fx.elements[i].type == "select-multiple"){
				fx.elements[i].style.visibility = "visible";
			}
		}
	}
	if(frm_down == 'frm_enviar_emails')
		var cuerpo = document.getElementById(frm_down);
	else
		var cuerpo = document.body;
	cuerpo.removeChild(document.getElementById('id_data'+frm_down));
	cuerpo.removeChild(document.getElementById('id_fondo'+frm_down));
}

function winPopup(pag, ancho, alto, frm_down){
	var h = 0; // height
	var w = 0; // width
	var top  = (window.screen.height - alto)/2 - 120;
	var left = (window.screen.width  - ancho)/2;

	if( typeof( window.innerHeight ) == 'number' ) {
		//no es IE
		pos = 'fixed';
	} else if( document.body && document.body.clientHeight ) {
		//IE 4 o superior
		pos = 'absolute';
	}

	h = document.body.scrollHeight;
	w = document.body.scrollWidth;
	
	var fondo = document.createElement('div');
	fondo.id = 'id_fondo'+frm_down;
	fondo.style.top = '0px';
	fondo.style.left= '0px';
	fondo.style.minHeight = '100%';
	fondo.style.backgroundColor = '#000000';
	fondo.style.filter = 'alpha(opacity=65)';
	fondo.style.opacity= '0.65';
	fondo.style.height = h+'px';
	fondo.style.width  = w+'px';
	fondo.style.zIndex = 1500;
	fondo.style.position = 'absolute';
	if(frm_down == 'frm_enviar_emails')
		var cuerpo = document.getElementById(frm_down);
	else
		var cuerpo = document.body;
	cuerpo.appendChild(fondo);

	ajax_win=nuevoAjax();

	var c = pag.split('?');
	if(c.length <= 1){
		pag=pag+'?';
	}

	ajax_win.open("GET", pag+'&frm='+frm_down, true);
	ajax_win.onreadystatechange=function(){ 
		if (ajax_win.readyState==4){
			var contenedor= document.createElement('div');
			contenedor.id = 'id_data'+frm_down;
			contenedor.style.height = alto+'px';
			contenedor.style.width  = ancho+'px';
			contenedor.style.zIndex = 1500;
			contenedor.style.position = pos;
			contenedor.style.overflowY= 'auto';	
			contenedor.style.filter   = 'alpha(opacity=100)';
			contenedor.style.opacity  = '1';
			contenedor.style.top = top+'px';
			contenedor.style.left= left+'px';
			if(frm_down == 'frm_paquetes')
				contenedor.style.backgroundColor = '#000000';
			else
				contenedor.style.backgroundColor = '#FFFFFF';
			contenedor.style.border = '1px'; 
			contenedor.style.borderColor = '#000000';
			contenedor.style.borderStyle = 'solid';
			cuerpo.appendChild(contenedor);
			contenedor.focus();

			document.getElementById('id_data'+frm_down).innerHTML =ajax_win.responseText;
			document.getElementById('id_fondo'+frm_down).innerHTML="";

			var fx = document.getElementById(frm_down);
			if(fx){
				for (i = 0; i < fx.elements.length; i++) {
					if(fx.elements[i].type == "select" || fx.elements[i].type == "select-one" || fx.elements[i].type == "select-multiple"){
						fx.elements[i].style.visibility = "hidden";
					}
				}
			}
		}else{
			document.getElementById('id_fondo'+frm_down).innerHTML="<img src='include/loadingAnimation.gif'>";
		}
	}
	ajax_win.send(null);
}

function count_clicks(id_imagen){
	ajax=nuevoAjax();
	ajax.open("GET", "include/ajax_resp.php?acc=16&id_imagen="+id_imagen, true);
	ajax.onreadystatechange=function()	{ 
		if (ajax.readyState==4)	{
			return;
		}
	}
	ajax.send(null);
}

function ver_afiliados(id_rec, ajax_id, nivel){
	if(document.getElementById(ajax_id).style.display == "none"){
		ajax=nuevoAjax();
		ajax.open("GET", "include/ajax_resp.php?acc=28&id_cliente="+id_rec+"&id_ajax="+ajax_id+"&nivel="+nivel, true);
		ajax.onreadystatechange=function(){ 
			if (ajax.readyState==4){
				if(ajax.responseText != false){
					document.getElementById(ajax_id).style.display = "";
					document.getElementById(ajax_id).innerHTML= ajax.responseText;
					
					document.getElementById('link'+id_rec).src= "images/red_minus.png";
				}else{
					alert("No se encontraron Afiliados!");
					document.getElementById(ajax_id).style.display = "none";
					document.getElementById(ajax_id).innerHTML= "&nbsp;";
					document.getElementById('link'+id_rec).src= "images/red_plus.png";
				}
			}else{
				document.getElementById(ajax_id).style.display = "";
				document.getElementById(ajax_id).innerHTML="<img src='images/cargar.gif' alt='Cargando' width='16' height='16' /> <b>Cargando.... </b> ";
			}
		}
		ajax.send(null);
	}else{
		document.getElementById(ajax_id).style.display = "none";
		document.getElementById('link'+id_rec).src= "images/red_plus.png";
	}
}

function ajax_recordar(){
	if(document.getElementById('email_send').value != ""){
		if(document.getElementById('login_send').value != ""){
			var email_str=/^[^@\s]+@[^@\.\s]+(\.[^@\.\s]+)+$/;
			
			if(!email_str.test(document.getElementById('email_send').value)) {
				show_hidden('help_email_send');
				document.getElementById('email_send').style.backgroundColor = "#FEEEE6";
				document.getElementById('email_send').focus();
				return false;
			}else{
				ajax=nuevoAjax();
				ajax.open("GET", "include/ajax_resp.php?acc=36&email_send="+document.getElementById('email_send').value+"&login_send="+document.getElementById('login_send').value, true);
				ajax.onreadystatechange=function(){ 
					if (ajax.readyState==4){
						var datos = ajax.responseText.split('-');
						if(datos[0].trim() == 1){
							document.getElementById('help_email_send').style.display = "none";
							document.getElementById('email_send').style.backgroundColor = "#EFF4F5";
							document.getElementById('help_login_send').style.display = "none";
							document.getElementById('login_send').style.backgroundColor = "#EFF4F5";
						}
						document.getElementById('ajax_msj_recordar').innerHTML=datos[1];
					}else{
						document.getElementById('ajax_msj_recordar').innerHTML="<img src='images/cargar.gif' width='16' height='16' alt='Cargando...' /> <b>Cargando.... </b> ";
					}
				}
				ajax.send(null);
			}
		}else{
			show_hidden('help_login_send');
			document.getElementById('login_send').style.backgroundColor = "#FEEEE6";
			document.getElementById('login_send').focus();
			return false;
		}
	}else{
		show_hidden('help_email_send');
		document.getElementById('email_send').style.backgroundColor = "#FEEEE6";
		document.getElementById('email_send').focus();
		return false;
	}
}

function ajax_retiro(fx){
	if(fx.texto.value != ""){
		if(fx.captcha.value != ""){
			ajax=nuevoAjax();
			ajax.open("GET", "include/ajax_resp.php?acc=44&texto="+fx.texto.value+"&captcha="+fx.captcha.value, true);
			ajax.onreadystatechange=function(){ 
				if (ajax.readyState==4){
					var datos = ajax.responseText.split('-');
					if(datos[0].trim() == 1){
						document.getElementById('help_texto').style.display     = "none";
						document.getElementById('texto').style.backgroundColor  = "#EFF4F5";
						document.getElementById('help_captcha').style.display   = "none";
						document.getElementById('captcha').style.backgroundColor= "#EFF4F5";
					}
					document.getElementById('ajax_msj').innerHTML=datos[1];
				}else{
					document.getElementById('ajax_msj').innerHTML="<img src='images/cargar.gif' alt='Cargando' width='16' height='16' /> <b>Cargando.... </b> ";
				}
			}
			ajax.send(null);
		}else{
			show_hidden('help_captcha');
			fx.captcha.style.backgroundColor = "#FEEEE6";
			fx.captcha.focus();
			return false;
		}
	}else{
		show_hidden('help_texto');
		fx.texto.style.backgroundColor = "#FEEEE6";
		fx.texto.focus();
		return false;
	}
}

function change_gastos(fx){
	if(fx.monto.value != ""){
		ajax=nuevoAjax();
		ajax.open("GET", "include/ajax_resp.php?acc=46&monto="+fx.monto.value+"&tg="+fx.tipo_geo.value+"&cod="+fx.cod.value, true);
		ajax.onreadystatechange=function(){ 
			if (ajax.readyState==4){
				document.getElementById('ajax_msj_change').innerHTML=ajax.responseText;
			}else{
				document.getElementById('ajax_msj_change').innerHTML="<img src='images/cargar.gif' alt='Cargando' width='16' height='16' /> <b>Cargando.... </b> ";
			}
		}
		ajax.send(null);
	}else{
		show_hidden('help_monto');
		fx.monto.style.backgroundColor = "#FEEEE6";
		fx.monto.focus();
		return false;
	}
}

function ajax_my_invitacion(n){
	var opc=n;
	for(var i=0; i<= n; i++){
		if(document.getElementById('opc'+i).checked){
			opc = i;
			break;
		}
	}
	winPopup('emails/my_invitation.php?opc='+opc, 600, 500, 'frm_enviar_emails');
}

function show_welcome(texto){
	var ancho = 800;
	var alto  = 250;
	var h = 0; // height
	var w = 0; // width
	var top  = (window.screen.height - alto)/2 - 120;
	var left = (window.screen.width  - ancho)/2;

	if( typeof( window.innerHeight ) == 'number' ) {
		//no es IE
		h = window.innerHeight;
		w = window.innerWidth;
		pos = 'fixed';
	} else if( document.body && document.body.clientHeight ) {
		//IE 4 o superior
		h = document.body.clientHeight*2;
		w = document.body.clientWidth;
		pos = 'absolute';
	}

	var fondo = document.createElement('div');
	fondo.id = 'id_fondo';
	fondo.style.top = '0px';
	fondo.style.left= '0px';
	fondo.style.minHeight = '100%';
	fondo.style.backgroundColor = '#000000';
	fondo.style.filter = 'alpha(opacity=65)';
	fondo.style.opacity= '0.65';
	fondo.style.height = h+'px';
	fondo.style.width  = w+'px';
	fondo.style.zIndex = 2500;
	fondo.style.position = 'absolute';
	var cuerpo = document.getElementById('body');
	cuerpo.appendChild(fondo);

	var contenedor    = document.createElement('div');
	contenedor.id = 'id_data';
	contenedor.align = 'center';
	contenedor.style.width  = ancho+'px';
	contenedor.style.height = alto+'px';
	contenedor.style.zIndex = 2500;
	contenedor.style.position = pos;
	contenedor.style.overflow = 'hidden';	
	contenedor.style.filter   = 'alpha(opacity=100)';
	contenedor.style.opacity  = '1';
	contenedor.style.color    = '#FFFFFF';
	contenedor.style.fontSize = '20pt';
	contenedor.style.top = top+'px';
	contenedor.style.left= left+'px';
	cuerpo.appendChild(contenedor);

	document.getElementById('id_data').innerHTML = texto;
	document.getElementById('id_fondo').innerHTML= "";
	cuerpo.focus();
}

function hidde_welcome() {
	var cuerpo = document.getElementById('body');
	if(document.getElementById('id_data')){
		cuerpo.removeChild(document.getElementById('id_data'));
		if(document.getElementById('id_fondo'))
			cuerpo.removeChild(document.getElementById('id_fondo'));
	}
}

function show_video(){
	ventanaPopUp('video/video.html','ventana_video','740px','520px','no','no');
}

function hidden_video(){
	window.close();
}

function change_passw(fx, id){
	if(fx.cl_actual.value == ''){
		show_hidden('help_cl_actual');
		fx.cl_actual.style.backgroundColor = "#FEEEE6";
		fx.cl_actual.focus();
	}else{
		if(fx.passw.value != fx.confir.value){
			show_hidden('help_confir');
			fx.confir.style.backgroundColor = "#FEEEE6";
			fx.confir.focus();
		}else{
			document.getElementById('help_confir').style.display = "none";
			fx.confir.style.backgroundColor = "#EFF4F5";

			ajax=nuevoAjax();
			ajax.open("GET", "include/ajax_resp.php?acc=42&f1="+fx.cl_actual.value+"&f2="+fx.passw.value+"&f3="+fx.confir.value+"&f4="+id, true);
			ajax.onreadystatechange=function(){ 
				if (ajax.readyState==4){
					document.getElementById('ajax_msj_change').innerHTML = ajax.responseText;
				}else{
					document.getElementById("ajax_msj_change").innerHTML = "<img src='images/cargar.gif' alt='Cargando' width='16' height='16' /> <b>Cargando.... </b>";
				}
			}		
			ajax.send(null);
		}
	}
}

function show_data(id){
	var alto = '438';
	var ancho= '500';
	fondo = document.createElement('div');
	fondo.id = 'id_fondo';
	fondo.style.top = '0px';
	fondo.style.left= '0px';
	fondo.style.minHeight = '100%';
	fondo.style.backgroundColor = '#000';
	fondo.style.filter = 'alpha(opacity=65)';
	fondo.style.opacity= '0.65';
	fondo.style.height = window.screen.height;
	fondo.style.width  = window.screen.width;
	fondo.style.zIndex ='100';
	fondo.style.position ='absolute';
	cuerpo = document.getElementById('display');
	cuerpo.appendChild(fondo);

	ajax=nuevoAjax();

	ajax.open("GET", "include/tree_m4/show_data.php?id="+id, true);
	ajax.onreadystatechange=function(){ 
		if (ajax.readyState==4){
			contenedor = document.createElement('div');
			contenedor.id    = 'id_data';
			contenedor.align = 'center';
			contenedor.style.height = alto;
			contenedor.style.width  = ancho;
			contenedor.style.zIndex = '250';
			contenedor.style.position ='absolute';
			contenedor.style.overflow ='hidden';
			contenedor.style.filter   = 'alpha(opacity=100)';
			contenedor.style.opacity  = '1';
			contenedor.style.top = (window.screen.height - alto)/2 - 70;
			contenedor.style.left= (window.screen.width  - ancho)/2;
			contenedor.style.backgroundColor = '#FFFFFF';
			contenedor.style.border = '1px'; 
			contenedor.style.borderColor = '#000000';
			contenedor.style.borderStyle = 'solid';
			cuerpo.appendChild(contenedor);
		
			document.getElementById('id_data').innerHTML=ajax.responseText;
			document.getElementById('id_fondo').innerHTML="";
		}else{
			document.getElementById('id_fondo').innerHTML="<img src='include/loadingAnimation.gif'>";
		}
	}
	ajax.send(null);
}

function remove_data(){
	var cuerpo = document.getElementById('display');//document.body;
	cuerpo.removeChild(document.getElementById('id_data'));
	cuerpo.removeChild(document.getElementById('id_fondo'));
}

function ajax_confirm_check(frm, moneda){
	var fx = document.getElementById(frm);
	ajax=nuevoAjax();
	ajax.open("GET", "include/ajax_resp.php?acc=55&captcha_chk="+fx.captcha_chk.value+"&n_cheque="+fx.n_cheque.value+"&id_pago="+fx.id_pago.value+"&cobrado="+(fx.cobrado.checked?'true':'false'), true);
	ajax.onreadystatechange=function(){ 
		if (ajax.readyState==4){
			var datos = ajax.responseText.split('#');
			if(datos[0].trim() == 'S' && fx.cobrado.checked){
				document.getElementById(fx.id_pago.value+''+moneda).className = 'bg_cel_4';
			}
			document.getElementById('ajax_msj_change').innerHTML = datos[1];
		}else{
			document.getElementById("ajax_msj_change").innerHTML = "<img src='images/cargar.gif' alt='Cargando' width='16' height='16' /> <b>Cargando.... </b>";
		}
	}
	ajax.send(null);
}
function ajax_info(frm) {
	var fx = document.getElementById(frm);
    var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
			if(req.responseJS.result == 'N'){
				document.getElementById('tr_frm').style.display = '';
			}else{
				document.getElementById('tr_frm').style.display = 'none';
			}
			document.getElementById('ajax_msj_info').innerHTML = req.responseJS.mensaje;
		}else{
			document.getElementById('tr_frm').style.display  = 'none';
			document.getElementById('tr_info').style.display = '';
			document.getElementById('ajax_msj_info').innerHTML = "<img src=images/aero_light.gif width=32 height=32> <b>Por favor, espere estamos procesando su petici&oacute;n.... </b>";
        }
    }
    req.open('POST', 'include/ajax_resp.php', true);
    req.send( { result: fx } );
}

function ajax_create_SD(frm) {
	var fx = document.getElementById(frm);
    var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
			if(req.responseJS.result == 'S'){
				document.getElementById('ajax_frm_SD').innerHTML = req.responseJS.tb_SD;
			}else{
				document.getElementById('btn_aj_sd').style.display = '';
			}
			document.getElementById('ajax_frm_SD').style.display = '';
			document.getElementById('ajax_msj_SD').innerHTML = req.responseJS.mensaje;
		}else{
			document.getElementById('btn_aj_sd').style.display   = 'none';
			document.getElementById('ajax_frm_SD').style.display = 'none';
			document.getElementById('ajax_msj_SD').style.display = '';
			document.getElementById('ajax_msj_SD').innerHTML = "<img src=images/aero_light.gif width=32 height=32> <b>Procesando.... </b>";
        }
    }
	req.open('POST', 'include/ajax_resp.php', true);
    req.send( { result: fx } );
}
function ajax_my_photo(frm) {
	var fx = document.getElementById(frm);
    var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
			if(req.responseJS.result == 'S'){
				document.getElementById('my_photo').src = 'images/aero_light.gif';
				document.getElementById('my_photo').innerHTML = '<img src="'+req.responseJS.photo+'?'+setInterval('',500)+'" alt="Mi Fotografia" title="Mi Fotografia" border="0" />';
			}else{
				document.getElementById('btn_aj_ap').style.display = '';
			}
			document.getElementById('ajax_msj_change').innerHTML = req.responseJS.mensaje;
		}else{
			document.getElementById('btn_aj_ap').style.display   = 'none';
			document.getElementById('ajax_msj_change').innerHTML = "<img src=images/aero_light.gif width=32 height=32> <b style='color:#006699'>Por favor, espere estamos procesando su petici&oacute;n.... </b><br>";
        }
    }
    req.open('POST', 'include/ajax_resp.php', true);
    req.send( { result: fx } );
}

function ajax_search_cliente(frm){
	var fx = document.getElementById(frm);
    var req = new JsHttpRequest();
	var style = '';
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
			if(req.responseJS.result == 'S'){
				document.getElementById('ajax_monto').innerHTML = req.responseJS.monto_format;
				document.getElementById('monto').value = req.responseJS.monto;
				document.getElementById('type_pago').value = req.responseJS.type_pago;
				style = 'successmessage';
			}else{
				document.getElementById('ajax_monto').innerHTML = '0,00';
				document.getElementById('monto').value = '0.0';
				document.getElementById('type_pago').value = '';
				document.getElementById('id_des').readOnly = false;
				document.getElementById('cedula').readOnly = false;
				style = 'errormessage';
			}
			document.getElementById('ajax_msj').innerHTML = '<div class="'+style+'">'+req.responseJS.mensaje+'</div>';
		}else{
			document.getElementById('ajax_msj').innerHTML = "<img src=images/aero_light.gif width=32 height=32> <b style='color:#006699'>Por favor, espere estamos procesando su petici&oacute;n.... </b><br>";
			document.getElementById('id_des').readOnly = true;
			document.getElementById('cedula').readOnly = true;
        }
    }
    req.open('POST', 'include/ajax_resp.php', true);
    req.send( { result: fx } );
}

function envio_mail_contacto(fx){
	if(validar(fx)){		
		var asunto = document.getElementById('asunto_cnt').value;
		var nombre = document.getElementById('nombre_cnt').value;
		var email  = document.getElementById('email_cnt').value;
		var contenido = document.getElementById('texto_cnt').value;
		
		ajax=nuevoAjax();
		ajax.open("GET", "include/ajax_resp.php?acc=1&asunto="+asunto+"&nombre="+nombre+"&email="+email+"&contenido="+contenido, true);
		ajax.onreadystatechange=function()	{ 	
			if (ajax.readyState==4)	{
				document.getElementById('ajax_msj_cnt').innerHTML=ajax.responseText;
			}else{
				document.getElementById('ajax_msj_cnt').innerHTML="<img src='images/cargar.gif' width='16' height='16' alt='Cargando...' /> <b>Cargando.... </b>";
			}
		}
		ajax.send(null);
	}
}

function envio_mail_info_cnt(fx){
	if(validar(fx)){
		var asunto = document.getElementById('asunto_info_cnt').value;
		var nombre = document.getElementById('nombre_info_cnt').value;
		var email  = document.getElementById('email_info_cnt').value;
		var contenido = document.getElementById('texto_info_cnt').value;
		
		ajax=nuevoAjax();
		ajax.open("GET", "include/ajax_resp.php?acc=59&asunto="+asunto+"&nombre="+nombre+"&email="+email+"&contenido="+contenido, true);
		ajax.onreadystatechange=function()	{ 	
			if (ajax.readyState==4)	{
				document.getElementById('ajax_msj_contacto').innerHTML=ajax.responseText;
			}else{
				document.getElementById('ajax_msj_contacto').innerHTML="<img src='images/cargar.gif' width='16' height='16' alt='Cargando...' /> <b>Cargando.... </b>";
			}
		}
		ajax.send(null);
	}
}

function envio_recomendacion(fx){
	if(validar(fx)){
		var email = document.getElementById('email_rec').value;
		ajax=nuevoAjax();
		ajax.open("GET", "include/ajax_resp.php?acc=45&email="+email, true);
		ajax.onreadystatechange=function()	{ 
			if (ajax.readyState==4)	{
				document.getElementById('ajax_msj_rec').innerHTML=ajax.responseText;
			}else{
				document.getElementById('ajax_msj_rec').innerHTML="<img src='images/cargar.gif' width='16' height='16' alt='Cargando...' /> <b>Cargando.... </b>";
			}
		}
		ajax.send(null);
	}
}

function envio_mail(fx){
	if(validar(fx)){
		var nombre_sol	= fx.nombre_sol.value;
		var email		= fx.email.value;
		var telf		= fx.telf.value;
		var destino		= fx.destino_sol.value;
		var dia			= fx.dia.value;
		var mes 		= fx.mes.value;
		var anio 		= fx.anio.value;
		var observaciones = fx.observaciones.value;
		
		ajax=nuevoAjax();
		ajax.open("GET", "include/ajax_resp.php?acc=56&nombre_sol="+nombre_sol+"&email="+email+"&telf="+telf+"&destino="+destino+"&dia="+dia+"&mes="+mes+"&anio="+anio+"&observaciones="+observaciones, true);
		ajax.onreadystatechange=function(){
			if (ajax.readyState==4)	{
				document.getElementById('ajax_msj').innerHTML=ajax.responseText;
				document.getElementById('frm_email').reset();
			}else{
				document.getElementById('ajax_msj').innerHTML="<img src='images/cargar.gif' width='16' height='16' alt='Cargando...' /> <b>Cargando.... </b>";
			}
		}	
		ajax.send(null);
	}
}

function envio_mail_finan(fx){
	var verificacion=0;
	var financiamiento;
	
	for (i=0; tiporadio=document.getElementById('frm_email_finan').elements[i];i++){
		if(tiporadio.type=='radio'){
			if(tiporadio.checked){
				verificacion=1;
				financiamiento=tiporadio.value;
				break;
			}
		}
	}
	
	if(verificacion){
		if(validar(fx)){
			var nombre_sol_finan= fx.nombre_sol_finan.value;
			var email		    = fx.email.value;
			var telf_finan		= fx.telf_finan.value;
			var paquete_finan	= fx.paquete_finan.value;

			ajax=nuevoAjax();
			ajax.open("GET", "include/ajax_resp.php?acc=57&nombre_sol_finan="+nombre_sol_finan+"&email="+email+"&telf_finan="+telf_finan+"&paquete_finan="+paquete_finan+"&financiamiento="+financiamiento, true);
			ajax.onreadystatechange=function()	{ 
				if (ajax.readyState==4)	{
					document.getElementById('ajax_msj_finan').innerHTML=ajax.responseText;
					document.getElementById('frm_email_finan').reset();
				}else{
					document.getElementById('ajax_msj_finan').innerHTML="<img src='images/cargar.gif' width='16' height='16' alt='Cargando...' /> <b>Cargando.... </b>";
				}
			}	
			ajax.send(null);
		}
	}else{
		alert('Debes Seleccionar alguna de las Opciones de financiamiento')
		return false;
	}
}

var idl = 'layer_contenido';
var begin = 0;
var end   = 480;
var inc   = 10;
var cl    = '';
var id	  = '';
var txt   = '';
var timer = 4;
function open_layer(){
	var capa = document.getElementById(idl);
	var alto = capa.style.height;
	alto = parseInt(alto.replace('px',''));
	if(alto == begin){
		capa.style.display = '';
		document.getElementById('layer_txt').innerHTML = "<img src='images/aero_light.gif' alt='Cargando' width='32' height='32' /> <b>Cargando Contenido.... </b>";
	}
	if(alto < end){
		capa.style.height = (alto + inc) + 'px';
		setTimeout('open_layer()', timer);
	}else if(alto == end){
		document.getElementById('layer_txt').innerHTML = document.getElementById('cl'+cl).innerHTML;
	}
}
function close_layer(){
	var capa = document.getElementById(idl);
	var alto = capa.style.height;
	alto = parseInt(alto.replace('px',''));
	if(alto == begin)
		capa.style.display = 'none';
	if(alto > begin){
		capa.style.height = (alto - inc) + 'px';
		setTimeout('close_layer()', timer);
	}else if(alto == end){
		document.getElementById('layer_txt').innerHTML = '';
	}
}

function confirmar_retiro(){
	if (confirm("Esta seguro de solicitar su retiro de nuestro sistema?") ){
		winPopup('clientes/retiro.php', 510, 275, 'frm_menu');
	}
}

function add_subdominio(){	
	winPopup('clientes/add_subdominio.php?', 500, 200, 'frm_menu');	
}

function add_photo(){
	winPopup('clientes/change_photo.php?', 500, 250, 'frm_menu');
}

function ajax_change_emails(frm) {
	var fx  = document.getElementById(frm);
    var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
			if(req.responseJS.result.trim() != 'S'){
				document.getElementById('btn_aj_emails').style.display = '';
			}
			document.getElementById('ajax_msj_emails').innerHTML = req.responseJS.mensaje;
		}else{
			document.getElementById('btn_aj_emails').style.display   = 'none';
			document.getElementById('ajax_msj_emails').style.display = '';
			document.getElementById('ajax_msj_emails').innerHTML = "<img src=images/aero_light.gif width=32 height=32> <b>Procesando.... </b>";
        }
    }
	req.open('POST', 'include/ajax_resp.php', true);
    req.send( { result: fx } );
}

function drop_email_sends(){
	document.getElementById('ajax_es').innerHTML = '<input name="email_sends" class="introinput" type="text" id="email_sends" size="40" onkeypress="return(formato_campo(this,event,8))" style="width:90%!important" />';
	document.getElementById('ajax_es').innerHTML += '<label for="help_email_sends"><img onclick="show_hidden(\'help_email_sends\')" alt="Ayuda" src="./images/help_icon.png" /></label>';
}

function open_am(am){
	winPopup('paquetes/aviso.php?am='+am, 500, 300, 'frm_paq');
}

function change_cuenta(id_cmb, id_cuenta, num_cuenta){
	var valor = document.getElementById(id_cmb).options[document.getElementById(id_cmb).selectedIndex].value;
	if(valor != '' && valor != 'x999'){
		var classN= document.getElementById(id_cmb).options[document.getElementById(id_cmb).selectedIndex].className;
		var datos = classN.split('-');
		document.getElementById(id_cuenta).value  = datos[0];
		document.getElementById(num_cuenta).value = datos[1];
	}
}
