document.observe("dom:loaded", function(event) {
	var opened=Array();
	var current_car=null;
	var collapse_others=true;
	var duration=0.4;
	var busy=false;
	var current_career=null;
	var opened=Array();
	var current_car=null;
	var collapse_others=false;
	var duration=0.4;
	var busy=false;
	var current_career=null;
	var careers=$('career_holder').getElementsByClassName('the_career_top');
	for(var a=0;a<careers.length;a++){
		opened.push(careers[a].id);
		opened[careers[a].id]={status:0}; //0: closed; 1:opened
		
		Event.observe(careers[a].id,'click',function(){
			if (collapse_others){
				if (!busy){
					if (current_career!=this.id){
						busy=true;
						current_career=this.id;
						Effect.BlindDown(current_career+'_body',{afterFinish:function(){
											opened[current_career].status=1;
											$(current_career+'_title').className='the_career_top_title_selected';
											$(current_career+'_button').className='collapse_button';
											busy=false;
								}});

						for(var a=0;a<opened.length;a++){ /*closes opened careers*/
							if(opened[opened[a]].status){
								var idd=opened[a];
								Effect.BlindUp(idd+'_body',{afterFinish:function(){
													opened[idd].status=0;
													$(idd+'_title').className='the_career_top_title';
													$(idd+'_button').className='expand_button';
													busy=false;
											}});
							}
						}
					}
				}
			}
			else{
				if (!busy){
					id=this.id;
					busy=true;
					Effect.toggle(id+'_body','blind',{duration:duration,afterFinish:function(event){
									if (opened[id].status){
										opened[id].status=0;
										$(id+'_title').className='the_career_top_title';
										$(id+'_button').className='expand_button';
									}
									else{
										opened[id].status=1;
										$(id+'_title').className='the_career_top_title_selected';
										$(id+'_button').className='collapse_button';
									}
									busy=false;
								}});
				}
			}
		});
	}
});