/*
Client: ISB
Project: 20 years
Author: Mathias Currat (mathias.currat@cybmed.com)
Date: 2005-09-26

Version: 1
Revision: 1
Age: 0

History:
	2005-06-23: genesis

Notes:
	2005-06-23: initial version

*/
/*
Check if form elements have been filled and return error message if not
Login form
*/
function checklogin(form)
{
// see http://www.thesitewizard.com/archive/validation.shtml
// for an explanation of this script and how to use it on your
// own website

 // ** START **
 if (form.username.value == "") {
 	alert( "Your username is missing.\nPlease try again." );
 	form.username.focus();
 	return false ;
 }
 if (form.password.value == "") {
 	alert( "Your password is missing.\nPlease try again." );
 	form.password.focus();
 	return false ;
 }

 // ** END **
 return true ;
}

/*
Check if form elements for mailing list have been filled and return error message if not
*/

function checkformemail(form)
{
// see http://www.thesitewizard.com/archive/validation.shtml
// for an explanation of this script and how to use it on your
// own website

 // ** START **
 if (form.name.value == "") {
 	alert( "Your name is missing.\nPlease try again." );
 	form.name.focus();
 	return false ;
 }
 if (form.affiliation.value == "") {
 	alert( "Your affiliation is missing.\nPlease try again." );
 	form.affiliation.focus();
 	return false ;
 }
 if (form.email.value == "") {
 	alert( "Your E-mail adress is missing.\nPlease try again." );
 	form.email.focus();
 	return false ;
 }
 // ** END **
 return true ;
}

/*
Check if form elements have been filled and return error message if not
Poster submission - First Author form
*/

function checkposter(form)
{
// see http://www.thesitewizard.com/archive/validation.shtml
// for an explanation of this script and how to use it on your
// own website

 // ** START **
 if (form.Ftitle.value == "None") {
 	alert( "The title is missing.\nPlease try again." );
 	form.Ftitle.focus();
 	return false ;
 }
if (form.Ffirst.value == "") {
 	alert( "The first name is missing.\nPlease try again." );
 	form.Ffirst.focus();
 	return false ;
 }
if (form.Flast.value == "") {
 	alert( "The last name is missing.\nPlease try again." );
 	form.Flast.focus();
 	return false ;
 }
if (form.Faff.value == "") {
 	alert( "The affiliation is missing.\nPlease try again." );
 	form.Faff.focus();
 	return false ;
 }

 // ** END **
 return true ;
}

/*
Check if form elements have been filled and return error message if not
Poster submission - First Author form
*/

function checkposter2(form)
{
// see http://www.thesitewizard.com/archive/validation.shtml
// for an explanation of this script and how to use it on your
// own website

 // ** START **
if (form.Otitle.value == "None") {
 	alert( "The title is missing.\nPlease try again." );
 	form.Otitle.focus();
 	return false ;
 }
 if (form.Ofirst.value == "") {
 	alert( "The first name is missing.\nPlease try again." );
 	form.Ofirst.focus();
 	return false ;
 }
if (form.Olast.value == "") {
 	alert( "The last name is missing.\nPlease try again." );
 	form.Olast.focus();
 	return false ;
 }
if (form.Oaff.value == "") {
 	alert( "The affiliation is missing.\nPlease try again." );
 	form.Oaff.focus();
 	return false ;
 }

 // ** END **
 return true ;
}

/*
Check if form elements have been filled and return error message if not
Poster submission - Poster form
*/
function checkposter3(form)
{
// see http://www.thesitewizard.com/archive/validation.shtml
// for an explanation of this script and how to use it on your
// own website

 // ** START **
if (form.abst.value == "") {
 	alert( "The abstract is missing.\nPlease try again." );
 	form.abst.focus();
 	return false ;
 }

 // ** END **
 return true ;
}

/*
Check if form elements have been filled and return error message if not
Poster submission - Poster form
*/
function checkposter4(form)
{
// see http://www.thesitewizard.com/archive/validation.shtml
// for an explanation of this script and how to use it on your
// own website

 // ** START **
if (form.ptitle.value == "") {
 	alert( "The title is missing.\nPlease try again." );
 	form.ptitle.focus();
 	return false ;
 }

 // ** END **
 return true ;
}

/*
Check if form elements have been filled and return error message if not
Registration before poster submission
*/

function checkposterreg(form)
{
// see http://www.thesitewizard.com/archive/validation.shtml
// for an explanation of this script and how to use it on your
// own website

 // ** START **
 if (form.r_title.value == "None") {
 	alert( "The title is missing.\nPlease try again." );
 	form.r_title.focus();
 	return false ;
 }
 if (form.r_first.value == "") {
 	alert( "The first name is missing.\nPlease try again." );
 	form.r_first.focus();
 	return false ;
 }
 if (form.r_last.value == "") {
 	alert( "The last name is missing.\nPlease try again." );
 	form.r_last.focus();
 	return false ;
 }
 if (form.r_email.value == "") {
 	alert( "The e-mail is missing.\nPlease try again." );
 	form.r_email.focus();
 	return false ;
 }
 if (form.r_picto.value == "") {
 	alert( "The text from the pictogram is missing.\nPlease try again." );
 	form.r_picto.focus();
 	return false ;
 }

 
 // ** END **
 return true ;
}

/*
Check if form elements have been filled and return error message if not
Registration form
*/

function checkregistration(form)
{
// see http://www.thesitewizard.com/archive/validation.shtml
// for an explanation of this script and how to use it on your
// own website

 // ** START **
 if (form.r_title.value == "None") {
 	alert( "The title is missing.\nPlease try again." );
 	form.r_title.focus();
 	return false ;
 }
 if (form.r_first.value == "") {
 	alert( "The first name is missing.\nPlease try again." );
 	form.r_first.focus();
 	return false ;
 }
 if (form.r_last.value == "") {
 	alert( "The last name is missing.\nPlease try again." );
 	form.r_last.focus();
 	return false ;
 }
 if (form.r_dpt.value == "") {
 	alert( "The departement is missing.\nPlease try again." );
 	form.r_dpt.focus();
 	return false ;
 }
 if (form.r_inst.value == "") {
 	alert( "The institution is missing.\nPlease try again." );
 	form.r_inst.focus();
 	return false ;
 }
 if (form.r_ad1.value == "") {
 	alert( "The adress is missing.\nPlease try again." );
 	form.r_ad1.focus();
 	return false ;
 }
 if (form.r_pc.value == "") {
 	alert( "The postal code is missing.\nPlease try again." );
 	form.r_pc.focus();
 	return false ;
 }
 if (form.r_city.value == "") {
 	alert( "The city is missing.\nPlease try again." );
 	form.r_city.focus();
 	return false ;
 }
 if (form.r_ctry.value == "None") {
 	alert( "The country is missing.\nPlease try again." );
 	form.r_ctry.focus();
 	return false ;
 }
 if (form.r_phone.value == "") {
 	alert( "The phone number is missing.\nPlease try again." );
 	form.r_phone.focus();
 	return false ;
 }
 if (form.r_email.value == "") {
 	alert( "The e-mail is missing.\nPlease try again." );
 	form.r_email.focus();
 	return false ;
 }
 /*
 if (form.r_cat.value == "None") {
 	alert( "The category is missing.\nPlease try again." );
 	form.r_cat.focus();
 	return false ;
 }
 */ 
 if (form.r_cat1.checked == false && form.r_cat2.checked == false) {
  	alert( "The category is missing.\nPlease try again." );
  	form.r_cat1.focus();
  	return false ;
 } 
 if (form.r_terms.checked == false) {
 	alert( "You must read and accept the congress terms.\nPlease try again." );
 	form.r_terms.focus();
 	return false ;
 }
 if (form.r_picto.value == "") {
 	alert( "The text from the pictogram is missing.\nPlease try again." );
 	form.r_picto.focus();
 	return false ;
 }
 
 // ** END **
 return true ;
}

/*
Check if form elements have been filled and return error message if not
A new participant form (admin section)
*/

function checkinvitation(form)
{
// see http://www.thesitewizard.com/archive/validation.shtml
// for an explanation of this script and how to use it on your
// own website


 // ** START **
 if (form.r_title.value == "None") {
 	alert( "The title is missing.\nPlease try again." );
 	form.r_title.focus();
 	return false ;
 }
 if (form.r_first.value == "") {
 	alert( "The first name is missing.\nPlease try again." );
 	form.r_first.focus();
 	return false ;
 }
 if (form.r_last.value == "") {
 	alert( "The last name is missing.\nPlease try again." );
 	form.r_last.focus();
 	return false ;
 }
 if (form.r_dpt.value == "") {
 	alert( "The departement is missing.\nPlease try again." );
 	form.r_dpt.focus();
 	return false ;
 }
 if (form.r_inst.value == "") {
 	alert( "The institution is missing.\nPlease try again." );
 	form.r_inst.focus();
 	return false ;
 }
 if (form.r_ad1.value == "") {
 	alert( "The adress is missing.\nPlease try again." );
 	form.r_ad1.focus();
 	return false ;
 }
 if (form.r_pc.value == "") {
 	alert( "The postal code is missing.\nPlease try again." );
 	form.r_pc.focus();
 	return false ;
 }
 if (form.r_city.value == "") {
 	alert( "The city is missing.\nPlease try again." );
 	form.r_city.focus();
 	return false ;
 }
 if (form.r_ctry.value == "None") {
 	alert( "The country is missing.\nPlease try again." );
 	form.r_ctry.focus();
 	return false ;
 }
 if (form.r_phone.value == "") {
 	alert( "The phone number is missing.\nPlease try again." );
 	form.r_phone.focus();
 	return false ;
 }
 if (form.r_email.value == "") {
 	alert( "The e-mail is missing.\nPlease try again." );
 	form.r_email.focus();
 	return false ;
 }
 if (form.r_cat1.checked == false && form.r_cat2.checked == false && form.r_cat3.checked == false && form.r_cat4.checked == false && form.r_cat5.checked == false) {
  	alert( "The category is missing.\nPlease try again." );
  	form.r_cat1.focus();
  	return false ;

}
 
 // ** END **
 return true ;
}

/*
Check if form elements have been filled and return error message if not
Password Help - Answer Hint
*/
function checkanswer(form)
{
// see http://www.thesitewizard.com/archive/validation.shtml
// for an explanation of this script and how to use it on your
// own website

 if (form.answer.value == "") {
 	alert( "The hint answer is missing.\nPlease try again." );
 	form.answer.focus();
 	return false ;
 }
 
 // ** END **
 return true ;
}
/*
Check if form elements have been filled and return error message if not
Password Help - changePassword
*/
function checkpasswords(form)
{
// see http://www.thesitewizard.com/archive/validation.shtml
// for an explanation of this script and how to use it on your
// own website

if (form.psswrd.value.length < 6 ) {
 	alert( "Your password must be at least 6 char long.\nPlease try again." );
 	form.psswrd.focus();
 	return false ;
}
if (form.psswrd.value != form.repsswrd.value) {
 	alert( "Both occurence of the password are different.\nPlease try again." );
 	form.repsswrd.focus();
 	return false ;
 }
 
 // ** END **
 return true ;
}

/*
	::: doPopups :::::::::::::::::::::::::::::::::::::::::::::
	:::	fct: opens a link in a new browser window
	:::	ori: http://adactio.com/atmedia2005/
*/
function doPopups() {
  if (!document.getElementsByTagName) return false;
  var links = document.getElementsByTagName("a");
  for (var i=0; i < links.length; i++) {
    if (links[i].className.match("popup")) {
      links[i].onclick = function() {
        window.open(this.href);
        return false;
      }
    }
  }
}

/*
	::: window.onload :::::::::::::::::::::::::::::::::::::::::::::
*/
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

addLoadEvent(doPopups);



/*
Check if form elements have been filled and return error message if not
Administration - Poster comment form
*/
function checkcomment(form)
{
// see http://www.thesitewizard.com/archive/validation.shtml
// for an explanation of this script and how to use it on your
// own website

 // ** START **
 if (form.cname.value == "") {
 	alert( "Your name is missing.\nPlease try again." );
 	form.cname.focus();
 	return false ;
 }
 if (form.com.value == "") {
 	alert( "Your comment is missing.\nPlease try again." );
 	form.com.focus();
 	return false ;
 }
 // ** END **
 return true ;
}

