function gid($co) {return document.getElementById($co);}

function init_page()
	{
	init_opener();
	}



// new window:

function switch_new_win_stnd(e)
	{
	switch_new_win(e.currentTarget.checked);
	}

function switch_new_win(st)
	{
	document.cookie="neotevirat_v_novem_okne="+(st?"0":"1")+"; path=/";
	}

function get_anchor(el)
	{
	while(el.nodeName!="A") el=el.parentNode;
	return el;
	}

function open_anchor(e)
	{
	if(!e)e=window.event;
	var atarget=e.currentTarget?e.currentTarget:get_anchor(e.srcElement);
	//open_new_window=document.getElementById("windowswitch").checked;
	atarget.target=open_new_window?"_blank":"";
	}

function check_anchor(a)
	{
	var test_exp=new RegExp("^(http(s)?://"+self.location.host+"|mailto:)");
	return ((!test_exp.test(a.href) || a.rel=="external" || a.className.indexOf("external")>-1) && a.href);
	}

function init_opener()
	{/*
	var i,e,open_new_window,anch,test_exp,found_ext_anchors,switchdiv;
	var sdtitle=" otevírat odkazy vedoucí mimo server www.all-stars.cz v novém okně - doporučené";
	var linktext=" otevírat externí odkazy v novém okně";

	if(document.getElementsByTagName("a"))
		{
		open_new_window=document.cookie?((document.cookie.indexOf("neotevirat_v_novem_okne=1")>-1)?false:true):true;
		anch=document.body.getElementsByTagName("a");
		found_ext_anchors=0;
		for(i=0;i<anch.length;i++)
			{
			if(anch[i].href.indexOf("local-redir")>-1) anch[i].href=unescape("http://"+anch[i].href.substr(7,anch[i].href.substr(7).indexOf("/"))+anch[i].href.substr(anch[i].href.indexOf("=")+1));
			if(check_anchor(anch[i]))
				{
				anch[i].className+=" external";
				try
					{
					anch[i].addEventListener("click",open_anchor,true);
					}
				catch(e){}
				try
					{
					anch[i].onclick=open_anchor;
					}
				catch(e){}
				found_ext_anchors++;
				}
			}
		if(found_ext_anchors)
			{
			switchdiv=document.getElementById("windowopener");
			switchdiv.title=sdtitle;
			try
				{
				switchdiv.innerHTML="<input type='checkbox' id='windowswitch' onchange='switch_new_win(this.checked);' "+(open_new_window?"checked='checked' ":"")+"/>"+linktext;
				}
			catch(e)
				{
				var switchbox=document.createElement("input");
				switchdiv.appendChild(switchbox);
				switchbox.setAttribute("type","checkbox");
				switchbox.setAttribute("id","windowswitch");
				switchbox.addEventListener("change",switch_new_win_stnd,false);
				if(open_new_window) switchbox.checked=true;

				switchdiv.appendChild(document.createTextNode(linktext));
				}
			switchdiv.setAttribute("for","windowswitch");
			}
		}*/
	}


	
	Page = function () {};

Page.showPicture = function (imgNode, src, w, h) 
{
   var ImgDiv = document.getElementById('page-orig-image');
   
   if (ImgDiv) {
      if (ImgDiv.parentNode) ImgDiv.parentNode.removeChild(ImgDiv);
      var Img = ImgDiv.firstChild;
   } else {
      ImgDiv = document.createElement('div');
      ImgDiv.id = 'page-orig-image';
      ImgDiv.style.position = 'fixed';
      if (document.all && !window.Opera) ImgDiv.style.position = 'absolute';
      
      ImgDiv.style.left = '0';
      ImgDiv.style.textAlign = 'center';
      ImgDiv.style.width = '100%';
      
      
      ImgDiv.onclick = function () {this.parentNode.removeChild(this)};
      
      var Img = document.createElement('img');
      ImgDiv.appendChild(Img);
   };
   
   var vp = Page.getViewport();
   
   Img.src = '';
   Img.src = src;
   
   var pomerX = w/(vp.x-4);
   var pomerY = h/(vp.y-4);
   
   if (pomerX>1 || pomerY>1) {
      var pomerMax = pomerX > pomerY ? pomerX : pomerY;
      w = Math.round(w/pomerMax);
      h = Math.round(h/pomerMax);
   };
   Img.width = w;
   Img.height = h;
   
   var scrollTop = 0;
   if (document.all && !window.Opera) {
      scrollTop = document.body.scrollTop;
   };
   
   ImgDiv.style.top = ((vp.y/2)-(h/2)-2+scrollTop)+'px';
   Img.style.backgroundColor = 'white';
   Img.title="Klikněte pro zavření velkého obrázku.";
   Img.style.cursor="pointer";
   
   
   document.body.appendChild(ImgDiv);
};

Page.getViewport = function () {
   var x,y;
   if (self.innerHeight) {
   	x = self.innerWidth;
   	y = self.innerHeight;
   } else if (document.documentElement && document.documentElement.clientHeight) {
   	x = document.documentElement.clientWidth;
   	y = document.documentElement.clientHeight;
   } else if (document.body) {
   	x = document.body.clientWidth;
   	y = document.body.clientHeight;
   };
   return {'x' : x, 'y' : y};
};