function open_nipost(state_field, lga_field, code_field, type, form, update_field) {
/*
Parameters are as follows:
1> state_field = name of the field containing the state that should be used
2> lga_field = name of the field containing the lga that should be used. This field can be left blank if the lga is what is to be searched for.
3> code_field = the name of the field that will be used to  hold the postal code. This field can be left blank if the lga is what is to be searched for or the postcode does not need to be displayed.
4> type = used to tell the function if this is an "lga" or "district" search.
5> form = the name of the form containing the fields in question
6> update_field = the field this search should display the result in.
*/
params = "";
	if (type=="district") {
		if ((lga_field == null) || (lga_field == "") || (lga_field == " ")){
			alert("you must select the LGA first.");
			return;
		} else {
			which_lga = eval("document." + form + "." + lga_field + ".value");;
			params = "lga=" + which_lga;
	    	PostcodeFieldName = eval("document." + form + "." + code_field);
		}
	}
	state_index = eval("document." + form + "." + state_field + ".selectedIndex");;
	if (state_index == 0){
		alert("you must select the State first.");
		return;
	} else {
	    StateFieldName = eval("document." + form + "." + state_field + ".options[" + state_index + "].value");
		params += "&state=" + StateFieldName;
	}
    window.open("nipostdrop.php?" + params, "Selector", "width=200,height=100,status=yes");
    UpdateFieldName = eval("document." + form + "." + update_field);
}

function reset_fields(lga_field, district_field, pcode_field, form) {
/*
Parameters are as follows:
1> lga_field = name of the field containing the lga that should be used. This field can be left blank if the lga is what is to be searched for.
2> code_field = the name of the field that will be used to  hold the postal code. This field can be left blank if the lga is what is to be searched for or the postcode does not need to be displayed.
4> form = the name of the form containing the fields in question
*/
	UpdateFieldName = eval("document." + form + "." + lga_field);
	UpdateFieldName.value = "";
	UpdateFieldName = eval("document." + form + "." + district_field);
	UpdateFieldName.value = "";
	UpdateFieldName = eval("document." + form + "." + pcode_field);
	UpdateFieldName.value = "";
}

function returnChosen(form,show_postcode) {
	ChosenIndex = form.chosen.selectedIndex;
    ChosenValue = form.chosen.options[ChosenIndex].value;
    window.opener.UpdateFieldName.value = ChosenValue;
	if (show_postcode){
	    window.opener.PostcodeFieldName.value = form.postcode.value;
	}
    window.close();
}
function byebye(){
	if (confirm("Are you sure you want to exit without saving?")){
		document.location.href="entrance.php"
	}
}
function resfrm(form) {
	if (confirm("Are you sure you want to clear all fields?")){
		form.reset()
	}
}
function openCalendar(params, form, field, type) {
    window.open("calendar.php?" + params, "calendar", "width=260,height=200,status=yes");
    dateField = eval("document." + form + "." + field);
    dateType = type;
}
function popup(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=600,height=450');");
}

function popupPrintable(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=1,resizable=1,width=550,height=400');");
}
function showadvert(form) {
win=window.open("show_image.php?num="+form.num.value+"&","AdvertWin","scrollbars=no,status=no,location=no,toolbar=no,menubar=no,directories=no,resizable=no,width=250,height=300,top=50,left=100");
if (parseInt(navigator.appVersion) >=4) { win.window.focus();}
}
function popwin(id) {
	win=window.open("comments.php?topic=N"+id,"MCommentWin","scrollbars=yes,status=no,location=no,toolbar=no,menubar=no,directories=no,resizable=no,width=660,height=490,top=20,left=20");
	if (parseInt(navigator.appVersion) >=4) { win.window.focus();}
}
function popvwin(id) {
	win=window.open("view_comments.php?topic=N"+id,"VCommentWin","scrollbars=yes,status=no,location=no,toolbar=no,menubar=no,directories=no,resizable=no,width=650,height=500,top=20,left=20");
	if (parseInt(navigator.appVersion) >=4) { win.window.focus();}
}
function popawin(id,url) {
	win=window.open("open_advert.php?id="+id+"&url="+url,"AdvertWin"+id,"scrollbars=yes,status=no,location=no,toolbar=no,menubar=no,directories=no,resizable=yes,width=650,height=500,top=20,left=20");
	if (parseInt(navigator.appVersion) >=4) { win.window.focus();}
}

