Changes of structure and bonding with thickness in chalcogenide thin films