

	var im=Array();
	im[1]=new Image();
	im[1].src='/images/main/top_search_submit_2.png';
	im[2]=new Image();
	im[2].src='/images/main/top_search_submit_2a.png';



	var BH=Array();
	BH['maxa']=Array(0, 112);
	BH['runs']=0;

	function BHV(elem, max, speed)
	{
		idm=elem;

		if(!BH[idm]) BH[idm]=Array();

		if(BH[idm]['run']) return;

		BH['runs']++;

		BH[idm]['max']=BH[idm]['height']=false;

		BH[idm]['run']=true;
		BH[idm]['elem']=GO(elem);
		//BH[idm]['back']=(BH[idm]['elem'].style.display == 'none') ? false : true;
		BH[idm]['back']=BH[idm]['elem'].offsetHeight ? true : false;
		BH[idm]['elem'].blur();
		BH[idm]['speed']=speed ? speed : 35;

		if(max && BH['maxa'])
		{
			BH[idm]['max']=BH['maxa'][max];

			BH[idm]['height']=BH[idm]['back'] ? (BH[idm]['elem'].offsetHeight ? BH[idm]['elem'].offsetHeight : BH[idm]['max']) : 0;
		}
		else
		{
			if(BH[idm]['back'])
			{
				BH[idm]['height']=BH[idm]['max']=BH[idm]['elem'].offsetHeight;
			}
			else
			{
				CCS(elem, 'display', 'block');
				BH[idm]['max']=BH[idm]['elem'].offsetHeight;
				BH[idm]['height']=0;
				CCS(elem, 'display', 'none');
			}
		}

		CCS(BH[idm]['elem'], 'overflow', 'hidden');
		CCS(BH[idm]['elem'], 'height', BH[idm]['height'] + 'px');
		CCS(BH[idm]['elem'], 'display', 'block');

		if(BH[idm]['elem'].id == 'login')
		{
			if(BH[idm]['back'])
			{
				CCS('login-close', 'display', 'none');
			}
		}

		BHV_Go(idm);
	}



	function BHV_Go(idm)
	{
		var plus=BH[idm]['back'] ? Math.ceil(BH[idm]['height'] / BH[idm]['speed']) : Math.ceil((BH[idm]['max'] - BH[idm]['height']) / BH[idm]['speed']);

		BH[idm]['height']=BH[idm]['back'] ? (BH[idm]['height'] - plus) : (BH[idm]['height'] + plus);

		if((BH[idm]['back'] && (BH[idm]['height'] <= 0)) || (!BH[idm]['back'] && (BH[idm]['height'] >= BH[idm]['max'])))
		{
			if(BH[idm]['back'])
			{
				CCS(BH[idm]['elem'], 'display', 'none');
				if(!IE6())
				{
					CCS(BH[idm]['elem'], 'height', 'auto');
				}
			}
			else
			{
				if(!IE6())
				{
					CCS(BH[idm]['elem'], 'height', 'auto');
				}
			}

			if(BH[idm]['elem'].id == 'login')
			{
				if(!BH[idm]['back'])
				{
					CCS('login-close', 'display', 'block');
				}

			}

			BH[idm]['run']=false;
			BH['runs']--;

			if(BH[idm]['back'] && BH[idm]['function_end'])
			{
				setTimeout(BH[idm]['function_end'], 1);
			}
		}
		else
		{
			CCS(BH[idm]['elem'], 'height', BH[idm]['height'] + 'px');
			setTimeout('BHV_Go(\'' + idm + '\');', 7);
		}
	}


/*
	var BH=Array();
	BH['maxa']=Array(0, 112);

	function BHV(elem, max, speed)
	{
		if(BH['run']) return;

		BH['max']=BH['height']=false;

		BH['run']=true;
		BH['elem']=GO(elem);
		BH['back']=(BH['elem'].style.display == 'block') ? true : false;
		BH['elem'].blur();
		BH['speed']=speed ? speed : 35;

		if(max && BH['maxa'])
		{
			BH['max']=BH['maxa'][max];

			BH['height']=BH['back'] ? (BH['elem'].offsetHeight ? BH['elem'].offsetHeight : BH['max']) : 0;
		}
		else
		{
			if(BH['back'])
			{
				BH['height']=BH['max']=BH['elem'].offsetHeight;
			}
			else
			{
				CCS(elem, 'display', 'block');
				BH['max']=BH['elem'].offsetHeight;
				BH['height']=0;
				CCS(elem, 'display', 'none');
			}
		}

		CCS(BH['elem'], 'overflow', 'hidden');
		CCS(BH['elem'], 'height', BH['height'] + 'px');
		CCS(BH['elem'], 'display', 'block');

		if(BH['elem'].id == 'login')
		{
			if(BH['back'])
			{
				CCS('login-close', 'display', 'none');
			}
		}

		BHV_Go();
	}



	function BHV_Go()
	{
		var plus=BH['back'] ? Math.ceil(BH['height'] / BH['speed']) : Math.ceil((BH['max'] - BH['height']) / BH['speed']);

		BH['height']=BH['back'] ? (BH['height'] - plus) : (BH['height'] + plus);

		if((BH['back'] && (BH['height'] <= 0)) || (!BH['back'] && (BH['height'] >= BH['max'])))
		{
			if(BH['back'])
			{
				CCS(BH['elem'], 'display', 'none');
				CCS(BH['elem'], 'height', 'auto');
			}
			else
			{
				CCS(BH['elem'], 'height', 'auto');
			}

			if(BH['elem'].id == 'login')
			{
				if(!BH['back'])
				{
					CCS('login-close', 'display', 'block');
				}

			}

			BH['run']=false;

			if(BH['back'] && BH['function_end'])
			{
				setTimeout(BH['function_end'], 1);
			}
		}
		else
		{
			CCS(BH['elem'], 'height', BH['height'] + 'px');
			setTimeout('BHV_Go();', 7);
		}
	}
*/

	var MTV=Array();
	MTV['actual']=Array();
	MTV['max']=Array();
	MTV['time']=Array();
	MTV['time'][1]=80;
	MTV['time'][2]=40;
	MTV['time'][3]=1600;
	MTV['time'][4]=50;
	MTV['close']=Array();
	MTV['next']=Array();
	MTV['mode']=Array();

	function MT(id, max)
	{
		if(!MTV['actual'][id])
		{
			MTV['close'][id]=false;
			MTV['actual'][id]=1;
			MTV['mode'][id]=1;
			MTV['max'][id]=max;
			MT_Change(id);
			GO('mtt-' + id).blur();
		}


		for(key in MTV['actual'])
		{
			if((key != id) && MTV['actual'][key] && !MTV['close'][key])
			{
				MTV['close'][key]=true;
				MTV['next'][key]=false;
			}
		}


		if(MTV['actual'][id])
		{
			if(MTV['mode'] == 2)
			{
				MTV['mode'][id]=1;
			}
			MTV['next'][id]=true;
		}

	}



	function MT_Change(id)
	{
		CCS('mt-' + id + '-' + MTV['actual'][id], 'display', ((MTV['mode'][id] == 1) ? 'block' : 'none'));

		if(MTV['mode'][id] == 1)
		{
			if((MTV['actual'][id] + 1) > MTV['max'][id])
			{
				setTimeout('MTV_End(' + id + ');', MTV['time'][3]);

				if(!MT['run'])
				{
					MT['run']=id;
					MT_Close(id);
				}
				return;
			}

			MTV['actual'][id]++;
		}
		else
		{
			if((MTV['actual'][id] - 1) < 1)
			{
				MTV['close'][id]=false;
				MTV['actual'][id]=false;
				MTV['mode'][id]=false;
				return;
			}

			MTV['actual'][id]--;
		}

		setTimeout('MT_Change(' + id + ');', MTV['time'][MTV['mode'][id]]);
	}



	function MT_Close(id)
	{
		var cont;

		if(MT['run'] && (MT['run'] != id))
		{
			return;
		}

		for(key in MTV['actual'])
		{
			if(MTV['close'][key] && (MTV['actual'][key] == MTV['max'][key]) && (MTV['mode'][key] == 1))
			{
				MTV['close'][key]=false;
				MTV['mode'][key]=2;
				MT_Change(key);
			}

			if(MTV['actual'][key] && !cont)
			{
				cont=key;
			}
		}

		if(cont)
		{
			MT['run']=cont;
			setTimeout('MT_Close(' + cont + ');', MTV['time'][4]);
		}
		else
		{
			MT['run']=false;
		}
	}



	function MTV_End(id)
	{
		if(MTV['next'][id])
		{
			MTV['next'][id]=false;
			setTimeout('MTV_End('+ id + ');', MTV['time'][3]);
		}
		else
		{
			MTV['close'][id]=true;
		}
	}



	window.onload=Proc;

	var proc_actual=false;
	var proc_mode=false;
	var proc_i=false;
	var proc_max=false;

	function Proc()
	{
		var i;

		if(!proc_max)
		{
			setTimeout("GFT()", 500);

			var elem=GO('proc-max');
			if(!elem) return;
			proc_max=elem.value;
		}

		if(!proc_actual)
		{

			var elem=GO('proc-1');
			if(!elem) return;

			CCBD('proc-1');

			for(i=1; i<=proc_max; i++)
			{
				if(GO('proc-' + i).style.display == 'block')
				{
					proc_actual=i;
					proc_mode=1;
					proc_i=99;
					setTimeout('Proc();', 5000);
					return;
				}
			}
		}

		if(proc_mode == 1)
		{
			proc_i-=10;
			if(proc_i < 0) proc_i=0;
			CCO('proc-' + proc_actual, proc_i);

			if(proc_i < 10)
			{
				proc_mode=2;
				proc_i=0;
			}

			setTimeout('Proc();', 40);
		}
		else if(proc_mode == 2)
		{
			if(proc_i == 0)
			{
				CCS('proc-' + proc_actual, 'display', 'none');
				proc_actual++;
				if(proc_actual > proc_max) proc_actual=1;
				CCS('proc-' + proc_actual, 'display', 'block');
			}

			CCO('proc-' + proc_actual, proc_i);
			proc_i+=10;
			if(proc_i == 10) proc_i=9;

			if(proc_i > 99)
			{
				proc_mode=1;
				proc_i=99;
				setTimeout('Proc(1);', 9000);
			}
			else
			{
				setTimeout('Proc();', 40);
			}
		}
	}


	function Search(elem)
	{
		if(elem.value == 'hledaný výraz...')
		{
			elem.value='';
		}
	}


	var IG=Array();

	function Ited_Gallery(mode, pocet)
	{
		var start, end;

		if(IG['run']) return;
		//if(!IG['pos']) IG['pos']=0;

		IG['run']=true;
		IG['max']=((114 * pocet) - (114 * 3)) * -1;
		IG['mode']=mode;

//GO('g-pocet').value=pocet;
//GO('g-max').value=IG['max'];

		start=GO('ited-gallery').style.marginLeft ? GO('ited-gallery').style.marginLeft : 0;

		if(start)
		{
			ex=start.split('px');
			start=ex[0];
		}

		IG['start']=Number(start);

		if((mode == 2) && ((IG['start'] + -1) <= IG['max']))
		{
			IG['run']=false;
			return;
		}

		if(mode == 1)
		{
			end=IG['start'] + (114 * 3);

			if(end > 0)
			{
				end=0;
			}
		}
		else
		{
			end=IG['start'] - (114 * 3);

			if(end < IG['max'])
			{
				end=IG['max'];
			}
		}

		IG['end']=end;
//alert('mode: ' + IG['mode'] + ' | start: ' + IG['start'] + ' | end: ' + IG['end']);
		Ited_Gallery_Move();
	}



	function Ited_Gallery_Move()
	{
		var ml;

		if(IG['mode'] == 1)
		{
			ml=IG['start'] + Math.ceil((IG['end'] - IG['start']) / 20);
		}
		else
		{
			ml=IG['start'] + (Math.ceil((IG['end'] - IG['start']) / 20) - 1);

			//ml=IG['start'] + ((IG['end'] - IG['start']) / 20);

			//alert('c=' + (IG['end'] - IG['start']) + ' > ' + ((IG['end'] + IG['start']) / 20) + ' || es: ' + IG['end'] + ' | ' + IG['start'] + ' > ' + ml);
		}

//GO('g-start').value=IG['start'];
//GO('g-end').value=IG['end'];
//GO('g-ml').value=ml;
//GO('g-cq').value=Math.ceil((IG['end'] - IG['start']) / 20) + ' | ' + ((IG['end'] - IG['start']) / 20);
//GO('g-cqs').value=IG['start'] + Math.ceil((IG['end'] - IG['start']) / 20);

//date=new Date();
//GO('g-time').value=date.getMilliseconds();

		IG['start']=ml;
		//alert(IG['start']);

		GO('ited-gallery').style.marginLeft=ml + 'px';

		if((IG['mode'] == 2) && (IG['start'] <= IG['end']))
		{
			//alert('end');
			IG['run']=false;
		}
		else if((IG['mode'] == 1) && (IG['start'] >= IG['end']))
		{
			//alert('end');

			IG['run']=false;
		}
		else
		{
			setTimeout('Ited_Gallery_Move()', 10);
		}

/*
		v=ml
		ml=(IG['mode'] == 1) ? (IG['start'] - ml) : (IG['start'] + ml);
		ml=Math.ceil(ml);
		IG['start']=ml;

		if(IG['mode'] == 1)
		{
			alert(v + ' | ' + ml);
		}



		if(((IG['mode'] == 2) && (IG['start'] >= IG['end'])) || ((IG['mode'] == 1) && (IG['end'] >= IG['start'])))
		{
			alert('end');
			IG['run']=false;
		}
		else
		{
			setTimeout('Ited_Gallery_Move()', 400);
		}
*/
	}


	var TabsV=Array();

	function Tabs(tab, active)
	{
		if(!TabsV['first'])
		{
			TabsV['first']=true;
			TabsV['active']=active;
		}

		GO('tabsm-' + TabsV['active']).className=false;
		CCS('tabs-' + TabsV['active'], 'display', 'none');

		GO('tabsm-' + tab).className='ited-tabs-menu-active';
		GO('tabsm-' + tab).blur();
		CCS('tabs-' + tab, 'display', 'block');

		TabsV['active']=tab;
	}



	function Ited_Vars(vl)
	{
		var elem;

		if(GO('ited-vars-but-' + vl).innerHTML == 'Zabalit varianty')
		{
			if(MV['define']['count'][vl] < 40)
			{
				BHV('vars-list-' + vl, false, 10);
			}
			else
			{
				CCS('vars-list-' + vl, 'display', 'none');
			}

			CCS('ited-vars-grad-' + vl, 'display', 'block');
			Ited_Vars_Grad(vl, 9, 2);
		}
		else
		{
			if(MV['define']['count'][vl] < 40)
			{
				BHV('vars-list-' + vl, false, 20);
			}
			else
			{
				CCS('vars-list-' + vl, 'display', 'block');
			}

			Ited_Vars_Grad(vl, 109, 1);
		}
	}


	function Ited_Vars_Grad(vl, vs, mode)
	{
		vs=(mode == 2) ? (vs + 22) : (vs - 10);

 		if((mode == 2) && (vs > 100))
 		{
 			GO('ited-vars-but-' + vl).blur();
 			GO('ited-vars-but-' + vl).className='';
 			GO('ited-vars-but-' + vl).innerHTML='Zobrazit všechny varianty';
 			return;
 		}
		else if((mode == 1) && (vs < 0))
		{
			GO('ited-vars-but-' + vl).blur();
			CCS('ited-vars-grad-' + vl, 'display', 'none');
			GO('ited-vars-but-' + vl).className='vars-list-button-small';
			GO('ited-vars-but-' + vl).innerHTML='Zabalit varianty';
		}
		else
		{
			CCO('ited-vars-grad-' + vl, vs);
			setTimeout('Ited_Vars_Grad(' + vl + ', ' + vs + ', ' + mode + ')', 130);
		}
	}



	var IVBg=Array();
	IVBg['clr']='rgb(213,223,181)';
	IVBg['clr2']='rgb(225,220,207)';
	IVBg['clr1']='none';
	IVBg['clr3']='rgb(239,204,164)';

	function Ited_VarsBg(idv, mode)
	{
		var test;

		for(key in MV['bcgids'])
		{
			if(MV['bcgids'][key] == idv)
			{
				test=true;
			}
		}

		if(test || (mode == 3))
		{
			CCS(idv, 'background', IVBg['clr3']);
		}
		//else if(IVBg[idv] || mode)
		else if(mode)
		{
			IVBg[idv]=false;

			CCS(idv, 'background', IVBg['clr' + mode]);
		}
		else
		{
			IVBg[idv]=true;
			CCS(idv, 'background', IVBg['clr']);
		}
	}



	function Set_Adress(mode, id)
	{
 		Forms('adress', id, mode);
	}



	function Forms(mode, id, v1)
	{
		if(!GO('frm'))
		{
			var top=GO('top');
			var frmc=document.createElement('form');
			frmc.setAttribute('id', 'frm');
			frmc.setAttribute('method', 'post');
			frmc.setAttribute('action', '');
			top.appendChild(frmc);

			frm=GO('frm');
		}
		else
		{
			alert(GO('frm'));
			frm=GO('frm');
		}

		var t1=document.createElement('input');
		t1.setAttribute('type', 'hidden');
		t1.setAttribute('name', 'bt[mode]');
		t1.setAttribute('value', mode);
		frm.appendChild(t1);

		switch(mode)
		{
			case 'adress':
			/*case 'cart_del':
			case 'fullds':*/
				var t=document.createElement('input');
				t.setAttribute('type', 'hidden');
				t.setAttribute('name', 'bt[id]');
				t.setAttribute('value', id);
				frm.appendChild(t);

				if(v1)
				{
					var t=document.createElement('input');
					t.setAttribute('type', 'hidden');
					t.setAttribute('name', 'bt[v1]');
					t.setAttribute('value', v1);
					frm.appendChild(t);
				}
				break;
		}

		frm.submit();
	}



	var InputBgV=Array();
	InputBgV[1]=255;
	InputBgV[2]=243;
	InputBgV[3]=199;
	InputBgV['max']=25;
	InputBgV['mode']=Array();

	function InputBg(id, out, ga)
	{
		if(InputBgV['mode'][id])
		{
			InputBgV['mode'][id]=out ? 2 : 1;

			CCS(id, 'border', '1px solid ' + (out ? 'silver' : 'rgb(120,120,120)'));

			return;
		}

		InputBgV['mode'][id]=out ? 2 : 1;

		CCS(id, 'border', '1px solid ' + (out ? 'silver' : 'rgb(120,120,120)'));

		InputBgr(id, (out ? InputBgV['max'] : 1));

		if(ga)
		{
			pageTracker._trackPageview('/kosik/kontaktni-udaje/' + ga + '/');
		}
	}



	function InputBgr(id, step)
	{
		var c=Array(), color, i;

		for(i=1; i<=3; i++)
		{
			c[i]=Math.ceil(255 - ((255 - InputBgV[i]) / InputBgV['max'] * step));

			if(c[i] > 255)
			{
				c[i]=255;
			}
		}

		color='rgb(' + c[1] + ',' + c[2] + ',' + c[3] + ')';
//alert(step + ': ' + color);

		//GO('test').value=GO('test').value + "\n" + step + ': ' + color;

		CCS(id, 'backgroundColor', color);

		step=(InputBgV['mode'][id] == 1) ? (step + 1) : (step - 1);

		if((InputBgV['mode'][id] == 1) && (step == InputBgV['max']))
		{
			InputBgV['mode'][id]=false;
			CCS(id, 'background', 'rgb(' + InputBgV[1] + ',' + InputBgV[2] + ',' + InputBgV[3] + ')');
		}
		else if((InputBgV['mode'][id] == 2) && (step == 1))
		{
			InputBgV['mode'][id]=false;
			CCS(id, 'background', 'rgb(255,255,255)');
		}
		else
		{
			setTimeout('InputBgr(\'' + id + '\', ' + step + ')', ((InputBgV['mode'][id] == 2) ? 25 : 10));
		}
	}



	function toDetail()
	{
		var date=new Date();

		document.cookie='mover=' + Math.ceil(date.getTime() / 1000) + ';path=/';
	}



	function Price(price)
	{
		var d, i, e, rst='';

		price=String(Math.ceil(price));
		d=price.length;

		for(i=d, e=0; i>0; i--)
		{
			if(!(e++ % 3))
			{
				rst=' ' + rst;
			}

			rst=price.substr([i-1], 1) + rst;
		}

		rst+=' Kč';

		return rst;
	}



	function Dotaznik(mode)
	{
		BHV('dotaznik-1', false, 10);
		BHV('dotaznik-2', false, 10);
		//CCS('dotaznik-1', 'display', 'none');
		//CCS('dotaznik-2', 'display', 'block');

		if(mode == 1)
		{

		}
		else if(mode == 2)
		{
			GO('dotaznik-failed').value=1;
			GO('dotaznik-row-1-1').className='dotaznik-none';
			GO('dotaznik-row-1-2').className='dotaznik-none';
			GO('dotaznik-row-2-1').className='dotaznik-none';
			GO('dotaznik-row-2-2').className='dotaznik-none';
			GO('dotaznik-row-3-1').className='dotaznik-none';
			GO('dotaznik-row-3-2').className='dotaznik-none';
			GO('dotaznik-words-1').className='dotaznik-none-2';
			GO('dotaznik-words-2').className='dotaznik-none-2';
		}
	}



	function Seznam_Objednavek(order, deposit)
	{
		window.open('/seznam-objednavek/' + (deposit ? 'deposit' : 'proforma') + '/' + order + '/', 'invoice' + order, 'width=650');
	}


	var VB=Array();

	function Vanoce_Banner(active, count)
	{
		var time, next;

		if(BH['runs']) return;

		if(VB['block'] && !active)
		{
			return;
		}

		if(active && !count)
		{
			if(active == VB['active']) return;

			VB['block']=true;
			next=active;
			time=20000;
			//setTimeout("VB['block']=false;", time);
		}
		else if(active && count)
		{
			VB['active']=active;
			VB['count']=count;

			setTimeout('Vanoce_Banner()', 5000);
			return;
		}

		BHV('vanoce-banner-' + VB['active']);
		GO('vanoce-banner-nums-' + VB['active']).className='';

		if(next)
		{
			VB['active']=next;
		}
		else
		{
			VB['active']++;
			if(VB['active'] > VB['count']) VB['active']=1;
		}

		BHV('vanoce-banner-' + VB['active']);
		GO('vanoce-banner-nums-' + VB['active']).className='vanoce-banner-nums-active';

		setTimeout('Vanoce_Banner()', (time ? time : 10000));
	}



	function GFT()
	{
		if(!GO('ited-buttons')) return;

		var url=GO('gft-url').value;

		var tx='<table class="ited-buttons-01"><colgroup><col class="col-50" /><col /><col class="col-50" /></colgroup><tr><td><div class="g-plusone" data-size="tall"></div></td><td></td>';
		tx+='<td><div id="fb-root"></div><div class="fb-like" data-href="' + url + '" data-send="false" data-layout="box_count" data-width="50" data-show-faces="true" data-colorscheme="dark" data-font="lucida grande"></div></td></tr>';
		tx+='</table>';

		GO('ited-buttons').innerHTML=tx;

		// g+
		window.___gcfg = {lang: 'cs'};
		(function() {  var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true; po.src = 'https://apis.google.com/js/plusone.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s); })();

		// fcb
		(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) {return;} js = d.createElement(s); js.id = id; js.src = '//connect.facebook.net/en_US/all.js#xfbml=1'; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));
	}
