function agregar_caracter(num){
var str=num+'';
if ( str.length==1){
	str="0"+num;
	//alert(num);
}

return str;
}
function mesNombre(mes){

switch (mes){
	case "01":
		return "Enero";
		break;
	case "02":
		return "Febrero";
		break;
	case "03":
		return "Marzo";
		break;
	case "04":
		return "Abril";
		break;
	case "05":
		return "Mayo";
		break;
	case "06":
		return "Junio";
		break;
	case "07":
		return "Julio";
		break;
	case "08":
		return "Agosto";
		break;
	case "09":
		return "Septiembre";
		break;
	case "10":
		return "Octubre";
		break;
	case "11":
		return "Noviembre";
		break;
	case "12":
		return "Diciembre";
		break;	
}

}
function getSiglas(hs){
	if(hs>12)
		return "PM";
	else
		return "AM";
}
var tim="";
var horas=0;
var minutos=0;
var segundos=0;
var siglas="AM";
function obtener_fecha(){
	cad_segundos=segundos+'';
	
	segundos=(parseInt(segundos)+1);
	cad_segundos=segundos+'';
	if (cad_segundos.length==1)
		cad_segundos="0";
	else
		cad_segundos="";

	//siglas=getSiglas(horas);
	if (segundos=="60")
		segundos="00";
	resultado=horas+":"+minutos+":"+cad_segundos+segundos;
	
	document.getElementById("div_horaServer").innerHTML=resultado;
	clearTimeout(tim);
	tim=setTimeout("obtener_fecha()",1000);
	if (segundos>=59 )
		calcularHoraServer();
	
}

function calcularHoraServer(){
$.post("files_menujs/hora_server.asp", {},
			function(datos)
			{
				//alert(datos);
				tiempo=datos.split(":");
				horas=(tiempo[0]);
				minutos=(tiempo[1]);
				//alert(tiempo[2]);
				tiempo=tiempo[2].split(" ");
				segundos=(tiempo[0]);
				//alert(segundos);
				siglas=tiempo[1];
				if (siglas=="PM" && parseInt(horas)!=12)
					horas=parseInt(horas)+12;
				else if(siglas=="AM" && parseInt(horas)==12)
					horas="00";
				obtener_fecha();
			}
			);
			
}
calcularHoraServer();
