#include <stdio.h>
#include <string.h>
#include "cgiutils.h"

char tohex(int i) 
{
  if (i >= 10) return('A'+i-10) ;
  else return ('0'+i) ;
}

main()
{
  int num ;
  char *rle_fname, *nregs_str, *reg_num_str ;

  decode_query_string("f", &rle_fname, "n", &nregs_str,
		      "num", &reg_num_str, NULL) ;

  num = atoi(reg_num_str) ;
  

  return_header("text/html") ;

  printf("<h1>Region %d</h1>\n", num) ;

  printf("<a href=\"javascript:void(0);\" onClick=\"window.location.replace('http://www.csdl.tamu.edu/FLORA/cgi/rle2_next?f=%s&n=%s&num=%d');return false;\">",
	 rle_fname, nregs_str, num+1) ;

  printf("<img src=\"/FLORA/cgi/rle_image?f=%s&n=%s&w=3&l=FF0000%c%c%c\"></a><p>\n",
	 rle_fname, nregs_str, 
	 tohex((int)((num-1)/256)), tohex((int)(((num-1)%256)/16)),
	 tohex((int)((num-1)%16))) ;


}
