var isDOM=document.getElementById?1:0;
var isIE=document.all?1:0;
var isNS4=navigator.appName=='Netscape'&&!isDOM?1:0;
var isIE4=isIE&&!isDOM?1:0;
var isOp=window.opera?1:0;
var isDyn=isDOM||isIE||isNS4;

function getRef(id, par)
{
 par=!par?document:(par.navigator?par.document:par);
 return isIE ? par.all[id] :
  (isDOM ? (par.getElementById?par:par.ownerDocument).getElementById(id) :
  (isNS4 ? par.layers[id] : null));
}

function getSty(id, par)
{
 var r=getRef(id, par);
 return r?(isNS4?r:r.style):null;
}

if (!window.LayerObj) var LayerObj = new Function('id', 'par',
 'this.ref=getRef(id, par); this.sty=getSty(id, par); return this');
function getLyr(id, par) { return new LayerObj(id, par) }

function LyrFn(fn, fc)
{
 LayerObj.prototype[fn] = new Function('var a=arguments,p=a[0],px=isNS4||isOp?0:"px"; ' +
  'with (this) { '+fc+' }');
}
LyrFn('x','if (!isNaN(p)) sty.left=p+px; else return parseInt(sty.left)');
LyrFn('y','if (!isNaN(p)) sty.top=p+px; else return parseInt(sty.top)');
LyrFn('w','if (p) (isNS4?sty.clip:sty).width=p+px; ' +
 'else return (isNS4?ref.document.width:ref.offsetWidth)');
LyrFn('vis','sty.visibility=p');
LyrFn('write','if (isNS4) with (ref.document){write(p);close()} else ref.innerHTML=p');


var CSSmode=document.compatMode;
CSSmode=(CSSmode&&CSSmode.indexOf('CSS')!=-1)||isDOM&&!isIE||isOp?1:0;

if (!window.page) var page = { win: window, minW: 0, minH: 0, MS: isIE&&!isOp,
 db: CSSmode?'documentElement':'body' }

page.winW=function()
 { with (this) return Math.max(minW, MS?win.document[db].clientWidth:win.innerWidth) }
page.winH=function()
 { with (this) return Math.max(minH, MS?win.document[db].clientHeight:win.innerHeight) }


// *** QUOTATION SCROLLER ENGINE ***

function checkDivs()
{
 if (!isDyn) return;
 
 for (var i = 1; i <= visQuotes; i++)
 {
  // Get a layer object if it doesn't exist, and work with it.
  if (!sDivs[i])
  {
   sDivs[i] = getLyr('capa' + i);
   // IE4, as normal, has horrible width bugs in which content expands to fill the screen.
   if (isIE4) sDivs[i].w(10);
  }

  with (sDivs[i])
  {
   // If it's moved offscreen to the left (or starting), set things in motion...
   if (x() < (0 - w()))
   {
    // New random value to choose quote size+speed.
    var rnd = Math.random();

    // Scrolling increment varies from 8 to 63.
    speed[i] = minSpeed + rnd*(maxSpeed-minSpeed);
    // Off to the right it goes -- qPos records the current position as a floating point number.
    qPos[i] = page.winW() + 50*Math.random();
 
    // Likewise calculate a new fontsize and position.
    var fontSize = parseInt(minSize + rnd*(maxSize-minSize));

    // Position and layer it according to its size & speed (faster = higher).
    var topMax = page.winH() - (isIE?5:20) - fontSize;
    y(topMax * Math.random());
    sty.zIndex = speed[i];

    // Choose a colour (based on the random speed) and a quote.
    var col = colours[Math.floor(rnd*colours.length)];
    var selquote = quotes[Math.floor(Math.random() * quotes.length)];

    // Format with FONT tag for NS4, SPAN for proper browsers.
    var str = isNS4 ? '<font face="'+fontFace+'" point-size="'+fontSize+'" color="#'+col+
     '">'+selquote+'</font>' : '<span style="font-family: '+fontFace+'; font-size: '+fontSize+
     'px; color: '+col+'">'+selquote+'</span>';

    // Write the content to a div, ensuring it doesn't wrap. Perhaps make this a link etc?
    write('<nobr>' + str + '</nobr>');
   }

   // All items: Keep 'em moving left.
   qPos[i] -= speed[i];
   x(qPos[i]);
  }
 }

 // Again!
 setTimeout('checkDivs()', 50);
}

// *** START EDITING HERE ***


// There's more Simpsons at http://www.everything2.com/index.pl?node_id=767744
// Just cut and paste your quotes into this array:

var quotes = new Array(); c = 0;
quotes[c] = 'DAAC'; c++;
quotes[c] = 'SEGURIDAD TOTAL'; c++;
quotes[c] = 'D&eacute;jelo en nuestras manos'; c++;
quotes[c] = 'Conocemos bien los riesgos que afectan a la vida diaria y c&oacute;mo deben asegurarse los posibles daņos personales y materiales'; c++;
quotes[c] = 'Todo riesgo de la construcci&oacute;n'; c++;
quotes[c] = 'Decenal de daņos a la edificaci&oacute;n'; c++;
quotes[c] = 'Accidentes. Individuales y Colectivos'; c++;
quotes[c] = 'Responsabilidad civil general y profesional'; c++;
quotes[c] = 'Multirriesgo: Hogar'; c++;
quotes[c] = 'Multirriesgo: Comercios y Oficinas'; c++;
quotes[c] = 'Automovil'; c++;


// Maximum onscreen at once, also number of DIVs in body -- change that too!
var visQuotes = 10;

// Set the minimum and maximum quote speeds and font sizes.
var minSpeed = 5, maxSpeed = 8, minSize = 15, maxSize = 32;

//  Left: Low speed colours (lighter) .... Right: High speed colours (darker).
var colours = new Array('ffffff','EE3A42');

// Fonts, of course, a comma-separated list is fine.
var fontFace = 'Arial, Helvetica, Verdana';

// Just leave these, some global arrays are needed to remember quote details.
var sDivs = new Array(visQuotes);
var speed = new Array(visQuotes);
var qPos = new Array(visQuotes);



// Finally trigger quotation scrolling on page load.
// Remember to call all onLoad events here somehow (e.g. popup menus/other scripts)...
window.onload = new Function('checkDivs()');

