
function getElementsByClassName2(className, tag, elm)
{
    var testClass = new RegExp("(^|\\s)" + className + "(\\s|$)");	        	        	        	        	        
    var tag = tag || "*";
    var elm = elm || document;
    var elements = (tag == "*" && elm.all)? elm.all : elm.getElementsByTagName(tag);
    var returnElements = [];
    var current;
    var length = elements.length;
	
    for(var i=0; i<length; i++)
    {
        current = elements[i];
        if(testClass.test(current.className))
        {
	        returnElements.push(current);
        }
    }
	
    return returnElements;
}


function attachFsInfoEventHandlers()
{		
    // for each fsInfo element
    // loop through its children element and tag the 
    // fsShortInfo, fsMoreInfo, fsShowMore, and fsCloseMe elements
    // attach onclick handler to the "See More" button
	
    var fsInfoElems = getElementsByClassName2("fsInfo", "div");		

    for(i=0; i < fsInfoElems.length; ++i)
    {		
        var shortInfoElement = null;
        var moreInfoElement  = null;
        var showMoreButton   = null;
        var hideButton       = null;
        		       
        // go through an fsInfo block's children
        for(j=0; j < fsInfoElems[i].childNodes.length; ++j)
        {
            // tag elements that will be used for the onclick toggle handler
            
	        if(fsInfoElems[i].childNodes[j].className == 'fsShortInfo')    			
	        {			            
		        shortInfoElement = fsInfoElems[i].childNodes[j];			
		        showMoreButton = getElementsByClassName2('fsShowMore', null, shortInfoElement)[0];				       	
	        } 	
	        			        
	        if(fsInfoElems[i].childNodes[j].className == 'fsSeeMoreInfo')    			
	        {
		        moreInfoElement = fsInfoElems[i].childNodes[j];		
		        hideButton = getElementsByClassName2('fsCloseMe', null, moreInfoElement)[0];		        
	        } 				        
        }
        
        areAllElementsFound = shortInfoElement && moreInfoElement && showMoreButton && hideButton;

        if(areAllElementsFound)
        {                
            showMoreButton.onclick = function()
            {
                shortInfoElement = this.parentNode.parentNode;	  
                moreInfoElement = getElementsByClassName2('fsSeeMoreInfo', null, shortInfoElement.parentNode)[0];
                          
                shortInfoElement.style.display = "none";
                moreInfoElement.style.display = "block";
            }                
        
            hideButton.onclick = function()
            {
                moreInfoElement = this.parentNode;
                shortInfoElement = getElementsByClassName2('fsShortInfo', null, moreInfoElement.parentNode)[0];            
            
                shortInfoElement.style.display = "block";
                moreInfoElement.style.display = "none";		                                    
            }                                		            
        }
    }			
}	

onloads.push(attachFsInfoEventHandlers);


