function openclose() {
	if (page_open_status == 1) {
		if (animation_ready) {
			$('bgcontent').className='bgcontent';
			get_msg_once();
	        userpanel_out_oc();
			for (i=1;i<=6;i++) {
				rnd=Math.floor(Math.random( ) * 900 - 200 + 1) + 200;
				menu_out_oc('menu'+i,rnd,-110);
			}	
			page_open_status = 0;
			$('dynmsg').scrollTop = $('dynmsg').scrollHeight;
			if ($('text_new_msg')) $('text_new_msg').focus();
		}
	} else {
		if (animation_ready) {
			$('kinyito').className='rejtett';		
			float_in_oc();
			setTimeout('menu_start_oc()',100);
			page_open_status = 1;
			window.scroll(0,0);
			start.setTime(time.getTime());
		}
	}
}

function menu_start_oc() {
		for (i=1;i<=6;i++) {
			rnd=Math.floor(Math.random( ) * 900 - 200 + 1) + 200;
			document.getElementById('menu'+i).style['left'] = rnd+'px';
		}
		menu_in_oc('menu1',699-15,10+10);
		menu_in_oc('menu2',704-15,47+10);
		menu_in_oc('menu3',698-15,84+10);
		menu_in_oc('menu4',703-15,121+10);
		menu_in_oc('menu5',696-15,158+10);
		menu_in_oc('menu6',702-15,195+10);
}

function menu_in_oc(menu,x,y) {
	menux=document.getElementById(menu).offsetLeft;
	menuy=document.getElementById(menu).offsetTop;
	px=(x-menux)/3;
	py=(y-menuy)/3+0.1;
	if (Math.abs(menuy-y)>5) {
		animation_ready=0;
		menux+=px;
		menuy+=py;
		document.getElementById(menu).style['top'] = menuy+'px';
		document.getElementById(menu).style['left'] = menux+'px';
		if (animation_allow_in) setTimeout('menu_in_oc("'+menu+'",'+x+','+y+')',10);
	} else if (menu == 'menu1') {
        animation_ready=1;
	}
}

function menu_out_oc(menu,x,y) {
	menux=document.getElementById(menu).offsetLeft;
	menuy=document.getElementById(menu).offsetTop;
	px=(x-menux)/3;
	py=(y-menuy)/3+0.1;
	if (menuy>y+10) {
		animation_ready=0;
		menux+=px;
		menuy+=py;
		document.getElementById(menu).style['top'] = menuy+'px';
		document.getElementById(menu).style['left'] = menux+'px';
		setTimeout('menu_out_oc("'+menu+'",'+x+','+y+')',10);
	} else if (menu == 'menu1') {
		animation_ready=1;
	}
}

function float_in_oc() {
	var float_x=document.getElementById('container').offsetLeft;
	p=(0-float_x)/3+1;
	if (float_x<0) {
		animation_ready=0;
		float_x+=p;
		document.getElementById('container').style['left'] = float_x+'px';
		if (animation_allow_in) setTimeout('float_in_oc()',1);
		if (float_x>-200) $('bgcontent').className='rejtett';
	} else {
        userpanel_start_oc();
	}
}

function userpanel_start_oc() {
	document.getElementById('userpanel').style['left'] = '500px';
	userpanel_in_oc();
}

function userpanel_in_oc() {
	panelx=document.getElementById('userpanel').offsetLeft;
	p=(800-panelx)/2+1;
	if (panelx<800) {
		animation_ready=0;
		panelx+=p;
		document.getElementById('userpanel').style['left'] = panelx+'px';
		if (animation_allow_in) setTimeout('userpanel_in_oc()',10);
	} else {
		animationready();
	}
}

function userpanel_out_oc() {
	panelx=document.getElementById('userpanel').offsetLeft;
	p=(500-panelx)/2;
	if (panelx>550) {
		animation_ready=0;
		panelx+=p;
		document.getElementById('userpanel').style['left'] = panelx+'px';
		setTimeout('userpanel_out_oc()',10);
	} else {
		document.getElementById('userpanel').style['left'] = '-400px';
		float_out_oc();
	}
}

function float_out_oc() {
	var float_x=document.getElementById('container').offsetLeft;
	p=(-800-float_x)/3+1;
	if (float_x>-790) {
		float_x+=p;
		document.getElementById('container').style['left'] = float_x+'px';
		setTimeout('float_out_oc()',1);
	} else {
		animation_ready=1;
		$('kinyito').className='kinyito_active';		
	}
}
