| 175 | |
| 176 | // returns the value of 1em in pixels |
| 177 | getEmValue = function () { |
| 178 | var ret, |
| 179 | div = doc.createElement('div'), |
| 180 | body = doc.body, |
| 181 | fakeUsed = false; |
| 182 | |
| 183 | div.style.cssText = "position:absolute;font-size:1em;width:1em"; |
| 184 | |
| 185 | if (!body) { |
| 186 | body = fakeUsed = doc.createElement("body"); |
| 187 | body.style.background = "none"; |
| 188 | } |
| 189 | |
| 190 | body.appendChild(div); |
| 191 | |
| 192 | docElem.insertBefore(body, docElem.firstChild); |
| 193 | |
| 194 | ret = div.offsetWidth; |
| 195 | |
| 196 | if (fakeUsed) { |
| 197 | docElem.removeChild(body); |
| 198 | } |
| 199 | else { |
| 200 | body.removeChild(div); |
| 201 | } |
| 202 | |
| 203 | //also update eminpx before returning |
| 204 | ret = eminpx = parseFloat(ret); |
| 205 | |
| 206 | return ret; |
| 207 | }, |
| 208 | |
| 209 | //cached container for 1em value, populated the first time it's needed |
| 210 | eminpx, |