﻿function getFecha() 
{
    var fecha_actual = new Date()

	var dia = fecha_actual.getDate()
	var mes = fecha_actual.getMonth() + 1
	var anio = fecha_actual.getFullYear()
	
	if (mes < 10)
		mes = '0' + mes

	if (dia < 10)
		dia = '0' + dia

	return (dia + "/" + mes + "/" + anio)   
}

function getHora()
{
    var fecha_actual = new Date()
    
    var hora = fecha_actual.getHours(); 
	var minutos = fecha_actual.getMinutes();
	
	if(hora <= 9)
	{
	    hora = "0" + hora;
	}
	
	if( minutos <= 9) 
	{
	    minutos = "0" + minutos;
	}
    return  (hora + ":" + minutos)
}

function ClientDate(fecha, hora)
{
    if($get(fecha)!=null)
    {
       $get(fecha).value = getFecha();
    }
      
    if($get(hora)!=null)
    {
       $get(hora).value = getHora();
    }
}

function ValidarHora(source, args)
{
    var Result = true;

    if (args.Value != '')
    {
        if (/^[0-2]{1}[0-9]{1}[':']{1}[0-5]{1}[0-9]{1}$/.test(args.Value))
        {
            if ((args.Value.substring(0, 1) == '2') && ((parseInt(args.Value.substring(1, 2)) > 3)))
            {
                Result = false;
            }
        }
        else
        {
            Result = false;
        }
    }
    
    args.IsValid = Result;
}

function seleccionarCampo(ID)
{
    ID.firstChild.firstChild.firstChild.firstChild.checked = true;
}