Есть плеер с плейлистом и у него кнопки серий в виде button через JS и проблема в том что при нажатии на кнопку серии у другого button на странице исчезают стили. Как сделать, чтобы те стили, которые заданы у плеера только на нем имели эффект?
Скрипт плеера:
var a, b, n, j, k = 1;
num = 0, nom = 0, nym = 0, pos = 0, seria = " Серия", chast = " Часть", server = " Сервер";
um = window.um || {};
(um = {
create: function(e) {
document.getElementById(e).innerHTML = '<div id="wrapper" onselectstart="return false" oncontextmenu="return false;"><div id="player"></div><div id="panel"></div></div>';
k = 1, num = 0, nom = 0, nym = 0;
var c = document.createElement("div"),
d = document.getElementById("panel");
if(d != null) {
c.id = "playlist";
d.appendChild(c);
d.innerHTML += '<div onmousedown="um.move(3)" onmouseover="um.move(1)" onmouseout="um.move(0)" id="r"></div><div onmousedown="um.move(4)" onmouseover="um.move(2)" onmouseout="um.move(0)" id="l"></div>'
}
},
uplay: function(h, f, d) {
var g, m = 1,
e, c, l;
if(d) {
if(d == 1) {
d = chast
} else {
if(d == 2) {
d = server
}
}
} else {
d = seria
}
try {
num = num + 1;
l = document.createElement("button");
l.setAttribute("title", num + d);
l.setAttribute("class", "plclass");
l.setAttribute("id", "id-" + num);
l.setAttribute("type", h);
l.setAttribute("name", f);
if(d == chast || d == server) {
nym = nym + 1;
nom = nom - nym + num;
if(k == 1) {
k = k - 1;
nom = nom + 1
}
l.innerHTML = nym + d
} else {
nom = nom + 1;
l.innerHTML = nom + d
}
document.getElementById("playlist").appendChild(l)
} finally {
e = document.getElementById("id-" + num);
e.setAttribute("onclick", "um.player('id-" + num + "');return false;");
e.addEventListener("click", function() {
if(document.getElementsByTagName("button")) {
c = document.getElementsByTagName("button");
for(g = 0; g < c.length; ++g) {
c[g].setAttribute("class", "")
}
}
e.setAttribute("class", "active")
}, false)
}
setTimeout("um.move(2);um.player('id-1');document.getElementsByTagName('button')[0].setAttribute('class','active');", 1700)
},
move: function(d) {
var g, f, c, e = 0,
h = document.getElementsByTagName("button");
for(g = 0; g < h.length; g++) {
e = e + h[g].clientWidth + 2
}
e = e - 425;
if(d == 0) {
clearTimeout(a);
clearTimeout(b)
}
if(d == 1) {
if(pos >= -e) {
b = setTimeout("um.move(1)", 15);
pos = pos - 5;
document.getElementById("playlist").style.left = pos + "px";
document.getElementById("l").removeAttribute("style")
} else {
clearTimeout(b);
document.getElementById("r").setAttribute("style", "background:url(images/next.png) -122px 0 no-repeat;")
}
}
if(d == 2) {
if(pos <= -5) {
a = setTimeout("um.move(2)", 15);
pos = pos + 5;
document.getElementById("playlist").style.left = pos + "px";
document.getElementById("r").removeAttribute("style")
} else {
clearTimeout(a);
document.getElementById("l").setAttribute("style", "background:url(images/prev.png) -120px 0 no-repeat;")
}
}
if(d == 3) {
if(pos >= -e) {
f = setTimeout("um.move(3)", 10);
pos = pos - 10;
document.getElementById("playlist").style.left = pos + "px";
document.getElementById("l").removeAttribute("style")
} else {
clearTimeout(f);
document.getElementById("r").setAttribute("style", "background:url(images/next.png) -122px 0 no-repeat;")
}
}
if(d == 4) {
if(pos <= -10) {
c = setTimeout("um.move(4)", 10);
pos = pos + 10;
document.getElementById("playlist").style.left = pos + "px";
document.getElementById("r").removeAttribute("style")
} else {
clearTimeout(c);
document.getElementById("l").setAttribute("style", "background:url(images/prev.png) -120px 0 no-repeat;")
}
}
if(e <= pos) {
document.getElementById("r").setAttribute("style", "background:url(images/next.png) -122px 0 no-repeat;")
}
},
player: function(e) {
var c = document.createElement("embed"),
d = document.createElement("object");
type = document.getElementById(e).getAttribute("type");
if(em = document.getElementsByTagName("embed")[0]) {
em.parentNode.removeChild(em)
} else {
if(ob = document.getElementsByTagName("object")[0]) {
ob.parentNode.removeChild(ob)
}
}
if(type == "0" || type == "") {
c.height = "100%";
c.width = "100%";
c.setAttribute("allowScriptAccess", "always");
c.setAttribute("allowfullscreen", "true");
c.src = "http://www.youtube.com/v/" + document.getElementById(e).name;
c.type = "application/x-shockwave-flash";
document.getElementById("player").appendChild(c).style.background = "#000"
}
if(type == "1") {
c.type = "application/x-shockwave-flash";
c.src = "http://video.rutube.ru/" + document.getElementById(e).name;
c.setAttribute("allowfullscreen", "true");
c.setAttribute("wmode", "transparent");
c.height = "100%";
c.width = "100%";
document.getElementById("player").appendChild(c).style.background = "#000"
}
if(type == "2") {
c.type = "application/x-shockwave-flash";
c.src = "http://www.24video.net/player/24.12.08/v24_play.swf";
c.setAttribute("flashvars", "id=" + document.getElementById(e).name + "&idHtml=/video/xml/&idView=/video/view/&rootUrl=http://www.24video.net&playerCode=/video/playerCode/&playerPath=/player/24.12.08/v24_play.swf");
c.setAttribute("allowscriptaccess", "always");
c.setAttribute("allowfullscreen", "true");
c.setAttribute("wmode", "transparent");
c.setAttribute("quality", "high");
c.height = "100%";
c.width = "100%";
document.getElementById("player").appendChild(c).style.background = "#000"
}
if(type == "3") {
c.type = "application/x-shockwave-flash";
c.src = "http://www.openfile.ru/video/player4/player.swf";
c.setAttribute("flashvars", "videoID=" + document.getElementById(e).name);
c.setAttribute("allowscriptaccess", "sameDomain");
c.setAttribute("allowfullscreen", "true");
c.setAttribute("bgcolor", "#000");
c.setAttribute("quality", "high");
c.height = "100%";
c.width = "100%";
document.getElementById("player").appendChild(c).style.background = "#FFF"
}
if(type == "4") {
c.type = "application/x-shockwave-flash";
c.src = "http://whitecdn.org/player/76fb851c2e71150f8f38a1af23c55b86/player.swf";
c.setAttribute("flashvars", "videoID=" + document.getElementById(e).name);
c.setAttribute("allowscriptaccess", "sameDomain");
c.setAttribute("allowfullscreen", "true");
c.setAttribute("bgcolor", "#000000");
c.setAttribute("quality", "high");
c.height = "100%";
c.width = "100%";
document.getElementById("player").appendChild(c).style.background = "#000"
}
if(type == "5") {
d.data = document.getElementById(e).name;
d.setAttribute("frameborder", "none");
d.height = "100%";
d.width = "100%";
document.getElementById("player").appendChild(d).style.background = "#000"
}
}
})(um);