var seller_available = true;
var seller_id = 182;
var BUTTON_URL = "https://rtn.fididel.com/";
var fididel_url = BUTTON_URL + "rtn/chat/seller/182";
var button_container = 'divFididelButton',
appear_timeout = 1000,
floating_y_step = .008,
TARGET_Y = -130,
TARGET_X = -190,
FLOAT_SPEED = 15;
function addFloatingButtonCloseLink()
{
var para = document.createElement('p');
para.innerHTML = 'Close';
para.style.textAlign = 'right';
para.style.margin = '0 0 5px 0';
para.style.fontSize = '10px';
var obj = document.getElementById(button_container);
var link = obj.getElementsByTagName('a').item(0);
obj.insertBefore(para, link);
}
function startFloatingButton() {
if (!document.getElementById) {
return;
}
var obj = document.getElementById(button_container);
if (obj && isHostMethod(obj, 'style')) {
// remove image for old button
var button = document.getElementById('fididel_image');
if (button) {
var root = button.parentNode;
root.removeChild(button);
root.innerHTML = '
';
// apply png fix
var img = document.getElementById('fididel_image');
if (document.all) {
img.parentNode.style.width = img.offsetWidth;
img.parentNode.style.height = img.offsetHeight;
img.parentNode.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=scale src='"+ img.src +"')";
} else {
img.style.visibility = 'visible';
}
}
// apply style
obj.style.display = 'none';
obj.style.textAlign = 'center';
obj.style.position = 'absolute';
obj.style.width = '156px';
obj.style.left = '0';
obj.style.top = '0';
obj.style.zIndex = 9999;
addFloatingButtonCloseLink();
} else {
d = document;
if (isHostMethod(d, 'createElement') && isHostMethod(d, 'getElementsByTagName')
&& isHostMethod(d, 'appendChild')) {
var div = d.createElement('div');
div.innerHTML = '
\
';
var bodyRef = document.getElementsByTagName("body").item(0);
bodyRef.appendChild(div);
}
}
floatingMenu =
{
targetX: TARGET_X,
targetY: 10,
hasInner: typeof(window.innerWidth) == 'number',
hasElement: typeof(document.documentElement) == 'object'
&& typeof(document.documentElement.clientWidth) == 'number',
menu:
document.getElementById
? document.getElementById(floatingMenuId)
: document.all
? document.all[floatingMenuId]
: document.layers[floatingMenuId]
};
floatingMenu.move = function ()
{
floatingMenu.menu.style.left = floatingMenu.nextX + 'px';
floatingMenu.menu.style.top = floatingMenu.nextY + 'px';
}
floatingMenu.computeShifts = function ()
{
var de = document.documentElement;
floatingMenu.shiftX =
floatingMenu.hasInner
? pageXOffset
: floatingMenu.hasElement
? de.scrollLeft
: document.body.scrollLeft;
if (floatingMenu.targetX < 0)
{
floatingMenu.shiftX +=
floatingMenu.hasElement
? de.clientWidth
: document.body.clientWidth;
if (floatingMenu.shiftX == 0) {
floatingMenu.shiftX = document.body.clientWidth;
}
}
floatingMenu.shiftY =
floatingMenu.hasInner
? pageYOffset
: floatingMenu.hasElement
? de.scrollTop
: document.body.scrollTop;
if (typeof(pageYOffset) == 'undefined') {
floatingMenu.shiftY = document.body.scrollTop;
}
if (floatingMenu.targetY < 0)
{
if (floatingMenu.hasElement && floatingMenu.hasInner)
{
// Handle Opera 8 problems
floatingMenu.shiftY +=
de.clientHeight > window.innerHeight
? window.innerHeight
: de.clientHeight
}
else
{
floatingMenu.shiftY +=
floatingMenu.hasElement
? de.clientHeight
: document.body.clientHeight;
if (de.clientHeight == 0) {
floatingMenu.shiftY += document.body.clientHeight;
}
}
}
}
floatingMenu.calculateCornerX = function()
{
if (floatingMenu.targetX != 'center')
return floatingMenu.shiftX + floatingMenu.targetX;
var width = parseInt(floatingMenu.menu.offsetWidth);
var cornerX =
floatingMenu.hasElement
? (floatingMenu.hasInner
? pageXOffset
: document.documentElement.scrollLeft) +
(document.documentElement.clientWidth - width)/2
: document.body.scrollLeft +
(document.body.clientWidth - width)/2;
return cornerX;
};
floatingMenu.calculateCornerY = function()
{
if (floatingMenu.targetY != 'center') {
//console.info('Shift Y:' + floatingMenu.shiftY + ' targetY:' + floatingMenu.targetY);
return floatingMenu.shiftY + floatingMenu.targetY;
}
var height = parseInt(floatingMenu.menu.offsetHeight);
// Handle Opera 8 problems
var clientHeight =
floatingMenu.hasElement && floatingMenu.hasInner
&& document.documentElement.clientHeight
> window.innerHeight
? window.innerHeight
: document.documentElement.clientHeight
var cornerY =
floatingMenu.hasElement
? (floatingMenu.hasInner
? pageYOffset
: document.documentElement.scrollTop) +
(clientHeight - height)/2
: document.body.scrollTop +
(document.body.clientHeight - height)/2;
return cornerY;
};
floatingMenu.doFloat = function()
{
var stepX, stepY;
floatingMenu.computeShifts();
var cornerX = floatingMenu.calculateCornerX();
var stepX = (cornerX - floatingMenu.nextX) * .07;
if (Math.abs(stepX) < .5)
{
stepX = cornerX - floatingMenu.nextX;
}
var cornerY = floatingMenu.calculateCornerY();
//console.info('Corner Y: ' + cornerY);
//console.info('nextY: ' + floatingMenu.nextY);
//var stepY = (cornerY - floatingMenu.nextY) * floating_y_step; // original .07
var stepY = 1;
if (floatingMenu.nextY == cornerY) {
stepY = 0;
}
if (cornerY < floatingMenu.nextY) {
stepY *= -1;
}
//console.info('Step Y: ' + stepY);
// if (Math.abs(stepY) < .5)
// {
// stepY = cornerY - floatingMenu.nextY;
// }
if (Math.abs(stepX) > 0 ||
Math.abs(stepY) > 0)
{
floatingMenu.nextX += stepX;
floatingMenu.nextY += stepY;
//console.info(stepY);
floatingMenu.move();
}
setTimeout('floatingMenu.doFloat()', FLOAT_SPEED);
};
// addEvent designed by Aaron Moore
floatingMenu.addEvent = function(element, listener, handler)
{
if(typeof element[listener] != 'function' ||
typeof element[listener + '_num'] == 'undefined')
{
element[listener + '_num'] = 0;
if (typeof element[listener] == 'function')
{
element[listener + 0] = element[listener];
element[listener + '_num']++;
}
element[listener] = function(e)
{
var r = true;
e = (e) ? e : window.event;
for(var i = element[listener + '_num'] -1; i >= 0; i--)
{
if(element[listener + i](e) == false)
r = false;
}
return r;
}
}
//if handler is not already stored, assign it
for(var i = 0; i < element[listener + '_num']; i++)
if(element[listener + i] == handler)
return;
element[listener + element[listener + '_num']] = handler;
element[listener + '_num']++;
};
floatingMenu.hide = function()
{
floatingMenu.menu.style.display='none';
return false;
}
floatingMenu.show = function()
{
floatingMenu.menu.style.display='block';
return false;
}
floatingMenu.init = function()
{
window.setTimeout(start_button, appear_timeout);
//floatingMenu.initSecondary();
//floatingMenu.doFloat();
};
// Some browsers init scrollbars only after
// full document load.
floatingMenu.initSecondary = function()
{
floatingMenu.computeShifts();
floatingMenu.nextX = floatingMenu.calculateCornerX();
floatingMenu.nextY = floatingMenu.calculateCornerY();
floatingMenu.move();
window.setTimeout(move_lower_right, 1000);
}
if (document.layers)
floatingMenu.addEvent(window, 'onload', floatingMenu.init);
else
{
floatingMenu.init();
floatingMenu.addEvent(window, 'onload',
floatingMenu.initSecondary);
}
}
/* Script by: www.jtricks.com
* Version: 20071017
* Latest version:
* www.jtricks.com/javascript/navigation/floating.html
*/
var floatingMenuId = button_container;
var floatingMenu = {};
function start_button() {
floatingMenu.show();
floatingMenu.initSecondary();
floatingMenu.doFloat();
}
function move_lower_right() {
floatingMenu.targetX=TARGET_X;
floatingMenu.targetY=TARGET_Y;
}
function getElementsByTagNames(list,obj) {
if (!obj) var obj = document;
var tagNames = list.split(',');
var resultArray = new Array();
for (var i=0;i