// used in default, serge_join and search_form_quick scripts
function toggle_gender(sel, g, s, sid, age, age_for) {

	var sel_name=sel.name;
	var sel_value=sel.options[sel.selectedIndex].value;
	var tooggle_what='';
	var tooggle_value='';
	var tooggle_sel_a=new Array();
	var tooggle_what_a=new Array();
	var seeking=document.getElementById('seeking'+sid);

	if(sel.name=='gender') {
		tooggle_what=document.getElementById('seeking'+sid);
		tooggle_sel_a=g;
		tooggle_what_a=s;
	} else if(sel.name=='seeking') {
		tooggle_what=document.getElementById('gender'+sid);
		tooggle_sel_a=s;
		tooggle_what_a=g;
	}

	if(tooggle_what) {
		for(i=0; i<tooggle_sel_a.length; i++) {
			if(tooggle_sel_a[i]==sel_value) {
			 tooggle_value=tooggle_what_a[i];
			 break;
			}
		}

		for(i=0; i<tooggle_what.length; i++) {
			if(tooggle_what.options[i].value==tooggle_value) {
			 tooggle_what.selectedIndex=i;
			 break;
			}
		}

		if(age!='' && seeking.options[seeking.selectedIndex].value==age_for) {
			add_remove_options('remove');
		} else {
			add_remove_options('add');
		}
	}
}
/*
function add_remove_options(todo)
{
	var min_age=document.getElementById('min_age');
	var max_age=document.getElementById('max_age');

	if(todo=='add' && min_age && max_age) {
		if(min_age.length==18) {
			for(i=36; i<100; i++) {
				(min_age.options.add) ? min_age.options.add(new Option(i,i)) : min_age.add(new Option(i,inull));
				(max_age.options.add) ? max_age.options.add(new Option(i,i)) : max_age.add(new Option(i,inull));
			}
			max_age.selectedIndex=22;
		}
	} else if(todo=='remove' && min_age && max_age) {
		if(min_age.length>18) {
			for(i=18; i<82; i++) {
				min_age.remove(min_age.length-1);
				max_age.remove(max_age.length-1);
			}
			max_age.selectedIndex=17;
		}
	}
}
*/
function add_remove_options(todo)
{
	var min_age=document.getElementById("min_age");
	var max_age=document.getElementById("max_age");

	if(todo=='add') {
		/*if(min_age.length==18) {
			for(i=36; i<100; i++) {
				(min_age.options.add) ? min_age.options.add(new Option(i,i)) : min_age.add(new Option(i,inull));
				(max_age.options.add) ? max_age.options.add(new Option(i,i)) : max_age.add(new Option(i,inull));
			}
			for(i=0; i<12; i++) { min_age.remove(0); max_age.remove(0); }
			max_age.selectedIndex=10;
		} */
		min_age.selectedIndex=12;
		max_age.selectedIndex=22;
	} else {
		/*if(min_age.length>18) {
			for(i=18-6; i<82; i++) { min_age.remove(min_age.length-1); max_age.remove(max_age.length-1); }
		}
		for(i=18; i<36; i++) {
			(min_age.options.add) ? min_age.options.add(new Option(i,i)) : min_age.add(new Option(i,inull));
			(max_age.options.add) ? max_age.options.add(new Option(i,i)) : max_age.add(new Option(i,inull));
		}
		max_age.selectedIndex=17; */
		min_age.selectedIndex=0;
		max_age.selectedIndex=17;
	}
}
