var timerID = null
var timerRunning = false

function ltrim(str){return str.replace(/^[ ]+/, '');}
function rtrim(str){return str.replace(/[ ]+$/, '');}
function trim(str){return ltrim(rtrim(str));}

function C_Vacio(valor)// Validar los campos
{
	var v;
	
	if ((valor==null) || (valor.length==0))
		{return true;}
	else
		{
			v=trim(valor);
			if ((v=='') || (v=='0'))
				return true;
			else
				return false;
		}
}

function startclock ()
{
	stopclock()
	showtime()
}

function stopclock ()
{
	if(timerRunning)
		{clearTimeout(timerID)}
		
	timerRunning = false
}

function gettheDate()
{
	var now = new Date()
	var dia = now.getDay()
	var mes = now.getMonth()
	var fecha

	//El día de la semana
	switch(dia)
	{
	case 0: {fecha="Domingo, "; break;}
	case 1: {fecha="Lunes, "; break;}
	case 2: {fecha="Martes, "; break;}
	case 3: {fecha="Miercoles, "; break;}
	case 4: {fecha="Jueves, "; break;}
	case 5: {fecha="Viernes, "; break;}
	case 6: {fecha="Sabado, "; break;}
	}

	fecha = fecha + now.getDate() + "-"
	//El nombre del mes
	switch(mes)
	{
	case 0: {fecha=fecha + "Ene";	break;}
	case 1: {fecha=fecha + "Feb"; break;}
	case 2: {fecha=fecha + "Mar"; break;}
	case 3: {fecha=fecha + "Abr"; break;}
	case 4: {fecha=fecha + "Mayo"; break;}
	case 5: {fecha=fecha + "Jun"; break;}
	case 6: {fecha=fecha + "Jul"; break;}
	case 7: {fecha=fecha + "Ago"; break;}
	case 8: {fecha=fecha + "Sept"; break;}
	case 9: {fecha=fecha + "Oct"; break;}
	case 10:{fecha=fecha + "Nov";	break;}
	case 11:{fecha=fecha + "Dic";	break;}
	//Ene.Feb.Mar.Abr.Mayo.Jun.Jul.Ago.Sept.Oct.Nov.Dic.
	}
	fecha = fecha + "-" + now.getYear()
	return fecha
}

function showtime ()
{
var now = new Date()
var hours = now.getHours()
var minutes = now.getMinutes()
var seconds = now.getSeconds()
var timeValue = "" + hours

	timeValue += ((minutes < 10) ? ":0" : ":") + minutes
	
	document.getElementById("txtfecha").innerText = timeValue + "  " + gettheDate()
	
	timerID = setTimeout("showtime()",1000)
	timerRunning = true
}

function cargar_busqueda (texto, url)
{
	window.event.keyCode = 0;
	
	if (C_Vacio(texto))
	{
		alert('Debe indicar el texto a buscar.');
	}
	else
	{
		document.location.href=url + "?txt=" + texto;
	}
}

function redintranet ()
{
	window.open("http://www.tdsdirecto.com","Intranet","toolbar=yes,location=yes,status=yes,resizable=yes,scrollbars=auto,favorites=yes,width=800,height=600") 
} 