﻿var urlstr = "";

function SmpVnTag(){

	if (document.referrer.indexOf('/smp/') == -1 && ((navigator.userAgent.indexOf('iPhone') > 0 && navigator.userAgent.indexOf('iPad') == -1) || navigator.userAgent.indexOf('iPod') > 0 || navigator.userAgent.indexOf('Android') > 0)) {
		Smptagwrite();
	}else{
		Pctagwrite();
	}
}

function Pctagwrite(){
	var Vnid=VnidPc;
	if(!document.body)document.write('<body>');
	document.write('<div id="vnimg"><script type="text/javascript" src="http://www02.tracer.jp/VL/Trace?c=2021&p=' + Vnid + VnOption +'&tp=1"></script></div>');
	document.getElementById('vnimg').style.position='absolute';
}

function Smptagwrite(){
	var Vnid=VnidSmp;
	if(!document.body)document.write('<body>');
	document.write('<div id="vnimg"><script type="text/javascript" src="http://www02.tracer.jp/VL/Trace?c=2021&p=' + Vnid +'&tp=1"></script></div>');

	// url生成
	var hoststr = location.host;
	urlstr = location.toString();
	urlstr = urlstr.replace(hoststr,hoststr+"/smp");

	// 移動実行
	ToSmp();
}

function ToSmp(){
	if(document.getElementById('container')){
		document.getElementById('container').style.display = 'none';
	}

	var ele = document.getElementById('vnimg');
 	if(ele.childNodes[2]){
			ele=ele.childNodes[2];
			ele.onload=location.href = urlstr;
		}else{
			setTimeout(ToSmp,50);
		}

}

