
function setLanguage(args)
{document.location='/setlanguage.php?lang='+args+'&referer='+escape(document.location.href);}
var Utils={getRandomId:function(prefix)
{var id=0;do
{id=Math.round(Math.random()*10000);}
while(typeof($(prefix+id))!='undefined'&&$(prefix+id)!=null);return id;},handleError:function(transport,json)
{var str='An error occured: ';if(json)
{str+=json.message;}
else
{if(transport.status==200)
str+='Unknown error';else
str+=transport.statusText;}
alert(str);},displayFormError:function(container,displayError,validators)
{var str='<ul>';validators.each(function(v){str+='<li>'+v.options.message+'</li>';});str+='</ul>';new AlertBox(str,{alertType:'Warning',okButtonClass:'button'});},createCookie:function(name,value,days)
{if(days)
{var date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires="; expires="+date.toGMTString();}
else
var expires="";document.cookie=name+"="+value+expires+"; path=/";},readCookie:function(name)
{var nameEQ=name+"=";var ca=document.cookie.split(';');for(var i=0;i<ca.length;i++)
{var c=ca[i];while(c.charAt(0)==' ')c=c.substring(1,c.length);if(c.indexOf(nameEQ)==0)return c.substring(nameEQ.length,c.length);}
return null;},eraseCookie:function(name)
{createCookie(name,"",-1);},testPassword:function(passwd)
{var score=0;if(passwd.length<5)
score+=3;else if(passwd.length>4&&passwd.length<8)
score+=6;else if(passwd.length>7&&passwd.length<16)
score+=12;else if(passwd.length>15)
score+=18;var hasLetter=false;var haslowerLetter=false;if(passwd.match(/[a-z]/))
{score+=1;hasLowerLetter=true;hasLetter=true;}
var hasUpperLetter=false;if(passwd.match(/[A-Z]/))
{score+=5;hasLetter=true;hasUpperLetter=true;}
var hasNumber=false;if(passwd.match(/\d+/))
{score+=5;hasNumber=true;}
if(hasNumber&&passwd.match(/(.*[0-9].*[0-9].*[0-9])/))
{score+=5;}
var hasSpecialChar=false;if(passwd.match(/.[!,@,#,$,%,^,&,*,?,_,~]/))
{score+=5;hasSpecialChar=true;}
if(hasSpecialChar&&passwd.match(/(.*[!,@,#,$,%,^,&,*,?,_,~].*[!,@,#,$,%,^,&,*,?,_,~])/))
{score+=5;}
if(hasLowerLetter&&hasUpperLetter)
{score+=1;}
if(hasLetter&&hasNumber)
{score+=1;}
if(hasLetter&&hasNumber&&hasSpecialChar)
{score+=2;}
return Math.round((score/48)*100);},initFileUploads:function(root,size)
{var f=new Element('div',{'class':'fakefile'});f.appendChild(new Element('input',{type:'text',size:size}));f.appendChild(new Element('img',{src:"/globalIcons/ie/AppBasic/16x16/plain/folder_up.png",width:16,height:16}));$A($(root).getElementsBySelector('div.file')).each(function(e)
{var c=$(f.cloneNode(true));e.appendChild(c);var i=e.down('input');i.relatedElement=c.down('input');i.addClassName('hidden');Event.observe(i,'change',function(){this.relatedElement.value=this.value;});Event.observe(i,'mouseout',function(){this.relatedElement.value=this.value;});});}}
var Popup={show:function(name,file,width,height,params)
{var features='scrollbars=yes, width='+width.toString()+', height='+height.toString();window.open(file+'?'+params,name,features);}}
Object.extend(Form,{needConfirmation:false,confirmationMessage:"**",setSelectedValue:function(select,value)
{select=$(select);for(var i=0;i<select.options.length;i++)
{if(select.options[i].value==value)
{select.selectedIndex=i;return;}}},selectAll:function(checkbox,container,name)
{var fields=$A($(container).getElementsByTagName('input'));fields.each(function(field)
{if(field.name==name)
{field.checked=checkbox.checked;}});},clearElement:function(element)
{element=$(element);if(element.tagName=='INPUT'||element.tagName=='TEXTAREA')
element.value='';else if(element.tagName=='SELECT')
{for(var i=0;i<element.options.length;i++)
element.options[i].selected=false;}},disable:function(element,exceptions)
{exceptions=(exceptions||{});element=$(element);var els=$A(element.getElementsByTagName('input'));els.each(function(el){if(!exceptions[el.id]&&!exceptions[el.name])el.disabled='disabled';});els=$A(element.getElementsByTagName('select'));els.each(function(el){if(!exceptions[el.id]&&!exceptions[el.name])el.disabled='disabled';});els=$A(element.getElementsByTagName('textarea'));els.each(function(el){if(!exceptions[el.id]&&!exceptions[el.name])el.disabled='disabled';});els=$A(document.getElementsByClassName('formElement',element));els.each(function(el){if(!exceptions[el.id]&&!exceptions[el.name])Element.hide(el);});},confirmExit:function(needConfirmation,message)
{if(this.needConfirmation==needConfirmation)
return;if(needConfirmation)
{if(message)
this.confirmationMessage=message;window.onbeforeunload=this.onBeforeUnload.bind(this);}
else
window.onbeforeunload=null;this.needConfirmation=needConfirmation;},onBeforeUnload:function()
{return this.confirmationMessage;}});LoginValidator=Class.create();LoginValidator.prototype=Object.extend(new Validator(),{initialize:function(element,options)
{this.element=$(element);this.setOptions({currentUser:0},options);FormValidate.Validators.register(this);},isValid:function()
{var v=this.getValue(this.element);if(v==null||v.length<=0)
return true;var req=new Ajax.Request(webRoot+'/_ajax/users.php',{method:'get',parameters:'method=_loginExists&args[0]='+v+'&args[1]='+this.options.currentUser,asynchronous:false});req=new Ajax.Response(req);var json=req.responseJSON;return json.out!=true;}});function closeAlertBox()
{$('alertBox_overlay').remove();$('alertBox_overlayContent').remove();}
function openLwAlertRss()
{myLightWindow.activateWindow({href:'/stayInTouch/rss.php',title:'',type:'page',width:700,height:500});}
function openLwAlertMail()
{myLightWindow.activateWindow({href:'/stayInTouch/email.php',title:'',type:'page',width:700,height:500});}
function openLwSponsorShip()
{myLightWindow.activateWindow({href:'/sponsorship.php',title:'',type:'page',width:700,height:500});$('alertBox_overlay').remove();$('alertBox_container').remove();}
Event.observe(window,'keypress',function(e)
{if(e.keyCode==13&&e.target.tagName=='INPUT'&&(e.target.type=='text'||e.target.type=='password'))
{var f=$(e.target).up('form');if(f&&(typeof f.onsubmit=='undefined'||f.onsubmit()))
{f.submit();}}}.bindAsEventListener(window));var GlobuleCaptcha={getAnother:function()
{new Ajax.Request("/lw/register.php?captcha=new",{method:"get",onSuccess:this.showAnother.bind(this)});},showAnother:function(transport)
{$('GlobuleCaptcha-img').src='/lw/register.php?captcha='+transport.responseText;$('code').value=transport.responseText;}}
if(typeof(userControler)=='undefined')
userControler=new Object();Object.extend(userControler,{_callback471f412e84a1d:"/_ajax/users.php",_proxy:function(callbackurl,methodName,args,sync)
{var targs=$H();for(var i=0;i<args.length-1;i++){targs.set('args['+i+']',args[i]);}
callback=args[args.length-1];var ar=new Ajax.Request(callbackurl+'?method='+methodName,{method:'post',asynchronous:(!sync),parameters:targs,onComplete:(sync)?null:callback,onException:function(request,e){console.debug(request,e);}});if(sync)
return new Ajax.Response(ar);},_resetPassword:function(){this._proxy(this._callback471f412e84a1d,'_resetPassword',arguments,false);},_resetPassword_sync:function(){return this._proxy(this._callback471f412e84a1d,'_resetPassword',arguments,true);},_checkLogin:function(){this._proxy(this._callback471f412e84a1d,'_checkLogin',arguments,false);},_checkLogin_sync:function(){return this._proxy(this._callback471f412e84a1d,'_checkLogin',arguments,true);},_loginExists:function(){this._proxy(this._callback471f412e84a1d,'_loginExists',arguments,false);},_loginExists_sync:function(){return this._proxy(this._callback471f412e84a1d,'_loginExists',arguments,true);},_registerCompany:function(){this._proxy(this._callback471f412e84a1d,'_registerCompany',arguments,false);},_registerCompany_sync:function(){return this._proxy(this._callback471f412e84a1d,'_registerCompany',arguments,true);},_t:''});Object.extend(userControler,{_request:null,isLogged:false,_isCompanyPage:false,_callback:null,loginAndCallback:function(callback)
{this._callback=callback;myLightWindow.activateWindow({href:'/lw/login.php',title:'',type:'page',width:520,height:220});},checkLogin:function(login,pass,remember)
{$('lightwindow_loading').show();this._checkLogin(login,pass,remember,this._loginChecked.bind(this))},checkLoginCompany:function(login,pass,remember)
{this._isCompanyPage=true;$('lightwindow_loading').show();this._checkLogin(login,pass,remember,'client',this._loginChecked.bind(this));},_loginChecked:function(transport)
{if(!transport.responseJSON.failed)
{this.isLogged=true;if(!this._callback)
{if(this._isCompanyPage)
{document.location='/company/edit.php';}
else
{document.location.reload(true);}}
else
{$('lightwindow_loading').hide();myLightWindow.options.deactivateCallback=function(proceed)
{document.location.reload(true);};this._callback(this);}}
else
{$('lightwindow_loading').hide();new AlertBox(transport.responseJSON.message,{alertType:'Error',okButtonClass:'button'});}},resetPass:function(login)
{$('lightwindow_loading').show();this._resetPassword(login,this.passReseted.bind(this));},passReseted:function(transport,json)
{$('lightwindow_loading').hide();if(json.out.status)
{new AlertBox(json.out.error,{alertType:'OK',okButtonClass:'button'});}
else
{new AlertBox(json.out.error,{alertType:'Error',okButtonClass:'button'});}},register:function()
{$('lightwindow_loading').show();$('register_form').submit();},registerFinish:function(error,message,code)
{$('lightwindow_loading').hide();if(error)
{$('code').value=code;$('codeUser').value="";GlobuleCaptcha.getAnother();new AlertBox(message,{alertType:'Error',okButtonClass:'button'});}
else
{myLightWindow.options.deactivateCallback=function(proceed)
{document.location.reload(true);};if(!this._callback)
{$('lightwindow_loading').hide();myLightWindow.activateWindow({href:'/sponsorship.php',title:'',type:'page',width:700,height:500});}
else
{$('lightwindow_loading').hide();this._callback(this);}}},dropACV:function(fromLogin)
{if(this.isLogged)
{if(fromLogin)
myLightWindow.openWindow($('b_dropCv'));else
myLightWindow.activate(null,$('b_dropCv'));}
else
this.loginAndCallback(this.dropACV.bind(this));},sponsorShip:function()
{if(this.isLogged){myLightWindow.activateWindow({href:'/sponsorship.php',title:'',type:'page',width:700,height:500});}
else
{this.loginAndCallback(this.sponsorShip.bind(this));}},registerCompany:function()
{$('lightwindow_loading').show();var o={companyName:$F('company_name'),sector:$F('sector'),website:$F('website'),firstName:$F('first_name'),lastName:$F('last_name'),email:$F('email'),companyPosition:$F('companyPosition'),phone:$F('phone'),password:$F('password'),confirm:$F('confirm')}
this._registerCompany(Object.toJSON(o),$F('codeUser'),$F('code'),this._companyRegistered.bind(this));},_companyRegistered:function(transport,json)
{$('lightwindow_loading').hide();if(json.failed)
{var data=json.message.evalJSON();$('code').value=data["code"];$('codeUser').value="";GlobuleCaptcha.getAnother();new AlertBox(data["message"],{alertType:'Error',okButtonClass:'button'});}
else
{myLightWindow.options.deactivateCallback=function(proceed)
{document.location.reload(true);};if(!this._callback){document.location='/company/edit.php';}
else
{$('lightwindow_loading').hide();this._callback(this);}}},showSectorSkill:function(elem,init)
{if(init==undefined)param2=false;$$('.skillsTab').invoke('hide');$$('#'+elem.id+'> option').each(function(e)
{if(e.selected)
{if(e.value)
{$('skills_list'+e.value).show();if(!init)
$('skills').select('.ckbSkill').each(function(e){e.checked=false});}}});},toogleSkill:function(elem)
{var parentSkill=$(elem);var childSkill=parentSkill.next('ul');if(childSkill)
{if(childSkill.visible())
{childSkill.hide();childSkill.select('.ckbSkill').each(function(e){e.checked=false});childSkill.select('.skillsList').invoke("hide");}
else
{childSkill.show();}}}});if(typeof(AlertsController)=='undefined')
AlertsController=new Object();Object.extend(AlertsController,{_callback471f411a03355:"/_ajax/alert.php",_proxy:function(callbackurl,methodName,args,sync)
{var targs=$H();for(var i=0;i<args.length-1;i++){targs.set('args['+i+']',args[i]);}
callback=args[args.length-1];var ar=new Ajax.Request(callbackurl+'?method='+methodName,{method:'post',asynchronous:(!sync),parameters:targs,onComplete:(sync)?null:callback,onException:function(request,e){console.debug(request,e);}});if(sync)
return new Ajax.Response(ar);},_addAlert:function(){this._proxy(this._callback471f411a03355,'_addAlert',arguments,false);},_addAlert_sync:function(){return this._proxy(this._callback471f411a03355,'_addAlert',arguments,true);},_t:''});Object.extend(AlertsController,{addAlert:function()
{$('lightwindow_loading').show();var oneSelected=false;var freq=$F('lwfrequency');var name=$F('lwname');var id=$F('alertId');var sectors='';$A($('sectorList').getElementsByTagName('input')).each(function(t)
{if(t.checked&&!t.disabled)
{oneSelected=true;sectors+=t.value+',';}});if(oneSelected)
sectors=sectors.substring(0,sectors.length-1);oneSelected=false;var types='';$A($('typeList').getElementsByTagName('input')).each(function(t)
{if(t.checked)
{oneSelected=true;types+=t.value+',';}});if(oneSelected)
types=types.substring(0,types.length-1);this._addAlert(freq,name,sectors,types,$F('lwcountry'),id,this._alertAdded.bind(this));},_alertAdded:function(transport)
{$('lightwindow_loading').hide();if(!transport.responseJSON.failed)
{if($F('alertId')!=0)
new AlertBox(transport.responseJSON.out,{alertType:'OK',okButtonClass:'button',callBack:function(){document.location.reload(true);}});else
new AlertBox(transport.responseJSON.out,{alertType:'OK',okButtonClass:'button',callBack:this._closeLW});}
else
new AlertBox(transport.responseJSON.message,{alertType:'Error',okButtonClass:'button'});$('alert_mail').reset();},_closeLW:function()
{myLightWindow.deactivate();if(new RegExp('^.{0,}alerts\.php.?$').test(document.URL))
{document.location.reload(true);}},makeUrl:function()
{var url=webRoot+'/rss.php?sector=';var oneSelected=false;$A($('sectorList').getElementsByTagName('input')).each(function(t)
{t.disabled=false;if(t.checked)
{oneSelected=true;url+=t.value+',';}});if(oneSelected)
url=url.substring(0,url.length-1);oneSelected=false;url+='&location='+$('lwcountry').value;url+='&type=';$A($('typeList').getElementsByTagName('input')).each(function(t)
{if(t.checked)
{oneSelected=true;url+=t.value+',';}});if(oneSelected)
url=url.substring(0,url.length-1);$('lwurl_rss').value=url;},subscribeRss:function()
{window.open('http://www.addthis.com/feed.php?pub=Y7TQF2IYTQB954ZL&h1='+$F('lwurl_rss'));},makeTooltip:function(alertObj)
{var str='<div class="toolTipsAlert">';str+='<img src="/images/dessus_cadre_rose_alert.jpg" alt="">';str+='<div class="contenu_cadreTT"><span class="toolTipsItem"><b>Name:</b> '+alertObj.name+'</span>';str+='<span class="toolTipsItem"><b>Frequency:</b> '+alertObj.frequenceType+'</span>';str+='<span class="toolTipsItem"><b>Location:</b> '+alertObj.locationLabel+'</span>';str+='<span class="toolTipsItem"><b>Contract types:</b> '+((alertObj.contractType.length>0)?alertObj.contractType:'all')+'</span>';str+='<b>Sectors: </b>';if(alertObj.tabSector)
{$A(alertObj.tabSector).each(function(s)
{str+='<span class="toolTipsItem">'+s+'</span>';});}
else
str+='<span class="toolTipsItem">all</span>';str+='</div><img src="/images/dessous_cadre_rose_alert.jpg" alt=""></div></div>';return str;},selectAllSectors:function()
{$A($('sectorList').getElementsByTagName('input')).each(function(t)
{t.checked=true;});},deselectAllSectors:function()
{$A($('sectorList').getElementsByTagName('input')).each(function(t)
{t.checked=false;});},invertSectors:function()
{$A($('sectorList').getElementsByTagName('input')).each(function(t)
{t.checked=!t.checked;});}});if(typeof(ContactsController)=='undefined')
ContactsController=new Object();Object.extend(ContactsController,{_callback471f40d6ec215:"/_ajax/contact.php",_proxy:function(callbackurl,methodName,args,sync)
{var targs=$H();for(var i=0;i<args.length-1;i++){targs.set('args['+i+']',args[i]);}
callback=args[args.length-1];var ar=new Ajax.Request(callbackurl+'?method='+methodName,{method:'post',asynchronous:(!sync),parameters:targs,onComplete:(sync)?null:callback,onException:function(request,e){console.debug(request,e);}});if(sync)
return new Ajax.Response(ar);},editContact:function(){this._proxy(this._callback471f40d6ec215,'editContact',arguments,false);},editContact_sync:function(){return this._proxy(this._callback471f40d6ec215,'editContact',arguments,true);},_loadContacts:function(){this._proxy(this._callback471f40d6ec215,'_loadContacts',arguments,false);},_loadContacts_sync:function(){return this._proxy(this._callback471f40d6ec215,'_loadContacts',arguments,true);},forwardMission:function(){this._proxy(this._callback471f40d6ec215,'forwardMission',arguments,false);},forwardMission_sync:function(){return this._proxy(this._callback471f40d6ec215,'forwardMission',arguments,true);},_searchContacts:function(){this._proxy(this._callback471f40d6ec215,'_searchContacts',arguments,false);},_searchContacts_sync:function(){return this._proxy(this._callback471f40d6ec215,'_searchContacts',arguments,true);},_t:''});Object.extend(ContactsController,{loadContacts:function(letter,container,template)
{this._loadContacts(letter,this._contactsLoaded.bind(this,container,template));},_contactsLoaded:function(container,template,transport)
{var json=transport.responseJSON;if(json&&!json.failed)
{container=$(container);container.update('');$A(json.out).each(function(contact){container.insert(template.evaluate(contact));});}
else
{new AlertBox(json.message,{alertType:'Error',okButtonClass:'button'});}},searchContacts:function(lastName,firstName,container,template)
{this._searchContacts(lastName,firstName,this._contactsFound.bind(this,container,template));},_contactsFound:function(container,template,transport)
{var json=transport.responseJSON;if(json&&!json.failed)
{container=$(container);container.update('');$A(json.out).each(function(contact){container.insert(template.evaluate(contact));});}
else
{new AlertBox(json.message,{alertType:'Error',okButtonClass:'button'});}}});if(typeof(skillsControler)=='undefined')
skillsControler=new Object();Object.extend(skillsControler,{_callback471f412e84a1d:"/_ajax/skills.php",_proxy:function(callbackurl,methodName,args,sync)
{var targs=$H();for(var i=0;i<args.length-1;i++){targs.set('args['+i+']',args[i]);}
callback=args[args.length-1];var ar=new Ajax.Request(callbackurl+'?method='+methodName,{method:'post',asynchronous:(!sync),parameters:targs,onComplete:(sync)?null:callback,onException:function(request,e){console.debug(request,e);}});if(sync)
return new Ajax.Response(ar);},_saveSkill:function(){this._proxy(this._callback471f412e84a1d,'_saveSkill',arguments,false);},_saveSkill_sync:function(){return this._proxy(this._callback471f412e84a1d,'_saveSkill',arguments,true);},_t:''});Object.extend(skillsControler,{saveSkills:function(level)
{var skills=new Hash();$$('div.step_list input').each(function(s){if(s.checked){skills.set(s.value,s.checked);}});this._saveSkill(skills.toJSON(),function(r,json){if(level<6){$('step'+level).hide();$('step'+(level+1)).show();}else{myLightWindow.deactivate();}});}});