jsArray = new Array();

function $(id) {
	return document.getElementById(id);
}

function toggleProductList() {
	usage 		= $('pinUsageGlobal');
	list 		= $('voucherProductList');
	globalPins 	= $('pinFieldsGlobal');
	if (usage.value == 'enterSeperate') {
		list.style.display = '';
		globalPins.style.display = 'none';
		for (identifier in jsArray) {
			$('pinUsageItem_' + identifier).disabled = false;
		}
	} else {
		globalPins.style.display = '';
		list.style.display = 'none';
		for (identifier in jsArray) {
			$('pinUsageItem_' + identifier).disabled = true;
		}
	}
	if (usage.disabled) {
		list.style.display = 'none';
		globalPins.style.display = 'none';
	}
}


function toggleVoucherList(identifier) {
	usage 		= $('pinUsageItem_' + identifier);
	list 		= $(identifier);
	pins 		= $('pinFieldsItem_' + identifier);
	if (usage.value == 'useForAll') {
		list.style.display = 'none';
		pins.style.display = '';		
	} else {
		list.style.display = '';
		pins.style.display = 'none';
	}
}

function initPinMask() {
	checked =  $('useVouchers').checked;
	if (checked) {
		$('pinUsageGlobal').disabled = !$('pinUsageGlobal').disabled;
		toggleProductList();
		for (identifier in jsArray) {
			if ($('pinUsageItem_' + identifier).value == 'enterSeperate') {
				toggleVoucherList(identifier);
			}
		}
	} 
}