/*
Adam Haken, 2006
tento kod je chranen autorskym zakonem, jakekoli nepovolene pouziti je trestne
*/


function checkinzform(res) {

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

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

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

		alert('Vyplňte název obchodu.');
		return false;
		}

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

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

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

		alert('Vyplňte url stránek obchodu.');
		return false;
		}

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

		alert('Vyplňte IČ firmy.');
		return false;
		}

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

		if (!confirm('Bez vyplněného importního souboru nebude možno vyhledávat ve Vašem internetovém obchodu. Opravdu chcete odeslat registraci bez importu zboží?'))
			return false;
		}

	return true;
	}



function f_open(foto) {

	window.open('/_data/clscripts/foto.php?foto='+foto,'','scrollbars=yes,width=840,height=630');
	}



var pomocnik={

/* globalni promenne */

	id_q:null,
	id_pomocnik:null,
	id_helper:null,
	p_vstup:0,
	i_act:0,
	i_pocet:0,
	i_max:12,
	a_vals:new Array(),
	i_lastq:null,
	i_submit:0,
	i_last:0,
	i_wlast:0,
	i_keytime:200,
	i_wtime:6000,

	init:function(id_q,id_pomocnik,pocet) {

		this.id_q=document.getElementById(id_q);
		this.id_pomocnik=document.getElementById(id_pomocnik);
		this.id_helper=document.getElementById('helper');
		this.i_max=pocet;

		if (document.all) this.id_q.onkeydown=this.checkkey;
		else this.id_q.onkeypress=this.checkkey;

		this.id_q.form.onsubmit=this.cansubmit;
		},

	update:function(pole) {

		var tmp;

		this.i_act=0;
		this.p_vstup=pole.length;
		if (this.p_vstup==0) {

			this.wclosenow();
			return 0;
			}

		if (this.p_vstup>this.i_max) this.i_pocet=this.i_max;
		else this.i_pocet=this.p_vstup;

		tmp='<ul>';
		for(var i=0;i<this.i_pocet;i++) {
		
			this.a_vals[i+1]=pole[i][0];

			tmp+='<li id="pomocnik-'+(i+1)+'" onmouseover="pomocnik.itemover('+(i+1)+');" onmouseout="pomocnik.itemout('+(i+1)+');" onclick="pomocnik.itemclick('+(i+1)+');"><span id="spomocnik-'+(i+1)+'">zboží '+((pole[i][1]>1000)?('> 1000'):(pole[i][1]))+'</span>'+pole[i][0]+'</li>';
			}
/*
		tmp+='<li class="pomoff"><a href="/?pomocnik=off">Vypnout pomocníka</a></li>';
*/
		tmp+='</ul>';

		this.id_pomocnik.innerHTML=tmp;
		this.id_pomocnik.style.display='block';
		},

	check:function() {

		if (this.i_lastq!=this.id_q.value) {

			this.i_last++;
			window.setTimeout('pomocnik.loaddata('+this.i_last+')',this.i_keytime);
			}
		},

	loaddata:function(last) {

		if (last==this.i_last) {

			this.i_lastq=this.id_q.value;
			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/pomocnik.php?q='+this.id_q.value;
			script.type='text/javascript';
			script.defer=true;
			script.id='last_id'
			void(head.appendChild(script));
			}
		},

	wclosenow:function(wlast) {

		this.i_pocet=0;
		this.i_act=0;
		this.a_vals=Array();
		this.id_pomocnik.innerHTML='';
		this.id_pomocnik.style.display='none';
		},

	wclose:function(wlast) {

		if (wlast==this.i_wlast) {

			this.wclosenow();
			}
		},

	focus:function() {

		},

	blur:function() {

		window.setTimeout('pomocnik.wclosenow()',150);
		},

	rewrite:function() {

		for(var i=0;i<this.i_pocet;i++) {

			if (i+1==this.i_act) {

				document.getElementById('pomocnik-'+(i+1)).className='hover';
				document.getElementById('spomocnik-'+(i+1)).className='hover';
				}
			else {

				document.getElementById('pomocnik-'+(i+1)).className='';
				document.getElementById('spomocnik-'+(i+1)).className='';
				}
			}
	
		this.i_wlast++;
		window.setTimeout('pomocnik.wclose('+this.i_wlast+')',this.i_wtime);
		},

	itemover:function(item) {

		this.i_act=item;

		this.rewrite();
		},

	itemout:function(item) {

/*		this.i_act=0;*/

		this.rewrite();
		},

	itemclick:function(item) {

		this.id_q.value=this.a_vals[this.i_act];
		this.i_submit=1;
		this.id_q.form.submit();
		},

	cansubmit:function() {

		if (i_act==0) return true;

		if (i_submit==0) return false;
		},

	checkkey:function(e) {

		if(!e) if (window.event) e=window.event;

		var key;
		if (typeof(e.which)=='number') key=e.which;
		else if (typeof(e.keyCode)=='number') key=e.keyCode;
		else if (typeof(e.charCode)=='number') key=e.charCode;
   	else return;

		key=e.keyCode;
		switch(key) {
			case 13:

				if (pomocnik.i_act>0)
					pomocnik.id_q.value=pomocnik.a_vals[pomocnik.i_act];

				pomocnik.i_submit=1;
				this.id_q.form.submit();

			break
			case 38:

				if (pomocnik.i_act>1) pomocnik.i_act--;
				pomocnik.rewrite();

			break
			case 40:
		
				if (pomocnik.i_act<pomocnik.i_pocet) pomocnik.i_act++;
				pomocnik.rewrite();

			break
			}

		}

	}


function focusq() {

	document.getElementById('q').focus();
	}

function rstat(idshop,p,url) {

	location.href='/stat.php?i='+idshop+'&j=1&p='+p+'&u='+url;

	return false;
	}















