var rpp = 40;
var c1 = "#E0FFC1";
var c2 = "#FFFFFF";

function getlinks() {
	p_num=1;
	document.write("<tr><td>"); 
	for (i=0; i<x.length/rpp;i++) {
	offset = p_num * rpp - rpp;
	document.write("<a href='?offset="+offset+"&page_num="+p_num+"'>Page "+p_num+"</a> | "); 
	p_num++;
	}
}

document.write('Displaying offers '+(offset+1)+' to '+(offset+rpp)+'<br>');

if (window.XMLHttpRequest)
  {
  xhttp=new XMLHttpRequest();
  }
else // Internet Explorer 5/6
  {
  xhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xhttp.open("GET","offerdata.xml",false);
xhttp.send("");
xmlDoc=xhttp.responseXML; 


var x=xmlDoc.getElementsByTagName("campaign");

if (page_num >= Math.round(x.length/rpp)){ r=x.length%rpp; } else { r=rpp; }


for (i=0;i<r;i++)
  { 
 	 if (i%2 == 0) {  c = c1  } else {  c = c2  }
	 document.write('<tr style="background-color:'+c+'"><td><strong>');
 	 document.write(x[i+offset].getElementsByTagName("name")[0].childNodes[0].nodeValue);
 	 document.write("</strong></td><td><span class='boldgreen'>");
 	 document.write(x[i+offset].getElementsByTagName("id")[0].childNodes[0].nodeValue);
 	 document.write("</span></td></tr>"); 
  }

getlinks();
document.write("</td></tr></table>");

