var isIE=false;
function IE()
{
  ua = navigator.userAgent;

  s = "MSIE";
  if ((i = ua.indexOf(s))) {
    document.write("<link href='../css/ie.css' rel='stylesheet' type='text/css' media='all' />");
    isIE=true;
  }
}

IE();

function menu(elementName, display)
{
  if(isIE)
  {
    document.getElementById(elementName).style.visibility=display?'visible':'hidden';
  }
}

function validateRegExp(string, regexp)
{
    regExp = new RegExp([regexp]);
    if(!regExp.test(string))  
       return false;
    return true; 
}

function validateFormContact(form)
{
	    f=form.fJmeno; if(!f.value) { alert("Zadejte jméno."); f.focus(); return false;}
	    f=form.fPrijmeni; if(!f.value) { alert("Zadejte příjmení."); f.focus(); return false;}
	    f=form.fTelefon; if(!f.value) { alert("Zadejte telefon."); f.focus(); return false;}
	    f=form.fTelefon; if(!validateRegExp(f.value,'^[\+]{0,1}[ 0-9]{6,30}$')) { alert("Telefonní číslo má neplatný formát."); 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;}
	    f=form.fText; if(!f.value) { alert("Zadejte text zprávy."); 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);
}


