function changeUSA(state, country)
{
// if a state is selected, USA is automatically picked as the country
// requires input to determine which fields are affected
	var usaFlag = 0;

	// find out if USA should be selected
	if (country.options[country.selectedIndex].value == "USA")
		usaFlag = 1;
	else {
		for (var i = 0; i < state.length; i++) {
			if (state.options[i].selected && state.options[i].value != "") {
				usaFlag = 1;
				break;
			}
		}
	}

	if (usaFlag) {
		for (i = 0; i < country.length; i++) {
			if (country.options[i].value == "USA") {
				country.options[i].selected = true;
				break;
			} else
				country.options[i].selected = false;
		}
	}
}

var stateBuffer = new Array();		// remebers selected state for changeCountry()

function changeState(country, state)
{
// if a country other than USA is selected,
// change state field to first option (blank)
	if (state.selectedIndex == -1) { 
		state.selectedIndex = 0;  // this must be here in case there is no defaut value selected.
	}
	if (state.options[state.selectedIndex].value != "")
		stateBuffer[state.name] = state.selectedIndex;

	// clear the select list (in case of select multiple)
	if (state.type != "select-one") {
		for (var i = 0; i < state.length; i++)
			state.options[i].selected = false;
	}

	if (country.options[country.selectedIndex].value != "USA")
		state.selectedIndex = 0;
	else if (stateBuffer[state.name])
		state.selectedIndex = stateBuffer[state.name];
}
 

function preview(formObj)
{
        var a = window.open("","Preview","resizable,scrollbars,width=610,height=300");
        var b = a.document;

        if (!formObj) {
		formObj = document.postaevent;
	}

	b.open('text/html');
        b.write('<html><body bgcolor="#ffffff"><link rel="stylesheet" type="text\/css" href="css\/journals.css">\n');
        b.write('<table width="600"><tr><td class="content">\n');
	b.write('<b>' + formObj.EventTitle.value + '<\/b><br>\n');
	if (formObj.J__LABEL) {
		b.write(formObj.J__LABEL.value + '<br>\n');
	}
    b.write(formObj.EventDesc.value + '<p>\n');
	b.write('Deadline: ' + formObj.startMonth.value + '\/' + formObj.startDate.value + '\/' + formObj.startYear.value + '<p>\n');
    b.write('<\/td><\/tr><\/table>\n');
    b.write('<hr><center>\n');
    b.write('<a href="javascript: window.close();">Close<\/a><\/center><\/body><\/html>');
    b.close();
}

function popUpWindow(mypage, myname, w, h, scroll) 
{
		var winl = (screen.width - w) / 2	;
		var wint = (screen.height - h) / 2;
		winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable, bgcolor=#000000'
		win = window.open(mypage, myname, winprops)
		if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}


