// Clones an item and appends it with a new id
function newAddRow(id, parent, source){
	var listParent = document.getElementById(parent);
	var itemToCopy = document.getElementById(id);
	var nextNum = parseInt(id.charAt(id.length - 1)) + 1;
	var itemClone = itemToCopy.cloneNode(true);
	itemClone.id = id.substr(0, (id.length - 1)) + nextNum;
	// Modify link
	var anchors = itemClone.getElementsByTagName('a');
	anchors[0].onclick = function(){ newAddRow(id.substr(0, (id.length - 1)) + nextNum, parent, this); return false; }
	// Modify input value
	var inputs = itemClone.getElementsByTagName('input');
	inputs[0].value = '';
	// Append to parent
	listParent.appendChild(itemClone);
	hideself(source);
}

function hideself(element) {
	element.style.display = 'none';
	element.className = "hidden";
	element.setAttribute("disabled","disabled");  
}

function populate(id, catid){
	//alert("This is the id: " + id);
	var cats = new Array();
	cats["thiscat"] = new Array();
	cats["thiscat"][0] = new Option("Product 1","Product 1");
	cats["thiscat"][1] = new Option("Product 2","Product 2");
	cats["thiscat"][2] = new Option("Product 3","Product 3");
	
	var temp=document.quote.product_list_1;
	for (m=temp.options.length-1;m>0;m--){
		temp.options[m]=null;
	}
	for (i=0;i<cats[catid].length;i++){
		temp.options[i]=new Option(cats[catid][i].text,cats[catid][i].value)
	}
	temp.options[0].selected=true;
}