window.onerror = function(){ return true; }

var d = document, xFlaQueue = new Array(), xFlaComStatus = 0, undefined, xFlaComListener = new Array(), xIEMac = (d.all && !window.opera && navigator.userAgent.toLowerCase().indexOf('mac')+1), flaIntV = (xIEMac)? 300:100;
var scpts = ('script', d);
var slen = scpts.length, xFlaComPath = 'http://msnbcmedia.msn.com/i/msnbc/Components/Blogs/RisingFromRuin/stages/'; // path to xFlaCom.swf (sans filename) must match target swf domain

	function xFlaCom(e, query){
xFlaQueue[xFlaQueue.length] = [arguments[0], arguments[1]];
if(!xFlaComListener[1]) xFlaComListener[0] = setInterval("xFlaProcess()", flaIntV), xFlaComListener[1] = 1;
	}

	function xFlaProcess() {
var len = xFlaQueue.length;
// not busy and queued item: send
if(!xFlaComStatus && len > 0) { xFlaComStatus = 1; xFlaDeliver(); }
// not busy and no items
else if(!xFlaComStatus && !len) { clearInterval(xFlaComListener[0]), xFlaComListener[1]=undefined; }
	}

	function xFlaDeliver(){
xFlaComStatus = 1; 
var e = xFlaQueue[0][0], query = xFlaQueue[0][1];
var el = d.getElementById(e), ix, flashquery;
xFlaQueue = xFlaQueue.slice(1);
// handle errors
self.onerror = function(errMsg) {
// gecko flash-plugin bug workaround
if(errMsg.search(/SetVariable is not a function/i) != -1) { return true;
//} else { return false; }
} else { return true; }
	}

var GeckoPass = (navigator.userAgent.toLowerCase().indexOf('gecko')+1 && d[e].SetVariable)? 1:0;
	if((d.all && !window.opera && !xIEMac) || GeckoPass){
var chunk = query.split("&");
for(ix in chunk){ flashquery = chunk[ix].split("="); d[e].SetVariable(flashquery[0],flashquery[1]); }
	} else { doFlaIntermed() }

	function doFlaIntermed() {
		if(!d.getElementsByTagName('embed', el).length && el.nodeName.toLowerCase() != 'embed') {
var elembed = d.createElement("div");
elembed.id = e;
elembed.style.display = 'inline';
// assume we have object & params with needed attributes
var attrlen = el.attributes.length, paramslen = el.childNodes.length, elattr = '';

for(var i = 0; i < attrlen; i++){ if(el.attributes[i].value != '') elattr += el.attributes[i].name + '="' + el.attributes[i].value + '" '; }
for(var i = 0; i < paramslen; i++){ if(el.childNodes[i].nodeName.toLowerCase() == 'param' && el.childNodes[i].value != '') {
	elattr += (el.childNodes[i].name == 'movie')? ' src':' '+el.childNodes[i].name;
	elattr += '="' + el.childNodes[i].value + '" ';
} }
elembed.innerHTML = '<embed '+elattr+'></embed>';
d.body.replaceChild(elembed, el);
el = d.getElementById(e);
		}

var flashId = "flash_setvariables_"+e;
var flashDiv = d.getElementById(flashId);
	if(!flashDiv){
flashDiv = d.createElement("div");
flashDiv.id = flashId;
d.body.appendChild(flashDiv);
	}
flashDiv.innerHTML =  "";
var divcontent = '<embed allowScriptAccess="always" src="'+xFlaComPath+'xFlaCom.swf?a=0&" FlashVars="lc='+e+'&fq='+escape(query)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';
flashDiv.innerHTML = divcontent;
xFlaComStatus = 0;
return true;
}
xFlaComStatus = 0;
}

///// page-specific fn /////
RFR = {misc: [],
ids: [
"nav-stories",
"nav-journals",
"nav-tour",
"nav-about"

]
	};

function addLV(fn) { var olv = window.onload;
if (typeof window.onload != 'function') { window.onload = fn;
} else { window.onload = function() { olv(); fn(); }
} }
addLV(function(){ mkswfroll(); });

function mkswfroll(){
if(!d.getElementById && !d.getElementsByTagName) return;
var len = RFR.ids.length;
	for(var i = 0; i<len;i++){
var p = d.getElementById(RFR.ids[i]);
var ro = (p)? p.getElementsByTagName('a')[0]:false;
	if(ro) {
	ro.id = p.id + 'a1';
	ro.no = i;
	ro.onmouseover = function(){ toPano(this.no); };
	RFR.ids[i] = ro.id;
		}
	}
RFR.activateTab = RFR.activateTabLive;
}

        RFR.activateTabLive = function(no){
var d = document;
if(!d.getElementById || !d.createElement) return;
if(!RFR.activeTab) RFR.activeTab = d.getElementById(RFR.ids[0]);
var el = d.getElementById(RFR.ids[no]);
if(!el) return;
el.no = no;
RFR.activeTab.className = '';
RFR.activeTab = el;
el.className = 'activeTab';
        } // end activateTab

function toPano(no){
if(( !RFR.activeTab && no == 0) || (RFR.activeTab && RFR.activeTab.no == no) || (RFR.activeTab && typeof RFR.activeTab.no != 'number')) return; // skip if already active
xFlaCom('RFRpano', 'mcWatcher:jsEvent= '+no);
}

