function go(i) {
	if ( (document.forms[i].login.value!="") && (document.forms[i].passe.value!="") )
		document.forms[i].submit();
}

function verif_new_codes() {
	_go = true;

	if (document.forms[0].id_societe.selectedIndex==0) {
		_go = false;
		alert("Please fill in Company field");
		}

	if (document.forms[0].prenom.value=="") {
		_go = false;
		alert("Please fill in Employee's first name");
		}
	if (document.forms[0].nom.value=="") {
		_go = false;
		alert("Please fill in Employee's last name");
		}
	if (document.forms[0].mail.value=="") {
		_go = false;
		alert("Please fill in Employee's e-mail address");
		}


	if (_go == true) document.forms[0].submit();

}

function verif_new_codes_cands() {
	_go = true;

	if (document.forms[0].prenom_spouse.value=="") {
		_go = false;
		alert("Please fill in Spouse/partner's first name");
		}
	if (document.forms[0].nom_spouse.value=="") {
		_go = false;
		alert("Please fill in Spouse/partner's last name");
		}
	if (document.forms[0].mail_spouse.value=="") {
		_go = false;
		alert("Please fill in Spouse/partner's e-mail address");
		}

	if (document.forms[0].id_pays.selectedIndex==0) {
		_go = false;
		alert("Please fill in Country field");
		}
	if (document.forms[0].id_societe.selectedIndex==0) {
		_go = false;
		alert("Please fill in Employer field");
		}

	if (document.forms[0].prenom.value=="") {
		_go = false;
		alert("Please fill in Employee's first name");
		}
	if (document.forms[0].nom.value=="") {
		_go = false;
		alert("Please fill in Employee's last name");
		}
	if (document.forms[0].mail.value=="") {
		_go = false;
		alert("Please fill in Employee's e-mail address");
		}


	if (_go == true) document.forms[0].submit();

}


function ouvrir_popup_mod(ty,id,cate,id_pays, id_societe, act, retour) {
var lg=500;
var ht=500;
var left=(screen.width-lg)/2;
var top=(screen.height-ht)/2; 
ch = "popup_mod_item.php?ty=" + ty + "&id=" + id + "&categ=" + cate + "&id_pays=" + id_pays + "&id_societe=" + id_societe + "&ACT=" + act  + "&retour=" + retour;
window.open(ch,"","top="+top+",left="+left+",width="+lg+",height="+ht+",menubar=no,scrollbars=yes,statusbar=no"); 

}

//////////////////
function OP_valide() {
			if (document.forms[0].ACT.value=="aj") document.forms[0].ACT.value="insert" ;
			else document.forms[0].ACT.value="update" ;
			document.forms[0].submit();
}

//////////////////
function lister_users() {
			document.forms[0].action="index.php";
			document.forms[0].target="_self" ;
			document.forms[0].ACT.value = "liste" ;
			_go = true ;
			if ( (document.forms[0].id_pays[document.forms[0].id_pays.selectedIndex].value=="")&& (document.forms[0].id_societe[document.forms[0].id_societe.selectedIndex].value=="") && (document.forms[0].id_categ[document.forms[0].id_categ.selectedIndex].value=="") ) {
				_go = false;
				alert("Please select a criteria");
				}
			if (_go == true) document.forms[0].submit();
}

//////////////////
function lister_users_excel() {
			_go = true ;
			if ( (document.forms[0].id_pays[document.forms[0].id_pays.selectedIndex].value=="")&& (document.forms[0].id_societe[document.forms[0].id_societe.selectedIndex].value=="") && (document.forms[0].id_categ[document.forms[0].id_categ.selectedIndex].value=="") ) {
				_go = false;
				alert("Please select a criteria");
				}
			if (_go == true) {
				document.forms[0].action="excel_users.php";
				document.forms[0].target="_blank" ;			
				document.forms[0].submit();
				}
}

//////////////////
function envoi_codes() {
			document.forms[0].ACT.value = "mail" ;
			document.forms[0].submit();
}

///////////////
function OP_sup(id) {
	if ( confirm("Are you sure?") ) {
			document.forms[0].ACT.value = "sup" ;
			document.forms[0].id.value = id ;
			document.forms[0].submit();
	} 
}

//////////////////
function aj_user() {
var lg=500;
var ht=500;
var left=(screen.width-lg)/2;
var top=(screen.height-ht)/2; 
_go = true ;
d=document.forms[0] ;
if (d.id_categ[d.id_categ.selectedIndex].value==7) { /// si local coordin pas besoin de renseigner la société
		if ( document.forms[0].id_pays[document.forms[0].id_pays.selectedIndex].value=="" || document.forms[0].id_categ[document.forms[0].id_categ.selectedIndex].value=="" ) {
			_go = false;
			alert("Please select a country and a category");
			}
		}
else {
	if ( (document.forms[0].id_pays[document.forms[0].id_pays.selectedIndex].value=="") || (document.forms[0].id_societe[document.forms[0].id_societe.selectedIndex].value=="") || (document.forms[0].id_categ[document.forms[0].id_categ.selectedIndex].value=="") ) {
		_go = false;
		alert("Please select a company, a country and a category");
		}
	}
if (_go == true) {
ch = "popup_mod_item.php?ty=users&categ=" + document.forms[0].id_categ[document.forms[0].id_categ.selectedIndex].value + "&id_pays=" + document.forms[0].id_pays[document.forms[0].id_pays.selectedIndex].value + "&id_societe=" + document.forms[0].id_societe[document.forms[0].id_societe.selectedIndex].value + "&ACT=aj&retour=liste";
window.open(ch,"","top="+top+",left="+left+",width="+lg+",height="+ht+",menubar=no,scrollbars=yes,statusbar=no"); 
}

}

//////////////////
function aj_news() {
var lg=500;
var ht=500;
var left=(screen.width-lg)/2;
var top=(screen.height-ht)/2; 
ch = "popup_mod_item.php?ty=news&ACT=aj";
window.open(ch,"","top="+top+",left="+left+",width="+lg+",height="+ht+",menubar=no,scrollbars=yes,statusbar=no"); 

}

//////////////////
function aj_member() {
var lg=500;
var ht=500;
var left=(screen.width-lg)/2;
var top=(screen.height-ht)/2; 
ch = "popup_mod_item.php?ty=members&ACT=aj";
window.open(ch,"","top="+top+",left="+left+",width="+lg+",height="+ht+",menubar=no,scrollbars=yes,statusbar=no"); 

}

//////////////////
function aj_theme_faq() {
var lg=500;
var ht=500;
var left=(screen.width-lg)/2;
var top=(screen.height-ht)/2; 
ch = "popup_mod_item.php?ty=themes_faq&ACT=aj";
window.open(ch,"","top="+top+",left="+left+",width="+lg+",height="+ht+",menubar=no,scrollbars=yes,statusbar=no"); 

}


//////////////////
function aj_theme_contact() {
var lg=500;
var ht=500;
var left=(screen.width-lg)/2;
var top=(screen.height-ht)/2; 
ch = "popup_mod_item.php?ty=contact&ACT=aj";
window.open(ch,"","top="+top+",left="+left+",width="+lg+",height="+ht+",menubar=no,scrollbars=yes,statusbar=no"); 

}

//////////////////
function aj_theme_lien() {
var lg=500;
var ht=500;
var left=(screen.width-lg)/2;
var top=(screen.height-ht)/2; 
ch = "popup_mod_item.php?ty=themes_liens&ACT=aj";
window.open(ch,"","top="+top+",left="+left+",width="+lg+",height="+ht+",menubar=no,scrollbars=yes,statusbar=no"); 

}

//////////////////
function aj_faq() {
var lg=500;
var ht=500;
var left=(screen.width-lg)/2;
var top=(screen.height-ht)/2; 
ch = "popup_mod_item.php?ty=faq&ACT=aj";
window.open(ch,"","top="+top+",left="+left+",width="+lg+",height="+ht+",menubar=no,scrollbars=yes,statusbar=no"); 

}

//////////////////
function aj_link() {
var lg=500;
var ht=500;
var left=(screen.width-lg)/2;
var top=(screen.height-ht)/2; 
ch = "popup_mod_item.php?ty=links&ACT=aj";
window.open(ch,"","top="+top+",left="+left+",width="+lg+",height="+ht+",menubar=no,scrollbars=yes,statusbar=no"); 

}

//////////////////
function aj_tool() {
var lg=500;
var ht=500;
var left=(screen.width-lg)/2;
var top=(screen.height-ht)/2; 
ch = "popup_mod_item.php?ty=tools&ACT=aj";
window.open(ch,"","top="+top+",left="+left+",width="+lg+",height="+ht+",menubar=no,scrollbars=yes,statusbar=no"); 

}

//////////////////
function aj_theme_tool() {
var lg=500;
var ht=500;
var left=(screen.width-lg)/2;
var top=(screen.height-ht)/2; 
ch = "popup_mod_item.php?ty=themes_tools&ACT=aj";
window.open(ch,"","top="+top+",left="+left+",width="+lg+",height="+ht+",menubar=no,scrollbars=yes,statusbar=no"); 

}

//////////////////
function aj_theme_forum() {
var lg=500;
var ht=500;
var left=(screen.width-lg)/2;
var top=(screen.height-ht)/2; 
ch = "popup_mod_item.php?ty=themes_forums&ACT=aj";
window.open(ch,"","top="+top+",left="+left+",width="+lg+",height="+ht+",menubar=no,scrollbars=yes,statusbar=no"); 

}



////////////////
function ouvrir_news(id_news) {
var lg=500;
var ht=500;
var left=(screen.width-lg)/2;
var top=(screen.height-ht)/2; 
ch = "popup_news.php?id_news=" + id_news;
window.open(ch,"","top="+top+",left="+left+",width="+lg+",height="+ht+",menubar=no,scrollbars=yes,statusbar=no"); 

}

////////////////
function ouvrir_success(id) {
var lg=500;
var ht=500;
var left=(screen.width-lg)/2;
var top=(screen.height-ht)/2; 
ch = "popup_success.php?id_story=" + id;
window.open(ch,"","top="+top+",left="+left+",width="+lg+",height="+ht+",menubar=no,scrollbars=yes,statusbar=no"); 
}

////////////////
function ouvrir_share() {
var lg=600;
var ht=600;
var left=(screen.width-lg)/2;
var top=(screen.height-ht)/2; 
ch = "popup_share.php";
window.open(ch,"","top="+top+",left="+left+",width="+lg+",height="+ht+",menubar=no,scrollbars=yes,statusbar=no"); 

}

////////////////
function mod_topic(id) {
var lg=400;
var ht=400;
var left=(screen.width-lg)/2;
var top=(screen.height-ht)/2; 
ch = "mod_topic.php?id_topic=" + id;
window.open(ch,"","top="+top+",left="+left+",width="+lg+",height="+ht+",menubar=no,scrollbars=yes,statusbar=no"); 

}

///////////////////////
function insertion(repdeb, repfin,i) {
	switch(i) {
		case 2 :   var input = document.forms[0].elements['texte_about1']; break;
		case 3 :   var input = document.forms[0].elements['texte_about2']; break;
		case 4 :   var input = document.forms[0].elements['texte_about3']; break;
		case 5 :   var input = document.forms[0].elements['texte_conditions']; break;
		case 50 :   var input = document.forms[0].elements['message']; break;
}

  input.focus();
  /* pour l'Explorer Internet */
  if(typeof document.selection != 'undefined') {
    /* Insertion du code de formatage */
    var range = document.selection.createRange();
    var insText = range.text;
    range.text = repdeb + insText + repfin;
    /* Ajustement de la position du curseur */
    range = document.selection.createRange();
    if (insText.length == 0) {
      range.move('character', -repfin.length);
    } else {
      range.moveStart('character', repdeb.length + insText.length + repfin.length);
    }
    range.select();
  }
  /* pour navigateurs plus récents basés sur Gecko*/
  else if(typeof input.selectionStart != 'undefined')
  {
    /* Insertion du code de formatage */
    var start = input.selectionStart;
    var end = input.selectionEnd;
    var insText = input.value.substring(start, end);
    input.value = input.value.substr(0, start) + repdeb + insText + repfin + input.value.substr(end);
    /* Ajustement de la position du curseur */
    var pos;
    if (insText.length == 0) {
      pos = start + repdeb.length;
    } else {
      pos = start + repdeb.length + insText.length + repfin.length;
    }
    input.selectionStart = pos;
    input.selectionEnd = pos;
  }
  /* pour les autres navigateurs */
  else
  {
    /* requête de la position d'insertion */
    var pos;
    var re = new RegExp('^[0-9]{0,3}$');
    while(!re.test(pos)) {
      pos = prompt("Insertion à la position (0.." + input.value.length + "):", "0");
    }
    if(pos > input.value.length) {
      pos = input.value.length;
    }
    /* Insertion du code de formatage */
    var insText = prompt("Veuillez entrer le texte à formater:");
    input.value = input.value.substr(0, pos) + repdeb + insText + repfin + input.value.substr(pos);
  }
}
////////////////////////////////////////
function OP_show(j) {
	if (ouvert==false) {
		debut_show_calendar('forms[0].dt',j) ;
		ouvert=true;
		document.forms[0].prenom.focus();
	}
	else ouvert=false ;
}

//////////////////////////////
var ouvert = false ;
function verif_share() {
	_go = true;

	if ( (document.forms[0].ty_story[0].checked==false) && (document.forms[0].ty_story[1].checked==false) ) {
		_go = false;
		alert("Please select your category (Candidate/Recruiter)");
		}
	if (document.forms[0].dt.value=="") {
		_go = false;
		alert("Please fill in submission date");
		}
	if (document.forms[0].prenom.value=="") {
		_go = false;
		alert("Please fill in your first name");
		}
	if (document.forms[0].nom.value=="") {
		_go = false;
		alert("Please fill in your last name");
		}
	if (document.forms[0].mail.value=="") {
		_go = false;
		alert("Please fill in your e-mail address");
		}
	if (document.forms[0].id_pays.selectedIndex==0) {
		_go = false;
		alert("Please fill in your country");
		}
	if (document.forms[0].poste.value=="") {
		_go = false;
		alert("Please fill in your job title");
		}
	if (document.forms[0].descrip.value=="") {
		_go = false;
		alert("Please fill in your story");
		}

	if (_go == true) document.forms[0].submit();

}

function verif_new_question() {
	_go = true;

	if ( (document.forms[0].ty_story[0].checked==false) && (document.forms[0].ty_story[1].checked==false)&& (document.forms[0].ty_story[2].checked==false) ) {
		_go = false;
		alert("Please select your category");
		}

	if (document.forms[0].prenom.value=="") {
		_go = false;
		alert("Please fill in your first name");
		}
	if (document.forms[0].nom.value=="") {
		_go = false;
		alert("Please fill in your last name");
		}
	if (document.forms[0].mail.value=="") {
		_go = false;
		alert("Please fill in your e-mail address");
		}
	if (document.forms[0].id_pays.selectedIndex==0) {
		_go = false;
		alert("Please fill in your country");
		}
	if (_go == true) document.forms[0].submit();

}

///////////////////////////
function liste_faq() {
	_go = true;
	if ( document.forms[0].id_theme_faq.selectedIndex==0 ) {
		alert("Please select a criteria") ;
		_go = false;
		}
	if (_go == true) document.forms[0].submit();
}

///////////////////////////
function liste_forums() {
	_go = true;
	if ( document.forms[0].id_theme.selectedIndex==0 ) {
		alert("Please select a theme") ;
		_go = false;
		}
	if (_go == true) document.forms[0].submit();
}

///////////////////////////
function liste_links() {
	_go = true;
	if ( (document.forms[0].id_region.selectedIndex==0) && (document.forms[0].id_theme_lien.selectedIndex==0) ) {
		alert("Please select a criteria") ;
		_go = false;
		}
	if (_go == true) document.forms[0].submit();
}

///////////////////////////
function liste_tools() {
	_go = true;
	if ( (document.forms[0].id_theme_tool.selectedIndex==0) ) {
		alert("Please select a criteria") ;
		_go = false;
		}
	if (_go == true) document.forms[0].submit();
}

/////////////////////////
function verif_contact() {
	_go = true;
	document.forms['form1'].ACT.value = "ok" ;
	if (document.forms['form1'].mail.value=="") {
		_go = false;
		alert("Please fill in your e-mail address");
		}
	if (document.forms['form1'].sujet.selectedIndex==0) {
		_go = false;
		alert("Please select a subject");
		}
	if (document.forms['form1'].comment.value=="") {
		_go = false;
		alert("Please fill in your comments");
		}

	if (_go == true) document.forms['form1'].submit();

}

/////////////////////////
function verif_new_topic() {
	_go = true;
	if (document.forms[0].texte.value=="") {
		_go = false;
		alert("Please fill in your subject");
		}
	if (_go == true) {
		document.forms[0].ACT.value="new_topic_cands" ;
		document.forms[0].submit();
		}

}

/////////////////////////
function verif_new_topic_man() {
	_go = true;
	if (document.forms[0].texte.value=="") {
		_go = false;
		alert("Please fill in your subject");
		}
	if (_go == true) {
		document.forms[0].ACT.value="new_topic_man" ;
		document.forms[0].submit();
		}

}


/////////////////////////
function verif_new_answer() {
	_go = true;
	if (document.forms[0].texte.value=="") {
		_go = false;
		alert("Please fill in your answer");
		}
	if (_go == true) document.forms[0].submit();

}

function verif_liste_bulk() {
	_go = true;

	if (_go == true) {
		document.forms[0].ACT.value = "liste" ;
		document.forms[0].submit();
		}
}

function mailing() {
	_go = true;

	if (_go == true) {
		document.forms[0].ACT.value = "mailing" ;
		document.forms[0].submit();
		}
}

////////////////////////////////////////////////////////////////
function tout_cocher()
{
    var elts      =  document.forms[0].elements['panier[]'];

    var elts_cnt  = (typeof(elts.length) != 'undefined')? elts.length : 0;
    if (elts_cnt) {
        for (var i = 0; i < elts_cnt; i++) {
            elts[i].checked = true;
        } // end for
    } else {
        elts.checked        = true;
    } // end if... else

    return true;
}

function tout_decocher()
{
    var elts      =  document.forms[0].elements['panier[]'];

    var elts_cnt  = (typeof(elts.length) != 'undefined')? elts.length : 0;
    if (elts_cnt) {
        for (var i = 0; i < elts_cnt; i++) {
            elts[i].checked = false;
        } // end for
    } else {
        elts.checked        = false;
    } // end if... else

    return true;
} 

function confirm_del_topic(id,dest, id_theme) {
	if (confirm("Are you sure?")) {
		document.location="index.php?rub=admin&item=" + dest + "&ACT=sup_topic&id_topic=" + id  + "&id_theme=" + id_theme;
		}
}

function confirm_del_post(id,id_ref, dest) {
	if (confirm("Are you sure?")) {
		document.location="index.php?rub=admin&item=" + dest + "&ACT=sup_post&id_topic=" + id_ref + "&id_topic_sup=" + id ;
		}
}

function lister_success_pays() {
	document.location = "index.php?rub=admin&item=success&id_pays=" + document.forms[0].id_pays[document.forms[0].id_pays.selectedIndex].value ;

}

/////////////////////
function ouvre_mail_masse() {
	d=document.forms['0'];
	_go = true;
	var elts      =  document.forms[0].elements['id_user[]'];
    var elts_cnt  = (typeof(elts.length) != 'undefined')? elts.length : 0;
	coche = false ;
    if (elts_cnt) {
        for (var i = 0 ; i < elts_cnt ; i++) {
            if (elts[i].checked==true) coche = true ;
       		 } 
 		  } 
	else {
        	if (elts.checked==true) coche = true;
  		  }
	if (coche==false) {
		alert("Please check at least one User");
		_go = false ;
	}
	if (_go==true) {
		var lg=500;
		var ht=500;
		var left=(screen.width-lg)/2 ;
		var top=(screen.height-ht)/2; 
		ch = "popup_mail_masse.php";
		window.open(ch,"fen","top="+top+",left="+left+",width="+lg+",height="+ht+",menubar=no,scrollbars=yes,statusbar=no"); 
		d.action = "popup_mail_masse.php";
		d.target="fen"; 
		d.submit();	
	}
}


/////////////////////
function ouvre_mail_masse_bis() {
	d=document.forms['0'];
	_go = true;
	var elts      =  document.forms[0].elements['id_user[]'];
    var elts_cnt  = (typeof(elts.length) != 'undefined')? elts.length : 0;
	coche = false ;
    if (elts_cnt) {
        for (var i = 0 ; i < elts_cnt ; i++) {
            if (elts[i].checked==true) coche = true ;
       		 } 
 		  } 
	else {
        	if (elts.checked==true) coche = true;
  		  }
	if (coche==false) {
		alert("Please check at least one User");
		_go = false ;
	}
	if (_go==true) {
		var lg=500;
		var ht=500;
		var left=(screen.width-lg)/2 ;
		var top=(screen.height-ht)/2; 
		ch = "popup_mail_masse_bis.php";
		window.open(ch,"fen","top="+top+",left="+left+",width="+lg+",height="+ht+",menubar=no,scrollbars=yes,statusbar=no"); 
		d.action = "popup_mail_masse_bis.php";
		d.target="fen"; 
		d.submit();	
	}
}


/////////////////////
function ouvre_delete_masse() {
	d=document.forms['0'];
	_go = true;
	var elts      =  document.forms[0].elements['id_user[]'];
    var elts_cnt  = (typeof(elts.length) != 'undefined')? elts.length : 0;
	coche = false ;
    if (elts_cnt) {
        for (var i = 0; i < elts_cnt; i++) {
            if (elts[i].checked==true) coche = true ;
       		 } 
 		  } 
	else {
        	if (elts.checked==true) coche = true;
  		  }
	if (coche==false) {
		alert("Please check at least one User");
		_go = false ;
	}
	if (_go==true) {
		var lg=500;
		var ht=500;
		var left=(screen.width-lg)/2 ;
		var top=(screen.height-ht)/2; 
		ch = "popup_delete_masse.php";
		window.open(ch,"fen","top="+top+",left="+left+",width="+lg+",height="+ht+",menubar=no,scrollbars=yes,statusbar=no"); 
		d.action = "popup_delete_masse.php";
		d.target="fen"; 
		d.submit();	
	}
}



