function setUpDocSets(exec) {
    eval(exec);
}


function ShowData() {
	var datadir = _vars['dataDir'][0];
    var imageFile = _vars['imageFile'][0];
    var content = '<img src="' + datadir + "images/" + imageFile + '"/>'
    bpc.render(content, 'replacechildren', "id('image')");
}

function msgSupportsEditions(msg, maxSDKVers) {
	showUS = _vars['showUS'][0];
	showOE = _vars['showOE'][0];
	showCA = _vars['showCA'][0];
	showUK = _vars['showUK'][0];
	if (showUS && msg.minVerUS > 0 && msg.minVerUS <= maxSDKVers) {
    	return true;
	}
	if (showOE && msg.minVerOE > 0 && msg.minVerOE <= maxSDKVers) {
    	return true;
	}
	if (showCA && msg.minVerCA > 0 && msg.minVerCA <= maxSDKVers) {
    	return true;
	}
	if (showUK && msg.minVerUK > 0 && msg.minVerUK <= maxSDKVers) {
    	return true;
	}
	return false;
}      

function populateMsgSelector() {
	var maxVers = _vars['maxSDKVersion'][0];
	if (typeof(maxVers) == "undefined") {
		return;
	}
	var msgData;
	var toEval = '(' + _vars['messageData'][0] + ')';
	if (typeof(_vars['messageData'][0]) == "undefined") {
		return;
	}
	//alert("showUS = " + showUS + " showCA=" + showCA + " showUK=" + showUK + " showOE=" + showOE);
	var ex;
	try {
		msgData = eval(toEval);
	} catch(ex) {
		alert("Exception caught: " + ex);
	}
	var mode = 'replacechildren';
	for (i=0; i<msgData.messages.length; i++) {
		req = msgData.messages[i];
		if (msgSupportsEditions(req, maxVers)) {
			text = req.name;
			if (req.minVerText != "") {
	    		text += req.minVerText;
	    	}
	    	bpc.render('<b:option b:value="' + req.name + '">' + text + '</b:option>', mode, 'id("messageSelector")');
	    	mode = 'aslastchild';
		}
	}
	var haveSubscriptions = false;
	mode = 'replacechildren';
	if (msgData.subscriptions != null && msgData.subscriptions.length > 0) {
		for (i=0; i<msgData.subscriptions.length; i++) {
			req = msgData.subscriptions[i];
			if (msgSupportsEditions(req, maxVers)) {
				text = req.name;
				if (req.minVerText != "") {
					text += req.minVerText;
				}
				bpc.render('<b:option b:value="' + req.name + '">' + text + '</b:option>', mode, 'id("subscriptionSelector")');
				mode = 'aslastchild';
				haveSubscriptions = true;
	    	}
		}
	} 
	if (!haveSubscriptions) {
		bpc.task(['b:action','hide','b:target',"id('SubscriptionSelect')"], "id('topPanel')");
	} else {
		bpc.task(['b:action','show','b:target',"id('SubscriptionSelect')"], "id('topPanel')");
	}
} 

function showPossibleIncludeRetElements() {
	var RsData = _vars['RsDetailsJSON'][0];
	var RsDataJSON;
	if (RsData != "") {
		RsDataJSON = eval('(' + RsData + ')');
	}
	var possibleElems = "<p><b>Possible IncludeRetElement values: </b>" + renderPossibleRetElements(RsDataJSON) + "</p>\n";
	bpc.render('<div>\n' + possibleElems + '</div>\n', 'aslastchild', "id('detailstarget')");
}
