function getURLParam(strParamName){
  var strReturn = "";
  var strHref = window.location.href;
  if ( strHref.indexOf("?") > -1 ){
    var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
    var aQueryString = strQueryString.split("&");
    for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
      if (
aQueryString[iParam].indexOf(strParamName + "=") > -1 ){
        var aParam = aQueryString[iParam].split("=");
        strReturn = aParam[1];
        break;
      }
    }
  }
  return strReturn;
}

function getWindowSize() {
	if (typeof(window.innerWidth) == 'number') {
	   	return Array(window.innerWidth, window.innerHeight);
	} else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
		return Array(document.documentElement.clientWidth, document.documentElement.clientHeight);
	} else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
		return Array(document.body.clientWidth, document.body.clientHeight);
	} else {
		return Array(0, 0);
	}	
}

function getWindowScroll() {
	if (typeof(window.pageYOffset) == 'number') {
		return Array(window.pageXOffset, window.pageYOffset);
	} else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) {
		return Array(document.body.scrollLeft, document.body.scrollTop);
	} else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
		return Array(document.documentElement.scrollLeft, document.documentElement.scrollTop);
	} else {
		return Array(0, 0);	
	}
}

function showFoto(id) {
	var e = document.getElementById('fotoPopup');
	if (e) {
		var imgLoad = document.createElement('img');
			imgLoad.onload = function () {
				while (e.firstChild) e.removeChild(e.firstChild);
				e.appendChild(imgLoad);
				showPopup();
				sizePopup();				
			}
			imgLoad.src = dirPath + '_loading.gif';	

		var imgFoto = new Image();
			imgFoto.onload = function () {
				while (e.firstChild) e.removeChild(e.firstChild);
				e.appendChild(imgFoto);
				sizePopup();
			}
			imgFoto.src = dirPath + 'foto/' + id + '.jpg';
	}
	
}

function sizePopup() {
	var e = document.getElementById('fotoPopup');
	if (e) {
		var siz = getWindowSize();
		var scr = getWindowScroll();
		e.style.left = ( (siz[0] / 2) - (e.clientWidth  / 2) + scr[0] ) + 'px';
		e.style.top  = ( (siz[1] / 2) - (e.clientHeight / 2) + scr[1] ) + 'px';
	}
}

function showPopup() {
	var e = document.getElementById('hideWindow');
	if (e) {
		var size = getWindowSize();
		var main = document.getElementById('mainContainer');			
		var sizeX = (main.offsetWidth  > size[0] ? main.offsetWidth  : size[0]);
		var sizeY = (main.offsetHeight > size[1] ? main.offsetHeight : size[1]);		
		e.style.width   = '100%';
		e.style.height  = sizeY + 'px';		
		e.style.display = 'block';
	}	
	var e = document.getElementById('fotoPopup');
	if (e) {
		e.style.display = 'block';
	}
}

function hidePopup() {
	var e = document.getElementById('hideWindow');
	if (e) {
		e.style.display = 'none';
	}	
	var e = document.getElementById('fotoPopup');
	if (e) {
		e.style.display = 'none';
	}
}
