function obj(id) {
	return document.getElementById(id);
}
function isUndefined(a) {
    return typeof a == "undefined";
}

function init() {
	menuTimer = setTimeout("hideMenu()", 2000);
	hideTab("r-login");
	hideTab("r-search");
}

var menuId = "r-menu";
var menuTimer;
function toggleMenu(over) {
	if (over) {
		clearTimeout(menuTimer);
		obj(menuId).className = "";
	} else {
		menuTimer = setTimeout("hideMenu()", 1000);
	}
}
function hideMenu() {
	obj(menuId).className += " hideMenu";
}

//var oldClass;
var activeId;
function toggleTab(id) {
	if (activeId != id) {
		if (activeId) hideTab(activeId);
		obj(id).className = obj(id).className.substring(0,obj(id).className.indexOf(" hideTab"));
		activeId = id;
	} else {
		hideTab(id);
	}
}
function hideTab(id) {
	obj(id).className += " hideTab";
	activeId = "";
}
function clearInput(o) {
	if (o.value == "Nick" || o.value == "Heslo") o.value = "";
}

/*var lastTab;
var tabTimer;
var focusObj;
var freeze = "";
function toggleTab(o,ovr) {
	clearTimeout(tabTimer);
	if (freeze == o.id) return;
	else unFreeze(freeze);
	if (ovr) {
		if (lastTab) hideTab(lastTab);
		o.className = o.className.substring(0,o.className.indexOf(" hideTab"));
	} else {
		tabTimer = setTimeout("hideTab('"+o.id+"')", 400);
	}
	lastTab = o.id;
}
function hideTab(id) {
	obj(id).className += " hideTab";
}
function clearInput(o) {
	if (o.value == "Nick" || o.value == "Heslo") o.value = "";
	focusObj = o;
	freeze = lastTab;
}
function unFreeze(id) {
	if (!freeze) return;
	freeze = "";
	focusObj.blur();
	toggleTab(obj(lastTab));
}*/

// Focus first item in last form
function focusForm() {
	var e = document.forms[document.forms.length-1].elements;
	for (var i=0; i<e.length; i++) {
		if (!isUndefined(e[i].type) && e[i].type != "hidden") {
			e[i].focus();
			break;
		}
	}
}

// open win
function openWin(path) {
	var w=707;
	var h=480;
	
  winLeft = (screen.width - w) / 2;
	winTop = (screen.height - h) / 2;
	winProp = 'menubar=no,resizable=yes,scrollbars=1,status=no,toolbar=no,locationbar=no,directories=no';
	winProp += ',width='+w+',height='+h+',left='+winLeft+',top='+winTop;
	Win = window.open(path,"mobileContent",winProp);
	Win.focus();
}

