var param_COUNT = 14;




function Trim(str)
{
	return (str+'').replace(/^\s*/, '').replace(/\s*$/, '');
}
function HTMLEncode(s)
{
	return (s+'').replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;').replace(/"/g,'&quot;');
}
var buildTimer = null;
function KillBuildTimer()
{
	if (buildTimer)
	{
		clearTimeout(buildTimer);
		buildTimer = null;
	}
}
function clsProduct(args)
{
	this.proCode= args[0];
	this.proName= args[1];
	this.proPic = args[2];
	this.proPdf = args[3];
	this.catCode = args[4];
	this.catName = args[5];
	this.seriesCode = args[6];
	this.seriesName = args[7];
	this.apps = args[8];
	this.params = new Array(10);
	var a =0;
	for(i=10;i<18;i++)
	{
		
		this.params[a] = args[i];
		a++;
	}
	this.mainCatCode = args[21];
	this.mainCatName=args[22];
}
function clsProductPool()
{
	this.Products = new Array();
}

clsProductPool.prototype.add = function()
{
	this.Products[this.Products.length] = new clsProduct(arguments);
}

var productPool = new clsProductPool();	


var proList = new Array();
var currentPage;
function showPage()
	{
		var pageSize=12;
		var totalRecord = proList.length;
		if(!currentPage||currentPage<=0)
			currentPage="1";			
		var totalPage= Math.round(totalRecord/pageSize);
		if(totalPage*pageSize<totalRecord)
		{
			totalPage++;
		}
		if(currentPage>totalPage)
			currentPage = totalPage;
		var splitPage ='<a href="#" onclick="show(currentPage-1)"><img src="/images/pre.gif" border="0" align="absmiddle"></a>&nbsp;';
		
		var ig = Math.round(currentPage/10);
		if(ig*10>currentPage)
			ig=ig-1;
		for(p=(ig*10)==0?1:ig*10-1;p<(ig+1)*10+1&&p<totalPage+1;p++)
		{
			if(currentPage==p)
				splitPage+='&nbsp;<font color="red"><b>'+p+'</b></font>&nbsp;';
			else
				splitPage+='<a href="#" onclick="show('+p+')">&nbsp;'+p+'&nbsp;</a>';	
			
		}
				
		splitPage +='&nbsp;<a href="#" onclick="show(currentPage+1)"><img src="/images/next.gif" border="0 " align="absmiddle"></a>';

		if(totalRecord==0||totalPage==1)
			splitPage="";
		el=document.getElementById('PageList');
		if (el) el.innerHTML=splitPage;
		
	}
	function show(cPage){
		if(proList.length<1)
		{
			el=document.getElementById('ContList');
			if (el) el.innerHTML="";
		}
		if(cPage)
			currentPage= cPage;
		var pageSize=12;
		var totalRecord = proList.length;
		if(!currentPage||currentPage<=0)
			currentPage="1";			
		var totalPage= Math.round(totalRecord/pageSize);
		if(totalPage*pageSize<totalRecord)
		{
			totalPage++;
		}
		if(currentPage>totalPage)
			currentPage = totalPage;
		var end = currentPage*pageSize;
		if(end>totalRecord)
			end=totalRecord;
		var sPage="";
		for(l=(currentPage-1)*pageSize;l<end;l++)
		{
			if(proList[l])
				sPage+=proList[l];
		}
		if(totalRecord==0)
			sPage="";	
		el=document.getElementById('ContList');
		if (el) el.innerHTML=sPage;
		showPage();		
	}
