var classFix;
if (document.all){
classFix = "className";
} else {
classFix = "class";}
var columnMode = 2;
var originalHeight;
var currentPos = 0;
var col3Width = 495;
var heightOfColumns = 250;
function getHeight(obj){
if (obj == "window"){
if (window.innerHeight){
return window.innerHeight;
} else {
return document.getElementById("bodyNode").offsetHeight;}
} else {
obj = document.getElementById(obj);
if (obj.offsetHeight){
return obj.offsetHeight;
}}}
function articleSetup(lineHeight,fontSize){
var parentDiv = document.getElementById("articleParent");
var currentPos = 0;
for (var i = 0; i < 2; i++){
var col = document.createElement("div");
col.setAttribute("id", "ac" + i);
col.setAttribute(classFix, "artCol");
parentDiv.appendChild(col);
var obj = document.getElementById("articleBody");
var artText = obj.cloneNode(true);
artText.setAttribute("id", "at" + i);
artText.style.display = "block";
artText.style.top = "0px";
artText.style.fontSize = fontSize + "px";
artText.style.lineHeight = lineHeight + "px";
col.appendChild(artText);}}
function layoutArticles(lineHeight){	
var parentHeight = getHeight("articleParent");
for (var i = 0; i < columnMode; i++){
var obj = document.getElementById("at" + i);
if (parentHeight > (2 * lineHeight)){
obj.style.top = -1 * (parentHeight * (i + currentPos));}}
articlePages(lineHeight);}
function resetArticle(){
currentPos = 0;
layoutArticles(lineHeight);}
function setSnap(mod , lineHeight){
if (mod == null){
mod = 0;}
var snap = lineHeight * Math.round((getHeight("window") - mod) / lineHeight);
if (snap < (lineHeight * 10)){
snap = lineHeight * 10;
if (window.scrollTo){
window.scrollTo(0, 75);}
} else if (window.scrollTo){
window.scrollTo(0, 0);}
return snap;}
function setArticleHeight(lineHeight){
if (columnMode > 1){
if (document.getElementById("articleBody") != null){
document.getElementById("articleParent").style.height = setSnap(heightOfColumns , lineHeight);
var tHeight = getHeight("at1");
parentHeight = getHeight("articleParent");
while ((parentHeight * (currentPos + (columnMode - 1))) > tHeight && currentPos > 0){
currentPos = currentPos - 1;}}}}
function articlePages(lineHeight){
var parentHeight = getHeight("articleParent");
var tHeight = getHeight("at1");
var totalColumns = tHeight / parentHeight;
var totalPages = Math.ceil(totalColumns);
var tPos = (currentPos + columnMode) / columnMode;
var pagesTotal = Math.ceil(totalPages / columnMode);
var pagesCurrent = Math.round(tPos);
var obj = document.getElementById("tc_page_nav_middle");
obj.innerHTML = "" + pagesCurrent + " de " + pagesTotal;
var prevButtonBG = document.getElementById("tc_prev_button_bg");
var prevButtonText = document.getElementById("tc_prev_button_text");
var nextButtonBG = document.getElementById("tc_next_button_bg");
var nextButtonText = document.getElementById("tc_next_button_text");
if (pagesTotal > 1) {
if (pagesCurrent == 1) {
nextButtonText.style.color = "#000";
nextButtonBG.onmouseover = function () {
nextButtonBG.style.backgroundColor = "#e5e5e5";
nextButtonBG.style.cursor = "pointer";}
nextButtonBG.onmouseout = function () {
nextButtonBG.style.backgroundColor = "";}
nextButtonBG.onclick = function () { nextPage(lineHeight); }
prevButtonText.style.color = "#ccc";
prevButtonBG.onmouseover = function () {
prevButtonBG.style.backgroundColor = "";
prevButtonBG.style.cursor = "";}}
if (pagesCurrent > 1 && (pagesCurrent <= pagesTotal)) {
prevButtonText.style.color = "#000";
prevButtonBG.onmouseover = function () {
prevButtonBG.style.backgroundColor = "#e5e5e5";
prevButtonBG.style.cursor = "pointer";}
prevButtonBG.onmouseout = function () {
prevButtonBG.style.backgroundColor = "";}
prevButtonBG.onclick = function () { prevPage(lineHeight); }
if (pagesCurrent == pagesTotal) {
nextButtonText.style.color = "#ccc";
nextButtonBG.onmouseover = function () {
nextButtonBG.style.backgroundColor = "";
nextButtonBG.style.cursor = "";}
} else {
nextButtonText.style.color = "#000";
nextButtonBG.onmouseover = function () {
nextButtonBG.style.backgroundColor = "#e5e5e5";
nextButtonBG.style.cursor = "pointer";}
nextButtonBG.onmouseout = function () {
nextButtonBG.style.backgroundColor = "";}
nextButtonBG.onclick = function () { nextPage(lineHeight); }}}}}
function nextPage(lineHeight){
tHeight = getHeight("at1")
var parentHeight = getHeight("articleParent");
if ((parentHeight * (currentPos + columnMode)) < tHeight){
currentPos = currentPos + columnMode;}
layoutArticles(lineHeight);}
function prevPage(lineHeight){
currentPos = currentPos - columnMode;
if (currentPos < 0){
currentPos = 0;}
layoutArticles(lineHeight);}
function threeColumn(fontSize){
currentPos = 0;
columnMode = 1;
colWidth = col3Width;
if (fontSize > 18){
fontSize = 18;}
var obj2 = document.getElementById("at1");
obj2.style.zIndex = 5;
obj2.style.display = "block";
obj2.style.width = colWidth;
obj2.style.left = colWidth + 20;}
function initArticle(fontSize,lineHeight){
if (document.getElementById("articleBody") != null){
articleSetup(lineHeight,fontSize);
setArticleHeight(lineHeight);
threeColumn(fontSize);
layoutArticles(lineHeight);
} else {
alert("No se pudo encontrar el cuerpo del paginado");}}
function initArticle_2(fontSize,lineHeight){
setArticleHeight(lineHeight);
threeColumn(fontSize);
layoutArticles(lineHeight);
windowResize(lineHeight);}
function windowResize(lineHeight){
setArticleHeight(lineHeight);
layoutArticles(lineHeight);}
window.onresize = windowResize;