var flashInstalled = false;

//Toggle Adobe Badge Layer...
function toggleBadgeLayer(swfPath) {
	if (!flashInstalled) {
		alert("This content requires Flash. Please download Flash from Adobe website.")
	return;	
	}
	
	
	doOnClick(swfPath);
	if (document.getElementById('ADE_DetectAndInstallDiv').style.visibility == "visible" ) {
		document.getElementById('ADE_DetectAndInstallDiv').style.visibility = "hidden" ;
	}
	else {
		document.getElementById('ADE_DetectAndInstallDiv').style.visibility = "visible";
	} 
}

//Called inline from the page to detect ADE, and hide/show the layer for installing the button..
function detectADE(swfPath) {
	ADE_Detect_doOnLoad('', false, false, swfPath);
	///doOnLoad(swfPath);
}

//This is a callback function invoked after the function ADE_Detect_doOnLoad() has finished.
function setG_nADEInstalled(IS_INSTALLED) {
	
	var obj = document.getElementById('ADE_ShowContentDiv');
	if (IS_INSTALLED == '1') {
		if (obj != null &&  typeof(obj.style)!= "undefined"){
			//document.getElementById('ADE_ShowContentDiv').style.visibility = "hidden";
		}
	}
}

function doOnClick(swfPath)
{
	//  HTML Section params:
	//  =========================
	var HTMLdivID = "ADE_DetectAndInstallDiv";
	var HTMLobjectID = "ADEBadgeLauncherInstance";
	//  Flash SWF parameters:
	//  =========================
	var doFulfillmentLink = false;
	var autoInstall = false; 
	var autoLaunch = false;
	var badFlashRedirectURL	= null; // "http://my.domain.com/flashhelp";  // null; // can be null
	var sendADEInstalled = true;	
	var sendSWFVersion = true;	
	var sendButtonPush = true;  // if true, only call the JS function - contentURL would be ignored if used
	ADEBadgeLauncherInstance(HTMLdivID, HTMLobjectID, "", 
		doFulfillmentLink, 
		autoInstall, 
		autoLaunch, 
		badFlashRedirectURL, 
		sendADEInstalled, 
		sendSWFVersion, 
		sendButtonPush,
		swfPath);
}

function doOnLoad(swfPath)
{
	//  HTML Section params:
	//  =========================
	var HTMLdivID = "ADE_DetectAndInstallDiv";
	var HTMLobjectID = "ADEBadgeLauncherInstance";
	//  Flash SWF parameters:
	//  =========================
	var doFulfillmentLink = false;
	var autoInstall = false; 
	var autoLaunch = false;
	var badFlashRedirectURL	= null; // "http://my.domain.com/flashhelp";  // null; // can be null
	var sendADEInstalled = true;	
	var sendSWFVersion = true;	
	var sendButtonPush = true;  // if true, only call the JS function - contentURL would be ignored if used
	ADEBadgeLauncherInstance(HTMLdivID, HTMLobjectID, "", 
		doFulfillmentLink, 
		autoInstall, 
		autoLaunch, 
		badFlashRedirectURL, 
		sendADEInstalled, 
		sendSWFVersion, 
		sendButtonPush,
		swfPath);
	document.getElementById('ADE_DetectAndInstallDiv').style.visibility = "hidden" ;
	
}
function ShowADE_DivLayer()
{
	flashInstalled = G_bFlashInstalled;
	//alert("abc" + G_bFlashInstalled);
	// This example does not use DigitalEditionsDetection.js
	// Therefore this stub is needed
	return;
}

// ********************
// Stub function provided to support operation for SWF Version
// This is called when sendSWFVersion = "true"
// and the script at setG_strSWFVersion() detects a fresh string
// ********************
function ShowSWFVersion_DivLayer() {
	// We do the version in this example therefore this is needed
	if (G_bUpdateSWFVersion)
	{
		G_bUpdateSWFVersion = false;
		if (G_strSWFVersion.length > 0)
		{
			//THIS IS THE PLACE TO SET ADE INSTALLED FLAG TO TRUE....FOR APPLICATIONS TO USE...
			//element.innerHTML = "<hr/>Adobe Digital Editions SWF Version:<br/><br/>" + G_strSWFVersion;
			// kick in the pants to be sure to display
			//element.style.display = "block";
		}
	}
	return;
}	
//Button Pushed...- Lets hide the div layer...
function ADE_SWF_ButtonPush_action() {
	var obj = document.getElementById('ADE_DetectAndInstallDiv');
	if (typeof(obj.style)!="undefined"){
		obj.style.visibility = "hidden";	
	}
	return;
}
