function apclass (name, Class) {
	var el=document.getElementById(name);
	if (!el) return false;
	el.className=Class;
	return true;
}
function apdisp (name, disp, allowfail) {
	allowfail = typeof(allowfail) != 'undefined' ? allowfail : true;
	var el=document.getElementById(name);
	if (!el && allowfail) return false;
	el.style.display=disp;
	return true;
}

function maxhfull (base) {
	//var creh=base_h();
	var creh=document.getElementById('maxh').offsetTop;
	var winh=parseInt(window.innerHeight);
	var tooh=winh-creh-base;
	//alert('creh:'+creh+' — winh:'+winh+' — base:'+base+' — tooh:'+tooh);
	apmaxheight('maxh',tooh);
}
function maxwfull (base) {
	var crew=base_w();
	var winw=parseInt(window.innerWidth);
	var toow=winw-crew-base-16;
	//alert('crew:'+crew+' — winw:'+winw+' — base:'+base+' — toow:'+toow);
	apmaxwidth('maxh',toow);
}
function apheight (id, height) {
	var el=document.getElementById(id);
	if (typeof(height)=='number') {
		el.style.height=height+'px';
	}
	else if (!el) {
		return null;
	}
	if (typeof(height)=='string') {
		return parseInt(el.clientHeight);
	}
	return parseInt(el.scrollHeight);
}
function apmaxheight (id, height) {
	var el=document.getElementById(id);
	el.style.maxHeight=height+'px';
}
function apwidth (id, width) {
	var el=document.getElementById(id);
	if (typeof(width)=='number') {
		el.style.width=width+'px';
	}
	else if (!el) {
		return null;
	}
	if (typeof(width)=='string') {
		return parseInt(el.clientWidth);
	}
	return parseInt(el.scrollWidth);
}
function apmaxwidth (id, width) {
	var el=document.getElementById(id);
	el.style.maxWidth=width+'px';
}

function button_hide (thing) {
	apdisp(thing,'none');
	apclass(thing+'_button','nbutton');
}
function button_show (thing) {
	button_none();
	apdisp(thing,'');
	apclass(thing+'_button','pbutton');
	location.href='#'+thing;
}

sac_done=0;
function sac () {
	if (sac_done) return;
	var el=document.getElementById('search_text');
	el.value='';
	sac_done=1;
}
