﻿function deviceIsAn(aFamilyOfDevice) {
	var UA = navigator.userAgent.toLowerCase();
	var devices = {
		"appleDevice": /ip(hone|ad)/i,
		"androidDevice": /android/i,
		"symbianDevice": /symbian/i,
		"winphoneDevice": /iemobile/i,
		"blackberryDevice": /blackberry/i
	}
	return devices[aFamilyOfDevice].test(UA);
}

/*
if(deviceIsAn('appleDevice') || deviceIsAn('androidDevice') || deviceIsAn('symbianDevice') || deviceIsAn('winphoneDevice') || deviceIsAn('blackberryDevice')){
	window.document.location = '/_en/_gb/mobile/fusio-dose/index.aspx';
}*/

$(document).ready(function() {
	if(deviceIsAn('blackberryDevice')){		
		if(document.getElementById('registration') && document.getElementById('registerForm')){
			document.getElementById('intro').innerHTML = '';
			document.getElementById('main').innerHTML = '<p>Sorry, this application is not supported by your mobile device.<br/>You will be redirected to the homepage automatically.<br/>If this does not happen in the next 5 seconds, <a href="/_en/_gb/home/index.aspx">Click Here</a>.</p>';
			
			setTimeout(function(){
				window.document.location = '/_en/_gb/home/index.aspx';
			},5000);
		}
	
		box.bind({
			'addtodom.generic.popin.contact': function() {
				var closeMask = function() {
					box.ui('generic.pagemask').animate({opacity: 0}, 180, 'close');
				};
				
				if(document.getElementById('contactForm')){
					$('#contactForm').css('display','none');
					if(!document.getElementById('errorBB')){
						$('.popinCore').append('<p id="errorBB">Sorry, this application is not supported by your mobile device.<br/>You will be redirected to the "Questions and contacts" page automatically.<br/>If this does not happen in the next 5 seconds, <a href="/questions-and-contacts.aspx">Click Here</a>.</p>');
					}
					setTimeout(function(){
						ker.closePopin();
					},5000);
				}
			}
		});
	}
});
