function createElements(rnum){
	var ncont = document.getElementById("cross-n");
	var icont = document.getElementById("cross-i");
	var pcont = document.getElementById("cross-p");
	var scont = document.getElementById("cross-s");
	var ycont = document.getElementById("cross-y");
	
	var spcr = document.createElement("td");
	spcr.className = "crossspcr";
	spcr.setAttribute("rowspan",5);
	
	/* create name element */
	var namecont = document.createElement("td");
	namecont.className = "crossname";
	var namelink = document.createElement("a");
	namelink.setAttribute("href",itemlist[rnum][1]);
	var itemname = document.createTextNode(itemlist[rnum][0]);
	namelink.appendChild(itemname);
	namecont.appendChild(namelink);				
	ncont.appendChild(namecont);
				
	/* create image element */
	var imagecont = document.createElement("td");
	imagecont.className = "crossimg";
	var imglink = document.createElement("a");
	imglink.setAttribute("href",itemlist[rnum][1]);
	var img = document.createElement("img");
	img.setAttribute("src",itemlist[rnum][2]);
	imglink.appendChild(img);
	imagecont.appendChild(imglink);
	icont.appendChild(imagecont);
					
	/* create price element */
	var pricecont = document.createElement("td");
	var pricespan = document.createElement("span");
	pricespan.className = "crossprice";
	var pricetxt = document.createTextNode(itemlist[rnum][6]);
	var pricemon = document.createTextNode(itemlist[rnum][3]);
	pricecont.appendChild(pricespan);
	pricecont.appendChild(pricemon);
	pricespan.appendChild(pricetxt);
	pcont.appendChild(pricecont);
				
	/* check for saleprice then create element */
	var salepricecont = document.createElement("td");
	if(itemlist[rnum][4]!= " "){
		var salepricespan = document.createElement("span");
		salepricecont.className = "crosssaleprice";
		salepricespan.className = "crosssalespan";
		var salepricetxt = document.createTextNode(itemlist[rnum][7]);
		var salepricemon = document.createTextNode(itemlist[rnum][4]);
		salepricecont.appendChild(salepricespan);
		salepricecont.appendChild(salepricemon);
		salepricespan.appendChild(salepricetxt);
	}
	scont.appendChild(salepricecont);
				
	/* create you save element */
	var yousavecont = document.createElement("td");
	yousavecont.className = "crossyousave";
	var yousave = document.createTextNode(itemlist[rnum][5]);
	yousavecont.appendChild(yousave);
	ycont.appendChild(yousavecont);	
}


function generateRandom(){
	var totalnum = itemlist.length;
	if(totalnum){		
		var numchop = Math.ceil(totalnum/numelms);
		for (var i=0;i<numelms;i++){
			numb = Math.floor(numchop * (i+1));
			/* create start array num */
			incstart = Math.floor(numb - numchop);
			if(incstart>0){
				incend = incend - 1
			}
			/* create end array num */
			incend = Math.floor(numchop * (i+1));
			if(incend > 0 || incend < itemlist.length - 1){
				incend = incend - 1
			}
			if(incend > itemlist.length - 1){
				var offset = incend - (itemlist.length - 1)
				incend = incend - offset;
			}
			var choices = incend - incstart + 1;
			if(incend <= totalnum){
				/* create random number */
				var elmnum = Math.floor(Math.random()* choices + incstart);
				/* pass random num to create elements */
				createElements(elmnum);
			}
		}
	}
}
//alert(incstart + " - " + incend + " -- " + elmnum +" -- " + totalnum);

