Photodissociation and chemistry of N2 in the circumstellar envelope of carbon-rich AGB stars