function isMobile() {		
	if( navigator.userAgent.match(/Android/i) || navigator.userAgent.match(/webOS/i) || navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/iOS/i)
		|| navigator.userAgent.match(/series60/i) || navigator.userAgent.match(/symbian/i) || navigator.userAgent.match(/windows ce/i) || navigator.userAgent.match(/blackberry/i)) {

		var override = new Cookie(document, 'mobile_override', 240, '/', window.location.hostname.replace('www\.', '').replace('mobile\.', ''));
		override.load();

		if (override.skip == 1) {
			return false;
		} else {
			return true;
		}
	} else {
		return false;
	}
}

function toMobile() {
	var override = new Cookie(document, 'mobile_override', 240, '/', window.location.hostname.replace('www\.', '').replace('mobile\.', ''));
	override.load();
	override.skip = 0;
	override.store();

	location.href = location.href.replace(window.location.hostname, 'mobile.' + window.location.hostname.replace('www.', ''));
}

if (isMobile()) {
	toMobile();
}

