function easeInOut(minValue, maxValue, totalSteps, actualStep, powr) {
            var delta = maxValue - minValue;
            var stepp = minValue + (Math.pow(((1 / totalSteps) * actualStep), powr) * delta);
            return Math.ceil(stepp)
        } 
        function addEvent(a, b, c) {
            if (a.addEventListener) { a.addEventListener(b, c, false); }
            else if (a.attachEvent) {
                a.attachEvent("on" + b, c);
            }
            else { a.setAttribute("on" + b, c); }
        }
        function ce(a, b) { var c = document.createElement(a); if (b) { c.className = b }; return c; }
        function sa(a, b, c) { a.setAttribute(b, c) }
        function ge(a) { return document.getElementById(a)}
            function WCOOPWinners() {
            var ItemWidth = 108;
            
            this.Container = null;
            this.TotalWidth = null;
            this.CurrentX = 0;
            this.ScrollPane = ce("div", "hpWinnersScrollPane");
            this.animate = function(a) {
                if (objWCOOPWinners.CurrentX > 0) { objWCOOPWinners.CurrentX = 0 }
                if (a > 0) {
                    b = objWCOOPWinners.CurrentX;
                    var endLeft = b + a;
                    objWCOOPWinners.CurrentX = endLeft;
                    if (endLeft >= 0) { endLeft = 0 }
                    MoveIt(objWCOOPWinners.ScrollPane, b, endLeft, 50, 5, 1);
                } else {
                    b = objWCOOPWinners.CurrentX;
                    var endLeft = b + a
                    objWCOOPWinners.CurrentX = endLeft;
                    if (endLeft <= (objWCOOPWinners.TotalWidth - a)) { endLeft = objWCOOPWinners.TotalWidth - a; objWCOOPWinners.CurrentX = endLeft; }
                    MoveIt(objWCOOPWinners.ScrollPane, b, endLeft, 50, 5, 1);
                }
            };
            this.init = function() {
                this.Container = document.getElementById("hpWinnersContainer");
                if (this.Container) {
                    var a = this.Container.getElementsByTagName("div");
                    this.CurrentX = 0;
                    var colWinners = []; for (i = 0, il = a.length; i < il; i++) { colWinners[colWinners.length] = a[i] }
                    this.TotalWidth = colWinners.length * ItemWidth * -1;
                    this.ScrollPane.style.width = (this.TotalWidth * -1) + "px";
                    this.ScrollPane.style.left = 0;
                    var leftArrow = ce("div", "hpWinnersLeftArrow");
                    addEvent(leftArrow, "click", function() { objWCOOPWinners.animate(540) })
                    var rightArrow = ce("div", "hpWinnersRightArrow");
                    addEvent(rightArrow, "click", function() { objWCOOPWinners.animate(-540) })
                    var PaneContainer = ce("div", "hpWinnersScrollerContainer");
                    for (i in colWinners) { this.ScrollPane.appendChild(colWinners[i]) }
                    PaneContainer.appendChild(this.ScrollPane);
                    this.Container.appendChild(leftArrow);
                    this.Container.appendChild(PaneContainer);
                    this.Container.appendChild(rightArrow);
                }

            }
            function MoveIt(elem, startLeft, endLeft, steps, intervals, powr) {
                if (elem.leftChangeMemInt)
                    window.clearInterval(elem.leftChangeMemInt);
                var actStep = 0;
                elem.leftChangeMemInt = window.setInterval(
	                function() {
	                    elem.currentLeft = easeInOut(startLeft, endLeft, steps, actStep, powr);
	                    elem.style.left = elem.currentLeft + "px";
	                    actStep++;
	                    if (actStep > steps) window.clearInterval(elem.leftChangeMemInt);
	                }
	            , intervals)
            }

        }
        var objWCOOPWinners = new WCOOPWinners();

        function WCOOPCoverage() {
            function hpBlogItem(a) {
                this.Title = a.title;
                this.Post = a.post;
                this.Date = a.date;
                this.link = a.link;
                this.Div = ce("div", "newsItem");
                this.CreateElement = function() {
                    var myH4 = ce("h3");
                    var tL = ce("a");
                    sa(tL, "href", this.link);
                    sa(tL, "target", "_blank");
                    tL.appendChild(document.createTextNode(this.Title))
                    myH4.appendChild(tL);
                    var myDate = ce("p", "date");
                    myDate.appendChild(document.createTextNode(this.Date));
                    var myPost = ce("p");
                    var tPost = (this.Post.length > 200) ? this.Post.substring(0, 200) : this.Post;
                    tPost = tPost.substring(0, tPost.lastIndexOf(" ")) + "...";
                    myPost.appendChild(document.createTextNode(tPost))
                    this.Div.appendChild(myDate);
                    this.Div.appendChild(myH4);
                    this.Div.appendChild(myPost);
                }
        }
        this.BlogContainer = null;
            this.BottomBlog = null;
            this.Blogs = null;
            this.FilePrefix = "http://www.pokerstarsblog.com/tournaments/wcoop/";
            this.DataFiles = [this.FilePrefix + "entries.js"]
            this.init = function() {
            this.BlogContainer = ge("hpNewsItem");
			this.BlogContainer.innerHTML="";
                this.attachJSON()
            }
            this.DataFileIndex = 0
            this.RenderBlog = function(a) {
                if (this.DataFileIndex === 0) {
                    for (i = 0; i < 2; i++) {
                        var BlogPost = new hpBlogItem(a[i]);
                        BlogPost.CreateElement();
                        this.BlogContainer.appendChild(BlogPost.Div);
                    }
                    this.BlogContainer.appendChild(ce("div", "clear"))
                } else {
                    var mB = ce2("div", "flexcroll", "BlogPostContainer")
                    for (i = 0, il = a.length; i < il; i++) {
                        var bPost = new BlogPost(a[i]);
                        bPost.CreateElement();
                        mB.appendChild(bPost.Div)
                    }
                    this.Blogs.appendChild(mB)
                    $(mB).jScrollPane({ showArrows: true, scrollbarWidth: 15, reinitialiseOnImageLoad: true });
                }
            }

            this.attachJSON = function() {
                var fileref = ce('script');
                sa(fileref, "type", "text/javascript");
                sa(fileref, "src", this.DataFiles[this.DataFileIndex]);
                document.getElementsByTagName("head")[0].appendChild(fileref);
            } 
        }
        var objBlogs = new WCOOPCoverage();
		function VideoScanner() {
        function ge(a) { return document.getElementById(a) }
        function changeVideo(b) {
            objVideoScanner.MainDiv.innerHTML = "";
            var newDiv = document.createElement("div")
            //newDiv.setAttribute("id", "MainVideoInnerContainer");
            newDiv.id = "MainVideoInnerContainer";
            objVideoScanner.MainDiv.appendChild(newDiv);
            swfobject.embedSWF("http://player.videojuicer.com/bootstrap.swf", "MainVideoInnerContainer", objVideoScanner.MainWidth, objVideoScanner.MainHeight, "7.0.0", false, { AUTOPLAY: "0", seed_name: "pokerstars", presentation_id: "" + b }, { wmode: "transparent", allowFullScreen: "true", allowscriptaccess: "always" });
        }
        var mD = "hpMainVideoContainer", mC = "hpOtherVideosContainer";
        this.MainDiv = null;
        this.Container = null;
        this.MainHeight=null;
        this.MainWidth = null;
        this.colVideoLinks = null;
        this.init = function() {
            this.MainDiv = ge(mD);
            this.MainHeight = this.MainDiv.scrollHeight;
            this.MainWidth = this.MainDiv.scrollWidth;
            this.VideoList = ge(mC);
            if (!this.MainDiv | !this.VideoList) { return; }
            this.colVideoLinks = this.VideoList.getElementsByTagName("a");
            for (var i = 0, il = this.colVideoLinks.length; i < il; i++) {
                var thisLink = this.colVideoLinks[i];
                var thisID = thisLink.getAttribute("href").substr(46, 4);
                addEvent(thisLink, "click", (function(thisID) {
                    return function(e) {
                        changeVideo(thisID);
                        if (objVideoScanner.colVideoLinks) {
                            for (var i = 0, il = objVideoScanner.colVideoLinks.length; i < il; i++) {
                                var cLink = objVideoScanner.colVideoLinks[i];
                                newClass = cLink.parentNode.className.replace(/ active/ig, "")
                                cLink.parentNode.className = (thisID === cLink.getAttribute("href").substr(46, 4)) ? newClass + ' active' : newClass;
                            }
                        }
                        if (e.preventDefault) { e.preventDefault(); return false } else { return false }
                    }
                })(thisID))

            }
            if (this.colVideoLinks[0]) {
                var t = this.colVideoLinks[0];
                changeVideo(t.getAttribute("href").substr(46, 4));
                newClass = t.parentNode.className.replace(/ active/ig,'');
                newClass = newClass + " active";
                t.parentNode.className = t.parentNode.className + " active";
            }
        }
    }
var objVideoScanner = new VideoScanner();
        function psRenderBlogs(a) { objBlogs.RenderBlog(a.blogs); }
        addEvent(window, 'load', function () { objWCOOPWinners.init(); objBlogs.init(); objVideoScanner.init() })
        function cE(a, b) { var c = document.createElement(a); if (b) { sO(c, b) }; return c; };
        function sO(a, b) { if (b.opacity) { b.MozOpacity = b.opacity / 100; b.KhtmlOpacity = b.opacity / 100; b.filter = "alpha(opacity=" + b.opacity + ")"; b.opacity = b.opacity / 100; b.zoom = 1; } for (var i in b) { if (typeof a[i] === "object") { sO(a[i], b[i]) } else { a[i] = b[i] } } return a };

        function getXML(a, b, c) {
            var s = this;
            this.XMLHTTP = new ajaxRequest();
            this.Fail = function () { if (c) { eval(c(this.XMLHTTP)); } }
            this.Success = function () { eval(b(this.XMLHTTP)) };
            this.XMLHTTP.onreadystatechange = function () { stateChange(s.XMLHTTP, s); }
            this.XMLHTTP.open("GET", a, true);
            this.XMLHTTP.send(null);
            function stateChange(d, e) { if (d.readyState === 4) { (d.status === 200 | d.status === 0) ? e.Success() : e.Fail() } }
        }
        function ajaxRequest() {
            var activexmodes = ["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"];
            if (window.ActiveXObject) { for (var i = 0; i < activexmodes.length; i++) { try { return new ActiveXObject(activexmodes[i]) } catch (e) { } } }
            else return (window.XMLHttpRequest) ? new XMLHttpRequest() : flase;
        }
        var myI = 0
        var myMatch = null;
        function LoadLeaderBoard() {
            var c = window.location.pathname
            var rx = new RegExp("/de/|/hu/|/nl/|/br/|/es/|/fr/|/pl/|/pt/|/ru/|/se/", "ig");
            myMatch = (c.match(rx)) ? c.match(rx)[0] : null;
            myMatch = (myMatch===null) ? '' : '_' + myMatch.substring(1, 3);
            if(myMatch==="_se"){myMatch="_sv"}
            if(myMatch==="_br"){myMatch="_pt-BR"}
            var t = getXML("/datafeed/events/wcoop-10/leagueTlb"+myMatch+".html", LeaderboardSuccess, LeaderboardFailed);
        }
        function LeaderboardSuccess(a) {
            myDiv = cE("div", { id: "temp1", innerHTML: a.responseText });
            myC = document.getElementById("hpRightColumn");
            myH = myC.getElementsByTagName("h3")[0]
            myH.innerHTML = myH.innerHTML.replace("2009", "2010");
            sO(myC.getElementsByTagName("table")[0], { id: "DeleteMe" })
            cTbl = myC.getElementsByTagName("table")[0];
            toSwap = myDiv.getElementsByTagName("table")[0];
            cTbl.parentNode.insertBefore(toSwap, cTbl);
            myArr = [];
            for (var t in toSwap.getElementsByTagName("tr")) {
                if (myI > 17) { myArr[myArr.length] = toSwap.getElementsByTagName("tr")[t] }
                myI++;
            }
            for (var i = 0, il = myArr.length; i < il; i++) {

                if (myArr[i].parentNode) { myArr[i].parentNode.removeChild(myArr[i]); }
            }
            document.getElementById("DeleteMe").parentNode.removeChild(document.getElementById("DeleteMe"));
            var t1 = getXML("/datafeed/events/wcoop-10/all_summary_include" + myMatch + ".html?3", StatsOk, LeaderboardFailed);
        }
        function LeaderboardFailed(a) {
        }
        function StatsOk(a) {
            var tS = a.responseText;
            myDiv = ce("div", { id: "temp2"});
            myDiv.innerHTML = tS;
            myC = document.getElementById("hpRightColumn");
            cTbl = myC.getElementsByTagName("table")[1];
            cTbl.getElementsByTagName("td")[0].innerHTML = myDiv.getElementsByTagName("td")[3].innerHTML;
            cTbl.getElementsByTagName("td")[1].innerHTML = myDiv.getElementsByTagName("td")[1].innerHTML;
            cTbl.getElementsByTagName("td")[2].innerHTML = myDiv.getElementsByTagName("td")[0].innerHTML;
            var t1 = getXML("/datafeed/events/wcoop-10/summary_include" + myMatch + ".html?3", RenderLatestStats, LeaderboardFailed);
        }
        function RenderLatestStats(a) {
            var rT = a.responseText;
            nH = cE("h4", { innerHTML: "WCOOP 2010" });
            nD = cE("div");
            nD.innerHTML = rT;
            nT = cE("table",{className:"hpAllTimeStats"})
            nT.appendChild(nD.getElementsByTagName("tr")[3])
            nT.appendChild(nD.getElementsByTagName("tr")[1])
            nT.appendChild(nD.getElementsByTagName("tr")[0])

            //sO(mT, { className: "hpAllTimeStats" });
            myC = document.getElementById("hpRightColumn");
            oTbl = myC.getElementsByTagName("h4")[0];
            oTbl.parentNode.insertBefore(nH, oTbl);
            oTbl.parentNode.insertBefore(nT, oTbl);
            
        }
        //addEvent(window, "load", function () { LoadLeaderBoard()});
