function FotoWin(uri,title,w,h) {
  var okno = window.open('','','width='+w+',height='+h+',top='+(screen.height/2-h/2)+',left='+(screen.width/2-w/2));
  okno.document.write('<html><head><meta http-equiv="content-type" content="text/html; charset=windows-1250"><title>'+(title!='' ? title : 'fotogalerie')+'</title><link rel="stylesheet" href="http://www.realitymorava.cz/_template/okno.css" type="text/css"></head>');
  okno.document.write('<body>');
  okno.document.write('<a href="javascript:self.close()"><img alt="" title="Kliknutím zavřete" border=0 src="http://www.realitymorava.cz'+uri+'"></a>');
  if(title!='') okno.document.write('<p>'+title+'</p>');
  okno.document.write('</body>');
  okno.document.write('</htm>');
  okno.focus();
}

function WriteFlashCodeWithJS(f,w,h,q,b,t) {
  var output="";
  if(window.navigator.userAgent.indexOf("MSIE") != -1 && window.navigator.userAgent.indexOf("Windows") != -1){
    output=output+"<object id=\"flashmovie\" width=\""+w+"\" height=\""+h+"\" type=\"application/x-shockwave-flash\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0\">";
    output=output+"<param name=\"movie\" value=\""+f+"\">";
    output=output+"<param name=\"menu\" value=\"false\">";
    output=output+"<param name=\"bgcolor\" value=\""+b+"'\">";
    output=output+"<param name=\"quality\" value=\""+q+"\">";
    if(t==1) output=output+"<param name=\"wmode\" value=\"transparent\">";
    output=output+"<"+"/object>";
  } else {
    output=output+"<object id=\"flashmovie\" data=\""+f+"\" width=\""+w+"\" height=\""+h+"\" type=\"application/x-shockwave-flash\">";
    output=output+"<param name=\"movie\" value=\""+f+"\">";
    output=output+"<param name=\"menu\" value=\"false\">";
    output=output+"<param name=\"bgcolor\" value=\""+b+"'\">";
    output=output+"<param name=\"quality\" value=\""+q+"\">";
    if(t==1) output=output+"<param name=\"wmode\" value=\"transparent\">";
    output=output+"<"+"/object>";
  }
  return output;
}

function CheckSearch(f) {
  with(f) {
    /*if(stat.value=='' && lokalita.value=='' && druh.value=='' && typ.value=='' && cenaod.value=='' && cenado.value=='' && fulltext.value=='') {
      alert('Zadejte alespoň jedno kritérium pro hledání');
      return false;
    }*/
  }
  return true;
}
function getObj(name)
{
  if (document.getElementById)
    {this.obj = document.getElementById(name);
    this.style = document.getElementById(name).style;}
  else if (document.all)
    {this.obj = document.all[name];
    this.style = document.all[name].style;}
  else if (document.layers)
    {this.obj = document.layers[name];
    this.style = document.layers[name];}
}

function hidestyle(whichid)
{
  mainobject = new getObj(whichid);
  if (mainobject.style.display=='none')
    {mainobject.style.display='';}
  else
    {mainobject.style.display='none';}
}
function hidestyleON(whichid)
{
  mainobject = new getObj(whichid);
  mainobject.style.display='none';
}

function hidestyleOFF(whichid)
{
  mainobject = new getObj(whichid);
  mainobject.style.display='';
}

function DomDisable(whichid,bool) {
  mainobject = new getObj(whichid);
  mainobject.obj.disabled=bool;
}

function NastavStat(stat) {
  document.forms['newitemform'].kraj.options.length = 0;
  document.forms['newitemform'].okres.options.length = 0;
  if(stat==101) {
    for(i=0;i<14;i++) {
      document.forms['newitemform'].kraj.options[i] = new Option(kraj[kraje[i]],kraje[i]);
    }
    for(i=0;i<okresy[1003].length;i++) {
          document.forms['newitemform'].okres.options[i] = new Option(okres[okresy[1003][i]],okresy[1003][i]);
    }
    document.forms['newitemform'].mena.value = 1;
  }
  if(stat==122) {
    for(i=0;i<8;i++) {
      document.forms['newitemform'].kraj.options[i] = new Option(kraj_sk[i+3001],i+3001);
    }
    for(i=0;i<okresy_sk[3001].length;i++) {
      document.forms['newitemform'].okres.options[i] = new Option(okres_sk[okresy_sk[3001][i]],okresy_sk[3001][i]);
    }
    document.forms['newitemform'].mena.value = 21;
  }
}

function ObnovOkresy(kraj) {
  document.forms['newitemform'].okres.options.length = 0;
  if(kraj>3000) {
    for(i=0;i<okresy_sk[kraj].length;i++) {
      document.forms['newitemform'].okres.options[i] = new Option(okres_sk[okresy_sk[kraj][i]],okresy_sk[kraj][i]);
    } 
    } else {
      for(i=0;i<okresy[kraj].length;i++) {
      document.forms['newitemform'].okres.options[i] = new Option(okres[okresy[kraj][i]],okresy[kraj][i]);
    }  
  }
}
function GetName(p) {
  var pole = p.split('\\');
  var file = pole[pole.length-1];
  var pole = file.split('.');
  if(pole.length>=2) return pole[pole.length-2];
  if(pole.length>=1) return pole[pole.length-1];
}
function FotoOpen(uri,w,h) {
  window.open(uri,'','width='+(w+20)+',height='+(h+20)+',left='+(screen.width/2-w/2-10)+',top='+(screen.height/2-h/2-10)+',status=yes,resizable=yes,scrollbars=no');
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}


function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}