﻿
Delegate=new Object();Delegate.create=function(obj,func)
{var f=function()
{var target=arguments.callee.target;var func1=arguments.callee.func;return func1.apply(target,arguments);};f.target=obj;f.func=func;return f;}
function SWFObjectResizer(flashDivId,so)
{if(SWFObjectResizer.count==null)
{SWFObjectResizer.count=0;}
else
{SWFObjectResizer.count++;}
this.instanceCount=SWFObjectResizer.count;var uniqStr=this.getUniqueString();this.origWidth=this.width=so.getAttribute("width");this.origHeight=this.height=so.getAttribute("height");so.setAttribute("width","100%")
so.setAttribute("height","100%")
var flashDiv=document.getElementById(flashDivId);flashDiv.innerHTML='<div id="flashDivDummy'+uniqStr+'"></div><div id="flashDivContainer'+uniqStr+'" style="position:absolute;"><div id="flashDiv'+uniqStr+'" style="width:100%;height:100%;">'+flashDiv.innerHTML+'</div></div>';SWFObjectResizer.addEvent(window,"load",Delegate.create(this,this.pageLoad));}
SWFObjectResizer.prototype.getElementId=function()
{return"flashDiv"+this.getUniqueString();}
SWFObjectResizer.addEvent=function(target,eventName,func)
{if(target.addEventListener)
{target.addEventListener(eventName,func,false);}
else if(target.attachEvent)
{eventName="on"+eventName;target.attachEvent(eventName,func);}
else
{alert("Failed to add event : "+event);}}
SWFObjectResizer.prototype.getUniqueString=function()
{if(this.uniqueString==null)
{var time_str=new Date().getTime().toString();this.uniqueString="_"+
(Number(time_str.substr(0,7))).toString(36)+
(Number(time_str.substr(7))).toString(36)+
(Math.floor(Math.random()*1679616).toString(36))+"_"+
this.instanceCount.toString(36);}
return this.uniqueString;}
SWFObjectResizer.prototype.pageLoad=function(ev)
{var uniqStr=this.getUniqueString();this.containerDiv=document.getElementById("flashDivContainer"+uniqStr);this.dummyDiv=document.getElementById("flashDivDummy"+uniqStr);this.dummyDiv.style.width=this.width+"px";this.dummyDiv.style.height=this.height+"px";var pos=SWFObjectResizer.findPos(this.dummyDiv);this.containerDiv.style.left=pos[0]+"px";this.containerDiv.style.top=pos[1]+"px";this.containerDiv.style.width=this.width+"px";this.containerDiv.style.height=this.height+"px";SWFObjectResizer.addEvent(window,"resize",Delegate.create(this,this.positionSync));setInterval(Delegate.create(this,this.positionSync),100);}
SWFObjectResizer.prototype.positionSync=function()
{var pos=SWFObjectResizer.findPos(this.dummyDiv);this.containerDiv.style.left=pos[0]+"px";this.containerDiv.style.top=pos[1]+"px";}
SWFObjectResizer.prototype.revert=function()
{this.resize(this.origWidth,this.origHeight,false);}
SWFObjectResizer.prototype.resize=function(width,height,floating)
{this.width=width;this.height=height;if(!floating)
{this.dummyDiv.style.width=this.width+"px";this.dummyDiv.style.height=this.height+"px";}
this.containerDiv.style.width=this.width+"px";this.containerDiv.style.height=this.height+"px";}
SWFObjectResizer.findPos=function(obj)
{var curleft=curtop=0;if(obj.offsetParent)
{curleft=obj.offsetLeft
curtop=obj.offsetTop
while(obj=obj.offsetParent)
{curleft+=obj.offsetLeft
curtop+=obj.offsetTop}}
return[curleft,curtop];}