/* funkce
 *
 */

function validateDate(str)
{
	$parts=str.split('.');
	if($parts.length!=3) return false;
	if($parts[0]<1 || $parts[0]>31) return false
	if($parts[1]<1 || $parts[1]>12) return false
	if($parts[2]<1000 || $parts[2]>3000) return false
	return true;
}

function getkey(e)
{ 
  var code; 
  if (!e)
    var e = window.event; // nastaveni pro IE
  if (e.keyCode)
    code = e.keyCode; // IE a Mozilla
  else
    if (e.which)
      code = e.which; // NN4
  return code; 
} 

function numerickeys(eX)
{
  test=getkey(eX);
  if (test<48 || test>57)
    return false;
}

function datekeys(eX)
{
  test=getkey(eX);
  if ((test>=48 && test<=57) || test==46 || test==32)
    return true;
  return false;
}



function validateRegExp(string, regexp)
{
    regExp = new RegExp([regexp]);
    if(!regExp.test(string))  
       return false;
    return true; 
}
function validateEmail(form)
{
	    f=form.fEmail; if(!f.value) { alert("Zadejte e-mailovou adresu."); f.focus(); return false;}
	    f=form.fEmail; if(f.value && !validateRegExp(f.value,'^[_a-zA-Z0-9\.\-]+@[_a-zA-Z0-9\.\-]+\.[a-zA-Z]{2,4}$')) { alert("Zadaný e-mail má neplatný formát."); f.focus(); return false;}
	    return true;
} 

// vrati rozliseni plochy prohlizece
function getSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement &&
      ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  return [myWidth, myHeight];
} 

function detail(file,w,h)
{
   url = "detail.php?pic=" + file + "&amp;w=" + w + "&amp;h=" + h;
   w = parseInt(w);
   h = parseInt(h);
   roz = getSize();
   l = (roz[0]-w)/2;
   t = (roz[1]-h)/2;
   window.open(url,'okno','toolbar=0,menubar=0,location=no,directories=no,scrollbars=no,resizable=0,status=no,left='+l+',top='+t+',width='+w+',height='+h);
}


