function linkpage (pageURL) {
	document.frmInterface.target = '';
	document.frmInterface.action = pageURL;
	document.frmInterface.submit();
}

function linkpagex (pageURL, winName) {
	var oldt = document.frmInterface.target;
	var olda = document.frmInterface.action;
	document.frmInterface.target = winName;
	document.frmInterface.action = pageURL;
	document.frmInterface.submit();	
	document.frmInterface.target = oldt;
	document.frmInterface.action = olda;	
}

function helpline (helpStr) {
	self.status = helpStr;
	return true;
}

function nohelp () {
	self.status = "";
	return true;
}

function showphf (subDate) {
	var oldt = document.frmInterface.target;
	var olda = document.frmInterface.action;
	document.frmInterface.target = 'phfwin';
	document.frmInterface.fSubDate.value = subDate;
	document.frmInterface.action = 'phfview.asp';
	document.frmInterface.submit();
	document.frmInterface.target = oldt;
	document.frmInterface.action = olda;
}

function trim (s) {
	while (s.length > 0 && s.charAt(0) == ' ') s = s.substring(1, s.length);
	while (s.length > 0 && s.charAt(s.length-1) == ' ') s = s.substring(0, s.length-1);
	return s;
}

function insert_job () {
	var c, s, i;
	var cr = '\x0A';
	if (!confirm('Are you sure you wish to insert a new job?')) return;
	with (document.frmInterface)
	{
		// move the 6th job to the "other jobs" box
		s = '';
		c = trim(fWE6_fromM[fWE6_fromM.selectedIndex].text); if (c != '' && c.charAt(0) != '-') s += 'from ' + c + ' ';
		c = trim(fWE6_fromY[fWE6_fromY.selectedIndex].text); if (c != '' && c.charAt(0) != '-') s += c + ' ';
		c = trim(fWE6_toM[fWE6_toM.selectedIndex].text);     if (c != '' && c.charAt(0) != '-') s += 'to ' + c + ' ';
		c = trim(fWE6_toY[fWE6_toY.selectedIndex].text);     if (c != '' && c.charAt(0) != '-') s += c;
		c = trim(fWE6_title.value);    if (c != '') { if (s != '') s += cr; s += 'Post title: ' + c; }
		c = trim(fWE6_employer.value); if (c != '') { if (s != '') s += cr; s += 'Employer: ' + c;	}
		c = trim(fWE6_type.value);     if (c != '') { if (s != '') s += cr; s += 'Type of business: ' + c;	}
		c = trim(fWE6_subord.value);   if (c != '') { if (s != '') s += cr; s += 'Employees supervised: ' + c;	}
		c = trim(fWE6_reason.value);   if (c != '') { if (s != '') s += cr; s += 'Reason for leaving: ' + c; }
		c = trim(fWE6_duties.value);   if (c != '') { if (s != '') s += cr; s += 'Description of duties: ' + c; }																		
		if (s != '') fWE_misc_info.value = s + cr + cr + fWE_misc_info.value;
		
		// move the jobs 1-5 down
		for (i = 5; i >= 1; i--)
		{
			elements['fWE' + (i+1) + '_fromM'].selectedIndex = elements['fWE' + i + '_fromM'].selectedIndex;
			elements['fWE' + (i+1) + '_fromY'].selectedIndex = elements['fWE' + i + '_fromY'].selectedIndex;
			elements['fWE' + (i+1) + '_toM'].selectedIndex = elements['fWE' + i + '_toM'].selectedIndex;
			elements['fWE' + (i+1) + '_toY'].selectedIndex = elements['fWE' + i + '_toY'].selectedIndex;
			elements['fWE' + (i+1) + '_title'].value = elements['fWE' + i + '_title'].value;
			elements['fWE' + (i+1) + '_employer'].value = elements['fWE' + i + '_employer'].value;
			elements['fWE' + (i+1) + '_type'].value = elements['fWE' + i + '_type'].value;
			elements['fWE' + (i+1) + '_subord'].value = elements['fWE' + i + '_subord'].value;
			elements['fWE' + (i+1) + '_reason'].value = elements['fWE' + i + '_reason'].value;
			elements['fWE' + (i+1) + '_duties'].value = elements['fWE' + i + '_duties'].value;
			if (i == 1)
			{
				elements['fWE' + (i+1) + '_phone'].value = elements['fWE' + i + '_phone'].value;
				elements['fWE' + (i+1) + '_income'].value = elements['fWE' + i + '_income'].value;											
			}
		}
		
		// erase job 1
		fWE1_fromM.selectedIndex = 0;
		fWE1_fromY.selectedIndex = 0;
		fWE1_toM.selectedIndex = 0;
		fWE1_toY.selectedIndex = 0;				
		fWE1_title.value = '';
		fWE1_employer.value = '';
		fWE1_phone.value = '';
		fWE1_superv.value = '';
		fWE1_type.value = '';
		fWE1_subord.value = '';
		fWE1_reason.value = '';
		fWE1_income.value = '';
		fWE1_duties.value = '';
	}
}

function show_ccog_sel()
{
	var s = '', t;
	var i, c = 0;
	if (!document.getElementById) return;
	if (!document.getElementById('selectedCCOG')) return;
	if (!document.frmInterface.fCCOG) return;
	for (i = 0; i < document.frmInterface.fCCOG.length; i++)
	{
		if (document.frmInterface.fCCOG[i].selected) {
			t = document.frmInterface.fCCOG[i].text;
			while(t.substr(0,2)=='- ') t = t.substr(2);
			c++;
			if (s != '') s += '<br>';
			if (c <= 5)
			{
				s += c.toString() + '. ' + t;
			} else {
				s += '<span style="color:red">More than 5 categories selected. Please reduce your selection.</span>';
				break;
			}
		}
	}
	if (s != '')
	{
		s = 'Current selection:<br>' + s;
		document.getElementById('selectedCCOG').innerHTML = s;
	} else {
		document.getElementById('selectedCCOG').innerHTML = '';	
	}
}
