var _dt_sep = "/";
var _dt_f_j = "0";
var _dt_f_m = "1";
var _dt_f_a = "2";
var _dt_wc_df = "JJ/MM/AAAA";
var _dt_nb_y = "4";
var _ipb = "false";
var _pbs = "";
var _vr = false;
var _ppos = "";
function body_onLoad() {
//selectActiveField();
_bLoaded = true;
jQuery(document).ready(function() {
	
	
	$('select#lstPaysRech_left').live('dblclick', function(){
		__wms_a('lstPaysRech',false,'','0','');
		getRegions();
		getEtablissements();
	});
	$('select#lstPaysRech_right').live('dblclick', function(){
		__wms_r('lstPaysRech',false,'');
		getRegions();
		getEtablissements();
		$('select#lstRegionRech_right').empty();
		$('select#lstDepartementRech_right').empty();
	});
	
	$('#lstPaysRech_btnAdd').live('click', function(){
		$('select#lstPaysRech_left').dblclick();
	});
	$('#lstPaysRech_btnRemove').live('click', function(){
		$('select#lstPaysRech_right').dblclick();
	});
	
	
	$('select#lstRegionRech_left').live('dblclick', function(){
		__wms_a('lstRegionRech',false,'','0','');
		getEtablissements();
	});
	$('select#lstRegionRech_right').live('dblclick', function(){
		__wms_r('lstRegionRech',false,'');
		getEtablissements();
		$('select#lstDepartementRech_right').empty();
	});

	$('#lstRegionRech_btnAdd').live('click', function(){
		$('select#lstRegionRech_left').dblclick();
	});
	$('#lstRegionRech_btnRemove').live('click', function(){
		$('select#lstRegionRech_right').dblclick();
	});

	
	$('form#MainForm').submit(function(){
		var _infosSaisies = true;
		
		var civilite = $('#lstCivilite').val();
		if(!civilite || civilite == '' ){
			_infosSaisies = false;
			var _msg1 = $('#lstCivilite_alert');
			_msg1.show();
			$('#lstCivilite').focus(function(){
				_msg1.hide();
			});
		}
		var nom = $('#txtNom').val();
		if(!nom || nom == '' ){
			_infosSaisies = false;
			var _msg2 = $('#txtNom_alert');
			_msg2.show();
			$('#txtNom').focus(function(){
				_msg2.hide();
			});
		}
		var prenom = $('#txtPrenom').val();
		if(!prenom || prenom == '' ){
			_infosSaisies = false;
			var _msg3 = $('#txtPrenom_alert');
			_msg3.show();
			$('#txtPrenom').focus(function(){
				_msg3.hide();
			});
		}
		var cp = $('#txtCodePostal').val();
		if(!cp || cp == '' ){
			_infosSaisies = false;
			var _msg4 = $('#txtCodePostal_alert');
			_msg4.show();
			$('#txtCodePostal').focus(function(){
				_msg4.hide();
			});
		}
		
		var email = $('#txtMail').val();
		if(!email || email == '' ){
			_infosSaisies = false;
			var _msg5 = $('#txtMail_alert');
			_msg5.show();
			$('#txtMail').focus(function(){
				_msg5.hide();
			});
		}
		
		var telFixe = $('#txtTelFixe').val();
		var telPort = $('#txtTelPortable').val();
		if( (!telFixe || telFixe == '') && (!telPort || telPort == '') ){
			_infosSaisies = false;
			var _msg6 = $('#txtTel_alert');
			_msg6.show();
			$('#txtTelPortable').focus(function(){
				_msg6.hide();
			});
			$('#txtTelFixe').focus( function(){
				_msg6.hide();
			});
		}
		
		
		var cv = $('#oUploadCV').val();
		if(!cv || cv == '' ){
			_infosSaisies = false;
			var _msg7 = $('#oUploadCV_alert');
			_msg7.show();
			$('#oUploadCV').focus(function(){
				_msg7.hide();
			});
		}
		

		if($('select#lstPaysRech_right')[0] && $('select#lstPaysRech_right option').length == 0){
			_infosSaisies = false;
			var _msg8 = $('#lstPaysRech_alert');
			_msg8.show();
			$('select#lstPaysRech_left, #lstPaysRech_btnAdd').focus(function(){
				_msg8.hide();
			});
		}
		if($('select#lstRegionRech_right')[0] && $('select#lstRegionRech_right option').length == 0){
			_infosSaisies = false;
			var _msg9 = $('#lstRegionRech_alert');
			_msg9.show();
			$('select#lstRegionRech_left, #lstRegionRech_btnAdd').focus(function(){
				_msg9.hide();
			});
		}
		if($('select#lstDepartementRech_right')[0] && $('select#lstDepartementRech_right option').length == 0){
			_infosSaisies = false;
			var _msg10 = $('#lstDepartementRech_alert');
			_msg10.show();
			$('select#lstDepartementRech_left,#lstDepartementRech_btnAdd').focus(function(){
				_msg10.hide();
			});
		}
		if($('select#lstSecteurRech_right')[0] && $('select#lstSecteurRech_right option').length == 0){
			_infosSaisies = false;
			var _msg11 = $('#lstSecteurRech_alert');
			_msg11.show();
			$('select#lstSecteurRech_left, #lstSecteurRech_btnAdd').focus(function(){
				_msg11.hide();
			});
		}
		if($('select#lstFiliereRech_right')[0] && $('select#lstFiliereRech_right option').length == 0){
			_infosSaisies = false;
			var _msg12 = $('#lstFiliereRech_alert');
			_msg12.show();
			$('select#lstFiliereRech_left, #lstFiliereRech_btnAdd').focus(function(){
				_msg12.hide();
			});
		}
		if($('select#lstMetierRech_right')[0] && $('select#lstMetierRech_right option').length == 0){
			_infosSaisies = false;
			var _msg13 = $('#lstMetierRech_alert');
			_msg13.show();
			$('select#lstMetierRech_left, #lstMetierRech_btnAdd').focus(function(){
				_msg13.hide();
			});
		}
		if($('select#lstTypeContratRech_right')[0] && $('select#lstTypeContratRech_right option').length == 0){
			_infosSaisies = false;
			var _msg14 = $('#lstTypeContratRech_alert');
			_msg14.show();
			$('select#lstTypeContratRech_left, #lstTypeContratRech_btnAdd').focus(function(){
				_msg14.hide();
			});
		}
		
		
		if(_infosSaisies){
			ta('btnEnregistrer',true);
			$('#btnEnregistrer').attr("disabled","disabled");
		}
		return _infosSaisies;
	});
});
}
var _strJSI = "/jsinterface.php?scriptname=recrute%2Ffo_form_cand.php&classname=Base_fo_form_cand";
var _aCtrls = new Array();
var _aParams = new Array("Readonly","new","IDCandidat","id","idpartenaire","iIDCandidat","iIDMailing","txtMail","txtCle");
function oUploadCV_btn_click() {
	window.open('http://sodifrance.profilsearch.com/psframeworkfo/webcontrols/resources/fileselector_2_5.php?lang=fr&rep=%2Fwww%2Fsodifrance.profilsearch.com%2Fweb%2Fpj%2Ftemp%2F&nom_champs=oUploadCV&value=&img=false&apb=true&mfs=1000000&ext=doc,rtf,html,htm,txt,pdf,xls,csv,gif,jpg,jpeg,odt,ott,oth,odg,ods,png,ppt,pps,wps', 'fileselector', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=520,height=270,top=200,left=200');
}

function oUploadLM_btn_click() {
	window.open('http://sodifrance.profilsearch.com/psframeworkfo/webcontrols/resources/fileselector_2_5.php?lang=fr&rep=%2Fwww%2Fsodifrance.profilsearch.com%2Fweb%2Fpj%2Ftemp%2F&nom_champs=oUploadLM&value=&img=false&apb=true&mfs=1000000&ext=doc,rtf,html,htm,txt,pdf,xls,csv,gif,jpg,jpeg,odt,ott,oth,odg,ods,png,ppt,pps,wps', 'fileselector', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=520,height=270,top=200,left=200');
}

function uplFileCV_btn_click() {
	window.open('http://sodifrance.profilsearch.com/psframeworkfo/webcontrols/resources/fileselector_2_5.php?lang=fr&rep=%2Fwww%2Fsodifrance.profilsearch.com%2Fweb%2Fpj%2Ftemp%2F&nom_champs=uplFileCV&value=&img=false&apb=true&mfs=1000000&ext=doc,rtf,html,htm,txt,pdf,xls,csv,gif,jpg,jpeg,odt,ott,oth,odg,ods,png,ppt,pps,wps', 'fileselector', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=520,height=270,top=200,left=200');
}

function uplFileLM_btn_click() {
	window.open('http://sodifrance.profilsearch.com/psframeworkfo/webcontrols/resources/fileselector_2_5.php?lang=fr&rep=%2Fwww%2Fsodifrance.profilsearch.com%2Fweb%2Fpj%2Ftemp%2F&nom_champs=uplFileLM&value=&img=false&apb=true&mfs=1000000&ext=doc,rtf,html,htm,txt,pdf,xls,csv,gif,jpg,jpeg,odt,ott,oth,odg,ods,png,ppt,pps,wps', 'fileselector', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=520,height=270,top=200,left=200');
}

function lanSel_change(strVal) {
	var oTxt=document.getElementById("lanSel");
	oTxt.value = strVal;
	throwPostBack("lanSel")
}

function removeMsgErr(id){
	var noeud = document.getElementById(id);
	if(noeud){
		noeud.parentNode.removeChild(noeud);
	}
	
}

function getZoneGeographique(zonetype,zoneid) {
	var _url = "/?eID=oxcs_offresemploi_check_region";
	if(zonetype && zonetype != '' && zoneid && zoneid != ''){
		_url += "&" + zonetype + "=" + zoneid;
	}
	
	var reponse = $.ajax({
		  type: "GET",
		  url: _url,
		  async: false
		}).responseText;
	
	return reponse;
}

function getRegions(){
	var _tabpays = new Array();
	$('select#lstPaysRech_right option').each( function(){
		_tabpays.push($(this).val());
	});
	var _strpays = _tabpays.length > 0 ? _tabpays.join(',') : 'all';
	
	$('select#lstRegionRech_left').html(getZoneGeographique('pays', _strpays ));
}

function getEtablissements(){
	var _tabregions = new Array();
	if($('select#lstRegionRech_right option').length > 0 ){
		$('select#lstRegionRech_right option').each( function(){
			_tabregions.push($(this).val());
		});
	}
	else{
		$('select#lstRegionRech_left option').each( function(){
			_tabregions.push($(this).val());
		});
	}
	
	var _strregions = _tabregions.join(',');
	$('select#lstDepartementRech_left').html(getZoneGeographique('region', _strregions ));
}



