defined function to switch background transpacency