Electronic structure and magnetic properties of Co doped TiO2 thin films using X-ray absorption spectroscopy