var UIContents = {
    contentsArea : null,		// UIContents Div
    categoryTitle : null,		// Category title Div
    articleTitle : null,		// Article title Div
    articleDescription : null,	// Article description Div
    scrollBar : null,			// Scroll bar Div
    scrollBead : null,			// Scroll bead Div
    SCROLLBAR_SIZE : 412,		// scroll bar length
    dataObj : null,				// Data object
}

UIContents.create = function() {
    this.contentsArea = document.getElementById("UIContents");
    this.categoryTitle = document.getElementById("UIContentsCategoryTitle");
    this.articleTitle = document.getElementById("UIContentsTitle");
    this.articleDescription = document.getElementById("UIContentsDescription");
    this.scrollBar = document.getElementById("UIContentsScrollBar");
    this.scrollBead = document.getElementById("UIContentsScrollBead");
}

UIContents.show = function() {
	this.articleDescription.scrollTop = '0';
    this.contentsArea.style.display = "block";
    this.fillCategoryTitle();
    this.fillArticleTitle();
    this.fillDescription();
    KeyHandler.focusToContents();
}

UIContents.refresh = function() {
	this.articleDescription.scrollTop = '0';
    this.fillCategoryTitle();
    this.fillArticleTitle();
    this.fillDescription();
}

UIContents.hide = function() {
    this.contentsArea.style.display = "none";
    KeyHandler.focusToKeyBlocker();
}

UIContents.setDataObj = function(pDataObj) {
    this.dataObj = pDataObj;
}

UIContents.fillCategoryTitle = function() {
    this.categoryTitle.innerHTML = '<h4>'+this.dataObj.categoryTitle+'</h4><span>'+ISSUE_NAME+'</span>';
}

UIContents.fillArticleTitle = function() {
    this.articleTitle.innerHTML = Util.wrapInTable(this.dataObj.article.title, "", "UIConentsTitle_style");
}

UIContents.fillDescription = function() {
    this.articleDescription.innerHTML = this.dataObj.article.content + "<a id='UIContentsDescriptionAnchor' href=javascript:>&nbsp</a>";
    KeyHandler.focusToContents();
}

UIContents.adjustScrollBar = function() {
    var scrollTop = this.articleDescription.scrollTop;
    var scrollHeight = this.articleDescription.scrollHeight;
    var offsetHeight = this.articleDescription.offsetHeight;

    if (scrollHeight <= offsetHeight) {
        this.hideScrollBar();
    }
    else {
        var position = parseInt((this.articleDescription.scrollTop)/(this.articleDescription.scrollHeight-this.articleDescription.offsetHeight) * this.SCROLLBAR_SIZE);
        this.scrollBead.style.top = position + "px";
        this.showScrollBar();
    }
}

UIContents.showScrollBar = function() {
    this.scrollBar.style.display = "block";
}

UIContents.hideScrollBar = function() {
    this.scrollBar.style.display = "none";
}







