function KiesStudyDesign(){
	document.regform.iStudyDesign.value=document.getElementById('study_design')[document.getElementById('study_design').selectedIndex].value;
}
function TestIsNumm(x){
	var isnumm=true;
	var hlp='a'+x;
	if (hlp.length<=1) {
		return false;
	} else {
		for (var i=1;i<hlp.length;i++){
			var y=hlp.substring(i,i+1);
			y=parseInt(y);
			if (isNaN(y)) {
				isnumm=false;
			}
		}
		return isnumm;
	}
}
function DoSendMail(x,y){
	//alert('DoSendMail2: x = ' + x + '\ny = ' + y);
	alert(x);

	document.MailForm.iMeldingText.value=x;
	document.MailForm.iPagID.value=y;
	document.MailForm.submit();
	window.close();
}
function KiesClinicalArea(){
	document.regform.iClinicalArea.value=document.getElementById('clinical_area')[document.getElementById('clinical_area').selectedIndex].value;
}
function CheckCorrect(){
	var hlp=document.regform.title.value;
	if (hlp.length<=0){
		alert('Please enter a title for Your study');
		return false;
	}
	/*var hlp=document.regform.objective.value;
	if (hlp.length<=0){
		alert('Please enter an objective for Your study');
		return false;
	}
	var hlp=document.regform.iStudyDesign.value;
	if (hlp==0){
		alert('Please choose a study design for Your study');
		return false;
	}*/	
	
	var nlenght = document.getElementById('uid41').options.length;
	if (nlenght==0){
		alert('Select at least one country that is linked to you study');
		return false;
	}
	
	var hlp=document.regform.study_design[document.regform.study_design.selectedIndex].text;
	if (hlp=='Make Your Choice'||hlp=='Other'){
		var hlp=document.regform.other_study_design.value;
		if (hlp.length<=0){
			alert('Choose a study design from the list, or enter another design in the input box');
			return false;
		}
	}
	
	var hlp=document.regform.iClinicalArea.value;
	if (hlp==0||hlp==696){
		var hlp=document.regform.other_clinical_area.value;
		if (hlp.length<=0){
			alert('Choose a clinical area from the list, or enter another clinical area in the input box');
			return false;
		}
	}
	var hlp=document.regform.source_of_funding.value;
	if (hlp.length<=0){
		alert('Please enter a source of funding for Your study');
		return false;
	}	
	var hlp=document.regform.number_of_patients_txt.value;
	if (hlp.length<=0){
		alert('Please enter a number of patients for Your study');
		return false;
	}else {
		//var hlp2 = parseInt(hlp);
		if (!TestIsNumm(hlp)){
			alert('Please enter a numeric value for the number of patients');
			return false;
		}
	}
	//XXX
	var hlp=document.regform.start_year.value;
	if (hlp.length<=0){
		alert('Please enter a starting year for Your study');
		return false;
	}else {
		//var hlp2 = parseInt(hlp);
		if (!TestIsNumm(hlp)){
			alert('Please enter a numeric value for the starting year');
			return false;
		}
	}var hlp=document.regform.finish_year.value;
	if (hlp.length<=0){
		alert('Please enter a finishing year for Your study');
		return false;
	}else {
		//var hlp2 = parseInt(hlp);
		if (!TestIsNumm(hlp)){
			alert('Please enter a numeric value for the finishing year');
			return false;
		}
	}
	var hlp=document.regform.generic.value;
	if (hlp.length<=0){
		alert('Please state the other generic measures You will be using');
		return false;
	}
	var hlp=document.regform.specific.value;
	if (hlp.length<=0){
		alert('Please state the other disease / condition specific health measures You will be using');
		return false;
	}
	return true;
}
function DoFinish(){
	if (CheckCorrect()){
		try {
			var nValues = document.getElementById('uid41').options.length;
			var sSel='';
			for (var v=0;v<nValues;v++){
			    sSel = sSel + '*' + document.getElementById('uid41').options[v].value;
			}
			//alert('sSel = ' + sSel);
			document.regform.SelectedCountries.value=sSel;
			/*document.regform.Actie.value='Opslaan';
			document.regform.submit();
			top.frames['Mfeedback'].ToonSaving();*/
			
			sSel = '';
			
			for (var v=0;v<nValues;v++){
			    sSel = sSel + ';' + document.getElementById('uid41').options[v].text;
			}
			
			document.regform.SelCountriesTXT.value=sSel;
		} catch (err) {alert(err.description);}
	
		document.regform.iActie.value='finish';	
		document.regform.submit();
	}
}
function DoMelding(x){
	if (x.length>0){
		alert(x);
	}
	window.close();
}
function DoMeldingC(x){
	if (x.length>0){
		alert(x);
	}
	document.regform.title.value='';
	document.regform.objective.value=''
	document.regform.other_study_design.value='';
	document.regform.other_clinical_area.value='';
	document.regform.source_of_funding.value='';
	document.regform.number_of_patients_txt.value='';
	document.regform.start_year.value='';
	document.regform.finish_year.value='';
	document.regform.generic.value='';
	document.regform.specific.value='';
	document.regform.published.value='';
	document.getElementById('study_design').selectedIndex=0;
	document.getElementById('clinical_area').selectedIndex=0;
	document.getElementById('ReportYES').checked=true;
	document.getElementById('ContactYES').checked=true;
	alert('You can now proceed to enter another study');
}
function DoMeldingE(x){
	if (x.length>0){
		alert(x);
	}
	//window.close();
}
function DoContinue(){
	if (CheckCorrect()){
		document.regform.iActie.value='Continue';	
		document.regform.submit();
		//document.location.href='RegistrationForm2.rbm';
	}
}
function SetContact(x){
	document.regform.iContact.value=x;
}
function SetReport(x){
	document.regform.iReport.value=x;
}
function VulSelectBox(x,y,z){
	//alert('VulSelectBox: y = ' + y + '\nz = ' + z + '\nx = ' + x);
	//x = FORM 
	//y = Select Name
	//z = string met nieuwe waarden
	// vervangt automatisch alle aanwezige waarden door de nieuwe lijst
	// Zet zowel de VALUE als de TEXT properties van iedere option!
	// OPTION delimiter = '&'
	// VALUE - TEXT delimiter = '*'
	
	var nValues = 'var nValues = document.'+x+'.'+y+'.length';
	eval(nValues);
	for (var v=0;v<nValues;v++){
		var oOption = 'var oOption = document.'+x+'.'+y+'.options['+v+'];';
		eval(oOption);
        var hlp2 = 'var hlp2 = document.'+x+'.'+y+'.remove(oOption.index);';
        eval(hlp2);
        nValues--;
        v--;
    }
    if (z.length>0) {
		var hlp1 = new Array();
		hlp1 = z.split('&');
		try {
    
			for (var i=0;i<hlp1.length;i++){
				var hlp2 = new Array();
				hlp2 = hlp1[i].split('*');
				var Val=hlp2[0];
				var Txt=hlp2[1];
				Val = Val.toString();
				Txt = Txt.toString();
				var MyOption = new Option(Txt,Val);
				var nValues = 'var nValues = document.'+x+'.'+y+'.length';
				eval(nValues);
				hlp2 = 'document.'+x+'.'+y+'.options.add(MyOption,'+nValues+');'
				eval(hlp2);
			}
		} catch (err) {alert('i = ' + i + '\n\n' + err.description);}
	}
}

function VoegToeXX(){
    var nValues = document.getElementById('uid40').options.length;
    for (var v=0;v<nValues;v++){
        if(document.getElementById('uid40').options[v].selected){
			var Val=document.getElementById('uid40').options[v].value;
			var Txt=document.getElementById('uid40').options[v].text;
			if (Txt!='Choose a Country'){
				var nValues2 = document.getElementById('uid41').options.length;
				var doCopy = true;
				for (var x=0;x<nValues2;x++){
					if (document.getElementById('uid40').options[v].value == document.getElementById('uid41').options[x].value)
						doCopy = false;
				}
				if(doCopy) { 
					var oOption = new Option(Txt,Val);
					var einde = document.getElementById('uid41').options.length;
					document.getElementById('uid41').options.add(oOption,einde);
				}	
            }
       }
    }
}
function VerwijderXX(){
    var nValues = document.getElementById('uid41').options.length;
    for (var v=0;v<nValues;v++){
        if(document.getElementById('uid41').options[v].selected){
			var Val=document.getElementById('uid41').options[v].value;
			var Txt=document.getElementById('uid41').options[v].text;
            var oOption = new Option(Txt,Val);
            document.getElementById('uid41').remove(v);
            var einde = document.getElementById('uid40').options.length;
            nValues--;
            v--;
        }
    }
}

