var cartoonIssue1 = new Array("105","103","102","101","055","099","098","097","056","057","095","058","094","059","060","093","091","089","088","087","085","083","082","081","080","079","077","076","075","074","073","072","070","069","068","067","066","065","064","063","062");

var thisPage = 0;
var rowWidth = 6; // num of icons in a row
var cartoonMatrix = new Array();

numRow = Math.ceil(cartoonIssue1.length / rowWidth);

var i=0;

  for (j=0;j<numRow;j++) {
      cartoonMatrix[j] = new Array();
      
    for (k=0;k<rowWidth;k++) {
      
      cartoonMatrix[j][k] = cartoonIssue1[i];  
      
      if (i+1 >= cartoonIssue1.length) {
        break;
      } else {
        i++;
      }
    }
  }

/*
//print cartoonMatrix for testing
 var result = ""
for (x=0;x<cartoonMatrix.length;x++) {
  result = result +"+"+ cartoonMatrix[x];
}
//  alert("Page no. " +result);
*/

function showThisPage() {
  document.write(thisPage);
}

function nextPage() {
	var thisPage= parseInt(document.getElementById("rownum").value);
	if (thisPage < numRow-1) {
 		document.getElementById("rownum").value= parseInt(document.getElementById("rownum").value) + 1;
	}
//  alert("Page no. " + thisPage + ", ID = " +"row"+thisPage+ ", rno " +document.getElementById("rownum").value + ", Total p. = " +cartoonMatrix.length);

  if (thisPage+2 == cartoonMatrix.length) {
    document.getElementById('cartoon_next').style.display = "none";
    document.getElementById('cartoon_next0').style.display = "block";
  } 

  document.getElementById("cartoon_prev").style.display = "block";
  document.getElementById("cartoon_prev0").style.display = "none";

  var cpage="row"+thisPage;
  thisPage++;
  var npage="row"+thisPage;
  document.getElementById(cpage).style.display = "none";
//  thisPage++;
  document.getElementById(npage).style.display = "block";
}

function prevPage() {
	var thisPage= parseInt(document.getElementById("rownum").value);
 	document.getElementById("rownum").value= parseInt(document.getElementById("rownum").value) - 1;
  if (thisPage-1 == 0) {
    document.getElementById("cartoon_prev").style.display = "none";
    document.getElementById("cartoon_prev0").style.display = "block";
  } 

  document.getElementById("cartoon_next").style.display = "block";
  document.getElementById("cartoon_next0").style.display = "none";

  var cpage="row"+thisPage;
  thisPage--;
  var npage="row"+thisPage;
  document.getElementById(cpage).style.display = "none";
  document.getElementById(npage).style.display = "block";

//  document.getElementById("row"+thisPage).style.display = "none";
//  thisPage--;
//  document.getElementById("row"+thisPage).style.display = "block";
}


function showthumbnails(thisPage) {
  for (x=0;x<cartoonMatrix.length;x++) {
  	if (x==thisPage) {
    		idString =  x + "'";
  	} else {
    		idString =  x + "' style='display:none;'";
  	}
  	document.write("<div id=" + "'row"+idString+ " align='center'>");
	for  (y=0;y<cartoonMatrix[x].length;y++) {  
    		document.write("<a href=javascript:switchCartoon('"+cartoonMatrix[x][y]+"')><img src='images/preview"+cartoonMatrix[x][y]+".jpg' width=92 height=104 border=0 style='" +opacityStyle(0.4)+ "' onMouseOver='" +changeOpacity(1)+ "' onMouseOut='" +changeOpacity(0.4)+ "'></a>");
  	}
  	document.write("</div>");
  }
}


