
function getOnlineStatus()
{var online;var request;if(window.XMLHttpRequest&&!(window.ActiveXObject)){try{request=new XMLHttpRequest();}catch(ex){request=false;}}else if(window.ActiveXObject){try{request=new ActiveXObject("Msxml2.XMLHTTP");}catch(ex){try{request=new ActiveXObject("Microsoft.XMLHTTP");}catch(ex){request=false;}}}
if(request){request.open('POST','/coremodule/checkonline/',false);request.setRequestHeader('Content-Type','application/x-www-form-urlencoded');request.send('');online=request.responseText;}
return online;}
function logged_out()
{if(getOnlineStatus()==0){document.location.reload();return 1;}
return 0;}
function loadXMLDoc(url,parser,offline_allowed){if(!offline_allowed&&logged_out()){return;}
if(window.XMLHttpRequest&&!(window.ActiveXObject)){try{req=new XMLHttpRequest();}catch(ex){req=false;}}else if(window.ActiveXObject){try{req=new ActiveXObject("Msxml2.XMLHTTP");}catch(ex){try{req=new ActiveXObject("Microsoft.XMLHTTP");}catch(ex){req=false;}}}
if(req){req.onreadystatechange=parser;req.open("GET",url,true);req.send(null);}}
function loadAndWaitForXML(url,parser,offline_allowed)
{var XML=getResponseXML(url,offline_allowed);parser(XML);}
function getXmlDoc(url,data,parser){if(logged_out()){return;}
if(window.XMLHttpRequest&&!(window.ActiveXObject)){try{req=new XMLHttpRequest();}catch(ex){req=false;}}else if(window.ActiveXObject){try{req=new ActiveXObject("Msxml2.XMLHTTP");}catch(ex){Tac
try{req=new ActiveXObject("Microsoft.XMLHTTP");}catch(ex){req=false;}}}
if(req){req.onreadystatechange=parser;req.open('POST',url,true);req.setRequestHeader('Content-Type','application/x-www-form-urlencoded');req.send(data);}}
function postAndWaitForResponse(url,data,offline_allowed){if(!offline_allowed&&logged_out()){return null;}
var request;if(window.XMLHttpRequest&&!(window.ActiveXObject)){try{request=new XMLHttpRequest();}catch(ex){request=false;}}else if(window.ActiveXObject){try{request=new ActiveXObject("Msxml2.XMLHTTP");}catch(ex){try{request=new ActiveXObject("Microsoft.XMLHTTP");}catch(ex){request=false;}}}
if(request){request.open('POST',url,false);request.setRequestHeader('Content-Type','application/x-www-form-urlencoded');request.send(data);return request.responseText;}
return null;}
function postAndParseResult(url,_data,offline_allowed)
{var data=postAndWaitForResponse(url,_data,offline_allowed);if(data!=''){data=JSON.parse(data);}
return data;}
function postAndCallback(url,data,callback,offline_allowed){if(!offline_allowed&&logged_out()){return null;}
var request;if(window.XMLHttpRequest&&!(window.ActiveXObject)){try{request=new XMLHttpRequest();}catch(ex){request=false;}}else if(window.ActiveXObject){try{request=new ActiveXObject("Msxml2.XMLHTTP");}catch(ex){try{request=new ActiveXObject("Microsoft.XMLHTTP");}catch(ex){request=false;}}}
if(request){request.open('POST',url,true);request.setRequestHeader('Content-Type','application/x-www-form-urlencoded');request.send(data);request.onreadystatechange=function(){if(request.readyState==4){callback(request.responseText);}};return null;}
return null;}
function getResponseText(url,offline_allowed){if(!offline_allowed&&logged_out()){return false;}
var request;if(window.XMLHttpRequest&&!(window.ActiveXObject)){try{request=new XMLHttpRequest();}catch(ex){request=false;}}else if(window.ActiveXObject){try{request=new ActiveXObject("Msxml2.XMLHTTP");}catch(ex){try{request=new ActiveXObject("Microsoft.XMLHTTP");}catch(ex){request=false;}}}
if(request){request.open('GET',url,false);request.send(null);return request.responseText;}
return false;}
function getResponseXML(url,offline_allowed){if(!offline_allowed&&logged_out()){return false;}
var request;if(window.XMLHttpRequest&&!(window.ActiveXObject)){try{request=new XMLHttpRequest();}catch(ex){request=false;}}else if(window.ActiveXObject){try{request=new ActiveXObject("Msxml2.XMLHTTP");}catch(ex){try{request=new ActiveXObject("Microsoft.XMLHTTP");}catch(ex){request=false;}}}
if(request){request.open('GET',url,false);request.send(null);return request.responseXML;}
return false;}
if(!Array.prototype.forEach){Array.prototype.forEach=function(fun)
{var len=this.length;if(typeof fun!="function"){throw new TypeError();}
var thisp=arguments[1];for(var i=0;i<len;i++){if(i in this){fun.call(thisp,this[i],i,this);}}};}
if(!Array.prototype.inArray){Array.prototype.inArray=function(p_val){for(var i=0,l=this.length;i<l;i++){if(this[i]==p_val){return i;}}
return-1;};}
function forEach(arr,fun)
{if(typeof fun!="function"){throw new TypeError();}
var thisp=arguments[1];for(var id in arr){var val=arr[id];if((typeof val)!='function'){fun.call(thisp,id,val,arr);}}}
function getMenuItemForX(x){return pages[x-1];}
function switchSubHelpPage(sub,nr)
{var currPage=document.getElementById('currPage');var currSub=document.getElementById('currSub');var currPageNr=currPage?currPage.innerHTML:'';var currSubNr=currSub?currSub.innerHTML:'';if(currSubNr!=sub){currPageNr='';if(currSubNr!=''){var pageDiv;for(var i=1;(pageDiv=document.getElementById(currSubNr+'-helppage-'+i))!=null;i++){pageDiv.style.display='none';}
document.getElementById('subpage-'+currSubNr).style.display='none';}
var subDiv=document.getElementById('subpage-'+sub);if(subDiv==null){var tmpDiv=document.getElementById('currPage');if(tmpDiv!=null){tmpDiv.innerHTML='0';}
tmpDiv=document.getElementById('currSub');if(tmpDiv!=null){tmpDiv.innerHTML='0';}
tmpDiv=document.getElementById('maxPage');if(tmpDiv!=null){tmpDiv.innerHTML='0';}
tmpDiv=document.getElementById('maxPage');if(tmpDiv!=null){document.getElementById('txtCurrPage').innerHTML='0 / 0';}
return false;}
if(currSub!=null){currSub.innerHTML=sub;}
if(subDiv!=null){subDiv.style.display='block';}
if(document.getElementById('subMaxPage-'+sub)!=null){document.getElementById('maxPage').innerHTML=''+document.getElementById('subMaxPage-'+sub).innerHTML;}}
var helpDiv=document.getElementById(sub+'-helppage-'+nr);if(helpDiv==null){return false;}
if(currPageNr!=''){document.getElementById(sub+'-helppage-'+currPageNr).style.display='none';}
helpDiv.style.display='block';document.getElementById('txtCurrPage').innerHTML=(nr+' / '+
document.getElementById('maxPage').innerHTML);currPage.innerHTML=nr;}
function helpRight()
{var currPage=document.getElementById('currPage').innerHTML;var currSub=document.getElementById('currSub').innerHTML;if(currSub==''||currSub=='0'){return;}
if(switchSubHelpPage(currSub,parseInt(currPage)+1)==false){switchSubHelpPage(currSub,1);}}
function helpLeft()
{var currPage=document.getElementById('currPage').innerHTML;var currSub=document.getElementById('currSub').innerHTML;if(currSub==''||currSub=='0'){return;}
if(parseInt(currPage)==1){currPage=(parseInt(document.getElementById('maxPage').innerHTML)+1);}
switchSubHelpPage(parseInt(currSub),parseInt(currPage)-1);}
function helpPage(id)
{var foundHelpDiv=false;var subpage0=document.getElementById('subpage-0');var helppage0=document.getElementById('0-helppage-0');if(switchSubHelpPage(id,1)==false){if(subpage0!=null){subpage0.style.display='block';}
if(helppage0!=null){helppage0.style.display='block';}
return;}
if(subpage0!=null){document.getElementById('subpage-0').style.display='none';}
if(helppage0!=null){document.getElementById('0-helppage-0').style.display='none';}}
function oneMenuItem(id,callbackHook){var currButt=$('topButton-'+id);var currClass='main-button-blank-sel';var otherClass='main-button-blank';for(var cnt=1;cnt<=6;cnt++){var otherButt=$('topButton-'+cnt);if(otherButt==null){continue;}
otherButt.className=otherClass;}
if(callbackHook!=null){callbackHook();}
currButt.className=currClass;menuItem(id,false,true);}
function menuItem(id,nohelp,nobuttons,callBackHook){var save=document.getElementById('saveWhenChange');if(save&&save.value=='1'){var x=document.getElementById('ws-navigator-x1');if(x!=null){savePage(getMenuItemForX(x.innerHTML));}}
if(nohelp==null){setTimeout('helpPage('+id+')',0);}
if(id<10){id='0'+id;}
for(var i=1;i<=19;i++){var num=i;if(i<10){num='0'+num;}
var menuItem=$('menuItem'+num);if((menuItem!=null)||(nobuttons==true)){if(num==id){if(menuItem!=null){menuItem.className='menuItemSelected';}
document.getElementById('menuItemWorkspace'+num).style.display='block';}else if(document.getElementById('menuItemWorkspace'+num)){if(menuItem!=null){menuItem.className='menuItem';}
document.getElementById('menuItemWorkspace'+num).style.display='none';}}}
for(i=1;i<=19;i++){var num=i;if(i<10){num='0'+num;}
if(document.getElementById('nextPrevButtons')!=null){updateNextPrev(id);}
var menuItemHorizontal=document.getElementById('menuItemHorizontal'+num);if(menuItemHorizontal!=null){if(num==id){menuItemHorizontal.className='menuItemSelectedHorizontal';document.getElementById('menuItemWorkspace'+num).style.display='block';}else if(document.getElementById('menuItemWorkspace'+num)){menuItemHorizontal.className='menuItemHorizontal';document.getElementById('menuItemWorkspace'+num).style.display='none';}}}
if(callBackHook!=null){callBackHook(id,nohelp,nobuttons);}}
function getSelectedMenuItem()
{var item;for(var i=1;i<=19;i++){var num=i;if(i<10){num='0'+num;}
item=document.getElementById('menuItemWorkspace'+num);if(item.style.display=='block'){return i;}}
return-1;}
function nextstep(){if(validUsername){loadXMLDoc('/module:coremodule/method:register/action:usernamereservation/username:'+username+'/',nextstepHandler);}else{document.getElementById('regusernamebutton').innerHTML='Ugyldig brukernavn!';}}
function nextstepHandler(){if(req.readyState==4){if(req.status==200){id=req.responseText;if(id==-1){document.getElementById('regusernamebutton').innerHTML='For kort brukernavn!';}else if(id==-2){document.getElementById('regusernamebutton').innerHTML='Brukernavnet er tatt i bruk!';}else{username=document.getElementById('USR').value;document.getElementById('USR').disabled='disabled';document.getElementById('regform').style.display='block';document.getElementById('step1completed').style.display='none';document.getElementById('container-USR').style.display='none';}}}}
function saveGeneral(){var GEN=document.getElementById('GEN');var UTD=document.getElementById('UTD');var FA1=document.getElementById('FA1');var FA2=document.getElementById('FA2');var SUR=document.getElementById('SUR');var AD1=document.getElementById('AD1');var AD2=document.getElementById('AD2');var POS=document.getElementById('POS');var PAD=document.getElementById('PAD');var YEA=document.getElementById('YEA');var MON=document.getElementById('MON');var DAY=document.getElementById('DAY');var MOB=document.getElementById('MOB');var PHO=document.getElementById('PHO');var FOR=document.getElementById('FOR');var EXP=document.getElementById('EXP');var COU=document.getElementById('COU');var CNTY=document.getElementById('CNTY');if(postAndWaitForResponse('/coremodule/checkonline/','')==0){alert('You have been inactive for too long or have logged in from another computer.');return;}
var nrError=0;if(trim(FOR.value)==''){document.getElementById("cvReqFirstName").style.color="red";document.getElementById("cvReqFirstNameStar").style.color="red";document.getElementById("cvReqGeneral").style.display="";nrError++;}else{document.getElementById("cvReqFirstName").style.color="black";document.getElementById("cvReqFirstNameStar").style.color="black";}
if(trim(SUR.value)==''){document.getElementById("cvReqLastName").style.color="red";document.getElementById("cvReqLastNameStar").style.color="red";document.getElementById("cvReqGeneral").style.display="";nrError++;}else{document.getElementById("cvReqLastName").style.color="black";document.getElementById("cvReqLastNameStar").style.color="black";}
if(trim(AD1.value)==''){document.getElementById("cvReqAddress").style.color="red";document.getElementById("cvReqAddressStar").style.color="red";document.getElementById("cvReqGeneral").style.display="";nrError++;}else{document.getElementById("cvReqAddress").style.color="black";document.getElementById("cvReqAddressStar").style.color="black";}
if(trim(POS.value)==''){document.getElementById("cvReqZipcode").style.color="red";document.getElementById("cvReqZipcodeStar").style.color="red";document.getElementById("cvReqGeneral").style.display="";nrError++;}else{document.getElementById("cvReqZipcode").style.color="black";document.getElementById("cvReqZipcodeStar").style.color="black";}
if(trim(PAD.value)==''){document.getElementById("cvReqCity").style.color="red";document.getElementById("cvReqCityStar").style.color="red";document.getElementById("cvReqGeneral").style.display="";nrError++;}else{document.getElementById("cvReqCity").style.color="black";document.getElementById("cvReqCityStar").style.color="black";}
if(trim(COU.value)==''){document.getElementById("cvReqCountry").style.color="red";document.getElementById("cvReqCountryStar").style.color="red";document.getElementById("cvReqGeneral").style.display="";nrError++;}else{document.getElementById("cvReqCountry").style.color="black";document.getElementById("cvReqCountryStar").style.color="black";}
if(trim(GEN.value)==''){document.getElementById("cvReqGender").style.color="red";document.getElementById("cvReqGenderStar").style.color="red";document.getElementById("cvReqGeneral").style.display="";nrError++;}else{document.getElementById("cvReqGender").style.color="black";document.getElementById("cvReqGenderStar").style.color="black";}
if(UTD){if(trim(UTD.value)==''){document.getElementById("cvReqEducationGen").style.color="red";document.getElementById("cvReqEducationGenStar").style.color="red";document.getElementById("cvReqGeneral").style.display="";nrError++;}else{document.getElementById("cvReqEducationGen").style.color="black";document.getElementById("cvReqEducationGenStar").style.color="black";}}
if(DAY.value>30&&(MON.value==2||MON.value==4||MON.value==6||MON.value==9||MON.value==11)){alert('The date you have chosen does not exist');return;}
if(DAY.value>28&&MON.value==2&&(DAY.value>29||YEA.value%4!=0)){alert('The date you have chosen does not exist');return;}
if((MOB.value==''||MOB.value==0)&&PHO.value==''){document.getElementById("cvReqPhone").style.color="red";document.getElementById("cvReqPhoneStar").style.color="red";document.getElementById("cvReqGeneral").style.display="";nrError++;}else{document.getElementById("cvReqPhone").style.color="black";document.getElementById("cvReqPhoneStar").style.color="black";}
if(nrError>0){}
url='/cv/saveGeneral/';url+='FOR:'+escape(FOR.value)+'/';url+='SUR:'+escape(SUR.value)+'/';url+='AD1:'+escape(AD1.value)+'/';url+='AD2:'+escape((AD2.value?AD2.value:''))+'/';url+='POS:'+escape(POS.value)+'/';url+='PAD:'+escape(PAD.value)+'/';url+='YEA:'+escape(YEA.value)+'/';url+='MON:'+escape(MON.value)+'/';url+='DAY:'+escape(DAY.value)+'/';url+='PHO:'+escape((PHO.value?PHO.value:''))+'/';url+='MOB:'+escape(MOB.value)+'/';url+='GEN:'+escape(GEN.value)+'/';if(UTD){url+='UTD:'+escape(UTD.value)+'/';url+='FA1:'+escape(FA1.value)+'/';url+='FA2:'+escape(FA2.value)+'/';url+='EXP:'+escape(EXP.value)+'/';}
url+='COU:'+escape(COU.value)+'/';url+='CNTY:'+escape(CNTY.value)+'/';var licenses=new Array();var checkBoxes=document.getElementsByTagName('input');for(var cnt=0;cnt<checkBoxes.length;cnt++){if((checkBoxes[cnt].name=='drivers_license')&&(checkBoxes[cnt].checked==true)){licenses[licenses.length]=checkBoxes[cnt].id;}}
if(licenses.length>0){url+='DRV:'+licenses.join(',')+'/';}
displayWait('Saving');loadXMLDoc(url,function(){if(req.readyState==4&&req.status==200){removeWait();if(req.responseText){alert(unescape(req.responseText));}}});try{document.getElementById('cvMenuBack11').className='cvMenuBackGreen';}
catch(e){}}
function activateWithMyNetwork()
{if($('acceptedTerms').checked==false){alert('NEED_TO_ACCEPT_TERMS');return;}
postAndWaitForResponse('/cv/activateuser/');document.location.reload(true);}
function tryLoadMessages(activeReqFid)
{if(activeRecruitmendFolderID==null){return;}
var isFolded=getMenu().getItemAt(activeRecruitmendFolderID).getFolded();if(isFolded==true){setTimeout(tryLoadMessages,100);return;}
loadMessages();}
function openProjectReport(id)
{window.open('/center/projectreport/id:'+id+'/','profile'+id,'width=700,height=705,menubar=no,location=no,resizable=no,scrollbars=no,status=no');}
function addProjectComment()
{document.getElementById('project-comment').style.display='block';document.getElementById('project-shade').style.display='block';}
function closeProjectComment()
{document.getElementById('project-comment').style.display='none';document.getElementById('project-shade').style.display='none';}
function reloadFileList(pid)
{displayWait('RELOADING_FILES');loadXMLDoc('/center/loadfilelist/pid:'+pid+'/',function(){removeWait();var div=document.getElementById('report-file-container');div.innerHTML='';var elems=req.responseXML.getElementsByTagName('file');for(var i=0;i<elems.length;i++){div.innerHTML+='<div style="width: 250px; float: left;">'+elems[i].getAttribute('name')+'</div>'+'<div style="width: 250px; float: left;">'+elems[i].getAttribute('assocname')+'</div>'+'<div style="width: 70px; float: left; text-align: center;"><a href="/center/downloadCompanyFile/fid:'+elems[i].getAttribute('id')+'/" class="recruit-links">Download</a></div>'+'<div style="width: 70px; float: left; text-align: center;"><a href="javascript:deleteCompanyFile('+elems[i].getAttribute('id')+');" class="recruit-links">Delete</a></div>'+'<div style="clear: both;"></div>'+'<div style="width: 475px; margin-bottom: 3px;"><i>'+elems[i].getAttribute('description')+'</i></div>';}});}
function saveProjectComment(id)
{var editor=tinyMCE.getInstanceById('project-comment-text');var comment=editor.getContent();displayWait('Saving');var data=postAndWaitForResponse('/center/commentproject/pid:'+id+'/','comment='+htmlspecialchars(comment));removeWait();if(data=='1'){document.location.reload();}else{alert(data);}}
function viewProfile(id){window.open('/user/view/id:'+id+'/include:0/','profile'+id,'width=700,height=650,menubar=no,location=no,resizable=no,scrollbars=no,status=no');}
function viewSelectedProfiles()
{var req_id=new Array();var tags=document.getElementById('dataresult').getElementsByTagName('input');for(var i=0;i<tags.length;i++){if(tags[i].type!='checkbox'&&tags[i].id!='toggleall'){continue;}
if(tags[i].checked==false){continue;}
req_id[req_id.length]=tags[i].id;}
if(req_id.length==0){alert('Mark the profiles you wish to have access to');return;}
var req_str=req_id.join(';');window.open('/user/request/id:'+req_id+'/','request','width=700,height=650,menubar=no,location=no,resizable=no,scrollbars=no,status=no');}
function closeProfileInfo(){document.getElementById('infobox').style.display='none';var editor=tinyMCE.getInstanceById('editor');if(editor!=null){editor.remove();}
document.getElementById('infoboxButtonContainer').style.width='180px';document.getElementById('infoboxButtonContainer').innerHTML='<div class="button-180-gray" style="float: left;"><a class="button-180-gray" href="javascript:infobox.hide();"><span class="vertical-180-24-button">Close</span></a></div>';}
function profileInfo(table,id){var box=document.getElementById('infobox');displayWait('Loading data');loadXMLDoc('/user/profileInfo/table:'+escape(table)+'/id:'+id+'/',function(){if(req.readyState==4&&req.status==200){removeWait();box.style.display='block';document.getElementById('infoboxData').innerHTML=unescape(req.responseText);}});}
function loadLocaleGroups(selectID,id,occupationClear)
{var selectOb=document.getElementById(selectID);var elem=document.createElement('option');selectOb.options.length=0;if(occupationClear!=null){document.getElementById(occupationClear).options.length=1;document.getElementById(occupationClear).disabled=true;}
loadAndWaitForXML('/center/loadLocaleGroups/id:'+id+'/',function(ret){var elems=ret.getElementsByTagName('localeGroup')
if(elems.length==0){elem.text='Occupation group missing';selectOb.disabled=true;}else{elem.text='Choose occupation group';selectOb.disabled=false;}
if(!document.all){selectOb.add(elem,null);}else{selectOb.add(elem);}
for(var i=0;i<elems.length;i++){var node=elems[i].attributes;var id=node.getNamedItem('localecode').value;var name=unescape(node.getNamedItem('name').value);elem=document.createElement('option');elem.text=name;elem.value=id;if(!document.all){selectOb.add(elem,null);}else{selectOb.add(elem);}}});}
function loadOccupationNames(selectID,id)
{var selectOb=document.getElementById(selectID);var elem=document.createElement('option');selectOb.options.length=0;loadAndWaitForXML('/center/loadOccupationNames/id:'+id+'/',function(ret){var elems=ret.getElementsByTagName('occupationName')
if(elems.length==0){elem.text='Occupation title missing';selectOb.disabled=true;}else{elem.text='Choose occupation';selectOb.disabled=false;}
if(!document.all){selectOb.add(elem,null);}else{selectOb.add(elem);}
for(var i=0;i<elems.length;i++){var node=elems[i].attributes;var id=node.getNamedItem('occupationnameid').value;var name=unescape(node.getNamedItem('name').value);elem=document.createElement('option');elem.text=name;elem.value=id;if(!document.all){selectOb.add(elem,null);}else{selectOb.add(elem);}}});}
function testJobDate(ends){var year;var month;var day;if(ends==true){year=document.getElementById('ends-YEA');mon=document.getElementById('ends-MON');day=document.getElementById('ends-DAY');}else{year=document.getElementById('pub-YEA');mon=document.getElementById('pub-MON');day=document.getElementById('pub-DAY');}
if(year.value==''){return false;}
if(mon.value==''){return false;}
if(day.value==''){return false;}
return(year.value+'-'+(mon.value<10?('0'+mon.value):mon.value)+'-'+(day.value<10?('0'+day.value):day.value));}
function updateDateDiv(div,type,val)
{var divOb=document.getElementById(div);var date=divOb.value.split('-');var typeInt;if(type=='year'){typeInt=0;}else if(type=='month'){typeInt=1;if(val<10){val='0'+val;}}else{typeInt=2;if(val<10){val='0'+val;}}
date[typeInt]=val;divOb.value=date.join('-');}
function hideDatePicker()
{$('job-ends-gui').style.display='none';$('job-published-gui').style.display='none';$('job-projends-gui').style.display='none';var pubs=document.getElementById('job-published').value.split('-');var ends=document.getElementById('job-ends').value.split('-');var projends=document.getElementById('job-projends').value.split('-');var pubSelY=document.getElementById('pub-YEA');var pubSelM=document.getElementById('pub-MON');var pubSelD=document.getElementById('pub-DAY');for(var i=0;i<pubSelY.options.length;i++){if(parseInt(pubSelY.options[i].value)==parseInt(pubs[0])){pubSelY.options[i].selected=true;}}
for(var i=0;i<pubSelM.options.length;i++){if(parseInt(pubSelM.options[i].value)==parseInt(pubs[1])){pubSelM.options[i].selected=true;}}
for(var i=0;i<pubSelD.options.length;i++){if(parseInt(pubSelD.options[i].value)==parseInt(pubs[2])){pubSelD.options[i].selected=true;}}
var endSelY=document.getElementById('ends-YEA');var endSelM=document.getElementById('ends-MON');var endSelD=document.getElementById('ends-DAY');for(var i=0;i<endSelY.options.length;i++){if(parseInt(endSelY.options[i].value)==parseInt(ends[0])){endSelY.options[i].selected=true;}}
for(var i=0;i<endSelM.options.length;i++){if(parseInt(endSelM.options[i].value)==parseInt(ends[1])){endSelM.options[i].selected=true;}}
for(var i=0;i<endSelD.options.length;i++){if(parseInt(endSelD.options[i].value)==parseInt(ends[2])){endSelD.options[i].selected=true;}}
var projeSelY=document.getElementById('proje-YEA');var projeSelM=document.getElementById('proje-MON');var projeSelD=document.getElementById('proje-DAY');for(var i=0;i<projeSelY.options.length;i++){if(parseInt(projeSelY.options[i].value)==parseInt(projends[0])){projeSelY.options[i].selected=true;}}
for(var i=0;i<projeSelM.options.length;i++){if(parseInt(projeSelM.options[i].value)==parseInt(projends[1])){projeSelM.options[i].selected=true;}}
for(var i=0;i<projeSelD.options.length;i++){if(parseInt(projeSelD.options[i].value)==parseInt(projends[2])){projeSelD.options[i].selected=true;}}}
var datePickerTimeoutID;var pickerParentOB;function datePickerTimeout(type,parent)
{if(parent!=null){pickerParentOB=parent;type=pickerParentOB.id;}
datePickerTimeoutID=setTimeout("showDatePicker('"+type+"')",500);}
function clearDatePickerTimeout()
{pickerParentOB=null;clearTimeout(datePickerTimeoutID);}
function showDatePicker(type)
{if(type=='published'){$('job-ends-gui').style.display='none';$('job-published-gui').style.display='block';$('job-projends-gui').style.display='none';}else if(type=='ends'){$('job-ends-gui').style.display='block';$('job-published-gui').style.display='none';$('job-projends-gui').style.display='none';}else{$('job-ends-gui').style.display='none';$('job-published-gui').style.display='none';$('job-projends-gui').style.display='block';}
displayDatePicker(('job-'+type),('job-'+type+'-gui'),pickerParentOB);}
function resetPassword(){var email=document.getElementById('email').value;displayWait('Sending');loadXMLDoc('/coremodule/resetpassword/email:'+escape(email)+'/request:1/',function(){if(req.readyState==4&&req.status==200){var resp;removeWait();resp=unescape(req.responseText);if(resp!='1'){alert(resp);}else{alert('A new password has been sent to your e-mail');window.location='/';}}},true);}
function changePassword(){var PA1=document.getElementById('PA1').password?document.getElementById('PA1').password:document.getElementById('PA1').value;var PA2=document.getElementById('PA2').password?document.getElementById('PA2').password:document.getElementById('PA2').value;var PA3=document.getElementById('PA3').password?document.getElementById('PA3').password:document.getElementById('PA3').value;if(PA2==PA3){displayWait('Sending',true);loadXMLDoc('/coremodule/resetpassword/pa1:'+hex_md5(PA1)+'/pa2:'+hex_md5(PA2)+'/',function(){if(req.readyState==4&&req.status==200){removeWait();if(req.responseText!=''){alert(unescape(req.responseText));}else{alert('Your password has now been changed.');try{hideMessageBox();}
catch(e){}}}});}else{alert('The passwords do not match.');}}
function shareOnLinkedIn(url)
{window.open(url,'LIShare','width=700,height=700,toolbar=0,resizable=1,status=0,menubar=0,scrolling=1');}
function readTerms(){window.open('/info/memberterms/popup:1/nobuttons:1/','memberTerms','width=700,height=705,toolbar=0,resizable=1,status=0,menubar=0,scrolling=1');}
function readNAVInfo(){window.open('/info/nav/popup:1/nobuttons:1/','navTerms','width=700,height=705,toolbar=0,resizable=1,status=0,menubar=0,scrolling=1');}
function readCTerms(){var box=document.getElementById('infobox');loadXMLDoc('/article/id:10/encode:1/',function(){if(req.readyState==4&&req.status==200){box.style.display='block';document.getElementById('infoboxData').innerHTML=unescape(req.responseText);}},true);}
function seeSpontaneousAppAnswers(id)
{window.open('/center/spontaneousform/id:'+id+'/','spontAppAnswers'+id,'width=600,height=600,toolbar=0,resizable=0,status=0,menubar=0,scrolling=0');}
function getSAPPURL(sappid)
{var sappURL='/job/applyforspontaneous/sappid:'+sappid+'/';return sappURL;}
function getSAPPPostData(sappid)
{var sappURL='';var currName=null;var currSapp=null;var inputs=document.getElementsByTagName('*');var dataArray=new Array();var ok=true;var oneChecked=false;var currBox;var sapps=new Array();for(var cnt=0;cnt<inputs.length;cnt++){if(!inputs[cnt].name||(inputs[cnt].name.length<8)||(inputs[cnt].name.substr(0,8)!='question')){continue;}
if(inputs[cnt].id=='selection'){continue;}
currBox=inputs[cnt];if(currName==null||currName!=inputs[cnt].name){if(dataArray.length>0){sappURL+=(('answer_'+currSapp)+'='+dataArray.join(',')+'&');dataArray.length=0;}
if(currName&&(currType==2)){if(oneChecked==false){ok=false;}
oneChecked=false;}
currName=inputs[cnt].name;currSapp=parseInt(inputs[cnt].name.substr(9));currType=(inputs[cnt].type=='textarea'?1:2);sapps[sapps.length]=currSapp+';'+currType;}
if(inputs[cnt].type=='radio'||inputs[cnt].type=='checkbox'){if(inputs[cnt].checked==false){dataArray[dataArray.length]=inputs[cnt].id+';0';}else{dataArray[dataArray.length]=inputs[cnt].id+';1';oneChecked=true;}}else{if(inputs[cnt].value.length==0){ok=false;}else{if(inputs[cnt].id!='selection'){var answerText=inputs[cnt].value;answerText=htmlspecialchars(answerText);answerText=answerText.replace(/,/g,'%COMMA%');answerText=answerText.replace(/;/g,'%SEMICOLON%');answerText=answerText.replace(/:/g,'%COLON%');sappURL+=(('answer_'+currSapp)+'='+inputs[cnt].id+';'+answerText+'&');}}}}
if(dataArray.length>0){if(currBox.type=='radio'||currBox.type=='checkbox'){if(oneChecked==false){ok=false;}}
sappURL+=(('answer_'+currSapp)+'='+dataArray.join(',')+'&');}
sappURL+=('questions='+sapps.join(','));if(ok==false){alert('You must answer all questions');return false;}
return sappURL;}
function seeSpontaneousAppAnswers(id)
{window.open('/center/spontaneousform/id:'+id+'/','spontAppAnswers'+id,'width=600,height=600,toolbar=0,resizable=0,status=0,menubar=0,scrolling=0');}
function savePositionAnswers(pid)
{var ret=[];var sort=1;var qm=$('qm-1');for(;qm;qm=$('qm-'+(++sort))){var qmId=parseInt(qm.value);ret[sort]={'type':qmId};switch(qmId){case 1:if(!$(sort+'-yes').checked&&!$(sort+'-no').checked){alert('All questions must be answered in order for your application to be submitted.');return false;}
ret[sort].value=($(sort+'-yes').checked==true)?'yes':'no';break;case 4:var oneChecked=false;var qmOpts=$('!'+sort+'-opt');var qmOpt=null;var scid=null;var regex=/[0-9]-opt-([0-9]{1,})/;var matches=null;var arr=[];ret[sort].value='';for(var cnt=0;cnt<qmOpts.length;cnt++){qmOpt=qmOpts[cnt];matches=qmOpt.id.match(regex);if(matches.length>0){scid=matches[1];if(qmOpt.checked==true){arr.push(scid);oneChecked=true;}}}
if(oneChecked==false){alert('All questions must be answered in order for your application to be submitted.');return false;}
ret[sort].value=arr.join(';');break;case 2:case 7:var oneChecked=false;var osort=1;var qmOpt=$(sort+'-opt-'+osort);ret[sort].value=[];for(;qmOpt;qmOpt=$(sort+'-opt-'+(++osort))){if(qmOpt.checked==true){ret[sort].value[osort]=true;oneChecked=true;}else{ret[sort].value[osort]=false;}}
if(oneChecked==false){alert('All questions must be answered in order for your application to be submitted.');return false;}
break;case 6:var val=$(sort+'-textInput').value;if(!$(sort+'QMtextInputOptional')){if(!val.length){alert('All questions must be answered in order for your application to be submitted.');return false;}}
var maxLen;if((maxLen=$(sort+'QMtextInputMaxLen'))!=null){maxLen=parseInt(maxLen.value);if((maxLen>0)&&(maxLen<val.length)){alert('QUESTION_TEXT_TOO_LONG');return false;}}
ret[sort].value=encodeRowForPost(val);break;}}
displayWait('Saving answers');var json=JSON.stringify(ret);json=encodeForPost(json);var resp=postAndWaitForResponse('/job/savespontanswers/','questions='+json);removeWait();if(resp!='1'){alert(resp);return false;}
return true;}
function updateCharsLeft(box,max)
{if(box.value.length>max){$(box.id+'_counter').style.color='red';}else{$(box.id+'_counter').style.color='black';}
$(box.id+'_counter').innerHTML=box.value.length+'/'+max;}
function getManualPositionAnswers()
{var ret=[];var sort=1;var qm=$('qm-1');for(;qm;qm=$('qm-'+(++sort))){var qmId=parseInt(qm.value);ret[sort]={'type':qmId};switch(qmId){case 1:if(!$(sort+'-yes').checked&&!$(sort+'-no').checked){alert('All questions must be answered in order for your application to be submitted.');return false;}
ret[sort].value=($(sort+'-yes').checked==true)?'yes':'no';break;case 2:var oneChecked=false;var osort=1;var qmOpt=$(sort+'-opt-'+osort);ret[sort].value=[];for(;qmOpt;qmOpt=$(sort+'-opt-'+(++osort))){if(qmOpt.checked==true){ret[sort].value[osort]=true;oneChecked=true;}else{ret[sort].value[osort]=false;}}
if(oneChecked==false){alert('All questions must be answered in order for your application to be submitted.');return false;}
break;case 6:ret[sort].value=encodeRowForPost($(sort+'-textInput').value);break;}}
if(ret.length==0){return-1;}
var json=JSON.stringify(ret);json=encodeForPost(json);return json;}
function updateProfileTag(id){var profileTags=document.getElementById('profileTags');if(profileTags.value!=''){displayWait('Saving');loadXMLDoc('/mess/tagprofile/id:'+id+'/folder:'+escape(profileTags.value)+'/',function(){if(req.readyState==4&&req.status==200){removeWait();var idx=profileTags.selectedIndex;if(profileTags.options[idx].innerHTML.substring(0,2)=='* '){profileTags.options[idx].innerHTML=profileTags.options[idx].innerHTML.substring(2);}else{profileTags.options[idx].innerHTML='* '+profileTags.options[idx].innerHTML;}}});}}
function searchUser(){var inn=document.getElementById('user-input');var request;if(window.XMLHttpRequest&&!(window.ActiveXObject)){try{request=new XMLHttpRequest();}catch(ex){request=false;}}else if(window.ActiveXObject){try{request=new ActiveXObject("Msxml2.XMLHTTP");}catch(ex){try{request=new ActiveXObject("Microsoft.XMLHTTP");}catch(ex){request=false;}}}
if(request){request.open('POST','/mnadmin/user/action:search/',false);request.setRequestHeader('Content-Type','application/x-www-form-urlencoded');request.send('search='+escape(inn.value));}
document.getElementById('user-result').innerHTML=unescape(request.responseText);return true;}
function adminManageUser(id){window.open('/mnadmin/user/action:manage/id:'+id+'/','adminManageUser'+id,'width=450,height=600,toolbar=0,resizable=0,status=0,menubar=0,scrolling=0');}
function adminAddCompanyUser(){window.open('/mnadmin/user/action:compuserform/','compuserform','width=450,height=600,toolbar=0,resizable=0,status=0,menubar=0,scrolling=0');}
function validateAndSubmit()
{var email=document.getElementById('email').value;var company=document.getElementById('company').value;var phone=document.getElementById('phone').value;var messg=document.getElementById('message').value;var name=document.getElementById('name').value;var subjectSelect=document.getElementById('subject');var subject=subjectSelect.options[subjectSelect.selectedIndex].value;if(name.length<1){alert('Name must be included');return;}
if(subject.length<1){alert('You have not chosen a subject.');return;}
if((phone.length<1)&&(email.length<1)){alert('You must give either an email or telephone number so you can be contacted');return;}
if(messg.length<1){alert('You must enter a message.');return;}
data='email='+htmlspecialchars(email);data+='&phone='+htmlspecialchars(phone);data+='&message='+encodeURIComponent(messg);data+='&subject='+encodeURIComponent(subject);data+='&company='+encodeURIComponent(company);data+='&name='+encodeURIComponent(name);var res=postAndWaitForResponse('/coremodule/contactmail/',data,true);if(res=='1'){document.getElementById('contact_form').reset();alert('Message is sent.');}else{alert(unescape(res));}}
function validateAndSubmitPopup()
{var email=document.getElementById('email').value;var phone=document.getElementById('phone').value;var messg=document.getElementById('message').value;var name=document.getElementById('name').value;var subject=document.getElementById('subject').value;if(name.length<1){alert('Name must be included');return;}
if(subject.length<1){alert('You have not chosen a subject.');return;}
if((phone.length<1)&&(email.length<1)){alert('You must give either an email or telephone number so you can be contacted');return;}
if(messg.length<1){alert('You must enter a message.');return;}
data='email='+htmlspecialchars(email);data+='&phone='+htmlspecialchars(phone);data+='&message='+htmlspecialchars(messg);data+='&subject='+htmlspecialchars(subject);data+='&company='+'';data+='&name='+htmlspecialchars(name);var res=postAndWaitForResponse('/coremodule/contactmail/',data,true);if(res=='1'){alert('Message is sent.');hideMessageBox();}else{alert(unescape(res));}}
function validateAndSubmitInterestForm()
{var name=document.getElementById('interestName').value;var company=document.getElementById('interestCompany').value;var email=document.getElementById('interestEmail').value;var phone=document.getElementById('interestPhone').value;var nrLicense=document.getElementById('interestNrLicense').value;var errorArray=new Array();var y=0;if(name.length<2){errorArray[y]='Name';y++;}
if(company.length<2){errorArray[y]='Company';y++;}
var regExp=/^[\.a-z0-9_-]+@[a-z0-9_-]+\.[a-z]+$/;if(email.length<5||!regExp.test(email)){errorArray[y]='E-mail';y++;}
if(phone.length<6){errorArray[y]='Telephone';y++;}
if(nrLicense.length<1){errorArray[y]='Number of licenses';y++;}
if(errorArray.length>0){var errorString="";for(i=0;i<y;i++){errorString+=errorArray[i];errorString+='\n'}
alert('The following information is required and must be filled in so that you can send in your application. Click on the links below in order to fill in the missing information. \n'+errorString);return;}
data='name='+htmlspecialchars(name);data+='&company='+htmlspecialchars(company);data+='&email='+htmlspecialchars(email);data+='&phone='+htmlspecialchars(phone);data+='&nrLicense='+htmlspecialchars(nrLicense);var res=postAndWaitForResponse('/coremodule/interestContact/',data,true);if(res=='1'){document.getElementById('interestForm').reset();alert('Thank you for your interest! Soon you will be contacted by MyNetwork with your requested price information.');}else{alert(unescape(res));}}
function setAccessLevel(company,state){displayWait('Saving');var response=postAndWaitForResponse('/mypage/acl/','company='+escape(company)+'&state='+escape(state),true);removeWait();if(parseInt(response)==1){document.getElementById('access-'+company).innerHTML='Access';}else{document.getElementById('access-'+company).innerHTML='No access';}}
function displayPDFDownload(id)
{window.open("/pdf/apdf/?uid="+id,"PDF","menubar=0,resizable=1,width=640,height=480");}
function displayProjectPDFDownload(id)
{window.open("/pdf/pdfp/?pid="+id,"PDF","menubar=0,resizable=1,width=640,height=480");}
function removeChoose(box){if(box.options[0].text.substr(0,2)=='[-'){box.remove(0);}}
function checkAccess(pk,action,where)
{var data=getResponseText('/center/checkAccess/pk:'+pk+'/action:'+escape(action)+'/where:'+escape(where)+'/');if(isNaN(data)==true){alert(data);}else if(parseInt(data)==1){return true;}
return false;}
function loadDocsForRecruitment()
{var data=postAndWaitForResponse('/center/loaddocuments/','');if(data==0){alert('Missing');return;}
data=JSON.parse(data);displayMessageBox(data);}
function downloadDocumentForRecruitment(doc,mime,cid)
{window.open('/center/downloadDocForRecruitment/doc:'+doc+'/mime:'+mime+'/cid:'+cid+'/','documentDownload','width=1,height=1,menubar=no,location=no,resizable=no,scrollbars=no,status=no');}
function printJob(id,forceSave,cv,lang)
{var module;if(forceSave==true){updateChanges();if(!checkForChangesAndSave()){return;}}
if(id==null||id==0){if($('job-id')){id=$('job-id').value;}else{var checked=getChecked('posToggles');if(checked.length==0){alert('You must select an alternative.');return;}
for(var cnt=0;cnt<checked.length;cnt++){id=checked[cnt];}}}
if(cv==true){module="cv";}else{module="center"}
var url='/'+module+'/generatead/id:'+id+'/';if(lang!=null){url+=('lang:'+lang+'/');}
window.open(url,'printpdf','left=50,top=50,width=1024,height=768,toolbar=0,resizable=1,status=0,menubar=0,scrollbars=1');}
function downloadPermanentUserCV(id,uid,type)
{window.open('/user/downloadpermanentusercv/id:'+id+'/uid:'+uid+'/type:'+type+'/','cvdownload_'+uid,'width=1,height=1,toolbar=0,resizable=0,status=0,menubar=0,scrolling=0');}
String.prototype.isInt=function()
{return!isNaN(this);};String.prototype.charCode=function()
{return String.fromCharCode(this);};String.prototype.stripWhiteSpace=function()
{return this.replace(/\s+/g,'');};String.prototype.htmlspecialchars=function(){var ret=this;ret=ret.replace(/&/g,'%26');ret=ret.replace(/"/g,'%22');ret=ret.replace(/\'/g,'%27');ret=ret.replace(/</g,'%3C');ret=ret.replace(/>/g,'%3E');return ret;};
var ttId=null;function __displayToolTip(parent,text,doNotDisplayIfHidden)
{var div=$('toolTipDiv');if((doNotDisplayIfHidden==true)&&div.style.display=='none'){return;}
if(!isIE()){div.style.display='table-cell';}else{if(isIE6()){div.style.position='absolute';}
div.style.display='block';}
var yPos=findPosY(parent);div.innerHTML=text;if(!isIE6()){yPos-=document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop;}
yPos-=div.offsetHeight;var leftPos=(findPosX(parent)+50);var topPos=yPos;if(isIE6()){leftPos=findPosX(parent);}else if(isIE7()){leftPos-=25;}
div.style.left=(leftPos+'px');div.style.top=(topPos+'px');}
function displayToolTip(parent,text)
{if(ttId!=null){return;}
ttId=setTimeout(function(){if(text.substr(0,1)=='!'){postAndCallback(text.substr(1),'',function(data){__displayToolTip(parent,data,true);});text='<img src="/Graphics/Img/Icons/loading.gif" />';}
__displayToolTip(parent,text);},100);}
function hideToolTip()
{var div=document.getElementById('toolTipDiv');div.style.display='none';if(ttId!=null){clearTimeout(ttId);}
ttId=null;}
function hideMessageBox()
{if($('youtubePlayer')){$('youtubePlayer').style.display='block';}
$('message-box-bg').style.display='none';$('message-box').style.display='none';}
function displayMessageBox(message)
{if((typeof message)=='object'){message=message.innerHTML;}
var scroll=document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop;$('message-box').style.top=((scroll+20)+'px');$('message-box').style.display='block';$('message-box-bg').style.display='block';$('message-box-text').innerHTML=message;}
function loadMessageBox(message,args)
{if(args==null){args='';}
if(message=="login"){if($('youtubePlayer')){$('youtubePlayer').style.display="none";}}
var txt=postAndWaitForResponse('/info/message/id:'+message+'/',args,true);displayMessageBox(txt);}
function loadSupportBox()
{var html=postAndWaitForResponse('/center/loadcompanysupport/');displayMessageBox(html);showCompanyAdmin();}
function showCompanyAdmin()
{var html=postAndWaitForResponse('/center/loadcompanysupportusers/');document.getElementById('contactCompanyAdminUsers').innerHTML=html;}
function loadHelpPage(hlp)
{var txt=getResponseText('/info/help/id:'+hlp+'/',true);displayMessageBox(txt);}
function displayWait(message,noShadow,loading){if(isIE6()==true){var wait=getElement('wait');wait.style.display='block';getElement('waitMessage').innerHTML=message;}else{var waitBg=getElement('wait-bg');var waitBox=getElement('wait-box');if(waitBg&&!noShadow){waitBg.style.display='block';}
var scroll=document.documentElement.scrollTop;waitBox.style.top=((scroll+20)+'px');waitBox.style.display='block';if(loading!=null){message='<div style="height: 50px;">'+'<div style="float: left; height: 50px;">'+'<img style="margin-left: 15px; margin-top: -7px" src="/Graphics/Img/Icons/loading.gif" />'+'</div>'+'<div style="margin-left: 15px; float: left; height: 10px;">'+
message+'</div></div>';}
getElement('waitMessage').innerHTML=message;}}
function removeWait(){setTimeout('disableWait()',250);}
function disableWait(){if(isIE6()==true){var wait=getElement('wait');wait.style.display='none';getElement('waitMessage').innerHTML='';}else{var waitBg=getElement('wait-bg');var waitBox=getElement('wait-box');if(waitBg){waitBg.style.display='none';}
waitBox.style.display='none';getElement('waitMessage').innerHTML='';}}
function displayHelppage(type)
{document.getElementById(type+'Container-Shadow').style.display='block';var data=document.getElementById(type+'Container-Data');if(document.all){document.getElementById(type+'Container-Shadow').style.width=document.documentElement.clientWidth;document.getElementById(type+'Container-Shadow').style.height=document.body.clientHeight;var scroll=document.body.scrollTop;data.style.left=(((parseInt(document.getElementById(type+'Container-Shadow').style.width)/2)-500)+'px');data.style.top=((scroll+100)+'px');}
data.style.display='block';if(document.all){var inputs=document.getElementsByTagName('select');for(var cnt=0;cnt<inputs.length;cnt++){inputs[cnt].style.display='none';}}}
function closeHelppage(type)
{document.getElementById(type+'Container-Shadow').style.display='none';document.getElementById(type+'Container-Data').style.display='none';if(document.all){var inputs=document.getElementsByTagName('select');for(var cnt=0;cnt<inputs.length;cnt++){inputs[cnt].style.display='block';}}
if(isIE()){if($('reloadUI')){displayWait('Loading');reloadUI();removeWait();}}}
function getSAPPURL(sappid)
{var sappURL='/job/applyforspontaneous/sappid:'+sappid+'/';return sappURL;}
function getSAPPPostData(sappid)
{var sappURL='';var currName=null;var currSapp=null;var inputs=document.getElementsByTagName('*');var dataArray=new Array();var ok=true;var oneChecked=false;var currBox;var sapps=new Array();for(var cnt=0;cnt<inputs.length;cnt++){if(!inputs[cnt].name||(inputs[cnt].name.length<8)||(inputs[cnt].name.substr(0,8)!='question')){continue;}
if(inputs[cnt].id=='selection'){continue;}
currBox=inputs[cnt];if(currName==null||currName!=inputs[cnt].name){if(dataArray.length>0){sappURL+=(('answer_'+currSapp)+'='+dataArray.join(',')+'&');dataArray.length=0;}
if(currName&&(currType==2)){if(oneChecked==false){ok=false;}
oneChecked=false;}
currName=inputs[cnt].name;currSapp=parseInt(inputs[cnt].name.substr(9));currType=(inputs[cnt].type=='textarea'?1:2);sapps[sapps.length]=currSapp+';'+currType;}
if(inputs[cnt].type=='radio'||inputs[cnt].type=='checkbox'){if(inputs[cnt].checked==false){dataArray[dataArray.length]=inputs[cnt].id+';0';}else{dataArray[dataArray.length]=inputs[cnt].id+';1';oneChecked=true;}}else{if(inputs[cnt].value.length==0){ok=false;}else{if(inputs[cnt].id!='selection'){var answerText=inputs[cnt].value;answerText=htmlspecialchars(answerText);answerText=answerText.replace(/,/g,'%COMMA%');answerText=answerText.replace(/;/g,'%SEMICOLON%');answerText=answerText.replace(/:/g,'%COLON%');sappURL+=(('answer_'+currSapp)+'='+inputs[cnt].id+';'+answerText+'&');}}}}
if(dataArray.length>0){if(currBox.type=='radio'||currBox.type=='checkbox'){if(oneChecked==false){ok=false;}}
sappURL+=(('answer_'+currSapp)+'='+dataArray.join(',')+'&');}
sappURL+=('questions='+sapps.join(','));if(ok==false){alert('You must answer all questions');return false;}
return sappURL;}
function relogin()
{var username=document.getElementById('email').value;var password=document.getElementById('pass').value;var dest=document.getElementById('DEST').value;var url='/coremodule/login/username:'+escape(username);url+='/password:'+hex_md5(password)+'/?nocandidate=1';displayWait('Trying to log in...');var response=postAndWaitForResponse(url,'',true);removeWait();if(response>=1&&response<=3){if(dest==''){if(response=='1'){document.location=baseUrl+'/cv/edit/'}else if(response=='2'){document.location=baseUrl+'/center/'}else if(response=='3'){document.location=baseUrl+'/mnadmin/'}}else{document.location=baseUrl+dest;}
document.getElementById('ERROR_BOX').style.display='none';}else{if(response=='-1'){var html=getResponseText('/info/message/id:companyCandidate/',true);displayMessageBox(html);$('tmp_pass').value=password;$('tmp_user').value=username;return;}else{document.getElementById('ERROR_MSG').innerHTML=unescape(response);document.getElementById('ERROR_BOX').style.display='block';}}
return;}
function login(applyToPosID,where,candidate,confirmcandidate)
{var password=document.getElementById('password').value;var username=document.getElementById('username').value;var keep=(document.getElementById('password-keep-yes').checked==true?'1':'0');if(password!=''){password=hex_md5(password);}
var args='username='+escape(username)+'&password='+password+'&keep='+escape(keep);if(applyToPosID!=null&&applyToPosID!=0){args+=('&apply='+applyToPosID);}
if(candidate){args+='&candidate=1';}
if(confirmcandidate){args+='&confirmcandidate=1';}
displayWait('Trying to log in...');var response=postAndWaitForResponse('/coremodule/login/',args,true);removeWait();if(applyToPosID!=null&&applyToPosID!=0){if(response!='1'){alert(response);}else{if(where!=null&&where!=0){document.location=baseUrl+'/job/apply/'+applyToPosID+'/'+where+'/';}else{document.location=baseUrl+'/job/apply/'+applyToPosID+'/';}}
return;}
var systemUpdate;if(response=='1'){systemUpdate=postAndWaitForResponse('/coremodule/systemUpdate/','');document.location=baseUrl+'/mypage/user/'+(systemUpdate=='0'?'':'update:1/');}else if(response=='2'){systemUpdate=postAndWaitForResponse('/coremodule/systemUpdate/','');document.location=baseUrl+'/center/'+(systemUpdate=='0'?'':'update:1/');}else if(response=='3'){document.location=baseUrl+'/mnadmin/';}else if(response=='4'){document.location=baseUrl+'/mnadmin/language/';}else{if(response=='-1'){var html=getResponseText('/info/message/id:companyCandidate/',true);displayMessageBox(html);$('tmp_pass').value=password;$('tmp_user').value=username;return;}else if(response.split(';').length==2){var data=response.split(';');if(data[0]=='apply'){document.location='/job/apply/'+data[1]+'/';}
return;}
alert(unescape(response));}}
function activateCompanyCandidate()
{hideMessageBox();login(null,null,true,true);}
function createNewUser(cid,pos,where,internal)
{var EMA=document.getElementById('EMA');var EMA2=document.getElementById('EMA2');var PA1=document.getElementById('PA1');var PA2=document.getElementById('PA2');var FOR=document.getElementById('FOR');var SUR=document.getElementById('SUR');var TUR=document.getElementById('TUR');var ACC=document.getElementById('ACC');if(EMA.value!=EMA2.value){alert('E-mail addresses do not match');return;}
if(PA1.value!=PA2.value){alert('The passwords do not match.');return;}
if(PA1.value.length<6){alert('Password is too short. It must have at least 6 characters!');return;}
var regExp=/^[\.a-z0-9_-]+@[\.a-z0-9_-]+\.[a-z]{1,4}$/;if(trim(EMA.value)==''||EMA.value.indexOf('@')==-1||EMA.value.indexOf('.')==-1||!regExp.test(EMA.value)){alert('Invalid E-mail address!');return;}
if(trim(FOR.value)==''){alert('First name is mandatory!');return;}
if(trim(SUR.value)==''){alert('Surname mandatory!');return;}
if(TUR&&trim(TUR.value)==''){alert('Write the verification code.');}
if(!ACC.checked){alert('You will have to accept all terms for this position!');return;}
url='/coremodule/register/action:createnewuser/';url+='PAS:'+hex_md5(PA1.value)+'/';url+='EMA:'+escape(EMA.value)+'/';url+='FOR:'+escape(FOR.value)+'/';url+='SUR:'+escape(SUR.value)+'/';if(TUR!=null){url+='TUR:'+escape(TUR.value)+'/';}
if(cid!=null){url+='cid:'+cid+'/';}
if(pos!=null){url+='pos:'+pos+'/';}
if(internal!=null){url+='internal:'+internal+'/';}
displayWait('Creating account');loadXMLDoc(url,function(){if(req.readyState==4&&req.status==200){removeWait();if(req.responseText!='1'&&req.responseText!='2'){if(req.responseText.split(';').length==2){var data=req.responseText.split(';');if(data[0]=='apply'){if(where!=0||where!=null){document.location=baseUrl+'/job/apply/'+data[1]+'/'+where+'/';return;}else{window.location='/job/apply:'+data[1]+'/';return;}}}
alert(unescape(req.responseText));}else{window.location='/cv/edit/page:11/';}}},true);}
function loginAndSA(sappid){var password=document.getElementById('password').value;var username=document.getElementById('username').value;var keep=(document.getElementById('password-keep-yes').checked==true?'1':'0');var args='username='+escape(username)+'&password='+hex_md5(password)+'&keep='+escape(keep);var sappURL=getSAPPURL(sappid);var sappDATA=getSAPPPostData(sappid);if(sappDATA==false){return;}
displayWait('Trying to log in...');var response=postAndWaitForResponse('/coremodule/login/',args,true);removeWait();if(response=='1'){document.location.href='/job/apply/'+sappid+'/spont:1/';return;}else if(response=='2'||response=='3'||response=='4'){alert('YOU_CANNOT_SEND_A_SPONTANEOUS_APPLICATION');}else{alert(unescape(response));}}
function createNewUserAndSA(cid,sappid)
{var EMA=document.getElementById('EMA');var EMA2=document.getElementById('EMA2');var PA1=document.getElementById('PA1');var PA2=document.getElementById('PA2');var FOR=document.getElementById('FOR');var SUR=document.getElementById('SUR');var TUR=document.getElementById('TUR');var ACC=document.getElementById('ACC');if(EMA.value!=EMA2.value){alert('<lang>EMAILS_DOES_NOT_MATCH");?>');return;}
if(PA1.value!=PA2.value){alert('The passwords do not match.');return;}
if(PA1.value.length<6){alert('Password is too short. It must have at least 6 characters!');return;}
if(trim(EMA.value)==''||EMA.value.indexOf('@')==-1||EMA.value.indexOf('.')==-1){alert('Invalid E-mail address!');return;}
if(trim(FOR.value)==''){alert('First name is mandatory!');return;}
if(trim(SUR.value)==''){alert('Surname mandatory!');return;}
if(TUR&&trim(TUR.value)==''){alert('Write the verification code.');}
if(!ACC.checked){alert('You will have to accept all terms for this position!');return;}
url='/coremodule/register/action:createnewuser/';url+='PAS:'+hex_md5(PA1.value)+'/';url+='EMA:'+escape(EMA.value)+'/';url+='FOR:'+escape(FOR.value)+'/';url+='SUR:'+escape(SUR.value)+'/';if(TUR!=null){url+='TUR:'+escape(TUR.value)+'/';}
if(cid!=null){url+='cid:'+cid+'/';}
var sappURL=getSAPPURL(sappid);var sappDATA=getSAPPPostData(sappid);if(sappDATA==false){return;}
displayWait('Creating account');loadXMLDoc(url,function(){if(req.readyState==4&&req.status==200){removeWait();if(req.responseText=='1'){document.location.href='/job/apply/'+sappid+'/spont:1/';}else{alert(req.responseText);}}},true);return;}
function approveMemberTerms(){if(document.getElementById('ACC')){document.getElementById('ACC').checked=true;}
hideMessageBox();}
