addLoadEvent(initLeads);

function initLeads()
{
    // creating Lead objects for each div.lead
    var containers = document.getElementsByTagName('*');
    for (var i = 0; i < containers.length; i++) {
        if (containers[i].className.indexOf('lead') != -1) {            
            new Lead(containers[i]);
        }
    }
}

function Lead(container) {
    var leadContainer = container;
    var header = null; 
    var anchor = null;
    var href = null;
    var ps = null;
    var that = this; 
    
    initialize();
    
    function initialize() 
    {
        //if (window.console && console.firebug) console.debug("ok");
        header = leadContainer.getElementsByTagName('h3')[0];
        if (header) {
            anchor = header.getElementsByTagName('a')[0];
            if (anchor) {
                href = anchor.href;
                attachEvents(leadContainer);
                ps = leadContainer.getElementsByTagName('p');
                for (var i = 0; i < ps.length; i++) {
                    attachMore(ps[i]); //if (i == (ps.length-1)) attachMore(ps[i]);
                }
            }
        }
    }
        
    function attachEvents(container) {
        container.style.cursor = "pointer";
        container.onclick = function() {
            window.location = href;
        }
        container.onmouseover = function() {
            attachDecoration(this,'underline');
        }
        container.onmouseout = function() {
            attachDecoration(this,'none');
        }
    }
    
    function attachMore(p) {
        var more = document.createElement('a');
		more.setAttribute('class', 'more');
		more.setAttribute('href', href);
		var txt = document.createTextNode('\u00BB');
		more.appendChild(txt);
        more.style.color = 'red';
        more.style.fontWeight = 'bold';
		p.appendChild(more);
    }
}
