// ----------------------------------------------------------------------------
//------ Global Variables
	
	var global_selected = false;
	var calendar_created = false;
	var calendar_1 = null;
// ----------------------------------------------------------------------------
	function char_replace(ch_str, ch_value, ch_replace)	
	{
		if(ch_str == "")
			return "";
			
		ch_return = "";
		
		for(ch_i = 0; ch_i < len(ch_str); ch_i++)
		{
			ch_char = ch_str.charAt(ch_i);
			
			if(ch_char == ch_value)
				ch_return += ch_replace;
			else
				ch_return += ch_char;
		}
		
		return ch_return;
	}
// ----------------------------------------------------------------------------
	function check_calendar()
	{
		if(calendar_created)
			return;
		
		calendar_1 = new CalendarPopup("calendar_div");
		calendar_1.showNavigationDropdowns();	
		calendar_created = true;
	}
// ----------------------------------------------------------------------------
	function checkbox_values(cc_obj)
	{
			if(!is_object(cc_obj))
				return "";
				
			cc_total_count = cc_obj.length;
			
			cc_str = "";
			cc_total = 0;
			
			if(cc_total_count == null && cc_obj.checked)
				return cc_obj.value;
			else
			{
				for(cc_count = 0; cc_count < cc_total_count; cc_count++)
				{
					if(cc_obj[cc_count].checked)
					{
						if(cc_total > 0)
							cc_str += ",";
						
						cc_str += cc_obj[cc_count].value;
						cc_total++;
					}
				}
			}
			
			return cc_str;
	}	
// ----------------------------------------------------------------------------
	function clear_element(ce_obj)
	{
		if(  !is_object(ce_obj)  )
			return;
			
		ce_obj.value = "";
	}
// ----------------------------------------------------------------------------
	function clear_date(date_prefix)
	{
		cd_obj = element(date_prefix + "_month");
		
		if(  !is_object(cd_obj)  )
			return;
		
		cd_obj.value = "";
		cd_obj.focus();
		
		cd_obj = element(date_prefix + "_day");
		cd_obj.value = "";
			
		cd_obj = element(date_prefix + "_year");
		cd_obj.value = "";
	}
// ----------------------------------------------------------------------------
	function element(element_name)
	{
			frm = document.frmMain;
			obj = eval("frm." + element_name);
			return obj;
	}
// ----------------------------------------------------------------------------
	function focused(element_name)
	{
			frm = document.frmMain;
			obj = eval("frm." + element_name);
			
			if(is_object(obj))
				obj.focus();
	}	
// ----------------------------------------------------------------------------
	function float_value(gf_obj)
	{
		if(!is_object(gf_obj))
			return 0;
				
		if(!isNumeric(gf_obj.value))
			return 0;
		else
		{
			fv = char_replace(gf_obj.value,"$","");
			fv = char_replace(fv,",","");			
			return parseFloat(trim(fv));
		}
	}	
// ----------------------------------------------------------------------------
	function force_numeric(fn_object, fn_display_name)
	{
		if(!isNumeric(fn_object.value))
		{
			alert("Please enter a numeric value for: " + fn_display_name);
			fn_object.focus();
		}
		else if(parseFloat(trim(fn_object.value)) <= 0)
		{
			alert("The value for: " + fn_display_name + " must be greater than zero");
			fn_object.focus();
		}
		else
			return true;
			
		return false;	
	}
// ----------------------------------------------------------------------------	
	function getInteger(gi_obj)
	{
		if(!is_object(gi_obj))
			return 0;
		
		if(!isNumeric(gi_obj.value))
			return 0;
		else
		{
			gi_val = trim(gi_obj.value);
			gi_len = len(gi_val);
			
			if(gi_len > 1)
			{
				if(gi_val.charAt(0) == "0")
					gi_val = gi_val.substr(1);
			}
			
			return parseInt( trim(gi_val) );
		}
	}	
// ----------------------------------------------------------------------------
	function getObject(go_name, go_index)
	{
		frm = document.frmMain;
		
		go_obj = eval("frm." + go_name);
		
		if(!is_object(go_obj))
			return null;
		
		if(go_obj.length == null)
			return go_obj;
		else
		{
			go_obj = eval("frm." + go_name + "[" + go_index + "]");
			return go_obj;
		}
	}	
// ----------------------------------------------------------------------------	
	function hideDiv(div_name)
	{
				if (document.all)
						document.all[div_name].style.display = 'none';
				else
				{
						var el = document.getElementById(div_name);
						el.style.display = 'none';
				}
	}	
// ----------------------------------------------------------------------------		
	function invalidate_form()
	{
		set("check_form_c5_submission", "false");
	}	
// ----------------------------------------------------------------------------
	function is_a_checkbox_checked(cc_obj)
	{
			if(!is_object(cc_obj))
				return false;
				
			cc_total_count = cc_obj.length;
			
			if(cc_total_count == null)
				return cc_obj.checked;
			else
			{
				for(cc_count = 0; cc_count < cc_total_count; cc_count++)
				{
					if(cc_obj[cc_count].checked)
						return true;
				}
			}
			
			return false;
	}
// ----------------------------------------------------------------------------	
	function is_date_before(month_obj, day_obj, year_obj, target_month, target_day, target_year)
	{
		if(!valid_date(month_obj, day_obj, year_obj))
			return false;
			
		v_month = getInteger(month_obj);
		v_day = getInteger(day_obj);
		v_year = getInteger(year_obj);
		
		if(target_year > v_year)
			return true;
		else if(  (target_year == v_year) && (target_month > v_month)  )
			return true;
		else if(  (target_year == v_year ) && (target_month == v_month) && (target_day > v_day) )
			return true;
		else
			return false;
	}	
// ----------------------------------------------------------------------------
	function isNumeric(in_value)
	{
		if(in_value == null || in_value == "")
			return false;
			
		in_value = trim(in_value);
		
		if(in_value == null || in_value == "")
			return false;
			
		in_value = char_replace(in_value, "$","");
		in_value = char_replace(in_value, ",","");		
	
		in_valid = "0123456789";
		in_period_count = 0;
		
		if(in_value.charAt(0) == "-")
			in_start = 1;
		else
			in_start = 0;
			
		for(in_count = in_start; in_count < in_value.length; in_count++)
		{
			in_test = in_value.charAt(in_count);
			
			if(in_test == ".")
			{
				in_period_count++;
				
				if(in_period_count > 1)
					return false;
			}		
			else if(in_valid.indexOf(in_test) < 0)
				return false;
		}
	
		return true;	
	}
// ----------------------------------------------------------------------------	
	function is_in(in_value, in_array)
	{
		if(in_value == null || in_array == null)
			return false;
			
		for(in_i = 0; in_i < in_array.length; in_i++)
		{
			if(in_value.toLowerCase() == in_array[in_i].toLowerCase())
				return true;
		}
		
		return false;
	}	
// ----------------------------------------------------------------------------
	function is_object(io_obj)
	{
		if(!io_obj || io_obj == null)
			return false;
		else
			return true;
	}	
// ----------------------------------------------------------------------------
	function is_selectbox_selected(sel_obj)
	{
		if(!is_object(sel_obj))
			return false;
			
		sel_total = sel_obj.options.length;
		
		if(sel_total == null)
			return false;
	
		if(sel_obj.selectedIndex == -1)
			return false;
		
		return true;	
	}
// ----------------------------------------------------------------------------
	function jwindow(url)
	{
		openCenteredWindow(url, 600, 500, 'win','resizable=yes,scrollbars=yes');
	}
// ----------------------------------------------------------------------------
	function jwindow_size(url, width, height)
	{
		openCenteredWindow(url, width, height, 'win','resizable=yes,scrollbars=yes');
	}
// ----------------------------------------------------------------------------
	function large_key(value, key_table, key_tableID, key_columns, return_column, ext)
	{
		str = "?kt=" + key_table + "&ktid=" + key_tableID + "&kc=" + key_columns;
		str += "&rc=" + return_column + "&rcv=" + value;
		
		jwindow("../../system/module/key." + ext + str, 390,270);
	}
// ----------------------------------------------------------------------------
	function left(left_str, ltotal)
	{
		if(left_str == "")
			return "";
			
		left_str = trim(left_str);
		lcount = len(left_str);
		return left_str.substr(0, ltotal);
	}		
// ----------------------------------------------------------------------------
	function len(lvalue)
	{
		if(lvalue == null || lvalue == "")
			return 0;
			
		total = lvalue.length;

		if(total == null)
			return 0;
		else
			return parseInt(total);
	}
// ----------------------------------------------------------------------------
	function ltrim(t_value)
	{
		if(t_value == null || t_value == "")
			return "";
			
		t_forward = "";
		t_start = false;
		
		for(t = 0; t < t_value.length; t++)
		{
			if(!t_start && t_value.charAt(t) == " ")
				continue;
			else if(!t_start && t_value.charAt(t) != " ")
			{
				t_start = true;
				t_forward += t_value.charAt(t);
			}
			else
				t_forward += t_value.charAt(t);
		}
		
		return t_forward;
	}	
// ----------------------------------------------------------------------------
	function money(m_value)
	{
		m_value = trim(m_value);
		m_value = char_replace(m_value, "$","");
		m_value = char_replace(m_value, ",","");

		m_neg = "";
		
		if(m_value.charAt(0) == "-")		
			m_neg = "-";
			
		m_value = char_replace(m_value, "-", "");

		m_suffix = "";
		m_prefix = "";
		
		m_index = m_value.indexOf(".");
		
		if(m_index > -1)
		{
			m_prefix = m_value.substring(0, m_index);
			m_suffix = m_value.substring(m_index + 1);
			m_suffix = left(m_suffix, 2);
		}
		else
		{
			m_prefix = trim(m_value);
			m_suffix = "";
		}
		
		if(!isNumeric(m_prefix))
		{
			m_prefix = "0";
			m_suffix = "0";
		}
		else if(!isNumeric(m_suffix))
			m_suffix = "0";

		if(len(m_suffix) == 1)
			m_suffix += "0";
			
		m_str = "";
		m_count = 0;
		m_len = len(m_prefix);
		
		for(m_x = m_len; m_x > -1 ; m_x--)
		{
			if(m_count == 4)
			{
				m_str += ",";
				m_count = 1;
			}	
			
			m_str += m_prefix.charAt(m_x);
			
			m_count++;
		}

		m_prefix = "";
		m_len = len(m_str);		
		
		for(m_x = m_len; m_x > -1; m_x--)
		{
			m_prefix += m_str.charAt(m_x);	
		}

		return m_neg + "$" + m_prefix + "." + m_suffix;	
	}
// ----------------------------------------------------------------------------
	function money_element(fld)
	{
		fld.value = money(fld.value);
	}	
// ----------------------------------------------------------------------------
	function numeric(fn_object, fn_display_name)
	{
		if(!isNumeric(fn_object.value))
		{
			alert("Please enter a numeric value for: " + fn_display_name);
			fn_object.focus();
		}
		else
			return true;
			
		return false;	
	}
// ----------------------------------------------------------------------------
	function openCenteredWindow(url, width, height, name, parms) {
	   var left = Math.floor( (screen.width - width) / 2);
	   var top = Math.floor( (screen.height - height) / 2);
	   var winParms = "top=" + top + ",left=" + left + ",height=" + height + ",width=" + width;
	   if (parms) { winParms += "," + parms; }
	   var win = window.open(url, name, winParms);
	   if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
	}
// ----------------------------------------------------------------------------
	function preview_image(image)
	{
			if(trim(image) == '')
				return;
			else
				jwindow_size('../../documents/' + image,400,300);
	}
// ----------------------------------------------------------------------------
	function radio_button_value(rb)
	{
			if(!is_object(rb))
				return "";
			
			rb_total = rb.length;
			
			if(rb_total == null)
						return  rb.value;
			else
			{
					for(rb_i = 0; rb_i < rb_total; rb_i++)
					{
							if(rb[rb_i].checked)
								return rb[rb_i].value;
					}
			}
			
			return "";
	}
// ----------------------------------------------------------------------------
	function refresh_page()
	{
		frm = document.frmMain;
		
		if(is_object(frm.command))
			frm.command.value = 0;
		
		invalidate_form();
		frm.submit();
	}
// ----------------------------------------------------------------------------
	function reload_page()
	{
		refresh_page();
	}
// ----------------------------------------------------------------------------
	function right(right_str, ltotal)
	{
		if(right_str == "")
			return "";
			
		right_str = trim(right_str);
		lcount = len(right_str);
		lstart = lcount - ltotal;
		
		if(lstart > lcount)
			return "";
		else
			return right_str.substr(lstart, ltotal);
	}			
// ----------------------------------------------------------------------------
	function rtrim(t_value)
	{
		if(t_value == null || t_value == "")
			return "";
			
		t_back = "";
		t_start = false;
		
		for(t = (t_value.length - 1); t > -1; t--)
		{
			if(!t_start && t_value.charAt(t) == " ")
				continue;
			else if(!t_start && t_value.charAt(t) != " ")
			{
				t_start = true;
				t_back += t_value.charAt(t);
			}
			else
				t_back += t_value.charAt(t);
		}
		
		t_forward = "";
		
		for(t = (t_back.length - 1); t > - 1; t--)
		{
			t_forward += t_back.charAt(t);
		}
		
		return t_forward;
	}	
// ----------------------------------------------------------------------------
	function row_over(row)
	{
			row.style.cursor = "hand";
			color = "#33FFFF";
			row.bgColor = color;
	}
// ----------------------------------------------------------------------------
	function row_out(row,color)
	{
			row.style.cursor = "default";
			row.bgColor = color;
	}	
// ----------------------------------------------------------------------------
	function select_all_checkboxes(sac_obj)
	{
		if(!is_object(sac_obj))
			return;
			
		sac_total_count = sac_obj.length;
		
		global_selected = !global_selected;
		
		if(sac_total_count == null)
			sac_obj.checked = global_selected;
		else
		{
			for(sac_count = 0; sac_count < sac_total_count; sac_count++)
			{
				sac_obj[sac_count].checked = global_selected;
			}
		}
	}	
// ----------------------------------------------------------------------------
	function selectbox_add(add_obj, add_display, add_value)
	{
		if(!is_object(add_obj))
			return;
			
		add_total = add_obj.options.length;
		
		if(add_total == null)
			return;
			
		add_obj.options[add_total] = new Option(add_display, add_value);
	}	
// ----------------------------------------------------------------------------
	function selectbox_all_values(all_obj)
	{
		if(!is_object(all_obj))
			return "";
			
		all_total = all_obj.options.length;
		
		if(all_total == null)
			return "";
		
		all_str = "";
		
		for(all_i = 0; all_i < all_total; all_i++)
		{
			if(all_i > 0)
				all_str += ",";
				
			all_str += all_obj.options[all_i].value;
		}
		
		return all_str;
	}
// ----------------------------------------------------------------------------
	function selectbox_all_values_from_one(all_obj)
	{
		if(!is_object(all_obj))
			return "";
			
		all_total = all_obj.options.length;
		
		if(all_total == null)
			return "";
		
		all_str = "";
		
		for(all_i = 1; all_i < all_total; all_i++)
		{
			if(all_i > 1)
				all_str += ",";
				
			all_str += all_obj.options[all_i].value;
		}
		
		return all_str;
	}	
// ----------------------------------------------------------------------------
	function selectbox_array(sa_obj)
	{
		if(!is_object(sa_obj))
			return null;
			
		sa_count = selectbox_count(sa_obj);
		
		if(sa_count == 0)
			return null;
			
		sa_return = new Array();
		
		for(sa_i = 0; sa_i < sa_count; sa_i++)
		{
			sa_return[sa_i] = sa_obj.options[sa_i].value;
		}
		
		return sa_return;
	}		
// ----------------------------------------------------------------------------
	function selectbox_clear(clear_obj)
	{
		if(!is_object(clear_obj))
			return;
			
		clear_total = clear_obj.options.length;
		
		if(clear_total == null)
			return;
		
		for(clear_i = clear_total; clear_i > 0; clear_i--)
		{
			clear_obj.options[clear_i] = null;
		}
		
	}	
// ----------------------------------------------------------------------------
	function selectbox_clear_noselect(clear_obj)
	{
		if(!is_object(clear_obj))
			return;
			
		clear_total = clear_obj.options.length;
		
		if(clear_total == null)
			return;
		
		for(clear_i = clear_total; clear_i > -1; clear_i--)
		{
			clear_obj.options[clear_i] = null;
		}
		
	}		
// ----------------------------------------------------------------------------
	function selectbox_copy(copy_from, copy_to)
	{
		if(!is_object(copy_from) || !is_object(copy_to))
			return;
			
		copy_from_index = copy_from.options.length;
		copy_to_index = copy_to.options.length;
		
		if(copy_from_index == null)
			return;
		
		if(copy_to_index == null)
			copy_to_index = 0;
			
		copy_index = copy_from.selectedIndex;
		
		if(copy_index == -1)
			return;
			
		using_multiple = false;
		
		if(selectbox_selected_count(copy_from) > 1)
			using_multiple = true;
		
		if(!using_multiple)
		{		
				copy_text = copy_from.options[copy_index].text;
				copy_value = copy_from.options[copy_index].value;
		
				sct_values = selectbox_array(copy_to);
				
				if(is_in(copy_value, sct_values))
				{
					alert("Value already exists in list");
					return;
				}
 
 				selectbox_add(copy_to, copy_text, copy_value);			
		}
		else
		{
				c_options = copy_from.options;
				
				for(c = 0; c < c_options.length; c++)
				{
					if(!c_options[c].selected)
						continue;
				
					copy_text = c_options[c].text;
					copy_value = c_options[c].value;
		
					sct_values = selectbox_array(copy_to);
				
					if(is_in(copy_value, sct_values))
						continue;
						
					selectbox_add(copy_to, copy_text, copy_value);		
				}
		}
		
		if(using_multiple)
			selectbox_first(copy_to);
		else
			selectbox_last(copy_to);
	}
// ----------------------------------------------------------------------------
	function selectbox_count(count_obj)
	{
		if(!is_object(count_obj))
			return 0;
		
		count_total = count_obj.options.length;
		
		if(count_total == null)
			return 0;

		return count_total;		
	}
// ----------------------------------------------------------------------------	
	function selectbox_first(select_obj)
	{
		if(!is_object(select_obj))
			return;
			
		select_total = select_obj.options.length;
		
		if(select_total == null)
			return;
			
		select_obj.selectedIndex = 0;
	}
// ----------------------------------------------------------------------------	
	function selectbox_index(select_obj)
	{
		if(!is_object(select_obj))
			return 0;
		else
			return select_obj.selectedIndex;
	}		
// ----------------------------------------------------------------------------	
	function selectbox_last(select_obj)
	{
		if(!is_object(select_obj))
			return;
			
		select_total = select_obj.options.length;
		
		if(select_total == null)
			return;
			
		select_obj.selectedIndex = (select_total - 1);
	}	
// ----------------------------------------------------------------------------
	function selectbox_move_down(down_obj)
	{
		if(!is_object(down_obj))
			return;
			
		down_total = down_obj.options.length;
		
		if(down_total == null)
			return;
			
		down_index = down_obj.selectedIndex;
		
		if(down_index == -1)
			return;
		
		if(down_index >= (down_total - 1) )
			return;
			
		down_values = new Array();
		down_text = new Array();
		
		for(down_i = 0; down_i < down_total; down_i++)
		{
			down_values[down_i] = down_obj.options[down_i].value;
			down_text[down_i] = down_obj.options[down_i].text;
		}	
		
		selectbox_clear_noselect(down_obj);
		
		temp_value = down_values[down_index];
		temp_text =  down_text[down_index];
		
		down_values[down_index] = down_values[down_index + 1];
		down_text[down_index] = down_text[down_index + 1];
		
		down_values[down_index + 1] = temp_value;
		down_text[down_index + 1] = temp_text;
		
		for(down_i = 0; down_i < down_total; down_i++)
		{
			selectbox_add(down_obj, down_text[down_i], down_values[down_i]);
		}
		
		down_obj.selectedIndex = (down_index + 1);	
	}
// ----------------------------------------------------------------------------
	function selectbox_move_up(up_obj)
	{
		if(!is_object(up_obj))
			return;
			
		up_total = up_obj.options.length;
		
		if(up_total == null)
			return;
			
		up_index = up_obj.selectedIndex;
		
		if(up_index == -1)
			return;
		
		if(up_index < 1)
			return;
			
		up_values = new Array();
		up_text = new Array();
		
		for(up_i = 0; up_i < up_total; up_i++)
		{
			up_values[up_i] = up_obj.options[up_i].value;
			up_text[up_i] = up_obj.options[up_i].text;
		}	
		
		selectbox_clear_noselect(up_obj);
		
		temp_value = up_values[up_index - 1];
		temp_text =  up_text[up_index - 1];
		
		up_values[up_index - 1] = up_values[up_index];
		up_text[up_index - 1] = up_text[up_index];
		
		up_values[up_index] = temp_value;
		up_text[up_index] = temp_text;
		
		for(up_i = 0; up_i < up_total; up_i++)
		{
			selectbox_add(up_obj, up_text[up_i], up_values[up_i]);
		}
		
		up_obj.selectedIndex = (up_index - 1);
			
	}
// ----------------------------------------------------------------------------
	function selectbox_remove(remove_obj)
	{
		if(!is_object(remove_obj))
			return;
		
		remove_total = remove_obj.options.length;
		
		if(remove_total == null)
			return;
		else if(!is_selectbox_selected(remove_obj))
			return;
		
		for(ri = (remove_total - 1); ri > -1; ri--)
		{
			if(remove_obj.options[ri].selected)
				remove_obj.options[ri] = null;
		}
		
		if(selectbox_count(remove_obj) > 0)
			remove_obj.selectedIndex = 0;
	}	
// ----------------------------------------------------------------------------
	function selectbox_remove_except_one(remove_obj)
	{
		if(!is_object(remove_obj))
			return;
		
		remove_total = remove_obj.options.length;
		
		if(remove_total == null)
			return;
		else if(!is_selectbox_selected(remove_obj))
			return;
		
		for(ri = (remove_total - 1); ri > 0; ri--)
		{
			if(remove_obj.options[ri].selected)
				remove_obj.options[ri] = null;
		}
		
		if(selectbox_count(remove_obj) > 0)
			remove_obj.selectedIndex = 0;
	}	
// ----------------------------------------------------------------------------
	function selectbox_select_all(count_obj)
	{
		if(!is_object(count_obj))
			return;
		
		count_total = count_obj.options.length;
		
		if(count_total == null)
			return;
			
		sopt = count_obj.options;
		
		for(sc = 0; sc < count_total; sc++)
		{
			sopt[sc].selected = true;
		}	
	}			
// ----------------------------------------------------------------------------
	function selectbox_selected_count(count_obj)
	{
		if(!is_object(count_obj))
			return 0;
		
		count_total = count_obj.options.length;
		
		if(count_total == null)
			return 0;
			
		sopt = count_obj.options;
		
		sc_return = 0;
		
		for(sc = 0; sc < count_total; sc++)
		{
			if(sopt[sc].selected)
				sc_return++;
		}	

		return sc_return;		
	}	
// ----------------------------------------------------------------------------	
	function selectbox_set_index_by_value(select_obj, select_value)
	{
		if(!is_object(select_obj))
			return;

		s_options = select_obj.options;
		
		s_total = s_options.length;
		
		if(s_total == null)
		{
			selectbox_first(select_obj);
			return;
		}
		
		for(s_i = 0; s_i < s_options.length; s_i++)
		{
			if(  s_options[s_i].value == select_value   )
			{
					select_obj.selectedIndex = s_i;
					return;
			}
		}
		
		selectbox_first(select_obj);
	}		
// ----------------------------------------------------------------------------
	function selectbox_text(st_obj)
	{
		if(!is_object(st_obj))
			return "";
			
		st_total = st_obj.options.length;
		
		if(st_total == null)
			return "";
		else if(!is_selectbox_selected(st_obj))
			return "";
					
		return st_obj.options[st_obj.selectedIndex].text;
	}	
// ----------------------------------------------------------------------------
	function selectbox_value(s_obj)
	{
		s_return = '';
		
		if(!is_object(s_obj))
			return s_return;
			
		s_total = s_obj.options.length;
		
		if(s_total == null)
			return s_return;
		else if(!is_selectbox_selected(s_obj))
			return s_return;
		
		return s_obj.options[s_obj.selectedIndex].value;
	}	
// ----------------------------------------------------------------------------
	function selectbox_values(count_obj)
	{
		if(!is_object(count_obj))
			return "";
		
		count_total = count_obj.options.length;
		
		if(count_total == null)
			return "";
			
		sopt = count_obj.options;
		
		sc_return = "";
		sc_tot = 0;
		
		for(sc = 0; sc < count_total; sc++)
		{
			if(sopt[sc].selected)
			{
				if(sc_tot > 0)
					sc_return += ",";
				
				sc_return += sopt[sc].value;
				
				sc_tot++;
			}
		}	

		return sc_return;		
	}	
// ----------------------------------------------------------------------------
	function set(s_name, s_value)
	{
			frm = document.frmMain;
			obj = eval("frm." + s_name);
			
			if(is_object(obj))
				obj.value = s_value;
	}
// ----------------------------------------------------------------------------
	function set_date(date_prefix, sd_month, sd_day, sd_year)
	{
		cd_obj = element(date_prefix + "_month");
		
		if(  !is_object(cd_obj)  )
			return;
		
		cd_obj.value = sd_month;
		cd_obj.focus();
		
		cd_obj = element(date_prefix + "_day");
		cd_obj.value = sd_day;
			
		cd_obj = element(date_prefix + "_year");
		cd_obj.value = sd_year;
	}	
// ----------------------------------------------------------------------------
	function showDiv(div_name)
	{
				if (document.all)
						document.all[div_name].style.display = 'block';
				else
				{
						var el = document.getElementById(div_name);
						el.style.display = 'show';
				}
	}		
// ----------------------------------------------------------------------------	
	function textbox_values(cc_obj)
	{
			if(!is_object(cc_obj))
				return "";
				
			cc_total_count = cc_obj.length;
			
			cc_str = "";
			cc_total = 0;
			
			if(cc_total_count == null)
				return cc_obj.value;
			else
			{
				for(cc_count = 0; cc_count < cc_total_count; cc_count++)
				{
						if(cc_total > 0)
							cc_str += ",";
						
						cc_temp = cc_obj[cc_count].value;
						if(trim(cc_temp) == '') cc_temp = 'null';
						cc_str += cc_temp;
						cc_total++;
				}
			}
			
			return cc_str;
	}	
// ----------------------------------------------------------------------------
	function trim(str)
	{
		v = ltrim(str);
		v = rtrim(v);
		return v;
	}
// ----------------------------------------------------------------------------
	function valid_date(vd_month_obj, vd_day_obj, vd_year_obj)
	{
		v_month = getInteger(vd_month_obj);
		v_day = getInteger(vd_day_obj);
		v_year = getInteger(vd_year_obj);
		
		 if(v_month == 0 || v_day == 0 || v_year == 0)
			return false;		
		else if(v_month < 1 || v_month > 12 || v_day < 1 || v_day > 31 || v_year < 1900 || v_year > 2999)
			return false;
		else if( (v_month == 1 || v_month == 3 || v_month == 5 || v_month == 7 || v_month == 8 || v_month == 10 || v_month == 12)  && ( v_day > 31 )    )
			return false;
		else if( (v_month == 4 || v_month == 6 || v_month == 9 || v_month == 11)  && ( v_day > 30 )    )
			return false;			
		else if(v_month == 2 && v_day >= 30)
			return false;
		else
			return true;
	}
// ----------------------------------------------------------------------------
	function validate(v_object, v_display_name)
	{
		if(trim(v_object.value) == "")
		{
			alert("Please enter a value for: " + v_display_name);
			v_object.focus();
		}
		else
			return true;
			
		return false;	
	}
// ----------------------------------------------------------------------------		
	function validate_date(vd_month_object, vd_day_object, vd_year_object, vd_display_name)
	{
		if(!valid_date(vd_month_object, vd_day_object, vd_year_object))
		{	
			alert("Please enter a valid date for: " + vd_display_name);
			vd_month_object.focus();
			return false;
		}
		
		return true;
	}	
// ----------------------------------------------------------------------------	
	function validate_date_text(vdt_object, vdt_display)
	{
		var vdt_val = trim(vdt_object.value);
		
		if(vdt_val == "")
		{
			alert("Please enter a valid date for: " + vdt_display + " (mm/dd/yyyy)");	
			vdt_object.focus();	
			return false;
		}
		else if(len(vdt_val) < 8)
		{
			alert("Please enter a valid date for: " + vdt_display + " (mm/dd/yyyy)");	
			vdt_object.focus();	
			return false;
		}
		
		if(len(vdt_val) == 8)
		{
			vdt_val = '0' + vdt_val;
			vdt_object.value = vdt_val;
		}
		
		if(vdt_val.charAt(2) == "/" && vdt_val.charAt(5) == "/")
		{	
			vdt_val = char_replace(vdt_val, "/","");

			if(isNumeric(vdt_val))
				return true;	
		}
		
		alert("Please enter a valid date for: " + vdt_display + " (mm/dd/yyyy)");
		vdt_object.focus();		
		
		return false;
	}	
// ----------------------------------------------------------------------------	
	function validate_email(ve_obj)
	{
		if(!is_object(ve_obj))
			return false;
		else if(   len(trim(ve_obj.value)) < 3)
		{
			alert("Please enter a valid email address");
			ve_obj.focus();
			return false;
		}
			
		period_count = 0;
		at_count = 0;
		
		for(ve_i = 0; ve_i < ve_obj.value.length; ve_i++)
		{
			ve_char = ve_obj.value.charAt(ve_i);
			
			if(ve_char == "@")
				at_count++;
			else if(ve_char == ".")
				period_count++;
		}
		
		if(at_count == 1 && period_count > 0)
			return true;
		else
		{
			alert("Please enter a valid email address");
			ve_obj.focus();		
			return false;
		}
	
	}
// ----------------------------------------------------------------------------
	function validate_len(v_object, v_display_name, v_min)
	{
		if(trim(v_object.value) == "")
		{
			alert("Please enter a value for: " + v_display_name);
			v_object.focus();
		}
		else if( (parseInt(v_min) > 0) && (v_object.value.length < parseInt(v_min))  )
		{
			alert(v_display_name + ":  must be at least " + v_min + " characters");
			v_object.focus();
		}
		else
			return true;
			
		return false;	
	}		
// ----------------------------------------------------------------------------
	function validate_max(v_object, v_display_name, v_max)
	{
		if(trim(v_object.value) == "")
		{
			alert("Please enter a value for: " + v_display_name);
			v_object.focus();
		}
		else if( (parseInt(v_max) > 0) && (v_object.value.length > parseInt(v_max))  )
		{
			alert(v_display_name + ":  must be " + v_max + " characters or less");
			v_object.focus();
		}
		else
			return true;
			
		return false;	
	}		
// ----------------------------------------------------------------------------	
	function validate_select(vs_object, vs_display_name)
	{
		if(vs_object.selectedIndex < 1)
		{
			alert("Please select a value for: " + vs_display_name);
			vs_object.focus();
		}
		else
			return true;
			
		return false;	
	}
// ----------------------------------------------------------------------------





// ----------------------------------------------------------------------------
	function send(command)
	{
			frm = document.frmMain;
			frm.command.value = command;
			frm.submit();
	}
// ----------------------------------------------------------------------------
	function sendform(target)
	{
			frm = document.frmMain;
			frm.action = target;
			invalidate_form();
			frm.submit();
	}
// ----------------------------------------------------------------------------



//--- Macromedia Crap


	function MM_preloadImages() { //v3.0
	  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
		var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
		if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
	}
// ----------------------------------------------------------------------------
	function MM_swapImgRestore() { //v3.0
	  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
	}
// ----------------------------------------------------------------------------
	function MM_findObj(n, d) { //v4.0
	  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	  if(!x && document.getElementById) x=document.getElementById(n); return x;
	}
// ----------------------------------------------------------------------------
	function MM_swapImage() { //v3.0
	  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
	}
// ----------------------------------------------------------------------------