OpineoSlider._instance = null;
OpineoSlider._cls_activator = 'op:activator';
OpineoSlider._cls_slide = 'op:slide';
OpineoSlider._fps = 50;
OpineoSlider._frameStep = 20;
OpineoSlider._delay = 800;
OpineoSlider._HTMLtemplate = null;
OpineoSlider.data = null;
OpineoSlider.appendTo = null;
OpineoSlider.offsetTop = false;
OpineoSlider._makeHTMLTemplate = function() {
return "
za moment bedziemy
";
};
OpineoSlider.get = function() {
if (OpineoSlider.__fetched) return;
OpineoSlider.__fetched = true;
if (OpineoSlider._instance == null) {
var html = document.createElement('div');
html.innerHTML = OpineoSlider._HTMLtemplate;
html = html.firstChild;
if(OpineoSlider.test){
html.style.cssText = html.style.cssText.replace("fixed","absolute");
}
if (OpineoSlider.offsetTop && OpineoSlider.offsetTop > 0) {
html.style.top = '' + OpineoSlider.offsetTop + 'px';
}
var s = new OpineoSlider(html);
s.update(OpineoSlider.data);
if (OpineoSlider.appendTo != null) {
OpineoSlider.appendTo = document.getElementById(OpineoSlider.appendTo);
if (OpineoSlider.appendTo != null)
OpineoSlider.appendTo.appendChild(html);
else
document.body.appendChild(html);
} else {
document.body.appendChild(html);
}
}
return OpineoSlider._instance;
};
OpineoSlider.__attached = false;
OpineoSlider.__fetched = false;
OpineoSlider.__attach = function () {
if (!OpineoSlider.__attached) {
OpineoSlider.__attached = true;
if (document.addEventListener) {
document.addEventListener ("DOMContentLoaded", function(){
document.removeEventListener("DOMContentLoaded", arguments.callee, false);
OpineoSlider.get();
}, false);
} else if (document.attachEvent) {
document.attachEvent("onreadystatechange", function(){
if (document.readyState === "complete") {
document.detachEvent("onreadystatechange", arguments.callee);
OpineoSlider.get();
}
});
if (document.documentElement.doScroll && window == window.top) (function(){
if (OpineoSlider.__fetched) return;
try {
document.documentElement.doScroll("left");
} catch (e) {
setTimeout (arguments.callee, 0);
return;
}
OpineoSlider.get();
})();
}
}
};
OpineoSlider.prototype._state = null;
OpineoSlider.prototype._popout = true;
OpineoSlider.prototype._postponer = null;
OpineoSlider.prototype._animator = null;
OpineoSlider.prototype._activators = [];
OpineoSlider.prototype._slide = null;
OpineoSlider.prototype._div = null;
OpineoSlider.prototype._nextFrame = function() {
var at = parseInt(this._slide.style.right);
var nx = at + (this._popout ? 1 : -1 ) * OpineoSlider._frameStep;
if (nx <= -this._slide.scrollWidth) {
nx = -this._slide.scrollWidth;
this._enterState(1);
}
if (nx >= 0) {
nx = 0;
this._enterState(3);
}
this._slide.style.right = nx + 'px';
};
OpineoSlider.prototype._clearTimers = function() {
if (this._postponer != null) clearTimeout(this._postponer);
this._postponer = null;
if (this._animator != null) clearTimeout(this._animator);
this._animator = null;
};
OpineoSlider.prototype._makePostponer = function() {
this._clearTimers();
var self = this;
this._postponer = setInterval(function(){self._enterState(5);}, OpineoSlider._delay);
};
OpineoSlider.prototype._makeAnimator = function() {
if (this._slide == null) return;
this._clearTimers();
var self = this;
this._animator = setInterval(function(){self._nextFrame();}, 1000 / OpineoSlider._fps);
};
OpineoSlider.prototype._resizer = function(big) {
if (big) {
this._div.style.width = '233px';
this._div.style.height = '450px';
} else {
this._div.style.width = '41px';
this._div.style.height = '175px';
}
};
OpineoSlider.prototype._mout = function() {
switch (this._state) {
case 2: this._enterState(5); break;
case 3: this._enterState(4); break;
}
};
OpineoSlider.prototype._mover = function() {
switch (this._state) {
case 1:
case 5:
this._enterState(2);
break;
case 4:
this._enterState(3); break;
}
};
OpineoSlider.prototype._enterState = function(s) {
switch (s) {
case 1:
this._resizer(false);
this._clearTimers();
break;
case 2:
this._popout = true;
this._resizer(true);
this._makeAnimator();
break;
case 3:
this._clearTimers();
break;
case 4:
this._makePostponer();
break;
case 5:
this._popout = false;
this._makeAnimator();
break;
}
this._state = s;
};
OpineoSlider.prototype.update = function(data) {
var divs = this._slide.getElementsByTagName('div');
divs[1].getElementsByTagName('a')[2].href = data.url;
for (i in divs[4].childNodes) if (divs[4].childNodes[i].nodeType == 1){
if (divs[4].childNodes[i].className == 'op:logo') { divs[4].childNodes[i].src = data.logo; divs[4].childNodes[i].alt = data.name; };
}
for (i in divs[5].childNodes){
if (divs[5].childNodes[i].nodeType == 1){
if (divs[5].childNodes[i].className == 'op:qlink' && data.q){
divs[5].childNodes[i].href = data.url;
divs[5].childNodes[i].childNodes[0].style.display = 'inline';
}
if (divs[5].childNodes[i].className == 'op:ssklink' && data.ssk){
divs[5].childNodes[i].href = data.url;
divs[5].childNodes[i].childNodes[0].style.display = 'inline';
}
}
}
divs[3].getElementsByTagName('b')[0].innerHTML = data.positive;
divs[6].getElementsByTagName('b')[0].innerHTML = data.mark;
divs[8].style.width = '' + parseInt(parseFloat(data.mark) * 0.1 * 115) + 'px';
var td = divs[3].getElementsByTagName('td');
var tr = divs[3].getElementsByTagName('tr');
td[2].innerHTML = '' + data.num + ' ' + data.word;
for (var i in data.marks) if ((typeof i == 'number' || typeof i == 'string') && !isNaN(parseInt(i))) {
tr[3+parseInt(i)].style.display = 'table-row';
td[3 + i * 2].innerHTML = data.marks[i].txt;
if(data.marks[i].txt.length > 50)
td[3 + i * 2].style.font = '10px Tahoma,sans-serif';
td[4 + i * 2].getElementsByTagName('div')[1].style.width = '' + parseInt(parseFloat(data.marks[i].n) * 0.1 * 60) + 'px';
td[4 + i * 2].getElementsByTagName('b')[0].innerHTML = data.marks[i].n;
}
};
function OpineoSlider(div) {
this._state = 1;
this._div = div;
var activator = div.childNodes;
for (a in div.childNodes) {
var cls = div.childNodes[a].className;
if (cls) {
cls = cls.split(' ');
for (c in cls) {
if (cls[c] == OpineoSlider._cls_activator) { this._activators[this._activators.length] = div.childNodes[a]; }
if (cls[c] == OpineoSlider._cls_slide) { this._slide = div.childNodes[a]; }
}
}
}
var self = this;
for (a in this._activators) {
this._activators[a].onmouseover = function(){self._mover();};
this._activators[a].onmouseout = function(){self._mout();};
}
}OpineoSlider.test = false;
OpineoSlider.data = {"num":"159","mark":"9.6","name":"Helios-Szk\u0142o","word":"opinii","logo":"https:\/\/www.opineo.pl\/upload\/logos\/small\/helios-porcelana-1309443741-0-316036001309443741-1045-gif.jpg","ssk":true,"q":false,"positive":"99%","marks":[{"txt":"Szybko\u015b\u0107 realizacji zam\u00f3wienia","n":"9.6"},{"txt":"Poziom obs\u0142ugi klienta","n":"9.4"},{"txt":"Jako\u015b\u0107 zapakowania przesy\u0142ki","n":"9.7"},{"txt":"Poleci\u0142(a)bym ten sklep znajomym","n":"9.6"}],"url":"http:\/\/www.opineo.pl\/opinie\/helios-szklo-pl"};
OpineoSlider._HTMLtemplate = "\
\
\
\
\
\
\
\

\
\
\

\

\
\
\
| 23 333 klientów poleca ten sklep |
\
| \
\
|
\
| 23 333 opinie |
\
| \
\
\
|
\
| \
\
\
|
\
| \
\
\
|
\
| \
\
\
|
\
\
\
\
Sprawd opinie na Opineo.pl\
\
\
\
";
OpineoSlider.__attach();