The two shouldn't effect eachother, but at the same time, you shouldn't need to use createElement
for what you're trying to do.
I've tidied it up a little, separated bits into clear functions and removed the createElement
parts. Hopefully you'll be able to debug more easily now. I've tried to keep the behaviour the same otherwise, though.
As mentioned in comments, you could also change to using an event listener for resize, which will save the function from having to be called so often.
var getDocSpecs = (function () {
var t,
pre = {h: -1, w: -1},
getDocSpecs;
function asyncFlashGallery(p1, p2, p3) {
return window.setTimeout(function () {jQuery.flashgallery(p1, p2, p3)}, 0);
}
function dMax(nx) {
return Math.max(document.body[nx] || 0, document.documentElement[nx] || 0);
}
getDocSpecs = function getDocSpecs() {
window.clearTimeout(t);
var D = Math.max(
dMax('scrollHeight'), dMax('offsetHeight'), dMax('clientHeight')
),
Le = Math.max(
dMax('scrollWidth'), dMax('offsetWidth'), dMax('clientWidth')
),
calcheight = (0.80 * D);
alert(pre.h + "_" + pre.w + "_" + D + "_" + Le + "_"); // consider console.log
if (pre.h !== D || pre.w !== Le) {
asyncFlashGallery(
'gallery/ArtGallery.swf',
'gallery/gallery.xml',
"{width: '100%', height: '" + calcheight + "px', background: '#000000'}"
);
}
pre.h = D;
pre.w = Le;
t = window.setTimeout(getDocSpecs, 2000);
};
getDocSpecs.CANCEL = function () {window.clearTimeout(t);}
return getDocSpecs;
}());