
function loadscript(url) {

	var head=document.getElementsByTagName('head').item(0);
	var old=document.getElementById('xlast_id');
	if (old)head.removeChild(old);
	script=document.createElement('script');
	script.src=url;
	script.type='text/javascript';
	script.defer=true;
	script.id='xlast_id'
	void(head.appendChild(script));
	}


function setfoto(foto,fx,fy) {

	try {

		var fid=document.getElementById('nfoto');

		fid.width=fx;
		fid.height=fy;
		fid.src='/_data/foto/'+foto+'x1.jpg';
		}
	catch (e) {

		}
	}

function openfoto(foto) {

	try {

		window.open('/_pub/clscripts/foto.php?foto='+escape(foto.replace(/x1/g,'x2')),'','scrollbars=yes,width=840,height=630');
		}
	catch (e) {

		}
	}


var lastparam=0;

function parametry_kat(idkat) {

	var head=document.getElementsByTagName('head').item(0);
	var old=document.getElementById('last_id');
	if (old)head.removeChild(old);
	script=document.createElement('script');
	script.src='/_clscripts/parametry.php?s=kat&idkat='+idkat;
	script.type='text/javascript';
	script.defer=true;
	script.id='last_id'
	void(head.appendChild(script));
	}

function parametry_predn_zobraz(id) {

	try {

		document.getElementById('predn_'+lastparam).style.visibility='hidden';
		}
	catch (e) {

		}

	if (lastparam==id) {

		lastparam=0;
		}
	else {
	
		document.getElementById('predn_'+id).style.visibility='visible';
		lastparam=id;
		}
	}

function parametry_anone_zobraz(id) {

	try {

		document.getElementById('anone_'+lastparam).style.visibility='hidden';
		}
	catch (e) {

		}

	if (lastparam==id) {

		lastparam=0;
		}
	else {
	
		document.getElementById('anone_'+id).style.visibility='visible';
		lastparam=id;
		}
	}

function parametry_predn_schovej(id) {

	try { 
		document.getElementById('predn_'+id).style.visibility='hidden';
		}
	catch (e) { }

	try {
		document.getElementById('predn_'+lastparam).style.visibility='hidden';
		}
	catch (e) {	}


	try {
		document.getElementById('anone_'+lastparam).style.visibility='hidden';
		}
	catch (e) {	}

	}

function parametry_predn_set(id,hodnota,ano) {

	try {
	
		if (ano==1) {

			document.getElementById('butanone_'+id).value='ANO';
			document.getElementById('param_ano_'+id).value=1;
			}
		else {

			document.getElementById('butanone_'+id).value='N/A';
			document.getElementById('param_ano_'+id).value=-1;
			}
		}
	catch(e) {

		}
	
	document.getElementById('p_'+id).value=hodnota;
	
	document.getElementById('predn_'+id).style.visibility='hidden';
	lastparam=0;
	}

function parametry_anone_set(id,hodnota) {

	switch(hodnota) {

	case "-1":

		document.getElementById('butanone_'+id).value='N/A';
		document.getElementById('param_ano_'+id).value=-1;

	break;
	case "0":

		document.getElementById('butanone_'+id).value='NE';
		document.getElementById('param_ano_'+id).value=0;

	break;
	case "1":

		document.getElementById('butanone_'+id).value='ANO';
		document.getElementById('param_ano_'+id).value=1;

	break;
		}

	document.getElementById('anone_'+id).style.visibility='hidden';
	lastparam=0;
	}

function parametry_hodnota_checkano(hodnota,id) {
/*	if (hodnota.length==0) {

		document.getElementById('butanone_'+id).value='N/A';
		document.getElementById('param_ano_'+id).value=-1;
		}
	else {

*/

	try {

		if (hodnota.length>0 && document.getElementById('param_ano_'+id).value==-1) {
			document.getElementById('butanone_'+id).value='ANO';
			document.getElementById('param_ano_'+id).value=1;
			}
		}
	catch(e) {

		}

	}

function vlozjsemail(str) {

	str=str.replace(/\|/g,'.');
	str=str.replace(/\{/g,'c');
	str=str.replace(/;/g,'z');
	str=str.replace(/:/g,'a');
	str=str.replace(/>/g,'i');
	str=str.replace(/\}/g,'o');
	str=str.replace(/a1#a93z9/g,'@');

	document.write(str);
	}


function odkazopen(url) {

	try {

		window.open(url,'');
		}
	catch (e) {

		}
	}

function zmenokres(url) {

	var tar='';
	var xmore='';
	var okres='';

	try {

		okres=escape(document.getElementById('ofield').value);
		}
	catch(e) {

		}

	try {

		xmore=document.getElementById('qfield').value;
		if (xmore!='') xmore='?q='+xmore;
		}
	catch(e) {

		}

	if (okres!='') {

		tar=url+'-'+okres+'/'+xmore;
		}
	else {

		tar=url+xmore;
		}

	location.href=tar;
	return false;
	}

function parametry_setfocus(id) {

	try {

		document.getElementById('p_'+id).focus();
		}
	catch (e) {


		}
	}



function oznacit_inzerat(id,typ) {
	
	var hlaska='';

	var head=document.getElementsByTagName('head').item(0);
	var old=document.getElementById('last_id');
	if (old)head.removeChild(old);
	script=document.createElement('script');
	script.src='/_pub/clscripts/oznacitinzerat.php?id='+id+'&typ='+typ;
	script.type='text/javascript';
	script.defer=true;
	script.id='last_id'
	void(head.appendChild(script));
	}




function vlozjbs(frz) {

	document.write('<iframe src="/_pub/clscripts/jbs.php?q='+escape(frz)+'" scrolling="no" style="border:none;width:710px;height:100px;margin:0 0 10px 0;padding:0" frameborder="0"></iframe>');
	}


function checkregform() {

	if (!document.getElementById('souhlas').checked) {

		alert('K registraci je nutno potvrdit souhlas s podminkami.');
		return false;
		}

	if (document.getElementById('iemail').value.length==0) {

		alert('Vyplnte email.');
		return false;
		}

	return true;
	}



function openfotky(id) {

	try {

		window.open('/_pub/clscripts/fotoall.php?id='+id,'','scrollbars=yes,width=840,height=630');
		}
	catch (e) {

		}
	}

function zavadnyobsah(id,questi) {

	if (confirm(questi))
		loadscript('/_pub/clscripts/zavadnyobsah.php?id='+id);
	}

function zavadnyobsah_res(txt) {

	document.getElementById('ozninz').innerHTML=txt;
	}

function showhelp(typ) {

	}

function hidehelp(typ) {

	}

function focushelp(typ) {

	}

function blurhelp(typ) {

	}


var blokjslkat=0;

function inz_hn_mouse(el,typ) {

	try {

		if (el.className!='selected') {

			if (typ==1)
				el.className='s-hover';
			else
				el.className='';
			}
		}
	catch(e) {

		}
	}

function inz_hn_click(id) {

	try {

		if (blokjslkat==0) {

			tmp=document.getElementById('lk-'+id);
			location.href=tmp.href;
			}
		}
	catch(e) {

		}
	}

function inz_pm_mouse(id,el,typ) {

	try {

		if (document.getElementById('kk-'+id).className=='hn-dc')
			tmp='plus';
		else
			tmp='minus';

		if (typ==1) {

			blokjslkat=1;
			el.src='/_pub/styles/img/l-kat-'+tmp+'.png';
			}
		else {

			blokjslkat=0;
			el.src='/_pub/styles/img/l-kat-'+tmp+'-l.png';
			}
		}
	catch(e) {

		}
	}

function inz_pm_open(id,el) {

	try {

		tmp=document.getElementById('kk-'+id);

		if (tmp.className!='hn-dc') {

			tmp.className='hn-dc';
			el.src='/_pub/styles/img/l-kat-plus.png';
			}
		else {
			tmp.className='hn-do';
			el.src='/_pub/styles/img/l-kat-minus.png';
			}

		}
	catch(e) {

		}
	}

var tbtnold='';
function tbtn_click(typ) {

	try {

		if (tbtnold!='') {

			tmp=document.getElementById('tbtn-'+tbtnold);
			tmp.style.display='none';
			}
		}
	catch(e) {

		}

	try {

		tmp=document.getElementById('tbtn-'+typ);

		if (tmp.style.display=='block' || tbtnold==typ) {

			tbtnold='';
			tmp.style.display='none';
			}
		else {

			tbtnold=typ;
			tmp.style.display='block';
			}
		}
	catch(e) {

		}
	}






var pgz_wwx=0;
var pgz_wwy=0;
var pgz_scrolly=0;


function pgz_window_onresize() {

	if (typeof(window.innerWidth)=='number') {
		pgz_wwx=window.innerWidth;
		pgz_wwy=window.innerHeight;
		}
	else if (document.documentElement && (document.documentElement.clientWidth ||
	document.documentElement.clientHeight)) {
		pgz_wwx=document.documentElement.clientWidth;
		pgz_wwy=document.documentElement.clientHeight;
		}
	else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
		pgz_wwx=document.body.clientWidth;
		pgz_wwy=document.body.clientHeight;
		}
/*
	if (pgz_lightbox_activated==1) {

		pgz_lightbox_refresh++;

		window.setTimeout('pgz_light_refresh('+pgz_lightbox_refresh+')',50);
		}
*/

	if (pgz_lightbox_activated==1)
		pgz_light_close();
	}


function pgz_window_onscroll() {

	try {
		
		if (document.body.scrollTop==0)
			pgz_scrolly=document.documentElement.scrollTop;
		else
			pgz_scrolly=document.body.scrollTop;
	
		}
	catch(e) {
	
		}

	if (pgz_lightbox_activated==1)
		pgz_light_close();
	}


function pgz_light_refresh(kontrola) {

	if (pgz_lightbox_refresh==kontrola) {

		pgz_light_close();
		pgz_light_activate(null);

		pgz_lightbox_refresh=0;
		}
	}

pgz_window_onresize();
pgz_window_onscroll();

var pgz_lightbox_refresh=0;

var pgz_lightbox_activated=0;
var pgz_lightbox_fotky=new Array();
var pgz_lightbox_fotky_l=new Array();
var pgz_lightbox_fotky_x=new Array();
var pgz_lightbox_fotky_y=new Array();
var pgz_lightbox_fotky_ozn=new Array();
var pgz_lightbox_fotky_ano=new Array();
var pgz_lightbox_title='';
var pgz_lightbox_act=0;
var pgz_lightbox_count=0;
var pgz_lightbox_blockmove=0;
var pgz_lightbox_maxx=0;
var pgz_lightbox_maxy=0;

function pgz_lightbox_init(titulek) {

	pgz_lightbox_title=titulek;
	window.onresize=pgz_window_onresize;
	window.onscroll=pgz_window_onscroll;
	}

function pgz_light_activate(el) {

	pgz_lightbox_maxx=pgz_wwx-50;
	pgz_lightbox_maxy=pgz_wwy-100;

	if (el) {

		tmp3=el.src.replace(/x0/,'x2');
		tmp3=tmp3.replace(/x1/,'x2');
		}

	if (pgz_lightbox_activated==0 && pgz_lightbox_count==0)  {

		tmp1=document.getElementsByTagName('img');
		tmp2=tmp1.length;
		for (i=0;i<tmp2;i++) {

			tmps=tmp1[i].className;
			if (tmps.match('^pgz_fotky_')) {
				
				tmpx=tmps.split('_');

				pgz_lightbox_fotky[pgz_lightbox_count]=tmp1[i].src.replace(/x0/,'x2');
				pgz_lightbox_fotky[pgz_lightbox_count]=pgz_lightbox_fotky[pgz_lightbox_count].replace(/x1/,'x2');

				pgz_lightbox_fotky_x[pgz_lightbox_count]=tmpx[2];
				pgz_lightbox_fotky_y[pgz_lightbox_count]=tmpx[3];
//				pgz_lightbox_fotky_ozn[pgz_lightbox_count]=tmp1[i].getAttribute('alt');
				pgz_lightbox_fotky_ano[pgz_lightbox_count]=tmp1[i].getAttribute('title');

				pgz_lightbox_count++;
				}
			}

		pgz_lightbox_activated=1;
		}

	if (pgz_lightbox_count==0)
		return false;

	for (i=0;i<pgz_lightbox_count;i++) {

		if (pgz_lightbox_fotky[i]==tmp3)
			pgz_lightbox_act=i;
		}

	pgz_lightbox_blockmove=0;

	var body=document.getElementsByTagName('body').item(0);

	var old=document.getElementById('pgz_light');
	if (old)body.removeChild(old);

	tmp4=document.createElement('div');
	tmp4.id='pgz_light';
	tmp4.style.top=pgz_scrolly+'px';

	if (document.body.clientHeight>pgz_wwy)
		tmp4.style.height=document.body.clientHeight+'px';
	else
		tmp4.style.height=pgz_wwy+'px';

	tmp4.onclick=pgz_light_close;
	body.appendChild(tmp4);

	tmp5=document.createElement('div');
	tmp5.id='pgz_light2';
	tmp5.style.width=(pgz_wwx-45)+'px';
	tmp5.style.top=pgz_scrolly+'px';

	tmp6=document.createElement('span');
	tmp6.className='pgz_light2_btn';
	tmp6.innerHTML='X';
	tmp6.onclick=new Function("pgz_light_close()");
	tmp5.appendChild(tmp6);

	if (pgz_lightbox_count>1) {
	
		tmp6=document.createElement('span');
		tmp6.className='pgz_light2_btn';
		tmp6.innerHTML='&gt;';
		tmp6.onclick=new Function("pgz_light_move(1)");
		tmp5.appendChild(tmp6);
	
		tmp6=document.createElement('span');
		tmp6.className='pgz_light2_btn';
		tmp6.innerHTML='&lt;';
		tmp6.onclick=new Function("pgz_light_move(-1)");
		tmp5.appendChild(tmp6);
		}

	tmp6=document.createElement('span');
	tmp6.id='pgz_light2_nadpis';
	tmp6.className='pgz_light2_span';
	tmp5.appendChild(tmp6);

	body.appendChild(tmp5);

	pgz_light_move(0);
	}

function pgz_light_clkfoto() {

	if ((pgz_lightbox_act+1)<pgz_lightbox_count)
		pgz_light_move(1);
	else
		pgz_light_close();
	}

function pgz_light_cache_foto() {

	if ((pgz_lightbox_act+1)<pgz_lightbox_count) {

		var body=document.getElementsByTagName('body').item(0);

		body.appendChild(tmp6);

		tmp6=document.getElementById('pgz_light_img_cache');
		if (tmp6)body.removeChild(tmp6);

		tmp6=document.createElement('img');
		tmp6.id='pgz_light_img_cache';
		tmp6.style.visibility='hidden';
		tmp6.src=pgz_lightbox_fotky[pgz_lightbox_act+1];
		}
	}

function pgz_light_move(set) {

	if (pgz_lightbox_blockmove==1)
		return false;

	pgz_lightbox_blockmove=1;

	var body=document.getElementsByTagName('body').item(0);

	pgz_lightbox_act=pgz_lightbox_act+set;

	if (pgz_lightbox_act<0) pgz_lightbox_act=0;
	else if (pgz_lightbox_act>=pgz_lightbox_count) pgz_lightbox_act=pgz_lightbox_count-1;

	tmp6=document.getElementById('pgz_light2_nadpis');
	tmp6.innerHTML='';
//pgz_lightbox_fotky_ozn[pgz_lightbox_act]!='' || 
//		tmp6.innerHTML+='<p>'+pgz_lightbox_fotky_ozn[pgz_lightbox_act]+((pgz_lightbox_fotky_ano[pgz_lightbox_act]!='')?(' - '+pgz_lightbox_fotky_ano[pgz_lightbox_act]):(''))+'</p>';

	tmp6=document.getElementById('pgz_light_img');
	if (tmp6)body.removeChild(tmp6);

	tmp6=document.createElement('img');
	tmp6.id='pgz_light_img';
//	tmp6.title='Kliknutím na fotografii zobrazíte další (pokud není poslední). Kliknutím mimo fotografii zavřete prohlížení fotek.';
	tmp6.style.visibility='hidden';

/*
	if (pgz_lightbox_fotky_l[pgz_lightbox_act]!=1) {
		tmp6.onload=pgz_light_resize;
		tmp6.style.visibility='hidden';
		}
*/
//	tmp6.onclick=pgz_light_close;
	tmp6.onclick=new Function("pgz_light_clkfoto()");

	tmp6.src=pgz_lightbox_fotky[pgz_lightbox_act];
/* +'?r='+Math.round(Math.random()*100000); */
	body.appendChild(tmp6);
/*
	if (pgz_lightbox_fotky_l[pgz_lightbox_act]==1)
		pgz_light_resize()
*/

	pgz_light_resize();

	if (set>=0)
		pgz_light_cache_foto();
	}

function pgz_light_resize() {

	tmpw=pgz_lightbox_fotky_x[pgz_lightbox_act];
	tmph=pgz_lightbox_fotky_y[pgz_lightbox_act];

	if (tmpw>pgz_lightbox_maxx || tmph>pgz_lightbox_maxy) {

		tmpp1=tmpw/pgz_lightbox_maxx;
		tmpp2=tmph/pgz_lightbox_maxy;

		if (tmpp1>tmpp2) 
			tmppo=tmpp1;
		else
			tmppo=tmpp2;

		tmpw=Math.floor(tmpw/tmppo);
		tmph=Math.floor(tmph/tmppo);
		}

	pgz_lightbox_fotky_l[pgz_lightbox_act]=1;
	tmp=document.getElementById('pgz_light_img');

	tmp.style.visibility='visible';

	tmpx=Math.round((pgz_wwx-tmpw)/2)-10;
	tmpy=Math.round((pgz_wwy-tmph)/2);
/*
	tmpx=Math.round((pgz_wwx-tmp.width)/2);
	tmpy=Math.round((pgz_wwy-tmp.height)/2);
*/
	if (tmpx<5) tmpx=5;
	if (tmpy<75) tmpy=75;

	tmp.style.left=tmpx+'px';
	tmp.style.top=(tmpy+pgz_scrolly)+'px';

	tmp.width=tmpw;
	tmp.height=tmph;
	tmp.style.width=tmpw+'px';
	tmp.style.height=tmph+'px';
	tmp.style.visibility='visible';

	pgz_lightbox_blockmove=0;
	}

function pgz_light_close() {

	pgz_lightbox_activated=0;
	var body=document.getElementsByTagName('body').item(0);

	tmp3=document.getElementById('pgz_light_img');
	tmp2=document.getElementById('pgz_light2');
	tmp1=document.getElementById('pgz_light');

	if (tmp3) body.removeChild(tmp3);
	if (tmp2) body.removeChild(tmp2);
	if (tmp1) body.removeChild(tmp1);
	}



