function get_element_by_id(id){return document.getElementById(id);}
function focus_item(id){if(id){var e=get_element_by_id(id)
e.focus();}}
function changecss(id,k,v){var e=get_element_by_id(id);e.style[k]=v;}

function set_spouse(){var id="div_spouse";var spouse_section=get_element_by_id(id);var dd=get_element_by_id("f1[statut_legal]");if(dd.selectedIndex==2||dd.selectedIndex==3)
changecss(id,'display','block');else
changecss(id,'display','none');}

function set_networth(){var id="div_networth";var networth_section=get_element_by_id(id);var nn=get_element_by_id("f1[business]");if(nn.selectedIndex==2)
changecss(id,'display','block');else
changecss(id,'display','none');}


function set_children(){var dd_kids=get_element_by_id("f1[enfants]");var span_kids_id="f1_enfants";if(dd_kids.selectedIndex==0||dd_kids.selectedIndex==1)
changecss(span_kids_id,'display','none');else
changecss(span_kids_id,'display','block');}
function set_dd_adapt(){set_dd_adaptability('f1');set_dd_adaptability('f2');}
function set_dd_adaptability(fx){if(fx=="f2"){var dd=get_element_by_id("f1[statut_legal]");if(dd.selectedIndex!=2&&dd.selectedIndex!=3){return true;}}
var id_links=fx+'[lien]';var id_span_links=fx+'_links';var id_studies=fx+'[sejour_etude_postsecondaire]';var id_studies_loc=fx+'_sejour_etude_postsecondaire_location';var id_employment=fx+'[sejour_emploi]';var id_employment_loc=fx+'_sejour_emploi_location';var id_other_visit=fx+'[sejour_autre]';var id_other_visit_loc=fx+'_autre_sejour_location';var sel_links=null;var sel_studies=null;var sel_employment=null;var sel_other_visit=null;var dd_links=get_element_by_id(id_links);var dd_studies=get_element_by_id(id_studies);var dd_employment=get_element_by_id(id_employment);var dd_other_visit=get_element_by_id(id_other_visit);if(dd_links.selectedIndex==0||dd_links.selectedIndex==1)
changecss(id_span_links,'display','none');else
changecss(id_span_links,'display','block');if(dd_studies.selectedIndex==0||dd_studies.selectedIndex==1)
changecss(id_studies_loc,'display','none');else
changecss(id_studies_loc,'display','block');if(dd_employment.selectedIndex==0||dd_employment.selectedIndex==1)
changecss(id_employment_loc,'display','none');else
changecss(id_employment_loc,'display','block');if(dd_other_visit.selectedIndex==0||dd_other_visit.selectedIndex==1)
changecss(id_other_visit_loc,'display','none');else
changecss(id_other_visit_loc,'display','block');}
function getcookie(cookiename){var cookiestring=""+document.cookie;var index1=cookiestring.indexOf(cookiename);if(index1==-1||cookiename=="")return "";var index2=cookiestring.indexOf(';',index1);if(index2==-1)index2=cookiestring.length;return unescape(cookiestring.substring(index1+cookiename.length+1,index2));}
function setcookie(name,value){cookiestring=name+"="+escape(value)+";EXPIRES=-1";document.cookie=cookiestring;if(!getcookie(name))
return false;else
return true;}
function open_window(url,name,my_width,my_height,other_options){var my_top=(screen.height-my_height)/2;var my_left=(screen.width-my_width)/2;new_window=window.open(url,name,'width='+my_width+',height='+my_height+',top='+my_top+',left='+my_left+', features='+other_options);new_window.focus();}
function MM_findObj(n,d){var p,i,x;if(!d)d=document;if((p=n.indexOf("?"))>0&&parent.frames.length){d=parent.frames[n.substring(p+1)].document;n=n.substring(0,p);}
if(!(x=d[n])&&d.all)x=d.all[n];for(i=0;!x&&i<d.forms.length;i++)x=d.forms[i][n];for(i=0;!x&&d.layers&&i<d.layers.length;i++)x=MM_findObj(n,d.layers[i].document);if(!x&&d.getElementById)x=d.getElementById(n);return x;}
function P7_autoLayers(){var g,b,k,f,args=P7_autoLayers.arguments;var a=parseInt(args[0]);if(isNaN(a))a=0;if(!document.p7setc){p7c=new Array();document.p7setc=true;for(var u=0;u<10;u++){p7c[u]=new Array();}}
for(k=0;k<p7c[a].length;k++){if((g=MM_findObj(p7c[a][k]))!=null){b=(document.layers)?g:g.style;b.visibility="hidden";}}
for(k=1;k<args.length;k++){if((g=MM_findObj(args[k]))!=null){b=(document.layers)?g:g.style;b.visibility="visible";f=false;for(j=0;j<p7c[a].length;j++){if(args[k]==p7c[a][j]){f=true;}}
if(!f){p7c[a][p7c[a].length++]=args[k];}}}}
function P7_Snap(){var x,y,ox,bx,oy,p,tx,a,b,k,d,da,e,el,args=P7_Snap.arguments;a=parseInt(a);for(k=0;k<(args.length-3);k+=4)
if((g=MM_findObj(args[k]))!=null){el=eval(MM_findObj(args[k+1]));a=parseInt(args[k+2]);b=parseInt(args[k+3]);x=0;y=0;ox=0;oy=0;p="";tx=1;da="document.all['"+args[k]+"']";if(document.getElementById){d="document.getElementsByName('"+args[k]+"')[0]";if(!eval(d)){d="document.getElementById('"+args[k]+"')";if(!eval(d)){d=da;}}}else if(document.all){d=da;}
if(document.all||document.getElementById){while(tx==1){p+=".offsetParent";if(eval(d+p)){x+=parseInt(eval(d+p+".offsetLeft"));y+=parseInt(eval(d+p+".offsetTop"));}else{tx=0;}}
ox=parseInt(g.offsetLeft);oy=parseInt(g.offsetTop);var tw=x+ox+y+oy;if(tw==0||(navigator.appVersion.indexOf("MSIE 4")>-1&&navigator.appVersion.indexOf("Mac")>-1)){ox=0;oy=0;if(g.style.left){x=parseInt(g.style.left);y=parseInt(g.style.top);}else{var w1=parseInt(el.style.width);bx=(a<0)?-5-w1:-10;a=(Math.abs(a)<1000)?0:a;b=(Math.abs(b)<1000)?0:b;x=document.body.scrollLeft+event.clientX+bx;y=document.body.scrollTop+event.clientY;}}}else if(document.layers){x=g.x;y=g.y;var q0=document.layers,dd="";for(var s=0;s<q0.length;s++){dd='document.'+q0[s].name;if(eval(dd+'.document.'+args[k])){x+=eval(dd+'.left');y+=eval(dd+'.top');break;}}}
if(el){e=(document.layers)?el:el.style;var xx=parseInt(x+ox+a),yy=parseInt(y+oy+b);if(navigator.appName=="Netscape"&&parseInt(navigator.appVersion)>4){xx+="px";yy+="px";}
if(navigator.appVersion.indexOf("MSIE 5")>-1&&navigator.appVersion.indexOf("Mac")>-1){xx+=parseInt(document.body.leftMargin);yy+=parseInt(document.body.topMargin);xx+="px";yy+="px";}e.left=xx;e.top=yy;}}}
function DropDownMenuX(id){this.type="horizontal";this.delay={"show":0,"hide":400}
this.position={"level1":{"top":0,"left":0},"levelX":{"top":0,"left":0}}
this.fixIeSelectBoxBug=true;this.zIndex={"visible":500,"hidden":-1};this.browser={"ie":Boolean(document.body.currentStyle),"ie5":(navigator.appVersion.indexOf("MSIE 5.5")!=-1||navigator.appVersion.indexOf("MSIE 5.0")!=-1),"ie6":(navigator.appVersion.indexOf("MSIE 6.0")!=-1)};if(!this.browser.ie){this.browser.ie5=false;this.browser.ie6=false;}
this.init=function(){if(!document.getElementById(this.id)){return alert("DropDownMenuX.init() failed. Element '"+this.id+"' does not exist.");}
if(this.type!="horizontal"&&this.type!="vertical"){return alert("DropDownMenuX.init() failed. Unknown menu type: '"+this.type+"'");}
if(this.browser.ie&&this.browser.ie5){fixWrap();}
fixSections();parse(document.getElementById(this.id).childNodes,this.tree,this.id);}
function fixSections(){var arr=document.getElementById(self.id).getElementsByTagName("div");var sections=new Array();var widths=new Array();for(var i=0;i<arr.length;i++){if(arr[i].className=="section"){sections.push(arr[i]);}}
for(var i=0;i<sections.length;i++){widths.push(getMaxWidth(sections[i].childNodes));}
for(var i=0;i<sections.length;i++){sections[i].style.width=(widths[i])+"px";}
if(self.browser.ie){for(var i=0;i<sections.length;i++){setMaxWidth(sections[i].childNodes,widths[i]);}}}
function fixWrap(){var elements=document.getElementById(self.id).getElementsByTagName("a");for(var i=0;i<elements.length;i++){if(/item2/.test(elements[i].className)){elements[i].innerHTML='<div nowrap="nowrap">'+elements[i].innerHTML+'</div>';}}}
function getMaxWidth(nodes){var maxWidth=0;for(var i=0;i<nodes.length;i++){if(nodes[i].nodeType!=1||/section/.test(nodes[i].className)){continue;}
if(nodes[i].offsetWidth>maxWidth){maxWidth=nodes[i].offsetWidth;}}
return maxWidth;}
function setMaxWidth(nodes,maxWidth){for(var i=0;i<nodes.length;i++){if(nodes[i].nodeType==1&&/item2/.test(nodes[i].className)&&nodes[i].currentStyle){if(self.browser.ie5){nodes[i].style.width=(maxWidth)+"px";}else{nodes[i].style.width=(maxWidth-parseInt(nodes[i].currentStyle.paddingLeft)-parseInt(nodes[i].currentStyle.paddingRight))+"px";}}}}
function parse(nodes,tree,id){for(var i=0;i<nodes.length;i++){if(1!=nodes[i].nodeType){continue;}
switch(true){case/\bitem1\b/.test(nodes[i].className):nodes[i].id=id+"-"+tree.length;tree.push(new Array());nodes[i].onmouseover=itemOver;nodes[i].onmouseout=itemOut;break;case/\bitem2\b/.test(nodes[i].className):nodes[i].id=id+"-"+tree.length;tree.push(new Array());nodes[i].onmouseover=itemOver;nodes[i].onmouseout=itemOut;break;case/\bsection\b/.test(nodes[i].className):nodes[i].id=id+"-"+(tree.length-1)+"-section";nodes[i].onmouseover=sectionOver;nodes[i].onmouseout=sectionOut;var box1=document.getElementById(id+"-"+(tree.length-1));var box2=document.getElementById(nodes[i].id);var el=new Element(box1.id);if(1==el.level){if("horizontal"==self.type){box2.style.top=box1.offsetTop+box1.offsetHeight+self.position.level1.top+"px";if(self.browser.ie5){box2.style.left=self.position.level1.left+"px";}else{box2.style.left=box1.offsetLeft+self.position.level1.left+"px";}}else if("vertical"==self.type){box2.style.top=box1.offsetTop+self.position.level1.top+"px";if(self.browser.ie5){box2.style.left=box1.offsetWidth+self.position.level1.left+"px";}else{box2.style.left=box1.offsetLeft+box1.offsetWidth+self.position.level1.left+"px";}}}else{box2.style.top=box1.offsetTop+self.position.levelX.top+"px";box2.style.left=box1.offsetLeft+box1.offsetWidth+self.position.levelX.left+"px";}
self.sections.push(nodes[i].id);self.sectionsShowCnt.push(0);self.sectionsHideCnt.push(0);if(self.fixIeSelectBoxBug&&self.browser.ie6){nodes[i].innerHTML=nodes[i].innerHTML+'<iframe id="'+nodes[i].id+'-iframe" src="javascript:false;" scrolling="no" frameborder="0" style="position: absolute; top: 0px; left: 0px; display: none; filter:alpha(opacity=0);"></iframe>';}
break;}
if(nodes[i].childNodes){if(/\bsection\b/.test(nodes[i].className)){parse(nodes[i].childNodes,tree[tree.length-1],id+"-"+(tree.length-1));}else{parse(nodes[i].childNodes,tree,id);}}}}
function itemOver(){self.itemShowCnt++;var id_section=this.id+"-section";if(self.visible.length){var el=new Element(self.visible.getLast());el=document.getElementById(el.getParent().id);if(/item\d-active/.test(el.className)){el.className=el.className.replace(/(item\d)-active/,"$1");}}
if(self.sections.contains(id_section)){clearTimers();self.sectionsHideCnt[self.sections.indexOf(id_section)]++;var cnt=self.sectionsShowCnt[self.sections.indexOf(id_section)];var timerId=setTimeout(function(a,b){return function(){self.showSection(a,b);}}(id_section,cnt),self.delay.show);self.timers.push(timerId);}else{if(self.visible.length){clearTimers();var timerId=setTimeout(function(a,b){return function(){self.showItem(a,b);}}(this.id,self.itemShowCnt),self.delay.show);self.timers.push(timerId);}}}
function itemOut(){self.itemShowCnt++;var id_section=this.id+"-section";if(self.sections.contains(id_section)){self.sectionsShowCnt[self.sections.indexOf(id_section)]++;if(self.visible.contains(id_section)){var cnt=self.sectionsHideCnt[self.sections.indexOf(id_section)];var timerId=setTimeout(function(a,b){return function(){self.hideSection(a,b);}}(id_section,cnt),self.delay.hide);self.timers.push(timerId);}}}
function sectionOver(){self.sectionsHideCnt[self.sections.indexOf(this.id)]++;var el=new Element(this.id);var parent=document.getElementById(el.getParent().id);if(!/item\d-active/.test(parent.className)){parent.className=parent.className.replace(/(item\d)/,"$1-active");}}
function sectionOut(){self.sectionsShowCnt[self.sections.indexOf(this.id)]++;var cnt=self.sectionsHideCnt[self.sections.indexOf(this.id)];var timerId=setTimeout(function(a,b){return function(){self.hideSection(a,b);}}(this.id,cnt),self.delay.hide);self.timers.push(timerId);}
this.showSection=function(id,cnt){if(typeof cnt!="undefined"){if(cnt!=this.sectionsShowCnt[this.sections.indexOf(id)]){return;}}
this.sectionsShowCnt[this.sections.indexOf(id)]++;if(this.visible.length){if(id==this.visible.getLast()){return;}
var el=new Element(id);var parents=el.getParentSections();for(var i=this.visible.length-1;i>=0;i--){if(parents.contains(this.visible[i])){break;}else{this.hideSection(this.visible[i]);}}}
var el=new Element(id);var parent=document.getElementById(el.getParent().id);if(!/item\d-active/.test(parent.className)){parent.className=parent.className.replace(/(item\d)/,"$1-active");}
if(document.all){document.getElementById(id).style.display="block";}
document.getElementById(id).style.visibility="visible";document.getElementById(id).style.zIndex=this.zIndex.visible;if(this.fixIeSelectBoxBug&&this.browser.ie6){var div=document.getElementById(id);var iframe=document.getElementById(id+"-iframe");iframe.style.width=div.offsetWidth+parseInt(div.currentStyle.borderLeftWidth)+parseInt(div.currentStyle.borderRightWidth);iframe.style.height=div.offsetHeight+parseInt(div.currentStyle.borderTopWidth)+parseInt(div.currentStyle.borderBottomWidth);iframe.style.top=-parseInt(div.currentStyle.borderTopWidth);iframe.style.left=-parseInt(div.currentStyle.borderLeftWidth);iframe.style.zIndex=div.style.zIndex-1;iframe.style.display="block";}
this.visible.push(id);}
this.showItem=function(id,cnt){if(typeof cnt!="undefined"){if(cnt!=this.itemShowCnt){return;}}
this.itemShowCnt++;if(this.visible.length){var el=new Element(id+"-section");var parents=el.getParentSections();for(var i=this.visible.length-1;i>=0;i--){if(parents.contains(this.visible[i])){break;}else{this.hideSection(this.visible[i]);}}}}
this.hideSection=function(id,cnt){if(typeof cnt!="undefined"){if(cnt!=this.sectionsHideCnt[this.sections.indexOf(id)]){return;}
if(id==this.visible.getLast()){for(var i=this.visible.length-1;i>=0;i--){this.hideSection(this.visible[i]);}
return;}}
var el=new Element(id);var parent=document.getElementById(el.getParent().id);if(/item\d-active/.test(parent.className)){parent.className=parent.className.replace(/(item\d)-active/,"$1");}
document.getElementById(id).style.zIndex=this.zIndex.hidden;document.getElementById(id).style.visibility="hidden";if(document.all){document.getElementById(id).style.display="none";}
if(this.fixIeSelectBoxBug&&this.browser.ie6){var iframe=document.getElementById(id+"-iframe");iframe.style.display="none";}
if(this.visible.contains(id)){if(id==this.visible.getLast()){this.visible.pop();}else{return;}}else{return;}
this.sectionsHideCnt[this.sections.indexOf(id)]++;}
function Element(id){this.menu=self;this.id=id;this.getLevel=function(){var s=this.id.substr(this.menu.id.length);return s.substrCount("-");}
this.getParent=function(){var s=this.id.substr(this.menu.id.length);var a=s.split("-");a.pop();return new Element(this.menu.id+a.join("-"));}
this.hasParent=function(){var s=this.id.substr(this.menu.id.length);var a=s.split("-");return a.length>2;}
this.hasChilds=function(){return Boolean(document.getElementById(this.id+"-section"));}
this.getParentSections=function(){var s=this.id.substr(this.menu.id.length);s=s.substr(0,s.length-"-section".length);var a=s.split("-");a.shift();a.pop();var s=this.menu.id;var parents=[];for(var i=0;i<a.length;i++){s+=("-"+a[i]);parents.push(s+"-section");}
return parents;}
this.level=this.getLevel();}
function clearTimers(){for(var i=self.timers.length-1;i>=0;i--){clearTimeout(self.timers[i]);self.timers.pop();}}
var self=this;this.id=id;this.tree=[];this.sections=[];this.sectionsShowCnt=[];this.sectionsHideCnt=[];this.itemShowCnt=0;this.timers=[];this.visible=[];}
if(typeof Array.prototype.indexOf=="undefined"){Array.prototype.indexOf=function(item){for(var i=0;i<this.length;i++){if(this[i]===item){return i;}}
return-1;}}
if(typeof Array.prototype.contains=="undefined"){Array.prototype.contains=function(s){for(var i=0;i<this.length;i++){if(this[i]===s){return true;}}
return false;}}
if(typeof String.prototype.substrCount=="undefined"){String.prototype.substrCount=function(s){return this.split(s).length-1;}}
if(typeof Array.prototype.getLast=="undefined"){Array.prototype.getLast=function(){return this[this.length-1];}}
if(!Array.prototype.pop){Array.prototype.pop=function(){var last;if(this.length){last=this[this.length-1];this.length-=1;}
return last;};}
if(!Array.prototype.push){Array.prototype.push=function(){for(var i=0;i<arguments.length;++i){this[this.length]=arguments[i];}
return this.length;};}
if(!Array.prototype.shift){Array.prototype.shift=function(){var first;if(this.length){first=this[0];for(var i=0;i<this.length-1;++i){this[i]=this[i+1];}
this.length-=1;}
return first;};}
if(!Array.prototype.unshift){Array.prototype.unshift=function(){if(arguments.length){var i,len=arguments.length;for(i=this.length+len-1;i>=len;--i){this[i]=this[i-len];}
for(i=0;i<len;++i){this[i]=arguments[i];}}
return this.length;};}
if(!Array.prototype.splice){Array.prototype.splice=function(index,howMany){var elements=[],removed=[],i;for(i=2;i<arguments.length;++i){elements.push(arguments[i]);}
for(i=index;(i<index+howMany)&&(i<this.length);++i){removed.push(this[i]);}
for(i=index+howMany;i<this.length;++i){this[i-howMany]=this[i];}
this.length-=removed.length;for(i=this.length+elements.length-1;i>=index+elements.length;--i){this[i]=this[i-elements.length];}
for(i=0;i<elements.length;++i){this[index+i]=elements[i];}
return removed;};}
