<?
   session_start();
  require('../valtiempoinact.php');
  require('../conectar.php');
  $usuario_nivel=$_SESSION['usuario_nivel'];
  $usuario_login=$_SESSION['usuario_login'];
  
  $prospecto=mysql_query("select * from rentas where id_renta='$_GET[id]'",$db_conexion);
  if($rpro=mysql_fetch_array($prospecto))
  {
   $id_renta=$rpro['id_renta'];
   $id_cliente=$rpro['id_cliente'];
   $id_gerente=$rpro['id_gerente'];
   $id_coordinador=$rpro['id_coordinador'];
   $id_ejecutivo=$rpro['id_ejecutivo'];
   $prospeccion=$rpro['prospeccion'];
   $medio=$rpro['medio'];
   $submedio=$rpro['submedio'];
   $califica=$rpro['califica'];
   $motivo_nocal=$rpro['motivo_nocal'];
   $razon_ni=$rpro['razon_ni'];
   $id_departamento=$rpro['id_departamento'];
   $id_complejo=$rpro['id_complejo'];
   $fecha=$rpro['fecha'];
   $hora_registro=$rpro['hora_registro'];
   $dia_inicio=$rpro['dia_inicio'];
   $dia_salida=$rpro['dia_salida'];
   $fecha_apartado=$rpro['fecha_apartado'];
   $deposito=$rpro['deposito'];
   $hospedaje=$rpro['hospedaje'];
   $perextcama=$rpro['perextcama'];
   $per_extra=$rpro['per_extra'];
   $garage=$rpro['garage'];
   $camaextra=$rpro['camaextra'];
   $cuna=$rpro['cuna'];
   $mascota=$rpro['mascota'];
   $subtotal=$rpro['subtotal'];
   $impuesto=$rpro['impuesto'];
   $otros=$rpro['otros'];
   $total=$rpro['total'];
   $tipomoneda=$rpro['tipomoneda'];
   $formarenta=$rpro['formarenta'];
   $estmtostatus=$rpro['estmtostatus'];
   $camaexstatus=$rpro['camaexstatus'];
   $cunastatus=$rpro['cunastatus'];
   $mascotastatus=$rpro['mascotastatus'];
   $cuotainvitado=$rpro['cuotainvitado'];
   $noPersonas=$rpro['noPersonas'];
   $no_anios=$rpro['no_anios'];
   $no_meses=$rpro['no_meses'];
   $no_sem=$rpro['no_sem'];
   $no_dias=$rpro['no_dias'];
   $diasapartado=$rpro['diasapartado'];
   $ubicacionactual=$rpro['ubicacionactual'];
   $factura=$rpro['factura'];
   $tipopago=$rpro['tipopago'];
   $formapago=$rpro['formapago'];
   $limpieza=$rpro['limpieza'];
   $kit_B=$rpro['kit_B'];
   $fecha_cierre=$rpro['fecha_cierre'];
   $status_renta=$rpro['status_renta'];
   $seguimiento=$rpro['seguimiento'];
   $descuento=$rpro['descuento'];
   $autoriza_desc=$rpro['autoriza_desc'];
   $motivo_desc=$rpro['motivo_desc'];
   $tipo_renta=$rpro['tipo_renta'];
   $client_cierre=$rpro['client_cierre'];
   $tipo_cambio=$rpro['tipo_cambio'];
   $tipo_efectivo=$rpro['tipo_efectivo'];
   $infoadicional=$rpro['infoadicional'];
  }
  
  $datos_cliente=mysql_query("select * from clientes where id_cliente='$id_cliente'",$db_conexion); 
	if($rd=mysql_fetch_array($datos_cliente))
	 {
	   $nombre=$rd['nombre'];
	   $ap=$rd['a_pat'];
	   $am=$rd['a_mat'];
	   $email=$rd['email'];
	   $intacc1=$rd['intacc1'];
	   $coco1=$rd['coco1'];
	   $aco1=$rd['aco1'];
	   $num1=$rd['num1'];
	   $intacc2=$rd['intacc2'];
	   $coco2=$rd['coco2'];
	   $aco2=$rd['aco2'];
	   $num2=$rd['num2'];
	   $suestado=$rd['estado'];
	   $edad=$rd['edad'];
	   $motivo_viaje=$rd['motivo_viaje'];
	   $sexo=$rd['sexo'];
	   $empresa=$rd['empresa'];
	 }
	 
	 $edo=mysql_query("select * from lista_estados where id='$suestado'",$db_conexion);
    if($redo=mysql_fetch_array($edo))
	 {
	    $idedo=$redo['id'];
	    $suedo=$redo['opcion'];
	 }	 
	 
	 $depa=mysql_query("select * from departamentos where id_departamento='$id_departamento'",$db_conexion);
	 if($rdep=mysql_fetch_array($depa))
	 {
	  $clave_depto=$rdep['clave'];
	  $id_complejo=$rdep['id_complejo'];
	 }
	 
	 $complejo=mysql_query("select * from complejo where id_complejo='$id_complejo'",$db_conexion);
	 if($rcom=mysql_fetch_array($complejo))
	 {
	  $nombre_complejo=$rcom['nombre'];
	 }
	 
	 
function generaPaises()
  {	 
  
  require('../conectar.php');
  
   $prospecto2=mysql_query("select * from rentas where id_renta='$_GET[id]'",$db_conexion);
   if($rpro2=mysql_fetch_array($prospecto2))
   {
   $id_cliente2=$rpro2['id_cliente'];
   }
   
    $datos_cliente2=mysql_query("select * from clientes where id_cliente='$id_cliente2'",$db_conexion); 
	if($rd2=mysql_fetch_array($datos_cliente2))
	 {
	   $supais=$rd2['pais']; 
	 }
	 
  $elpais=mysql_query("select * from lista_paises where id='$supais'",$db_conexion);
    if($rpais=mysql_fetch_array($elpais))
     {
		 $elpais=$rpais['opcion'];
		 $idpais=$rpais['id'];
	 }
    
	if($idpais!=0)
    {
	$consulta=mysql_query("select id,opcion from lista_paises where id<>'$idpais'",$db_conexion);
	mysql_close();
    
	// Voy imprimiendo el primer select compuesto por los paises
	
	echo "<select name='paises' id='paises' onChange='cargaContenido(this.id)' style='width:129px'>";
	echo "<option value='$idpais' selected='selected'>$elpais</option>";

	while($registro=mysql_fetch_row($consulta))
	{
		echo "<option value='".$registro[0]."'>".$registro[1]."</option>";
	}
	echo "</select>";
	
	} else	{
	
	$consulta=mysql_query("select id,opcion from lista_paises",$db_conexion);
	mysql_close();
    
	// Voy imprimiendo el primer select compuesto por los paises
	
	echo "<select name='paises' id='paises' onChange='cargaContenido(this.id)' style='width:129px'>";
	while($registro=mysql_fetch_row($consulta))
	{
		echo "<option value='".$registro[0]."'>".$registro[1]."</option>";
	}
	echo "</select>";
	
	}
	
}
$url = "http://www.dolar.mx/tipo-de-cambio-sat/";
$palabra = "Tipo de Cambio SAT";
$x = 1;
$fd = @fopen($url, "r");
while($line=@fgets($fd,1000))
     {
      $pos = strpos ($line, $palabra);
	  if($pos)
	    {
		 $glosa = " ";
		 $line2=fgets($fd,1000);
		 $valor=strip_tags($glosa.trim($line2));
		 function fPasarNumero($str)
		 {
		  $caracteres ="%[^0-9 \. \- ]%";
		  $str=preg_replace($caracteres,"",$str);
		  return $str;
		 }
		 $convmxn=fPasarNumero($valor);
		 $convmxn=str_replace(" ","",$convmxn);
		 $convmxn=round($convmxn,2);
		}
     }
	 @fclose($fd);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script language='javascript'>
function capacidad()
{
 var noper=document.forma.npers.value; 
 var clave=document.forma.clavedep.value;
 $.post("capacidad_deptos.php", { cap: noper, idepa: clave}, function(data){
$("#mensaje").html(data);
 });
}
function lugarmot(val)
{
 var td1=document.getElementById("lugar");
 var td2=document.getElementById("lugar2");
  if(val!=""){td1.innerHTML="Nombre de la empresa o instituci&oacute;n:";td2.innerHTML="<input type='text' name='empoinst' id='empoinst'>";}else{td1.innerHTML="";td2.innerHTML="";}
}
function tarea()
{
 var tar=document.forma.tipo_renta.value;
 var fcierre=document.forma.testinput;
 var status=document.forma.status_renta;
 if(tar=="SOLO MODIFICAR")
  { 
   fcierre.disabled=1;    
   status.disabled=1;
  }
  else
  { 
   fcierre.disabled=0;    
   status.disabled=0;
  }
  
}

function verifica()
{
 var fcierrea=document.forma.fecha_cierre_anterior.value;
 var fcierre=document.forma.testinput.value;
 $.post("verifica_fecha_modificar.php", { fca: fcierrea, fc: fcierre},function(data) {$("#alerta_fecha").html(data);}); 
}

function validamail(mail)
    {
	 div = document.getElementById('msgmail');
     div.style.display ='';
     $.post("valmail.php", { email:mail}, function(data){
     $("#msgmail").html(data);
     });
    }
function ndias(){
     var fechain= document.forma.fr.value;
	 var fechafin= document.forma.fr2.value;	
	 $.post("nodias.php", { fini: fechain, ffin: fechafin}, function(data){
	 $("#totdias").html(data);
	 });
}	
</script>
<script language='javascript'>
function mostrar() {
div = document.getElementById('flotante');
div.style.display ='';
div2 = document.getElementById('cargando');
div2.style.display ='';
var no = forma.nombre.value;
var ap = forma.ap.value;
var am = forma.am.value;
var em = forma.mail.value;
var cmf = forma.comfr.value;
var pts = forma.ts.value;
var pms = forma.ms.value;
var pct = forma.ct.value;
var pcc = forma.cc.value;
var ptp = forma.tp.value;
var fi = forma.fr.value;
var ff = forma.fr2.value;
var pres = forma.presupuesto.value;
var est = forma.estmnto.value;
var cmex = forma.camaex.value;
var cun = forma.cuna.value;
var mskt = forma.mascota.value;
$.post("disponibles.php", { nombre: no, apat: ap, amat: am, mail: em, comfr: cmf, ts: pts, ms: pms, ct: pct, cc: pcc, tp: ptp, fini: fi, ffin: ff, presup: pres, esta: est, camaex: cmex, cuna: cun, mascota: mskt}, function(data){
$("#flotante").html(data);
 });
}
function cerrar() {
div = document.getElementById('flotante');
div.style.display='none';
}
</script>
<script language='javascript'>
function validar(contenido){
	document.forma.depto.length=0; 
	document.forma.depto2.length=0; 
	document.forma.depto.options[0] = new Option("-----COORDINADOR-----","","defaultSelected",""); 
	document.forma.depto2.options[0]=new Option("-----EJECUTIVO-----","","defaultSelected","");
	var indice=1; 

<? 
$sql_depto = "SELECT id_empleado,gerente,nombre,a_pat,a_mat from empleados where puesto='4' and fechabaja='0000-00-00'"; 
$rs_depto = mysql_query($sql_depto); 
if(mysql_num_rows($rs_depto)>0) 
  { 
   while($row_depto = mysql_fetch_assoc($rs_depto)) 
		{ 
?> 
		 if(contenido=='<?=$row_depto["gerente"]?>') 
		   { 
			document.forma.depto.options[indice] = new Option("<?=$row_depto["nombre"]." ".$row_depto["a_pat"]." ".$row_depto["a_mat"];?>","<?=$row_depto["id_empleado"]?>"); 
			indice++; 
			} 
<? 
		} 
   } 
?>  
}

function validar2(contenido) 
{ 
//alert(contenido); 
document.forma.depto2.length=0; 
document.forma.depto2.options[0] = new Option("-- EJECUTIVO --","","defaultSelected","");
var indice=1; 
<? 
$sql_depto = "SELECT * from empleados where puesto='5' and fechabaja='0000-00-00'"; 
$rs_depto = mysql_query($sql_depto); 
if(mysql_num_rows($rs_depto)>0) 
{ 
while($row_depto = mysql_fetch_assoc($rs_depto)) 
{ 
?> 
if(contenido=='<?=$row_depto["coordinador"]?>') 
{ 
document.forma.depto2.options[indice] = new Option("<?=$row_depto["nombre"]." ".$row_depto["a_pat"]." ".$row_depto["a_mat"];?>","<?=$row_depto["id_empleado"]?>"); 
indice++; 
} 

<? 
}}
 
?> 
}  
</script>

<script language='javascript'>
function validarmedio(contenido){
    //alert(contenido); 
	document.forma.submedio.length=0; 
	document.forma.submedio.options[0] = new Option("--SUBMEDIO--","","defaultSelected",""); 
	var indice=1; 
	

<?
$sql_depto = "SELECT idsubmedio,idcanal,subcanal from submedio"; 
$rs_depto = mysql_query($sql_depto); 
if(mysql_num_rows($rs_depto)>0) 
  { 
   while($row_depto = mysql_fetch_assoc($rs_depto)) 
		{ 
?> 
		 if(contenido=='<?=$row_depto["idcanal"]?>') 
		   { 
			document.forma.submedio.options[indice] = new Option("<?=$row_depto["subcanal"];?>","<?=$row_depto["idsubmedio"]?>"); 
			indice++; 
			} 
<? 
		} 
   } 
?>  
}
</script>
<link rel="stylesheet" type="text/css" href="select_dependientes.css">
<script type="text/javascript" src="select_dependientes.js"></script>
<script language="javascript" src="js/formasdepago.js"></script>

<!--ESTILO DEL AREA DE TRABAJO -->
<link id="rs-styleWidget" href="../../calendario/WidgetClass.css" type="text/css" rel="stylesheet"><link id="rs-styleUI" href="../../calendario/jquery-ui-1.css" type="text/css" rel="stylesheet"><style media="screen" type="text/css">#rs-iuqb {color: ;font-family: Arial;font-size:11px}</style><style media="screen" type="text/css">#rs-iuqb a:link {text-decoration:none;color: #B5AA33}</style><style media="screen" type="text/css">#rs-iuqb a:visited {text-decoration:none;color: #B5AA33}</style><style media="screen" type="text/css">#rs-iuqb a:hover {text-decoration:none;color: #B5AA33}</style><style media="screen" type="text/css">#rs-iuqb a:active {text-decoration:none;color: #B5AA33}</style><style media="screen" type="text/css">#rs-iuqb input {font-family: Arial}</style><style media="screen" type="text/css">#rs-iuqb select {font-family: Arial}</style><style media="screen" type="text/css">#rs-iuqb .rs-eventWrapper {background-color: #265565;}</style><script src="../../calendario/ga.js" async="" type="text/javascript"></script><script id="rs-WidgetHotelIuserQB_load" src="../../calendario/WidgetHotelIuserQB_load.js" type="text/javascript"></script>

<!-- estilo de inputs-->
<script>function foco(elemento) {elemento.style.border = "2px solid #000000";}function no_foco(elemento) {elemento.style.border = "1px solid #CCCCCC";}</script>
<!-- marcador en input-->
<style>    
input::-webkit-input-placeholder {
    color:#c00;
    font-weight: bold;
}
input:-moz-placeholder {
    color:#c00;
    font-weight: bold;
}
</style>

<!--solo numeros en input-->
</script>
    <script language="javascript">
    var nav4 = window.Event ? true : false;
    function IsNumber(evt){
    // Backspace = 8, Enter = 13, ’0' = 48, ’9' = 57, ‘.’ = 46
    var key = nav4 ? evt.which : evt.keyCode;
    return (key <= 13 || (key >= 48 && key <= 57) || key == 46);
    }
</script>
<script language="javascript">
function desasignar()  
{
 document.forma.deparprop.value="";
 document.forma.clavedep.value="";
 document.forma.fin.value="";
 document.forma.ffi.value="";
 document.forma.iddep.value="";
 document.forma.compl.value="";
 document.forma.deposito.value="0";
 document.forma.persext.value="0";
 document.forma.monto.value="0";
 document.forma.subtotal2.value="0";
 document.forma.iva2.value="0";
 document.forma.total2.value="0";
 document.forma.tipomoneda.value="USD";
 document.forma.ts2.value="";
 document.forma.ms2.value="";
 document.forma.ct2.value="";
 document.forma.cc2.value="";
 document.forma.tp2.value="";
 document.forma.ts2.checked=0;
 document.forma.ms2.checked=0;
 document.forma.ct2.checked=0;
 document.forma.cc2.checked=0;
 document.forma.tp2.checked=0;
 }
</script>
<script language="javascript">
function checa(val)
{
var prop = val;
switch (prop)
       {
	    case "ts":
 document.forma.ms2.value="";
 document.forma.ct2.value="";
 document.forma.cc2.value="";
 document.forma.tp2.value="";
 document.forma.ms2.checked=0;
 document.forma.ct2.checked=0;
 document.forma.cc2.checked=0;
 document.forma.tp2.checked=0;
 break;
       case "ms":
 document.forma.ts2.value="";
 document.forma.ct2.value="";
 document.forma.cc2.value="";
 document.forma.tp2.value="";
 document.forma.ts2.checked=0;
 document.forma.ct2.checked=0;
 document.forma.cc2.checked=0;
 document.forma.tp2.checked=0;
 break;
      case "ct":
 document.forma.ts2.value="";
 document.forma.ms2.value="";
 document.forma.cc2.value="";
 document.forma.tp2.value="";
 document.forma.ts2.checked=0;
 document.forma.ms2.checked=0;
 document.forma.cc2.checked=0;
 document.forma.tp2.checked=0;
 break;
      case "cc":
 document.forma.ts2.value="";
 document.forma.ms2.value="";
 document.forma.ct2.value="";
 document.forma.tp2.value="";
 document.forma.ts2.checked=0;
 document.forma.ms2.checked=0;
 document.forma.ct2.checked=0;
 document.forma.tp2.checked=0;
 break;
      case "tp":
 document.forma.ts2.value="";
 document.forma.ms2.value="";
 document.forma.ct2.value="";
 document.forma.cc2.value="";
 document.forma.ts2.checked=0;
 document.forma.ms2.checked=0;
 document.forma.ct2.checked=0;
 document.forma.cc2.checked=0;
 break;
	   }
}
</script>
<script language="javascript">
function hide()
{
var text = document.forma.comfr;
var label1 = document.forma.label;
var comfr = document.forma.frequerido;
var fr = document.forma.fr;
var fr2 = document.forma.fr2;
var nic = document.forma.nic;
var nit = document.forma.nit;
var tst = document.forma.tst;
var mst = document.forma.mst;
var ctt = document.forma.ctt;
var cct = document.forma.cct;
var tpt = document.forma.tpt;
var tst2 = document.forma.tst2;
var mst2 = document.forma.mst2;
var ctt2 = document.forma.ctt2;
var cct2 = document.forma.cct2;
var tpt2 = document.forma.tpt2;
var tst3 = document.forma.tst3;
var mst3 = document.forma.mst3;
var ctt3 = document.forma.ctt3;
var cct3 = document.forma.cct3;
var tpt3 = document.forma.tpt3;
var ts = document.forma.ts;
var ms = document.forma.ms;
var ct = document.forma.ct;
var cc = document.forma.cc;
var tp = document.forma.tp;
var presupuestot = document.forma.presupuestot;
var presupuesto = document.forma.presupuesto;
var ncal = document.forma.ncal;
var mncal = document.forma.mncal;
var causa = document.forma.causa;
var anadirmnq = document.forma.anadirmnq;
var anadirni = document.forma.anadirni;
var causani = document.forma.causani;
var estmtotx=document.forma.estmtotx;
var camaextx = document.forma.camaextx;
var cunatx = document.forma.cunatx;
var mascotatx = document.forma.mascotatx;
var invitadotx = document.forma.invitadotx;
var estmnto = document.forma.estmnto;
var camaex = document.forma.camaex;
var cuna = document.forma.cuna;
var mascota = document.forma.mascota;
var invitado = document.forma.invitado;
var npers= document.forma.npers;
var nper= document.forma.nper;
var desc= document.forma.descto;
var descto= document.forma.descuento;
var data="";
var huespedes = document.getElementById('huespedes');
var disponibles = document.getElementById('disponibles');
if(document.forma.combo.value == "NQ")
{
$("#totdias").html(data);
document.forma.comfr.value="";
document.forma.fr.value="";
document.forma.fr2.value="";
document.forma.nic.value="";
document.forma.ts.checked=false;
document.forma.ms.checked=false;
document.forma.ct.checked=false;
document.forma.cc.checked=false;
document.forma.tp.checked=false;
document.forma.presupuesto.value="";
document.forma.causa.value="";
npers.value="";

huespedes.style.display ='none';
text.style.visibility = "hidden";
label1.style.visibility = "hidden";
comfr.style.visibility = "hidden";
fr.style.visibility = "hidden";
fr2.style.visibility = "hidden";
npers.style.visibility = "hidden";
nper.style.visibility = "hidden";
desc.style.visibility="hidden";
descto.style.visibility="hidden";
nic.style.visibility = "hidden";
nit.style.visibility = "hidden";
tst.style.visibility = "hidden";
mst.style.visibility = "hidden";
ctt.style.visibility = "hidden";
cct.style.visibility = "hidden";
tpt.style.visibility = "hidden";
tst2.style.visibility = "hidden";
mst2.style.visibility = "hidden";
ctt2.style.visibility = "hidden";
cct2.style.visibility = "hidden";
tpt2.style.visibility = "hidden";
tst3.style.visibility = "hidden";
mst3.style.visibility = "hidden";
ctt3.style.visibility = "hidden";
cct3.style.visibility = "hidden";
tpt3.style.visibility = "hidden";
ts.style.visibility = "hidden";
ms.style.visibility = "hidden";
ct.style.visibility = "hidden";
cc.style.visibility = "hidden";
tp.style.visibility = "hidden";
estmtotx.style.visibility = "hidden";
camaextx.style.visibility = "hidden";
cunatx.style.visibility = "hidden";
mascotatx.style.visibility = "hidden";
invitadotx.style.visibility = "hidden";
estmnto.style.visibility = "hidden";
camaex.style.visibility = "hidden";
cuna.style.visibility = "hidden";
mascota.style.visibility = "hidden";
invitado.style.visibility = "hidden";
presupuestot.style.visibility = "hidden";
presupuesto.style.visibility = "hidden";
ncal.style.visibility = "visible";
mncal.style.visibility = "visible";
disponibles.style.display = "none";
causa.style.visibility="visible";
anadirmnq.style.visibility="visible";
anadirni.style.visibility="hidden";
causani.style.visibility="hidden";
}
else
{
document.forma.mncal.value="";
text.style.visibility = "visible";
label1.style.visibility = "visible";
ncal.style.visibility = "hidden";
mncal.style.visibility = "hidden";
causa.style.visibility = "hidden";
anadirmnq.style.visibility="hidden";
}
}
</script>

<script language="javascript">
function califica()
{
var text = document.forma.frequerido;
var fr = document.forma.fr;
var fr2 = document.forma.fr2;
var nit = document.forma.nit;
var nic = document.forma.nic;
var tst = document.forma.tst;
var mst = document.forma.mst;
var ctt = document.forma.ctt;
var cct = document.forma.cct;
var tpt = document.forma.tpt;
var tst2 = document.forma.tst2;
var mst2 = document.forma.mst2;
var ctt2 = document.forma.ctt2;
var cct2 = document.forma.cct2;
var tpt2 = document.forma.tpt2;
var tst3 = document.forma.tst3;
var mst3 = document.forma.mst3;
var ctt3 = document.forma.ctt3;
var cct3 = document.forma.cct3;
var tpt3 = document.forma.tpt3;
var ts = document.forma.ts;
var ms = document.forma.ms;
var ct = document.forma.ct;
var cc = document.forma.cc;
var tp = document.forma.tp;
var anadirni = document.forma.anadirni;
var causani = document.forma.causani;
var estmtotx=document.forma.estmtotx;
var camaextx = document.forma.camaextx;
var cunatx = document.forma.cunatx;
var mascotatx = document.forma.mascotatx;
var invitadotx = document.forma.invitadotx;
var estmnto = document.forma.estmnto;
var camaex = document.forma.camaex;
var cuna = document.forma.cuna;
var mascota = document.forma.mascota;
var invitado = document.forma.invitado;
var presupuestot = document.forma.presupuestot;
var presupuesto = document.forma.presupuesto;
var npers= document.forma.npers;
var nper= document.forma.nper;
var desc= document.forma.descto;
var descto= document.forma.descuento;
var data="";
var huespedes = document.getElementById('huespedes');
var disponibles = document.getElementById('disponibles');
if(document.forma.comfr.value == "LP")
{
$("#totdias").html(data);
document.forma.fr.value="";
document.forma.fr2.value="";
document.forma.nic.value="";
document.forma.presupuesto.value="";
document.forma.ts.checked=false;
document.forma.ms.checked=false;
document.forma.ct.checked=false;
document.forma.cc.checked=false;
document.forma.tp.checked=false;
document.forma.ts.value="";
document.forma.ms.value="";
document.forma.ct.value="";
document.forma.cc.value="";
document.forma.tp.value="";
document.forma.causa.value="";
npers.value="";

huespedes.style.display ='none';
text.style.visibility = "visible";
fr.style.visibility = "visible";
fr2.style.visibility = "visible";
npers.style.visibility = "visible";
nper.style.visibility = "visible";
desc.style.visibility="visible";
descto.style.visibility="visible";
tst.style.visibility = "visible";
mst.style.visibility = "visible";
ctt.style.visibility = "visible";
cct.style.visibility = "visible";
tpt.style.visibility = "visible";
tst2.style.visibility = "visible";
mst2.style.visibility = "visible";
ctt2.style.visibility = "visible";
cct2.style.visibility = "visible";
tpt2.style.visibility = "visible";
tst3.style.visibility = "visible";
mst3.style.visibility = "visible";
ctt3.style.visibility = "visible";
cct3.style.visibility = "visible";
tpt3.style.visibility = "visible";
ts.style.visibility = "visible";
ms.style.visibility = "visible";
ct.style.visibility = "visible";
cc.style.visibility = "visible";
tp.style.visibility = "visible";

estmtotx.style.visibility = "visible";
camaextx.style.visibility = "visible";
cunatx.style.visibility = "visible";
mascotatx.style.visibility = "visible";
invitadotx.style.visibility = "hidden";
estmnto.style.visibility = "visible";
camaex.style.visibility = "visible";
cuna.style.visibility = "visible";
mascota.style.visibility = "visible";
invitado.style.visibility = "hidden";

presupuestot.style.visibility = "visible";
presupuesto.style.visibility = "visible";
nit.style.visibility = "hidden";
nic.style.visibility = "hidden";
disponibles.style.display = "block";
anadirni.style.visibility="hidden";
causani.style.visibility="hidden";
}
if(document.forma.comfr.value == "CP")
{
$("#totdias").html(data);
document.forma.fr.value="";
document.forma.fr2.value="";
document.forma.nic.value="";
document.forma.presupuesto.value="";
document.forma.ts.value="";
document.forma.ms.value="";
document.forma.ct.value="";
document.forma.cc.value="";
document.forma.tp.value="";
document.forma.ts.checked=false;
document.forma.ms.checked=false;
document.forma.ct.checked=false;
document.forma.cc.checked=false;
document.forma.tp.checked=false;
document.forma.causa.value="";
npers.value="";

huespedes.style.display ='none';
text.style.visibility = "visible";
fr.style.visibility = "visible";
fr2.style.visibility = "visible";
npers.style.visibility = "visible";
nper.style.visibility = "visible";
desc.style.visibility="visible";
descto.style.visibility="visible";
tst.style.visibility = "visible";
mst.style.visibility = "visible";
ctt.style.visibility = "visible";
cct.style.visibility = "visible";
tpt.style.visibility = "visible";
tst2.style.visibility = "visible";
mst2.style.visibility = "visible";
ctt2.style.visibility = "visible";
cct2.style.visibility = "visible";
tpt2.style.visibility = "visible";
tst3.style.visibility = "visible";
mst3.style.visibility = "visible";
ctt3.style.visibility = "visible";
cct3.style.visibility = "visible";
tpt3.style.visibility = "visible";
ts.style.visibility = "visible";
ms.style.visibility = "visible";
ct.style.visibility = "visible";
cc.style.visibility = "visible";
tp.style.visibility = "visible";

estmtotx.style.visibility = "visible";
camaextx.style.visibility = "visible";
cunatx.style.visibility = "visible";
mascotatx.style.visibility = "visible";
invitadotx.style.visibility = "hidden";
estmnto.style.visibility = "visible";
camaex.style.visibility = "visible";
cuna.style.visibility = "visible";
mascota.style.visibility = "visible";
invitado.style.visibility = "hidden";

presupuestot.style.visibility = "visible"; 
presupuesto.style.visibility = "visible";
nit.style.visibility = "hidden";
nic.style.visibility = "hidden";
disponibles.style.display = "block";
anadirni.style.visibility="hidden";
causani.style.visibility="hidden";
}
if(document.forma.comfr.value == "NI")
{
$("#totdias").html(data);
nit.style.visibility = "visible";
nic.style.visibility = "visible";
text.style.visibility = "hidden";
fr.style.visibility = "hidden";
fr2.style.visibility = "hidden";
npers.style.visibility = "hidden";
nper.style.visibility = "hidden";
desc.style.visibility="hidden";
descto.style.visibility="hidden";
tst.style.visibility = "hidden";
mst.style.visibility = "hidden";
ctt.style.visibility = "hidden";
cct.style.visibility = "hidden";
tpt.style.visibility = "hidden";
tst2.style.visibility = "hidden";
mst2.style.visibility = "hidden";
ctt2.style.visibility = "hidden";
cct2.style.visibility = "hidden";
tpt2.style.visibility = "hidden";
tst3.style.visibility = "hidden";
mst3.style.visibility = "hidden";
ctt3.style.visibility = "hidden";
cct3.style.visibility = "hidden";
tpt3.style.visibility = "hidden";
ts.style.visibility = "hidden";
ms.style.visibility = "hidden";
ct.style.visibility = "hidden";
cc.style.visibility = "hidden";
tp.style.visibility = "hidden";
estmtotx.style.visibility = "hidden";
camaextx.style.visibility = "hidden";
cunatx.style.visibility = "hidden";
mascotatx.style.visibility = "hidden";
//invitadotx.style.visibility = "hidden";
estmnto.style.visibility = "hidden";
camaex.style.visibility = "hidden";
cuna.style.visibility = "hidden";
mascota.style.visibility = "hidden";
//invitado.style.visibility = "hidden";
presupuestot.style.visibility = "hidden";
presupuesto.style.visibility = "hidden";
disponibles.style.display = "none";
anadirni.style.visibility="visible";
causani.style.visibility="visible";
}
}
</script>
<script language="javascript">
function motivos()
	{ 
	 var causa = document.forma.causa;
     if(document.forma.mncal.value == 'BUSCA OTRA UBICACION' || document.forma.mncal.value == 'OTRA')
		{
		 causa.style.visibility = "visible";
		}else{
		 document.forma.causa.value="";
		 causa.style.visibility = "hidden";
		}
	}
</script>

<!--Crea Inputs dinamicos -->
<script type="text/javascript">
<!--
var num=1;
function crear() {
var ncapacidad=document.forma.cap.value;
var nlimite=document.forma.lim.value;
var perextras=document.forma.npers.value;
var totalextras=perextras-ncapacidad;
var nmax=totalextras; 
var valor=""; 
var valorap=""; 
var valoram=""; 
  if(num<=nmax){
  //num++;
  fi = document.getElementById('fiel'); // 1
  contenedor = document.createElement('div'); // 2
  contenedor.id = 'div'+num; // 3
  fi.appendChild(contenedor); // 4
  
  //para ap
  eleap = document.createElement('input'); // 5
  eleap.type = 'text'; // 6
  eleap.value = 'Apellido Paterno'+num;
  eleap.name = 'ap'+num; // 6
  eleap.id = 'ap'+num;
  valorap='Apellido Paterno'+num;
  eleap.addEventListener("focus",function(){if(this.value==valorap){this.value=""}},false);
  eleap.addEventListener("blur",function(){if(this.value==""){this.value=valorap}},false);
  contenedor.appendChild(eleap); // 7
  //para am
  eleam = document.createElement('input'); // 5
  eleam.type = 'text'; // 6
  eleam.value = 'Apellido Materno'+num;
  eleam.name = 'am'+num; // 6
  eleam.id = 'am'+num;
  valoram='Apellido Materno'+num;
  eleam.addEventListener("focus",function(){if(this.value==valoram){this.value=""}},false);
  eleam.addEventListener("blur",function(){if(this.value==""){this.value=valoram}},false);
  contenedor.appendChild(eleam); // 7
  //para nombre
  ele = document.createElement('input'); // 5
  ele.type = 'text'; // 6
  ele.value = 'Nombre'+num;
  ele.name = 'fil'+num; // 6
  ele.id = 'fil'+num;
  valor='Nombre'+num;
  ele.addEventListener("focus",function(){if(this.value==valor){this.value=""}},false);
  ele.addEventListener("blur",function(){if(this.value==""){this.value=valor}},false);
  contenedor.appendChild(ele); // 7
    
  ele = document.createElement('input'); // 5
  ele.type = 'button'; // 6
  ele.value = 'Borrar(-)'; // 8
  ele.name = 'div'+num; // 8
  ele.onclick = function () {borrar(this.name)} // 9
  contenedor.appendChild(ele); // 7  
  num=num+1;  
   }
   /* if(num>19){
	  num=0;
	}*/
	
 
}
function borrar(obj) {
  // alert(num);
  dis=false;
  fi = document.getElementById('fiel'); // 1 
  fi.removeChild(document.getElementById(obj)); // 10
   if(num==1){
  dis= false ? '' : 'none';
  tab=document.getElementById('tab');
  tab.getElementsByTagName('tr')[2].style.display=dis;
  dis=true;
  //w=0;
 }/*else{
    dis= true ? '' : 'none';
  tab=document.getElementById('tab');
  tab.getElementsByTagName('tr')[2].style.display=dis;
  //num=0;
  //dis=false;
   alert(dis+"-"+ num);
   //w=0;
 }*/
 num=num-1;
  }
  

w=0;
function tabla() {
 w++;
  if(w==1){
	 /* fi = document.getElementById('fiel'); // 1
	  contenedor = document.createElement('div'); // 2
	  contenedor.id = 'div'+w; // 3
	  fi.appendChild(contenedor); // 4*/
	 //para tabla
	  var tabla = document.getElementById("tab");
	  var tbody = document.createElement("tbody");
	  var tr = document.createElement("TR");
	  for (var j=0; j<1; j++) {			
	  var td = document.createElement("TD");
		tr.appendChild(td);
		
		var td2 = document.createElement('td');
		tr.appendChild(td2);
		
		var td3 = document.createElement('td');
		tr.appendChild(td3);
		}
				
		tbody.appendChild(tr);
		tabla.appendChild(tbody);
		
		td.setAttribute("width","129");
		td.setAttribute("bgcolor","#660000");
		td.setAttribute("class","mainfontbold");
		td.setAttribute("align","left");
		td.setAttribute("style","color:#FFFFFF");
		textNode = document.createTextNode("Apellido Paterno");
		td.appendChild(textNode);
		
		td2.setAttribute("width","129");
		td2.setAttribute("bgcolor","#660000");
		td2.setAttribute("class","mainfontbold");
		td2.setAttribute("align","left");
		td2.setAttribute("style","color:#FFFFFF");
		textNode = document.createTextNode("Apellido Materno");
		td2.appendChild(textNode);
		  
		td3.setAttribute("width","129");
		td3.setAttribute("bgcolor","#660000");
		td3.setAttribute("class","mainfontbold");
		td3.setAttribute("align","left");
		td3.setAttribute("style","color:#FFFFFF");
		textNode = document.createTextNode("Nombre(s)");
		td3.appendChild(textNode);  
		  //contenedor.appendChild(t); // 7
		  //w=2;
		}
}
--> 
</script>

<script type="text/javascript">
<!--
function anadir(frm) {
   if(frm.agregar.value == ''){
      alert('No puedes Introducir opciones en blanco');
   }else{
  opt = new Option(frm.agregar.value,frm.agregar.value);
  frm.motviaje.options[frm.motviaje.options.length] = opt;
  frm.agregar.value = '';
  }
}
 function anadirtipopros(frm) { 
  if(frm.agregartpros.value == ''){
      alert('No puedes Introducir opciones en blanco');
   }else{
  optagrepros = new Option(frm.agregartpros.value,frm.agregartpros.value);
  frm.tipoprospeccion.options[frm.tipoprospeccion.options.length] = optagrepros;
  frm.agregartpros.value = '';
  }
 }

 function anadirmotnq(frm) { 
  if(frm.causa.value == ''){
      alert('No puedes Introducir opciones en blanco');
   }else{
  optmnq = new Option(frm.causa.value,frm.causa.value);
  frm.mncal.options[frm.mncal.options.length] = optmnq;
  frm.causa.value = '';
  }
 }
 
   function anadirmedio(frm) { 
  if(frm.agregarmedio.value == ''){
      alert('No puedes Introducir opciones en blanco');
   }else{
  optmnq = new Option(frm.agregarmedio.value,frm.agregarmedio.value);
  frm.medio.options[frm.medio.options.length] = optmnq;
  frm.agregarmedio.value = '';
  }
 }
 
 function anadirsubmedio(frm) { 
  if(frm.agregarsubmedio.value == ''){
      alert('No puedes Introducir opciones en blanco');
   }else{
  optmnq = new Option(frm.agregarsubmedio.value,frm.agregarsubmedio.value);
  frm.submedio.options[frm.submedio.options.length] = optmnq;
  frm.agregarsubmedio.value = '';
  }
 } 
 
 function anadircni(frm) { 
  if(frm.causani.value == ''){
      alert('No puedes Introducir opciones en blanco');
   }else{
  optni = new Option(frm.causani.value,frm.causani.value);
  frm.nic.options[frm.nic.options.length] = optni;
  frm.causani.value = '';
  }
 }
-->
</script>

<!--Combos dependientes -->
<script language="javascript" src="js/jquery-1.2.6.min.js"></script>
<!--CALENDARIO ESTANCIA ACTUAL-->
<LINK rel="stylesheet" type="text/css" href="calendario/calendar.css" 
media="screen">
<SCRIPT type="text/javascript" src="calendario/mootools-1.2.5-core-yc.js"></SCRIPT>
<!--<SCRIPT type="text/javascript" src="calendario/mootools-1.2.5.1-more-yc.js"></SCRIPT>-->
<!--<SCRIPT type="text/javascript" src="calendario/slideshowjc-yc.js"></SCRIPT>
<SCRIPT type="text/javascript" src="calendario/_class.noobSlide.packed.js"></SCRIPT>-->
<SCRIPT type="text/javascript" src="calendario/calendar.js"></SCRIPT>
<SCRIPT type="text/javascript" src="calendario/calendar-en.js"></SCRIPT>
<SCRIPT type="text/javascript" src="calendario/calendar-setup.js"></SCRIPT>
<!--TERMINA CALENDARIO ACTUAL ESTANCIA-->
<!-- estilo de botones-->
<link rel="stylesheet" type="text/css" href="css/botones_bonitos.css" />

<!-- PARA LA FECHA DE CIERRE -->
<script language="javascript" src="calendario_cierre/calendar_db.js"></script>
<link type="text/css" href="calendario_cierre/calendar.css" rel="stylesheet" />
<!-- PARA LA FECHA DE CIERRE -->
<style>
    .datos{border:0;-moz-border-radius: 5px;-webkit-border-radius: 5px;border-radius: 5px;-khtml-border-radius: 5px;border-collapse: collapse;background:#ffffff url(images/tlcancion.jpg) repeat-x;;color:#0d0d0d;}
	.tcitas{border:0;border-collapse: collapse;color:#0d0d0d;font-size:13px;}
    .datos a{color:#0d0d0d;font-weight:bold;} 
	.datos img{border:none}
    .datos .tdi{font-size:11px;}
    .datos .tdi b{color:#585858;}
	.datos .trs{min-height:20px !important;max-height:20px !important;height:20px !important;}
	.datos .trs:hover{background:#01A9DB;font-weight:bold;color:#ffffff;}	
	.datos .trs:hover a{color:#ffffff;}	
	.datos .trs:hover .inp{color:#ffffff;font-weight:bold;}	
	.datos .trs .tds{border-left:1px solid #BDBDBD;}	
	.datos .trs .tdf{border-left:1px solid #BDBDBD;overflow:hidden;}	
	.datos .trss{min-height:30px !important;}	
	.datos .trss1{min-height:30px !important;max-height:30px !important;height:30px !important;background:url(images/tcancion.jpg) repeat-x;color:#ffffff;}	
	.datos .trst{min-height:33px !important;max-height:33px !important;height:33px !important;overflow:hidden;}	
	.datos .trst td{padding-left:15px;}	
	.datos .inp{background:none;border:none;text-align:center;font-color:#000000;}
	.modf {background:#ffffff;color:#000000;width:110px !important;height:70px !important;display:none;position:absolute;left:50%;margin-left:-300px;margin-top:-20px;border:1px solid #D8D8D8;-moz-border-radius: 5px;-webkit-border-radius: 5px;border-radius: 5px;-khtml-border-radius: 5px;-moz-box-shadow: 5px 5px 5px #585858;
-webkit-box-shadow: 5px 5px 5px #585858;box-shadow: 5px 5px 5px #585858;}
	.btnmod{margin-top:10px;color:#ffffff;background:#01A9DB;width:40px;height:15px;border:0;-moz-border-radius: 5px;-webkit-border-radius: 5px;border-radius: 5px;-khtml-border-radius: 5px;padding-top:4px;cursor:hand;cursor:pointer}
	.btnmod:hover{background:#2E9AFE;}
	.puntero{position:absolute;background:url(images/list-pointer.png);width:30px;height:14px;margin-top:11px;margin-left:15px;}
</style>
<script>
var columna=new Array();
var fila=new Array();
var i,na,contmod=1;
var status=1;
<?
  $sql="SELECT * FROM citas WHERE id_renta='$id_renta' order by fecha asc";
  $re=mysql_query($sql);
  $nr=mysql_num_rows($re);
?>
var idn=<?echo $nr;?>;
<?
  $x=0;
  $y=1;
  while($l=mysql_fetch_array($re))
  {
?> 
   columna=new Array();
   columna[0]=<?echo $y;?>;
   columna[1]="<?echo $l['fecha'];?>";
   columna[2]="<?echo $l['asistio'];?>";
   columna[3]="<?echo $l['hora'];?>";
   columna[4]="<?echo $l['observacion'];?>";
   fila[<?echo $x?>]=columna;
<?
   $x++;
   $y++;
  }
?>
function vercitas(){cierramod();cierramodh();if(contmod==0){document.getElementById("vermas").innerHTML="<font style='color:#000000;font-size:12px;'>mostrar</font>";contmod=1;document.getElementById("tcitas").style.display="none";}else if(contmod==1){document.getElementById("vermas").innerHTML="<font style='color:#000000;font-size:12px;'>ocultar</font>";ordenafechas();contmod=0;}}
function ordenafechas(img)
{
 var tabla=document.getElementById("tcitas");
 tabla.style.display="block";
 var datos="";
 var imgn=img;
 if(!img){imgn="up.png"}
 for(i=0;i<idn;i++)
 {
  var caso=fila[i][2];
  switch(caso){
  case "SI":asis="<td class='tds' align='center' style='width:80px !important;'><input type='radio' name='asistio"+i+"' id='asistio"+i+"' value='SI' onclick='javascript:block("+i+",this.value);' checked disabled></td><td class='tds' align='center' style='width:80px !important;'><input type='radio' name='asistio"+i+"' id='asistio"+i+"' value='NO' onclick='javascript:block("+i+",this.value);' disabled></td>";break;
  case "NO":asis="<td class='tds' align='center' style='width:80px !important;'><input type='radio' name='asistio"+i+"' id='asistio"+i+"' value='SI' onclick='javascript:block("+i+",this.value);' disabled></td><td class='tds' align='center' style='width:80px !important;'><input type='radio' name='asistio"+i+"' id='asistio"+i+"' value='NO' onclick='javascript:block("+i+",this.value);' checked disabled></td>";break;
  default : asis="<td class='tds' align='center' style='width:80px !important;'><input type='radio' name='asistio"+i+"' id='asistio"+i+"' value='SI' onclick='javascript:block("+i+",this.value);' disabled></td><td class='tds' align='center' style='width:80px !important;'><input type='radio' name='asistio"+i+"' id='asistio"+i+"' value='NO' onclick='javascript:block("+i+",this.value);' disabled></td>";
  }
  datos=datos+"<tr class='trs'><td class='tdi' align='center' style='width:50px !important;'>"+fila[i][0]+"</td><td class='tds' align='center' style='width:100px !important;'><input type='text' size='7' name='fechacita"+i+"' id='fechacita"+i+"' value='"+fila[i][1]+"' class='inp' style='border:none;' readonly><td class='tds' align='center' style='width:70px !important;'><input type='text' size='7' name='horacita"+i+"' id='horacita"+i+"' value='"+fila[i][3]+"' class='inp' style='border:none;' readonly></td>"+asis+"<td class='tds' align='center' style='width:350px !important;'><input type='text' size='60' class='inp' style='border:none;' name='observacion"+i+"' id='observacion"+i+"' value='"+fila[i][4]+"' readonly onkeyup='obsmod(this.value,"+i+");' onblur='javascript:blocko("+i+");'></td><td class='tds' align='center' style='width:70px !important;'><a href='javascript:modfil("+i+");'><img src='images/mod.png' id='img"+i+"'></div></a></td></tr>";
 } 
 tabla.innerHTML="<table width='100%'  class='tcitas'><tr class='trss1'><td align='center' style='width:50px !important;font-size:13px'><b><a href='javascript:ordencita();'><img src='images/"+imgn+"'></a></b></td><td align='center' style='width:100px !important;font-size:13px'><b>Fecha</b></td><td align='center' style='width:70px !important;font-size:13px'><b>Hora</b></td><td align='center' style='width:80px !important;font-size:13px'><b>Asistió</b></td><td align='center' style='width:80px !important;font-size:13px'><b>No asistió</b></td><td align='center' style='width:350px !important;font-size:13px'><b>Observación</b></td><td align='center' style='width:70px !important;font-size:13px'><b>Modificar</b></td></tr>"+datos+"<tr><td><input type='hidden' name='numcitas' id='numcitas' value='"+idn+"'></td></tr></table>";
}
function agregacita()
{
var fcita=document.forma.fechacita.value;
var horacita=document.forma.horacita.value;
var observ=document.forma.observacion.value;
var x=0;
if(fcita=="")
 {
 alert("Debes seleccionar una fecha");
 }
 else if(horacita=="")
   {
   alert("Debes seleccionar una hora");
   }
else if(fcita!="" && horacita!=""){
for(i=0;i<idn;i++){if(fcita==fila[i][1]){x=1;}}
if(x==0)
  { 
    status=0;ordencita();
    idn=idn+1;
    columna=new Array();
    columna[0]=idn;
    columna[1]=fcita;
    columna[2]="";
    columna[3]=horacita+":00";
    columna[4]=observ;
	fila[idn-1]=columna;
    ordenafechas();
	contmod=1
  }
 else{alert("Ya se agendo una cita en esa fecha");} 
 }
}
function ordencita()
{
var img;
cierramod();
if(status==1)
  {
   fila.reverse();
   status=0;
   img="down.png";
  }
else if(status==0)
{
   fila.sort();
   status=1;
   img="up.png";
}  
 ordenafechas(img);
}
function modfil(n)
{
 cierramod();
 var inp = document.getElementById("fechacita"+n);
 var asis = document.forma["asistio"+n];
 var hora = document.forma["horacita"+n];
 var obs = document.forma["observacion"+n];
 inp.removeAttribute('readOnly');
 hora.removeAttribute('readOnly');
 obs.removeAttribute('readOnly');
 fn="modfecha("+n+")";
 fnh="modhora("+n+")";
 inp.setAttribute('onClick',fn);// para safari,chrome,mozilla
 inp.onclick=new Function(fn);//para ie
 hora.setAttribute('onClick',fnh);// para safari,chrome,mozilla
 hora.onclick=new Function(fnh);//para ie
 asis[0].disabled=false;
 asis[1].disabled=false;
 $("#fechacita"+n).removeClass("inp");
 $("#horacita"+n).removeClass("inp");
 $("#observacion"+n).removeClass("inp");
}
function block(n,val)
{
 cierramod();
 cierramodh();
 var inp = document.getElementById("fechacita"+n);
 var asis = document.forma["asistio"+n];
 var hora = document.forma["horacita"+n];
 var obs = document.forma["observacion"+n];
 inp.setAttribute('readOnly',true);
 hora.setAttribute('readOnly',true);
 obs.setAttribute('readOnly',true);
 inp.removeAttribute('onClick');
 hora.removeAttribute('onClick');
 asis[0].disabled=true;
 asis[1].disabled=true;
 $("#fechacita"+n).addClass("inp");
 $("#horacita"+n).addClass("inp");
 $("#observacion"+n).addClass("inp");
 fila[n][2]=val;
 }
 function modfecha(n)
 {
 cierramodh();
 var inp = document.getElementById("fechacita"+n);
 var pos=22;
 var inpm = document.getElementById("fechacitamod");
 var div = document.getElementById("modf");
 div.style.display="block";
 npos=(pos*n)-20;
 div.style.marginTop=npos+"px";
 inpm.value=inp.value;
 na=n;
 }
 function cierramod()
 {
  var inpm = document.getElementById("fechacitamod");
  var div = document.getElementById("modf");
  inpm.value="";
  div.style.display="none";
 }
 function cierramodh()
 {
  var hora = document.getElementById("horacitam");
  var div = document.getElementById("modh");
  hora.value="";
  div.style.display="none";
 }
 function okmod()
 {
 var inp = document.getElementById("fechacita"+na);
 var inpm = document.getElementById("fechacitamod");
 inp.value=inpm.value;
 fila[na][1]=inp.value;
 cierramod();
 }
 function modhora(n)
 {
 cierramod();
 var hora = document.getElementById("horacita"+n);
 var pos=22;
 var horam = document.getElementById("horacitam");
 var div = document.getElementById("modh");
 div.style.display="block";
 npos=(pos*n)-20;
 div.style.marginTop=npos+"px";
 div.style.marginLeft="-215px";
 horac=hora.value;
 horam.value=horac.substring(0,5) ;
 na=n;
 }
 function okmodh()
 {
 var hora = document.getElementById("horacita"+na);
 var horam = document.getElementById("horacitam");
 fila[na][3]=horam.value + ":00";
 hora.value=horam.value + ":00";
 cierramodh();
 }
 function obsmod(val,n)
 {
  fila[n][4]=val;
 }
 function blocko(n)
 {
  var asis = document.forma["asistio"+n];
  if(asis[0].checked==1){val=asis[0].value;block(n,val);}
  if(asis[1].checked==1){val=asis[1].value;block(n,val);}
 }
</script>
</head>
<body onLoad="ndias();">
<div id="bkmsg" style="position:fixed;width:100%;height:100%;display:none;background:url(images/bkmsg.png);left:-10px;top:-10px;z-index:500;" ></div>
<!-- FORMULARIO DE REGISTRO DE EMPLEADOS-->						
	<div id="rs-iuqb">	
		<div id="content">      
            <div id="wrapper">
                <div id="steps">
                    <form name="forma" action="prospectos_modificar.php?tipo=modificar" method="post" onSubmit="javascript:return validalomod();">
                    <input type="hidden" name="id_cliente" value="<?php echo $id_cliente; ?>" />
                    <input type="hidden" name="id_renta" value="<?php echo $id_renta; ?>" />
                        <fieldset class="step">
                            <legend><strong>DATOS DEL CLIENTE</strong></legend>
                            <p>
							 <table style="font-family: Lucida Grande, Lucida Sans, Arial, sans-serif; font-size: 1em;text-align:right">
							  <tr>                 
								<td>
                                &nbsp;&nbsp;<label for="ap"><font color="#F30">*</font>Apellido Paterno:</label>
                                </td>
								<td>
								<input id="ap" name="ap" type="text" AUTOCOMPLETE=OFF onChange="javascript:this.value=this.value.toUpperCase();" onFocus="foco(this);" onBlur="no_foco(this);" value="<?php echo $ap; ?>">
                                </td>
							    <td>
                                &nbsp;&nbsp;<label for="am">Apellido Materno:</label>
                                </td>
								<td>
								<input id="am" name="am" type="text" AUTOCOMPLETE=OFF onChange="javascript:this.value=this.value.toUpperCase();" onFocus="foco(this);" onBlur="no_foco(this);" value="<?php echo $am; ?>">
                            	</td>
								<td>
								 <label  for="nombre"><font color="#F30">*</font>Nombre(s):</label>
                                </td>
								<td>
								<input id="nombre" name="nombre" type="text" AUTOCOMPLETE=OFF onChange="javascript:this.value=this.value.toUpperCase();"  onFocus="foco(this);" onBlur="no_foco(this);" value="<?php echo $nombre; ?>"/>
                                </td>
							  </tr>
							  <tr>
							   <td>
							    <label for="pais">País:</label>
							   </td>
							   <td>
								<?php generaPaises(); ?>
							   </td>
							   <td>
								<label for="estado">Estado:</label>
							   </td>
                               <td>							   
						           <select name="estados" id="estados" style=" width:129px">
								        <?php 
										if($suestado!=0)
										{
										echo "<option value='$idedo'>$suedo</option>";
										}
										?>
										<option value="0">Selecciona opci&oacute;n...</option>
									</select>
							   </td>
							   <td><label for="sexo">Sexo:</label></td>
							   <td>
							        <select name="sexo" style=" width:129px">
										<option value="0">--SELECCIONE--</option>
										<option value="MASCULINO"<?if($sexo=="MASCULINO"){?>selected="selected"<?}?>>MASCULINO</option>
										<option value="FEMENINO"<?if($sexo=="FEMENINO"){?>selected="selected"<?}?>>FEMENINO</option>
									</select>
							   </td>
							  </tr>
							  <tr>
							   <!--<td><label for="edocivil">Edo. Civil:</label></td>
							   <td><select name="edocivil" style=" width:129px;visibility:hidden">
										<option value="">Selecciona opci&oacute;n...</option>
										<option value="SOLTERO">Soltero</option>
										<option value="CASADO">Casado</option>
									</select></td>-->
							   <td><label for="mail"><font color="#F30">*</font>Mail:</label></td>	
                               <td>
							   <?php
							   if($email!='')
							   {
							   ?>
							   <input id="mail" name="mail" type="text" value="<?php echo $email ?>" onChange="validamail(this.value);" onFocus="foco(this);" onBlur="no_foco(this);">
							   <?php
							   }
							   else
							   {
							   ?>
							   <input id="mail" name="mail" type="text" placeholder="eje:mexico@hotmail.com" onChange="validamail(this.value);" onFocus="foco(this);" onBlur="no_foco(this);">
							   <div id="msgmail" style="position:absolute;display:none;width:15px;height:15px;margin-top:-20px;margin-left:140px"></div></td>							   								<?php
							   }							   
							   ?>
							   
							   	<td><label for="edad">Edad:</label></td>	
                               <td>
							       <select name="edad" style=" width:129px">
								       <? for($i=18;$i<100;$i++){?>
								      <option value="<? echo $i?>"<?if($i==$edad){?>selected="selected"<?}?>><? echo $i?></option>
								       <? } ?>
							       </select>
							   </td>
							   <td><label for="motviaje"><font color="#F30">*</font>Motivo de Viaje:</label></td>
								 <td><select name="motviaje" class="sel" style=" width:129px" onchange="javascript:lugarmot(this.value);">
								    <option value=""></option>
								   <?php
								   if($motivo_viaje!='')
								   {
								   $campo="MOTIVO_VIAJE";
								   $valor=$motivo_viaje;
								   require("llena2.php");
								   } else {
								   $campo="MOTIVO_VIAJE";
								   $valor=$motivo_viaje;
								   require("llena2.php");
								   }
								   ?>									
									 </select>
							     </td>
							  </tr>
							  <tr>
							     <td colspan="3"></td>
								 <td colspan="2" id="lugar"><?if($empresa != ""){?>Nombre de la empresa o institución<?}?></td>
								 <td id="lugar2"><?if($empresa != ""){?><input type="text" name="empoinst" id="empoinst" value="<?echo $empresa;?>"><?}?></td>
							  </tr>
							  <tr>
							     <td colspan="2">
                                     <table border="0" align="center">
                                         <tr>
                                             <td colspan="4" style="font-size:11px;"><center>Tel&eacute;fono Op1:</center></td>
                                         </tr>
                                         <tr style="text-align: left; font-size:9px;">
                                             <td><label for="internacional_access1">Acceso Int.</label></td>
                                             <td><label for="country_code1">Cód. Pa&iacute;s</label></td>
                                             <td><label for="area_code1">Cód. &Aacute;rea</label></td>
                                             <td><label for="numero1">N&uacute;mero</label></td>
                                         </tr>
                                         <tr style="text-align: left">
                                             <td><input id="intacc1" name="intacc1" type="text" size="1" onFocus="foco(this);" onBlur="no_foco(this);" value="<?echo $intacc1;?>" title="Acceso Internacional"/></td>
                                             <td><input id="coco1" name="coco1" type="text" size="1" onFocus="foco(this);" onBlur="no_foco(this);" value="<?echo $coco1;?>" title="Código del Pa&iacute;s"/></td>
                                             <td><input id="aco1" name="aco1" type="text" size="1" onFocus="foco(this);" onBlur="no_foco(this);" value="<?echo $aco1;?>" title="Código de &Aacute;rea"/></td>
                                             <td><input id="num1" name="num1" type="text" size="5" onFocus="foco(this);" onBlur="no_foco(this);" value="<?echo $num1;?>" title="N&uacute;mero"/></td>
                                         </tr>
                                     </table>  
                                 </td>
								 <td colspan="2">
                                     <table border="0" align="center">
                                         <tr style="text-align: left">
                                             <td colspan="4" style="font-size:11px;"><center>Tel&eacute;fono Op2:</center></td>
                                         </tr>                                
                                         <tr style="text-align: left; font-size:9px;">
                                             <td><label for="internacional_access2">Acceso Int.</label></td>
                                             <td><label for="country_code2">Cód. Pa&iacute;s</label></td>
                                             <td><label for="area_code2">Cód. &Aacute;rea</label></td>
                                             <td><label for="numero2">N&uacute;mero</label></td>
                                         </tr>
                                         <tr style="text-align: left">
                                             <td><input id="intacc2" name="intacc2" type="text" size="1" onFocus="foco(this);" onBlur="no_foco(this);" value="<?echo $intacc2;?>" title="Acceso Internacional"/></td>
                                             <td><input id="coco2" name="coco2" type="text" size="1" onFocus="foco(this);" onBlur="no_foco(this);" value="<?echo $coco2;?>" title="Código del Pa&iacute;s"/></td>
                                             <td><input id="aco2" name="aco2" type="text" size="1" onFocus="foco(this);" onBlur="no_foco(this);" value="<?echo $aco2;?>" title="Código de &Aacute;rea"/></td>
                                             <td><input id="num2" name="num2" type="text" size="5" onFocus="foco(this);" onBlur="no_foco(this);" value="<?echo $num2;?>" title="N&uacute;mero"/></td>
                                         </tr>
                                     </table>      
                                 </td>
								 <td>
									 <input type="button" value="Agregar(+)" onClick="anadir(this.form)" />
								 </td>
								 <td align="left"><input type="text" name="agregar" style="background-color:#E0E8F3;" onFocus="foco(this);" onBlur="no_foco(this);" onChange="javascript:this.value=this.value.toUpperCase();" size="10"/></td>
							  </tr>
							 </table>
							</p>	
							
							<!--<p>
                                <label for="fing">Fecha Ingreso</label>
								<input type="text" id="datepicker" name="fing" AUTOCOMPLETE=ON>
                            </p>-->
                        </fieldset>
                        <fieldset class="step">
                            <legend><strong>DATOS DE RENTA</strong></legend>
                            <p>
							<table border="0" width="800" style="font-family: Lucida Grande, Lucida Sans, Arial, sans-serif; font-size: 1em;text-align:right">
							   <tr>
								 <td><label for="fecha">Fecha:</label></td>
								 <td align="left"><input name="fecha" readonly="readonly" type="text" value="<? echo $fecha; ?>" onFocus="foco(this);" onBlur="no_foco(this);"></td>
								</tr>
							   <tr>
							        <?
								      require('../conectar.php');
									  $empleado=mysql_query("select * from empleados where id_empleado='$_SESSION[usuario_id]'",$db_conexion);
										if($re=mysql_fetch_array($empleado))
										{
										 $id_empleado=$re['id_empleado'];
										 $nom=$re['nombre'];
										 $a_pat=$re['a_pat'];
										 $a_mat=$re['a_mat'];
										 $su_puesto=$re['puesto'];
										 $su_gerente=$re['gerente'];
										 $su_coordinador=$re['coordinador'];
										}
										// GERENTE ES 3
										// COORDINADOR ES 4
										// EJECUTIVO ES 5
									?>
							    <td><label for="gerente">Gerente:</label></td>
								<td align="left">
											<select <?if($su_puesto==4 || $su_puesto==5){?>disabled="disabled"<?}?> name="gerente" onChange="validar(this.value)"> 
									            <option value="">--SELECCIONE--</option> 
									            <? 
									            $sql="SELECT distinct id_empleado,a_pat,a_mat,nombre from empleados where puesto='3' and fechabaja='0000-00-00'";
										        $rs=mysql_query($sql);
									            if(mysql_num_rows($rs)>0) 
											      { 
											       while($row = mysql_fetch_assoc($rs)) 
												        { 
									                    ?> 
								                           <option value="<?=$row["id_empleado"]?>"<?if($row["id_empleado"]==$id_gerente){?>selected="selected"<?}?>><?=$row["nombre"]." ".$row["a_pat"]." ".$row["a_mat"]?></option> 
									                    <? 
												        } 
											      }
                                             if($id_gerente==0)
											    {												  
									            ?> 
											    <option value="0" selected>SIN GERENTE ASIGNADO</option>
												<?
											    }
												?>
								            </select>								
								</td>
								<td><label for="coordinador">Coordinador:</label></td>
								<td align="left">
											<select <?if($su_puesto==5){?>disabled="disabled"<?}?> name="depto" onChange="validar2(this.value)"> 
									            <option value="">--SELECCIONE--</option> 
									            <? 
									            $sql="SELECT distinct id_empleado,a_pat,a_mat,nombre from empleados where puesto='4' and fechabaja='0000-00-00'";
										        $rs=mysql_query($sql);
									            if(mysql_num_rows($rs)>0) 
											      { 
											       while($row = mysql_fetch_assoc($rs)) 
												        { 
									                    ?> 
								                           <option value="<?=$row["id_empleado"]?>"<?if($row["id_empleado"]==$id_coordinador){?>selected="selected"<?}?>><?=$row["nombre"]." ".$row["a_pat"]." ".$row["a_mat"]?></option> 
									                    <? 
												        } 
											      } 
									         
											    if($id_coordinador==0)
										           {
										            ?> 
										             <option value="0" selected>SIN COORDINADOR ASIGNADO</option> 
										            <?  
												    }
                                                    ?>													
								            </select>
								</td>  
								<td><label for="ejecutivo">Ejecutivo:</label></td>
						            <td>
									    <select name="depto2" id="depto2" style="width:145px;"> 
									        <option value="">--SELECCIONE--</option> 
									            <? 
									            $sql="SELECT id_empleado,a_pat,a_mat,nombre from empleados where puesto='5' and fechabaja='0000-00-00'";
										        $rs=mysql_query($sql);
									            if(mysql_num_rows($rs)>0) 
											      { 
											       while($row = mysql_fetch_assoc($rs)) 
												        { 
									                    ?> 
								                           <option value="<?=$row["id_empleado"]?>"<?if($row["id_empleado"]==$id_ejecutivo){?>selected="selected"<?}?>><?=$row["nombre"]." ".$row["a_pat"]." ".$row["a_mat"]?></option> 
									                    <? 
												        } 
											      } 
												  if($id_ejecutivo==0)
										           {
										            ?> 
										             <option value="0" selected>SIN EJECUTIVO ASIGNADO</option> 
										            <?  
												    }
                                                    ?>
								        </select>
									</td>	
								</tr>
							  <tr>
								 <td><label for="tipopros">T. Prospección:</label></td>
								 <td><SELECT name="tipoprospeccion" class="sel">
										<option value="<? echo $tipoprospeccion ?>"><? echo $tipoprospeccion ?></option>
										<? $campo="TIPO_PROSPECCION";
										   $valor=$prospeccion;
											require("llena2.php");
										?>
										</select>
								 </td>
								 <td><label for="medio">Medio:</label></td>
								 <td>
								  <select name="medio" onChange="validarmedio(this.value)"> 
									 <option value="">--SELECCIONE--</option> 
									   <? 
									   $sql="SELECT distinct id,canal from medio";
										$rs=mysql_query($sql);
									   if(mysql_num_rows($rs)>0) 
											{ 
											 while($row = mysql_fetch_assoc($rs)) 
												 { 
									   ?> 
								  <option value="<?=$row["id"]?>"<?if($medio==$row["id"]){?>selected="selected"<?}?>><?=$row["canal"]?></option> 
									   <? 
												 }												 
											} 
									   ?> 
								  </select>
								</td>
								 <td><label for="submedio">Submedio:</label></td>
								 <td align="left">
								  <select name="submedio"  id="submedio" style="width:145px;"> 
									 <option>--SUBMEDIO--</option>
                                      <? 
									   $sql="SELECT distinct idsubmedio,subcanal FROM submedio WHERE idcanal=$medio";
										$rs=mysql_query($sql);
									   if(mysql_num_rows($rs)>0) 
											{ 
											 while($row = mysql_fetch_assoc($rs)) 
												 { 
									              ?> 
								                  <option value="<?=$row["idsubmedio"]?>"<?if($submedio==$row["idsubmedio"]){?>selected="selected"<?}?>><?=$row["subcanal"]?></option> 
									              <? 
												 } 
											} 
									   ?> 									 
								  </select>
								</td>
							   </tr>
                               <tr>
								 <td>
								    <input type="button" value="Agregar(+)" onClick="anadirtipopros(this.form)" /> 
								 </td>
								 <td align="left">
								    <input type="text" name="agregartpros" style="background-color:#E0E8F3;" onFocus="foco(this);" onBlur="no_foco(this);" onChange="javascript:this.value=this.value.toUpperCase();" size="10"/>
							     </td>
								 <td>
								    <input type="button" value="Agregar(+)" onClick="anadirmedio(this.form)" /> 
								 </td>
								 <td align="left">
								    <input type="text" name="agregarmedio" style="background-color:#E0E8F3;" onFocus="foco(this);" onBlur="no_foco(this);" onChange="javascript:this.value=this.value.toUpperCase();" size="10"/>
							     </td>
								 <td>
								    <input type="button" value="Agregar(+)" onClick="anadirsubmedio(this.form)" /> 
								 </td>
								 <td align="left">
								    <input type="text" name="agregarsubmedio" style="background-color:#E0E8F3;" onFocus="foco(this);" onBlur="no_foco(this);" onChange="javascript:this.value=this.value.toUpperCase();" size="10"/>
							     </td>
							   </tr>							   
							</table>
                            </p>							
                        </fieldset>
						 <fieldset class="step">
                            <legend><strong>EVALUACIÓN DEL PROSPECTO</strong></legend>														
                            <p>
							  <table border="0" width="800" style="font-family: Lucida Grande, Lucida Sans, Arial, sans-serif; font-size: 1em;text-align:right">
							  <tr>
							    <td><label for="califica"><font color="#F30">*</font>Califica?</label></td>
								<td> 
									 <select name="combo" onChange="hide()" style="width:129px">	
                                     <option value="" selected="selected">Escoge opcion</option>										 
									 <option value="Q" <?if($califica=='Q'){?>selected="selected"<?}?>>Q</option>
									 <option value="NQ"<?if($califica=='NQ'){?>selected="selected"<?}?>>NQ</option>
									 </select>
								</td>
								<td>
									<input type="text" name="label" value="* Plazo de Renta" id="label" size="12" style="<?if($califica=='NQ'){?>visibility:hidden;<?}if($califica=='Q'){?>visibility:visible;<?}?>background-color:#f1f1f1;border:none" readonly>
								</td>
								<td align="left">
									<select name="comfr" id="comfr" style="<?if($califica=='NQ'){?>visibility:hidden;<?}if($califica=='Q'){?>visibility:visible;<?}?>width:100px" onChange="califica()">
									    <option selected>Escoge opcion</option>
									    <option value="CP" <?if($formarenta=='CP'){?>selected="selected"<?}?>>CP</option>
									    <option value="LP" <?if($formarenta=='LP'){?>selected="selected"<?}?>>LP</option>
									    <option value="NI" <?if($formarenta=='NI'){?>selected="selected"<?}?>>NI</option>
									</select>
								</td>
								<td align="left"> 
								    &nbsp;<input type="text" name="frequerido" value="* Fecha Estancia" id="frequerido" size="12" style="<?if($califica=='NQ' ||($califica=='Q' &&$formarenta=="NI")){?>visibility:hidden;<?}if($califica=='Q' && ($formarenta=="CP" || $formarenta=="LP")){?>visibility:visible;<?}?>background-color:#f1f1f1;border:none" readonly>
								    <input id="aDate" class="input-text required" name="fr" type="text" size="15" style="<?if($califica=='NQ'||($califica=='Q' &&$formarenta=="NI")){?>visibility:hidden;<?}if($califica=='Q' && ($formarenta=="CP" || $formarenta=="LP")){?>visibility:visible;<?}?>" value="<?php echo $dia_inicio; ?>"><!--onblur="javascript: ndias();"-->
									<input id="dDate" class="input-text required" name="fr2" type="text" size="15" style="<?if($califica=='NQ'||($califica=='Q' &&$formarenta=="NI")){?>visibility:hidden;<?}if($califica=='Q' && ($formarenta=="CP" || $formarenta=="LP")){?>visibility:visible;<?}?>" value="<?php echo $dia_salida; ?>"><!--onblur="javascript:ndias();mostrar();" -->
								</td>
							   </tr>
							   <tr>
							    <td><input type="text" name="ncal" value="Motivo NQ" id="ncal" size="6" style="<?if($califica=="Q"){?>visibility:hidden;<?}if($califica=='NQ'){?>visibility:visible;<?}?>background-color:#f1f1f1;border:none" readonly></td>
								<td align="left">
								    <select name="mncal" style="<?if($califica=="Q"){?>visibility:hidden;<?}if($califica=='NQ'){?>visibility:visible;<?}?>width:128px">		
									<? 
									$campo="MOTIVO_NO_CALIFICA";
									$valor=$motivo_nocal;
									require("llena2.php");									
									?>
									</select>
								</td>
								<td align="left">
									<input type="text" name="nit" value="Motivo NI" id="nit" size="10" style="<?if($califica=="NQ" || ($califica=="Q" && ($formarenta=="CP"||$formarenta=="LP"))){?>visibility:hidden;<?}if($califica=='Q' && $formarenta=="NI"){?>visibility:visible;<?}?>background-color:#f1f1f1;border:none" readonly>
								</td>
                                <td>								
									<select name="nic" style="<?if($califica=="NQ" || ($califica=="Q" && ($formarenta=="CP"||$formarenta=="LP"))){?>visibility:hidden;<?}if($califica=='Q' && $formarenta=="NI"){?>visibility:visible;<?}?>width:100px">
									    <option value="<? $nic ?>"><? echo $nic ?></option>
										<? $campo="CALIFICA_NO_INTERESA";
										   $valor=$razon_ni;
											require("llena2.php");
										?>
									</select>
								</td>
								<td align="left">
								    <div id="totdias" style="font-size: 11px;padding-left:15px;"></div>
								</td>
								</tr>
								<tr>
								    <td><input type="button" name="anadirmnq" style="<?if($califica=="Q"){?>visibility:hidden;<?}if($califica=='NQ'){?>visibility:visible;<?}?>" value="Agregar(+)" onClick="anadirmotnq(this.form)" /></td>
								    <td align="left"><input type="text" name="causa" style="background-color:#E0E8F3;<?if($califica=="Q"){?>visibility:hidden;<?}if($califica=='NQ'){?>visibility:visible;<?}?>" onFocus="foco(this);" onBlur="no_foco(this);" onChange="javascript:this.value=this.value.toUpperCase();" size="10"/></td>
								    <td><input type="button" name="anadirni" style="<?if($califica=="NQ" || ($califica=="Q" && ($formarenta=="CP"||$formarenta=="LP"))){?>visibility:hidden;<?}if($califica=='Q' && $formarenta=="NI"){?>visibility:visible;<?}?>" value="Agregar(+)" onClick="anadircni(this.form)" /></td>
								    <td align="left"><input type="text" name="causani" style="background-color:#E0E8F3;<?if($califica=="NQ" || ($califica=="Q" && ($formarenta=="CP"||$formarenta=="LP"))){?>visibility:hidden;<?}if($califica=='Q' && $formarenta=="NI"){?>visibility:visible;<?}?>" onFocus="foco(this);" onBlur="no_foco(this);" onChange="javascript:this.value=this.value.toUpperCase();" size="10"/></td>
								<?
								////consulta que cuenta el numero de departamentos de cada propiedad o complejo que estan libres
								        for($i=1;$i<=5;$i++)
									    	{
											 //consulta que cuenta el numero de departamentos de cada propiedad o complejo
											 $sql="select count(id_complejo) from departamentos where id_complejo = '$i' group by id_complejo";
											 $ejesql=mysql_query($sql);
											 $totdepas=mysql_fetch_array($ejesql);
											 mysql_free_result($ejesql);
											 $totaldepas=$totdepas[0];
											 $sqldeplibres="select count(id_complejo) from departamentos where id_complejo = '$i' AND status='libre' group by id_complejo";
											 $ejesqldeplibres=mysql_query($sqldeplibres);
											 $totdepasdeplibres=mysql_fetch_array($ejesqldeplibres);
											 mysql_free_result($ejesqldeplibres);
											 $totaldepasdeplibres=$totdepasdeplibres[0];
											 $diflibredesocupado=$totaldepas-$totaldepasdeplibres;
											 
											 //tarifa alta,media,baja,muy baja
											 $tarifa=round((($diflibredesocupado*100)/$totaldepas));
											 if($tarifa>=0 && $tarifa<=35){
											  $tablatar="tarifa baja";
											  // echo "muy baja";
											 }
											 if($tarifa>=36 && $tarifa<=60){
											  $tablatar="tarifa media";
											 //  echo "baja";
											 }
											 if($tarifa>=61 && $tarifa<=85){
											  $tablatar="tarifa alta";
											  // echo "media";
											 }
											 if($tarifa>=86 && $tarifa<=100){
											  $tablatar="tarifa alta";
											  // echo "alta";
											 }
											 $array[$i]=$tablatar;
											 $array2[$i]=$tarifa;
										    }
								?>
								<td align="left">
								   <table border="0" width="300">
								    <tr>
									  <td width="75">
									  <input type="text" name="tst" value="Torre Sagredo" id="tst" size="12" style="<?if($califica=='NQ'||($califica=='Q' &&$formarenta=="NI")){?>visibility:hidden;<?}if($califica=='Q' && ($formarenta=="CP" || $formarenta=="LP")){?>visibility:visible;<?}?>background-color:#f1f1f1;border:none;text-align:center;" readonly>
									  </td>
									  <td width="75" align="center"><input type="text" name="mst" value="Moras Suites" id="mst" size="11" style="<?if($califica=='NQ'||($califica=='Q' &&$formarenta=="NI")){?>visibility:hidden;<?}if($califica=='Q' && ($formarenta=="CP" || $formarenta=="LP")){?>visibility:visible;<?}?>background-color:#f1f1f1;border:none;text-align:center;" readonly></td>
									  <td width="75" align="center"><input type="text" name="ctt" value="Casa Tiztik" id="ctt" size="11" style="<?if($califica=='NQ'||($califica=='Q' &&$formarenta=="NI")){?>visibility:hidden;<?}if($califica=='Q' && ($formarenta=="CP" || $formarenta=="LP")){?>visibility:visible;<?}?>background-color:#f1f1f1;border:none;text-align:center;" readonly></td>
									  <td width="75" align="center"><input type="text" name="cct" value="Casa Caracol" id="cct" size="11" style="<?if($califica=='NQ'||($califica=='Q' &&$formarenta=="NI")){?>visibility:hidden;<?}if($califica=='Q' && ($formarenta=="CP" || $formarenta=="LP")){?>visibility:visible;<?}?>background-color:#f1f1f1;border:none;text-align:center;" readonly></td>
									  <td width="75" align="center"><input type="text" name="tpt" value="Torre Periferico" id="tpt" size="11" style="<?if($califica=='NQ'||($califica=='Q' &&$formarenta=="NI")){?>visibility:hidden;<?}if($califica=='Q' && ($formarenta=="CP" || $formarenta=="LP")){?>visibility:visible;<?}?>background-color:#f1f1f1;border:none;text-align:center;" readonly></td>
									</tr>
									<tr>
									  <td width="75" align="center"><input type="text" name="tst2" value="<?echo $array[1];?>" id="tst2" size="12" style="<?if($califica=='NQ'||($califica=='Q' &&$formarenta=="NI")){?>visibility:hidden;<?}if($califica=='Q' && ($formarenta=="CP" || $formarenta=="LP")){?>visibility:visible;<?}?>background-color:#f1f1f1;border:none;text-align:center;color:#8A0808;font-size:10px;" readonly></td>
									  <td width="75" align="center"><input type="text" name="mst2" value="<?echo $array[2];?>" id="mst2" size="11" style="<?if($califica=='NQ'||($califica=='Q' &&$formarenta=="NI")){?>visibility:hidden;<?}if($califica=='Q' && ($formarenta=="CP" || $formarenta=="LP")){?>visibility:visible;<?}?>background-color:#f1f1f1;border:none;text-align:center;color:#8A0808;font-size:10px;" readonly></td>
									  <td width="75" align="center"><input type="text" name="ctt2" value="<?echo $array[3];?>" id="ctt2" size="11" style="<?if($califica=='NQ'||($califica=='Q' &&$formarenta=="NI")){?>visibility:hidden;<?}if($califica=='Q' && ($formarenta=="CP" || $formarenta=="LP")){?>visibility:visible;<?}?>background-color:#f1f1f1;border:none;text-align:center;color:#8A0808;font-size:10px;" readonly></td>
									  <td width="75" align="center"><input type="text" name="cct2" value="<?echo $array[4];?>" id="cct2" size="11" style="<?if($califica=='NQ'||($califica=='Q' &&$formarenta=="NI")){?>visibility:hidden;<?}if($califica=='Q' && ($formarenta=="CP" || $formarenta=="LP")){?>visibility:visible;<?}?>background-color:#f1f1f1;border:none;text-align:center;color:#8A0808;font-size:10px;" readonly></td>
									  <td width="75" align="center"><input type="text" name="tpt2" value="<?echo $array[5];?>" id="tpt2" size="11" style="<?if($califica=='NQ'||($califica=='Q' &&$formarenta=="NI")){?>visibility:hidden;<?}if($califica=='Q' && ($formarenta=="CP" || $formarenta=="LP")){?>visibility:visible;<?}?>background-color:#f1f1f1;border:none;text-align:center;color:#8A0808;font-size:10px;" readonly></td>
									</tr>
									<tr>
									  <td width="75" align="center"><input type="text" name="tst3" value="<?echo $array2[1]."%";?>" id="tst3" size="12" style="<?if($califica=='NQ'||($califica=='Q' &&$formarenta=="NI")){?>visibility:hidden;<?}if($califica=='Q' && ($formarenta=="CP" || $formarenta=="LP")){?>visibility:visible;<?}?>background-color:#f1f1f1;border:none;text-align:center;color:#8A0808;font-size:10px;" readonly></td>
									  <td width="75" align="center"><input type="text" name="mst3" value="<?echo $array2[2]."%";?>" id="mst3" size="11" style="<?if($califica=='NQ'||($califica=='Q' &&$formarenta=="NI")){?>visibility:hidden;<?}if($califica=='Q' && ($formarenta=="CP" || $formarenta=="LP")){?>visibility:visible;<?}?>background-color:#f1f1f1;border:none;text-align:center;color:#8A0808;font-size:10px;" readonly></td>
									  <td width="75" align="center"><input type="text" name="ctt3" value="<?echo $array2[3]."%";?>" id="ctt3" size="11" style="<?if($califica=='NQ'||($califica=='Q' &&$formarenta=="NI")){?>visibility:hidden;<?}if($califica=='Q' && ($formarenta=="CP" || $formarenta=="LP")){?>visibility:visible;<?}?>background-color:#f1f1f1;border:none;text-align:center;color:#8A0808;font-size:10px;" readonly></td>
									  <td width="75" align="center"><input type="text" name="cct3" value="<?echo $array2[4]."%";?>" id="cct3" size="11" style="<?if($califica=='NQ'||($califica=='Q' &&$formarenta=="NI")){?>visibility:hidden;<?}if($califica=='Q' && ($formarenta=="CP" || $formarenta=="LP")){?>visibility:visible;<?}?>background-color:#f1f1f1;border:none;text-align:center;color:#8A0808;font-size:10px;" readonly></td>
									  <td width="75" align="center"><input type="text" name="tpt3" value="<?echo $array2[5]."%";?>" id="tpt3" size="11" style="<?if($califica=='NQ'||($califica=='Q' &&$formarenta=="NI")){?>visibility:hidden;<?}if($califica=='Q' && ($formarenta=="CP" || $formarenta=="LP")){?>visibility:visible;<?}?>background-color:#f1f1f1;border:none;text-align:center;color:#8A0808;font-size:10px;" readonly></td>
									</tr>
									<tr>
								        <td width="75" align="center"><input type="checkbox" name="ts" id="ts" onClick="javascript:if(this.value=='on'||this.value==''){this.value='ts'}else{this.value=''};" style="<?if($califica=='NQ'||($califica=='Q' &&$formarenta=="NI")){?>visibility:hidden;<?}if($califica=='Q' && ($formarenta=="CP" || $formarenta=="LP")){?>visibility:visible;<?}?>" <?if($nombre_complejo=="TORRE SAGREDO"){?>checked="checked" value="ts"<?}?>></td>
									    <td width="75" align="center"><input type="checkbox" name="ms" id="ms" onClick="javascript:if(this.value=='on'||this.value==''){this.value='ms'}else{this.value=''};" style="<?if($califica=='NQ'||($califica=='Q' &&$formarenta=="NI")){?>visibility:hidden;<?}if($califica=='Q' && ($formarenta=="CP" || $formarenta=="LP")){?>visibility:visible;<?}?>" <?if($nombre_complejo=="MORAS SUITES"){?>checked="checked" value="ms"<?}?>></td>
									    <td width="75" align="center"><input type="checkbox" name="ct" id="ct" onClick="javascript:if(this.value=='on'||this.value==''){this.value='ct'}else{this.value=''};" style="<?if($califica=='NQ'||($califica=='Q' &&$formarenta=="NI")){?>visibility:hidden;<?}if($califica=='Q' && ($formarenta=="CP" || $formarenta=="LP")){?>visibility:visible;<?}?>" <?if($nombre_complejo=="CASA TIZTIK"){?>checked="checked" value="ct"<?}?>></td>
									    <td width="75" align="center"><input type="checkbox" name="cc" id="cc" onClick="javascript:if(this.value=='on'||this.value==''){this.value='cc'}else{this.value=''};" style="<?if($califica=='NQ'||($califica=='Q' &&$formarenta=="NI")){?>visibility:hidden;<?}if($califica=='Q' && ($formarenta=="CP" || $formarenta=="LP")){?>visibility:visible;<?}?>" <?if($nombre_complejo=="CASA CARACOL"){?>checked="checked" value="cc"<?}?>></td>
									    <td width="75" align="center"><input type="checkbox" name="tp" id="tp" onClick="javascript:if(this.value=='on'||this.value==''){this.value='tp'}else{this.value=''};" style="<?if($califica=='NQ'||($califica=='Q' &&$formarenta=="NI")){?>visibility:hidden;<?}if($califica=='Q' && ($formarenta=="CP" || $formarenta=="LP")){?>visibility:visible;<?}?>" <?if($nombre_complejo=="TORRE PERIFERICO"){?>checked="checked" value="tp"<?}?>></td>
								   </tr>
								   </table>
								</td>
							 </tr>	 
							 <tr>
							    <td></td>
								<td></td>
								<td></td>
								<td></td>
								<td>
								 <table align="center"border="0"> 
								 </table>	
								</td>
							 </tr>
							 <tr>
							    <td>&nbsp;</td>
								<td>&nbsp;</td>
								<td>&nbsp;</td>
								<td>&nbsp;</td>
								<td align="left"><input type="text" name="presupuestot" value="* Presupuesto USD" id="presupuestot" size="14" style="<?if($califica=='NQ'||($califica=='Q' &&$formarenta=="NI")){?>visibility:hidden;<?}if($califica=='Q' && ($formarenta=="CP" || $formarenta=="LP")){?>visibility:visible;<?}?>background-color:#f1f1f1;border:none" readonly>&nbsp;<input name="presupuesto" type="text" style="<?if($califica=='NQ'||($califica=='Q' &&$formarenta=="NI")){?>visibility:hidden;<?}if($califica=='Q' && ($formarenta=="CP" || $formarenta=="LP")){?>visibility:visible;<?}?>" onFocus="foco(this);" onBlur="no_foco(this);"></td>
							 </tr>
							 <tr> 
							    <td>&nbsp;</td>
								<td>&nbsp;</td>
								<td>&nbsp;</td>
								<td>&nbsp;</td>
								<td align="center"><a href="javascript:mostrar();" id="disponibles" style="<?if($califica=='NQ'||($califica=='Q' &&$formarenta=="NI")){?>visibility:hidden;<?}if($califica=='Q' && ($formarenta=="CP" || $formarenta=="LP")){?>visibility:visible;<?}?>"><img src="images/disponibles.png" style="border:0;"></a>
								</td>
							 </tr>
							 </table>
                            </p>
                        </fieldset>
						<div id="flotante" style="display:none;">
						</div>
						<div id="cargando" style="position:fixed;left:50%;top:50%;width:250px;height:70px;margin-left:-125px;margin-top:-35px;display:none;background:url(images/bkloading.png);background-repeat:no-repeat;color:#ffffff;padding-top:5px;align:center;">
						    <br><p align="center"><img src="images/loading.gif"></center>Cargando
						</div>
						<fieldset class="step"> 
                            <legend><strong>ASIGNAR DEPARTAMENTO</strong></legend>
                            <div id="mensaje"></div>
							<table align="center" width="90%" style="font-family: Lucida Grande, Lucida Sans, Arial, sans-serif; font-size: 1em;text-align:right">
							<tr>
							    <td colspan="6" align="center">
								    <table>
							            <tr>
								            <td align="center"><input type="text" name="estmtotx" value="Estacionamiento" id="estmtotx" size="12" style="<?if($califica=='NQ'||($califica=='Q' &&$formarenta=="NI")){?>visibility:hidden;<?}if($califica=='Q' && ($formarenta=="CP" || $formarenta=="LP")){?>visibility:visible;<?}?>background-color:#f1f1f1;border:none" readonly></td>
									        <td align="center"><input type="text" name="camaextx" value="Cama extra" id="camaextx" size="11" style="<?if($califica=='NQ'||($califica=='Q' &&$formarenta=="NI")){?>visibility:hidden;<?}if($califica=='Q' && ($formarenta=="CP" || $formarenta=="LP")){?>visibility:visible;<?}?>background-color:#f1f1f1;border:none" readonly></td>
									        <td align="center"><input type="text" name="cunatx" value="   Cuna" id="cunatx" size="10" style="<?if($califica=='NQ'||($califica=='Q' &&$formarenta=="NI")){?>visibility:hidden;<?}if($califica=='Q' && ($formarenta=="CP" || $formarenta=="LP")){?>visibility:visible;<?}?>background-color:#f1f1f1;border:none" readonly></td>
									        <td align="center"><input type="text" name="mascotatx" value="Mascota" id="mascotatx" size="11" style="<?if($califica=='NQ'||($califica=='Q' &&$formarenta=="NI")){?>visibility:hidden;<?}if($califica=='Q' && ($formarenta=="CP" || $formarenta=="LP")){?>visibility:visible;<?}?>background-color:#f1f1f1;border:none" readonly></td>
									        <td align="center"><input type="text" name="nper" value="Nº Personas" id="nper" size="8" style="<?if($califica=='NQ'||($califica=='Q' &&$formarenta=="NI")){?>visibility:hidden;<?}if($califica=='Q' && ($formarenta=="CP" || $formarenta=="LP")){?>visibility:visible;<?}?>background-color:#f1f1f1;border:none" readonly></td>
											<td align="center"><input type="text" name="descto" value="Descuento" id="descto" size="8"  style="<?if($califica=='NQ'||($califica=='Q' &&$formarenta=="NI")){?>visibility:hidden;<?}if($califica=='Q' && ($formarenta=="CP" || $formarenta=="LP")){?>visibility:visible;<?}?>background-color:#f1f1f1;border:none" readonly></td>
											<td align="center"><input type="text" name="dolartx" value="Precio dolar $" id="dolartx" size="11" style="background-color:#f1f1f1;border:none;text-align:center;" readonly></td>
								        </tr>
									    <tr>
									        <td align="center"><input type="checkbox" name="estmnto" id="estmnto" <? if($estmtostatus=="s"){ echo "value='s'"; } else { echo "value='n'"; } ?> onClick="javascript:if(this.checked==0){limpiasub(),this.value='n'}else{calculatotal(),this.value='s'};" style="<?if($califica=='NQ'||($califica=='Q' &&$formarenta=="NI")){?>visibility:hidden;<?}if($califica=='Q' && ($formarenta=="CP" || $formarenta=="LP")){?>visibility:visible;<?}?>" <?if($estmtostatus=="s"){?>checked<?}?>/></td>
									        <td align="center"><input type="checkbox" name="camaex" id="camaex" <? if($estmtostatus=="s"){ echo "value='s'"; } else { echo "value='n'"; } ?> onClick="javascript:if(this.checked==0){limpiasub(),calculatotal(),this.value='n'}else{calculatotal(),this.value='s'};" style="<?if($califica=='NQ'||($califica=='Q' &&$formarenta=="NI")){?>visibility:hidden;<?}if($califica=='Q' && ($formarenta=="CP" || $formarenta=="LP")){?>visibility:visible;<?}?>" <?if($camaexstatus=="s"){?>checked<?}?>/></td>
									        <td align="center"><input type="checkbox" name="cuna" id="cuna" <? if($estmtostatus=="s"){ echo "value='s'"; } else { echo "value='n'"; } ?> onClick="javascript:if(this.checked==0){limpiasub(),this.value='n'}else{calculatotal(),this.value='s'};" style="<?if($califica=='NQ'||($califica=='Q' &&$formarenta=="NI")){?>visibility:hidden;<?}if($califica=='Q' && ($formarenta=="CP" || $formarenta=="LP")){?>visibility:visible;<?}?>" <?if($cunastatus=="s"){?>checked<?}?>/></td>
									        <td align="center"><input type="checkbox" name="mascota" id="mascota" <? if($estmtostatus=="s"){ echo "value='s'"; } else { echo "value='n'"; } ?> onClick="javascript:if(this.checked==0){limpiasub(),this.value='n'}else{calculatotal(),this.value='s'};" style="<?if($califica=='NQ'||($califica=='Q' &&$formarenta=="NI")){?>visibility:hidden;<?}if($califica=='Q' && ($formarenta=="CP" || $formarenta=="LP")){?>visibility:visible;<?}?>" <?if($mascotastatus=="s"){?>checked<?}?>/></td>
									        <td align="center">
									        <input id="npers" name="npers" type="text" size="2" value="<?echo $noPersonas?>" onKeypress="javascript:if (event.keyCode < 45 || event.keyCode > 57) event.returnValue=false;" onKeyUp="javascript:if(this.value==''){limpiasub(),calculatotal()}else{capacidad(),setTimeout('calculatotal()',1000)};" style="<?if($califica=='NQ'||($califica=='Q' &&$formarenta=="NI")){?>visibility:hidden;<?}if($califica=='Q' && ($formarenta=="CP" || $formarenta=="LP")){?>visibility:visible;<?}?>">
											</td>
											<td align="center">
									        <input id="descuento" name="descuento" type="text" size="2" value="<?echo $descuento;?>" onKeypress="javascript:if (event.keyCode < 45 || event.keyCode > 57) event.returnValue=false;"  onkeyup="javascript:if(this.value>100){this.value=100};if(this.value<0){this.value=0};if(this.value>0 && this.value<100 ){calculatotal()}else{calculatotal()};comdesc();" style="<?if($califica=='NQ'||($califica=='Q' &&$formarenta=="NI")){?>visibility:hidden;<?}if($califica=='Q' && ($formarenta=="CP" || $formarenta=="LP")){?>visibility:visible;<?}?>" <?if($su_puesto==5){?>disabled="disabled" readonly<?}?>>
											<input type="hidden" name="descant" id="descant" size="5" value="<?echo $descuento?>">
									        <input type="hidden" name="iddep" id="iddep" size="5" value="<?echo $id_departamento;?>"><input type="hidden" name="compl" id="compl" size="5" onFocus="foco(this);" onBlur="no_foco(this);" value="<?echo $id_complejo;?>">
											</td>
											<td align="center">
									        <input id="dolar" name="dolar" type="text" size="2" value="<? if($tipo_cambio!=0){ echo $tipo_cambio; } else { echo $convmxn; } ?>">
											</td>
									    </tr>
										
										<input type="text" name="invitadotx" value="Cuota invitado" id="invitadotx" size="11" style="visibility:hidden;background-color:#f1f1f1;border:none;text-align:center;" readonly>
                                        <input type="checkbox" name="invitado" id="invitado" value="n" onClick="javascript:if(this.checked==0){limpiasub(),this.value='n'}else{calculatotal(),this.value='s'};" style="visibility:hidden;" />
									   
									    <tr>
									        <td colspan="6" align="center">
										        <div id="huespedes" style="display:none;font-family: Lucida Grande, Lucida Sans, Arial, sans-serif; font-size: 10px;">  
								                    <table border="0" style="font-family: Lucida Grande, Lucida Sans, Arial, sans-serif; font-size: 10px;text-align:left;display: block">
								                        <tr>
								                            <td colspan="3">Agregar Huesped:<input type="button" name="agregar" id="agregar" value="Agregar(+)"  onclick="javascript:crear(),tabla();"/></td>
								                        </tr>
								                        <tr id="f1"></tr>
								                            <tr>
													            <td>
														            <table id="tab" border="0" style="font-family: Lucida Grande, Lucida Sans, Arial, sans-serif; font-size: 1em;text-align:left;display: block">
															        </table>
															    </td>
													        </tr>
								                            <tr>
														        <td id="fiel" colspan="3">
														        </td>
														    </tr>
								                    </table>
                                                <div>			
									        </td>
									    </tr>
									</table>
								</td>
                            </tr>								
							<tr>
							    <td colspan="6" align="center">
								 <div id="tabladatos1">
								    <table width="100%" style="font-family: Lucida Grande, Lucida Sans, Arial, sans-serif; font-size: 1em;text-align:right">
								        <tr>
										    <td align="center" colspan="2">Fecha:</td>
							                <td align="center">Propiedad:</td>
								            <td align="center">Clave:</td>
								            <td align="center">Monto <?if($factura=="CON FACTURA" || $tipomoneda=="MXN"){?>MXN<?}else{?>USD<?}?>:</td>
								            <td align="right">Deposito <?if($factura=="CON FACTURA" || $tipomoneda=="MXN"){?>MXN<?}else{?>USD<?}?>:</td>
										</tr>
										<tr>
										    <td colspan="2"><input id="fin" class="input-text required" name="fini" type="text" readonly onFocus="foco(this);" onBlur="no_foco(this);" value="<?php echo $dia_inicio; ?>"> - <input id="ffi" class="input-text required" name="ffin" type="text" onFocus="foco(this);" onBlur="no_foco(this);" readonly value="<?php echo $dia_salida; ?>"></td>
										    <td><input type="text" name="deparprop" id="deparprop" size="20" onFocus="foco(this);" onBlur="no_foco(this);" readonly value="<?php echo $nombre_complejo; ?>"></td>
										    <td><input type="text" name="clavedep" id="clavedep" size="5" onFocus="foco(this);" onBlur="no_foco(this);" readonly value="<?php echo $clave_depto; ?>"></td>
										    <td><input type="text" name="monto" id="monto" size="5" onFocus="foco(this);" onBlur="no_foco(this);" value="<?php echo $hospedaje; ?>" readonly></td>
										    <td><input type="text" name="deposito" id="deposito" style="text-align:right" size="5" onFocus="foco(this);" value="<?php echo $deposito; ?>" onBlur="no_foco(this);" readonly></td>
										</tr>
									</table>
                                 </div>									
							    </td> 
							</tr>
							<tr>
							    <td colspan="6">
								 <div id="tabladatos2">
								 <table width="100%" style="font-family: Lucida Grande, Lucida Sans, Arial, sans-serif; font-size: 1em;text-align:right">
								    <tr>
									    <td>Persona extra con cama:</td>
									    <td>Persona extra:</td>
									    <td>Estacionamiento:</td>
									    <td>Cama extra:</td>
									    <td>Cuna:</td>
									    <td>Mascota:</td>
									    <td>Subtotal <?if($factura=="CON FACTURA" || $tipomoneda=="MXN"){?>MXN<?}else{?>USD<?}?>:</td>
									</tr>
									<tr>
									    <td><input type="text" name="perextcama" id="perextcama" size="3" value="<?echo $perextcama;?>" readonly onFocus="foco(this);" onBlur="no_foco(this);" /></td>
									    <td><input type="text" name="persext" id="persext" size="3" value="<?echo $per_extra;?>" readonly onFocus="foco(this);" onBlur="no_foco(this);" /></td>
									    <td><input type="text" name="estmnto2" id="estmnto2" size="3" value="<?echo $garage;?>" readonly onFocus="foco(this);" onBlur="no_foco(this);" /></td>
									    <td><input type="text" name="camaex2" id="camaex2" size="3" value="<?echo $camaextra;?>" readonly onFocus="foco(this);" onBlur="no_foco(this);" /></td>
									    <td><input type="text" name="cuna2" id="cuna2" size="3" value="<?echo $cuna;?>" readonly onFocus="foco(this);" onBlur="no_foco(this);" /></td>
									    <td><input type="text" name="mascota2" id="mascota2" size="3" value="<?echo $mascota;?>" readonly onFocus="foco(this);" onBlur="no_foco(this);" /></td>
									    <td><input type="text" name="subtotal2" id="subtotal2" style="text-align:right" size="5" value="<?echo $subtotal;?>" readonly onFocus="foco(this);" onBlur="no_foco(this);" /></td>
									</tr>
								 </table>
								 </div>
								</td> 
							</tr>
							<tr>
							    <td colspan="6">
								 <div id="tabladatos3">
								    <table width="100%" style="<?if($factura=="CON FACTURA" || $tipomoneda=="MXN"){?><?}else{?>display:none;<?}?>font-family: Lucida Grande, Lucida Sans, Arial, sans-serif; font-size: 1em;text-align:right">
								        <td>IVA MXN: <input type="text" name="iva2" id="iva2" size="5" value="<?echo $impuesto;?>" style="text-align:right" readonly onFocus="foco(this);" onBlur="no_foco(this);" /></td>
								    </table>
								 </div>
								</td> 
							</tr>
							<tr>
							    <td colspan="6">
								 <div id="tabladatos4">
								    <table width="100%" style="font-family: Lucida Grande, Lucida Sans, Arial, sans-serif; font-size: 1em;text-align:right">
								        <td>TOTAL <?if($factura=="CON FACTURA" || $tipomoneda=="MXN"){?>MXN<?}else{?>USD<?}?>: <input type="text" style="text-align:right" name="total2" id="total2" size="5" value="<?php echo $total; ?>" readonly onFocus="foco(this);" onBlur="no_foco(this);" /></td>
								    </table>
								 </div> 
								</td> 
							</tr>
							<tr>
							    <td colspan="6">
								    <input type="hidden" name="idmto" id="idmto" size="5" value="0" readonly />
								    <input type="hidden" name="tipomoneda" id="tipomoneda" size="5" value="<?if($factura=="CON FACTURA" || $tipomoneda=="MXN"){?>MXN<?}else{?>USD<?}?>" readonly />
								    <input type="hidden" name="noanos" id="noanios" size="5" value="<?echo $no_anios;?>" readonly />
                                    <input type="hidden" name="nomeses" id="nomeses" size="5" value="<?echo $no_meses;?>" readonly />	
									<input type="hidden" name="nosem" id="nosem" size="5" value="<?echo $no_sem;?>" readonly />
                                    <input type="hidden" name="nodias" id="nodias" size="5" value="<?echo $no_dias?>" readonly />	
                                    <input type="hidden" name="cap" id="cap" size="5" value="0" readonly />	
                                    <input type="hidden" name="lim" id="lim" size="5" value="0" readonly />										
								</td>
							</tr>
							</table>
                        </fieldset>
						<fieldset>
						    <legend><strong>CITAS</strong></legend>
							<center><table style="width:800px;font-family: Lucida Grande, Lucida Sans, Arial, sans-serif; font-size: 1em;">
							    <tr>
								    <td>
								    </td>
									<td align="center">
										<div id='modf' class='modf'><font style="color:#ffffff;">.</font><input type="text" name="fechacitamod" id="fechacitamod" size="7" style="text-align:center;margin-top:10px;">
										 <script language="JavaScript">
                                                        var o_cal = new tcal ({
                                                        // form name
                                                        'formname': 'forma',
                                                        // input name
                                                        'controlname': 'fechacitamod'
                                                        });
                                                        // individual template parameters can be modified via the calendar variable
                                                        o_cal.a_tpl.yearscroll = false;
                                                        o_cal.a_tpl.weekstart = 1;     
                                         </script>
										 <div class="btnmod" onclick="javascript:okmod();"><b class="tx">OK</b></div>
										 <div class="puntero"></div>
										</div>
										<div id='modh' class='modf'>
										     <select name="horacitam" id="horacitam" style="width:55px;margin-top:10px;">
													    <option value=""></option> 
														<option value='08:00'>08:00</option>  
														<option value='08:15'>08:15</option>  
														<option value='08:30'>08:30</option>  
														<option value='08:45'>08:45</option>  
														<option value='09:00'>09:00</option>  
														<option value='09:15'>09:15</option>  
														<option value='09:30'>09:30</option>  
														<option value='09:45'>09:45</option>  
														<option value='10:00'>10:00</option>  
														<option value='10:15'>10:15</option>  
														<option value='10:30'>10:30</option>  
														<option value='10:45'>10:45</option>  
														<option value='11:00'>11:00</option>  
														<option value='11:15'>11:15</option>  
														<option value='11:30'>11:30</option>  
														<option value='11:45'>11:45</option>  
														<option value='12:00'>12:00</option>  
														<option value='12:15'>12:15</option>  
														<option value='12:30'>12:30</option>  
														<option value='12:45'>12:45</option>  
														<option value='13:00'>13:00</option>  
														<option value='13:15'>13:15</option>  
														<option value='13:30'>13:30</option>  
														<option value='13:45'>13:45</option>  
														<option value='14:00'>14:00</option>  
														<option value='14:15'>14:15</option>  
														<option value='14:30'>14:30</option>  
														<option value='14:45'>14:45</option>  
														<option value='15:00'>15:00</option>  
														<option value='15:15'>15:15</option>  
														<option value='15:30'>15:30</option>  
														<option value='15:45'>15:45</option>  
														<option value='16:00'>16:00</option>  
														<option value='16:15'>16:15</option>  
														<option value='16:30'>16:30</option>  
														<option value='16:45'>16:45</option>  
														<option value='17:00'>17:00</option>  
														<option value='17:15'>17:15</option>  
														<option value='17:30'>17:30</option>  
														<option value='17:45'>17:45</option>  
														<option value='18:00'>18:00</option>  
														<option value='18:15'>18:15</option>  
														<option value='18:30'>18:30</option>  
														<option value='18:45'>18:45</option>  
														<option value='19:00'>19:00</option>  
														<option value='19:15'>19:15</option>  
														<option value='19:30'>19:30</option>  
														<option value='19:45'>19:45</option>  
														<option value='20:00'>20:00</option> 
														<option value='20:15'>20:15</option> 
														<option value='20:30'>20:30</option> 
														<option value='20:45'>20:45</option> 
														<option value='21:00'>21:00</option> 
														<option value='21:15'>21:15</option> 
														<option value='21:30'>21:30</option> 
														<option value='21:45'>21:45</option> 
														<option value='22:00'>22:00</option> 
														<option value='22:15'>22:15</option> 
														<option value='22:30'>22:30</option> 
														<option value='22:45'>22:45</option> 
														<option value='23:00'>23:00</option> 
												</select>
										 <div class="btnmod" onclick="javascript:okmodh();"><b class="tx">OK</b></div>
										 <div class="puntero"></div>
										</div>
									    <table class="datos" style="width:800px;";>
				                            <tr class="trst">
					                            <td align="left" colspan=4 >Fecha nueva cita: <input type="text" name="fechacita" style="text-align:left;" value="<?php if($fecha_cierre=='0000-00-00') { } else { echo $fecha_cierre; } ?>" size="10"/>
								                    <script language="JavaScript">
                                                        var o_cal = new tcal ({
                                                        // form name
                                                        'formname': 'forma',
                                                        // input name
                                                        'controlname': 'fechacita'
                                                        });
                                                        // individual template parameters can be modified via the calendar variable
                                                        o_cal.a_tpl.yearscroll = false;
                                                        o_cal.a_tpl.weekstart = 1;     
                                                    </script>
													Hora: <select name="horacita" id="horacita" style="width:55px;">
													    <option value=""></option> 
														<option value='08:00'>08:00</option>  
														<option value='08:15'>08:15</option>  
														<option value='08:30'>08:30</option>  
														<option value='08:45'>08:45</option>  
														<option value='09:00'>09:00</option>  
														<option value='09:15'>09:15</option>  
														<option value='09:30'>09:30</option>  
														<option value='09:45'>09:45</option>  
														<option value='10:00'>10:00</option>  
														<option value='10:15'>10:15</option>  
														<option value='10:30'>10:30</option>  
														<option value='10:45'>10:45</option>  
														<option value='11:00'>11:00</option>  
														<option value='11:15'>11:15</option>  
														<option value='11:30'>11:30</option>  
														<option value='11:45'>11:45</option>  
														<option value='12:00'>12:00</option>  
														<option value='12:15'>12:15</option>  
														<option value='12:30'>12:30</option>  
														<option value='12:45'>12:45</option>  
														<option value='13:00'>13:00</option>  
														<option value='13:15'>13:15</option>  
														<option value='13:30'>13:30</option>  
														<option value='13:45'>13:45</option>  
														<option value='14:00'>14:00</option>  
														<option value='14:15'>14:15</option>  
														<option value='14:30'>14:30</option>  
														<option value='14:45'>14:45</option>  
														<option value='15:00'>15:00</option>  
														<option value='15:15'>15:15</option>  
														<option value='15:30'>15:30</option>  
														<option value='15:45'>15:45</option>  
														<option value='16:00'>16:00</option>  
														<option value='16:15'>16:15</option>  
														<option value='16:30'>16:30</option>  
														<option value='16:45'>16:45</option>  
														<option value='17:00'>17:00</option>  
														<option value='17:15'>17:15</option>  
														<option value='17:30'>17:30</option>  
														<option value='17:45'>17:45</option>  
														<option value='18:00'>18:00</option>  
														<option value='18:15'>18:15</option>  
														<option value='18:30'>18:30</option>  
														<option value='18:45'>18:45</option>  
														<option value='19:00'>19:00</option>  
														<option value='19:15'>19:15</option>  
														<option value='19:30'>19:30</option>  
														<option value='19:45'>19:45</option>  
														<option value='20:00'>20:00</option> 
														<option value='20:15'>20:15</option> 
														<option value='20:30'>20:30</option> 
														<option value='20:45'>20:45</option> 
														<option value='21:00'>21:00</option> 
														<option value='21:15'>21:15</option> 
														<option value='21:30'>21:30</option> 
														<option value='21:45'>21:45</option> 
														<option value='22:00'>22:00</option> 
														<option value='22:15'>22:15</option> 
														<option value='22:30'>22:30</option> 
														<option value='22:45'>22:45</option> 
														<option value='23:00'>23:00</option> 
													</select>
													Observacion: <input type="text" name="observacion" id="observacion" size="50">
													<input type="button" value="Agregar(+)" onclick="javascript:agregacita();"> <a href="javascript:vercitas();" style="position:absolute;margin-top:5px;margin-left:5px;" id="vermas"><font style="color:#000000;font-size:12px;">mostrar</font></a>
											    </td> 
					                        </tr>
					                        <tr>
											    <td colspan="6" id="tcitas" id="tcitas">
												</td>
											</tr>
				                        </table>
									</td>
							    </tr>
							</table></center>
						</fieldset>
						<fieldset class="step"> 
                            <legend><strong>PRE-APARTADO<strong></legend>
							<table align="left" border="0" style="font-family: Lucida Grande, Lucida Sans, Arial, sans-serif; font-size: 1em;text-align:right">
							  <tr>						     
								 <td></td>
							     <td></td>
								 <td align="center">
								      <div id="fact" style="<?if($ubicacionactual=="MEXICO" && $formapago=="BANCO"){?><?}else{?>display:none;<?}?>width:600px">
								      Con factura: <input align="center" id="factura" name="factura" type="radio" value="CON FACTURA" onClick="javascript:opbanco();" <?if($factura=="CON FACTURA"){?>checked<?}?>>
									  Sin Factura: <input align="center" id="factura" name="factura" type="radio" value="SIN FACTURA" onClick="javascript:opbanco();"  <?if($factura=="SIN FACTURA"){?>checked<?}?>>
                                      </div>		
                                      <div id="efc" style="<?if($ubicacionactual=="MEXICO" && $formapago=="EFECTIVO"){?><?}else{?>display:none;<?}?>width:600px">
								      Pesos: <input align="center" id="efectivo" name="efectivo" type="radio" value="PESOS" onClick="javascript:opbanco3();" <?if($tipomoneda=="MXN"){?>checked<?}?>>
									  USD: <input align="center" id="efectivo" name="efectivo" type="radio" value="USD" onClick="javascript:opbanco3();" <?if($tipomoneda=="USD"){?>checked<?}?>>
                                      </div>						 
								 </td>
							  </tr>
							  <tr>
							     <td><label>Ubicación Actual:</label></td>
							     <td>
								    <select name="ubiact" onChange="javascript:ubicar();">
									  <option value="">--</option>
									  <option value="MEXICO" <?if($ubicacionactual=="MEXICO"){?>selected<?}?>>MEXICO</option>
									  <option value="AMERICA" <?if($ubicacionactual=="AMERICA"){?>selected<?}?>>USA Y CANADA/RESTO DE LATINOAMERICA </option>
									  <option value="EUROPARESTOMUNDO" <?if($ubicacionactual=="EUROPARESTOMUNDO"){?>selected<?}?>>EUROPA/RESTOMUNDO</option> 
									</select>
                                 </td>
								 <td align="center">
								      <div id="tdpag" style="<?if($ubicacionactual=="MEXICO" && $formapago=="BANCO"){?><?}else{?>display:none;<?}?>width:600px">
								      Deposito: <input align="center" id="depos" name="tipopago" type="radio" value="DEPOSITO" onClick="javascript:calculatotal();opbanco();" <?if($tipopago=="DEPOSITO"){?>checked<?}?>>
									  Transferencia: <input align="center" id="trasf" name="tipopago" type="radio" value="TRANSFERENCIA" onClick="javascript:calculatotal();opbanco();" <?if($tipopago=="TRANSFERENCIA"){?>checked<?}?>>
									  Cheque: <input align="center" id="chequ" name="tipopago" type="radio" value="CHEQUE" onClick="javascript:calculatotal();opbanco();" <?if($tipopago=="CHEQUE"){?>checked<?}?>>
                                      </div>						  
								 </td>
							  </tr>
							  <tr>
							     <td><label>Forma de pago:</label></td>
							     <td>
								    <select name="formapago" onChange="javascript:opciones();">
									  <option value="">--</option>
									  <option value="BANCO" <?if($formapago=="BANCO"){?>selected<?}?>>BANCO</option>
									  <option value="PAYPAL" <?if($formapago=="PAYPAL"){?>selected<?}?>>PAYPAL</option>
									  <option value="EFECTIVO" <?if($formapago=="EFECTIVO"){?>selected<?}?>>EFECTIVO</option>									  
									</select>
                                 </td>
							  </tr>
							  <tr>
							      <td colspan="3">
								  <div id="info">
							      </div>	
							      </td>
							  </tr>
							</table>
                        </fieldset>
						<?
						if($su_puesto==1 || $su_puesto==2)
						{
						?>
                          <fieldset class="step">                                                 
                      <legend><strong><?php if(($tipo_renta=='RENTA NUEVA' || $tipo_renta=='SEGUIMIENTO') || ($status_renta=='OCUPADO' || $status_renta=='APARTADO')) { echo $tipo_renta." - ".$status_renta; } else { echo "ESTADO DE LA RENTA"; } ?><strong></legend>
                            <p class="submit" align="center">
                            <table align="left" border="0" style="font-family: Lucida Grande, Lucida Sans, Arial, sans-serif; font-size: 1em;text-align:left">
                            <input type="hidden" name="fecha_cierre_anterior" value="<?php echo $fecha_cierre; ?>" />
                            <input type="hidden" name="tipo_renta_anterior" value="<?php echo $tipo_renta; ?>" />
                             <tr>
                              <td>Fecha Cierre</td>
                              <td>
                              <input type="text" name="testinput" style="text-align:left;" value="<?php if($fecha_cierre=='0000-00-00') { } else { echo $fecha_cierre; } ?>" size="10"/>
								<script language="JavaScript">
                                var o_cal = new tcal ({
                                    // form name
                                    'formname': 'forma',
                                    // input name
                                    'controlname': 'testinput'
                                });
                                
                                // individual template parameters can be modified via the calendar variable
                                o_cal.a_tpl.yearscroll = false;
                                o_cal.a_tpl.weekstart = 1;                                
								
                                </script>
                              </td>
                             </tr>
                                                         
                             <tr>
                               <td>Estatus Renta</td>
                              <td>
                              <select name="status_renta" style="width:98px;" onChange="verifica();">
                               <option value="" <?if($status_renta==''){?> selected <?}?>></option>                              
                               <option value="LIBRE"  <?if($status_renta=='LIBRE'){?> selected <?}?>>LIBRE</option>
                               <option value="OCUPADO"  <?if($status_renta=='OCUPADO'){?> selected <?}?>>OCUPADO</option>
                               <option value="APARTADO"  <?if($status_renta=='APARTADO'){?>selected <?}?>>APARTADO</option>
                              </select>
                              </td>
                             </tr>
                            </table>                            
                            </p>
                        </fieldset> 
						<?
						}
						?>
                        <div id="alerta_fecha"></div>
						 <fieldset>
						    <legend>INFORMACION ADICIONAL PARA EL CLIENTE</legend>
							<textarea align="left" name="infoadicional" id="infoadicional" style="margin-top: 2px; margin-bottom: 2px; height: 70px; margin-left: 2px; margin-right: 2px; width: 830px !important; resize:none;border:solid 2px #F5DA81;text-align:left;"><?echo $infoadicional?></textarea>
				        </fieldset>
						<fieldset class="step"> 
                            <legend><strong>REGISTRAR<strong></legend>
                            <p class="submit" align="center">
                                <button name="botonregistro" id="registerButton" type="submit" class="btn btnsave">Guardar</button>
                            </p>
							<a href="javascript:infomail();">ENVIAR SOLICITUD DE PAGO</a>
							<div id="prueba"></div>
                        </fieldset>
                    </form>				
					<SCRIPT type="text/javascript" src="calendario/calendar-start.js"></SCRIPT>
                </div>
            </div>
        </div>
	</div>	
	<div id="paypal" style="position:absolute;display:none;width:400px;margin-top:-150px;margin-left:380px;">
										    <form name="paypal" target="_blank" action="https://www.paypal.com/cgi-bin/webscr" method="post">
                                             <input type="hidden" name="cmd" value="_xclick">
                                             <input type="hidden" name="hosted_button_id" value="5ESXKWWUMHW9J">
                                             <input type="hidden" name="business" value="mexicoenrenta@hotmail.com">
                                             <input type="hidden" name="currency_code" value="USD">
                                             <input type="hidden" name="item_name" value="">
                                             <input type="hidden" name="amount" value="">
                                             <input type="image" src="https://www.paypalobjects.com/WEBSCR-640-20110429-1/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
                                             <img alt="" border="0" src="https://www.paypalobjects.com/WEBSCR-640-20110429-1/es_XC/i/scr/pixel.gif" width="1" height="1">
                                        </form> 
    <div>
<script>
 domReady(vercitas(),capacidad(),opbanco2(),chuesp(<?echo $id_renta;?>,<?echo $id_cliente;?>));
</script>					 
</body>
</html>