
function trim(str) {
	if (str) {
  	return str.replace(/^\s*|\s*$/g,"");
  } else {
  	return '';
  }
} 

function swapPas(aObj, state) {
  aObj.style.backgroundImage = 'slices/menuPas' + (state === 1 ? 'Over' : '') + '.png';
}

/* DSCROLL */

dScrollTimer = false;

function dScrollMove() {
	var d = document.getElementById('dContents');
	var dt = parseInt(d.style.top);
	if (!dt || dt == 'NaN') {dt = 0;}
	if (dScrollDirect < 0 && d.scrollHeight + dt < 0) {
		dt = 500;
	}
	if (dScrollDirect > 0 && dt > 270) {
		dScrollClassic();
		return;
	}
	d.style.top = dt + dScrollDirect + 'px';
	//dScrollTimer = setTimeout(dScrollMove, 20);
}

function dScrollClassic() {
	dScrollDirect = -1;
	//dScrollStop();
	//dScrollTimer = setTimeout(dScrollMove, 20);
}

function dScrollUp() {
	dScrollDirect = -5;
	//dScrollStop();
	//dScrollTimer = setTimeout(dScrollMove, 20);
}

function dScrollDown() {
	dScrollDirect = 5;
	//dScrollStop();
	//dScrollTimer = setTimeout(dScrollMove, 20);
}

function dScrollStop() {
	//if (dScrollTimer) {clearTimeout(dScrollTimer);}
}

/* konec DSCROLL */

function thisOnLoad() {
	if (document.getElementById('dContents')) {
  	dScrollDirect = -1 ;
	  setInterval(dScrollMove, 40);
		//dScrollClassic();
	}
}

function changeState(room, day, dow) {
  prevState = document.getElementById('i-' + room + '-' + day).value;
  newState = (prevState + 1) % 3;
  document.getElementById('i-' + room + '-' + day).value = newState;
  document.getElementById('t-' + room + '-' + day).className = 'state' + newState + dow;
}



