function setupReflections()
{
  var divs = document.getElementsByTagName('div');
  for( var i=0; i<divs.length; i++ )
  {
    var d = divs[i];
    var c = d.className;
    if( c != null && c.match('(^| )reflect($| )') != null )
    {
      // Reflect the last element inside the div
      if( d.childNodes.length > 0 )
      {
        var e = d.childNodes[d.childNodes.length-1];
      
        var w = 0;
        if( e.clientWidth != null && e.clientWidth != 0 ) w = e.clientWidth;
        else if( e.offsetWidth != null && e.offsetWidth != 0 ) w = e.offsetWidth;
      
        d.className = d.className += ' reflected';

        var n = document.createElement('div');
        n.className = 'reflection';
        n.style.width = w+'px';
        n.innerHTML = d.innerHTML;
        d.appendChild(n);
      
        // Gradient overlay
        var n2 = document.createElement('div');
        n2.style.width = w+'px';
        n2.className = 'reflectionol';
        n2.innerHTML ='<img src="" width="1" height="1" border="0" />';
        d.appendChild(n2);

        try{n2.style.backgroundImage='-o-linear-gradient(top,rgba(255,255,255,0.6), rgba(255,255,255,1))';} catch(ex){}
        try{n2.style.backgroundImage='-webkit-gradient(linear, left top, left bottom, from(rgba(255,255,255,0.6)), to(rgba(255,255,255,1)))';} catch(ex){}
        try{n2.style.backgroundImage='-moz-linear-gradient(top, rgba(255,255,255,0.6), rgba(255,255,255,1))';} catch(ex){}

      }
    }
  }
}

if( window.addEventListener )
  window.addEventListener('load',setupReflections,false);
else if( window.attachEvent )
  window.attachEvent('onload',setupReflections);

