var num = 10;
var total = 249;
image = new StringArray();

function StringArray() {
  this.length = num;
  for (var i = 0; i < num; i++) {
    this[i] = ' ';
  }
}

function RandImg() {
	for(var i = 0; i < num; i++) {
		index = Math.ceil(Math.random() * total);
		tmp = "chapitas_" + (index < 10 ? "0" : "") + index + ".jpg";
		while(haveNum(tmp)) {
			index = Math.ceil(Math.random() * total);
			tmp = "chapitas_" + (index < 10 ? "0" : "") + index + ".jpg";
		}
		image[i] = tmp;
	}
}

function haveNum(n) {
	for(var i = 0; i < num; i++) {
		if(image[i] == n) {
			return true;
		}
	}
	return false;
}

function display() {
	RandImg();
	for(var i = 0; i < num; ) {
		document.write("<li>");
        	document.write("<div align=\"left\"><img src=\"images/modelos/");
		document.write(image[i]);
		document.write("\" height=\"114\" width=\"111\"><img src=\"images/modelos/");
		document.write(image[i+1]);
		document.write("\" height=\"114\" width=\"111\"></div>");
      		document.write("</li>");
		i = i + 2;
	}
}


