#!/usr/bin/env bash

# Read in language
source ${BBROOTDIR}/lang/${BBLANG}/data_menu.lang

# Read in functions
source ${BBROOTDIR}/misc/commonfunctions.sh
source ${BBROOTDIR}/func/datafunc.sh


#####PROGRAM START#####
while true; do
# This is for the numbering of the menu choices. It is
# updated once before each entry printout in the menu
# except exit which should always be 0. The variable must
# be reset within this while loop or bad things will happen.
(( bb_m_c = 0 ))
# <colors>
#source "$BBROOTDIR"/misc/colors.idx
# </colors>
clear
# <table>
echo -e "${BBTABLECOLOR}${BBDECOLINE}"
echo -e "${BBTABLECOLOR}|${BBHEADCOLOR} ${BBVERSION} ${BBTABLECOLOR}|"
echo -e "${BBTABLECOLOR}${BBDECOLINE}"
echo -e "${BBTABLECOLOR}|"
echo -e "${BBTABLECOLOR}|-(${BBSUBCOLOR}$bb_dm_menu_title${BBTABLECOLOR})"
(( bb_m_c += 1 ))
echo -e "${BBTABLECOLOR}|${BBMAINCOLOR} $bb_m_c) $bb_dm_menu_1"
(( bb_m_c += 1 ))
echo -e "${BBTABLECOLOR}|${BBMAINCOLOR} $bb_m_c) $bb_dm_menu_2"
(( bb_m_c += 1 ))
echo -e "${BBTABLECOLOR}|${BBMAINCOLOR} $bb_m_c) $bb_dm_menu_3"
(( bb_m_c += 1 ))
echo -e "${BBTABLECOLOR}|${BBMAINCOLOR} $bb_m_c) $bb_dm_menu_4"
(( bb_m_c += 1 ))
echo -e "${BBTABLECOLOR}|${BBMAINCOLOR} $bb_m_c) $bb_dm_menu_5"
echo -e "${BBTABLECOLOR}|${BBMAINCOLOR} 0) $bb_dm_menu_0"
echo -e "${BBTABLECOLOR}|"
echo -n -e "${BBINPUTCOLOR}$bb_dm_menu_entry[0-$bb_m_c] |>${BBMAINCOLOR} "
read action
echo -e "${BBCOLOROFF}"
# </table>

case $action in  
	1)      # Burn data
		${BBROOTDIR}/burning/burning.sh --data
		;;
	2)	# Copy data cd
		copy_data_cd
		;;
	3)      # Burn data DVD
		${BBROOTDIR}/burning/burning.sh --dvddata
		;;
	4)	# Blank CDRW
		check_cd_status
                if [ ${BB_CDSTATUS} == "BLANK" ]; then
                        echo $bb_cdrw_blank6
                        wait_for_enter
                else
                        blank_cd
                fi
                continue
                ;;
	5)	# Blank DVD
		${BBROOTDIR}/burning/burning.sh --dvdblank
		;;
	0)	# Quit
		break     
		;;
	*)      # Bad choice
		echo "$bb_dm_error[0-$bb_m_c]"
		wait_for_enter
		continue
		;;
esac
done

