menu_conflits1 = new Array('', 'Consultant', "Sponsorisé");
menu_conflits2 = new Array('', 'Yes', 'No');
menu_conflits3 = new Array('', 'Aucun');

function loadMenu() {

	var menu = $('conflictOfInterest');

	for (i = menu.options.length-1; i >= 0; i--) {
		menu.options[i] = null;
	}
		
	var pt = $('cr_presentationType').options[$('cr_presentationType').selectedIndex].value;
	if (pt == 'ORALCOMM') {
		for (i=0; i<menu_conflits1.length; i++) {
			menu.options[i] = new Option (menu_conflits1[i], menu_conflits1[i]);
		}
	} else if (pt == 'POSTER') {
		for (i=0; i<menu_conflits2.length; i++) {
			menu.options[i] = new Option (menu_conflits2[i], menu_conflits2[i]);
		}
	} else {
		for (i=0; i<menu_conflits3.length; i++) {
			menu.options[i] = new Option (menu_conflits3[i], menu_conflits3[i]);
		}
	}

}

function wordCount (str) {
	var result = str.match(/[a-zA-Z0-9é??????äó??ö?????É??????Ä?Ó?Ö?????’']+/g);
	return (result == null) ? 0 : result.length;
}

function checkLength (obj) {
	if (wordCount(obj.value) > 275) {
		alert('The text cannot exceed 275 words');
		obj.focus();
	}
}

function abstractConfirm() {

	presentationtype = $('cr_presentationType').options[$('cr_presentationType').selectedIndex].innerHTML;
	title = $('title').value.substring(0,80);
	if (title.length > 80) {
		title = title.substring(0,80)+ '...';
	}
//	conflictOfInterest = $('conflictOfInterest').value;
	conflictOfInterest = $('conflictOfInterest').options[$('conflictOfInterest').selectedIndex].innerHTML;
	cr_mainTopic = $('cr_mainTopic').options[$('cr_mainTopic').selectedIndex].innerHTML;
	cr_workType = $('cr_workType').options[$('cr_workType').selectedIndex].innerHTML;
	keywords = $('keywords').value;
	keyMessage = $('keyMessage').value;
	body = $('body').value;
	if (body.length > 80) {
		body = body.substring(0,80)+ '...';
	}

	msg = ' ---ooo ABSTRACT SUMMARY  ooo--- ' + '\n\n';
	msg+= ' - Title : ' + title + '\n';
	msg+= ' - Type of presentation : ' + presentationtype + '\n';
	msg+= " - State of the proposed work : " + cr_workType + '\n';
	msg+= " - Conflict of interest : " + conflictOfInterest + '\n';
	msg+= ' - Main topic : ' + cr_mainTopic + '\n';
	msg+= ' - Keywords : ' + keywords + '\n';
	msg+= ' - Key message : ' + keyMessage + '\n';
	msg+= ' - Contents : ' + body + '\n';
	msg+= '------------------------------------\n'; 
	msg+= 'Comfirm abstract submission' + '\n'; 

	return window.confirm(msg);
}

function checkForm () {

	presentationtype = $('cr_presentationType').options[$('cr_presentationType').selectedIndex].value;
	cr_workType = $('cr_workType').options[$('cr_workType').selectedIndex].innerHTML;
	title = $('title').value;
	conflictOfInterest = $('conflictOfInterest').value;
	cr_mainTopic = $('cr_mainTopic').options[$('cr_mainTopic').selectedIndex].innerHTML;
	keywords = $('keywords').value;
	keyMessage = $('keyMessage').value;
	body = $('body').value;

	if (presentationtype.length==0) {
		alert('Veuillez spécifier un type de présentation');
		$('cr_presentationType').focus()
		return false;
	};

	if (title.length==0) {
		alert("You must give a title to your abstract");
		$('title').focus()
		return false;
	};

	if (cr_mainTopic.length==0) {
		alert("You must choose a main topic");
		$('cr_mainTopic').focus()
		return false;
	};

	if (body.length==0) {
		alert("Please, enter the contents");
		$('body').focus()
		return false;
	};

	if (keywords.length==0) {
		alert("Please, enter some key words with this abstract");
		$('body').focus()
		return false;
	};


	return abstractConfirm();
}