var cookie = new Object();
cookie = GetCookie();
var src_query = document.getElementById('smart_phone').src.split('?');
var sp_show_flag = 0;
parseUri.options = {
strictMode: false,
key: ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],
q: {
name: "queryKey",
parser: /(?:^|&)([^&=]*)=?([^&]*)/g
},
parser: {
strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
}
};
if( src_query[1] == 'pc' && cookie['smart_phone_flag']!=1 ) {
if( navigator.userAgent.indexOf('iPhone')!=-1 ){
LocationSP();
}
else if( navigator.userAgent.indexOf('iPod')!=-1 ){
LocationSP();
}
else if( navigator.userAgent.indexOf('Android')!=-1 ) {
LocationSP();
}
else {
}
}
if( navigator.userAgent.indexOf('iPhone')!=-1 ){
sp_show_flag = 1;
}
else if( navigator.userAgent.indexOf('iPod')!=-1 ){
sp_show_flag = 1;
}
else if( navigator.userAgent.indexOf('Android')!=-1 ) {
sp_show_flag = 1;
}
else {
}
function HtmlSmartPhone() {
var parse = new parseUri(location.href);
// document.write(parse['directory']);
// document.write(parse['file']);
// document.write("
");
// alert(sp_show_flag);
if( sp_show_flag ) {
document.write('PC | スマートフォン');
}
}
function JumpSP() {
SetCookie( 'smart_phone_flag', 0, 60 );
LocationSP();
}
function JumpPC() {
SetCookie( 'smart_phone_flag', 1, 60 );
LocationPC();
}
function LocationSP() {
var parse = new parseUri(location.href);
var query;
var d = new Array();
var room_id;
if( parse['directory']!='/mobile/') {
if( parse['file']=='list.php' ) {
location.href = './mobile/list.php';
}
else if( parse['directory'].match(/s_r_/) ) {
d = parse['directory'].split('_');
room_id = d[2].replace('/','');
location.href = '../mobile/shosai.php?room_id='+room_id;
}
// else if( parse['file']=='search.php' ) {
// location.href = './mobile/search.php';
// }
else if( parse['file']=='index.php' || parse['file']=='' ) {
location.href = './mobile/';
}
else {
location.href = './mobile/';
}
}
}
function LocationPC() {
var parse = new parseUri(location.href);
var query;
if( parse['directory']=='/mobile/') {
if( parse['file']=='list.php' ) {
location.href = '../search.php';
}
else if( parse['file']=='shosai_detail.php' ) {
query = ParseQuery( parse['query'] );
location.href = '../s_r_'+query['room_id']+'/index.html';
}
else if( parse['file']=='shosai.php' ) {
query = ParseQuery( parse['query'] );
location.href = '../s_r_'+query['room_id']+'/index.html';
}
// else if( parse['file']=='search_shubetsu.php' ) {
// location.href = '../search.php';
// }
else if( parse['file']=='index.php' || parse['file']=='' ) {
location.href = '../index.html';
}
else {
location.href = '../index.html';
}
}
}
function ParseQuery( query ) {
var obj = new Object();
var parms = query.split('&');
for( var i=0; i 0 ) {
var key = parms[i].substring(0,pos);
var val = parms[i].substring(pos+1);
obj[key] = val;
}
}
return obj;
}
function GetCookie() {
var i;
var arr = (document.cookie) ? document.cookie.split(';') : new Array();
var arr2 = new Array();
var obj = new Object();
arr = document.cookie.split(";");
for( i=0; i
// MIT License
function parseUri (str) {
var o = parseUri.options,
m = o.parser[o.strictMode ? "strict" : "loose"].exec(str),
uri = {},
i = 14;
while (i--) uri[o.key[i]] = m[i] || "";
uri[o.q.name] = {};
uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) {
if ($1) uri[o.q.name][$1] = $2;
});
return uri;
};