var otsSidePromo = false;
var otsSideCases = false;
var otsSideTesti = false;
function otsSide_init(siteID, cLen, pHint, sHint, sPromo, sCases, sTesti) {
	otsSidePromo = false;
	otsSideCases = false;
	otsSideTesti = false;
	sPromo = true;
	var avail = (sPromo != true ? 1 : 0) + (sCases != true ? 1 : 0) + (sTesti != true ? 1 : 0);
	var want = cLen == 'Short' ? 1 : (cLen == 'Long' ? 3 : 2);
	if(avail <= want) {
		if(sPromo != true) otsSidePromo = true;
		if(sCases != true) otsSideCases = true;
		if(sTesti != true) otsSideTesti = true;
	}
	else if(want == 2) { // avail == 3
		var v = Math.random();
		if(v < 0.5) otsSidePromo = true;
		else otsSideCases = true;
		otsSideTesti = true;
	}
	else if(avail == 3) { // want == 1
		var v = Math.random();
		if(v < 0.3333) otsSidePromo = true;
		else if(v < 0.6667) otsSideCases = true;
		else otsSideTesti = true;
	}
	else { // avail == 2, want == 1
		var v = Math.random();
		if(v < 0.5) {
			if(sPromo != true) otsSidePromo = true;
			else otsSideCases = true;
		}
		else {
			if(sTesti != true) otsSideTesti = true;
			else otsSideCases = true;
		}
	}
}
function otsSide_getPromoRef() {
	if(!otsSidePromo) return null;
	var i = Math.floor(Math.random()*1);
	var s = '/promo_content/promo/'+i+'.html';
	return s;
}
function otsSide_getCasesRef() {
	if(!otsSideCases) return null;
	var i = Math.floor(Math.random()*5);
	var s = '/promo_content/cases/'+i+'.html';
	return s;
}
function otsSide_getTestiRef() {
	if(!otsSideTesti) return null;
	var i = Math.floor(Math.random()*10);
	var s = '/promo_content/testi/'+i+'.html';
	return s;
}
var otsSideDid = [0,0,0];
var otsSideDone = [0,0,0];
var otsSideReady = 0;
var otsSideCallback = null;
function otsSide_callbackInit(callback)
{
	otsSideCallback = callback;
	otsSideDid = [0,0,0];
	otsSideDone = [0,0,0];
	otsSideReady = 0;
}
function otsSide_callbackSet(index)
{
	otsSideDid[index] = 1;
}
function otsSide_callbackReady()
{
	otsSideReady = 1;
}
function otsSide_callback(status, data) {
	otsSideDone[data] = 1;
	if(otsSideReady) {
		var i = 0;
		while(i < 3) {
			if(otsSideDid[i] && !otsSideDone[i]) return;
			i++;
		}
		otsSideCallback();
	}
}
