$(document).ready(function(){
	$("select[@name=material]").change( function(){
		if(this.selectedIndex == 0){ // populate all
			populate_all();
		}else{
			populate(this.value);
		}
	});
});


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


function populate(one){
	var it = items.popup[one][0].colors;
	var c = document.getElementById("colors");
	c.length=0;
	ca = it.split(',');
	c[c.length] = new Option(' - all colors *','');
	for(i=0;i<ca.length;i++){
		c[c.length] = new Option(ca[i].split(":")[1],ca[i].split(":")[0]);
	}
	it = items.popup[one][1].conditions;
	c = document.getElementById("conditions");
	c.length=0;
	ca = it.split(',');
	c[c.length] = new Option(' - all conditions *','');
	for(i=0;i<ca.length;i++){
		c[c.length] = new Option(ca[i].split(":")[1],ca[i].split(":")[0]);
	}
}
function populate_all(){
	var it = items.popup.all[0].colors;
	var c = document.getElementById("colors");
	c.length=0;
	ca = it.split(',');
	c[c.length] = new Option(' - all colors -','');
	for(i=0;i<ca.length;i++){
		c[c.length] = new Option(ca[i].split(":")[1],ca[i].split(":")[0]);
	}
	it = items.popup.all[1].conditions;
	c = document.getElementById("conditions");
	c.length=0;
	ca = it.split(',');
	c[c.length] = new Option(' - all conditions -','');
	for(i=0;i<ca.length;i++){
		c[c.length] = new Option(ca[i].split(":")[1],ca[i].split(":")[0]);
	}
}