// Flash interfaces to javascript
var uid = new Date().getTime();
var flashProxy = new FlashProxy(uid, '/flash/JavaScriptFlashGateway.swf');
var ourInterval;

var closeID = 0;
var flashReturned = true;
var store_targetArea;
var store_targetPassThrough;
var store_targetType;

var uidClose = uid+1;

function closeHTMLPopUp(){
	unloadIframe();
	closeID++;
	flashReturned = false;
	flashProxy.call('closeHTMLPopUp', closeID);
	ourInterval = setInterval("checkClosed()", 1000);
	store_targetArea = "";
	store_targetPassThrough = "";
	store_targetType = "";
}

function jumpToHTML(targetArea, targetPassThrough, targetType){
    // PJH - Dont refresh if trying to link to same area!
    // Unless product selector....
    if (targetArea == store_targetArea && targetArea != "rooms||kitchen||FelixFood") return;     
	unloadIframe();
	closeID++;
	flashReturned = false;
	store_targetArea = targetArea;
	store_targetPassThrough = targetPassThrough;
	store_targetType = targetType;
	flashProxy.call('changeLocationHTML', targetArea, targetPassThrough, targetType, closeID);
	ourInterval = setInterval("checkJumped()", 1000);
}

function checkClosed(){
	if (flashReturned){
		clearInterval(ourInterval);
		//alert("Done");
	} else {
		flashProxy.call('closeHTMLPopUp', closeID);
		//alert("Check Again");
	}
}
function checkJumped(){
	if (flashReturned){
		clearInterval(ourInterval);
		//alert("Done");
	} else {
		flashProxy.call('changeLocationHTML', store_targetArea, store_targetPassThrough, store_targetType, closeID);
		//alert("Check Again");
	}
}
function closeReceived(returnID){
	if (returnID == closeID){
		flashReturned = true;
	}
}