var neww = false;
function openw(co,okno,jak,nazev){
  var verze = parseInt(navigator.appVersion);
  var wi = 'width=';
  var hi = 'height=';
  var res = 'resizable=';
  var scr = 'scrollbars=';

  if (verze >= 4){

    sirkao = screen.width;
    vyskao = screen.height;

    var sirkaz = co.indexOf('x=') + 2;
    var sirkat = co.substr(sirkaz);
    var sirkak = sirkat.indexOf('&');
    if(sirkak > 0){
      var sirka = sirkat.substr(0, sirkak);
    }
    else{
      var sirka = sirkat;
    }

    var vyskaz = co.indexOf('y=') + 2;
    var vyskat = co.substr(vyskaz);
    var vyskak = vyskat.indexOf('&');

    if(vyskak > 0){
      var vyska = vyskat.substr(0, vyskak);
    }
    else{
      var vyska = vyskat;
    }

    sirka = sirka * 1;
    vyska = vyska * 1;

    if((isNaN(sirka) == true) && (isNaN(vyska) == true)){
      var res2cd1 = co.split('_');
      sirka = res2cd1[1];
      var res2cd2 = res2cd1[2].split('.');
      vyska = res2cd2[0];
    }

//    vyska = (vyska * 1) + 30;

  	if(sirka > sirkao){
  	  wih = sirkao;
      resh = 1;
      scrh = 1;
    }
    else{
      wih = sirka;
      resh = 0;
      scrh = 0;
    }

  	if(vyska > (vyskao - 30)){
  	  hih = vyskao;
      resh = 1;
      scrh = 1;
    }
    else{
      hih = vyska;
      if(scrh == 0){
        resh = 0;
        scrh = 0;
      }
    }

    wih = wih * 1;
    hih = hih * 1;

    if(scrh == 1){
      if((wih + 19) < sirkao){
        wih = wih + 19;
      }
      if((hih + 19) < vyskao){
        hih = hih + 19;
      }
    }

    var odshora = (vyskao - hih) / 2;
    if(odshora < 0){
      odshora = 0;
    }

    odboku = (sirkao - wih) / 2;
    if(odboku < 0){
      odboku = 0;
    }

    jak = wi + wih + ', ' + hi + hih + ', ' + res + resh + ', ' + scr + scrh + ', top=' + odshora + ', left=' + odboku;
  }

  if(neww != false){
	  if (typeof(neww.document) == "object"){
		  neww.window.close();
		}
	}

	neww=window.open('',okno,jak);
	neww.document.write("<html>\n<head>\n");
	neww.document.write("<title>"+nazev+"</title>\n</head>\n");
	neww.document.write("<body style=\"margin: 0;\">\n");
	neww.document.write("<div style=\"width: 100%; position: absolute; top: 40%; left: 0px; text-align: center; z-index: 1;\">Please wait ...</div>\n");
	neww.document.write("<a href=\"javascript:window.close()\" style=\"position: absolute; top: 0px; left: 0px; z-index: 2;\"><img src=\""+co+"\" border=\"0\" alt=\""+nazev+"\"></a>\n");
	neww.document.write("</body>\n");
	neww.document.write("</html>");
}

function prihlaseni(url) {
	var w=370;
	var h=280;
	var windowfeatures='toolbar=no, scrollbars=yes, resizable=yes, menubar=no';
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl;
	win = window.open(url, "prihlaseni", winprops+windowfeatures)
	if(parseInt(navigator.appVersion) >= 4){
		win.window.focus();
	}
}

function regwindow(url){
	var w=600;
	var h=400;
	var windowfeatures='toolbar=0, scrollbars=1, resizable=1, menubar=0';
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl;
	win = window.open(url, "registrace", winprops+windowfeatures)
	if(parseInt(navigator.appVersion) >= 4){
		win.window.focus();
	}
}

function appwindow(url, wu, hu, wname){

	var w;
	var h;

  sirkao = screen.width;
  vyskao = screen.height;

  if(wu >= sirkao){wu = (sirkao - 40)}
  if(hu >= vyskao){hu = (vyskao - 50)}

	if(wu > 0){
    w = wu;
  }
  else{
    w = 600;
  }
	if(hu > 0){
    h = hu;
  }
  else{
    h = 400;
  }

  if(wname == ''){
    wname = 'registrace';
  }

  var windowfeatures='toolbar=0, scrollbars=1, resizable=1, menubar=0';
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl;
	win = window.open(url, "registrace", winprops+windowfeatures)
	if(parseInt(navigator.appVersion) >= 4){
		win.window.focus();
	}
}

function appopen(url){
  if(opener == '[object]'){
    window.open(url);
    window.close();
  }
  else{
    parent.location.href=url;
  }
}

function datetoform(datum, kam){
  window.opener.document.getElementById(kam).value = datum;
  window.close();
}


function confirmLink(theLink, theMsg){
    var is_confirmed = confirm(theMsg);
    if (is_confirmed) {
    }
    return is_confirmed;
}
