var buf1 = new Array();
var buf2 = new Array();
var buf3 = new Array();

function rfBuf(pcode, code, name) {
	this.pcode = pcode;
	this.code = code;
	this.name = name;
}

function setb1(selected) {
	var p = GetObj("ss");
	if (! p) return;
	_setb1(selected, p.options[p.selectedIndex].value);
}
function _setb1(selected, pcode) {
	var o = GetObj("b1");
	if (! o) return;

	o.length = 0;
	o.length++;
	o.options[0].value = '';
	o.options[0].text = '';

	var ix = 0;
	for (var i = 0; i < buf1.length; i++) {
		if (pcode == buf1[i].pcode) {
			ix++;
			o.length++;
			o.options[ix].value = buf1[i].code;
			o.options[ix].text = buf1[i].name;
			if (selected == buf1[i].code ) {
				o.selectedIndex = ix;
			}
		}
	}
	setb2();
}

function setb2(selected) {
	var p = GetObj("b1");
	if (! p) return;
	_setb2(selected, p.options[p.selectedIndex].value);
}
function _setb2(selected, pcode) {
	var o = GetObj("b2");
	if (! o) return;

	o.length = 0;
	o.length++;
	o.options[0].value = '';
	o.options[0].text = '';

	var ix = 0;
	for (var i = 0; i < buf2.length; i++) {
		if (pcode == buf2[i].pcode) {
			ix++;
			o.length++;
			o.options[ix].value = buf2[i].code;
			o.options[ix].text = buf2[i].name;
			if (selected == buf2[i].code ) {
				o.selectedIndex = ix;
			}
		}
	}
	setb3();
}

function setb3(selected) {
	var p = GetObj("b2");
	if (! p) return;
	_setb3(selected, p.options[p.selectedIndex].value);
}
function _setb3(selected, pcode) {
	var o = GetObj("b3");
	if (! o) return;

	o.length = 0;
	o.length++;
	o.options[0].value = '';
	o.options[0].text = '';

	var ix = 0;
	for (var i = 0; i < buf3.length; i++) {
		if (pcode == buf3[i].pcode) {
			ix++;
			o.length++;
			o.options[ix].value = buf3[i].code;
			o.options[ix].text = buf3[i].name;
			if (selected == buf3[i].code ) {
				o.selectedIndex = ix;
			}
		}
	}
}

function openArtist(dir) {
	var wp = 'width=780,height=645,resizable=yes,scrollbars=yes';

	var popup = window.open(dir + '/app/collection/artists', 'artists', wp);
	popup.focus();
}

function selectArtist(v) {
	if (opener) {
		var sk = eval('opener.document.form1.sk');
		if (sk) sk.value = v;
	}
	window.close();
}