#namespace eval Icons {
#	image create photo closed -file closed.gif

#}

namespace eval Rent {

	variable posy
	variable cnv
	variable cpath
	variable maxy
	variable ibg 
	variable ibgw
	variable ibgh
	variable tabs

	proc create {w current_path bg} {
		variable posy 0
		variable cnv 
		variable index 0
		variable maxy 0
	variable ibg 
	variable ibgw
	variable ibgh
		
			frame $w.left
			canvas $w.left.title -bg black -height 18 
			title $w.left.title  {Num owner x x x title place} {10 50 140 150 160 190 340}
			pack $w.left.title -fill both -expand no
			canvas $w.left.cent -bg white -yscrollcommand "$w.sb set" -yscrollincrement 16 -width 380
			pack $w.left.cent  -expand yes -fill both
			
			scrollbar $w.sb -command "$w.left.cent yview" 
			pack $w.sb -side right -fill y -expand no
			
			pack $w.left -side left -fill both -expand yes

			bind $w.left.cent <Button-4> "$w.left.cent yview scroll -2 units"
			bind $w.left.cent <Button-5> "$w.left.cent yview scroll 2 units"
				
			set cnv $w.left.cent
			set cpath ${current_path}/images
			#image create photo ibg -file ${cpath}/$bg
			set ibg $bg
			set ibgw [ image width $ibg]
			set ibgh [ image height $ibg]
			add_bg 
			add_bg 
			add_bg 
	}
	
	proc add_bg {} {
		
		variable cnv 
		variable ibg 
		variable ibgw
		variable ibgh
		variable maxy
	$cnv create image 0 $maxy -anchor nw -image $ibg
	$cnv create image $ibgw $maxy -anchor nw -image $ibg
	$cnv create image [expr $ibgw * 2] $maxy -anchor nw -image $ibg
	incr maxy $ibgh	
			
	}


	proc title {w l t} {
		variable tabs
		set tabs $t
		pack $w -side top -fill x 
			$w create rectangle 0 0 400 16 -fill black 
		for {set i 0} { $i < [llength $tabs] } {incr i} {
			$w create text  [lindex $tabs $i] 4  -anchor nw -text [lindex $l $i] -fill white
		}
	}
		



	proc add {l} {
		variable posy 
		variable maxy 
		variable cnv 
		variable tabs
		
		for {set i 0} { $i < [llength $tabs] } {incr i} {
			$cnv create text [lindex $tabs $i] $posy -anchor nw -text [lindex $l $i]
			}
		set base [expr $posy - 2]
			set bottom [expr $posy + 14]
			set id [$cnv create polygon 0  $base  400 $base 400 $bottom 0 $bottom -outline white -activeoutline gray -fill ""]
			$cnv bind $id <Button-1>  "ruby {show_game([lindex $l 0])}"
			
			incr posy 16
			if { $posy > $maxy } add_bg

	}


	proc refresh {} {
		variable cnv 
		variable posy
			$cnv configure -scrollregion "0 0 0 $posy"
	}

}


