function getElementByClass(sIDRoot, sTag, sClass) 
{
    var temparray = new Array();   
    
    var containerDiv = document.getElementById(sIDRoot);
    var dvs = containerDiv.getElementsByTagName(sTag);
    var i = 0;
    
    for (var c = 0; c < dvs.length; c++) {
        if (dvs[c].className == sClass) {
            var aEls = dvs[c].getElementsByTagName('span');                       
            for (var n = 0; n < aEls.length; n++) {                
                temparray[i++] = aEls[n];
            }
        }              
    }
    return temparray;
} 

function getStyle(elt)  
   {  
   	var computedStyle;  
   
        if(typeof elt.currentStyle != 'undefined')  
         // IE  
          computedStyle = elt.currentStyle;  
       else  
          // Firefox  
         computedStyle = document.defaultView.getComputedStyle(elt, null);  
     
      return computedStyle;  
   }  
   
 function cleanupUrl(aUrl)  
 {  
    var regExp = /^url\("?(.*?)"?\)$/ig;  
    var matches = regExp.exec(aUrl);  
   
    if(matches == null || typeof matches[1] == "undefined")  
       return null;  
   
    return matches[1];  
 }

 function pageload() {

     var els = getElementByClass('menu-h', 'li', 'hnav_el');
     var theDivElementWithoutDimensions = els[0];
     var computedStyle;
//       
     for (var c = 0; c < els.length; c++) {     
         computedStyle = getStyle(els[c]);
         var the_width = computedStyle.backgroundImage.width;
         //els[c].style.width = the_width;
         //alert(computedStyle.backgroundImage.width);
    }

    var dummyImage = document.createElement("img");
    
    dummyImage.onload = function() {
        // Thanks to JavaScript closure we can access  
        // the theDivElementWithoutDimensions variable
        // from the onload method
        for (var c = 0; c < els.length; c++) {
            with (els[c].style) {
                width = this.width + "px";
                //height = this.height + "px";

            }
        }
    };

    dummyImage.src = cleanupUrl(computedStyle.backgroundImage);
}  