
document.write('<script type="text/javascript" src="ModalWindowSimulator.js"></script>');

function addListener(element, event, listener) 
{
  if(element.addEventListener) 
  {
    if(typeof(bubble) == "undefined") bubble = false;
    element.addEventListener(event, listener, bubble);
  } 
  else {
    if(element.attachEvent) element.attachEvent("on" + event, listener);
	}
}
//addListener(this, "load", function() { OpenDemoSWF_init(); });


//function OpenDemoSWF_init()
//{
//	modalWindowSimulator = new ModalWindowSimulator("DoModalBlockingDiv");
//	openDemoSWF = new OpenDemoSWF();
//}


var openDemoSWF;


function OpenDemoSWF()
{
	this._width;
	this._height;
	
	var dv = document.createElement("div"); // create dynamically div tag
	document.body.appendChild(dv);
	dv.setAttribute('id', "SWFDivContainerDBx");//give id to it
	dv.style.visibility = "hidden";
	dv.style.position = "absolute";       
	dv.style.top = "0px";
	dv.style.left = "0px";
	dv.innerHTML = "&nbsp;";
	
	this.m_divRef = document.getElementById("SWFDivContainerDBx");
}


OpenDemoSWF.GetInstance = function()
{
	if (openDemoSWF == null)
	{
	   openDemoSWF = new OpenDemoSWF(); 
	   ModalWindowSimulator.GetInstance();
	}
	
	return openDemoSWF;
}

OpenDemoSWF.prototype.OpenSWF = function(SWFtoOpen, width, height)
{
    ModalWindowSimulator.GetInstance().EnableDoModalDiv();
	
	this._width = width;
	this._height = height;
	//this.m_divRef.style.width = width + "px";
	//this.m_divRef.style.height = height + "px";
	
	this.SetPositionY();
	this.SetPositionX();
	
	this.m_divRef.innerHTML = 
	    '<table cellspacing="0" cellpadding="0" border="0">'+
        '<tr>'+
	        '<td>'+
		        '<div class="videoPopUp">'+
		        '<table><tr><td align="right"><a href="javascript:void(0);" onclick="OpenDemoSWF.GetInstance().CloseSWF()"><img src="images/closeBtn.gif" alt="Close" class="close" border="0" /></a><br \></td></tr>' + 
		        '<tr><td>' + 
		'<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="' + width + '" height="' + height + '" ID="Captivate1" VIEWASTEXT>' + 
		'<param name="movie" value="' + SWFtoOpen + '">' + 
		'<param name="quality" value="high">' + 
		'<param name="loop" value="0">' + 
		'<embed src="' + SWFtoOpen + '" width="' + width + '" height="' + height + '" loop="0" quality="high" pluginspage="http://www.adobe.com/go/getflashplayer" type="application/x-shockwave-flash" menu="false"></embed>' + 
		'</object>' +
						'</td></tr></table>' +
		        '</div>'+
	        '</td>'+
	        '<td class="videoPopUp_droite" width="6"></td>'+
        '</tr>'+
        '<tr>'+
	        '<td class="videoPopUp_bas"></td>'+
	        '<td class="videoPopUp_bas_droite"></td>'+
        '</tr>'+
        '</table>';
	
	this.m_divRef.style.zIndex = 5000;
	this.m_divRef.style.visibility = "visible";
}

OpenDemoSWF.prototype.CloseSWF = function()
{
	ModalWindowSimulator.GetInstance().DisableDoModalDiv();
	this.m_divRef.style.innerHTML = "";
	this.m_divRef.style.visibility = "hidden";
}

OpenDemoSWF.prototype.SetPositionX = function()
{
	var posX;
	var scrollX;
	if (window.innerWidth && document.body.scrollLeft)
	{
		// Firefox
		posX = window.innerWidth;
		scrollX = document.body.scrollLeft;
	}
	else if (document.body.scrollLeft && document.body.offsetWidth)
	{
		// all but Explorer Mac
		posX = document.body.offsetWidth;
		scrollX = document.body.scrollLeft;
	}
	else
	{
		// works in Explorer 6 Strict, Mozilla (not FF) and Safari
		posX = document.body.offsetWidth;
		scrollX = document.body.scrollLeft;
	}
	
	this.m_divRef.style.left = ( scrollX + (posX/2) - parseInt(this._width)/2  ) + "px";
}

OpenDemoSWF.prototype.SetPositionY = function()
{
	var posY;
	var scrollY;
	if (window.innerHeight && window.scrollMaxY)
	{
		// Firefox
		posY = window.innerHeight;
		scrollY = document.body.scrollTop;
	}
	else if (document.body.scrollTop && document.body.offsetHeight)
	{
		// all but Explorer Mac
		posY = document.body.offsetHeight;
		scrollY = document.body.scrollTop;
	}
	else
	{
		// works in Explorer 6 Strict, Mozilla (not FF) and Safari
		posY = document.body.offsetHeight;
		scrollY = document.body.scrollTop;
	}
	
	//this.m_divRef.style.top = ( scrollY + (posY/2) - parseInt(this._height)/2  ) + "px";
	this.m_divRef.style.top = "120px";
}
