/*
*/
_OHSkin = {
config: {},
init: function(args) {
_OHSkin.config = {
bg_image: (typeof(args.bg_image) != 'undefined') ? args.bg_image : 'http://static.outdoorhub.com/blank.gif',
bg_color: (typeof(args.bg_color) != 'undefined') ? args.bg_color : 'transparent',
clickthru_url: (typeof(args.clickthru_url) != 'undefined') ? args.clickthru_url : '#',
left_width: (typeof(args.left_width) != 'undefined') ? args.left_width : 200,
right_width: (typeof(args.right_width) != 'undefined') ? args.right_width : 200
}
if (screen.width - (_OHSkin.config.left_width + _OHSkin.config.right_width) >= 750) {
_OHSkin.apply();
}
},
apply: function() {
var scripts = document.getElementsByTagName('script');
var has_tb = false;
for (var i=0; i < scripts.length; i++) {
var script = scripts[i];
if (script.src.indexOf('http://toolbar.outdoorhub.com/toolbar.min.js') !== -1) {
has_tb = true;
}
}
if (_OHSkin.config.bg_image == null || _OHSkin.config.clickthru_url == null) {
return;
}
_OHSkin.setup();
var b = document.getElementsByTagName('body')[0];
var bm = {
t: b.style.marginTop,
l: b.style.marginLeft
}
if (navigator.userAgent.toLowerCase().indexOf('msie') !== -1) {
bg = {
x: b.style.backgroundPositionX,
y: b.style.backgroundPositionY
};
} else {
bp = b.style.backgroundPosition;
p = bp.split(' ');
bg = {
x: p[0],
y: p[1]
};
}
if (isNaN(parseInt(bg.y))) {
bg.y = 0;
}
if (has_tb && parseInt(bg.y) < 44) {
bg.y = 44;
}
bg_style = _OHSkin.config.bg_color;
b.style.background = bg_style;
b.style.backgroundColor = _OHSkin.config.bg_color;
b.style.backgroundImage = 'url("' + _OHSkin.config.bg_image + '")';
b.style.backgroundRepeat = 'no-repeat';
b.style.backgroundAttachment = 'fixed';
b.style.backgroundPosition = 'center ' + parseInt(bg.y) + 'px';
},
setup: function() {
if (window.addEventListener) { //dom
window.addEventListener('click', _OHSkin.onclick, false);
window.addEventListener('mouseover', _OHSkin.onmouseover, false);
}
if (window.attachEvent) { //msie
document.getElementsByTagName('body')[0].attachEvent('onclick', _OHSkin.onclick);
document.getElementsByTagName('body')[0].attachEvent('onmouseover', _OHSkin.onmouseover);
}
},
onclick: function(e) {
var tag = _OHSkin.get_tag(e);
if (!e) {
e = window.event;
}
if (e.button == 0) {
if (tag == 'body' || tag == 'html') {
pop = window.open(_OHSkin.config.clickthru_url, '_blank');
}
}
},
onmouseover: function(e) {
var tag = _OHSkin.get_tag(e);
if (tag == 'body' || tag == 'html') {
document.body.style.cursor = 'pointer';
} else {
document.body.style.cursor = 'default';
}
},
get_tag: function(e) {
var targ;
if (!e) {
e = window.event;
}
if (e.target) {
targ = e.target;
} else if (e.srcElement) {
targ = e.srcElement;
}
if (targ.nodeType != null && targ.nodeType == 3) { //safari bug
targ = targ.parentNode;
}
if (targ.tagName.toLowerCase() == 'html') {
var tag = 'html';
} else {
var tag = targ.tagName.toLowerCase();
}
return tag;
}
};