(function(){
	//vars
	var url = 'http://www.keiyobank.co.jp/';
	var ref = document.referrer;
	
	//flg
	if(ref.indexOf(url)!=-1){return;}
	
	//redirect sphone
	if(checkDevice('iphone|ipod') || checkDevice('android mobile') || checkDevice('BlackBerry') || checkDevice('Windows Phone')){
		if(location.href==url || location.href==url+'index.html' || location.href==url+'index.shtml'){
			location.href=url+'sphone/';
		}
	}
	
	//mobile ua
	function checkDevice(device) {
		var ua = navigator.userAgent;
		if (device == 'apple') { return RegExp('iphone|ipod|ipad', 'i').test(ua); }
		else if (device == 'android') { return RegExp('android', 'i').test(ua); }
		else if (device == 'mobile') { return RegExp('iphone', 'i').test(ua) || (RegExp('android', 'i').test(ua) && RegExp('mobile', 'i').test(ua)); }
		else if (device == 'tablet') { return RegExp('ipad|android', 'i').test(ua); }
		else if (device == 'android mobile') { return RegExp('android', 'i').test(ua) && RegExp('mobile', 'i').test(ua) && !RegExp('SC-01C', 'i').test(ua); }
		else if (device == 'android tablet') { return RegExp('android', 'i').test(ua); }
		else if (device == 'BlackBerry') { return RegExp('BlackBerry', 'i').test(ua); } // BlackBerry
		else if (device == 'Windows Phone') { return RegExp('Windows Phone', 'i').test(ua) || RegExp('IEMobile', 'i').test(ua); } // Windows Phone & IEMobile
		else { return RegExp(device, 'i').test(ua); }
	}
})();

