type:
integration
system:
Flash
name:
Hide Flash on FoxyBox load
description:
Hide flash objects when the Thickbox is launched, and show them again when it's closed.
tags:
flash,
foxybox
date:
2008-03-05

If the pages that launch your FoxyBox cart also contain flash objects, you may encounter some display conflicts. Specifically, flash objects can overlay your cart and obstruct its view, which is obviously not good. The release of ThickBox 3 (on which FoxyBox is based) should have fixed most cases of this problem, however there are still some lingering browser/platform combinations that need some help.

To fix this, simply use javascript to hide the flash objects when the ThickBox is launched, and show the objects again when the box is closed. Two functions created for the JSON cart object, can be defined which let you access these events easily:

// called before ThickBox is opened
function fc_PreProcess() {
	hideFlash();
	return true;
}
// called when ThickBox close button is clicked
function fc_BuildFoxyCart() {
	showFlash();
}

As for the functions hideFlash() and showFlash(), you can borrow from the distrubutions of ThickBox-like scripts. The following were taken from the excellent Lightbox 2 script:

function showFlash(){
	var flashObjects = document.getElementsByTagName("object");
	for (i = 0; i < flashObjects.length; i++) {
		flashObjects[i].style.visibility = "visible";
	}
 
	var flashEmbeds = document.getElementsByTagName("embed");
	for (i = 0; i < flashEmbeds.length; i++) {
		flashEmbeds[i].style.visibility = "visible";
	}
}
 
// ---------------------------------------------------
 
function hideFlash(){
	var flashObjects = document.getElementsByTagName("object");
	for (i = 0; i < flashObjects.length; i++) {
		flashObjects[i].style.visibility = "hidden";
	}
 
	var flashEmbeds = document.getElementsByTagName("embed");
	for (i = 0; i < flashEmbeds.length; i++) {
		flashEmbeds[i].style.visibility = "hidden";
	}
 
}