﻿
function showImg(id, width, height)
{
    width += 50;
    height+= 50;
    
    if(height + 50 > screen.height)
        height= screen.height- 200;

    if(width + 50 > screen.width)
        width = screen.width - 100;
        
    x = (screen.width  -  width) / 2;
    y = (screen.height - height) / 2;
    
    var a = window.open("imgDetail.aspx?imgid=" + id,"imgDialog","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,left="+x+",top="+y+",resizable=yes,width="+(width)+",height="+(height));
}


function toggleFilter()
{
    try {
    s = m$("madv");
    fa= m$("filtrAdvance");
    a = m$('fArrow');
    
	if	(s.value == "1") {
		fa.style.display = "none";
		s.value = "0";
		a.innerHTML = ">>";
	}
	else
	{
		fa.style.display = "block";
		s.value = "1";
		a.innerHTML = "<<";
	}
	} catch(e){}
}

function m$() {
  var elements = new Array();

  for (var i = 0; i < arguments.length; i++) {
    var element = arguments[i];
    if (typeof element == 'string')
      element = document.getElementById(element);

    if (arguments.length == 1)
      return element;

    elements.push(element);
  }

  return elements;
};


function checkNews()
{
	var x = m$("nemail").value;	
	if (x != null)
	{			
		var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (!filter.test(x))
		{		
			alert('Chybný formát!');
			return false;
		}
	}					
    return true;
};


/*----- ZJISTENI DRUHU PROHLIZECE (imgDetail.xsl)-----*/
function browser() {
  var userAgent = navigator.userAgent.toLowerCase();
  if (userAgent.indexOf("msie") != -1) {
      return "ie";
  }
  else if (userAgent.indexOf("firefox") != -1) {
      return "firefox";
  }
  else if (userAgent.indexOf("opera") != -1) {
      return "opera";
  }
  else return "other";
};

/*----- DODATECNA ZMENA OKNA OBRAZKU (imgDetail.xsl) -----*/
function remanipulator(width, height) {
  if (height + 50 > screen.height)
      height = screen.height - 200;
  if (width + 50 > screen.width)
      width = screen.width - 100;

  posX = (screen.width - width) / 2;
  posY = (screen.height - height) / 2;

  // pozor: Nejdriv premistit a potom teprve zvetsovat (aby bylo na obrazovce dost mista)
  window.moveTo(posX, posY);

  /* zmena velikosti okna podle prohlizecu */
  if (browser() == "ie") {
      window.resizeTo(width - 42, height - 35);
  }
  else if (browser() == "firefox") {
      window.resizeTo(width - 40, height + 0);
  }
  else if (browser() == "opera") {
      window.resizeTo(width - 40, height + 0);
  }
  else {
      window.resizeTo(width, height);
  }
};

// Validace e-mailu
function validateEmail(str) {
    var regex = new RegExp(/[a-zA-Z0-9._-]+@[a-zA-Z0-9_-]+\.[a-zA-Z0-9_.-]*[a-zA-Z]/);

    if (regex.test(str) == true) {
        return true;
    }
    else {
        alert("Chybný formát e-mailu!");
        document.getElementById("nemail").focus();
        return false;
        
    }
}
