/*********************************************************************************************************
*makelist(bandederoulante,hiddenparam)
*bandederoulante :
*hiddenparam :
*********************************************************************************************************/
function makelist(bandederoulante,hiddenparam) {
var list="";
var length=0;
if(bandederoulante.options.length)
	length=bandederoulante.options.length;

for(var i = 0; i < length; i++) 
	list=list+bandederoulante.options[i].value+"<0>";	

document.getElementsByName(hiddenparam)[0].value = list;
return false;
}




function changeTextAreaLength (  e, MIN_ROWS, MIN_COLS, MAX_ROWS, MAX_COLS ) {

    var txtLength = e.value.length;
    var numRows = 0 ;
    var arrNewLines = e.value.split("\n");
    
    for(var i=0; i<=arrNewLines.length-1; i++){
        numRows++;
        if(arrNewLines[i].length > MAX_COLS-5) {
            numRows += Math.floor(arrNewLines[i].length/MAX_COLS)
        }   
    } 
    
    if(txtLength == 0){
	    e.cols = MIN_COLS ;
	    e.rows = MIN_ROWS ;
	} else {
	    
	    if(numRows <= 1) {
	        e.cols = (txtLength % MAX_COLS) + 1 >= MIN_COLS ? ((txtLength % MAX_COLS) + 1) : MIN_COLS ;
	    }else{
	        e.cols = MAX_COLS ;    
	        e.rows = numRows > MAX_ROWS ? MAX_ROWS : numRows ;
	    }
	}
}





function move(fbox,tbox) {
var i = 0;
if(fbox.value != "") {
var no = new Option();
no.value = fbox.value;
no.text = fbox.value;
tbox.options[tbox.options.length] = no;
fbox.value = "";
   }
}
function remove(box) {
for(var i=0; i<box.options.length; i++) {
if(box.options[i].selected && box.options[i] != "") {
box.options[i].value = "";
box.options[i].text = "";
   }
}
BumpUp(box);
} 
function BumpUp(abox) {
for(var i = 0; i < abox.options.length; i++) {
if(abox.options[i].value == "")  {
for(var j = i; j < abox.options.length - 1; j++)  {
abox.options[j].value = abox.options[j + 1].value;
abox.options[j].text = abox.options[j + 1].text;
}
var ln = i;
break;
}
}
if(ln < abox.options.length)  {
abox.options.length -= 1;
BumpUp(abox);
   }
}
function Moveup(dbox) {
for(var i = 0; i < dbox.options.length; i++) {
if (dbox.options[i].selected && dbox.options[i] != "" && dbox.options[i] != dbox.options[0]) {
var tmpval = dbox.options[i].value;
var tmpval2 = dbox.options[i].text;
dbox.options[i].value = dbox.options[i - 1].value;
dbox.options[i].text = dbox.options[i - 1].text
dbox.options[i-1].value = tmpval;
dbox.options[i-1].text = tmpval2;
      }
   }
}
function Movedown(ebox) {
for(var i = 0; i < ebox.options.length; i++) {
if (ebox.options[i].selected && ebox.options[i] != "" && ebox.options[i+1] != ebox.options[ebox.options.length]) {
var tmpval = ebox.options[i].value;
var tmpval2 = ebox.options[i].text;
ebox.options[i].value = ebox.options[i+1].value;
ebox.options[i].text = ebox.options[i+1].text
ebox.options[i+1].value = tmpval;
ebox.options[i+1].text = tmpval2;
      }
   }
}

/*
function cache_bloc(i) 
{
  //var choix = document.frm.cases;
  var choix = document.getElementsByName("cases");
  if (choix[i].checked == false)
  {
     if(document.getElementById)
		document.getElementById(i).style.display = 'none'
  }else
       if(document.getElementById)
		document.getElementById(i).style.display = 'block'

  return true;
}
*/

function cache_bloc(i) 
{  var choix = document.getElementsByName("cases");
     if(document.getElementById){
		if (document.getElementById(i).style.display == 'none')
			document.getElementById(i).style.display = 'block';

		else
			document.getElementById(i).style.display = 'none';

	 }
  return true;
}




//===================== FONCTIONS POUR =============================== 
function validate_pass(form){

	if (form.f_password1.value=='') {
		alert('Password is a required field. Please complete and revalidate.');
		form.f_password1.focus();
		return false;}
	else if (form.f_password2.value=='') {
		alert('You have to input the password 2 times. Please complete and revalidate.');
		form.f_password2.focus();
		return false;}
	else if (form.f_password1.value!=form.f_password2.value) {
		alert('The two passwords that you typed do not match, please correct the error and try again');
		form.f_password1.focus(); 
		return false;
		
		}
	
	

}
 
 function validate(form){
	if (!verif_email(form.f_email)
	|| !verif_date(form.f_day,form.f_month,form.f_year)
 	|| !verif_date(form.f_day2,form.f_month2,form.f_year2)
	)	
	return false;
}



function verif_email(formField)
{
	var email = formField.value;
	
    if (  ((email == "") || (email.indexOf ('@') == -1) || (email.indexOf ('.') == -1)) && email!=""){
     alert("you have entered an invalid email address !");
	 formField.focus();
     return false;
	}
    return true;
}

function verif_date(dayfield,monthfield,yearField)
{
	
	var day = dayfield.value, month = monthfield.value, year = yearField.value;
	
	if (year!="")
		if ( isNaN(year) || year <=1940 ) {
			alert("The year must be an integer > 1940 !");
			yearField.focus();
		    return false;
		}
		else{
			if (month=="") monthfield.value=1;
			if (day=="") dayfield.value=1;
		}
	else	
		if (month!="" || day!=""){
			alert("The date is incomplete, please enter at least the year");
			yearField.focus();
			return false;
		}
		
	
	return true;
}

/*
  function verif_date(email) {
	  
	  parseint
//if (!(isNaN(
  }
*/



/*
function SetBorder(Objet,Color){Objet.style.backgroundColor=Color;}
function Mouse(){
   	onmouseover="this.className='on';" 
    onmouseout="this.className='off';"
	onclick="window.location.href='concours.phtml?session=118&amp;onglet=acces';"
	}

function limite(zone,max)
{
if(zone.value.length>=max){zone.value=zone.value.substring(0,max);}
}


function verif() 
{ 
if (document.getElementById) 
{ 
var length = document.getElementById("1").value.length; 
// ou var length = document.f.txt.value.length; 
if ( length >= 2) 
{ 
return false; 
} 
} 
return true; 
} 
*/

