document.writeln('<script type="text/javascript" src="/pr_data/javascript/string.js"></script>');

var NS4 = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) < 5);

function insert_option(select_object, text, value, is_default_selected, is_selected)
{
	if (is_default_selected == null) {
		is_default_selected = true;
	}
	
	if (is_selected == null) {
		is_selected = true;
	}
	
	var an_option = new Option(text, value, is_default_selected, is_selected);
	var select_object_length = select_object.length;
	select_object.options[select_object_length] = an_option;
}

function unique_insert_sort_option(select_object, text, value, is_default_selected, is_selected)
{
	if (is_default_selected == null) {
		is_default_selected = true;
	}
	
	if (is_selected == null) {
		is_selected = true;
	}
	
	var an_option = new Option(text, value, is_default_selected, is_selected);
	var select_object_length = select_object.length;
	
	var i;
	
	unselect_all(select_object);
	
	if (select_object_length == 0){
		insert_option(select_object, text, value, is_default_selected, is_selected);
		return;
	}
	
	for (i = 0; i < select_object_length; i++){
		if (text < select_object.options[i].text){
			try {
				select_object.add(an_option, select_object.options[i]); // standards compliant; doesn't work in IE
			}
			catch(ex) {
				select_object.add(an_option, i); // IE only
			}
			return;
		} else if (text == select_object.options[i].text) {
			return;
		}
	}
	
	insert_option(select_object, text, value, is_default_selected, is_selected);
	return;
}

function delete_option(select_object, index)
{ 
	var select_object_length = select_object.length;
	if(select_object_length>0)
	{
		select_object.options[index] = null;
	}
}

function move_selected_options(select_object_from, select_object_to)
{
  
	var select_object_from_length = select_object_from.length;
	var selected_texts = new Array();
	var selected_values = new Array();
	var selected_count = 0;
  
	var i;
  
	// Find the selected Options in reverse order
	// and delete them from the 'from' Select.
	for(i=select_object_from_length-1; i>=0; i--)
	{
    	if(select_object_from.options[i].selected)
    	{
			selected_texts[selected_count] = select_object_from.options[i].text;
			selected_values[selected_count] = select_object_from.options[i].value;
			delete_option(select_object_from, i);
			selected_count++;
		}
	}
  
	// Add the selected text/values in reverse order.
	// This will add the Options to the 'to' Select
	// in the same order as they were in the 'from' Select.
	for(i=selected_count-1; i>=0; i--)
	{
		insert_option(select_object_to, selected_texts[i], selected_values[i]);
	}
  
	if(NS4) history.go(0);
}

function copy_selected_options(select_object_from, select_object_to){
	var select_object_from_length = select_object_from.length;
	var selected_texts = new Array();
	var selected_values = new Array();
	var selected_count = 0;
  
	var i;
  
	// Find the selected Options in reverse order
	// and delete them from the 'from' Select.
	for(i=select_object_from_length-1; i>=0; i--)
	{
    	if(select_object_from.options[i].selected)
    	{
			selected_texts[selected_count] = select_object_from.options[i].text;
			selected_values[selected_count] = select_object_from.options[i].value;
			// delete_option(select_object_from, i);
			selected_count++;
		}
	}
  
	// Add the selected text/values in reverse order.
	// This will add the Options to the 'to' Select
	// in the same order as they were in the 'from' Select.
	for(i=selected_count-1; i>=0; i--)
	{
		insert_option(select_object_to, selected_texts[i], selected_values[i]);
	}
  
	if(NS4) history.go(0);
}


/*
 * uniquely insert selected categories options from select_object_from to select_object_to in a sorted order
 */

function copy_selected_categories_options(select_object_from, select_object_to){
	var select_object_from_length = select_object_from.length;
	var selected_texts = new Array();
	var selected_values = new Array();
	var selected_count = 0;
  
	var i;
  
	// Find the selected Options in reverse order
	for(i=select_object_from_length-1; i>=0; i--)
	{
    	if(select_object_from.options[i].selected)
    	{
			selected_texts[selected_count] = select_object_from.options[i].text;
			selected_values[selected_count] = select_object_from.options[i].value;
			// delete_option(select_object_from, i);
			selected_count++;
		}
	}
  
	// Add the selected text/values in reverse order.
	// This will add the Options to the 'to' Select
	// in the same order as they were in the 'from' Select.
	for(i=selected_count-1; i>=0; i--)
	{
		unique_insert_sort_option(select_object_to, trim(selected_texts[i]), selected_values[i]);
	}
  
	if(NS4) history.go(0);
}

function copy_selected_item_desc_options(select_object_from, hidden_object_from, select_object_to){
	var select_object_from_length = select_object_from.length;
	var selected_texts = new Array();
	var selected_values = new Array();
	var selected_count = 0;
  
	var i;
  
	// Find the selected Options in reverse order
	for(i=select_object_from_length-1; i>=0; i--)
	{
    	if(select_object_from.options[i].selected)
    	{
			selected_texts[selected_count] = hidden_object_from.options[i].text;
			selected_values[selected_count] = hidden_object_from.options[i].value;
			// delete_option(select_object_from, i);
			selected_count++;
		}
	}
  
	// Add the selected text/values in reverse order.
	// This will add the Options to the 'to' Select
	// in the same order as they were in the 'from' Select.
	for(i=selected_count-1; i>=0; i--)
	{
		select_object_to.value = selected_texts[i];
	}
  
	if(NS4) history.go(0);
}

function delete_selected_options(select_object){
	var select_object_length = select_object.length;
	  
	var i;
  
	// Find the selected Options in reverse order
	// and delete them from the 'from' Select.
	for(i=select_object_length-1; i>=0; i--)
	{
    	if(select_object.options[i].selected)
    	{
			delete_option(select_object, i);
		}
	}
	if(NS4) history.go(0);
}

function delete_all_options(select_object) {
	var select_object_length = select_object.length;
	var i;
	for(i=select_object_length-1; i>=0; i--)
	{
    	delete_option(select_object, i);
	}
	if(NS4) history.go(0);
}

function select_all(select_object){
	var select_object_length = select_object.length;
	  
	var i;
	
	for(i=select_object_length-1; i>=0; i--)
	{
    	select_object.options[i].selected = true;
	}
	if(NS4) history.go(0);
}

function unselect_all(select_object) {
	var select_object_length = select_object.length;
	  
	var i;
	
	for(i=select_object_length-1; i>=0; i--)
	{
    	select_object.options[i].selected = false;
	}
	if(NS4) history.go(0);
}
