// script controlling Stakeholder Eligibility diagrams -  ric - 12/03
// -- start --

var boxes = [];
function initEligibleScript() {
	if (!window.print) return false;
	boxes[0] = document.getElementById("st_start");
	var divtags = document.getElementsByTagName("DIV");
	var startPos = { top:getObjXY("st_start").top, left:getObjXY("st_start").left }
	for (var i=0;i<divtags.length;i++) {
		if (divtags[i].className=="stakeholder_anchor") divtags[i].style.display = "none";
		if (divtags[i].id&&((divtags[i].id.indexOf("st_question")==0)||(divtags[i].id.indexOf("st_end")==0))) {
			divtags[i].style.position = "absolute";
			divtags[i].style.top = startPos.top+"px";
			divtags[i].style.left = startPos.left+"px";
			divtags[i].style.display = "none";
			boxes[boxes.length] = divtags[i];
		}
	}
}

function getObjXY(el) {
	if (typeof(el)=="string") el = document.getElementById(el);
	var pos = { top:el.offsetTop, left:el.offsetLeft };
	while (el.offsetParent) {
		el = el.offsetParent;
		pos.top += el.offsetTop;
		pos.left += el.offsetLeft;
	}
	return pos;
}

function showBox(b,url) {
	if (!window.print) { window.location = url; return true; }
	var idStr = "st_"+(b<50?"question"+b:b<100?"end"+b%50:"question"+b%100+"info");
	var targetBox = document.getElementById(idStr);
	if (targetBox=="null") return false;
	for (var i=0;i<boxes.length;i++) { 
		if (boxes[i].id=="st_start") boxes[i].style.visibility = "hidden"; else boxes[i].style.display = "none";
	}
	targetBox.style.display = "block";
}

// -- end --

function openPopupWindow(url,width,height,name) {
	window.open(url,name,"width="+width+",height="+height+",directories=no,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no");
	// this returns false so that the href is not processed in the original <a> tag.
	return false;
}

function openABICalc(url) {
	window.open(url,'ABICalculator',"width=800,height=575,directories=no,location=no,menubar=no,resizable=no,scrollbars=yes,status=no,toolbar=no");
	// this returns false so that the href is not processed in the original <a> tag.
	return false;
}