function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


function changeSection(requestURI)
{
	var section = document.sectionForm.section.options[document.sectionForm.section.selectedIndex].value;
	var currentURL = location.href;
	var newAction = "";
	if (currentURL.indexOf("&") == -1)
	{
		newAction = currentURL + "&section=" + section;
	}else{
		newAction = currentURL.substring(0,currentURL.indexOf("&")) + "&section=" + section;
	}
	
	location.href = newAction;
}

function verifForm()
{

	var alertEmail = "L'Email n'est pas valide. Il doit être sous la forme dupont@domaine.xx!";
	var alertAnnee = "L'année est obligatoire!";
	var alertAnneeNumeric = "L'année n'est pas valide!";
	var alertNom = "Le Nom ou le Totem est obligatoire!";

	if ( document.camps_scouts.nom.value == '' )
	{
		alert(alertNom);
		return false;
	}


	if ( document.camps_scouts.annee.value == '' )
	{
		alert(alertAnnee);
		return false;
	}

	if ( document.camps_scouts.annee.value.length != 4 ||
			!isNumeric(document.camps_scouts.annee.value))
	{
		alert(alertAnneeNumeric);
		return false;


	}

	if ( document.camps_scouts.camps_scouts_ville.value == '' )
	{
		alert(alertVille);
		return false;
	}

	if ( document.camps_scouts.email.value != '' && !emailValidation(document.camps_scouts.email.value))
	{
		alert(alertEmail);
		return false;


	}
	return true;

}


function emailValidation(emailString)
/*
 * Email validity checker *
 * Parameter(s):
   * strEmail       (needed)         String expression containing the email address candidate

  * Examples:
    * isValidEmail('aaBBcc')     will return FALSE
    * isValidEmail('@mydom.com') will return FALSE
    * isValidEmail('ee@.com')    will return FALSE
    * isValidEmail('e%e@dom.cc') will return TRUE
    * isValidEmail('e%e@dom.cc',false) will return TRUE
    * isValidEmail('e%e@dom.cc',true)  will return FALSE

  * Remark:
    * Also validation of characters
*/

{
      var strEmail = emailString;

      var myFlag = false;

      if ( isFilled(strEmail)
        && (strEmail.indexOf('@@') == -1)
        && (strEmail.indexOf('..') == -1)
        && (strEmail.indexOf('.@') == -1)
        && (strEmail.indexOf('@.') == -1) )
      {
            // in a email address, '@' must be at least in the second position
            var at = strEmail.indexOf('@',1);
            if (at != -1)
            {
                  // in a email address, '.' must be at least one character after '@'... x@strEmail.strEmail is the minimal email
                  var dot = strEmail.indexOf('.', at+3);

                  if (dot != -1)
                  {
                        // there must have at least two char after the '.' ... and the email could be something like anything@strEmail.yy.dom
                        dot = strEmail.lastIndexOf('.');
                        if (dot+2 < strEmail.length)  // the index of the last char in a string is 'string.length-1'
                        {
                              // check for valid characters
                              if (isValidEmailCharacters(strEmail))
                              {
                                    { myFlag = true; }
                              }
                              else
                                    { myFlag = false; }
                        }
                  }
            }
      }

      return myFlag;
}

function isValidEmailCharacters(strEmail)
{
			var okBoolean;
      for (var i = 0; i < strEmail.length; i++)
      {
            var ch = strEmail.substring(i, i + 1);
            if ((ch >= "A" && ch <= "Z") || (ch >= "a" && ch <= "z")
                        || (ch == "@") || (ch == ".") || (ch == "_")
                        || (ch == "-") || (ch >= "0" && ch <= "9"))
            {
            	okBoolean = true;
          	} else {
          		okBoolean = false;
          		return false;
          	}
      }
      return okBoolean;

}

function isFilled(myString)
{
     return !(myString == "" || myString == null);
}

function isNumeric(myString)
{
	var okBoolean = false;
	for (var i = 0; i < myString.length; i++)
	{
		var ch = myString.substring(i, i + 1);
		if (ch >= "0" && ch <= "9")
		{
			okBoolean = true;
		} else {
			okBoolean = false;
			return false;
		}
	}
	return okBoolean;
}