/**
* blog parts library
* Copyright (C) KAYAC Inc. | http://www.kayac.com/
* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
* and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
* Date: 2008/9/19
* @author kyo_ago
* @version 1.1.7
*/
(function () {
var $, jQuery, swfobject;
loadLib();
var script_hosting_uri = 'http://hanshin.kayac.com/bp/';
var name_space = checkNameSpace(script_hosting_uri.replace(/\W/g, '_'));
var $script = $('script[src^="http://hanshin.kayac.com/tag/"]:last');
//(new Image).src = '';
$(function ($) {
$script.after('
');
$(document.body).append('');
var $target = $('#'+name_space+'_box');
var settings = createSettingsObject({
to_flash_attr : {
'width' : 160,
'height' : 200
},
to_flash_flashvars : {
'uid' : '148eb2f29012922.11480311'
}
}).outputSwf($target);
var middle_settings = createSettingsObject({
base_name : 'middle',
to_flash_attr : {
'width' : 160,
'height' : 156
},
to_flash_param : {
'wmode' : 'window'
},
to_flash_flashvars : {
'uid' : '148eb2f29012922.11480311'
}
}).outputSwf($target);
$target.append('
');
var bottom_settings = createSettingsObject({
base_name : 'bottom',
to_flash_attr : {
'width' : 160,
'height' : 54
},
to_flash_flashvars : {
'uid' : '148eb2f29012922.11480311'
}
}).outputSwf($target);
var css_style = {
'position' : 'absolute',
'top' : '0',
'left' : '0',
'z-index' : 1000
};
$('#'+settings.swf_id).css(css_style);
$('#'+middle_settings.swf_id).css($.extend(css_style, {
'top' : '200px'
}));
$('#'+bottom_settings.swf_id).css($.extend(css_style, {
'top' : '356px'
}));
$target.find('img').css($.extend(css_style, {
'top' : '200px',
'width' : '160px',
'height' : '156px'
}));
$('#'+name_space+'_box_div').append($('#'+name_space+'_box'));
$script.after('
');
addWindowNameSpace(settings);
new function () {
var old = window[settings.name_space].jack_swf;
window[settings.name_space].jack_swf = function (id) {
document.title += 'jack ';
this.jack_settings.swf_path = script_hosting_uri + 'swf/jack' + id + '.swf';
this.jack_settings.to_flash_flashvars.uid = '148eb2f29012922.11480311';
$('#'+middle_settings.swf_id).css('visibility', 'hidden');
var self = this;
setTimeout(function () {
return old.apply(self, arguments);
}, 500);
};
};
new function () {
var old = window[settings.name_space].clear_swf;
window[settings.name_space].clear_swf = function () {
$('#'+middle_settings.swf_id).css('visibility', '');
return old.apply(this, arguments);
};
};
/*
window[settings.name_space].onCrearSwf = function (remove_func) {
this.get_swf(this.settings.swf_id, 'initialize', function (ex) {
ex.initialize();
remove_func();
});
return this;
}
*/
});
//-------------------- library ------------------------------
function checkNameSpace (name_space) {
if (!window[name_space]) return name_space;
var count = 0;
while (window[name_space + '_' + (count++)]) true;
return name_space;
};
function createSettingsObject (options) {
if (!options) options = {};
if (!options.base_name) options.base_name = 'main';
var to_flash_attr = $.extend({
'width' : 160,
'height' : 340
}, options.to_flash_attr);
var to_flash_param = $.extend({
'wmode' : 'transparent',
'allowScriptAccess' : 'always',
'scale' : 'noScale'
}, options.to_flash_param);
var to_flash_flashvars = $.extend(getScriptParam($script), {
'name_space' : name_space,
'loc' : encodeURIComponent(location.href),
'ref' : encodeURIComponent(document.referrer)
}, options.to_flash_flashvars);
var bn = options.base_name;
return $.extend({
'$script' : $script,
'name_space' : name_space,
'swf_path' : script_hosting_uri + 'swf/' + bn + '.swf',
'swf_id' : name_space + '_' + bn + '_external',
'wrap_id' : name_space + '_' + bn + '_wrap'
},options, {
'to_flash_attr' : to_flash_attr,
'to_flash_param' : to_flash_param,
'to_flash_flashvars' : to_flash_flashvars,
'outputSwf' : function (elem) {
var self = this;
if (elem) {
$(elem).append('');
} else {
this.$script.after('');
}
var attr = $.extend(this.to_flash_attr, {
'id' : this.swf_id,
'data' : this.swf_path
});
var flashvars = $.param($.extend(this.to_flash_flashvars, {
'window_width' : $(window).width(),
'window_height' : $(window).height()
}));
var param = $.extend(this.to_flash_param, {
'flashvars' : flashvars
});
swfobject.createSWF(attr, param, self.wrap_id);
return this;
}
});
}
function getScriptParam ($script) {
var param = {};
try {
var src = $script.attr('src');
if (!src.match('#')) return;
$.each(src.split('#').pop().split('&'), function () {
var kv = (this + '').split('=');
param[decodeURIComponent(kv[0])] = decodeURIComponent(kv[1]);
} );
} catch (e) {}
return param;
};
function addWindowNameSpace(main_settings, options) {
var bplib = $.extend({
'swf_cache' : {},
'name_space' : main_settings.name_space,
'main_settings' : main_settings,
'jack_settings' : createSettingsObject({
'base_name' : 'jack',
'to_flash_attr' : {
'width' : '100%',
'height' : '100%',
'style' : 'position:fixed;bottom:0;left:0;margin:0;',
'z-index' : 1000
}
}),
// undefined === ignore
'swf_jacked' : false
}, options);
$.each(['Top', 'Left'], function () {
var name = this;
bplib['getScroll' + name] = function () {
var b = document.body['scroll' + name] || 0;
var e = document.documentElement['scroll' + name] || 0;
return Math.max(b, e, 0);
};
});
bplib.get_swf = function (swf_id, method, callback) {
if (this.swf_cache[swf_id]) return callback.call(this, this.swf_cache[swf_id]);
var max_retry = 30;
var self = this;
(function () {
if (!max_retry--) return;
var swf = swfobject.getObjectById(swf_id);
if (!swf || !swf[method]) return setTimeout(arguments.callee, 50);
self.swf_cache[swf_id] = swf;
callback.call(self, swf);
})();
return this;
};
bplib.set_window_resize = function (jack_swf) {
var self = this;
var resize = 'resize.' + this.name_space;
$(window).bind(resize, function () {
var swf_id = self.jack_settings.swf_id;
self.get_swf(swf_id, 'window_resize', function (ex) {
var width = Math.floor($(window).width());
var height = Math.floor($(window).height());
ex.window_resize(width, height);
});
});
return this;
};
bplib.jack_swf = function () {
this.jack_settings.outputSwf($(document.body));
this.get_swf(this.jack_settings.swf_id, 'window_resize', this.set_window_resize);
return this;
};
bplib.clear_swf = function () {
var self = this;
var resize = 'resize.' + this.name_space;
var id_set = '#'+self.jack_settings.swf_id + ', #'+self.jack_settings.wrap_id;
var func = function () {
$(id_set).remove();
$(window).unbind(resize);
};
self.onCrearSwf ? self.onCrearSwf(func) : func();
return this;
};
if (bplib.swf_jacked !== undefined) singletonJacked();
($.browser.msie && $.browser.version <= 6) ? forIE6() : forNotIE6();
return window[bplib.name_space] = bplib;
//-------------- inner function ------------------------
function singletonJacked () {
var j = bplib.jack_swf;
bplib.jack_swf = function () {
if (this.swf_jacked) return;
this.swf_jacked = true;
return j.apply(this, arguments);
};
var c = bplib.clear_swf;
bplib.clear_swf = function () {
var r = c.apply(this, arguments);
this.swf_jacked = false;
return r;
};
};
function forIE6 () {
bplib.$hidden_elements = [];
var j = bplib.jack_swf;
bplib.jack_swf = function () {
var main = swfobject.getObjectById(this.main_settings.swf_id);
var tags = 'object, embed, iframe, select';
this.$hidden_elements = $(tags)
.not(':hidden')
.not(main)
.css('visibility', 'hidden')
;
var result = j.apply(this, arguments);
// position:fixed for ie6
var swf = swfobject.getObjectById(this.jack_settings.swf_id);
if (!swf.style.setExpression) return;
$(swf).css({'position' : 'absolute', 'bottom' : '' });
swf.style.setExpression('behavior', 'style.top = (document.body.scrollTop || document.documentElement.scrollTop) + "px"');
return result;
};
var c = bplib.clear_swf;
bplib.clear_swf = function () {
if (this.$hidden_elements) this.$hidden_elements.css('visibility', '');
return c.apply(this, arguments);
};
};
function forNotIE6 () {
var c = bplib.clear_swf;
bplib.clear_swf = function () {
var self = this;
setTimeout(function () { c.apply(self, arguments) }, 0);
};
};
};
function loadLib() {
/* SWFObject v2.1
Copyright (c) 2007-2008 Geoff Stearns, Michael Williams, and Bobby van der Sluis
This software is released under the MIT License
*/
swfobject=function(){var b="undefined",Q="object",n="Shockwave Flash",p="ShockwaveFlash.ShockwaveFlash",P="application/x-shockwave-flash",m="SWFObjectExprInst",j=window,K=document,T=navigator,o=[],N=[],i=[],d=[],J,Z=null,M=null,l=null,e=false,A=false;var h=function(){var v=typeof K.getElementById!=b&&typeof K.getElementsByTagName!=b&&typeof K.createElement!=b,AC=[0,0,0],x=null;if(typeof T.plugins!=b&&typeof T.plugins[n]==Q){x=T.plugins[n].description;if(x&&!(typeof T.mimeTypes!=b&&T.mimeTypes[P]&&!T.mimeTypes[P].enabledPlugin)){x=x.replace(/^.*\s+(\S+\s+\S+$)/,"$1");AC[0]=parseInt(x.replace(/^(.*)\..*$/,"$1"),10);AC[1]=parseInt(x.replace(/^.*\.(.*)\s.*$/,"$1"),10);AC[2]=/r/.test(x)?parseInt(x.replace(/^.*r(.*)$/,"$1"),10):0}}else{if(typeof j.ActiveXObject!=b){var y=null,AB=false;try{y=new ActiveXObject(p+".7")}catch(t){try{y=new ActiveXObject(p+".6");AC=[6,0,21];y.AllowScriptAccess="always"}catch(t){if(AC[0]==6){AB=true}}if(!AB){try{y=new ActiveXObject(p)}catch(t){}}}if(!AB&&y){try{x=y.GetVariable("$version");if(x){x=x.split(" ")[1].split(",");AC=[parseInt(x[0],10),parseInt(x[1],10),parseInt(x[2],10)]}}catch(t){}}}}var AD=T.userAgent.toLowerCase(),r=T.platform.toLowerCase(),AA=/webkit/.test(AD)?parseFloat(AD.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,q=false,z=r?/win/.test(r):/win/.test(AD),w=r?/mac/.test(r):/mac/.test(AD);/*@cc_on q=true;@if(@_win32)z=true;@elif(@_mac)w=true;@end@*/return{w3cdom:v,pv:AC,webkit:AA,ie:q,win:z,mac:w}}();var L=function(){if(!h.w3cdom){return }f(H);if(h.ie&&h.win){try{K.write("