I have a mobile.js file for detecting mobile devices. The code is

function detect_size()
{
if(screen.width<=650)
{
window.location="http://what-do-christians-believe.co.uk/mob_phone";
exit();
}
if(screen.width<=995)
{
window.location="http://what-do-christians-believe.co.uk/mob_devices";
exit();
}
if(screen.width>=996)
{
window.location="http://what-do-christians-believe.co.uk/book.html";
exit();
}

and I have the folllowing link in my html file to link to this file;
<script src="mobiles.js" type="text/javascript"></script>

Either the link isn't working or I have set up the js file wrongly. Can someone show me what needs to be done to get them working.

I have the javascript code in my html file and it works. It's just that a search engine reply to a download issue advised me to create a seperate file for the javascript as it will speed up the performance of my site.