//Javascript para HacesFalta.org

function Is() {
    var agent = navigator.userAgent.toLowerCase();
    this.major = parseInt(navigator.appVersion);
    this.minor = parseFloat(navigator.appVersion);
    this.ns  = ((agent.indexOf('mozilla')!=-1) && ((agent.indexOf('spoofer')==-1) && (agent.indexOf('compatible') == -1)));
    this.ns2 = (this.ns && (this.major == 2));
    this.ns3 = (this.ns && (this.major == 3));
    this.ns4b = (this.ns && (this.major == 4) && (this.minor <= 4.03));
    this.ns4 = (this.ns && (this.major >= 4));
    this.ie   = (agent.indexOf("msie") != -1);
    this.ie3  = (this.ie && (this.major == 2));
    this.ie4  = (this.ie && (this.major >= 4));
    this.op3 = (agent.indexOf("opera") != -1);	
}

var is = new Is();

if(is.ns4) 
{
    doc = "document";
    sty = "";
    htm = ".document";
    img = ".document";
    xpos = "e.pageX";
    ypos = "e.pageY";	
} else if(is.ie4) 
	{
    doc = "document.all";
    sty = ".style";
    htm = "";
    img = ".document";
    xpos = "event.x";
    ypos = "event.y";	
	}

function objetoCapa(name,left,top) 
{
	this.obj = eval(doc + '[name]' + sty);
	this.obj.name = name;
	this.obj.left = left;
	this.obj.top = top;
	this.obj.visibility = 'hidden';
	return this.obj;
}

function objetoClip(top,left,width,bottom)
{
	this.top = top;
	this.left = left;
	this.width = width;
	this.bottom = bottom;
}

var capaTexto = null;
var textoClip = null;
var monitorClip = null;
var loop = true;
var velocidad = 3;
var timer1 = null;

function iniciarCapas ()
{
	capaTexto = new objetoCapa('divTexto',73,135);
	textoClip = new objetoClip (0,0,416,195);
	monitorClip = new objetoClip (0,0,416,195);
	capaTexto.visibility = 'visible';	
	return;
}

function scrollTexto(dir) 
{
    dir2 = dir;   
   
    if(loop == true) 
	{
        if(dir2 == "dn") 
		{
            textoClip.top = textoClip.top + velocidad;
			textoClip.bottom = textoClip.bottom + velocidad;			
			capaTexto.top = parseInt(capaTexto.top) - velocidad;            			
            if (is.ns4)			
			{
				capaTexto.clip.top = textoClip.top;
				capaTexto.clip.bottom = textoClip.bottom;
			}
			else
				capaTexto.clip = 'rect(' + textoClip.top + ' ' + textoClip.width + ' ' +textoClip.bottom + ' ' + textoClip.left + ')';
            clearTimeout(timer1);
            timer1 = setTimeout("scrollTexto(dir2)", 1);			
        } 
		else 
		{
			if(dir2 == "up" && parseInt(capaTexto.top) < 135) 
			{
            	textoClip.top = textoClip.top - velocidad;
				textoClip.bottom = textoClip.bottom - velocidad;
				capaTexto.top = parseInt(capaTexto.top) + velocidad;
				if (is.ns4)			
				{
					capaTexto.clip.top = textoClip.top;
					capaTexto.clip.bottom = textoClip.bottom;
				}
				else
					capaTexto.clip = 'rect(' + textoClip.top + ' ' + textoClip.width + ' ' +textoClip.bottom + ' ' + textoClip.left + ')';
	            clearTimeout(timer1);
    	        timer1 = setTimeout("scrollTexto(dir2)", 1);
        	} 
			else 
			{
				if(dir2 == "top") 
				{
		           capaTexto.visibility = 'hidden';
				   capaTexto.top = 135;
				   textoClip.top = monitorClip.top;
				   textoClip.bottom = monitorClip.bottom;				   				   
				   if (is.ns4)
				   {
						capaTexto.clip.top = textoClip.top;
						capaTexto.clip.bottom = textoClip.bottom;   	
					}
					else
						capaTexto.clip = 'rect(' + textoClip.top + ' ' + textoClip.width + ' ' +textoClip.bottom + ' ' + textoClip.left + ')';
					capaTexto.visibility = 'visible';
		        }
			}
		}
	}
	return;
}