top.onResize = ResizePage();

function link_to_home(wt)
{
	pg = top.document.getElementById("send_link");
	if (pg!=null) pg.style.visibility = 'hidden';	

	if (wt==null) wt = 1;	

	if (wt==1)
	{
		pg1 = top.document.getElementById("loading");
		if (pg1!=null) pg1.style.visibility = 'visible';	
	}
}
function ResizePage()
{
	pg = top.document.getElementById("page");
	//pg = top.document.getElementById("content");

	if (pg!=null)
	{	
		d = document.getElementById("page_data");
		if (d!=null)
			pg.height = d.offsetHeight + 70;

		limit = 800;
		lft = 165;

		c = document.getElementById("image");
		if ( c!=null )
		{
			if (c.width<limit-lft)
				pg.width = limit - lft + 63;
			else
				pg.width = c.width + 63;
		}
		else
		{
			c = document.getElementById("nastenka");

			if ( c!=null )
			{
				pg.width = 900;
			}
			else
			{
				if ( top.document.body.clientWidth > limit )
					pg.width = top.document.body.clientWidth - lft - 20;
				else
					pg.width = limit - lft - 20;

				if (d!=null && navigator.userAgent.indexOf('Chrome')!=-1)
				{
					//lb = top.document.getElementById("leftbar");
					//lb.height = lb.height-600;

					//pg.height = pg.height-600;
					//pg.height = d.offsetHeight;
					//pg.height = 800;
					//pg.width = 600;
					//alert("resize");
				}
				//else
				//{
				//	pg.height = 800;
				//	pg.width = 600;
				//}
			}
		}
	}

	pg = top.document.getElementById("loading");

	if (pg!=null) pg.style.visibility = 'hidden';	
}
function ResizeMenu()
{
	mn = top.document.getElementById("menu");

	if (mn!=null)
	{	
		d = document.getElementById("menu_data");
		if (d!=null) mn.height = d.offsetHeight + 200;
	}
}
function InitPage(size,wt)
{
	if (top.document.getElementById("page")!=null)
	{	
		top.document.getElementById("page").height = size;
		ResizePage();
	}
	link_to_home(wt);
}
function SetPageSize(size)
{
	if (top.document.getElementById("page")!=null)
	{	
		top.document.getElementById("page").height = size;
	}
	link_to_home();
}
function PageSize(height,width)
{
	if (top.document.getElementById("page")!=null)
	{	
		top.document.getElementById("page").height = height;
		//top.document.getElementById("page").width = width;
	}
}
function get_href()
{
	if (document.getElementById('page')==null) return '';

	iframe = document.getElementById('page');

	if (iframe.contentDocument!=null)
		new_link = iframe.contentDocument.URL;
	else if (document.frames.page.location)
		new_link = document.frames.page.location.href;
	else
		new_link = iframe.src;

	return new_link.replace('language=','');
}
function showOptions(tt) 
{
	t = document.getElementById(tt);

	if (t.style.visibility=="hidden")
	{
		t.style.visibility = "visible";
		t.style.height = "auto";
		t.style.display = "block";
		//document.forms.search.show_options.value = "1";
	}
	else
	{
		t.style.visibility = "hidden";
		t.style.height = "1px";
		t.style.display = "none";
		//document.forms.search.show_options.value = "0";
	}

	ResizePage();

	return false;
}
function showOptions2(tt) 
{
	t = document.getElementById(tt);

	if (t.style.visibility=="hidden")
	{
		t.style.visibility = "visible";
		t.style.height = "auto";
		t.style.display = "block";
	}
	else
	{
		t.style.visibility = "hidden";
		t.style.height = "1px";
		t.style.display = "none";
	}

	ResizePage();

	return false;
}
function onLMClick(id)
{
	var mnu = document.getElementById("mnu_"+id);

	if (mnu)
	{
		if (mnu.style.display=="none") 
			mnu.style.display="";
		else
			mnu.style.display="none";
	}
}
function validate_link(lnk,m)
{
	if (lnk=='')	return false;

	if (m==1)
	{
		a = top.document.frames;

		if ('http://nemcok.sk'+lnk == a[0].location)
			return false;

		if ('http://nemcok.sk'+lnk == top.document.frames["page"].location)
			return false;

		if ('http://nemcok.sk'+lnk == top.document.frames[0].location)
			return false;
	}
	else
	{
		if ('http://nemcok.sk'+lnk == top.document.getElementById('page').contentDocument.URL)
			return false;

		if (lnk == top.document.getElementById('page').contentDocument.URL)
			return false;
	}

	return true;
}

var popUpWin=new Array;
function popUpWindow(URLStr, left, top, width, height, name)
{
	if(popUpWin[name])
	{
		if(!popUpWin[name].closed) popUpWin[name].close();
	}

	popUpWin[name] = window.open(URLStr, name,'toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');

	popUpWin[name].focus();
}
var popUpDate=0;
function popUpDateWindow(URLStr, left, top)
{
	if(popUpDate)
	{
  		if(!popUpDate.closed) popUpDate.close();
	}
	popUpDate = window.open(URLStr, 'popUpDate','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=147,height=215,left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}
function shft( txt1, txt2 )
{
	if (navigator.appName == 'Microsoft Internet Explorer') 
		if (event.shiftKey==true) return txt1;

	return txt2;
}

function move_okno(o)
{
		if (dok)
		{
			if (ns6)
			{
				p.style.left=temp1+o.clientX-sur_x
				p.style.top=temp2+o.clientY-sur_y
			}
			else
			{
				p.style.left=temp1+event.clientX-sur_x
				p.style.top=temp2+event.clientY-sur_y
			}
			return false
		}
}

function d_okno(e)
{
		if (!ie&&!ns6) return

		if (ns6){var o=e.target;var t='HTML';}
		   else	{var o=event.srcElement;var t='BODY';}

		while (o.tagName!=t&&o.className!='okno')
			{o=ns6? o.parentNode : o.parentElement;}

		if (o.className=='okno')
		{	dok=true
			p=o
			zi++;
			p.style.zIndex=zi;
			temp1=parseInt(p.style.left+0)
			temp2=parseInt(p.style.top+0)
			sur_x=ns6? e.clientX: event.clientX
			sur_y=ns6? e.clientY: event.clientY
			document.onmousemove=move_okno
			return false
		}
}

function getNext(t,pocet)
						{
							src = t.src;
							pn = parseInt(pocet);

							if (src.substr(src.length-6,1)=='_')
							{
								n = parseInt(src.substr(src.length-5,1));

								if (n>=1 && n<pn)
									src=src.substring(0,src.length-6)+'_'+(n+1)+'.jpg';
								else if (n=pn)
									src=src.substring(0,src.length-6)+'.jpg';
								else
								{
									n = 1;
									src=src.substring(0,src.length-4)+'_2.jpg';
								}
							}
							else
							{
								n = 1;
								src=src.substring(0,src.length-4)+'_2.jpg';
							}

							if (n==pn) n = 0;
							t.title = t.title.substring(0,t.title.length-4) + (n+1) + '/'+(pn)+')';

							t.src = src;

							return src;
						}

// -------------------------------------------------------------------------
//  A J A X  support
// -------------------------------------------------------------------------

	var xmlhttp;

	function loadURL(o,url)
	{
		if (o==null)  return;

		xmlhttp=null
		if (window.XMLHttpRequest)
			xmlhttp=new XMLHttpRequest();
		else if (window.ActiveXObject)
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");

		if (xmlhttp!=null)
		{
			xmlhttp.onreadystatechange=getResponse
			xmlhttp.open("POST",url,true);
			xmlhttp.setRequestHeader("Cache-Control","no-cache");
			xmlhttp.send(null);
		}
	}

	function getResponse()
	{
		if (xmlhttp.readyState==4) // if "loaded"
		{
			response = xmlhttp.responseText;

			if (!response) return;

			s	= response.split('||');
			e	= s[0];
			text	= s[1];

			o=document.getElementById(e);

			if (xmlhttp.status==200) // if "OK"
				o.innerHTML=''+text;
			else	o.innerHTML+='<br />Error '+xmlhttp.status;
		}
	}

function show_hide(id)
{
	e=document.getElementById(id);

	if (e.style.display=='block') e.style.display='none';
	else e.style.display='block';

	ResizePage();
}
function LoadURL(l)
{
	h=top.document.getElementById('ld');
	h.src = l;
	return true;
}
