var tx_frm2_conferences_coAuthorCount = 0;

/**
 * Adds a new author field below the last one
 *
 * @param string authorBlockElement ID of the block element which contains the author fields
 * @return void
 */
function newAuthorFields(authorBlockElement) {
	// increment reference counter
	var next = ++tx_frm2_conferences_coAuthorCount;

	// important fields
	var parentElement = document.getElementById('coAuthors');
	var coAuthor = document.getElementById(authorBlockElement);

	// clone author fields
	var clonedCoAuthor = coAuthor.cloneNode(true);
	parentElement.appendChild(clonedCoAuthor);

	// modify new author fields
	clonedCoAuthor.id = 'coAuthor_' + next; // p tag
	var childNodes = clonedCoAuthor.getElementsByTagName('input');
	childNodes[0].id = 'abstractCoAuthorGivenName_' + next; // input 1
	childNodes[0].value = '';
	childNodes[1].id = 'abstractCoAuthorSurname_' + next; // input 2
	childNodes[1].value = '';
	childNodes[2].id = 'abstractCoAuthorInstitute_' + next; // input 3
	childNodes[2].value = '';
}

/**
 * Shows the original image if it's not displayed and vice versa
 *
 * @param string image ID of the block element with the image inside
 * @return void
 */
function toogleImage(image) {
	image = document.getElementById(image)
	if (image.style.width == 400 + 'px') {
		image.style.width = 40 + 'px';
		image.style.height = 50 + 'px';
		image.style.position = 'static';
	} else {
		image.style.width = 400 + 'px';
		image.style.height = 500 + 'px';
		image.style.position = 'absolute';
	}
}

/**
 * Outputs a message in a confirm box and redirects the user if he clicks on accept.
 *
 * @param string formName name of the formular which will be submitted after the user confirmed the message box
 * @param string msg message which is shown in the confirmation dialog
 * @return void
 */
function confirmMessage(formName, msg) {
	if (confirm(msg)) {
		document.forms[formName].submit();
	}
}

/**
 * This function toggles between hiding and unhiding of the given field.
 *
 * @param string field ID of the field which should be toogled
 * @return void
 */
function toogleDisplayStyleAttribute(field) {
	if (document.getElementById(field).style.display == 'none') {
		document.getElementById(field).style.display = '';
	} else {
		document.getElementById(field).style.display = 'none';
	}
}

