
//---------------------------------
function buildSelect(pid,id) {
	var selector = document.getElementById(id);
	var selected = selector.selectedIndex;
	var value    = selector.options[selected].value;
 	var myurl =  './ajax/json_get_option_list.php';
 	
 	
 	
 	
 	
 	new Ajax.Request(myurl, {
		method: 'get',
		parameters : {'pid':pid,'id':id,'sel':value},
		onSuccess: function(transport) {
			response = transport.responseJSON;
			var display = '';
			response.each(function(selector) {
				display += selector.sT+"\n";
			    selector.sG.each(function(group){
		    		OptionsClear(group.value);
	       	    });
				options = selector.sO;
				options.each(function(item){
					display += item.oT+"\n";     
					OptionsAdd(selector.sT,item.oV,item.oT);
				});
			});
			
		}
	});
}
//---------------------------------
function OptionsClear(id) {
	
    var element_id = 'ProductOption_'+id;	
    document.getElementById(element_id).options.length = 0;
    OptionsAdd(element_id,'',' - select - ');
}
//---------------------------------
function OptionsAdd(id,value,display) {
	
	selector = document.getElementById(id);
	lgth = selector.options.length - 1;
	selector.options[lgth+1] = new Option(display,value);
}
//---------------------------------
