// Copyright Julio de 2002 Enrique F. Castañón para sms.Ltn.Net. Todos los derechos reservados.

if (!ltn_palabra)  var ltn_palabra  = 'LTN';
if (!ltn_telefono) var ltn_telefono = '5868';

var retorno = ' ';
var url_script    = 'http://cgi.Ltn.Net/sms/c/js.cgi';
var url_responder = 'http://sms.Ltn.Net/r/';
var url_poner     = 'http://sms.Ltn.Net/a/';
var ok = 1;

if (!encuentralink('http://sms.ltn.net/') && !encuentralink('http://sms.Ltn.Net/') ) {
  ok = 0;
  document.write ('<center><font face="Arial" size="2"><b>El tablón de anuncios esta mal configurado,<br>copia y pega el código tal y como aparece en: </b></font><a href="http://sms.Ltn.Net/"><font face="Arial" size="2"><b>http://sms.Ltn.Net/</b></a><br>El código debe aparecer después de la etiqueta: BODY</font></center>');
} 

if (contine('file://',location.href)) {
  ok = 0;
  document.write ('<center><font face="Arial" size="2"><b>El tablón de anuncios debe estar en Internet,<br>No funciona desde el disco duro:<br>'+location.href+'</b><br></font><a href="http://sms.Ltn.Net/"><font face="Arial" size="2"><b>http://sms.Ltn.Net/</b></font></a></center>');
} 

if (ok) {
  ltn_tablon = new sms(ltn_palabra,ltn_telefono);
}

function sms(palabra,texto) {
	this.pal = palabra;
	this.txt = texto;
	this.resultados = ' ';
	this.url   = location.href;
	this.query = new String(document.location.search);
	this.query = this.query.substring(1,this.query.length);

  if ( this.url.indexOf('?') > 0 ) {
	  this.url   = this.url.substring(0,this.url.indexOf('?'));
	}

	if ( this.query.indexOf('pal=') <= 0 ) {
	  this.query += '&pal=' + this.pal;
	}
	if ( this.query.indexOf('txt=') <= 0 ) {
	  this.query += '&txt=' + this.txt;
	}
	if ( this.query.indexOf('url=') <= 0 ) {
	  this.query += '&url=' + this.url;
	}

	this.script = url_script+'?';
	this.cgi = cgi;
 	this.resultados = this.cgi(this.script + this.query);
}

function cgi(script) {
	document.write ('\<SCRIPT LANGUAGE=JavaScript SRC="' + script + '">\<\/SCRIPT\>');
	return;
}

function responder(email,nombre) {
  murl = url_responder+'?'+ltn_tablon.pal+'&'+ltn_tablon.txt+'&'+ltn_tablon.url+'&'+email+'&'+nombre+'&'+mirandom(9999);  
  remote = window.open(murl,'responder','resizable=no,scrollbars=yes,status=no,width=610,height=335,left=75,top=75');
  remote.opener.name = "opener";
  remote.focus();
  return;
}

function poner() {
  murl = url_poner+'?'+ltn_tablon.pal+'&'+ltn_tablon.txt+'&'+ltn_tablon.url+'&'+mirandom(9999);  
  remote = window.open(murl,'poner','resizable=no,scrollbars=yes,status=no,width=575,height=350,left=75,top=75');
  remote.opener.name = "opener";
  remote.focus();
  return;
}

if (!self.g_rnd) var g_rnd = 3.14;
function mirandom(numero) {      
	var now= new Date();
	var rnd = now.getSeconds() * now.getMinutes() + g_rnd;
	var tmp= Math.cos(rnd);
	if (tmp<0) { tmp = 0 - tmp}
	var rnd= tmp * numero
	rnd = Math.round(rnd)
	if (rnd == 0) {rnd = 1}
	if (numero==0) {rnd = 0}
	return g_rnd = rnd;
}

function encuentralink(text) {
  var encontrado = 0;
	for(i=0; i<document.links.length; i++) {
		if( contine(text,document.links[i].href) ) {
			encontrado = 1;
			return encontrado;
		}
	}
	return encontrado;
}

function contine(cadena,en) {
	this.myarray = new Array();
	this.myarray = en.split(cadena);
	return (this.myarray.length-1);
}