var DEloaded = false;
var initDEFailed =false;
var forceInfoObj;

function initDE(){
//load DE and hide it
	var params = {menu:"false"};
	params.wmode = "transparent";
	params.allowscriptaccess = "sameDomain";
	if (typeof(skinFolder)!= "undefined" ){
		swfobject.embedSWF(skinFolder+"downloadElement.swf", "downloadElement", "406", "406", "9.0.0", "expressInstall.swf", sessionVars, params, {});
	} else {
		swfobject.embedSWF("downloadElement.swf", "downloadElement", "406", "406", "9.0.0", "expressInstall.swf", sessionVars, params, {});
	}
	swfobject.createCSS("#downloadElement","outline:none");
	//debug("DE embedded");	
}

function DEFirstLoad(){
	if (!DEloaded){
		debug("stepInit DE");
		document.getElementById("downloadElement").className = "f-hide";
		document.getElementById("DEContainer").className = "f-hide";
	}
	
	DEloaded = true;
}

function showDownloadElement(infoObj){
	infoObj.s = sessionVars.s; //put session info into the infoObj
	if (!DEloaded){ return; }
	debug(infoObj.fileName/*+" "+SWFsArray[infoObj.fileName]+" "+SWFsArray[infoObj.fileName].divName*/);
	var SWFtop = (document.getElementById(SWFsArray[infoObj.fileName].divName).style.top);
	attPopupOpen=1; //To fix multiple DE openings.
	managePopup(hideDE);
	//place SWF:
	SWFtop = Number(SWFtop.substring(0,SWFtop.length-2));
	document.getElementById("DEContainer").className = "generalDE"
	document.getElementById("DEContainer").style.top = SWFtop+Number(infoObj.Y)-406/2;
	document.getElementById("DEContainer").style.marginLeft = -(490+406/2)+Number(infoObj.X);
	var swf = document.getElementById("downloadElement");
	swf.className="";
		if (((document.getElementById("downloadElement").initDE == undefined)||(navigator.appName!="Microsoft Internet Explorer"))&&(navigator.vendor!="Google Inc.")&&(navigator.vendor!="Apple Computer, Inc.")){
			//browser detection - this is wrong!! something must be done!!
		forceInfoObj = infoObj;
		initDEFailed = true;
	} else {
		initDEFailed =false;
		swf.initDE(infoObj);
	}
	//"disable" is called from within the SWF by getURL.
}

function forceInitDE(){
	if (initDEFailed){
		if (document.getElementById("downloadElement").initDE == undefined){
			hideDE();
			return;
		}
		document.getElementById("downloadElement").initDE(forceInfoObj);
	}
}

function hideDE(){
	document.getElementById("downloadElement").className = "f-hide";
	document.getElementById("DEContainer").className = "f-hide";
	if (currPopupClearFunc == hideDE){
	//remove trans blocker:
	enable();
	currPopup = null;	
	}
	attPopupOpen--;
}