

	function set_focus () {
		if (document.forms[0]) {
			for (i = 0; i < document.forms[0].length; i++) {
				if (document.forms[0][i].name != 'search_string' && document.forms[0][i].name != 'username' && document.forms[0][i].name != 'password' && (document.forms[0][i].type == 'text' || document.forms[0][i].type == 'textarea' || document.forms[0][i].type == 'password')) {
					//document.forms[0][i].focus();
					break;
				}
			}
		}
	}

	function unload() {
		if (document.input_changes && document.forms[document.input_name]) {
			if (confirm("Save changes?")) {
				for (i = 0; i < document.forms[document.input_name].length; i++) {
					if (document.forms[document.input_name][i].type == 'submit') {
						document.forms[document.input_name][i].click();
						break;
					}
				}
			}
		}
	}


	function init() {
		set_focus();
	}



	var pop_window = null;

	function popup(url, w, h) {

		var winl = 0;
		var wint = 0;
		w = w + 50;
		h = h + 50;
		if (screen) {
			var winl = (screen.width - w) / 2;
			var wint = (screen.height - h) / 2;
		}
		winprops = 'height='+h+', width='+w+', top='+wint+', left='+winl+', scrollbars=0';

		if (pop_window && !pop_window.closed && pop_window.location) {
			pop_window.close();
		}
		pop_window = window.open(url, "member", winprops);
	}



	function box_lists_add (form_obj, left, right) {
		box_lists_change(form_obj, left, right);
		box_lists_update(form_obj, left, right);
	}

	function box_lists_remove (form_obj, left, right) {
		box_lists_change(form_obj, right, left);
		box_lists_update(form_obj, left, right);
	}


	function box_lists_update (form_obj, left, right) {
		form_obj[left + '_' + right].value = '';

		for (i = 0; i < form_obj[right].length; i++) {
			if (i == form_obj[right].length - 1)
				form_obj[left + '_' + right].value = form_obj[left + '_' + right].value + form_obj[right][i].value;
			else
				form_obj[left + '_' + right].value = form_obj[left + '_' + right].value + form_obj[right][i].value + ',';
		}
		document.changed = true;
	}

	function box_lists_change (form_obj, left, right) {
		var
			opt_value, opt_text;

		for (;form_obj[left].selectedIndex > -1;) {
			opt_value = form_obj[left][form_obj[left].selectedIndex].value;
			opt_text = form_obj[left][form_obj[left].selectedIndex].text;
			form_obj[left][form_obj[left].selectedIndex] = null;
			form_obj[right][(form_obj[right].length)] = new Option(opt_text, opt_value);
		}
	}
	
	function box_expand (form_obj, area) {
		if (document.getElementById(area)) {
			if (form_obj.checked)
				document.getElementById(area).style.display = 'none';
			else
				document.getElementById(area).style.display = 'block';
		}
	}

	function box_expand_radio (form_obj, area) {
		if (document.getElementById(area)) {
			if (form_obj.value == 0)
				document.getElementById(area).style.display = 'none';
			else
				document.getElementById(area).style.display = 'block';
		}
	}

	function box_expand_radio_multi (form_obj, areas) {
		for (i=0; i<areas.length; i++) {
			var element = document.getElementById(areas[i]);
			
			if(element) {
				if (form_obj.value == i)
					element.style.display = 'block';
				else
					element.style.display = 'none';
			}
		
		
		}
		
	
	
	}
	
	function box_expand_flip (form_obj, area) {
		if (document.getElementById(area)) {
			if (!form_obj.checked)
				document.getElementById(area).style.display = 'none';
			else
				document.getElementById(area).style.display = 'block';
		}
	}
		
	var faq_current = '';
	
	function faq_expand (area) {
		if (document.getElementById(area)) {
			if (document.getElementById(area).style.display == 'block') {
				document.getElementById(area).style.display = 'none';
				document.getElementById('first_'+area).className = 'non-sel';
				
				faq_current = '';
			}
			else {
				document.getElementById(area).style.display = 'block';
				document.getElementById('first_'+area).className = 'sel';
				if ( (faq_current != area) && (faq_current != '') )
					faq_expand(faq_current)
				faq_current = area;
			}
		}
	}
	
	function extranet_menu_change() {
		var menu_id = document.forms[0].extranet_menu_id.value;
		var parts = document.forms[0].extranet_menu_id[document.forms[0].extranet_menu_id.selectedIndex].innerHTML.split(' (');
		
		var menu_sort_order = parseInt(parts[parts.length-1]);
		var menu_name = "";
		
		for (i=0; i<parts.length-1; i++) {
			if(i>0) {
				menu_name += " (";
			}
			menu_name += parts[i];
		}
		
		if(menu_id == 0) {
			menu_name = "";
			menu_sort_order = 0;
		}

		document.forms[0].extranet_menu_name.value = menu_name;
		document.forms[0].extranet_menu_sort_order.value = menu_sort_order;
		
	}
	
	/*
	sync_combo_text(select-element, div-id-prefix)
	
	will synchronize a select box (which object is given as first argument)
	with some div's which are turned on and of - the prefix of the id 
	of these divs are given as second argument and is suffixed the index
	of the element in the select-box
	*/
	
	function sync_combo_text(combo, prefix) {
		for(i=0; i<combo.length; i++) {
			if(combo[i].selected) {
				document.getElementById(prefix+i).style.display = "block";
			}
			else {
				document.getElementById(prefix+i).style.display = "none";
			}
			
			
		
		}
	
	}

