function toggleUploadBox(which) {

	if (document.getElementById('upload_' + which).style.display == 'none') {
		document.getElementById('upload_' + which).style.display = '';
		document.getElementById('upload_' + which + '_link').firstChild.nodeValue = 'Hide upload box';
	} else {
		document.getElementById('upload_' + which).style.display = 'none';
		document.getElementById('upload_' + which + '_link').firstChild.nodeValue = 'Upload again';
	}
	return;
}


function toggleUploadCoverBox(which) {

	if (document.getElementById('cover_upload_' + which).style.display == 'none') {
		document.getElementById('cover_upload_' + which).style.display = '';
		document.getElementById('cover_upload_' + which + '_link').firstChild.nodeValue = 'Hide upload box';
	} else {
		document.getElementById('cover_upload_' + which).style.display = 'none';
		document.getElementById('cover_upload_' + which + '_link').firstChild.nodeValue = 'Upload again';
	}
	return;
}


function toggleCoverArea() {

	if (document.getElementsByName('cover_letter')[0].checked) {
		document.getElementsByName('cover-area')[0].style.display = 'none';
		document.getElementsByName('cover-area')[1].style.display = 'none';
		document.getElementsByName('cover-area')[2].style.display = 'none';
		document.getElementsByName('cover-area')[3].style.display = 'none';
	} else if (document.getElementsByName('cover_letter')[1].checked) {
		document.getElementsByName('cover-area')[0].style.display = '';
		document.getElementsByName('cover-area')[1].style.display = '';
		document.getElementsByName('cover-area')[2].style.display = '';
		document.getElementsByName('cover-area')[3].style.display = '';
	}
	return;
}


function generateNewAccessKey() {

	var chars = "ABCDEFGHIJKLMNOPQRSTUVWXTZ";
	var string_length = 10;
	var randomstring = '';
	for (var i = 0; i < string_length; i++) {
		var rnum = Math.floor(Math.random() * chars.length);
		randomstring += chars.substring(rnum, rnum + 1);
	}

	document.getElementById('access_key').value = randomstring;
	return;
}


function assignmentChange() {
	
	if (document.getElementById('assigned_to').value != "") {
		document.getElementById('assign_email').style.display = '';
	} else {
		document.getElementById('assign_email').style.display = 'none';
	}
	return;	
}


function statusChange() {
	
	if (document.getElementById('status').value == '2') {
		document.getElementById('ready_email').style.display = '';
		document.getElementById('send_ready_email').disabled = false;
	} else {
		document.getElementById('ready_email').style.display = 'none';
		document.getElementById('send_ready_email').disabled = true;
	}
	return;	
}

