// Prohlizec info (1.0) - 8.4.08
var tmp = navigator.userAgent.toLowerCase();
browser = { 
  userAgent: tmp,
	version: (tmp.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/) || [])[1],
	webkit: /webkit/.test(tmp),
	opera: /opera/.test(tmp),
	msie: /msie/.test(tmp) && !/opera/.test(tmp),
	mozilla: /mozilla/.test(tmp) && !/(compatible|webkit)/.test(tmp),
	khtml: /khtml/.test(tmp),
	GET: getAssocGET()
};

function getAssocGET() { // 1.0
	var get=window.location.search.substr(1).split('&'), get_asoc=new Array(), i=0;
	if(get) {
		while(get[i]) {
			get[i]=get[i].split('=');
			get_asoc[get[i][0]]=unescape(get[i][1]);
			i++;
		}
		return get_asoc;
	}
	return new Array;
}

function makeRequest(url, params, method, func, funcParam) { // 1.0
	var httpRequest;
	if(window.XMLHttpRequest) { // w3c
		httpRequest = new XMLHttpRequest();
	} else if(window.ActiveXObject) { // ie
		try {
			httpRequest = new ActiveXObject('Msxml2.XMLHTTP');
		} catch(e) {
			try {
				httpRequest = new ActiveXObject('Microsoft.XMLHTTP');
			} catch(e) {}
		}
	}
	if(!httpRequest) return false;
	if(!method) method='GET';
	if(func) httpRequest.onreadystatechange = function() { func[0](httpRequest, func[1]); }
	httpRequest.open(method, url, true);
	httpRequest.send(params);
	if(!func) httpRequest.abort(); // only send request
}

function ajaxFillSelect(httpRequest, elSelect) { // 1.0 21.11.08
	if(httpRequest.readyState == 4 && httpRequest.status == 200 && httpRequest.responseText) {
		var elSelect = document.getElementById(elSelect), data = httpRequest.responseText.split(';;;');
		elSelect.length = 1;
		elSelect.selectedIndex = 0;
		for(var i=0, len=data.length, tmp; i<len; i++) {
			tmp = data[i].split(';;');
			elSelect.options[i +1] = new Option(tmp[0], tmp[1]);
		}
	}
}

function scrolbar(sBar_id, sBar_parent, contentDiv_id, bezecImgSrc, jumpPx, bigJumpPx, movePx) { // 1.3
	this.repaintBar=function() {
		barY=parseInt(barMaxY * (c.scrollTop / contentHeight)) + aHeight;
		bar.style.top=(barY > 0 ? barY : 0) + 'px';
		barY += getElemY(sBar);
	}
	this.jump=function(dir) {
		c.scrollTop=(dir ? c.scrollTop + jumpPx : c.scrollTop - jumpPx);
		this.repaintBar();
	}
	this.bigJump=function(e) {
		c.scrollTop=(getPageY(e) > barY ? c.scrollTop + bigJumpPx : c.scrollTop - bigJumpPx);
		this.repaintBar();
	}
	this.moveBar=function(e) {
		var e=getPageY(e);
		c.scrollTop=((lastMouseY && e > lastMouseY) ? c.scrollTop + movePx : c.scrollTop - movePx);
		lastMouseY=e;
		this.repaintBar();
	}
	this.mouseScroll=function(e) {
		if(!e) e=window.event;
		if(e.wheelDelta) {
			c.scrollTop=(e.wheelDelta < 0 ? c.scrollTop + bigJumpPx : c.scrollTop - bigJumpPx);
		} else if(e.detail) {
			c.scrollTop=(e.detail > 0 ? c.scrollTop + bigJumpPx : c.scrollTop - bigJumpPx);
		}
		this.repaintBar();
	}
	var c=document.getElementById(contentDiv_id);
	c.scrollTop=0;
	c.style.overflow='hidden';
	c.scrolbar=document.scrolbar=this;
	if(typeof(c.onmousewheel) == 'object') {
		c.onmousewheel=function(e) { stopEventBubble(e); this.scrolbar.mouseScroll(e); return false };
	} else if(window.addEventListener) {
		c.addEventListener((browser.opera ? 'mousewheel' : 'DOMMouseScroll'), function(e){stopEventBubble(e); this.scrolbar.mouseScroll(e)}, false); 
	}
	document.body.ondragstart=function() { return false };
	var sBar=document.createElement('DIV');
	sBar.id=sBar_id;
	sBar.scrolbar=this;
	sBar.onclick=function(e) { stopEventBubble(e); this.scrolbar.bigJump(e) };
	sBar.ondblclick=function(e) { stopEventBubble(e); this.scrolbar.bigJump(e)};
	if(typeof(sBar.onselectstart) == 'object') {
		sBar.onselectstart=function() {return false};
	}
	var a=document.createElement('A');
	a.scrolbar=this;
	a.style.top='0px';
	a.onclick=function(e) { stopEventBubble(e); this.scrolbar.jump() };
	a.ondblclick=function(e) { stopEventBubble(e); this.scrolbar.bigJump(e) };
	sBar.appendChild(a);
	a=document.createElement('A');
	a.scrolbar=this;
	a.style.bottom='0px';
	a.onclick=function(e) { stopEventBubble(e); this.scrolbar.jump(1) };
	a.ondblclick=function(e) { stopEventBubble(e); this.scrolbar.bigJump(e) };
	sBar.appendChild(a);
	var bar=document.createElement('IMG');
	bar.src=bezecImgSrc;
	bar.scrolbar=this;
	bar.onmousedown=function(e) {
		stopEventBubble(e);
		document.onmousemove=function(e) { stopEventBubble(e); this.scrolbar.moveBar(e)};
		document.onmouseup=function(e) { stopEventBubble(e); this.onmousemove=null; this.onmouseup=null};
	};
	sBar.appendChild(bar);
	document.getElementById(sBar_parent).appendChild(sBar);
	
	var aHeight=a.offsetHeight, barMaxY=sBar.offsetHeight - bar.offsetHeight - (2 * aHeight) -5, barY=getElemY(bar), contentHeight=c.scrollHeight - c.offsetHeight, lastMouseY=0;
	this.repaintBar();
}

function getElemY(elem) { // 1.0
	var top=0;
	if(elem.offsetParent) {
		while(elem.offsetParent) {
			top += elem.offsetTop;
			elem=elem.offsetParent;
		}
	}
	else { 
		top=elem.y;
	}
	return top;
}

function getPageY(e) { // 1.0
	if(!e) { e=window.event;}
	return posY=(e.pageY ? e.pageY : e.clientY + document.body.scrollTop);
}

function stopEventBubble(e) { // 1.1
	if(e) {
		e.stopPropagation();
		e.preventDefault();
	} else {
		window.event.cancelBubble=true;
		window.event.returnValue = false;
	}
}


// MF - Eweb
function menu_onoff(item)
{
    with (document.getElementById(item).style) {
        display = ((display == "none") ? "block" : "none");
        return true;
    }
    return false;
}

// onBlur="emailCheck(this, lang('Zadejte platný email!'));
// @require eregCheck
function emailCheck(field, alert_string)
{
    if (alert_string == "") { alert_string = "Zadejte e-mail."; }
	return eregCheck(alert_string, field, /^[^ @]+@[^ @]+\.[^ @]+$/);
}

function eregCheck(alert_string, field, regexp)
{
	if (field.value == '' || regexp.test(field.value)) {
		return true;
	} else {
        field.focus();
        alert(alert_string);
        return false;
    }
}

// return ulozitCheck(this.form, lang('Nejsou zadány povinné údaje, formulář nelze odeslat!'), 'col1', 'col2');
function ulozitCheck(f)
{
    if (arguments[1] == "") {
        alert_string = "Nejsou zadány povinné údaje,\n formulář nelze odeslat!";
    } else {
        alert_string = arguments[1];
    }
    for (i=2; i<arguments.length; i++) {
        if ((f[arguments[i]].tagName == 'SELECT' && !f[arguments[i]].selectedIndex) || !f[arguments[i]].value) {
            f[arguments[i]].focus();
            window.alert(alert_string);
            return false;
        }
    }
    return true;
}

