﻿// http://portal.mpsv.cz/pls/portal/okprace_web.purl.sScriptPage_URL

function vratdef(par){
	if ( par == "lokal_home" ) { return surlchk("http://portal.mpsv.cz/kiosek"); }
	if ( par == "lokal_tout" ) { return "60"; }
	if ( par == "lokal_toutadd" ) { return "5"; }
	return "";
}
function nactipar(par){
	var cookieList=document.cookie.split("; ");
	for (var i=0; i < cookieList.length; i++){
		var poz = cookieList[i].indexOf("=");
		var nam = cookieList[i].substring( 0, poz );
		if ( unescape(nam) == par ) {
			var str = unescape( cookieList[i].substring( poz + 1, cookieList[i].length ) );
			if ( par == "lokal_home" && str == "/" ) { return vratdef(par); }
			if (str != "" && str != "undefined") {	return str; } else { return vratdef(par); }
		}
	}
	return vratdef(par);
}
function xbprihlasen(){
	if ( nactipar("ok_login") == "1" ) {
		return true;
	} else {
		return false;
	}
}
function surlchk(surl_){
	var surl;
	surl = surl_.toLowerCase();
	if ( surl.substr( 0, 22 ) == "http://portal.mpsv.cz/" ) {
		if ( xbprihlasen() ) {
			return "https://portal.mpsv.cz/" + surl_.substr( 22 );
		} else {
			return "http://portal.mpsv.cz/" + surl_.substr( 22 );
		}
	}
	if ( surl.substr( 0, 23 ) == "https://portal.mpsv.cz/" ) {
		if ( xbprihlasen() ) {
			return "https://portal.mpsv.cz/" + surl_.substr( 23 );
		} else {
			return "http://portal.mpsv.cz/" + surl_.substr( 23 );
		}
	}
	return surl_;
}
function blokujKiosLink() {
	if (nactipar("kiosek")==1) {
		var x = document.links.length;
		if (x) {
			for (var i=0; i<x; i++) {
				var y = document.links[i]+"";
				if (y.search("mailto:") !=-1) {
					document.links[i].href="JavaScript:";
					document.links[i].style.textDecoration="none";
					document.links[i].style.cursor="default";
				}
				if (document.links[i].target!=null && document.links[i].target!="") {document.links[i].target="_top";}
			}
		}
	}
}
var aktuDat=new Date();
function zobrazPosledniLink() {
	if (document.location.href.indexOf("_mode=16")>0) {
		document.links[document.links.length-1].parentNode.parentNode.style.display="inline";
	}
}
function zobrazStatistiku(url) {
	document.write ('<img src="/portalssz/webstat/counter.do?name='+url+'&amp;ref='+escape(document.referrer)+'&amp;sw='+escape(window.screen.width)+'&amp;sh='+escape(window.screen.height)+'&amp;cd='+escape(window.screen.colorDepth)+'&amp;ce=' + (navigator.cookieEnabled ? '1' : '2') + '" width="1" height="1" border="0" alt="www Statistika">');
}
function zalOver(o,b) { o.parentNode.style.borderTopColor="#"+b;}
function zalOut(o) {o.parentNode.style.borderTopColor="#8A8A8A";}
function nastavAzCookie(z) {
	if (nactipar("kiosek")=="1") {
		document.cookie='a_z=; path=/;';
		document.cookie='a_z='+z+'; path=/;';
	}
}
function linkKiosekCss() {
	if (nactipar('kiosek')==1) {
		var ElCSS=document.createElement("LINK");
		ElCSS.rel="stylesheet";
		ElCSS.type="text/css";
		ElCSS.href="/images/okstyl/ok_kiosek.css";
		document.documentElement.firstChild.appendChild(ElCSS);
	}
}
function show_context_help(h) { 
    newWindow = window.open(h,"Help", "menubar=0,toolbar=0,scrollbars=1,resizable=1,width=700, height=500"); 
}
function zapisOKlang() {
	var x=nactipar("portal");
	var i1=x.indexOf("+");
	var i2=x.indexOf("+", i1 + 1);
	document.cookie='ok_lang='+x.substring( i1 + 1, i2 )+'; path=/;';
}
