Suche dir doch einfach mal Zeile 25 heraus und schreibe für diesen Block noch ein endif ans Ende. Das könnte das Problem schon lösen.