
	var IG=Array();

	function Ited_Gallery(mode, pocet)
	{
		var start, end;

		if(IG['run']) return;

		IG['run']=true;
		IG['max']=((109 * pocet) - (109 * 3)) * -1;
		IG['mode']=mode;

		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'] + (109 * 3);

			if(end > 0)
			{
				end=0;
			}
		}
		else
		{
			end=IG['start'] - (109 * 3);

			if(end < IG['max'])
			{
				end=IG['max'];
			}
		}

		IG['end']=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);
		}

		IG['start']=ml;

		GO('ited-gallery').style.marginLeft=ml + 'px';

		if((IG['mode'] == 2) && (IG['start'] <= IG['end']))
		{
			IG['run']=false;
		}
		else if((IG['mode'] == 1) && (IG['start'] >= IG['end']))
		{
			IG['run']=false;
		}
		else
		{
			setTimeout('Ited_Gallery_Move()', 10);
		}
	}



	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;
	}



	var menutv=Array();
	var menutz=50;
	var menuta=Array();

	function MenuT(id)
	{
		if(!menutv[id]) menutv[id]=1;

		CCS('menut-' + id, 'display', 'block');

		window.setTimeout("MenuT2(" + id + ", " + ++menutv[id] + ");", 3000);

		for(key in menuta)
		{
			if((key != id) && menuta[key])
			{
				CCS('menut-' + key, 'display', 'none');
				menuta[key]=false;
			}
		}

		menuta[id]=true;
	}



	function MenuT2(id, mtv)
	{
		if(!menuta[id]) return;

		if(mtv == menutv[id])
		{
			CCS('menut-' + id, 'display', 'none');
			menuta[id]=false;
		}
	}



	function MenuTO()
	{
		if(!menuta.length) return;

		for(key in menuta)
		{
			if(menuta[key])
			{
				CCS('menut-' + key, 'display', 'none');
				menuta[key]=false;
			}
		}
	}


	var LoginOpen=false;

	function Login()
	{
		CCS('login', 'display', (LoginOpen ? 'none' : 'block'));
		LoginOpen=LoginOpen ? false :true;
	}



	function FS(post)
	{
		if(!post)
		{
			GO('filtry').submit();
		}
	}



	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;
	}



	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');
				CCS(BH[idm]['elem'], 'height', 'auto');
			}
			else
			{
				CCBD();
				if(CCBIE6)
				{
					// IE 6 neumi height auto
					//CCS(BH[idm]['elem'], 'height', 'auto');
				}
				else
				{
					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);
		}
	}



	function Search(elem)
	{
		if(elem.value == 'Hledaný výraz...')
		{
			elem.value='';
		}
	}


	var InputBgV=Array();
	InputBgV[1]=255;
	InputBgV[2]=243;
	InputBgV[3]=199;
	InputBgV['max']=25;
	InputBgV['mode']=Array();

	function InputBg(id, out)
	{
		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));
	}


	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));
		}
	}


	var Rlt=Array();

	function Related(id)
	{
		if(Rlt[id])
		{
			Rlt[id]=false;
			CCS('related-' + id, 'display', 'none');
		}
		else
		{
			Rlt[id]=true;
			CCS('related-' + id, 'display', 'block');
		}
	}




	function Compare(item)
	{
		var vals=Array();
		vals['item']=item;

		POST('compare/', vals);
	}



	function POST(url, vals)
	{
		var param='';

		for(key in vals)
		{
			param+=key + '=' + (vals[key] ? vals[key] : '') + '&';
		}

		http=new XMLHttpRequest();
		http.open("POST", url, true);
		http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded; charset=utf-8');
		http.setRequestHeader('Content-length', param.length);
		http.setRequestHeader('Connection', 'close');

		http.onreadystatechange=function()
		{
			if(http.readyState == 4)
			{
				POST_Run(http.responseText);
			}
		}

		http.send(param);
	}


	function POST_Run(string)
	{
		var ex;

		ex=string.split("\n");

		if((ex[0] == '-start-') && (ex[ex.length-1] == '-end-'))
		{
			for(key in ex)
			{
				//alert('X: ' + ex[key]);

				if((key == 0) || (key == (ex.length - 1))) continue;

				eval(ex[key]);
			}
		}
		else
		{
			//alert('Y: ' + string);
		}
	}


	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();
	}
