
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 checkinzform(res) {

	if (document.getElementById('souhlas').checked==false) {

		alert('Nebyl potvrzen souhlas s podminkami.');
		return false;
		}

	if (document.getElementById('i-typ-1').checked!=true && document.getElementById('i-typ-2').checked!=true) {

		alert('Vyberte typ inzerátu.');
		return false;
		}

	if (document.getElementById('i-idkat').value==0) {

		alert('Vyberte kategorii inzerátu.');
		return false;
		}

	if (document.getElementById('i-nadpis').value.length==0) {

		alert('Vyplňte nadpis inzerátu.');
		return false;
		}

	if (document.getElementById('i-jmeno').value.length==0) {

		alert('Vyplňte jméno.');
		return false;
		}

	if (document.getElementById('i-heslo').value.length==0) {

		alert('Vyplňte heslo.');
		return false;
		}

	return true;
	}




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('/_data/clscripts/foto.php?foto='+escape(foto.replace(/x1/g,'x2')),'','scrollbars=yes,width=840,height=630');
		}
	catch (e) {

		}

	}


function openfoto2(foto) {

	try {

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

		}

	return false;
	}


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='/_data/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="/_data/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 podmínkami.');
		return false;
		}

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

		alert('Vyplňte email.');
		return false;
		}

	return true;
	}



function openfotky(id) {

	try {

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

		}
	}

function podobneinz(xtext) {

	document.write('<br />Můžete se pokusit <a href="/hledat/?q='+xtext+'">najít podobné inzeráty</a>.');
	}

function zavadnyobsah_wrt(id) {

	document.write('<h2>Nahlásit inzerát</h2>');

	document.write('<div class="dalsiinfo2">');
	document.write('<div class="ozninz" id="ozninz">');
	document.write('<form><input type="button" value="nahlásit závadný inzerát" onclick="zavadnyobsah('+id+',\'Opravdu chcete tento inzerát nahlásit jako závadný? (nesprávna kategorie, nevhodné fotografie, podvodný obsah, atd.\')" /></form>');
	document.write('</div>');
	document.write('<p>Za závadný se požavuje zejména inzerát který: neobsahuje informace o konkrétním předmětu(práci), je podvodný, obsahuje erotiku, apod.</p>');

	document.write('</div>');
	}


function zavadnyobsah(id,questi) {

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

function zavadnyobsah_res(txt) {

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


function inz_hn_mouse(id,el,typ) {

	try {

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

		if (typ==1)
			el.src='/_data/styles/img/hn-'+tmp+'.png';
		else
			el.src='/_data/styles/img/hn-'+tmp+'-l.png';
		}
	catch(e) {

		}
	}

function inz_hn_open(id,el) {

	try {

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

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

			tmp.className='hn-dc';
			el.src='/_data/styles/img/hn-plus.png';
			}
		else {
			tmp.className='hn-do';
			el.src='/_data/styles/img/hn-minus.png';
			}
/*
		if (tmp.style.display!='block')
			tmp.style.display='block';
		else
			tmp.style.display='none';
*/
		}
	catch(e) {

		}
	}


function inz_kat_change(sl) {

	try {

		tkat0=document.getElementById('item_kat_0');
		tkat1=document.getElementById('item_kat_1');
		tkat2=document.getElementById('item_kat_2');

		if (sl<2)
			tkat2=0;
		if (sl<1)
			tkat1=0;

		loadscript('/_clscripts/katchange.php?sl='+sl+'&kat0='+tkat0.value+'&kat1='+tkat1.value+'&kat2='+tkat2.value);
		}
	catch(e) {

		}
	}

function vlsb() {

	document.write('<div class="leftkat">Najdete nás na Seznam.cz<ul><li><a href="http://sea');
	document.write('rch.s');
	document.write('ezn');
	document.write('am.cz/?q=bazar+bazac" target="_blank">Bazar Bazáč</a></li></ul></div>');
	}