// Guardar Datos
	function guardaForm(id_div)
	{
	    switch(id_div)
	    {
	      case "tb_inicial":
	      pagina = document.getElementById("bandera").value;
	       if(pagina != "administrador"){
		  if(validaPricipal()){
		  _doSave('a_',id_div,'');
		  }
		}
		else{
		    if(validaAsigna()){
		    _doSave('a_',id_div,'');
		    }

		}
	      break;
	       case "tb_dir":
		  if(validaDir()){
		    _doSave('a_',id_div,'');
		  }
	      break;
	      case "tb_agenda":
		  if(validaAgenda()){
		    _doSave('a_',id_div,'');
		  }
	      break;
	      case "tb_nota":
		  if(validaNota()){
		    _doSave('a_',id_div,'');
		  }
	      break;
	      case "tb_galeria":
		  _doSave('a_',id_div,'');
	      break;
	      case "tb_doc":
		  _doSave('a_',id_div,'');
	      break;
	      case "tb_docana":
		  _doSave('a_',id_div,'');
	      break;
	       case "tb_docmaterial":
		  _doSave('a_',id_div,'');
	      break;
	      case "tb_genero":
		  _doSave('a_',id_div,'');
	      break;
	      case "tb_cultura":
		  _doSave('a_',id_div,'');
	      break;
	      case "tb_acuerdos":
		  _doSave('a_',id_div,'');
	      break;
	      case "tb_alianzas":
		  if(validaAlianza()){
		    _doSave('a_',id_div,'');
		  }
	      break;
	       case "tb_sitios":
		  if(validaAlianza()){
		    _doSave('a_',id_div,'');
		  }
	      break;
	      case "tb_contacto":
		  if(validaContact()){
		    _doSave('a_',id_div,'');
		  }
	      break;
	      case "tb_direccion":
		  if(validaDireccion()){
		    _doSave('a_',id_div,'');
		  }
	      break;
	      case "tb_clientes":	       
	      if(validaClient()){

		  pass=document.getElementById("a_password").value;
		  xajax_checapass(pass,id_div);
// 		_doSave('a_',id_div,'');
	      }
	      break;
	    }
	}
// Validar forms
	function validaPricipal()
	{
	    if(document.getElementById("a_nombre_sector").value== ""){
	      alert("Escriba el Nombre:, corrija por favor");	
	      setTimeout("document.getElementById('a_nombre_sector').focus(),75");
	      return false;
	    }
	    if(document.getElementById("a_quienes_somos").value== ""){
	      alert("Escriba el contenido para ¿Quienes somos?, corrija por favor");	
	      setTimeout("document.getElementById('a_quienes_somos').focus(),75");
	      return false;
	    }
	    if(document.getElementById("a_mision").value== ""){
	      alert("Escriba el contenido para Misión, corrija por favor");	
	      setTimeout("document.getElementById('a_mision').focus(),75");
	      return false;
	    }
	    if(document.getElementById("a_vision").value== ""){
	      alert("Escriba el contenido para Visión, corrija por favor");	
	      setTimeout("document.getElementById('a_vision').focus(),75");
	      return false;
	    }
	    if(document.getElementById("a_objetivos").value== ""){
	      alert("Escriba el contenido para Objetivos, corrija por favor");	
	      setTimeout("document.getElementById('a_objetivos').focus(),75");
	      return false;
	    }
 	    //retorno verdadero para que pueda guardar
	    return true;
	}
	function validaDir()
	{
//correo no
	    
	    if(document.getElementById("a_cargo").value== 0){
	      alert("Elija el Cargo de su Empleado, corrija por favor");	
	      setTimeout("document.getElementById('a_cargo').focus(),75");
	      return false;
	    }
	    if(document.getElementById("a_nombre").value== ""){
	      alert("Escriba el Nombre de su Empleado, corrija por favor");	
	      setTimeout("document.getElementById('a_nombre').focus(),75");
	      return false;
	    }
 	    //retorno verdadero para que pueda guardar
	    return true;
	}
	function validaAgenda()
	{
//fecha de conclusion y requerimientos no
	    if(document.getElementById("a_fecha_ini").value== ""){
	      alert("Seleccione la Fecha de Inicio, corrija por favor");	
	      setTimeout("document.getElementById('a_fecha_ini').focus(),75");
	      return false;
	    }
 	    if(document.getElementById("a_evento").value== ""){
 	      alert("Describa el Evento, corrija por favor");	
	      setTimeout("document.getElementById('a_evento').focus(),75");
	      return false;
 	    }
	    if(document.getElementById("a_lugar").value== ""){
 	      alert("Escriba el Lugar, corrija por favor");	
	      setTimeout("document.getElementById('a_lugar').focus(),75");
	      return false;
 	    }
 	    //retorno verdadero para que pueda guardar
	    return true;
	}
	function validaNota()
	{
	    if(document.getElementById("a_fecha").value== ""){
	      alert("Seleccione una Fecha, corrija por favor");	
	      setTimeout("document.getElementById('a_fecha').focus(),75");
	      return false;
	    }
	    if(document.getElementById("a_nota").value== ""){
	      alert("Describa su Nota, corrija por favor");	
	      setTimeout("document.getElementById('a_nota').focus(),75");
	      return false;
	    }
 	    //retorno verdadero para que pueda guardar
	    return true;
	}
	function validaAlianza()
	{
	    if(document.getElementById("a_organizacion").value== ""){
	      alert("Escriba el nombre de la Organizacion, corrija por favor");	
	      setTimeout("document.getElementById('a_nombre').focus(),75");
	      return false;
	    }
 	    //retorno verdadero para que pueda guardar
	    return true;
	}
	function validaContact()
	{
	    if(document.getElementById("a_nombre").value== ""){
	      alert("Escriba su nombre, por favor");	
	      setTimeout("document.getElementById('a_nombre').focus(),75");
	      return false;
	    }	
	    if(document.getElementById("a_tel").value== ""){
	      alert("Escriba el Telefono, corrija por favor");	
	      setTimeout("document.getElementById('a_tel').focus(),75");
	      return false;
	    }	    
	    if(document.getElementById("a_asunto").value== ""){
	      alert("Escriba el Asunto, corrija por favor");	
	      setTimeout("document.getElementById('a_asunto').focus(),75");
	      return false;
	    }
	    if(document.getElementById("a_mensaje").value== ""){
	      alert("Escriba el Mensaje, corrija por favor");	
	      setTimeout("document.getElementById('a_mensaje').focus(),75");
	      return false;
	    }
 	    //retorno verdadero para que pueda guardar
	    return true;
	}
	function validaDireccion()
	{
	    if(document.getElementById("a_tel").value== ""){
	      alert("Escriba el Telefono, corrija por favor");	
	      setTimeout("document.getElementById('a_tel').focus(),75");
	      return false;
	    }
	     if(document.getElementById("a_refer").value== ""){
	      alert("Escriba las Referencias de su Empresa, corrija por favor");	
	      setTimeout("document.getElementById('a_refer').focus(),75");
	      return false;
	    }
	    if(document.getElementById("a_direc").value== ""){
	      alert("Escriba la Direccion de la empresa, corrija por favor");	
	      setTimeout("document.getElementById('a_direc').focus(),75");
	      return false;
	    }
	    if(document.getElementById("a_correo").value== ""){
	      alert("Escriba su Correo, corrija por favor");	
	      setTimeout("document.getElementById('a_correo').focus(),75");
	      return false;
	    }
 	    //retorno verdadero para que pueda guardar
	    return true;
	}
//BUSCAR DATOS EN LA BASE
	function buscaDatos(tabla,c_llave,c_referencia,mensaje,div_show)
	{	
	    if(document.getElementById("txt_busca").value == ""){
		    alert("Introduzca del Texto a Buscar");
		    setTimeout("document.getElementById('txt_busca').focus(),75");
		    return;
	    }
	    var params = new Array("buscar",tabla,c_referencia,c_llave,mensaje, document.getElementById("txt_busca").value,"a_");
	    xajax_showBusca(div_show,params,'','',"");
	}
	function muestradiv(tabla)
	{
	  id_cliente=document.getElementById("id_clientead").value;
	  xajax_muestradiv(tabla,id_cliente);
	}
//************************************
//************************************
// 	'a_',"tb_preg",''
	function _doSave(ant,tabla,funcion,funcBefore){
		ss=document.getElementById("form_main");
		var det = new Array();
		var vals = new Array(); 
		var x;
		x=0;
		    for(i=0;i<ss.elements.length;i++){
			    if(ss.elements[i].id.substring(0,ant.length) == ant){
				    det[x]=ss.elements[i].id.substr(ant.length,ss.elements[i].id.length);
				    vals[x]=ss.elements[i].value;
				    x++;
			    }
		    }
		    xajax_doSave(det,vals,tabla,funcion,funcBefore);
	}
	function kill_all(){
		if(document.getElementById("div_main").style.display=="none"){
			document.getElementById("div_main").style.display="";
		}
		try{
			kill('div_gdoc');
			die('div_aperturas');
		}catch(e){
			//nada
		}
	}
	
  function doCons(val_llave, tabla, campo_llave, ant, func)
 	{
			var params = new Array(campo_llave, val_llave);
 			  //id_tabla          tabla               id_eosm             a_
// 				1 --       tb_inicial --        id_almac             -- a_
 		ss=document.getElementById("form_main");
		var det = new Array();var vals = new Array();
 		
 		for(i=0;i<ss.elements.length;i++){
 			if(ss.elements[i].id.substring(0,ant.length) == ant){
 				params[i+2]=ss.elements[i].id.substr(ant.length,ss.elements[i].id.length);
 			}
 		}
		
		  id_almacen = document.getElementById("id_principal").value;
		  xajax_show("div_" + tabla, params,'','',func,id_almacen);
		
 	}


	function goBack(curr_div,prev_div){
		document.getElementById(curr_div).style.display='none';
		document.getElementById(prev_div).style.display='';
	} 	

        function openWin(str_win)
	{
			WindowWidth  = screen.width;
			WindowHeight = screen.height;
			CenterLeft = (screen.width - WindowWidth)/2;
			CenterTop = (screen.height - WindowHeight)/2;
			MyWindow = window.open(str_win,'','scrollbars=yes,LEFT=' + CenterLeft + 
				',TOP=' + CenterTop + ',WIDTH=' + WindowWidth + ',HEIGHT=' + WindowHeight + ',MENU=yes');	
	}
	function addOption(selectId, txt, val)
	{
		var objOption = new Option(txt, val);
		document.getElementById(selectId).options.add(objOption);
	}
        function addOptionParent(selectId, txt, val)
	{
		var objOption = new Option(txt, val);
		parent.document.getElementById(selectId).options.add(objOption);
                Mediabox.close();
	}

	function LlenaCombo(XObject,str_sql,ValDef)
	{
		document.getElementById(XObject).length=0;
		str_sql=str_sql.replace("from","FFRR");
		str_sql=str_sql.replace("FROM","FFRR");
		xajax_llenaCombo2(XObject,str_sql,ValDef);
	}
	function kill(idDiv){
		document.getElementById(idDiv).style.display="none";
	}
	function die(idDiv){
		document.getElementById(idDiv).innerHTML="";
	}

	function ChangeSel(id,xObj)
	{
		xObj =document.getElementById(xObj);
		var xc=0;
		xObj.selectedIndex=0;
		var xFind = false;
		for (xc=0;xc<=xObj.length-1;xc++){
			xObj.selectedIndex=xc;
			if (id==xObj.value){
// 				alert(id + " == " + xObj.value);
				xFind = true;
				break;
			}
		}
		if (!xFind){
			xObj.selectedIndex=0;
		}
	}

	function ValDate(sDate){
		var xc=0;
		var ar = new Array();
		for (xc=0; xc<sDate.length; xc++){
			if (isNaN(sDate.charAt(xc))){
				var xSep = sDate.charAt(xc);
				break;
			}
		}
		var arrayOfStrings = sDate.split(xSep);
		for (var i=0; i < arrayOfStrings.length; i++) {
			ar[i] = arrayOfStrings[i];
		}
		if(isNaN(ar[0])){return "Dìa incorrecto";}
		if(isNaN(ar[1])){return "Mes incorrecto";}
		if(isNaN(ar[2])){return "Año incorrecto";}
		
		if(ar[0]>=32){return "Dìa incorrecto";}
		if(ar[1]>=13){return "Mes incorrecto";}
		if(ar[2].length!=4){return "Año incorrecto";}
		document.getElementById('txt_fecha').value=ar[2]+"/"+ar[1]+"/"+ar[0];
		return "";
	}
	function ValDate2(sDate){
		var xc=0;
		var ar = new Array();
		for (xc=0; xc<sDate.length; xc++){
			if (isNaN(sDate.charAt(xc))){
				var xSep = sDate.charAt(xc);
				break;
			}
		}
		var arrayOfStrings = sDate.split(xSep);
		for (var i=0; i < arrayOfStrings.length; i++) {
			ar[i] = arrayOfStrings[i];
		}
		return ar[2]+"/"+ar[1]+"/"+ar[0];
	}


function saveoption(objetocombo,consulta,opcion){
		consulta=consulta.replace("from","FFRR");
		consulta=consulta.replace("FROM","FFRR");
		xajax_saveoption(objetocombo,consulta,opcion);
	}

function GuardaOption(objetocombo,consulta,opcion,tabla){
		consulta=consulta.replace("from","FFRR");
		consulta=consulta.replace("FROM","FFRR");
		xajax_GuardaOption(objetocombo,consulta,opcion,tabla);
	}

function solonumeros(e){
      
         tecla = e.which || e.keyCode;
         patron = /\d/; // Solo acepta números
         te = String.fromCharCode(tecla);
         return (patron.test(te) || tecla == 9 || tecla == 8 || tecla == 46);  
     
}	

var patron = new Array(2,2)
var mezcla = new Array(2,2,2)
// var patron2 = new Array(1,3,3,3,3)telefono
function mascara(d,sep,pat,nums){
if(d.valant != d.value){
	val = d.value
	largo = val.length
	val = val.split(sep)
	val2 = ''
	for(r=0;r<val.length;r++){
		val2 += val[r]	
	}
	if(nums){
		for(z=0;z<val2.length;z++){
			if(isNaN(val2.charAt(z))){
				letra = new RegExp(val2.charAt(z),"g")
				val2 = val2.replace(letra,"")
			}
		}
	}
	val = ''
	val3 = new Array()
	for(s=0; s<pat.length; s++){
		val3[s] = val2.substring(0,pat[s])
		val2 = val2.substr(pat[s])
	}
	for(q=0;q<val3.length; q++){
		if(q ==0){
			val = val3[q]
		}
		else{
			if(val3[q] != ""){
				val += sep + val3[q]
				}
		}
	}
	d.value = val
	d.valant = val
	}
}

function timepicker(time,element)
  {
	    hora = document.getElementById(element).value;
	    if(document.getElementById(element).value.length == 5)
	    {
	    document.getElementById(element).value = document.getElementById(element).value  + ' ' + time;
	    return;
	    }
	    if(document.getElementById(element).value.length == 8)
	    {
	    tiempo = hora.substr(6,2);
            camboahora = hora.replace(tiempo, time);
	    document.getElementById(element).value = camboahora;
	    return;
	    }
  }

function chekaUsuario(valor){
    if(valor==0){
    }
    if(valor==1){
    xajax_muestracampos('div_tb_admini')
    }
    if(valor==2){
    xajax_muestracampos('div_tb_asesores')
    }
    if(valor==3){
    xajax_show('div_tb_loginalumno')
    }
}
function muestraDatos(nombre)
{
xajax_muestradatos(nombre,'tb_educan')
}
function chkUsr(usuario, pass)
 	{
 	  if(usuario=="")
 	  {
 	  alert("Favor de Escribir el Nombre de Usuario");
 	  setTimeout("document.getElementById('administrador').focus(),75");
 	  return;
 	  }
 	  else if(pass=="")
 	  {
 	  alert("Favor de Escribir la contraseña");
 	  setTimeout("document.getElementById('password').focus(),75");
 	  return;
 	  }
	  if(document.getElementById("rememberme").checked == true)
	  {
	      cokkis = true;
	      xajax_chkUsr(usuario, pass, cokkis)
	  }
 	  else{
 	  xajax_chkUsr(usuario, pass)
 	  }
 	}

function chkUsrAdm(usuario, pass)
 	{
 	  if(usuario=="")
 	  {
 	  alert("Favor de Escribir el Nombre de Usuario");
 	  setTimeout("document.getElementById('administrador').focus(),75");
 	  return;
 	  }
 	  else if(pass=="")
 	  {
 	  alert("Favor de Escribir la contraseña");
 	  setTimeout("document.getElementById('password').focus(),75");
 	  return;
 	  }
	  if(document.getElementById("rememberme").checked == true)
	  {
	      cokkis = true;
	      xajax_chkUsrAdm(usuario, pass, cokkis)
	  }
 	  else{
 	  xajax_chkUsrAdm(usuario, pass)
 	  }
 	}
//curso
function subirArchivos(){
  var id_almacen = document.getElementById("a_id_prin").value;
  if(id_almacen=="")
  {
      alert("Antes de agregar el logo primero debes de guardar el registro");
      return;
  }
  var foto = document.getElementById("a_logo").value;
  foto=foto.split('.');
  ext=foto[foto.length-1];
  nombre_foto = foto[foto.length-2];
  ext=ext.replace(/^\s*|\s*$/g,"");
  nombre_foto=nombre_foto.replace(/^\s*|\s*$/g,"");
   window.Mediabox.open('HTML/subearchivos.php?id_almacen='+id_almacen+'&ext='+ext+'&nombre_foto='+nombre_foto, 'Subir Logo', '650 300');
}

function move_popup(e){
		Xoffset=0;
		Yoffset=0;
		var x=(ns4||ns6)?e.pageX:event.x+document.body.scrollLeft;
		Xoffset=(x+Xoffset)+10;
		var y=(ns4||ns6)?e.pageY:event.y+document.body.scrollTop;
		Yoffset=(y+Yoffset)+10;
		
		x_top = Yoffset.toString() + "px";
		x_left = Xoffset.toString() + "px";
 		document.getElementById("loading").style.top="0px";
 		document.getElementById("loading").style.left="0px";
 		document.getElementById("loading").style.top=x_top;
 		document.getElementById("loading").style.left=x_left;
	}

	var Xoffset;
	var Yoffset;
	var ns4=document.layers;
	var ns6=document.getElementById&&!document.all;
	var ie4=document.all;

	if(ns4)document.captureEvents(Event.MOUSEMOVE);
	else{
	}
	document.onmousemove=move_popup;
 	xajax.callback.global.onRequest = function() {xajax.$('loading').style.display = 'inline';}
 	xajax.callback.global.beforeResponseProcessing = function() {xajax.$('loading').style.display='none';}

function doOpen(str_win,titulo,id_ant)
	{
		id_anterior = "a";

		switch(str_win)
		{
			case "tb_fotos":
				if(id_anterior == "")
				{
				alert("Antes de abrir el album primero debe Seleccionar un registro");
				return;
				}
				var titulobox = "kdjkd";
// 				str_open="admini.php?show=div_" + str_win + "&titulo=" + titulo"";
				str_open="admini.php?show=div_tb_fotos&titulo='ss'";
			break;

		}
		WindowWidth  = 800;
		WindowHeight = 600;
		CenterLeft = (screen.width - WindowWidth)/2;
		CenterTop = (screen.height - WindowHeight)/2;
		//window.open(str_open,"main","status=1,toolbar=0,location=0,menubar=0,resizable=0,scrollbars=1,height=600,width=800");
// 		window.parent.Mediabox.open(str_open, titulobox, '800 600');
		 xajax_show("div_" + str_win);
	}
function chekaPortal(tabla){
      id_principal = document.getElementById("id_principal").value;           
      xajax_show(tabla,'','','','',id_principal); 
}
function getAlmacen(tabla){
  if(tabla == "div_tb_fotos" || tabla == "div_tb_anec"){
 
    almacen =  document.getElementById("id_principal").value;
    xajax_show(tabla,'','','','',almacen);
    return;
  }
  else{
    almacen =  document.getElementById("a_id_principal").value;
    xajax_show(tabla,'','','','',almacen);
    return;
  }
}
function tag(id) {
 return document.getElementById(id);
}

function subirfoto1(){
    var id_almac = document.getElementById("a_id_prin").value;
    var id_foto = document.getElementById("a_id_foto").value;
    if(id_foto=="")
    {
      alert("Antes de Insertar la Foto debes guardar el Registro");
      return;
    }
//   var id_almacen = document.getElementById("a_id_prin").value;
  var foto = document.getElementById("a_foto1").value;
  foto=foto.split('.');
  ext=foto[foto.length-1];
  nombre_foto = foto[foto.length-2];
  ext=ext.replace(/^\s*|\s*$/g,"");
  nombre_foto=nombre_foto.replace(/^\s*|\s*$/g,"");
   window.Mediabox.open('HTML/subirfoto1.php?id_almacen='+id_almac+'&id_foto='+id_foto+'&ext='+ext+'&nombre_foto='+nombre_foto, 'Foto 1', '650 300');
}
function subirfoto2(){
    var id_almac = document.getElementById("a_id_prin").value;
    var id_foto = document.getElementById("a_id_foto").value;
    if(id_foto=="")
    {
      alert("Antes de Insertar la Foto debes guardar el Registro");
      return;
    }
//   var id_almacen = document.getElementById("a_id_prin").value;
  var foto = document.getElementById("a_foto2").value;
  foto=foto.split('.');
  ext=foto[foto.length-1];
  nombre_foto = foto[foto.length-2];
  ext=ext.replace(/^\s*|\s*$/g,"");
  nombre_foto=nombre_foto.replace(/^\s*|\s*$/g,"");
   window.Mediabox.open('HTML/subirfoto2.php?id_almacen='+id_almac+'&id_foto='+id_foto+'&ext='+ext+'&nombre_foto='+nombre_foto, 'Foto 2', '650 300');
}
function subirfoto3(){
    var id_almac = document.getElementById("a_id_prin").value;
    var id_foto = document.getElementById("a_id_foto").value;
    if(id_foto=="")
    {
      alert("Antes de Insertar la Foto debes guardar el Registro");
      return;
    }
//   var id_almacen = document.getElementById("a_id_prin").value;
  var foto = document.getElementById("a_foto3").value;
  foto=foto.split('.');
  ext=foto[foto.length-1];
  nombre_foto = foto[foto.length-2];
  ext=ext.replace(/^\s*|\s*$/g,"");
  nombre_foto=nombre_foto.replace(/^\s*|\s*$/g,"");
   window.Mediabox.open('HTML/subirfoto3.php?id_almacen='+id_almac+'&id_foto='+id_foto+'&ext='+ext+'&nombre_foto='+nombre_foto, 'Foto 3', '650 300');
}
function subirfoto4(){
    var id_almac = document.getElementById("a_id_prin").value;
    var id_foto = document.getElementById("a_id_foto").value;
    if(id_foto=="")
    {
      alert("Antes de Insertar la Foto debes guardar el Registro");
      return;
    }
//   var id_almacen = document.getElementById("a_id_prin").value;
  var foto = document.getElementById("a_foto4").value;
  foto=foto.split('.');
  ext=foto[foto.length-1];
  nombre_foto = foto[foto.length-2];
  ext=ext.replace(/^\s*|\s*$/g,"");
  nombre_foto=nombre_foto.replace(/^\s*|\s*$/g,"");
   window.Mediabox.open('HTML/subirfoto4.php?id_almacen='+id_almac+'&id_foto='+id_foto+'&ext='+ext+'&nombre_foto='+nombre_foto, 'Foto 4', '650 300');
}
function subirfoto5(){
    var id_almac = document.getElementById("a_id_prin").value;
    var id_foto = document.getElementById("a_id_foto").value;
    if(id_foto=="")
    {
      alert("Antes de Insertar la Foto debes guardar el Registro");
      return;
    }
//   var id_almacen = document.getElementById("a_id_prin").value;
  var foto = document.getElementById("a_foto5").value;
  foto=foto.split('.');
  ext=foto[foto.length-1];
  nombre_foto = foto[foto.length-2];
  ext=ext.replace(/^\s*|\s*$/g,"");
  nombre_foto=nombre_foto.replace(/^\s*|\s*$/g,"");
   window.Mediabox.open('HTML/subirfoto5.php?id_almacen='+id_almac+'&id_foto='+id_foto+'&ext='+ext+'&nombre_foto='+nombre_foto, 'Foto 5', '650 300');
}
function subirfoto6(){
    var id_almac = document.getElementById("a_id_prin").value;
    var id_foto = document.getElementById("a_id_foto").value;
    if(id_foto=="")
    {
      alert("Antes de Insertar la Foto debes guardar el Registro");
      return;
    }
//   var id_almacen = document.getElementById("a_id_prin").value;
  var foto = document.getElementById("a_foto6").value;
  foto=foto.split('.');
  ext=foto[foto.length-1];
  nombre_foto = foto[foto.length-2];
  ext=ext.replace(/^\s*|\s*$/g,"");
  nombre_foto=nombre_foto.replace(/^\s*|\s*$/g,"");
   window.Mediabox.open('HTML/subirfoto6.php?id_almacen='+id_almac+'&id_foto='+id_foto+'&ext='+ext+'&nombre_foto='+nombre_foto, 'Foto 6', '650 300');
}
function subirdoc1(num){
   	  var id_almac = document.getElementById("a_id_prin").value;
	  var id_doc = document.getElementById("a_id_doc").value;
	  if(id_doc=="")
	  {
	    alert("Antes de Subir un archivo debes guardar el Registro");
	    return;
	  }
	//   var id_almacen = document.getElementById("a_id_prin").value;
	  var doc = document.getElementById("a_doc1").value;
	  if(doc=="")
	  {
	    window.Mediabox.open('HTML/subirdoc1.php?id_almacen='+id_almac+'&id_doc='+id_doc+'&num_doc='+num+'&num_doc='+num, 'Doc 1', '650 300');
	  }
	  else
	  {
	      doc=doc.split('.');
	      ext=doc[doc.length-1];
	      nombre_doc = doc[doc.length-2];
	      ext=ext.replace(/^\s*|\s*$/g,"");
	      nombre_doc=nombre_doc.replace(/^\s*|\s*$/g,"");
	      window.Mediabox.open('HTML/subirdoc1.php?id_almacen='+id_almac+'&id_doc='+id_doc+'&num_doc='+num+'&ext='+ext+'&nombre_doc='+nombre_doc+'&num_doc='+num, 'Doc 1', '650 300');
	  }
    
}
function subirdoc2(num){
    var id_almac = document.getElementById("a_id_prin").value;
    var id_doc = document.getElementById("a_id_doc").value;
    if(id_doc=="")
    {
      alert("Antes de Subir un archivo debes guardar el Registro");
      return;
    }
//   var id_almacen = document.getElementById("a_id_prin").value;
  var doc = document.getElementById("a_doc2").value;
  if(doc=="")
  {
    window.Mediabox.open('HTML/subirdoc2.php?id_almacen='+id_almac+'&id_doc='+id_doc+'&num_doc='+num, 'Doc 2', '650 300');
  }
  else
  {
      doc=doc.split('.');
      ext=doc[doc.length-1];
      nombre_doc = doc[doc.length-2];
      ext=ext.replace(/^\s*|\s*$/g,"");
      nombre_doc=nombre_doc.replace(/^\s*|\s*$/g,"");
      window.Mediabox.open('HTML/subirdoc2.php?id_almacen='+id_almac+'&id_doc='+id_doc+'&num_doc='+num+'&num_doc='+num+'&ext='+ext+'&nombre_doc='+nombre_doc, 'Doc 2', '650 300');
  }
}
function subirdoc3(num){
    var id_almac = document.getElementById("a_id_prin").value;
    var id_doc = document.getElementById("a_id_doc").value;
    if(id_doc=="")
    {
      alert("Antes de Subir un archivo debes guardar el Registro");
      return;
    }
//   var id_almacen = document.getElementById("a_id_prin").value;
  var doc = document.getElementById("a_doc3").value;
  if(doc=="")
  {
    window.Mediabox.open('HTML/subirdoc3.php?id_almacen='+id_almac+'&id_doc='+id_doc+'&num_doc='+num, 'Doc 3', '650 300');
  }
  else
  {
      doc=doc.split('.');
      ext=doc[doc.length-1];
      nombre_doc = doc[doc.length-2];
      ext=ext.replace(/^\s*|\s*$/g,"");
      nombre_doc=nombre_doc.replace(/^\s*|\s*$/g,"");
      window.Mediabox.open('HTML/subirdoc3.php?id_almacen='+id_almac+'&id_doc='+id_doc+'&num_doc='+num+'&ext='+ext+'&nombre_doc='+nombre_doc, 'Doc 3', '650 300');
  }
}
function subirdoc4(num){
    var id_almac = document.getElementById("a_id_prin").value;
    var id_doc = document.getElementById("a_id_doc").value;
    if(id_doc=="")
    {
      alert("Antes de Subir un archivo debes guardar el Registro");
      return;
    }
//   var id_almacen = document.getElementById("a_id_prin").value;
  var doc = document.getElementById("a_doc4").value;
  if(doc=="")
  {
    window.Mediabox.open('HTML/subirdoc4.php?id_almacen='+id_almac+'&id_doc='+id_doc+'&num_doc='+num, 'Doc 4', '650 300');
  }
  else
  {
      doc=doc.split('.');
      ext=doc[doc.length-1];
      nombre_doc = doc[doc.length-2];
      ext=ext.replace(/^\s*|\s*$/g,"");
      nombre_doc=nombre_doc.replace(/^\s*|\s*$/g,"");
      window.Mediabox.open('HTML/subirdoc4.php?id_almacen='+id_almac+'&id_doc='+id_doc+'&num_doc='+num+'&ext='+ext+'&nombre_doc='+nombre_doc, 'Doc 4', '650 300');
  }
}
function subirdoc5(num){
    var id_almac = document.getElementById("a_id_prin").value;
    var id_doc = document.getElementById("a_id_doc").value;
    if(id_doc=="")
    {
      alert("Antes de Subir un archivo debes guardar el Registro");
      return;
    }
//   var id_almacen = document.getElementById("a_id_prin").value;
  var doc = document.getElementById("a_doc5").value;
  if(doc=="")
  {
    window.Mediabox.open('HTML/subirdoc5.php?id_almacen='+id_almac+'&id_doc='+id_doc+'&num_doc='+num, 'Doc 5', '650 300');
  }
  else
  {
      doc=doc.split('.');
      ext=doc[doc.length-1];
      nombre_doc = doc[doc.length-2];
      ext=ext.replace(/^\s*|\s*$/g,"");
      nombre_doc=nombre_doc.replace(/^\s*|\s*$/g,"");
      window.Mediabox.open('HTML/subirdoc5.php?id_almacen='+id_almac+'&id_doc='+id_doc+'&num_doc='+num+'&ext='+ext+'&nombre_doc='+nombre_doc, 'Doc 5', '650 300');
  }
}
function subirdoc6(num){
    var id_almac = document.getElementById("a_id_prin").value;
    var id_doc = document.getElementById("a_id_doc").value;
    if(id_doc=="")
    {
      alert("Antes de Subir un archivo debes guardar el Registro");
      return;
    }
//   var id_almacen = document.getElementById("a_id_prin").value;
  var doc = document.getElementById("a_doc6").value;
  if(doc=="")
  {
    window.Mediabox.open('HTML/subirdoc6.php?id_almacen='+id_almac+'&id_doc='+id_doc+'&num_doc='+num, 'Doc 6', '650 300');
  }
  else
  {
      doc=doc.split('.');
      ext=doc[doc.length-1];
      nombre_doc = doc[doc.length-2];
      ext=ext.replace(/^\s*|\s*$/g,"");
      nombre_doc=nombre_doc.replace(/^\s*|\s*$/g,"");
      window.Mediabox.open('HTML/subirdoc6.php?id_almacen='+id_almac+'&id_doc='+id_doc+'&num_doc='+num+'&ext='+ext+'&nombre_doc='+nombre_doc, 'Doc 6', '650 300');
  }
}
function subirdoc7(num){
    var id_almac = document.getElementById("a_id_prin").value;
    var id_doc = document.getElementById("a_id_doc").value;
    if(id_doc=="")
    {
      alert("Antes de Subir un archivo debes guardar el Registro");
      return;
    }
//   var id_almacen = document.getElementById("a_id_prin").value;
  var doc = document.getElementById("a_doc7").value;
  if(doc=="")
  {
    window.Mediabox.open('HTML/subirdoc7.php?id_almacen='+id_almac+'&id_doc='+id_doc+'&num_doc='+num, 'Doc 7', '650 300');
  }
  else
  {
      doc=doc.split('.');
      ext=doc[doc.length-1];
      nombre_doc = doc[doc.length-2];
      ext=ext.replace(/^\s*|\s*$/g,"");
      nombre_doc=nombre_doc.replace(/^\s*|\s*$/g,"");
      window.Mediabox.open('HTML/subirdoc7.php?id_almacen='+id_almac+'&id_doc='+id_doc+'&num_doc='+num+'&ext='+ext+'&nombre_doc='+nombre_doc, 'Doc 7', '650 300');
  }
}
function subirdoc8(num){
    var id_almac = document.getElementById("a_id_prin").value;
    var id_doc = document.getElementById("a_id_doc").value;
    if(id_doc=="")
    {
      alert("Antes de Subir un archivo debes guardar el Registro");
      return;
    }
//   var id_almacen = document.getElementById("a_id_prin").value;
  var doc = document.getElementById("a_doc8").value;
  if(doc=="")
  {
    window.Mediabox.open('HTML/subirdoc8.php?id_almacen='+id_almac+'&id_doc='+id_doc+'&num_doc='+num, 'Doc 8', '650 300');
  }
  else
  {
      doc=doc.split('.');
      ext=doc[doc.length-1];
      nombre_doc = doc[doc.length-2];
      ext=ext.replace(/^\s*|\s*$/g,"");
      nombre_doc=nombre_doc.replace(/^\s*|\s*$/g,"");
      window.Mediabox.open('HTML/subirdoc8.php?id_almacen='+id_almac+'&id_doc='+id_doc+'&num_doc='+num+'&ext='+ext+'&nombre_doc='+nombre_doc, 'Doc 8', '650 300');
  }
}
function subirdoc9(num){
    var id_almac = document.getElementById("a_id_prin").value;
    var id_doc = document.getElementById("a_id_doc").value;
    if(id_doc=="")
    {
      alert("Antes de Subir un archivo debes guardar el Registro");
      return;
    }
//   var id_almacen = document.getElementById("a_id_prin").value;
  var doc = document.getElementById("a_doc9").value;
  if(doc=="")
  {
    window.Mediabox.open('HTML/subirdoc9.php?id_almacen='+id_almac+'&id_doc='+id_doc+'&num_doc='+num, 'Doc 9', '650 300');
  }
  else
  {
      doc=doc.split('.');
      ext=doc[doc.length-1];
      nombre_doc = doc[doc.length-2];
      ext=ext.replace(/^\s*|\s*$/g,"");
      nombre_doc=nombre_doc.replace(/^\s*|\s*$/g,"");
      window.Mediabox.open('HTML/subirdoc9.php?id_almacen='+id_almac+'&id_doc='+id_doc+'&num_doc='+num+'&ext='+ext+'&nombre_doc='+nombre_doc, 'Doc 9', '650 300');
  }
}
function cambiaremo(num){
    if(num==1)
    {
    emoticonclickeado = document.getElementById("img1").src;
    }
    if(num==2)
    {
    emoticonclickeado = document.getElementById("img2").src;
    }
    if(num==3)
    {
    emoticonclickeado = document.getElementById("img3").src;
    }
    if(num==4)
    {
    emoticonclickeado = document.getElementById("img4").src;
    }
    if(num==5)
    {
    emoticonclickeado = document.getElementById("img5").src;
    }
    if(num==6)
    {
    emoticonclickeado = document.getElementById("img6").src;
    }
    if(num==7)
    {
    emoticonclickeado = document.getElementById("img7").src;
    }
    if(num==8)
    {
    emoticonclickeado = document.getElementById("img8").src;
    }
    if(num==9)
    {
    emoticonclickeado = document.getElementById("img9").src;
    }
    if(num==10)
    {
    emoticonclickeado = document.getElementById("img10").src;
    }
document.getElementById("emoticon_actual").src=emoticonclickeado;
}

//Reportes de almacen
function ver_oraculo()
{
    window.Mediabox.open('reportes/oraculo.php', 'ORACULO', '900 400');	
}
function checapass()
{
    if(document.getElementById("a_password").value== ""){
    alert("Introduzca la Contraseña del Cliente, corrija por favor");	
    setTimeout("document.getElementById('a_password').focus(),75");	      
    }
    
    pass=document.getElementById("a_password").value;
    xajax_checapass(pass);
    
}
function AsignaAlmacen()
{
     if(document.getElementById("a_id_cliente").value== ""){
     alert("Antes de Asignar,Debe guardar el registro, corrija por favor");	
     setTimeout("document.getElementById('a_id_cliente').focus(),75");	      
     } 
     else
      {
//     pass=document.getElementById("a_password").value;
//     xajax_AsignaAlmacen(pass);
	var a_password = document.getElementById("a_password").value;
	window.Mediabox.open('HTML/tb_inicial.php?a_password='+a_password, 'AsignaAlmacen', '950 400');
    }
}
function ChekaCliente(){
id_cliente = document.getElementById("id_clientead").value;
pass = document.getElementById("passw").value;
if (id_cliente=="" && pass=="")
{
    alert("Antes de asignar, Seleccione o Guarde el Registro Actual");
    return;
}
xajax_show('div_tb_inicial','','','','',id_cliente,pass);
}
function getCliente(tabla){
  if(tabla == "div_tb_clientes"){    
    xajax_show(tabla,'','','','','','');
    return;
  }
  else{
    id_cliente = document.getElementById("id_clientead").value;
    pass = document.getElementById("passw").value;
    xajax_show('div_tb_inicial','','','','',id_cliente,pass);
    return;
  }
}
function nuevo()
{
    
    document.getElementById("a_id_dir").value="";
    document.getElementById("a_cargo").value=0;
    document.getElementById("a_nombre").value="";
    document.getElementById("a_correo").value="";
}
function nuevo1()
{
    document.getElementById("a_id_agenda").value="";
    document.getElementById("a_fecha_ini").value="";
    document.getElementById("a_fecha_fin").value="";
    document.getElementById("a_evento").value="";
    document.getElementById("a_lugar").value="";
    document.getElementById("a_requisitos").value="";
}
function nuevo2()
{
    document.getElementById("a_id_nota").value="";
    document.getElementById("a_fecha").value="";
    document.getElementById("a_nota").value="";    
}
function nuevo3()
{
    document.getElementById("a_id").value="";
    document.getElementById("a_organizacion").value="";
//     document.getElementById("a_fecha").value="";    
    document.getElementById("a_logo").value="ahh_icon_logo.png";  
    document.getElementById("a_comentario").value="";  
    document.getElementById("a_liga").value="";  
    document.getElementById("foto_perfil").src="images/alianzas/ahh_icon_logo.png";  
}
function nuevo4()
{
    document.getElementById("a_id_contacto").value="";
    document.getElementById("a_nombre").value="";
    document.getElementById("a_asunto").value="";
    document.getElementById("a_mensaje").value="";
    document.getElementById("a_tel").value="";
    document.getElementById("a_correo").value="";         
}
function abreimg(img_current){
    foto1 = $("a_foto1").value;
    foto2 = $("a_foto2").value;
    foto3 = $("a_foto3").value;
    foto4 = $("a_foto4").value;
    foto5 = $("a_foto5").value;
    foto6 = $("a_foto6").value;
Mediabox.open([['album/'+foto1, 'galeria', '600 600'],['album/'+foto2, 'galeria', '600 600'],['album/'+foto3, 'galeria', '600 600'],['album/'+foto4, 'galeria', '600 600'],['album/'+foto5, 'galeria', '600 600'],['album/'+foto6, 'galeria', '600 600']], img_current);
}
function ver_ayuda(tabla)
{
xajax_show(tabla,'','','','','','');
}
function abrir_comunicadosurge()
{
window.open("comunicados.php", "_self");
}
