var viewpage=6;
var itemperpage=18;
var column=3;
//Number Format
function number_format( number, decimals, dec_point, thousands_sep ) {
    var n = number, c = isNaN(decimals = Math.abs(decimals)) ? 2 : decimals;
    var d = dec_point == undefined ? "," : dec_point;
    var t = thousands_sep == undefined ? "." : thousands_sep, s = n < 0 ? "-" : "";
    var i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0;
    
    return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
}
//End Of Number Format

function ShowProducts(first, last){
	var pagedata="";
	var columndivider="<td width=\"7\" align=\"center\" valign=\"middle\"><img src=\"http://iovistacommerce.com.p2.hostingprod.com/ystore/inhouse/advance-pagination/spacer.gif\" width=\"7\" height=\"1\"></td>";
	
	var rowdivider="<td align=\"left\" valign=\"top\"><table width=\"710\" border=\"0\" align=\"left\" cellpadding=\"0\" cellspacing=\"0\"><tr><td align=\"left\" valign=\"top\" class=\"pro-hr-grey-line\"><img src=\"http://battledressuniform.com.p.hostingprod.com/ystore/images/spacer.gif\" alt=\"\" width=\"1\" height=\"27\" border=\"0\" /></td><td width=\"7\" align=\"left\" valign=\"top\"><img src=\"http://battledressuniform.com.p.hostingprod.com/ystore/images/spacer.gif\" alt=\"\" width=\"7\" height=\"1\" border=\"0\" /></td><td align=\"left\" valign=\"top\" class=\"pro-hr-grey-line\"><img src=\"http://battledressuniform.com.p.hostingprod.com/ystore/images/spacer.gif\" alt=\"\" width=\"1\" height=\"27\" border=\"0\" /></td><td width=\"7\" align=\"left\" valign=\"top\"><img src=\"http://battledressuniform.com.p.hostingprod.com/ystore/images/spacer.gif\" alt=\"\" width=\"7\" height=\"1\" border=\"0\" /></td><td align=\"left\" valign=\"top\" class=\"pro-hr-grey-line\"><img src=\"http://battledressuniform.com.p.hostingprod.com/ystore/images/spacer.gif\" alt=\"\" width=\"1\" height=\"27\" border=\"0\" /></td></tr></table></td>";
	
	var cldatastart="<tr><td><table align=\"left\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr>";
	var	cldataend="</table></td></tr>";

var row=(last-first)/column;
var temp=Math.round(row);
if (row <= temp){
row=temp;
}else{
row= temp + 1;
}

for(c=0; c < row; c++){
	var probox="";
	var temp=first;
	var temp= temp + (column * c);
	for(r=0; r < column; r++){
		var pronum=temp + r;
		if(pronum < totalpro){
		//alert(pronum);
		
		var pronum=parseInt(pronum);
		if(pronum >totalpro){break}
		var name=myArray[pronum][0]; 
		var itemlink=myArray[pronum][1]; 
		var proid=itemlink;
		itemlink=itemlink+".html";
		var image=myArray[pronum][2]; 
		var quickview=myArray[pronum][3]; 
		var newitem=myArray[pronum][4]; 
		var hotitem=myArray[pronum][5];
		var saleitem=myArray[pronum][6];
		var price=myArray[pronum][7];
		var price=number_format(price, 2, '.', '');
		var saleprice=myArray[pronum][8];
		var saleprice=number_format(saleprice, 2, '.', '');
		var yousave=myArray[pronum][9];
		var yousave=number_format(yousave, 2, '.', '');
		if(yousave > 0){
			yousave="<br/>("+ yousave +"% Off)";
			}
		
		
		if(price > 0 && saleprice > 0){
			var pricedetail="<tr><td><img src=\"http://battledressuniform.com.p.hostingprod.com/ystore/images/spacer.gif\" alt=\"\" width=\"1\" height=\"4\" border=\"0\" /></td></tr><tr><td align=\"left\" valign=\"top\" class=\"pro-price\">Regular price: <s>$"+ price +"</s></td></tr><tr><td align=\"left\" valign=\"top\" class=\"pro-saleprice\">Sale price: <strong>$"+ saleprice +"</strong>"+ yousave +"</td></tr>";
			}else if(price > 0){
				var pricedetail="<tr><td><img src=\"http://battledressuniform.com.p.hostingprod.com/ystore/images/spacer.gif\" alt=\"\" width=\"1\" height=\"4\" border=\"0\" /></td></tr><tr><td align=\"left\" valign=\"top\" class=\"pro-saleprice\">Sale price: <strong>$"+ price +"</strong></td></tr>";
				}else if(saleprice > 0){
					var pricedetail="<tr><td><img src=\"http://battledressuniform.com.p.hostingprod.com/ystore/images/spacer.gif\" alt=\"\" width=\"1\" height=\"4\" border=\"0\" /></td></tr><tr><td align=\"left\" valign=\"top\" class=\"pro-saleprice\">Sale price: <strong>$"+ saleprice +"</strong></td></tr>";
					}else if (price == "" && price == ""){
						var pricedetail="";
						}
		
		//probox = probox + "<td class=\"productbox\" width=\"178\">"+ pronum +"Name="+ proname "</td>";
		if(newitem=="yes"){
		var prnewitem="<img src=\"http://battledressuniform.com.p.hostingprod.com/ystore/images/new.gif\" width=\"28\" height=\"17\" />";	
		}else{var prnewitem="";}
		if(hotitem=="yes"){
		var prhotitem="<img src=\"http://battledressuniform.com.p.hostingprod.com/ystore/images/hot.gif\"/>";	
		}else{var prhotitem="";}
		if(saleitem=="yes"){
		var prsaleitem="<img src=\"http://battledressuniform.com.p.hostingprod.com/ystore/images/sale.gif\"/>";	
		}else{var prsaleitem="";}
		
		probox = probox + "<td width=\"224\" align=\"left\" valign=\"top\" class=\"pro-box\"><table width=\"224\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td align=\"left\" valign=\"top\" class=\"pro-name-area\" ><table width=\"126\" border=\"0\" align=\"left\" cellpadding=\"0\" cellspacing=\"0\"><tr><td height=\"88\" align=\"left\" valign=\"top\" class=\"pro-name\"><a href=\""+ itemlink +"\">"+ name +"</a></td></tr><tr><td height=\"16\" align=\"left\" valign=\"top\"><a href=\""+ itemlink +"\"><img src=\"http://battledressuniform.com.p.hostingprod.com/ystore/images/details-img.jpg\" alt=\"\" width=\"44\" height=\"10\" border=\"0\" /></a></td></tr></table></td><td width=\"91\" align=\"center\" valign=\"middle\" class=\"fp-pro-img-area\"><table border=\"0\" cellspacing=\"0\" align=\"center\" cellpadding=\"0\"><tr><td class=\"load-img\"><a href=\""+ itemlink +"\"><img src=\""+ image +"\" alt=\"\" border=\"0\" /></a>"+ prnewitem +"</td></tr></table></td></tr></table></td>";

		
		}
		
		if(r < (column-1)){
		probox = probox + columndivider;
		}

	}
	pagedata = pagedata + cldatastart + probox + cldataend + rowdivider ; 
}
pagedata="<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"+ pagedata +"</table>";
WriteData("paging", pagedata);

}