function f_menu(height,original,color) {
	height=f_var(height,'N');
	original=f_var(original,'S');
	color=f_var(color,'O');
	if ((!height) || (!original) || (!color)) { return; }



	var menu=document.getElementById('menu');
	var submenu=document.getElementById('submenu');
	if ((!menu) || (!menu['children'].length) || (!submenu) || (!submenu['children'].length)) { return; }



	var current=-1;
	var x=0;
	var suboption;



	for (var i=0; i<menu['children'].length; i++) {
		if (!menu['children'][i]['href']) { continue; }



		if (!menu['children'][i]['id']) { menu['children'][i]['id']=f_unique(); }
		menu['children'][i]['~index']=i;
		menu['children'][i]['~change']=color[i];
		if (menu['children'][i]['className']=='current') { current=i; }
		menu['children'][i]['onmouseover']=function() { f_navigate(this['~index'],height,original); }
	}



	if (current==-1) {
		current=0;
		var section=0;



		for (i=0; i<submenu['children'].length; i++) {
			if (!submenu['children'][i]['href']) { section++; }
			else if (submenu['children'][i]['className']=='current') { current=section; break; }
		}
	}



	for (i=0; i<menu['children'].length; i++) {
		menu['children'][i]['onmouseout']=function() {
			menu['~f_navigate']=setTimeout('f_navigate('+current+','+height+',\''+original+'\')',1000);
		}
	}



	f_navigate(current,height,original);



	submenu['onmouseover']=function() { clearTimeout(menu['~f_navigate']); }
	submenu['onmouseout']=function() { menu['~f_navigate']=setTimeout('f_navigate('+current+','+height+',\''+original+'\')',1000); }
}



function f_navigate(index,height,original) {
	index=f_var(index,'N');
	height=f_var(height,'N');
	original=f_var(original,'S');
	if ((!height) || (!original)) { return; }



	var menu=document.getElementById('menu');
	if ((!menu) || (!menu['children'].length)) { return; }



	clearTimeout(menu['~f_navigate']);
	var add=0;



	for (var i=0; i<menu['children'].length; i++) {
		if (i!=index) { f_morph(menu['children'][i]['id'],{'~background_b':original,'background':original}); continue; }



		add=(f_navigator()=='Internet Explorer')?i*1:0;
		f_morph(menu['children'][i]['id'],{'~background_b':original,'background':menu['children'][i]['~change']});
		f_morph('submenu',{'vscroll':i*height+add,'~vscroll_w':true,'~background_b':original,'background':menu['children'][i]['~change']});
	}
}



function f_tabular(id,original,over) {
	id=f_var(id,'S');
	original=f_var(original,'S');
	over=f_var(over,'S');
	if ((!id) || (!original) || (!over)) { return; }



	var object=document.getElementById(id);
	if ((!object) || (!object['children'].length) || (object['className']!='tab')) { return; }



	object['innerHTML']=object['innerHTML'].replace(/[\r\n	]/g,'');



	for (var i=0; i<object['children'].length; i++) {
		if (!object['children'][i]['id']) { object['children'][i]['id']=f_unique(); }
		if (object['children'][i]['onclick']) { object['children'][i]['~action']=object['children'][i]['onclick']; }



		if (object['children'][i]['className']!='current') { object['children'][i]['style']['backgroundColor']=original; }



		object['children'][i]['onmouseover']=function() {
			if (this['className']=='current') { return; }
			f_morph(this['id'],{'~background_b':original,'background':over});
		}
		object['children'][i]['onmouseout']=function() {
			if (this['className']=='current') { return; }
			f_morph(this['id'],{'background':original});
		}
		object['children'][i]['onclick']=function() {
			if (this['className']=='current') { return; }
			f_tab(this,original);
			if (this['~action']) { this['~action'].call(); }
		}
	}
}



function f_tab(button,original) {
	button=f_var(button,'O');
	original=f_var(original,'S');
	if ((!button) || (button['className']=='current') || (!original)) { return; }



	var object=button['parentNode'];
	if (!object) { return; }



	for (var i=0; i<object['children'].length; i++) {
		if (object['children'][i]['className']!='current') { continue; }



		object['children'][i]['className']='';
		object['children'][i]['style']['backgroundColor']=original;
		object['children'][i]['_BACKGROUND']=original;
		break;
	}



	clearTimeout(button['~f_morph']);
	button['className']='current';
	button['style']['backgroundColor']='';
}



function f_field(input,caption,$out) {
	input=f_var(input,'O');
	caption=f_var(caption,'S');
	if ((!input) || (!caption)) { return; }



	if ($out) {
		if (!input['value']) { input['value']=caption; }
	}
	else if (input['value']==caption) { input['value']=''; }
}



function f_button(id,original,over) {
	id=f_var(id,'S');
	original=f_var(original,'S');
	over=f_var(over,'S');
	if ((!id) || (!original) || (!over)) { return; }



	var object=document.getElementById(id);
	if ((!object) || (object['className']!='button')) { return; }



	object['onmouseover']=function() { f_morph(this['id'],{'~background_b':original,'background':over}); }
	object['onmouseout']=function() { f_morph(this['id'],{'background':original}); }
}



function f_submit(form) {
	form=f_var(form,'O');
	if (!form) { return false; }



	var name='';
	var required='';
	for (var i=0; i<form['elements'].length; i++) {
		name=form['elements'][i]['name'];
		if (!name) { continue; }



		form['elements'][i]['value']=f_trim(form['elements'][i]['value']);



		if ((!form['elements'][i]['value']) || (form['elements'][i]['value']==name)) {
			required=(required)?required+', '+name:name;
			form['elements'][i]['value']=name;
		}
	}



	if (required) {
		if (required.indexOf(',')!=-1) { alert('Câmpurile '+required+' sunt obligatorii.'); }
		else { alert('Câmpul '+required+' e obligatoriu.'); }
		return false;
	}
	return true;
}



function f_repmenu(height,original,color) {
	height=f_var(height,'N');
	original=f_var(original,'S');
	color=f_var(color,'O');
	if ((!height) || (!original) || (!color)) { return; }



	var menu=document.getElementById('menu');
	if ((!menu) || (!menu['children'].length)) { return; }



	var current=-1;
	for (var i=0; i<menu['children'].length; i++) {
		if (!menu['children'][i]['href']) { continue; }



		if (!menu['children'][i]['id']) { menu['children'][i]['id']=f_unique(); }
		menu['children'][i]['~index']=i;
		menu['children'][i]['~change']=color[i];
		if (menu['children'][i]['className']=='current') { current=i; }
		menu['children'][i]['onmouseover']=function() { f_repnavigate(this['~index'],height,original); }
	}



	for (i=0; i<menu['children'].length; i++) {
		menu['children'][i]['onmouseout']=function() {
			menu['~f_repnavigate']=setTimeout('f_repnavigate('+current+','+height+',\''+original+'\')',1000);
		}
	}



	f_repnavigate(current,height,original);
}



function f_repnavigate(index,height,original) {
	index=f_var(index,'N');
	height=f_var(height,'N');
	original=f_var(original,'S');
	if ((!height) || (!original)) { return; }



	var menu=document.getElementById('menu');
	if ((!menu) || (!menu['children'].length)) { return; }



	clearTimeout(menu['~f_repnavigate']);
	for (var i=0; i<menu['children'].length; i++) {
		if (i!=index) { f_morph(menu['children'][i]['id'],{'~background_b':original,'background':original}); continue; }
		f_morph(menu['children'][i]['id'],{'~background_b':original,'background':menu['children'][i]['~change']});
	}
}
