/* Returns value of the specified computed style
for an element. If the specified style wasn't gotten,
returns null. */
function getElementComputedStyle(element, style) {
    
    /* First, try to use Internet-Explorer API. */
    if ('currentStyle' in element) {
        
        if (style in element.currentStyle)
            return element.currentStyle[style];
    }
    /* Otherwise, try to use W3C API. */
    else if ('getComputedStyle' in window) {
        
        var computedStyle = getComputedStyle(element, null);
        if (style in computedStyle)
            return computedStyle[style];
    }
    
    /* If the specified style wasn't gotten. */
    return null;
    
}   // end of function getElementComputedStyle()


/* Retrieves size value from the specified CSS size string,
converts it to numeric value and returns the result.
For example, for the string "100px" the function
will return a Number object with the value 100.
If the specified style size could not be converted to
number, the function returns NaN (not a number). */
function styleSizeToNumber(styleSize) {
    
    /* Check, if the specified style has a correct format.
    If it doesn't, return NaN. */
    var format = /^\d+(?:.\d+)?(?:%|in|cm|mm|em|ex|pt|pc|px)?$/;
    if (format.test(styleSize) == false)
        return NaN;
    
    /* Find the first occurance of size unit.
    If it's exists, retrieve substring that
    contains only number part of style size. */
    var retrievedSize = undefined;
    var unitOccuranceIndex = styleSize.search(/(%|in|cm|mm|em|ex|pt|pc|px)$/);
    if(unitOccuranceIndex != -1)
        retrievedSize = styleSize.substring(0, unitOccuranceIndex);
    else
        retrievedSize = styleSize;
    
    return parseFloat(retrievedSize);
    
}   // end of function retrieveSizeValue()