/**
 * VERTICAL SCROLLING NEWS TICKER
 *
 * By Jaime GÓMEZ OBREGÓN - jaime@iteisa.com
 * www.iteisa.com
 * For FUTBOLCRACKS.COM
 *
 * 2007-09-12 15:49:23
 *
**/

var tickerEnd;
var tickerInterval;
var tickerSpeed = 225;
var tickerPosition = 0;

function tickerStart() {
  ticker = $('newsTicker');

// maybe this can be better done by means of CSS and padding-top.
  var spacerHTML = '<div style="height: 256px"></div>';
  new Insertion.Top(ticker.getElementsByTagName('ul')[0], spacerHTML);
  tickerEnd = -(ticker.offsetHeight);
  ticker.addClassName('hasJS');

  tickerInterval = setInterval('tickerScroll()', tickerSpeed);

  ticker.onmouseover = function() {
    clearInterval(tickerInterval);
  }
  ticker.onmouseout = function() {
    tickerInterval = setInterval('tickerScroll()', tickerSpeed);
  }
}

function tickerScroll() {
  var tickerContent = $('newsTicker').getElementsByTagName('ul')[0];
  tickerContent.getElementsByTagName('ul')[0];

  if (--tickerPosition <= tickerEnd) {
    tickerPosition = 0;
  }

  tickerContent.style.top = tickerPosition + 'px';
}


















sfHover = function() {
  var sfEls = document.getElementById("iteisa-mainMenu").getElementsByTagName("LI");
  for (var i=0; i<sfEls.length; i++) {
    sfEls[i].onmouseover=function() {
      this.className+=" sfhover";
    }
    sfEls[i].onmouseout=function() {
      this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
    }
  }
}
if (window.attachEvent) window.attachEvent("onload", sfHover);












































/* 
Derived from a script by Alejandro Gervasio. 
Modified to work in FireFox by Stefan Mischook for Killersites.com
Modificado por Fernando Casabella y Juan Antonio Pereira para Futbolcracks.com

How it works: just apply the CSS class of 'columna' to your pages' main columns.
*/
matchColumns=function(){ 

     var divs,contDivs,maxHeight,divHeight,d; 
  
     // get all <div> elements in the document 

     divs=document.getElementsByTagName('div'); 

     contDivs=[]; 

// alert(divs.length);
     // initialize maximum height value 

     maxHeight=0; 

     // iterate over all <div> elements in the document 

     for(var i=0;i<divs.length;i++){ 

          // make collection with <div> elements with class attribute 'columna' 

          if(/\bcolumna\b/.test(divs[i].className)){ 

                d=divs[i]; 

                contDivs[contDivs.length]=d; 

                // determine height for <div> element 

                if(d.offsetHeight){ 

                     divHeight=d.offsetHeight;          

                } 

                else if(d.style.pixelHeight){ 

                     divHeight=d.style.pixelHeight;          

                } 

                // calculate maximum height 

                maxHeight=Math.max(maxHeight,divHeight); 

          } 

     } 

     // assign maximum height value to all of container <div> elements 

     for(var i=0;i<contDivs.length     -1      ;i++){ 
          contDivs[i].style.height=maxHeight + "px"; 
     } 

} 





function submitenter(myfield,e)
{
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;

if (keycode == 13)
   {
   myfield.form.submit();
   return false;
   }
else
   return true;
}









var myrules = {
  '.js_clearonclick' : function(el){
    if(!el.originaltext)
      el.originaltext=el.value;
    el.onfocus = function()
                {
                  if(el.value==el.originaltext)
                    el.value='';
                };
    el.onblur=function()
              {
                if(el.value=='')
                  el.value=el.originaltext;
              };
  },
  'form': function(el)
  {
    el.onsubmit=function()
    {
      //clean inputs
      inputs=document.getElementsByTagName("input");
      for(var i=0;i<inputs.length;i++)
        if(inputs[i].type=="text"&&inputs[i].className.indexOf("js_clearonclick")>=0
          &&(inputs[i].originaltext==inputs[i].value||!inputs[i].originaltext))
            inputs[i].value="";
      //clean textareas
      inputs=document.getElementsByTagName("textarea");
      for(var i=0;i<inputs.length;i++)
        if(inputs[i].className.indexOf("js_clearonclick")>=0
          &&(inputs[i].originaltext==inputs[i].value||!inputs[i].originaltext))
            inputs[i].value="";
    }
  }


};


Behaviour.register(myrules);

window.onload = function() {
  if(!document.getElementById || !document.createTextNode)
    return;

  if ($('newsTicker'))
    tickerStart();

  matchColumns();

  Behaviour.apply();
}