/*************************
v1.0
*************************/

  		function pload() 
  		{
  			//var myTables = getElementsByClassName('paging', 'table', document);
  			
  			//for(var i in myTables ) 
			//{
				//alert("pshow" + i);
				//myTables[i].id = "p"+1
				//pshow1( myTables[i].id, 1, 4 );
			//}

		}
		
		function pinit(tableID, pmax) 
  		{
			pshow1( tableID, 1, pmax );
		}

  		function pshow1( tableID, thePage, pmax ) 
  		{
			//alert(tableID);
			var theTable = document.getElementById(tableID);
  			var myRows = theTable.getElementsByTagName('tr');

			var i=1;
			var currentPage=1;
			
			//alert(myRows);
			
			//alert(myRows[0].style.display)
			
			//theTable.style.display = "table"; //Show Table
			
						theTable.style.visibility = "visible";
			
			//myRows[0].style.display = ""; //Show Header
  			
  			for(var x=1; x<=myRows.length-1; x++) 
			{
				
				if (currentPage==thePage )
				{
					//alert("show" + x);
					myRows[x].style.display = ""; //Show
					//alert("links" + x);
					if (i==1)
					{
						setLinks1(theTable, thePage, myRows.length, pmax );
					}
					
				}else
				{
					//alert("hide" + x);
					myRows[x].style.display = "none";	//Hide
				}
				
				//alert("i is: " + i);
				if (i==pmax)
				{
					currentPage++;
					i=0;
				}
				i++;
			}
			
			//alert("f pload");
		}
		
		
  		function setLinks1( theTable, thePage, ptotal, pmax ) 
  		{
			
			var strLinks = genLinkString( theTable.id, thePage, ptotal, pmax );
			//alert(strLinks);
			setLinks( theTable.parentNode, strLinks );

		}
		
		function setLinks( el, strLinks ) 
  		{
			var arr = el.childNodes
			
			//alert("here");
			
			for(var i=0; i<arr.length-1; i++ ) 
			{
				//alert("h:" + i);
				if(arr[i].className=="links")
				{
					arr[i].innerHTML = strLinks;
					
				}
				
				setLinks( arr[i], strLinks ) 
			}
			
			//alert("done");
		}
		

		
  		function genLinkString( tableID, thePage, ptotal, pmax ) 
  		{
			var strLink = "<a href=\"javascript:pshow1(\'{0}\',\'{1}\',\'{2}\')\" >{3}</a> ";
			var strLinks = "Page - ";
  			var pageNo = ptotal / pmax;
			//alert("links2c:" + pageNo);
			
  			for(var i=1; i<=pageNo; i++) 
			{
				if ( i == thePage )
				{
					strLinks += " " + i + " "; 
					
				}else
				{
					strLinks += fString( strLink, tableID, i, pmax, i );
				}
				
			}
			
			//alert(strLinks);
			//return "<a href=\"javascript:pshow1(\'1\',\'1\')\" >test</a>";
			return strLinks
		}
		
		
		
		