#!/mod/bin/jimsh

source /mod/webif/lib/setup
require system.class settings.class plugin

set settings [settings]

set menuwrap 4

proc menuitem {title icon link {width 217} {height 0} {extra ""}} {{num 0}} {
	global menuwrap
	if {$title eq "-reset"} {
		set num 0
		return
	}
	if {$title eq ""} return
#	incr num
#	if {$num > $menuwrap} {
#		puts {</div><div style="clear: both; padding-top: 1em">}
#		set num 1
#	}
	if {$extra ne ""} { append extra " " }
	puts -nonewline "
<div class=left num=$num>
	<center>
	<a href=$link>
		<img class=mmenu src=$icon ${extra}border=0 "
	if {$width} { puts -nonewline " width=$width" }
	if {$height} { puts -nonewline " height=$height" }
	puts -nonewline ">
	</a>
	<br>
	<a href=$link>
	<b>$title</b>
	</a>
	<br>
	</center>
</div>
"
}

puts {<div style="clear: both">}

menuitem "Browse Media Files" "/images/323_1_10_Menu_Video.png" \
	/go/mm_browse
menuitem "Scheduled Events" "/img/Menu_CHList.png" \
	/go/mm_schedule
menuitem "EPG" "/images/328_1_26_Menu_TV_Guide.png" \
	/go/mm_epg 217 228

if {[file exists "/mod/bin/ir"]} {
	menuitem "Remote" "/img/remote.png" /plugin/ir/remote.jim 217 228
}

if {[$settings nomobile] eq "0"} {
	menuitem "Mobile Version" "/img/mobile.png" /go/mm_mobile 217 228
}

menuitem "Service Management" "/img/spanner.png" \
	/go/mm_service 217 228
menuitem "Package Management" "/img/packages.png" \
	/go/mm_pkg 217 228
menuitem "Settings" "/images/326_1_00_Menu_Settings.png" \
	/go/mm_settings 217 228

menuitem "Diagnostics" "/img/diagnostics.png" \
	/go/mm_diag 217 228

if {[[settings] toolbarqueue]} {
	menuitem "Queue" "/img/queuep.png" \
	    "/go/mm_queue" 217 228
}

eval_plugins menu

puts {</div>}

