/**
 * show / hide filter options
 */
function filter_toggle(filter, toggler, fieldset) {

	/**
	 * switch current status
	 */
	switch (document.getElementById(filter).style.display) {

		/**
		 * filter shown - hide it, change toggler innerHTML and title, hide
		 * fieldset border
		 */
		case "block":
			document.getElementById(filter).style.display = "none";

			document.getElementById(toggler).innerHTML = "+ zobrazit filtr";
			document.getElementById(toggler).title = "Zobrazit možnosti filtrování";
			document.getElementById(toggler).blur();

			document.getElementById(fieldset).style.border = "none";
			document.getElementById(fieldset).style.padding = "0";
			break;

		/**
		 * filter hidden
		 */
		case "none":
			document.getElementById(filter).style.display = "block";

			document.getElementById(toggler).innerHTML = "- schovat filtr";
			document.getElementById(toggler).title = "Schovat možnosti filtrování";
			document.getElementById(toggler).blur();

			document.getElementById(fieldset).style.border = "1px #dedede solid";
			document.getElementById(fieldset).style.padding = "15px";
			break;
	}

	/**
	 * always return false
	 */
	return false;
}


/**
 * function flyer_overlay
 *
 * display overlay with image in the middle
 *
 * @param int image_width "image width in pixels"
 * @param int image_height "image height in pixels"
 * @param strin image_location "image location" 
 */
function flyer_overlay(image_width, image_height, image_location) {
	var width = 0;
	var height = 0;

	/**
	 * get referrer
	 */
	var ref = document.referrer;

	/**
	 * continue only of referrer does not contain "studio54.cz"
	 */
	if (ref.indexOf("starelazne.cz") == -1) {

		/**
		 * get window height
		 */
		if (typeof(window.innerWidth) == "number" ) {
			width = window.innerWidth;
			height = window.innerHeight;
		} else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
			width = document.documentElement.clientWidth;
			height = document.documentElement.clientHeight;
		} else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
			width = document.body.clientWidth;
			height = document.body.clientHeight;
		}

		/**
		 * create overlay above visible page area
		 */
		var overlay = document.createElement("div");
		overlay.style.position = "fixed";
		overlay.style.width = width + "px";
		overlay.style.height = height + "px";
		overlay.style.top = "0";
		overlay.style.left = "0";
		overlay.style.backgroundColor = "#000";
		overlay.style.opacity = "0.7";
		overlay.style.filter = "alpha(opacity=70)";
		overlay.style.cursor = "pointer";
		document.body.appendChild(overlay);

		/**
		 * append banner image
		 */
		var top = (height - image_height) / 2;
		var left = (width - image_width) / 2;
		var banner = document.createElement("img");
		banner.src = image_location;
		banner.style.position = "fixed";
		banner.style.top = (top) + "px";
		banner.style.left = ((left >= 0) ? left : 0) + "px";
		banner.style.border = "1px #fff solid";
		banner.style.zIndex = "500";
		banner.style.cursor = "pointer";
		document.body.appendChild(banner);

		/**
		 * click function for banner and overlay
		 */
		banner.onclick = function() {
			document.body.removeChild(banner);
			document.body.removeChild(overlay);
			document.body.removeChild(close);
		}

		overlay.onclick = function() {
			document.body.removeChild(banner);
			document.body.removeChild(overlay);
			document.body.removeChild(close);
		}
	}
}