function sf() {
	document.forms['f'].q.focus();
}

//implementacja mechanizmu zmiany kategorii

function change_cat(id, deactivate) {
	if(deactivate) {
		document.getElementById(activeCat).className = "cat_inactive";
	}
	document.getElementById(id).className = "cat_active";
	activeCat = id;
	//ustawienie zmiennej dla formularza
	document.forms['f'].c.value = id.substr(4);
}

function moreChoose(id, name) {
	if(typeof(activeCat) != 'undefined') {
		document.getElementById(activeCat).className = "cat_inactive";
	}
	document.getElementById(lastId).id = id;
	document.getElementById(id).innerHTML = name;
	document.getElementById(id).attributes["onclick"].value = "change_cat('" + id + "', 1);";
	lastId = id;
	change_cat(id, 0);
}

function checkMoreClick(e) {
	var target = (e && e.target) || (event && event.srcElement); 
	var obj = document.getElementById('cats_more'); 
	var obj2 = document.getElementById('more_click'); 
	checkParent(target)?obj.style.display='none':null; 
	target==obj2?obj.style.display='block':null;
}

function checkParent(t) { 
	while(t.parentNode) { 
		if(t == document.getElementById('cats_more')) { 
			return true;
		}
		t = t.parentNode;
	} 
	return true 
} 

function resizeWindow(page) {
	var y;
	var x;
	if (self.innerHeight) // all except Explorer
	{
		y = self.innerHeight;
		x = self.innerWidth;
	}
	else if(document.documentElement && document.documentElement.clientHeight) // Explorer 6 Strict Mode
	{
		y = document.documentElement.clientHeight;
		x = document.documentElement.clientWidth;
	}
	else if(document.body) // other Explorers
	{
		y = document.body.clientHeight;
		x = document.body.clientWidth;
	}
	if(page == "search") {
		document.getElementById("main").height = y - 25;
		clipWidth = x - 124;
		//document.getElementById("stabs").style.width = clipWidth + "px";
		document.getElementById("stabs").style.clip = "rect(0px," + (-1 * position + clipWidth) + "px,25px," + (-1 * position) + "px)";
	}
}

//glowna funkcja reSeeka

function reseekClick() {
	var reseekPanel = document.getElementById('reseek_panel');
	if(reseekPanel.style.display == "none") {
		reseekPanel.style.display = "block";
	} else {
		reseekPanel.style.display = "none";
	}
}

function moveStabs(direction, speed) {
	st = document.getElementById("stabs");
	if(direction) {
		if(position + st.offsetWidth > clipWidth) {
			st.style.marginLeft = position - speed + "px";
			position -= speed;
			st.style.clip = "rect(0px," + (-1 * position + clipWidth) + "px,25px," + (-1 * position) + "px)";
		}
	} else {
		if(position < 0) {
			st.style.marginLeft = position + speed + "px";
			position += speed;
			st.style.clip = "rect(0px," + (-1 * position + clipWidth) + "px,25px," + (-1 * position) + "px)";
		}
	}
}
