// function draws 9 buttons in the referenced image
int menuebuttons(gdImagePtr *im,char *s1, char *s2, char *s3, 
             char *s4, char *s5, char *s6,
	     char *s7, char *s8, char *s9,
	     int active)
{
  int x1mitte,x2mitte,y1mitte,y2mitte;
  int mitteproz=15;
  int xoff=5; // xoffset
  int yoff=5; // yoffset
  int buttonx1,buttonx2,buttony1,buttony2;
  int bgcolor;
  int bordercolor;
  int textcolor;
  char *s;
  int buttonwidth;
  int buttonheight;
  gdFontPtr myfont; 


  if (ScreenWidth==480)
    myfont=gdFontGetGiant();
  else
    myfont=gdFontGetLarge();

  x1mitte=ScreenWidth/2-(ScreenWidth*mitteproz)/100;  // bei 480x272:168 sonst (360x240) 126
  y1mitte=ScreenHeight/2-(ScreenHeight*mitteproz)/100;  // bei 480x272: 92 sonst (360x240) 84
  x2mitte=ScreenWidth/2+(ScreenWidth*mitteproz)/100;  // bei 480x272:312 sonst (360x240) 236
  y2mitte=ScreenHeight/2+(ScreenHeight*mitteproz)/100;  // bei 480x272:176 sonst (360x240) 156

  bgcolor=gdTrueColorAlpha(90,90,140,64); 
  bordercolor=gdTrueColorAlpha(60,60,120,64); 
  textcolor=gdTrueColorAlpha(0,0,0, 0);


  // left button in the upper row
  s=s1;
  buttonx1 = 0+xoff      ; buttony1 = 0+yoff; 
  buttonx2 =x1mitte-xoff ; buttony2=y1mitte-yoff;
  buttonwidth=buttonx2-buttonx1;
  buttonheight=buttony2-buttony1;
  gdImageFilledRectangle(*im, buttonx1, buttony1, buttonx2, buttony2, bgcolor);
  if (active==1)
    gdImageFilledRectangle(*im, buttonx1, buttony1, buttonx2, buttony2, bgcolor);
  gdImageRectangle(*im, buttonx1, buttony1, buttonx2, buttony2, bordercolor);
  gdImageString(*im, myfont,
                buttonx1 + (buttonwidth/2-strlen(s)*myfont->w/2), 
		buttony1 + (buttonheight/2-myfont->h/2) + yoff,
		s,textcolor);

  // middle button in the upper row 
  s=s2;
  buttonx1 = x1mitte+xoff ; buttony1 = 0+yoff; 
  buttonx2 = x2mitte-xoff ; buttony2 = y1mitte-yoff;
  buttonwidth=buttonx2-buttonx1;
  buttonheight=buttony2-buttony1;
  gdImageFilledRectangle(*im, buttonx1, buttony1, buttonx2, buttony2, bgcolor);
  if (active==2)
    gdImageFilledRectangle(*im, buttonx1, buttony1, buttonx2, buttony2, bgcolor);
  gdImageRectangle(*im, buttonx1, buttony1, buttonx2, buttony2, bordercolor);
  gdImageString(*im, myfont, 
                buttonx1 + (buttonwidth/2-strlen(s)*myfont->w/2), 
		buttony1 + (buttonheight/2-myfont->h/2) + yoff,
		s,textcolor);
  // right button in the upper row 
  s=s3;
  buttonx1 = x2mitte+xoff ; buttony1 = 0+yoff; 
  buttonx2 = ScreenWidth-xoff ; buttony2 = y1mitte-yoff;
  buttonwidth=buttonx2-buttonx1;
  buttonheight=buttony2-buttony1;
  gdImageFilledRectangle(*im, buttonx1, buttony1, buttonx2, buttony2, bgcolor);
  gdImageRectangle(*im, buttonx1, buttony1, buttonx2, buttony2, bordercolor);
  if (active==3)
    gdImageFilledRectangle(*im, buttonx1, buttony1, buttonx2, buttony2, bgcolor);
  gdImageString(*im, myfont, 
                buttonx1 + (buttonwidth/2-strlen(s)*myfont->w/2), 
		buttony1 + (buttonheight/2-myfont->h/2) + yoff,
		s,textcolor);
  // left button in the middle row 
  s=s4;
  buttonx1 = 0+xoff       ; buttony1 = y1mitte+yoff; 
  buttonx2 = x1mitte-xoff ; buttony2 = y2mitte-yoff;
  buttonwidth=buttonx2-buttonx1;
  buttonheight=buttony2-buttony1;
  gdImageFilledRectangle(*im, buttonx1, buttony1, buttonx2, buttony2, bgcolor);
  if (active==4)
    gdImageFilledRectangle(*im, buttonx1, buttony1, buttonx2, buttony2, bgcolor);
  gdImageRectangle(*im, buttonx1, buttony1, buttonx2, buttony2, bordercolor);
  gdImageString(*im, myfont, 
                buttonx1 + (buttonwidth/2-strlen(s)*myfont->w/2), 
		buttony1 + (buttonheight/2-myfont->h/2) , // yoff nicht hinzuaddiert!
		s,textcolor);
  // middle button in the middle row (center button)
  s=s5;
  buttonx1 = x1mitte+xoff ; buttony1 = y1mitte+yoff; 
  buttonx2 = x2mitte-xoff ; buttony2 = y2mitte-yoff;
  buttonwidth=buttonx2-buttonx1;
  buttonheight=buttony2-buttony1;
  gdImageFilledRectangle(*im, buttonx1, buttony1, buttonx2, buttony2, bgcolor);
  if (active==5)
    gdImageFilledRectangle(*im, buttonx1, buttony1, buttonx2, buttony2, bgcolor);
  gdImageRectangle(*im, buttonx1, buttony1, buttonx2, buttony2, bordercolor);
  gdImageString(*im, myfont, 
                buttonx1 + (buttonwidth/2-strlen(s)*myfont->w/2), 
		buttony1 + (buttonheight/2-myfont->h/2) , // yoff nicht hinzuaddiert!
		s,textcolor);
  // right button in the middle row
  s=s6;
  buttonx1 = x2mitte+xoff ; buttony1 = y1mitte+yoff; 
  buttonx2 = ScreenWidth-xoff     ; buttony2 = y2mitte-yoff;
  buttonwidth=buttonx2-buttonx1;
  buttonheight=buttony2-buttony1;
  gdImageFilledRectangle(*im, buttonx1, buttony1, buttonx2, buttony2, bgcolor);
  if (active==6)
    gdImageFilledRectangle(*im, buttonx1, buttony1, buttonx2, buttony2, bgcolor);
  gdImageRectangle(*im, buttonx1, buttony1, buttonx2, buttony2, bordercolor);
  gdImageString(*im, myfont, 
                buttonx1 + (buttonwidth/2-strlen(s)*myfont->w/2), 
		buttony1 + (buttonheight/2-myfont->h/2) , // yoff nicht hinzuaddiert!
		s,textcolor);
  // left button in the lower row
  s=s7;
  buttonx1 = 0+xoff       ; buttony1 = y2mitte+yoff; 
  buttonx2 = x1mitte-xoff ; buttony2 = ScreenHeight-yoff;
  buttonwidth=buttonx2-buttonx1;
  buttonheight=buttony2-buttony1;
  gdImageFilledRectangle(*im, buttonx1, buttony1, buttonx2, buttony2, bgcolor);
  if (active==7)
    gdImageFilledRectangle(*im, buttonx1, buttony1, buttonx2, buttony2, bgcolor);
  gdImageRectangle(*im, buttonx1, buttony1, buttonx2, buttony2, bordercolor);
  gdImageString(*im, myfont, 
                buttonx1 + (buttonwidth/2-strlen(s)*myfont->w/2), 
		buttony1 + (buttonheight/2-myfont->h/2) + yoff,
		s,textcolor);
  // middle button in the lower row
  s=s8;
  buttonx1 = x1mitte+xoff ; buttony1 = y2mitte+yoff; 
  buttonx2 = x2mitte-xoff ; buttony2 = ScreenHeight-yoff;
  buttonwidth=buttonx2-buttonx1;
  buttonheight=buttony2-buttony1;
  gdImageFilledRectangle(*im, buttonx1, buttony1, buttonx2, buttony2, bgcolor);
  if (active==8)
    gdImageFilledRectangle(*im, buttonx1, buttony1, buttonx2, buttony2, bgcolor);
  gdImageRectangle(*im, buttonx1, buttony1, buttonx2, buttony2, bordercolor);
  gdImageString(*im, myfont, 
                buttonx1 + (buttonwidth/2-strlen(s)*myfont->w/2), 
		buttony1 + (buttonheight/2-myfont->h/2) + yoff,
		s,textcolor);
  // right button in the lower row
  s=s9;
  buttonx1 = x2mitte+xoff ; buttony1 = y2mitte+yoff; 
  buttonx2 = ScreenWidth-xoff ; buttony2 = ScreenHeight-yoff;
  buttonwidth=buttonx2-buttonx1;
  buttonheight=buttony2-buttony1;
  gdImageFilledRectangle(*im, buttonx1, buttony1, buttonx2, buttony2, bgcolor);
  if (active==9)
    gdImageFilledRectangle(*im, buttonx1, buttony1, buttonx2, buttony2, bgcolor);
  gdImageRectangle(*im, buttonx1, buttony1, buttonx2, buttony2, bordercolor);
  gdImageString(*im, myfont, 
                buttonx1 + (buttonwidth/2-strlen(s)*myfont->w/2), 
		buttony1 + (buttonheight/2-myfont->h/2) + yoff,
		s,textcolor);
  return 0;
}

