function SWFbox( swfName, swfWidth, swfHeight, swfBackground, swfURL ) {
// create the div structure
createSWFbox( swfName, swfWidth, swfHeight, swfBackground, swfURL );
// position the flash in the middle vertically
positionSWFbox( swfName, swfWidth, swfHeight );
// finally make the swfbox visible
document.getElementById(swfName).style.display='block';
}
function createSWFbox( swfName, swfWidth, swfHeight, swfBackground, swfURL ) {
// get basic browser properties
var pageBody = document.getElementsByTagName("body").item(0);
var userAgent = navigator.userAgent.toLowerCase();
// start creating the div structure
var SWFbox = document.createElement("div");
SWFbox.setAttribute('id',swfName);
SWFbox.className = 'swfbox';
pageBody.appendChild(SWFbox);
var SWFbox_back = document.createElement("div");
SWFbox_back.className = 'swfbox-back';
// fix a bug with flickering flash over opacity on the firefox for Mac
if ( userAgent.indexOf('mac') != -1 && userAgent.indexOf('firefox')!=-1 ) {
SWFbox_back.style.backgroundImage= "url(http://www.coronadainn.com/js/swfbox/swfbox_back.png)";
SWFbox_back.style.backgroundRepeat="repeat";
} else {
SWFbox_back.style.backgroundColor = "#000";
SWFbox_back.style.MozOpacity = 0.5;
SWFbox_back.style.opacity = .50;
SWFbox_back.style.filter = "alpha(opacity=5)";
}
SWFbox.appendChild(SWFbox_back);
var SWFbox_container = document.createElement("div");
SWFbox_container.className = 'swfbox-container';
SWFbox.appendChild(SWFbox_container);
var SWFbox_content = document.createElement("div");
SWFbox_content.className = 'swfbox-content';
SWFbox_container.appendChild(SWFbox_content);
SWFbox_content.innerHTML = '';
SWFbox.onclick = function(e){
// fix a bug with Safari that passes the onclick event hierarchically inside the flash object
if( userAgent.indexOf('safari')!=-1 ) {
if( e.target.className == 'swfbox-flash' ) return;
hideSWFbox(swfName);
} else {
hideSWFbox(swfName);
}
}
window.onscroll = function() {
window.onscroll = null;
if (document.getElementById(swfName)) {
hideSWFbox(swfName);
}
}
}
function positionSWFbox( swfName, swfWidth, swfHeight ) {
// find the browser's window dimensions
windowDimensions = windowSize();
pageScrolls = pageScroll();
// get new positions for the swfbox divs so it appears in the middle vertically
positionDivs = new Array ();
positionDivs = {'swfbox-back-top' : String( pageScrolls[1] )+'px',
'swfbox-back-height' : String( windowDimensions[1] )+'px',
'swfbox-container-top' : String( pageScrolls[1] + (windowDimensions[1]/2) )+'px',
'swfbox-content-top' : String(-(swfHeight/2))+'px' };
// apply the new position of each div
swfboxNodes = document.getElementById(swfName).childNodes;
for ( var i=0; i