function BetterInnerHTML(o,p,q){function r(a){var b;if(typeof DOMParser!="undefined")b=(new DOMParser()).parseFromString(a,"application/xml");else{var c=["MSXML2.DOMDocument","MSXML.DOMDocument","Microsoft.XMLDOM"];for(var i=0;i<c.length&&!b;i++){try{b=new ActiveXObject(c[i]);b.loadXML(a)}catch(e){}}}return b}function s(a,b,c){a[b]=function(){return eval(c)}}function t(b,c,d){if(typeof d=="undefined")d=1;if(d>1){if(c.nodeType==1){var e=document.createElement(c.nodeName);var f={};for(var a=0,g=c.attributes.length;a<g;a++){var h=c.attributes[a].name,k=c.attributes[a].value,l=(h.substr(0,2)=="on");if(l)f[h]=k;else{switch(h){case"class":e.className=k;break;case"for":e.htmlFor=k;break;default:e.setAttribute(h,k)}}}b=b.appendChild(e);for(l in f)s(b,l,f[l])}else if(c.nodeType==3){var m=(c.nodeValue?c.nodeValue:"");var n=m.replace(/^\s*|\s*$/g,"");if(n.length<7||(n.indexOf("<!--")!=0&&n.indexOf("-->")!=(n.length-3)))b.appendChild(document.createTextNode(m))}}for(var i=0,j=c.childNodes.length;i<j;i++)t(b,c.childNodes[i],d+1)}p="<root>"+p+"</root>";var u=r(p);if(o&&u){if(q!=false)while(o.lastChild)o.removeChild(o.lastChild);t(o,u.documentElement)}}

function findPosX(obj) 
{
    var curleft = 0;
    if (obj.offsetParent) 
	{
        while (1) 
		{
            curleft+=obj.offsetLeft;
            if (!obj.offsetParent) 
			{
                break;
            }
            obj=obj.offsetParent;
        }
    } 
	else if (obj.x) 
	{
        curleft+=obj.x;
    }
    return curleft;
}

function findPosY(obj) 
{
    var curtop = 0;
    if (obj.offsetParent) 
	{
        while (1) 
		{
            curtop+=obj.offsetTop;
            if (!obj.offsetParent) 
			{
                break;
            }
            obj=obj.offsetParent;
        }
    } 
	else if (obj.y) 
	{
        curtop+=obj.y;
    }
    return curtop;
}

function moveIFrame(x,y,w,h) 
{
	var flashCont = document.getElementById("flashContainer");
    var frameRef = document.getElementById("popUpDiv");
	var xPos = findPosX(flashCont) + x;
	var yPos = findPosY(flashCont) + y;
    frameRef.style.left = xPos + "px";
    frameRef.style.top = yPos + "px";
	lastPositionX = x;
	lastPositionY = y;
}

function hideIFrame()
{
    document.getElementById("popUpDiv").style.visibility = "hidden";
}
	
function showIFrame()
{
    document.getElementById("popUpDiv").style.visibility = "visible";
}

function loadIFrame(embeddedCode)
{
	if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent))
	{
		BetterInnerHTML(document.getElementById("popUpDiv"),embeddedCode,true);
	}
	else
	{
		document.getElementById("popUpDiv").innerHTML = embeddedCode;
	}
}

function getWindowWidth() 
{
	var myWidth = 0;
	if( typeof( window.innerWidth ) == 'number' ) 
	{
		//Non-IE
		myWidth = window.innerWidth;
	} 
	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
	{
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
	} 
	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
	{
		//IE 4 compatible
		myWidth = document.body.clientWidth;
	}
	return myWidth;
}

var lastWindowWidth = 0;
var lastPositionX = 0;
var lastPositionY = 0;
var resizeTimeoutId;

window.onresize = function(event)
{
	if (document.getElementById("popUpDiv").style.visibility == "visible")
	{
		window.clearTimeout(resizeTimeoutId);
		resizeTimeoutId = window.setTimeout('onResize();', 10); 
	}
}

function onResize()
{
	var windowWidth = getWindowWidth();
	if (lastWindowWidth != windowWidth)
	{
		moveIFrame(lastPositionX,lastPositionY);
		lastWindowWidth = windowWidth;
	}
}
