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 ProBlogPost(a) {
    this.imgPrefix = "http://www.psimg.com/img/pros/whitebg/";
    this.imgPostfix = ".jpg";
    this.Title = a.title;
    this.Post = a.post;
    this.Date = a.date;
    this.Player = a.player;
    this.link = a.link;
    this.Div = ce("div", "ProBlogPost");
    this.CreateElement = function() {
        var LeftDiv = ce("div", "left");
        var RightDiv = ce("div", "right");
		var ProLink = ce("a");
		sa(ProLink,"href", "http://www.pokerstars.eu/team-pokerstars/" + this.Player + "/")
        sa(ProLink, "target", "_blank");
        var myImg = ce("img");
        sa(myImg, "src", this.imgPrefix + this.Player + this.imgPostfix);
		sa(myImg, "alt", this.Player);
		ProLink.appendChild(myImg);
        LeftDiv.appendChild(ProLink);
        var myH3 = ce("h3");
        var tL = ce("a");
        sa(tL, "href", this.link);
        sa(tL, "target", "_blank");
        tL.appendChild(document.createTextNode(this.Title))
        myH3.appendChild(tL);
        RightDiv.appendChild(myH3);
        var myDate = ce("div", "date");
        myDate.appendChild(document.createTextNode(this.Date));
        RightDiv.appendChild(myDate);
        var myArticle = ce("div", "article");
        tPost = (this.Post.length > 160) ? this.Post.substring(0, 160) : this.Post;
        tPost = tPost.substring(0, tPost.lastIndexOf(" ")) + "...";
        myArticle.appendChild(document.createTextNode(tPost));
        RightDiv.appendChild(myArticle);
        var cDiv = ce("div", "clear");
        this.Div.appendChild(LeftDiv);
        this.Div.appendChild(RightDiv);
        this.Div.appendChild(cDiv);
    }
}
function BlogPost(a) {
    this.Title = a.title;
    this.Date = a.date;
    this.link = a.link;
	this.post = a.post;
    this.Div = ce("div", "BlogList");
    this.CreateElement = function() {
    var myH4 = ce("h4");
        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("div", "date");
        myDate.appendChild(document.createTextNode(this.Date));
        this.Div.appendChild(myDate);
        this.Div.appendChild(myH4);
		var post = ce("div","Post");
		var tPost = (this.post.length > 100) ? this.post.substring(0, 100) : this.post;
        tPost = tPost.substring(0, tPost.lastIndexOf(" ")) + "...";
		post.innerHTML=tPost;
		this.Div.appendChild(post);
    }
}

function ce(a, b) {var c = document.createElement(a); c.className=(!b)?'':b ; return c }
function sa(a, b, c) { a.setAttribute(b, c); }
function ge(a) { return document.getElementById(a); }
function ce2(a, b, c) { var d = document.createElement(a); d.className = (!b) ? '' : b;d.setAttribute('id', c);  return d }
function WCOOPCoverage() {
    this.TopBlog = null;
    this.BottomBlog = null;
    this.Blogs = null;
    this.FilePrefix = "http://www.pokerstarsblog.com/tournaments/wcoop/";
    this.DataFiles = [this.FilePrefix + "team-pro-articles/entries.js", this.FilePrefix + "entries.js"]
    this.init = function() {
        this.TopBlog = ge("TopBlog");
        this.BottomBlog = ge("BottomBlog");
        this.Blogs = ge("BlogPosts");
        this.attachJSON()
    }
    this.DataFileIndex = 0
    this.RenderBlog = function(a) {
        if (this.DataFileIndex === 0) {
            for (i = 0; i < 4; i++) {
                var ProPost = new ProBlogPost(a[i]);
                ProPost.CreateElement();
                (i < 2) ? this.TopBlog.appendChild(ProPost.Div) : this.BottomBlog.appendChild(ProPost.Div);
            }
            this.BottomBlog.appendChild(ce("div", "clear"))
            this.DataFileIndex += 1;
            this.attachJSON();
        } 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);
} 
}
objWCOOPCoverage = new WCOOPCoverage()
function psRenderBlogs(a) {objWCOOPCoverage.RenderBlog(a.blogs); }
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 = "coverageVideo", mC = "VideoListItems";
        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();
addEvent(window, 'load', function() { objWCOOPCoverage.init();objVideoScanner.init(); })
