var MZN_SD_BP = {};
MZN_SD_BP.DIR = 'http://www.mizuno.jp/mizuno_swim/members/diary/blogparts/';
MZN_SD_BP.embedFlash = function(swf, id, w, h, mode, vars)
{
return [''].join('');
};
MZN_SD_BP.initialize = function()
{
this.display();
this.swimin();
};
MZN_SD_BP.swimin = function()
{
var pos = location.search.indexOf("mznswm=");
if (pos == -1) return;
var sex = location.search.substr((pos+7), 1);
var type = location.search.substr((pos+8), 1);
var left = location.search.substr((pos+9), 1);
if (sex.search(/(M|F)/)== -1) return;
if (type.search(/[0-3]/)== -1) return;
var div = document.createElement("div");
div.id = "mzn-swimin";
this.addEvent(window, "load", _onLoad);
function _onLoad() {
var style = div.style;
style.display = "block";
style.position = "absolute";
style.top = "0px";
style.left = "0px";
style.zIndex = "436514";
var size = MZN_SD_BP.getInnerSize();
style.width = size.width + "px";
style.height = "200px";
var params = ["left=",left, "&type=", type, "&sex=", sex].join('');
div.innerHTML = MZN_SD_BP.embedFlash(MZN_SD_BP.DIR + "swimin.swf", "mznswimin", size.width, 200, "transparent", params);
document.body.appendChild(div);
}
};
MZN_SD_BP.removeSwimin = function()
{
setTimeout(function(){
document.body.removeChild(document.getElementById("mzn-swimin"));
}, 1500);
};
MZN_SD_BP.display = function()
{
document.write('');
var that = this;
var bp = document.getElementById("mzn-bp");
var px = MZN_SD_BP.getPosition(bp).left;
var w = that.getInnerSize().width;
this.isLeft = px < w * 0.5 ? 1 : 0;
var hour = parseInt(03);
var time;
if (hour >= 6 && hour <= 16) time = 1;
else if (hour >= 17 && hour <= 18) time = 2;
else time = 3;
var bpswf = [that.DIR , "bp" , time , ".swf"].join("");
bp.innerHTML = that.embedFlash( bpswf, "flashexternalmznbp", 160, 367, "transparent", "left="+that.isLeft+"&member=2e7729d6d8c74cfd050c620390381a7f" );
};
MZN_SD_BP.addEvent = (function()
{
if (window.addEventListener) {
return function(elm, evtType, fnc, useCapture) {
elm.addEventListener(evtType, fnc, useCapture);
return true;
};
} else if (window.attachEvent) {
return function(elm, evtType, fnc) {
var res = elm.attachEvent('on' + evtType, fnc);
return res;
};
} else {
return function(elm, evtType, fnc) {
elm['on' + evtType] = fnc;
};
}
})();
MZN_SD_BP.getPosition = function(target) {
var top = 0;
var left = 0;
while (target) {
top += target.offsetTop;
left += target.offsetLeft;
target = target.offsetParent;
}
return {top: top, left: left};
};
MZN_SD_BP.getInnerSize = function() {
var width = 0;
var height = 0;
if (typeof window.innerHeight != 'undefined') {
height = window.innerHeight;
} else if (typeof document.documentElement.clientHeight != 'undefined') {
height = document.documentElement.clientHeight || document.body.clientHeight;
}
if (typeof window.innerWidth != 'undefined') {
width = window.innerWidth;
if (document.height > height) width -= 16;
} else if (typeof document.documentElement.clientWidth != 'undefined') {
width = document.documentElement.clientWidth || document.body.clientWidth;
}
return {width: width, height: height};
};
MZN_SD_BP.swimout = function(time, sex)
{
var pos = this.getPosition( document.getElementById("mzn-bp") );
var size = this.getInnerSize();
var left = pos.left;
var w;
if (this.isLeft == 1) {
left += 160;
w = size.width - pos.left - 160;
} else {
left = 0;
w = size.width - (size.width - pos.left)
}
var div = document.createElement("div");
var style = div.style;
style.position = "absolute";
style.top = (pos.top + 100) + "px";
style.left = left + "px";
style.width = w + "px";
style.height = "200px";
style.zIndex = "50000";
document.body.appendChild(div);
var params = ["left=",this.isLeft, "&time=", time, "&sex=", sex].join('');
div.innerHTML = this.embedFlash( this.DIR + "swim.swf", "swimmznbp", w, 200, "transparent", params);
this.addEvent(window, "unload", _onUnLoad);
function _onUnLoad() {
document.body.removeChild(div);
}
return 0;
}
MZN_SD_BP.initialize();