
var pagingControls=new Array();var pager_type=new PagerType();function PagerObject(id)
{this.id=id;this.margin=0;this.window_div;this.paging_div;this.container_div;this.total_pages;this.current_page=1;this.leftSrc;this.rightSrc;this.type=pager_type.pagecount;}
function PagerType()
{this.pagecount=1;this.moreprev=2;}
function addPagingControl(id,pagerid,src1,src2,type)
{p=new PagerObject(id);p.leftSrc=src1;p.rightSrc=src2;p.window_div=document.getElementById(id);p.paging_div=document.getElementById(pagerid);if(type!=null)
p.type=type;createContainerDiv(p);createPagingDiv(p);pagingControls.push(p);}
function createContainerDiv(p)
{p.container_div=p.window_div.cloneNode(true);p.window_div.style.overflow="hidden";p.container_div.id="_pagerContainerDiv";p.container_div.removeAttribute("class");p.container_div.style.height="auto";clearNodes(p.window_div);p.window_div.appendChild(p.container_div);}
function clearNodes(node)
{if(node.hasChildNodes())
{while(node.childNodes.length>=1)
{node.removeChild(node.firstChild);}}}
function createPagingDiv(p)
{if(p.total_pages==null)
p.total_pages=Math.ceil(p.container_div.offsetHeight/p.window_div.offsetHeight);if(p.total_pages<=1)
return;makePreviousLink(p);if(p.type==pager_type.pagecount)
makePageInfo(p);makeNextLink(p);}
function makePageInfo(p)
{var pageInformation=document.createElement("span");pageInformation.innerHTML="&nbsp;Page "+p.current_page+" of "+p.total_pages+" ";p.paging_div.appendChild(pageInformation);}
function makeNextLink(p)
{if(p.current_page<p.total_pages)
{var nextLink;if(p.rightSrc==null||p.rightSrc=='')
{nextLink=document.createElement("a");nextLink.innerHTML="&gt;&gt;";}
else
{nextLink=document.createElement("img");nextLink.src=p.leftSrc;nextLink.alt=">>";}
nextLink.style.cursor="pointer";nextLink.onclick=function(){nextPage(p.id);};nextLink.className="PagerNext";p.paging_div.appendChild(nextLink);}}
function makePreviousLink(p)
{if(p.current_page!=1)
{var previousLink;if(p.leftSrc==null||p.leftSrc=='')
{previousLink=document.createElement("a");previousLink.innerHTML="&lt;&lt;";}
else
{previousLink=document.createElement("img");previousLink.alt="<<";previousLink.src=p.rightSrc;}
previousLink.style.cursor="pointer";previousLink.onclick=function(){previousPage(p.id);};previousLink.className="PagerPrevious";p.paging_div.appendChild(previousLink);}}
function nextPage(id)
{var p=findPager(id);setCurrentPage(p);if(p.current_page<p.total_pages)
{p.margin=p.margin-p.window_div.offsetHeight;p.current_page++;p.container_div.style.marginTop=p.margin+"px";updatePages(p);}}
function previousPage(id)
{var p=findPager(id);setCurrentPage(p);if(p.current_page!=1)
{p.margin=p.margin+p.window_div.offsetHeight;p.current_page--;p.container_div.style.marginTop=p.margin+"px";updatePages(p);}}
function updatePages(p)
{clearNodes(p.paging_div);createPagingDiv(p);}
function setCurrentPage(p)
{if(p.total_pages==null)
p.total_pages=Math.ceil(p.container_div.offsetHeight/p.window_div.offsetHeight);p.current_page=p.margin/p.window_div.offsetHeight*-1+1;}
function findPager(id)
{for(var i=0;i<pagingControls.length;i++)
{if(pagingControls[i].id==id)
{return pagingControls[i];break;}}
return new PagerObject(id);}