use zUtil;


sub filmcanHandler
{
   $html = shift;
   my( @rValue ) = ();
   my( $count, $row, $movie, $movieLink, $rating, $starsImage, $times );
   my( $done, $textStar, $initial );

   #print "=------------------ filmcanHandler --------------------=\n";
   #print "html: $html\n";

   $count = 7;
   my $table = zUtil::getNthItem( $count, $html, "<table", "</table>" );

   # 6 is the whole first movie ..
   # and increment the row count by three for each subsequent movie.
   $count++;
   while( $count < 74 )
   {
       $row = zUtil::getNthItem( $count, $table, "<tr>", "</tr>" );

#print "row: $row\n";

       $movieLink = zUtil::getNthItem( 1, $row, "<a", "</a>" );
       $rating = zUtil::getNthItem( 2, $row, "<a", "</a>" );
       $stars = zUtil::getNthItem( 3, $row, "<a", "</a>" ); 
       $times = zUtil::getNthItem( 4, $row, "<td", "</td>" ); 

         if( $movieLink =~ /<A HREF=\"(.*?)\">(.*?)<\/A>/i )
         {
	      $movie = $2;
	     $movieLink = $1;
         }
         if( $rating =~ /<A HREF=\"(.*?)\">(.*?)</i )
         {
	     $rating = $2;
         }
         if( $stars =~ /<IMG.*?SRC=\".*\/(.*?)\"/i )
         {
	         $stars = "images/" . $1;
            if( $stars =~ /star1/gsi )
            {
               $textStar = "1";
            }
            if( $stars =~ /star2/gsi )
            {
               $textStar = "2";
            }
            if( $stars =~ /star3/gsi )
            {
               $textStar = "3";
            }
            if( $stars =~ /star4/gsi )
            { 
               $textStar = "4";
            }
            if( $stars =~ /star5/gsi )
            {
               $textStar = "5";
            }
         }
         if( $times =~ /<TD.*?><FONT.*?>\s*?(.*?)\s*?<\/TD>/i )
         {
	     $times = $1;
         }

        # print "Movie: $movie\n";
        # print "\tLink: $movieLink\n";
        # print "\trating: $rating\n";
        # print "\tstars: $stars\n";
      # print "\ttimes: $times\n\n";
 
        if( !($movieLink =~ /^$/ ) )
        {
           push @rValue,
           {
	           'movie' => $movie,
	           'movieLink' => $movieLink,
	           'rating' => $rating,
	           'stars' => $stars,
	           'times' => $times,
              'tstars' => $textStar 
           };
         }

       $count = $count + 3;
     }



   return @rValue;
}

return 1;

