//BUSCAR UN TEXTO EN UNA PAGINA Y POSICIONARSE EN EL
// ejemplos: buscarTxt("buenas")
//           buscarTxt(document.form1.input1.value); 
function buscarTxt(texto){
if(!document.all) return
var contenido = document.body.createTextRange();
var seguir = true;
var temporal = contenido.duplicate();
var existe = temporal.findText(texto,0,0)
while(existe && seguir)	{
	temporal.scrollIntoView(true)
		temporal.select();
		//Modifica contenido para que comience al final 
		//de la palabra encontrada
		contenido.setEndPoint("StartToEnd", temporal);
		seguir = confirm("¿Continuar la búsqueda?")
			if (seguir)		{
			//Repite  labúsqueda
			temporal = contenido.duplicate();
			existe = temporal.findText(texto,0,0)
			}
}
if (seguir)	alert("Fin del documento")
}

//OBTENER EL VALOR DE UN PARAMETRO RECIBIDO DESDE OTRA PAGINA, ES COMO REQUEST.QUERYSTRING DEL ASP.
// ejemplos: reciboParam("nombre")

function reciboParam(pa){
var i;
var recibo;
var haypara;
var hayvarios;
var datos;
var areadatos;
var contenido;
recibo=String(unescape(window.location));
haypara=recibo.indexOf("?");
if (haypara==-1) return "";
areadatos=recibo.split("?");
hayvarios=recibo.indexOf("&");
if (hayvarios==-1){
   datos=areadatos[1].split("=");
   if (datos[0]==pa){
       return datos[1];
       }
       else
       {
       return "";
   }    
 }
contenido=areadatos[1].split("&");
for (i=0;i<contenido.length;i++){ 
 datos=contenido[i].split("=");
   if (datos[0]==pa){
       return datos[1];
   }
}
return ""
}
////////////////////////////
function sacarventana(URL) {
if (URL!="NO"){
day = new Date();
id = day.getTime();

eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=yes,location=0,statusbar=0,menubar=0,resizable=yes,width=750,height=400,fullscreen=yes');");
}
}

function escribe(){
document.write ('<div id="mami" style="width:' + ancho + '; height:' + alto + 'px; position:relative;  overflow:hidden ">')
document.write('<table bgcolor="' + fondo + '" border = "' + marco + '" width="' + ancho + '" height="100%"><tr><td valign="top">')
document.write ('<div id="uno" style="top:' + alto +'; width:' + ancho + ' height:' + alto + 'px;  ">')
document.write ('<div class="titular">')
document.write (noticias[0].titular)
document.write ('</div>')
document.write ('<div class="fecha">')
document.write (noticias[0].fecha)
document.write ('</div>')
document.write ('<div class="texto">')
document.write (noticias[0].texto)
document.write ('</div>')
if(masInfo == true && noticias[0].enlace!="NO" ){
  coma="'";
   if (noticias[0].enlace.substr(0,4)!= "http"){
	document.write ('<a class="enlace" href="javascript:sacarventana('+coma)
	document.write (noticias[0].enlace)
	document.write (coma+')" >más información...</a>')
   }
   else
   {
	document.write ('<a class="enlace" href="')
	document.write (noticias[0].enlace)
	document.write ('" target="' + destino + '">más información...</a>')
   }	
}	
document.write ('</div>')
document.write ('<div id="dos" style="top:' + (alto*2) +'; width:' + ancho + ' height:' + alto + 'px; ">')
document.write ('<div class="titular">')
document.write (noticias[1].titular)
document.write ('</div>')
document.write ('<div class="fecha">')
document.write (noticias[1].fecha)
document.write ('</div>')
document.write ('<div class="texto">')
document.write (noticias[1].texto)
document.write ('</div>')
if(masInfo == true && noticias[1].enlace!="NO"){
   if (noticias[1].enlace.substr(0,4)!= "http"){
	document.write ('<a class="enlace" href="javascript:sacarventana('+coma)
	document.write (noticias[1].enlace)
	document.write (coma+')" >más información...</a>')
   }
   else
   {
	document.write ('<a class="enlace" href="')
	document.write (noticias[1].enlace)
	document.write ('" target="' + destino + '">más información...</a>')
	}	}
document.write ('</div>')
document.write('</td></tr></table>')
document.write ('</div>')
if(navigator.appName == "Netscape")
{altoUno = document.getElementById('uno').offsetHeight}
else
{altoUno = document.getElementById('uno').clientHeight}
document.getElementById('uno').onmouseover =function(){
	det = true
	clearTimeout(tiempo)
	}
document.getElementById('uno').onmouseout =function(){
	det = false;
	clearTimeout(tiempo)
	escrolea()
	}

document.getElementById('dos').onmouseover =function(){
	det = true
	clearTimeout(tiempo)
	}
document.getElementById('dos').onmouseout =function(){
	det = false;
	clearTimeout(tiempo)
	 escrolea()
	 
	}
}
desp = 1
var cont = 1
var pos,pos2


function escrolea(){
pos = document.getElementById('uno').style.top
pos = pos.replace(/px/,"");
pos = pos.replace(/pt/,"");
pos = new Number(pos);
pos2 = document.getElementById('dos').style.top
pos2 = pos2.replace(/px/,"");
pos2 = pos2.replace(/pt/,"");
pos2 = new Number(pos2);
pos -= desp
pos2 -= desp

if (pos == desp){
	var contenidos = ""
	document.getElementById('dos').style.top = alto
	document.getElementById('dos').childNodes[0].firstChild.nodeValue  = noticias[cont].titular
	if(poneFecha == true){
	document.getElementById('dos').childNodes[1].firstChild.nodeValue  = noticias[cont].fecha
	}
	document.getElementById('dos').childNodes[2].firstChild.nodeValue  = noticias[cont].texto
	if(masInfo == true && noticias[cont].enlace!="NO"){
		//document.getElementById('dos').childNodes[3].href = noticias[cont].enlace 
		if (noticias[cont].enlace.substr(0,4)!= "http"){
		document.getElementById('dos').childNodes[3].href = "javascript:sacarventana('"+noticias[cont].enlace +"')";
			
		}
		else
		{
		document.getElementById('dos').childNodes[3].href = noticias[cont].enlace 

		}		

	
	}
	document.getElementById('uno').style.top = 0
	if(cont == noticias.length-1)
		{cont=0}
	else{
		cont++
		}
	pausa()
	return false
	}
else{
	if (pos2 == desp){
		var contenidos = ""
		document.getElementById('uno').style.top = alto
		document.getElementById('uno').childNodes[0].firstChild.nodeValue  = noticias[cont].titular
		if(poneFecha == true){
		document.getElementById('uno').childNodes[1].firstChild.nodeValue  = noticias[cont].fecha
		}
		document.getElementById('uno').childNodes[2].firstChild.nodeValue  = noticias[cont].texto
		if(masInfo == true && noticias[cont].enlace!="NO"){
		//document.getElementById('uno').childNodes[3].href  = noticias[cont].enlace
		if (noticias[cont].enlace.substr(0,4)!= "http"){
		document.getElementById('uno').childNodes[3].href = "javascript:sacarventana('"+noticias[cont].enlace +"')";
			
		}
		else
		{
		document.getElementById('uno').childNodes[3].href = noticias[cont].enlace 

		}				
		
		
		
		}
		document.getElementById('dos').style.top = 0
		if(cont == noticias.length-1)
		{cont=0}
	else{
		cont++
		}
		pausa()
		return false
		}
	else{
		document.getElementById('uno').style.top = pos
		document.getElementById('dos').style.top = pos2
		}
	}
tiempo = window.setTimeout('escrolea()',50)
}

var tiempo


function pausa()
{
clearTimeout(tiempo)
if (det == false){
	tiempo = setTimeout ('continuar()',2000)
	}
}


function continuar()
{
if(det == false)
	{escrolea()}
}


