/* JavaScript File  */
var BrowserName = navigator.appName;
var IsUnknown;
var IsMSIE;
var IsFirefox;
var IsNetscape;
var IsOpera;
var IsSafari;
var IsKonqueror;
var IsOSWIN;
var IsOSLinux;
var IsOSUnix;
var IsOSMac;
var IsOSUnknown;
var eventAdded=false;
var loading=false;
var currTopMenuIndex;
var _DOC = new Document();
var _GUI = new GUI();
var _Client = new Client();
var _Browser = new Browser();
var _Validation = new Validation();
var _Cookies = new Cookies();
var isDebug = false;
var _String = new Strings();
var needToConfirm = false;

window.onload = function PageLoad() {
    var pageName = _Browser.PageName();

    try {
        _Client.AssignCSSfiles();
        // Top Menu Assignation...
        if (pageName == 'CandidatInscription.aspx' || pageName == 'CandidatLogin.aspx') { currTopMenuIndex = 2; }
        else { currTopMenuIndex = 1; }
        // Default Pages Assignations...
        if (pageName != 'EmailJob.aspx') {
            _Client.Maximize();
            setTopMenu(currTopMenuIndex);
            _DOC.SetElementValueById('AdeccoYear', 'Adecco ' + GetDateTimeDetails('y'));
        } else {
            ShowJobByMail();
        }
    } catch (err) { if (isDebug) { alert(err + '\n\n(' + GetmethodName() + ')'); } }

    try {
        setAutreSource();
    } catch (err) { if (isDebug) { alert(err + '\n\n(' + GetmethodName() + ')'); } }

    try {
        // No Results...
        if (pageName == 'ListePostes.aspx') {
            if (GetListItemsCount() > 0) {
                ShowNoResults(false);
                HighlightJobTypes();
            } else {
                // Show no items msg.
                ShowNoResults(true);
            }
        }
        //Login Cookie Assignment.
        if (pageName == 'CandidatLogin.aspx') {
            var email = _Cookies.GetCookie("adecco_rm");
            if (email != '' && email != 'undefined' && email != null) {
                _DOC.SetElementValueById('txtEmail', email);
                _DOC.SetElementValueById('rememberme', true);
                _Client.SetFocus('txtPwd');
            } else {
                _DOC.SetElementValueById('txtEmail', '');
                _DOC.SetElementValueById('rememberme', false);
                _Client.SetFocus('txtEmail');
            }
        }
        if (pageName == 'EmailJob.aspx') {
            ShowJobByMail();
        }
        // Set default 'CandidatInfo' Selection country as Canada.
        if (pageName == 'CandidatInfo.aspx') {
            if (_DOC.GetElementValueById('ddlPays') == '' || _DOC.GetElementValueById('ddlPays') == 'undefined' || _DOC.GetElementValueById('ddlPays') == null) {
                _DOC.SetElementValueById('ddlPays', 'canada')
            }
        }
        // Re-assign values after postback (if existing).
        if (pageName == 'CandidatInscription.aspx') {
            var value = '';
            value = _DOC.GetElementValueById('_email');
            if (value != '') { _DOC.SetElementValueById('txtEmail', value); }

            value = _DOC.GetElementValueById('_pwd1');
            if (value != '') { _DOC.SetElementValueById('txtPwd', value); }

            value = _DOC.GetElementValueById('_pwd2');
            if (value != '') { _DOC.SetElementValueById('txtPwdConfirm', value); }
        }
        // Disable Autocomplete for client inputs.
        if (pageName == 'CandidatInfo.aspx' || pageName == 'CandidatLogin.aspx' || pageName == 'CandidatInscription.aspx') {
            _Client.DisableAutoComplete();
        }
    } catch (err) { if (isDebug) { alert(err + '\n\n(' + GetmethodName() + ')'); } }
}

window.onbeforeunload = function beforeunload(e) {
    var pageName = '';
    var answer;

    try {
        e = e || window.event;
        pageName = _Browser.PageName();

        if (pageName == 'CandidatLogin.aspx') {
            //Cookie Assignment.
            var email = _DOC.GetElementValueById('txtEmail');
            if (email != '' && email != 'undefined' && email != null) {
                if (_Validation.isChecked('rememberme')) { _Cookies.SetCookie("adecco_rm", email); }
                else { _Cookies.SetCookie("adecco_rm", null); }
            }
        }
        /*
        if (pageName == 'CandidatInscription.aspx') {
            // Values to be remembered if postback.
            var value = '';
            value = _DOC.GetElementValueById('txtEmail');
            _DOC.SetElementValueById('_email', value);

            value = _DOC.GetElementValueById('txtPwd');
            _DOC.SetElementValueById('_pwd1', value);

            value = _DOC.GetElementValueById('txtPwdConfirm');
            _DOC.SetElementValueById('_pwd2', value);                        
            
        }
        */
        // This one must be the last!!
        if (pageName == 'CandidatInfo.aspx') {
            //e.cancelBubble = true;
            if (!Validate(false)) {
                return "Vous \352tes sur le point de quitter cette page et n''avez pas termin\351 le processus de soumission, \352tes vous certain de vouloir quitter?";
                //answer=confirm("Vous \352tes sur le point de quitter cette page et n''avez pas termin\351 le processus de soumission, \352tes vous certain de vouloir quitter?");
                //if(answer){e.returnValue = "";}else{event.returnValue = "This is the message!";}
                //window.unload = false;
            }
        }
    } catch (err) {
        if (isDebug) { alert(err + '\n\n(' + GetmethodName() + ')'); }
        return;
    }
}
/*
window.onunload = function OnUnload(e){
	var pageName='';
	var answer;
	
	try{
	    e = e || window.event;
		pageName=_Browser.PageName();


		if (pageName == 'CandidatInscription.aspx') {
		    // Values to be remembered if postback.
		    var value = '';
		    value = _DOC.GetElementValueById('txtEmail');
		    _DOC.SetElementValueById('_email', value);

		    value = _DOC.GetElementValueById('txtPwd');
		    _DOC.SetElementValueById('_pwd1', value);

		    value = _DOC.GetElementValueById('txtPwdConfirm');
		    _DOC.SetElementValueById('_pwd2', value);

		}
	}catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return;
	}
}
*/
window.onerror = function(msg){
	try{
	    alert(msg);
		return true;
	}catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return true;
	}
}
function setTopMenu(index){
	if(loading){return;}
	var tabDetails = new Object();
	var tabCount=getMenuItemsCount('NavMenu'); // Get Top Menu Items Count.
	var i = 0;
	var over=false;
	var leftClass = '';
	var rightClass = '';
	var labelColor = '';
	
	try{
		loading = true;
		
		for(i=0;i<=(tabCount-1);i++){
			if(i == index || i == currTopMenuIndex){over=true;}else{over=false;}

			if(i == 0){
				tabDetails=getTopMenuDetailsByPos("l",over);
				leftClass='tabLs';
				rightClass='tabR';
			}
			else if((i > 0) && (i < (tabCount-1))){
				tabDetails=getTopMenuDetailsByPos("c",over);
				leftClass='tabL';
				rightClass='tabR';		
			}
			else if(i == (tabCount-1)){
				tabDetails=getTopMenuDetailsByPos("r",over);
				leftClass='tabL';
				rightClass='tabRe';
			}
			setTopMenuItem(i,tabDetails,leftClass,rightClass);
		}
	}catch(err){if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}}
    finally{loading=false;}
}
function getTopMenuDetailsByPos(pos,over){
	var tabDetails=new Object();
	
	try{
		switch(pos){
			case "l":
				if(over){
					tabDetails.left='TabLeftOverS.PNG';
					tabDetails.right='TabRightOver.PNG';
				}else{
					tabDetails.left='TabLeftOutS.PNG';					
					tabDetails.right='TabRightOut.PNG';			
				}
				break;	
			case "c":
				if(over){
					tabDetails.left='TabLeftOver.PNG';
					tabDetails.right='TabRightOver.PNG';
				}else{
					tabDetails.left='TabLeftOut.PNG';
					tabDetails.right='TabRightOut.PNG';			
				}		
				break;	
			case "r":
				if(over){
					tabDetails.left='TabLeftOver.PNG';
					tabDetails.right='TabRightOverE.PNG';
				}else{
					tabDetails.left='TabLeftOut.PNG';
					tabDetails.right='TabRightOutE.PNG';			
				}
				break;	
		}
		
		if(over){
			if(_Browser.Name == 'IE'){tabDetails.center='DBD7CE';}
			else{tabDetails.center='#E0DDD6';}
			tabDetails.isOver = true;
		}else{
			if(_Browser.Name == 'IE'){tabDetails.center='#A19882';}
			else{tabDetails.center='#A9A18C';}
			tabDetails.isOver = false;					
		}		
		return tabDetails;	
	}catch(err){if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}}
    finally{}
}	
function setTopMenuItem(menuIndex,tabs,leftClass,rightClass){
	var tabDetails=new Object();
	var label;
	try{
		tabDetails=tabs;
	
		var tabLeft=_DOC.GetElementByClassName(leftClass,'div',_DOC.GetElementById('topMenu'+menuIndex));
		var tabCenter=_DOC.GetElementByClassName('tabC','div',_DOC.GetElementById('topMenu'+menuIndex));
		var tabRight=_DOC.GetElementByClassName(rightClass,'div',_DOC.GetElementById('topMenu'+menuIndex));

		tabLeft.style.backgroundImage="url('"+'http://www.adeccoqc.com/appl/images/MenuHoriz/'+tabDetails.left+"')";
		tabCenter.style.background = tabDetails.center;
		tabRight.style.backgroundImage="url('"+'http://www.adeccoqc.com/appl/images/MenuHoriz/'+tabDetails.right+"')";
		
		if(_Browser.Name == 'IE'){label = tabCenter.children[0];}
		else{label = tabCenter.childNodes[0];}
		
		if(tabs.isOver){label.style.color = '#000';}
		else{label.style.color = '#fff';}
	}catch(err){if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}}	
}
function getMenuItemsCount(objName){
    // Should look into table to count cell items...
	return 6;
}
function GetListItemsCount() {
    var obj, list, content, cnt;
    try{
        obj = _DOC.GetElementById("dtgPostes");
        if (_DOC.IsObject(obj)) {
            content = obj.innerHTML;
            content = content.toLowerCase(); 
            content = content.replace("<tbody>", "");
            content = content.replace("</tbody>", "");
            list = content.split("<tr ");
            cnt = 0;
            cnt = list.length - 2;
            return cnt;
        }
    }catch(Error){if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')'); return 0;}
    }finally{delete list;delete content;delete list;}
}
function ShowNoResults(visible){
    var obj, msg;
    try {
        obj = _DOC.GetElementById("NoItems");
        
        if(_DOC.IsObject(obj)){
            if (visible == undefined) { visible = false; }
            if (visible) {
                obj.style.display = 'block';
                obj.style.height = '450px';
            } else {
                obj.style.display = 'none';
                obj.style.height = '0px';
            }
        }else{obj.style.display = 'none';}
    }catch(Error){
        if (isDebug) { alert(err + '\n\n(' + GetmethodName() + ')'); return; }
    }finally{delete obj;}
}
/*
function SetVisibility(selected) {
    if (/Row (\d+)/.test(selected) && RegExp.$1 != '') {
        var item = RegExp.$1;
        document.getElementById('NoItems').style.display = '';
        var node;
        var ii = 1;
        while (node = document.getElementById('option' + ii)) {
            if (ii != item) {
                node.style.display = 'none';
            }
            ++ii;
        }
    }
}*/
function Validate(ShowMsg){
	var _Validate = new Validation;
	var isValid=true;
	var i=1;
	var msg = '';

	try{
	    if(ShowMsg == undefined){ShowMsg = true;}
	    
		// Renseignements personnels
		if(_Validate.isRadioListSel('rblSexe',true)){isValid=false;}
		if(_Validate.IsEmpty('txtNom',true)){isValid=false;}
		if(_Validate.IsEmpty('txtPrenom',true)){isValid=false;}
		if(_Validate.IsEmpty('txtAdresse',true)){isValid=false;}
		if(_Validate.IsEmpty('txtVille',true)){isValid=false;}
		if(!_Validate.isValidSelection('ddlProvince',true)){isValid=false;}
		if(!_Validate.isValidSelection('ddlPays',true)){isValid=false;}
		if(!_Validate.isValidPostalCode('txtCodePostal',true,true) || _Validate.IsEmpty('txtCodePostal',true)){isValid=false;}
		if(!_Validate.isValidEmail('txtEmail',true) || _Validate.IsEmpty('txtEmail',true)){isValid=false;}
		if(_Validate.IsEmpty('txtTel1',false) && _Validate.IsEmpty('txtTel2',false) && _Validate.IsEmpty('txtTelBureau',false)){
			isValid=false;
			_GUI.SetElementBGcolor('txtTel1',ReqValueColor);
		}
		// Mobilité. 
		if(!_Validate.isListChecked('cklMoyenTransport',true)){isValid=false;}
		if (_Validate.isRadioListSel('rblPermisValide', true)) { isValid = false; }
		if (_DOC.GetElementValueById('rblPermisValide_0') == true) {
		    if (!_Validate.isValidSelection('ddlClassePermis', true)) { isValid = false; }
		} else {
		    _GUI.SetElementBGcolor('ddlClassePermis', ReqNormalColor);
		}
		if (!_Validate.isValidSelection('ddlRegion1', false) && !_Validate.isValidSelection('ddlRegion2', false) && !_Validate.isValidSelection('ddlRegion3', false) && !_Validate.isValidSelection('ddlRegion4', false)) {
		    isValid = false;
		    _GUI.SetElementBGcolor('ddlRegion1', ReqValueColor);
		} else {
		    _GUI.SetElementBGcolor('ddlRegion1', ReqNormalColor);
		    _GUI.SetElementBGcolor('ddlRegion2', ReqNormalColor);
		    _GUI.SetElementBGcolor('ddlRegion3', ReqNormalColor);
		    _GUI.SetElementBGcolor('ddlRegion4', ReqNormalColor);
		}
		// Langue.		
		if(!_Validate.isValidSelection('ddlBureau',true)){isValid=false;}
		if(!_Validate.isValidSelection('ddlLangEvalFrancais',true)){isValid=false;}
		if(!_Validate.isValidSelection('ddlLangEvalAnglais',true)){isValid=false;}
		if(_Validate.isChecked('chkLangueAutre1',false)){
			if(!_Validate.isValidSelection('ddlLangAutre1',true)){isValid=false;}
			if(!_Validate.isValidSelection('ddlLangEvalAutre1',true)){isValid=false;}			
		}else{
		    // Reset Lists & Backcolor!!
		    _GUI.SetElementBGcolor('ddlLangAutre1', ReqNormalColor);
		    _GUI.SetElementBGcolor('ddlLangEvalAutre1', ReqNormalColor);
			 
		}
		if(_Validate.isChecked('chkLangueAutre2',false)){
			if(!_Validate.isValidSelection('ddlLangAutre2',true)){isValid=false;}
			if(!_Validate.isValidSelection('ddlLangEvalAutre2',true)){isValid=false;}			
		}else{
		    // Reset Lists & Backcolor!!
		    _GUI.SetElementBGcolor('ddlLangAutre2', ReqNormalColor);
		    _GUI.SetElementBGcolor('ddlLangEvalAutre2', ReqNormalColor);
		}
		// Formation.
		for(i=1;i<=5;i++){
		    if (_Validate.isValidSelection('ddlDiplome' + i, false) || _Validate.isValidSelection('ddlDiscipline' + i, false) || !_Validate.IsEmpty('txtAnneeObtention' + i, false) || !_Validate.IsEmpty('txtInstitution' + i, false)) {
		        if (!_Validate.isValidSelection('ddlDiplome' + i, true)) { isValid = false; }
		        if (!_Validate.isValidSelection('ddlDiscipline' + i, true)) { isValid = false; }
		        if (_Validate.IsEmpty('txtAnneeObtention' + i, true)) { isValid = false; }
		        if (_Validate.IsEmpty('txtInstitution' + i, true)) { isValid = false; }
		    } else {
		        _GUI.SetElementBGcolor('ddlDiplome' + i, ReqNormalColor);
		        _GUI.SetElementBGcolor('ddlDiscipline' + i, ReqNormalColor);
		        _GUI.SetElementBGcolor('txtAnneeObtention' + i, ReqNormalColor);
		        _GUI.SetElementBGcolor('txtInstitution' + i, ReqNormalColor);
		    }
		}
		// Type de poste.
		if (_Validate.IsEmpty('txtSalMinHoraire', false) && _Validate.IsEmpty('txtSalMinAnnuel', false)) {
		    isValid = false;
		    _GUI.SetElementBGcolor('txtSalMinHoraire', ReqValueColor);
		    _GUI.SetElementBGcolor('txtSalMinAnnuel', ReqValueColor);		    
		} else {
		    _GUI.SetElementBGcolor('txtSalMinHoraire', ReqNormalColor);
		    _GUI.SetElementBGcolor('txtSalMinAnnuel', ReqNormalColor);
		}
		//if(_Validate.IsEmpty('txtSalMinAnnuel',true)){isValid=false;}
		if(!_Validate.isListChecked('cklPostes',true)){isValid=false;}		
		if(!_Validate.isListChecked('cklDispo',true)){isValid=false;}		
		// C.V.
		if (_Validate.IsEmpty('inputFileCV', true) || !_Validate.isValidDoc('inputFileCV', true)) {
		    msg = '\n\n- Vous devez joindre un c.v.!';
		    isValid = false;
		}
		// Autres renseignements.
		if(_Validate.isValidSelection('ddlSource',true)){
            if(_DOC.GetElementValueById('ddlSource') == 393261){
                if(_DOC.GetElementValueById('txtAutreSource') == '' || _DOC.GetElementValueById('txtAutreSource') == 'undefined' || _DOC.GetElementValueById('txtAutreSource') == null){
                    _GUI.SetElementBGcolor('txtAutreSource',ReqValueColor);
                    isValid=false;    
                }else{
                    _GUI.SetElementBGcolor('txtAutreSource',ReqNormalColor);
                }
            }else{
                _GUI.SetElementBGcolor('ddlSource',ReqNormalColor);
            }	
		}else{isValid=false;}
		// Mot de passe.
		if((!_Validate.IsEmpty('txtpw1',false) && _Validate.IsEmpty('txtpw2',false)) || (_Validate.IsEmpty('txtpw1',false) && !_Validate.IsEmpty('txtpw2',false ))){
			isValid=false;
			if(_Validate.IsEmpty('txtpw1',false)){_GUI.SetElementBGcolor('txtpw1',ReqValueColor);isValid=false;}
			else{_GUI.SetElementBGcolor('txtpw1',ReqNormalColor);}
			if(_Validate.IsEmpty('txtpw2',false)){_GUI.SetElementBGcolor('txtpw2',ReqValueColor);isValid=false;}
			else{_GUI.SetElementBGcolor('txtpw2',ReqNormalColor);}			
		}else{
			if((!_Validate.IsEmpty('txtpw1',false) && !_Validate.IsEmpty('txtpw2',false)) && !_Validate.IsTextMatch('txtpw1','txtpw2')){
				_GUI.SetElementBGcolor('txtpw1',ReqValueColor);
				_GUI.SetElementBGcolor('txtpw2',ReqValueColor);
				msg = '\n\n- Les mot de passes ne sont pas identiques!';
				isValid=false;
			}else{
				_GUI.SetElementBGcolor('txtpw1',ReqNormalColor);
				_GUI.SetElementBGcolor('txtpw2',ReqNormalColor);
			}
		}
		needToConfirm = isValid;
		
		// Verifie validate Form...
		if(!isValid){
		    if(ShowMsg){
			    alert('Les zones marqu\351s en jaune requi\350rent votre attention!'+ msg);
			}
			return false;
		}else{
			return true;
		}
	}catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return true;
	}finally{delete _Validate;}
}
function ValidateLogin(){
	var _Validate = new Validation;
	var isValid=true;
	try{
		if(_Validate.IsEmpty('txtNom',true)){isValid=false;}
		if(_Validate.IsEmpty('txtPwd',true)){isValid=false;}
		delete _Validate;
		if(!isValid){alert('Les zones marqu\351s en jaune requi\350rent votre attention!'); return false;}
		else{return true;}	
	}catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return true;
	}finally{delete _Validate;}
}
function ValidateEmail(){
	var _Validate = new Validation;
	var isValid=true;
	try{
		if(!_Validate.isValidEmail('txtEmailPass',true) || _Validate.IsEmpty('txtEmailPass',true)){isValid=false;}
		delete _Validate;
		if(!isValid){alert('Un courriel valide est requis pour continuer!'); return false;}
		else{return true;}	
	}catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return true;
	}finally{delete _Validate;}
}
function ValidatePassword(){
	var _Validate = new Validation;
	var isValid=true;
	try{
		if(_Validate.IsEmpty('txtEmailPass',true) || !_Validate.IsMinLength('txtEmailPass',6,true,false)){isValid=false;}
		delete _Validate;
		if(!isValid){alert('Un courriel valide est requis pour continuer!'); return false;}
		else{return true;}	
	}catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return true;
	}finally{delete _Validate;}
}
function ValidateInscription(){
	var _Validate = new Validation;
	var _Doc = new Document;
	var msg = '';
	var i = 0;
	var pwd = false;
	var con = false;
	try{
		if(_Validate.IsEmpty('txtEmail',true)){
			msg += '\n- Courriel manquant.';
			i += 1;
		}else if(!_Validate.isValidEmail('txtEmail',true)){
			msg += '\n- Courriel invalide.';
			i += 1;
		}else{pwd = true;}
		if(_Validate.IsEmpty('txtPwd',true)){
			msg += '\n- Mot de passe manquant.';
			i += 1;
		}else if(!_Validate.IsMinLength('txtPwd',6,true,false)){
			msg += '\n- Mot de passe pas assez long.';
			i += 1;
		}else{con = true;}
		if(_Validate.IsEmpty('txtPwdConfirm',true)){
			msg += '\n- Confirmer mot de passe manquant.';
			i += 1;
		}else if(!_Validate.IsMinLength('txtPwdConfirm',6,true,false)){
			msg += '\n- Confirmer mot de passe pas assez long.';
			i += 1;
		}
		if(pwd && con){
			if(_Doc.GetElementValueById('txtPwd') == _Doc.GetElementValueById('txtPwdConfirm')){
				_GUI.SetElementBGcolor('txtPwd',ReqNormalColor);
				_GUI.SetElementBGcolor('txtPwdConfirm',ReqNormalColor);
			}else{
				msg += '\n- Les mots de passe ne sont pas identiques.';
				i += 1;
				_GUI.SetElementBGcolor('txtPwd',ReqValueColor);
				_GUI.SetElementBGcolor('txtPwdConfirm',ReqValueColor);
			}
        }
		if(!_Validate.IsEmpty('txtDynCode',true)){
		    if (!_Validate.IsMinLength('txtDynCode', 6, true, false)) {
		        msg += "\n- Les caract\350res n''ont pas tous \351t\351 retranscrits.";
		        i += 1;
		        _GUI.SetElementBGcolor('txtDynCode', ReqValueColor);
		    } else if (_Validate.IsMaxLength('txtDynCode', 6, true, false)) {
		        msg += "\n- Le nombre de caract\350res entr\351 d\351passe celui du code g\351n\351r\351.";
		        i += 1;
		        _GUI.SetElementBGcolor('txtDynCode', ReqValueColor);
		} else {
		        _GUI.SetElementBGcolor('txtDynCode', ReqNormalColor);
		    }
		}else{
		    msg += "\n- Le code n''a pas \351t\351 retranscrit.";
		    i += 1;
		    _GUI.SetElementBGcolor('txtDynCode', ReqValueColor);
		} 
		if(i > 0){alert('Les zones marqu\351s en jaune requi\350rent votre attention...\n' + msg); return false;}
		else{return true;}	
	}catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return true;
	}finally{delete _Validate; delete _Doc;}
}
function ValidateEmailJob(){
	var _Validate = new Validation;
	var _Doc = new Document;
	var msg = '';
	var i = 0;
	var pwd = false;
	var con = false;
	try{
		if(_Validate.IsEmpty('txtJobSenderName', true)){
			msg += '\n- Nom manquant.';
			i += 1;
		}else if(IsMaxLength('txtJobSenderName', 30)){
			msg += '\n- Nom trop long (maximum de 30 caract\350res).';
			i += 1;
			_GUI.SetElementBGcolor('txtJobSenderName', ReqValueColor);
		}else{_GUI.SetElementBGcolor('txtJobSenderName',ReqNormalColor);}
		
		if(_Validate.IsEmpty('txtJobMessage', true)){
			msg += '\n- Un message est requis.';
			i += 1;
		}else if(_Validate.IsMaxLength('txtJobMessage', 100, true, false)){
			msg += "\n- Le message d\351passe l''espace allou\351 (maximum de 100 caract\350res).";
			i += 1;
		}
		
		if(_Validate.IsEmpty('txtJobEmail', true)){
			msg += '\n- Courriel manquant.';
			i += 1;
		}else if(!_Validate.isValidEmailCount('txtJobEmail', 3, true)){
			msg += "\n- Le nombre d'adresses courriels d\351passe le nombre allou\351.";
			i += 1;
		}else if(!_Validate.isValidEmail('txtJobEmail',true)){
			msg += '\n- Courriel invalide';
			i += 1;
		}
		
		if(i > 0){alert('Les zones marqu\351s en jaune requi\350rent votre attention...\n' + msg); return false;}
		else{return true;}	
	}catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return true;
	}finally{delete _Validate; delete _Doc;}
}
function HighlightJobTypes(){
    var tmpContent = document.body.innerHTML;
    var tmpBefore = new Strings();   
    var tmpAfter = new Strings();
    var tmpOutput = new Strings();
    var intBefore = 0;
    var intAfter = 0;
    var SearchFor='>Permanent</td>';

    try{
		if (SearchFor.length == 0){return;}
		while (tmpContent.toUpperCase().indexOf(SearchFor.toUpperCase()) > -1) {
			// Get all content before the match
			intBefore = tmpContent.toUpperCase().indexOf(SearchFor.toUpperCase());
			tmpBefore = tmpContent.substring(0, intBefore);
			tmpOutput = tmpOutput + tmpBefore;

			// Get the string to replace
			tmpOutput = tmpOutput + '><span class="Highlited">Permanent</span></td>';
			// Get the rest of the content after the match until the next match or the end of the content.
			intAfter = tmpContent.length - SearchFor.length + 1;
			tmpContent = tmpContent.substring(intBefore + SearchFor.length);
        }
        tmpOutput = tmpOutput.replace('[object Object]', '');
		document.body.innerHTML = tmpOutput + tmpContent;
		//return tmpOutput + tmpContent;   
	}catch(err){if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}}
}
function setcvpath(obj){
	var docpath=_GetElementById("<%=cvpath.ClientID%>");
	docpath.value=obj.value;
	alert(docpath.value);
}
function setAutreSource(){
	var objSource=_DOC.GetElementById("ddlSource");
	var objAS=_DOC.GetElementById("oAutreSource");
	if(!_DOC.IsObject(_GUI)){_GUI = new GUI(objAS.id);}
	
	if(_DOC.IsObject(objSource) && _DOC.IsObject(objAS)){
	    _GUI._element = objAS;
		if(objSource.value == 393261){
			_GUI.ChangeVisibility(true);
		}
		else{
			_GUI.ChangeVisibility(false);
		}
	}
}
function ShowJobByMail(){
    try{
        var b =_Browser.Name;
        var v =_Browser.Version;
        
        switch(b){
            case 'IE':
                if(v <= 6){_Client.ResizeWindow(250,400,100,100);}
                if (v >= 7) { _Client.ResizeWindow(250, 400, 100, 100); }
                break
            case 'FF':
                _Client.ResizeWindow(250, 400, 100, 100);
                break
            case 'OP':
                _Client.ResizeWindow(250, 400, 100, 100);
                break
            case 'SA':
                _Client.ResizeWindow(250, 400, 100, 100);
                break
            default:
                _Client.ResizeWindow(250, 400, 100, 100);
                break;                                        
        }
    }catch(Error){
        if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
    }
}
function addEvent(eventName){
	if(document.addEventListener){ //code for Moz. 
		document.addEventListener(eventName,eventSink,false); 
	}else{                         // Code for IE.
		document.attachEvent('on'+eventName,eventSink); 
	} 
}
function alertkey(e) {
  if( !e ) {
    //if the browser did not pass the event information to the
    //function, we will have to obtain it from the event register
    if( window.event ) {
      //Internet Explorer
      e = window.event;
    } else {
      //total failure, we have no way of referencing the event
      return;
    }
  }
  if( typeof( e.keyCode ) == 'number'  ) {
    //DOM
    e = e.keyCode;
  } else if( typeof( e.which ) == 'number' ) {
    //NS 4 compatible
    e = e.which;
  } else if( typeof( e.charCode ) == 'number'  ) {
    //also NS 6+, Mozilla 0.9+
    e = e.charCode;
  } else {
    //total failure, we have no way of obtaining the key code
    return;
  }
  window.alert('The key pressed has keycode ' + e +
    ' and is key ' + String.fromCharCode( e ) );
}
/*
document.onkeyup = function KeyUpEvent(e){
    var field;             //field being processed
    var keyChar;        //the current character
    var KeyCode = 0;   //ascii value of character
    var obj;

    e = e || window.event;
    field = e.srcElement || e.target;

    if(typeof e.charCode != "undefined"){
         KeyCode = e.charCode;     //zero if is editing key non IE
    }else if(e.which){
         KeyCode = e.which;          //NN4
    }else{
         KeyCode = e.keyCode;      //zero if is editing key in IE
    }

    keyChar = String.fromCharCode(KeyCode);
    obj = _DOC.GetTargetElementByEvent(e);
    
    if(obj == '' || obj == 'undefined' || obj == null){return;}
    
	if(obj.id == 'txtTel1' || obj.id == 'txtTel2' || obj.id == 'txtTelBureau'){
		//IsNumericPhoneKey(e);
		if((KeyCode < 48 || KeyCode > 57) && (KeyCode < 96 || KeyCode > 105)){
			if(obj.value != '' && obj.value.length > 0){
				obj.value=_String.Left(obj.value,obj.value.length - 1);
			}
		}  // KeyCode = 0;
		//if(IsMaxLength(obj.id,12)){obj.value=oString.Left(obj.value,12);}
	}    
}
*/
document.onmouseover = function MouseOverEvent(e){
    var field;             //field being processed
    var keyChar;           //the current character
    var KeyCode = 0;       //ascii value of character
    var obj;
    var B;
    var parent;
	var oString = new Strings;
	var oDoc = new Document;
    
    try{
		e = e || window.event;

		if(typeof e.charCode != "undefined"){KeyCode = e.charCode; B = 'FF';}	// FF & Others.
		else if(e.which){KeyCode = e.which; B = 'NN';}							// NN4.
		else{KeyCode = e.keyCode; B = 'IE';}									// IE.

		obj = oDoc.GetTargetElementByEvent(e);			
		keyChar = String.fromCharCode(KeyCode);
	    
		if(obj == '' || obj == 'undefined' || obj == null){return;}
		if(obj.id == '' || obj.id == 'undefined' || obj.id == null){return;}
	    
		parent=oDoc.FindParentWithTagFromName(obj.id,'LI');
		if(parent != 'undefined' && parent != ''){
			if(oString.Left(parent.id,7) == 'topMenu'){
				setTopMenu(oString.Right(parent.id,1));
			}
		}		
    }catch(err){if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}}
    finally{delete oString; delete oDoc;}
}
document.onmouseout = function MouseOutEvent(e){
    var field;             //field being processed
    var keyChar;           //the current character
    var KeyCode = 0;       //ascii value of character
    var obj;
    var B;
    var parent;
	var oString = new Strings;
	var oDoc = new Document;
    try{
		e = e || window.event;

		if(typeof e.charCode != "undefined"){KeyCode = e.charCode; B = 'FF';}	// FF & Others.
		else if(e.which){KeyCode = e.which; B = 'NN';}							// NN4.
		else{KeyCode = e.keyCode; B = 'IE';}									// IE.

		obj = oDoc.GetTargetElementByEvent(e);			
		keyChar = String.fromCharCode(KeyCode);
	    
		if(obj == '' || obj == 'undefined' || obj == null){return;}
		if(obj.id == '' || obj.id == 'undefined' || obj.id == null){return;}
	    
		parent=oDoc.FindParentWithTagFromName(obj.id,'LI');
		if(parent != 'undefined' && parent != ''){
			if(oString.Left(parent.id,7) == 'topMenu'){setTopMenu(currTopMenuIndex);}
		}		
		        
    }catch(err){if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}}
    finally{delete oString; delete oDoc;}
}
document.onmouseclick = function MouseClickEvent(e){
    var field;             //field being processed
    var keyChar;           //the current character
    var KeyCode = 0;       //ascii value of character
    var obj;
    var B;
    var parent;
	var oString = new Strings;
	var oDoc = new Document;
    try{
		e = e || window.event;

		if(typeof e.charCode != "undefined"){KeyCode = e.charCode; B = 'FF';}	// FF & Others.
		else if(e.which){KeyCode = e.which; B = 'NN';}							// NN4.
		else{KeyCode = e.keyCode; B = 'IE';}									// IE.

		obj = oDoc.GetTargetElementByEvent(e);			
		keyChar = String.fromCharCode(KeyCode);
	    
		if(obj == '' || obj == 'undefined' || obj == null){return;}
		if(obj.id == '' || obj.id == 'undefined' || obj.id == null){return;}
	    
		parent=oDoc.FindParentWithTagFromName(obj.id,'LI');
		if(parent != 'undefined' && parent != ''){
			if(oString.Left(parent.id,7) == 'topMenu'){
				currTopMenuIndex=Right(parent.id,1);
				setTopMenu(currTopMenuIndex);
			}
		}		
		        
    }catch(err){if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}}
	finally{delete oString; delete oDoc;}    
}
document.onkeypress = function KeyPressEvent(e){
    var field;             //field being processed
    var keyChar;           //the current character
    var KeyCode = 0;       //ascii value of character
    var obj;
    var B;
	var oString = new Strings;
	var oDoc = new Document;
	var oVal = new Validation;    
    
    try{
		e = e || window.event;

		if(typeof e.charCode != "undefined"){KeyCode = e.charCode; B = 'FF';}	// FF & Others.
		else if(e.which){KeyCode = e.which; B = 'NN';}							// NN4.
		else{KeyCode = e.keyCode; B = 'IE';}									// IE.

		obj = oDoc.GetTargetElementByEvent(e);			
		keyChar = String.fromCharCode(KeyCode);
	    
		if(obj == '' || obj == 'undefined' || obj == null){return;}
		if(obj.id == '' || obj.id == 'undefined' || obj.id == null){return;}
	    
	    // Phone No.
		if(obj.id == 'txtTel1' || obj.id == 'txtTel2' || obj.id == 'txtTelBureau'){
			if(oVal.IsMaxLength(obj.id,12)){obj.value=oString.Left(obj.value,12);}
			return IsNumericPhoneKey(e,KeyCode);
		}
				
		// Salary.
		if(obj.id == 'txtSalMinHoraire' || obj.id == 'txtSalMinAnnuel'){
			if(oVal.IsMaxLength(obj.id,10)){obj.value=oString.Left(obj.value,10);}
			return IsNumericAmountKey(e,KeyCode);
		}

		// Year.
		if (obj.id == 'txtAnneeObtention1' || obj.id == 'txtAnneeObtention2' || obj.id == 'txtAnneeObtention3' || obj.id == 'txtAnneeObtention4' || obj.id == 'txtAnneeObtention5') {
			if(oVal.IsMaxLength(obj.id,4)){obj.value=oString.Left(obj.value,4);}
			return IsNumericKey(e,KeyCode);
		}
		
		if(obj.id == 'txtJobMessage'){
		    try{
		        if(obj.value.length > 0){
		            oDoc.SetElementValueById('msgcount',obj.value.length);
		        }
		    }catch(eer){
		        oDoc.SetElementValueById('msgcount',obj.value.length);
		        //oDoc.SetElementValueById('msgcount',0);
		    }
		}		
    }catch(err){if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
	}finally{delete oString; delete oDoc; delete oVal;}
}
document.onkeyup = function KeyUpEvent(e){
    var field;             
    var keyChar;           
    var KeyCode = 0;       
    var obj;
    var B;
	var oString = new Strings;
	var oDoc = new Document;
	var oVal = new Validation;
	var oStrings = new Strings;    
    
    try{
		e = e || window.event;

		if(typeof e.charCode != "undefined"){KeyCode = e.charCode; B = 'FF';}	
		else if(e.which){KeyCode = e.which; B = 'NN';}							
		else{KeyCode = e.keyCode; B = 'IE';}									

		obj = oDoc.GetTargetElementByEvent(e);			
		keyChar = String.fromCharCode(KeyCode);
	    
		if(obj == '' || obj == 'undefined' || obj == null){return;}
		if(obj.id == '' || obj.id == 'undefined' || obj.id == null){return;}
	    
		if(obj.id == 'txtJobMessage'){
		    if(obj.value.length > 0){
		        if(KeyCode == 8){
		            oDoc.SetElementValueById('msgcount',obj.value.length);
		        }
		    }
		}
		if(obj.id == 'txtJobMessage'){
		    try{
		        if(obj.value.length > 0){
		            if(KeyCode == 8){
		                var v = oStrings.Left(obj.value, obj.value.length);
		                oDoc.SetElementValueById('txtJobMessage',v);
		                oDoc.SetElementValueById('msgcount',obj.value.length);
		            }else{		        
		                oDoc.SetElementValueById('msgcount',obj.value.length);
		            }
		        }else{
		            oDoc.SetElementValueById('msgcount',0);
		        }
		    }catch(eer){
		        oDoc.SetElementValueById('msgcount',obj.value.length);
		    }
		}				
    }catch(err){if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
	}finally{delete oString; delete oDoc; delete oVal; delete oStrings;}
}
function Reload() {
    try {
        //var obj = _DOC.GetElementById("txtDynCode");
        _DOC.SetElementValueById('txtDynCode', '');
        
    } catch (err) {}
    try{
        window.location=self.location;
        return;
    } catch (err1) { if (isDebug) { alert(err + '\n\n(' + GetmethodName() + ')'); } }    
    try {
        window.location.reload(true);
        return;
    } catch (err2) { if (isDebug) { alert(err + '\n\n(' + GetmethodName() + ')'); } }
    try {
        var pageName = _Browser.PageName();
        window.location.replace(pageName);
        return;
    } catch (err3) { if (isDebug) { alert(err + '\n\n(' + GetmethodName() + ')'); } }

}
function SetStatusMessage(value) {
    try {
        if (value == undefined) { value = ''; }
        window.status = value;
    } catch (err) { if (isDebug) { alert(err + '\n\n(' + GetmethodName() + ')'); } }
}
function typingVal(e) {
    var field;             //field being processed
    var keyChar;        //the current character
    var thisKey = 0;   //ascii value of character

    e = e || window.event;
    field = e.srcElement || e.target;

    if(typeof e.charCode != "undefined"){
         thisKey = e.charCode;     //zero if is editing key non IE
    }else if(e.which){
         thisKey = e.which;          //NN4
    }else{
         thisKey = e.keyCode;      //zero if is editing key in IE
    }

    keyChar = String.fromCharCode(thisKey);

    if (field.id.slice(0,4) == "time") {      //processing a time field
        if (thisKey && !/[0-9:]/.test(keyChar)) {         //only digits and colon
            if (e.returnValue){e.returnValue = false;}
            else{
				//e.preventDefault();
            }
        }
        else if (keyChar == ":") {
            if (field.value.length != 2) {  //Allow : on in 3rd position
                if(e.returnValue){
					e.returnValue = false;
                }else{
					e.preventDefault();
				}
            }
        }else if(thisKey && field.value.length >= 2 && field.value.indexOf(":") == -1){
            //Make sure there is a : in 3rd position
            field.value = field.value.substring(0,2) + ":" + field.value.substring(2,field.value.length);
        }
    }
}
function IsNumericKey(e,KeyCode){
	try{
		if(typeof e.charCode != "undefined" && KeyCode == 0){return true;}
		if(KeyCode < 48 || KeyCode > 57){return false;}
		else{return true;}	
	}catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return true;
	}
}
function IsNumericAmountKey(e,KeyCode){
	try{
		if(typeof e.charCode != "undefined" && KeyCode == 0){return true;}
		if((KeyCode < 48 || KeyCode > 57) && KeyCode != 46){return false;}
		else{return true;}	
	}catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return true;
	}
}
function IsNumericPhoneKey(e,KeyCode){
	try{
		if(typeof e.charCode != "undefined" && KeyCode == 0){return true;}
		if((KeyCode < 48 || KeyCode > 57) && KeyCode != 45){return false;}
		else{return true;}	
	}catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return true;
	}
}
function IsMaxLength(objID,len,truncate){
	var mlength=0;
	var obj;
		
	try{
	    truncate = truncate || false
		if(objID == '' || objID == 'undefined' || objID == null){return false;}
		obj = _DOC.GetElementById(objID);
		if(len == '' || len == 'undefined' || len == null || len == 0  || isNaN(len)){
			mlength = obj.getAttribute ? parseInt(obj.getAttribute("maxlength")) : ""
		}else{
			mlength = len;
		}
		if((mlength != '' && mlength != 'undefined' && mlength != null) && mlength > 0){
			if(obj.getAttribute && obj.value.length > mlength){
				if(truncate){
				    obj.value = obj.value.substring(0,mlength);
				    return false;
				}else{return true;}
			}
		}
	}catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return true;
	}
}
function IsMinLength(objID,len){
	var mlength=0;
	var obj;
		
	try{
		if(objID == '' || objID == 'undefined' || objID == null){return false;}
		obj = _DOC.GetElementById(objID);
		if(len == '' || len == 'undefined' || len == null || len == 0  || isNaN(len)){
			mlength = obj.getAttribute ? parseInt(obj.getAttribute("maxlength")) : ""
		}else{
			mlength = len;
		}
		if((mlength != '' && mlength != 'undefined' && mlength != null) && mlength > 0){
			if(obj.getAttribute && obj.value.length < mlength){
				obj.value = obj.value.substring(0,mlength);	
			}
		}
	}catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return true;
	}
}
_GetNodeTextType = function(node){
	if(node == '' || node == 'undefined'){return 0;}
	switch(node.nodeType){
		case 1:return 'ELEMENT_NODE';break;
		case 2:return 'ATTRIBUTE_NODE';break;
		case 3:return 'TEXT_NODE';break;
		case 4:return 'CDATA_SECTION_NODE';break;
		case 5:return 'ENTITY_REFERENCE_NODE';break;
		case 6:return 'ENTITY_NODE';break;
		case 7:return 'PROCESSING_INSTRUCTION_NODE';break;
		case 8:return 'COMMENT_NODE';break;
		case 9:return 'DOCUMENT_NODE';break;
		case 10:return 'DOCUMENT_TYPE_NODE';break;
		case 11:return 'DOCUMENT_FRAGMENT_NODE';break;
		case 12:return 'NOTATION_NODE';break;
    }
}
function GetDateTimeDetails(detail){
	var d = new Date();
	try{
	    switch(detail){
		    case 'y':
			    return d.getFullYear(); 		
			    break;
		    case 'm':
			    return d.getMonth();
			    break;
		    case 'd':
			    return d.getDate();
			    break;
		    case 'h':
			    return d.getHours();
			    break;
		    case 'm':
			    return d.getMinutes();
			    break;
		    case 's':
			    return d.getSeconds();
			    break;													
	    }	
	}catch(err){if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}}
}
FormatDataGrid = function(DataGridID){
    var navRoot = _DOC.GetElementById(DataGridID);
    
    alert(navRoot.style.width);

    // Get a reference to the TBODY element 
    var tbody = navRoot.childNodes[0];

    for (i = 0; i < tbody.childNodes.length; i++){
        
        // Get Ref to Table Childs, Check only TR (Rows).
        node = tbody.childNodes[i];
        if (node.nodeName == "TR"){
            var rows = node.childNodes
            
            for (j = 0; j < rows.childNodes.length; j++){
                if (rows.childNodes[j].nodeName == "TD"){

                    var className = _DOC.GetElementClassNameById(rows.childNodes[j]);
                    switch(className){
                        case "Col1":
                            _DOC.GetElementClassNameById(rows.childNodes[j]).style.width = '11%';
                            break;
                        case "Col2":
                            _DOC.GetElementClassNameById(rows.childNodes[j]).style.width = '29%';
                            break;
                        case "Col3","Col4","Col6":
                            _DOC.GetElementClassNameById(rows.childNodes[j]).style.width = '14%';
                            break;                                                 
                        case "Col5":
                            _DOC.GetElementClassNameById(rows.childNodes[j]).style.width = '18%';
                            break;                        
                    }
                }    
            } 
        }
    }
}
DataGridHighlight = function(DataGridID){
    if (document.all && document.getElementById){  
        navRoot = document.getElementById(DataGridID);

        // Get a reference to the TBODY element 
        tbody = navRoot.childNodes[0];

        for (i = 0; i < tbody.childNodes.length; i++){
            node = tbody.childNodes[i];
            if (node.nodeName == "TR"){
                node.onmouseover=function(){
                    this.className = "over";                
                }
                node.onmouseout=function(){
                    this.className = this.className.replace("over", "");
                }
            }
        }
    }
}
