Separated Detection Functionality

Pulled the detection functions away from the js that ran it and
manipulated the demo page