function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function open_win(url, winWidth, winHeight, winRes) {
  if (winRes==1) { stat="resizable=1,scrollbars=1"; }
            else { stat="resizable=0,scrollbars=0"; };
  // calculate centered window position
  winLeft = Math.round((screen.width-winWidth)/2);
  winTop  = Math.round((screen.availHeight-winHeight)/2);
  winDef = "left="+winLeft+",top="+winTop+",height="+winHeight+",width="+winWidth+",directories=no,location=no,menubar=no,status=no,toolbar=no,"+stat;
  window.open(url, "", winDef);
  return true;
  }
  
var poc = 0;
var iwinTitle = document.title;
var lineCount = 1;
var lineHeight = 20;

function in_ff() {
  var agt=navigator.userAgent.toLowerCase();
  var firefox = (agt.indexOf("firefox") != -1);
  return firefox;
  }

function showImage(imgName, imWidth, imHeight, iTitle, iLines) { 
      if (poc!==0) { iwin.close(); }; 

      url = imgName;
      resStr = "resizable=0,scrollbars=0";
                                                             
      if (iLines) { 
        lineNum = iLines;
        } else {
        lineNum = lineCount;
        } 

      // define window oversize
      if (in_ff()) {
        winPlusWidth = 15;
        winPlusHeight = 35+(iLines-1)*lineHeight;
        } 
      else {
        winPlusWidth = 0;
        winPlusHeight = 20+(iLines-1)*lineHeight;
        }
      // calculate window size
      winHeight = imHeight + winPlusHeight;
      winWidth = imWidth + winPlusWidth;
      // test if the window is not too large
			heightOK = true;
      if (winHeight>screen.availHeight)
        { winHeight = screen.availHeight-80;
      	  resStr=",resizable=1,scrollbars=1";
    			heightOK = false;
      	}
      if (heightOK==false)
        { winWidth = winWidth+22;
      	}								 
      if (winWidth>screen.width)
        { winWidth = screen.width-80;
      	  resStr=",resizable=1,scrollbars=1";
      	}								 

      // calculate centered window position
      winLeft = Math.round((screen.width-winWidth)/2);
      winTop  = Math.round((screen.availHeight-winHeight)/2);

      iwin = window.open("", "", "left="+winLeft+",top="+winTop+",height="+winHeight+",width="+winWidth+",directories=no,location=no,menubar=no,status=no,toolbar=no"+resStr);
      iwin.document.write("<html><head><title>", iwinTitle, "</title>");
      iwin.document.write("<link rel='stylesheet' type='text/css' href='/imgwin.css' title='formal'>");
      iwin.document.write("</head>");
      iwin.document.write("<body class=ImgShow>");
      iwin.document.write("<a href='' onClick=\"window.close(); return false;\"><img width=", imWidth," height=", imHeight," src=\"", url, "\" alt='' border=0></a>");
      iwin.document.write("<p>", iTitle);
      iwin.document.write("</body></html>");
      poc++;
      return true;
    }

function check_search(fld) {
  if (fld.value.length<2) {
    alert('Zadejte alespoň 2 znaky.')
    fld.focus();
    return false;
    };
  }


function bodyload() {
  stretch_pool();
  }

var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;
var vyska_zbytku = (isIE ? 193 : 215);
function stretch_pool() {
  vyska_poolu = document.getElementById('pool').offsetHeight;
  vyska_body = document.body.offsetHeight;
  vyrez_okna = ((isIE) ? document.body.clientHeight : window.innerHeight);
  if ((vyska_poolu+vyska_zbytku)<vyrez_okna) {
    document.getElementById('pool').style.height = (vyrez_okna - vyska_zbytku)+'px';
    }
  }

function check_dotaz()
{
  // regularni vyrazek pro mail
  var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/

  if (document.getElementById('dotaz').value == '') {
    alert ('Nemáte vyplněný vlastní dotaz ke zboží...');
    document.getElementById('dotaz').focus();
    return false;
  }
  if (document.getElementById('tazatel').value == '') {
    alert ('Nemáte vyplněné své jméno...');
    document.getElementById('tazatel').focus();
    return false;
  }
  if (document.getElementById('adresa').value == '') {
    alert ('Nemáte vyplněnou e-mailovou adresu...');
    document.getElementById('adresa').focus();
    return false;
  }
  if (!re.test(document.getElementById('adresa').value)) {
    alert ('Zadaná e-mailová adresa není platná...');
    document.getElementById('adresa').focus();
    return false;
  }  
  if (document.getElementById('vysledek').value == '') {
    alert ('Zadejte kontrolní kód...');
    document.getElementById('vysledek').focus();
    return false;
  }  
  return true;
}

