function Layout() {	
	this.loadLayoutPropForm = function(name, id, bookmarkId, language) {
		if (!name.match("Header")) {
			$('disableBackground').style.display = "block";
			$('loadingCircle').style.display = 'block';
		} else {
			xajax_loadHeaders();
		}

		if (bookmarkId === undefined) {
			xajax_loadLayoutLinks(id, null, name);
		} else {
			xajax_loadLayoutLinks(id, bookmarkId, name, language);
		}
	};
	
	this.closeLayoutPropForm = function(name) {
		$('layouts' + name + 'PropForm').style.display = "none";

		if (name != "Header" || (name == "Header" && 
								 $('HeaderSubmit').value == "Zapisz")) {
			
			$('disableBackground').style.display = "none";
		}
	};
	
	this.restorePropForm = function(form) {
		$A(form.elements).each( function(element) {
			if (element.style.borderColor == "red red red red") {
				element.setStyle({border: "solid 1px gray"});
			}
		});
	};
	
	this.checkLinksForm = function(form) {
		var isError = false;
		this.restorePropForm(form);
		
		$A(form.elements).each( function(element) {
			if (element.type != "select-one" && 
				element.disabled == "" && element.type != "radio"){
				
				if (element.value == "") {
					element.setStyle({border: "solid 1px red"});
					isError = true;
				}
			}
		});
		
		return isError;
	};
	
	this.submitFooterForm = function(id, form, bookmarkId, lang, userId) {		
		if (this.checkLinksForm(form) === true) {
			alert("Uzupełnij brakujące pola");
			return;
		}	
		var propFormValues = [];
		
		if (bookmarkId === undefined || bookmarkId === 0) {

			$A(form.elements).each( function(element) {
				if (element.parentNode.id != "") {
					if (element.type == "select-one" &&
						element.value != "NotSelect") {
						
						propFormValues[element.parentNode.id + element.name] = element.value;
					} else if (element.type != "select-one" && 
								element.disabled == ""){
						
						propFormValues[element.parentNode.id + element.name] = element.value;
					}
				} else if (element.disabled == "" && 
							element.type == "radio" && element.checked) {
					var tempName = "Image";
					if (element.value == "") {
						tempName = "Color";
						propFormValues.footerImage = "";
					}
					
					var field = form[element.name + element.value + "Value"];
					propFormValues['footer' + tempName] = field.value;
				}
			});
			xajax_saveLayoutFooter(id, propFormValues, 0, '', userId);
		} else {
			propFormValues.hideFooter = form.hideFooter.checked;
			if (Prototype.Browser.IE) {
				propFormValues.footerText = form.footerText.innerText;
			} else {
				propFormValues.footerText = form.footerText.getValue();
			}
			
			for (var i = 0; i < form.footerAlignment.length; ++i) {
				if (form.footerAlignment[i].checked === true) {
					propFormValues.footerAlignment = form.footerAlignment[i].value;
					break;
				}
			}
			xajax_saveLayoutFooter(id, propFormValues, bookmarkId, lang);
		}
		this.closeLayoutPropForm('Footer');
		this.dataLoaded = false;
	};
	
	this.submitFooterMarqueeForm = function(id, form, userId) {		
		if (this.checkLinksForm(form) === true) {
			alert("Uzupełnij brakujące pola");
			return;
		}		
		var propFormValues = [];
		
		$A(form.elements).each( function(element) {
			if (element.type == "select-one" && element.value != "NotSelect") {
				propFormValues[element.parentNode.id + element.name] = element.value;
			} else if (element.type != "select-one" && element.disabled == ""){
				propFormValues[element.parentNode.id + element.name] = element.value;
			}
		});

		xajax_saveLayoutFooterMarquee(id, propFormValues, userId);
		this.closeLayoutPropForm('FooterMarquee');
		this.dataLoaded = false;
	};
	
	this.submitBookmarkListProp = function(id, form, userId) {
		if (this.checkLinksForm(form) === true) {
			alert("Uzupełnij brakujące pola");
			return;
		}
		
		var value;
		for (var i = form.bookmarkList.length; i--; ) {
			if (form.bookmarkList[i].checked) {
				value = $(form.bookmarkList[i]).next().value + 
							form.bookmarkList[i].value;
			}
		}
		
		xajax_saveBookmarkListProp(id, value, userId);
	};
	
	this.submitBasicBackgroundProp = function(id, form, userId) {
		if (this.checkLinksForm(form) === true) {
			alert("Uzupełnij brakujące pola");
			return;
		}
		var value;
		for (var i = form.basicBackground.length; i--; ) {
			if (form.basicBackground[i].checked) {
				value = $(form.basicBackground[i]).next().value + 
							form.basicBackground[i].value;
			}
		}
		
		xajax_saveBasicBackgroundProp(id, value, userId);
	};
	
	this.submitPageShadowProp = function(id, form, userId) {
		var values = [];
		
		var elements = form.elements;
		for (var i = elements.length; i--; ) {
			if (elements[i].type != "radio" && 
				elements[i].disabled == "" && 
				!elements[i].name.match("Palette") && 
				elements[i].type != "button") {
				
				var element = elements[i];
				var name = element.name.substr(10, element.name.indexOf("Value") - 10);
				//console.log(name + " = " + element.value);
				values[name] = element.value ? element.value : "transparent";
			}
		}
		
		xajax_savePageShadowProp(id, values, userId);
	};
	
	this.loadPageShadow = function(data, imageSize) {	
		var page = $('page');
		if (page) {
			page.style.visibility = "visible";
		}
		var imageOnLeft  = 0;
		var imageOnRight = 0;
		var element;
		for (var item in data) {
			var isImage = item.match("Image") !== null;
			var width = "5";
			var height = "5";

			if (isImage) {
				data[item] = "/" + data[item];
				var value = imageSize[item];
				width = value.substr(value.indexOf("\"") + 1, 
								value.indexOf(" ") - value.indexOf("\"") - 2);
				value = value.substr(value.indexOf(" ") + 1);
				height = value.substr(value.indexOf("\"") + 1, 
								value.lastIndexOf("\"") - value.indexOf("\"") - 1);
				item = item.substr(0, item.indexOf("Image"));
			}
			
			element = $$(".background" + item)[0];
			if (!element) {
				continue;
			}
			if (isImage) {
				element.style.backgroundImage = "url('http://www.noce.pl/inoce/" + data[item + "Image"] + "')";
				element.style.backgroundColor = "";
			} else {
				element.style.backgroundColor = data[item];
				element.style.backgroundImage = "none";
			}

			if(item.match(/^(Top|Bottom)$/)) {
				element.style.height = height + "px";
			} else if (item.match(/^(Top|Bottom){1}(Left|Right){1}$/)) {
				element.style.height = height + "px";
				element.style.width  = width  + "px";
				
				if (item.match(/^.+Left$/)) {
					element.style.left = 5 - width + "px";
				} else {
					element.style.right = 5 - width + "px";
				}							
			} else if (item.match(/^(Left|Right).+/)) {
				element.style.width  = width  + "px";
				if (item.match(/^Left.+$/)) {
					element.style.left = 5 - width + "px";
					if (isImage && (parseInt(width, 10) > parseInt(imageOnLeft, 10))) {
						imageOnLeft = width;
					}
				} else {
					element.style.right = 5 - width + "px";
					if (isImage && (parseInt(width, 10) > parseInt(imageOnRight, 10))) {
						imageOnRight = width;
					}
				}
			}
		}

		var top = $$('.backgroundTop')[0];
		var bottom = $$('.backgroundBottom')[0];
		var topLeft = $$('.backgroundTopLeft')[0];
		var topRight = $$('.backgroundTopRight')[0];
		var bottomLeft = $$('.backgroundBottomLeft')[0];
		var bottomRight = $$('.backgroundBottomRight')[0];
		
		if (topLeft)
		var marginTop = Math.max(topLeft.offsetHeight, 
								 topRight.offsetHeight, 
								 top.offsetHeight);
		if(bottomLeft)
		var marginBottom = Math.max(bottomLeft.offsetHeight, 
									bottomRight.offsetHeight, 
									bottom.offsetHeight);

		if (Prototype.Browser.IE && 
			!location.href.match("graphic")) {
			
			page.style.position = "relative";
			page.style.top = marginTop + "px";
		}
		
		if(page) {
			page.style.marginTop = marginTop + "px";
			page.style.marginBottom = marginBottom + "px";	
		}
		
		var canvas = $('canvas');
		
		var footer = $('stopka_strony');
		if (!footer) {
			footer = {offsetTop: canvas.offsetTop + canvas.offsetHeight};
		}

		for (item in data) {
//			console.log(item + " = " + data[item]);
			if (item.match("Image")) {
				var name = item.substr(0, item.indexOf("Image"));
				if ($$(".background" + name).length > 0) {
					element = $$(".background" + name)[0];
				}
			} else {
				if ($$(".background" + item).length > 0) {
					element = $$(".background" + item)[0];
				}		
			}

			if(!element) {
//				console.log(item);
				continue;
			}
			
			if(item.match(/^Top.*$/) || item.match(/^Top(Left|Right)$/)) {
				top = page.offsetTop - element.offsetHeight;
				element.style.top = top + "px";		
			} else if(item.match(/^Bottom.*$/) || item.match(/^Bottom(Left|Right)$/)) {
				if (Prototype.Browser.IE && 
					!location.href.match("graphic")) {
					if(footer)
						top = footer.offsetTop + footer.offsetHeight + marginTop;
				} else {
					if(footer)
						top = footer.offsetTop + footer.offsetHeight;
				}
				element.style.top = top + "px";
			}
			
			if (imageOnLeft && item.match(/^(Top|Bottom)Left$/)) {
				element.style.width = imageOnLeft + "px";
				element.style.left  = 5 - imageOnLeft + "px";
			} else if (imageOnRight && item.match(/^(Top|Bottom)Right$/)) {
				element.style.width = imageOnRight + "px";
				element.style.right = 5 - imageOnRight + "px";
			}
			
			var borderWidth = $('bookmarksMenuList').style.borderBottomWidth;
			borderWidth = parseInt(borderWidth.substr(0,1), 10);
			
			if (item.match(/^(Left|Right).+$/)) {
				
				if(item.match(/^.+Upper.*$/)) {
					if (Prototype.Browser.IE && 
						!location.href.match("graphic")) {
	
						element.style.height = 
							canvas.offsetTop - page.offsetTop + marginTop + "px";
					} else {
	
						element.style.height = canvas.offsetTop - page.offsetTop + "px";
//						element.style.height = canvas.offsetTop + "px";
					}
					element.style.top = page.offsetTop + "px";
				} else if (item.match(/^.+Middle(?!Lower).*$/)) {
					if (Prototype.Browser.IE && 
						!location.href.match("graphic")) {
						
						top = canvas.offsetTop + marginTop;
					} else {
						top = canvas.offsetTop - page.offsetTop + marginTop;
					}
					element.style.top = top + "px";
				} else if (item.match(/^.+MiddleLower.*$/)) {
					if (Prototype.Browser.IE && 
						!location.href.match("graphic")) {
						
						element.style.top = canvas.offsetTop + marginTop + 300 + "px";
					} else {
						element.style.top = canvas.offsetTop + 300 + "px";
					}
					if (footer) {
						element.style.height = footer.offsetTop - canvas.offsetTop - 300 + "px";
					}
				} else if (item.match(/^.+Lower.*$/)) {
					if (Prototype.Browser.IE && 
						!location.href.match("graphic")) {
						
						element.style.top = footer.offsetTop + marginTop + "px";
					} else {
						if (footer) {
							element.style.top = footer.offsetTop + "px";
						}
					}
					
					if (footer) {
						element.style.height = footer.offsetHeight + "px";
					}
					
				}
				
				if (imageOnLeft && item.match(/^Left.+(?!Image)$/)) {
					element.style.width = imageOnLeft + "px";
					element.style.left  = 5 - imageOnLeft + "px";
				} else if (imageOnRight && item.match(/^Right.+(?!Image)$/)) {
					element.style.width = imageOnRight + "px";
					element.style.right = 5 - imageOnRight + "px";
				}
			}
			
			
		}		
		
		if (Prototype.Browser.IE && canvas.offsetHeight < 500) {
			canvas.style.height = canvas.offsetHeight + 10 + "px";
		}
		
		if ($('basicBackgroundPropIcon') != null) {
			$('basicBackgroundPropIcon').style.display = 'block';
			$('pageShadowPropIcon').style.display = 'block';
			$('loadingCircle').style.display = "none";
			$('disableBackground').style.display = "none";	
		}	
	};
	
	this.submitLinksForm = function(id, form, bookmarkId, userId) {
		if (this.checkLinksForm(form) === true) {
			alert("Uzupełnij brakujące pola");
			return;
		}
		var propFormValues = [];
		
		$A(form.elements).each( function(element) {
			if (element.parentNode.id != "") {
				if (element.type == "select-one" && element.value != "NotSelect") {
					propFormValues[element.parentNode.id + element.name] = element.value;
				} else if (element.type != "select-one" && element.disabled == ""){
					propFormValues[element.parentNode.id + element.name] = element.value;
				}
			}
		});
				
		if (bookmarkId === undefined || bookmarkId === 0) {
			xajax_saveLayoutLinks(id, propFormValues, 0, userId);
		} else {
			propFormValues.hideLinks = form.hideLinks.checked;
			var inputs = $('chooseLinks').getElementsByTagName("input");
			
			propFormValues.links = [];
			for (var i = inputs.length; i--; ) {
				if (inputs[i].checked) {
					propFormValues.links.push(inputs[i].name);
				}
			}
			
			xajax_saveLayoutLinks(id, propFormValues, bookmarkId);
		}
		this.closeLayoutPropForm('Links');
		this.dataLoaded = false;
	};
	
	this.linksProp = function(data, formName) {
			
		var linksForm	= document.forms.Links;
		var footerForm	= document.forms.Footer;
		var bookmarkListForm = document.forms.bookmarkList;
		var pageShadowForm = document.forms.pageShadow;
		var basicBackgroundForm = document.forms.basicBackground;

		this.restorePropForm(linksForm);
		this.restorePropForm(footerForm);

		var hideLinks;
		var hideFlags;
		var hideFooter;
		var hideMarquee;
		if (document.forms.Links.hideLinks !== undefined) {
			hideLinks = document.forms.Links.hideLinks;
			hideFlags = document.forms.Flags.hideFlags;
			hideFooter = document.forms.Footer.hideFooter;
			hideMarquee = document.forms.FooterMarquee.hideMarquee;
		}
		var temp;
		var name;
		for (var item in data) {
			//console.log(item + " = |" + data[item] + "|");			
			if (item.match("hideLinks") && hideLinks !== undefined) {
				if (data[item] == 'true') {
					hideLinks.checked = "";
					inoce.hideLinksChceckBox(hideLinks);
				} else {
					hideLinks.checked = true;
				}
				temp = data.links;
				var inputs = $('chooseLinks').getElementsByTagName("input");
				for (var i = inputs.length; i--; ) {
					inputs[i].checked = "";
				}
	
				for (var index in temp) {
					inputs[temp[index]].checked = true;
				}
			} else if (item.match("hideFlags") && hideFlags !== undefined) {
				if (data[item] === 'true') {
					hideFlags.checked = "";
				} else {
					hideFlags.checked = true;
				}
			} else if (item.match("hideMarquee") && hideFlags !== undefined) {
				//console.log(item, "[" + data[item] + "]");
				if (data[item] === 'true') {
					hideMarquee.checked = "";
				} else {
					hideMarquee.checked = true;
				}
			} else if (item.match("hideFooter") && hideFooter !== undefined) {
				if (data[item] === 'true') {
					hideFooter.checked = "";
					value = "disabled";					
				} else {
					hideFooter.checked = true;
					value = "";
				}	
				
				for (var j = 0; j < footerForm.elements.length; ++j) {
					var element = footerForm.elements[j];
					if (element.type != "button" && element.type != "checkbox") {
						element.disabled = value;
					}
				}
			} else if (item.match("footerAlignment")) {
				for (var k = 0; k < footerForm.footerAlignment.length; ++k) {
					if (footerForm.footerAlignment[k].value == data[item]) {
						footerForm.footerAlignment[k].checked = true;
						break;
					}
				}
			} else if (item.match("footerText")) {
				$('footerText').innerHTML = data[item];
			} else if (item.match("linksFont")) {
				if (item.match("NotSelect") && item.match("Color")) {
					item = item.substr(0, item.indexOf("NotSelect"));
					data[item] = data[item + "NotSelect"];
				}
				if (linksForm[item.substr(9)].type == "select-one") {
					/*
					 * 
					 * przebiega po wszystkich opcjach pola select 
					 * i jesli wartość opcji jest taka sama jak
					 * wartość zapamiętana w bazie tą ją zaznacza
					 */
					$A(linksForm[item.substr(9)].options).each( function(option){
						if (option.value == data[item]) {
							option.selected = true;
						}
					});
				} else {
					linksForm[item.substr(9)].value = this.ucfirst(data[item]);
					linksForm[item.substr(9)].disabled = "";
					if (item.match("Family")) {
						temp = linksForm[item.substr(9, item.indexOf("NotSelect") - 9)];
						temp.options[temp.options.length - 1].selected = "selected";
					}
				}
			}  else if (item.match("footerFont")) {
				if (item.match("NotSelect") && item.match("Color")) {
					item = item.substr(0, item.indexOf("NotSelect"));
					data[item] = data[item + "NotSelect"];
				}
				if (footerForm[item.substr(10)].type == "select-one") {
					/*
					 * 
					 * przebiega po wszystkich opcjach pola select 
					 * i jesli wartość opcji jest taka sama jak
					 * wartość zapamiętana w bazie tą ją zaznacza
					 */
					$A(document.forms.Footer[item.substr(10)].options).each( function(option){
						if (option.value == data[item]) {
							option.selected = true;
						}
					});
				} else {
					footerForm[item.substr(10)].value = this.ucfirst(data[item]);
					footerForm[item.substr(10)].disabled = "";
					if (item.match("Family")) {
						temp = footerForm[item.substr(10, item.indexOf("NotSelect") - 10)];
						temp.options[temp.options.length - 1].selected = "selected";
					}
				}
			} else if (item.match("footerMarqueeFont")) {
				//console.log(item + " = " + data[item]);
				if (item.match("NotSelect") && item.match("Color")) {
					item = item.substr(0, item.indexOf("NotSelect"));
					data[item] = data[item + "NotSelect"];
				}
				var form = document.forms.FooterMarquee;
				if (form[item.substr(17)].type == "select-one") {
					/*
					 * 
					 * przebiega po wszystkich opcjach pola select 
					 * i jesli wartość opcji jest taka sama jak
					 * wartość zapamiętana w bazie tą ją zaznacza
					 */
					$A(document.forms.FooterMarquee[item.substr(17)].options).each( function(option){
						if (option.value == data[item]) {
							option.selected = true;
						}
					});
				} else {
					form[item.substr(17)].value = this.ucfirst(data[item]);
					form[item.substr(17)].disabled = "";
					if (item.match("Family")) {
						temp = form[item.substr(17, item.indexOf("NotSelect") - 17)];
						temp.options[temp.options.length - 1].selected = "selected";
					}
				}
			} else if (item.match("footerImage")) {
				if (data[item] != "") {
					footerForm.footerPictureValue.value	= this.ucfirst(data[item]);
					footerForm.footer[1].checked = true;
					footerForm.footerPictureValue.disabled = "";
					footerForm.footerPicturePalette.disabled = "";
					footerForm.footerValue.disabled = "disabled";
					footerForm.footerPalette.disabled = "disabled";
				} else {
					footerForm.footerValue.value	= this.ucfirst(data.footerColor);
				}
			} else if (item.match("bookmarkList")) {
				if (data[item] == "") {
					continue;
				}
				name = item;
				if (item.match("Color")) {
					name = item.substr(0, item.indexOf("Color"));
				} else if (item.match("Image")) {
					name = item.substr(0, item.indexOf("Image")) + "Picture";
					for (var z = bookmarkListForm.bookmarkList.length; z--; ) {
						if (bookmarkListForm.bookmarkList[z].value == "Picture") {
							bookmarkListForm.bookmarkList[z].checked = true;
							bookmarkListForm.bookmarkListPalette.disabled = "disabled";
							bookmarkListForm.bookmarkListPicturePalette.disabled = "";
							bookmarkListForm.bookmarkListValue.disabled = "disabled";
							bookmarkListForm.bookmarkListPictureValue.disabled = "";
						}
					}
				}
				name += "Value";
				bookmarkListForm[name].value = data[item];
				
			} else if (item.match("pageShadow")) {
				if (data[item] == "") {
					continue;
				}
				
				var shadow = data[item];
				for (var index2 in shadow) {
					if (item.match("Image")) {
						pageShadowForm["pageShadow" + index2 + "PictureValue"].value = shadow[index2];
						pageShadowForm["pageShadow" + index2 + "PictureValue"].disabled = "";
						pageShadowForm["pageShadow" + index2 + "PicturePalette"].disabled = "";
						pageShadowForm["pageShadow" + index2 + "Value"].disabled = "disabled";
						pageShadowForm["pageShadow" + index2 + "Palette"].disabled = "disabled";
						pageShadowForm["pageShadow" + index2][1].checked = true;
					} else {
						pageShadowForm["pageShadow" + index2 + "Value"].value = shadow[index2];
					}
					
				}
			} else if (item.match("basicBackground")) {
				if (data[item] == "") {
					continue;
				}
				name = item;
				if (item.match("Color")) {
					name = item.substr(0, item.indexOf("Color"));
					basicBackgroundForm.basicBackgroundPictureValue.value = "";
				} else if (item.match("Image")) {
					name = item.substr(0, item.indexOf("Image")) + "Picture";
					for (var s = basicBackgroundForm.basicBackground.length; s--; ) {
						if (basicBackgroundForm.basicBackground[s].value == "Picture") {
							basicBackgroundForm.basicBackground[s].checked = true;
							basicBackgroundForm.basicBackgroundPalette.disabled = "disabled";
							basicBackgroundForm.basicBackgroundPicturePalette.disabled = "";
							basicBackgroundForm.basicBackgroundValue.disabled = "disabled";
							basicBackgroundForm.basicBackgroundPictureValue.disabled = "";
							basicBackgroundForm.basicBackgroundValue.value = "";
						}
					}
				}
				name += "Value";
				basicBackgroundForm[name].value = data[item];
				
			}
		}
		
		$('layouts' + formName + 'PropForm').style.display = "block";
		$('loadingCircle').style.display = 'none';
	};
	
	this.saveLayoutHeader = function (id, form, userId) {
		header = "";
		for (i = 0; i < form.elements.length - 1; i++) {
			if (form[i].checked === true) {
				header = form[i].value;
				break;
			}
		}
		
		this.closeLayoutPropForm('Header');
		
		if (header != "") {
			xajax_saveLayoutHeader(id, header, userId);
		}
	};
	
	this.sendNewHeader = function(form, file) {
		xajax_loadHeaders(form.id.value, form.type.value, form.tekst.value, form.path.value, file);
	};
	
	this.createNewFolder = function(form) {
		var name = form.newFolder.value;
		if (name != "") {
			xajax_createNewFolder(form.path.value + name, form.id.value, form.type.value, form.tekst.value);
		}
	};
	
	this.refreshDir = function(id, type, text, dir) {
		xajax_loadHeaders(id, type, text, dir);
	};
	
	this.saveLayoutFlagsChange = function(form, id, userId) {
		if (this.checkLinksForm(form) === true) {
			alert("Uzupełnij brakujące pola");
			return;
		}
		var propFormValues = [];
		
		for (var e = form.elements.length; e--; ) {
			if (form.elements[e].type == "text") {
				var element = form.elements[e];
				propFormValues[element.name] = element.value;
			}
		}
		xajax_saveLayoutFlagsChange(propFormValues, id, userId);
	};
	
	this.hideMarqueeForm = function(bookmarkId, form) {
		var value = form.hideMarquee.checked;
		xajax_hideMarqueeForm(bookmarkId, value);
	};
	
	this.ucfirst = function (str) {
		var f;
		if (str.indexOf("Grafika") == -1 && str.indexOf("grafika") == -1) {
			f = str.charAt(0).toUpperCase();
		} else {
			f = "g";
		}
		return f + str.substr(1);
	};
	
	this.popupWindow = function (language, category, subCategory, objectId, tid, hash) {
		var options  = "width=610, height=840, toolbar=no, status=no, ";
			options += "fullscreen=no, maximize=yes, menubar=no, scrollbars=yes, ";
			options += "resizable=yes, location=no, directories=no, location=no";
		var url;
		if (window.location.href.match(".*\/in\/.*") || 
			window.location.href.match(".*\/inoce\/.*")) {
			
			url = "szczegoly_popup.php?tid=" + tid + "&lang=" + language;
		} else {
			url = "szczegoly_popup.php?tid=" + tid + "&lang=" + language;
		}
			
		
		url += "&k=" + category;
		url += "&pk=" + subCategory;
		url += "&ido=" + objectId;
			
		if (hash !== null) {
			url += "#" + hash;
		}
			
		var noweOkno = window.open(url, '_blank', options);
		noweOkno.moveTo(80, 50);
		noweOkno.focus();	
	};
	
	this.test = function(event) {
		if (typeof event != 'string'){
			var event = event || window.event;
			var target = event.target || event.srcElement;
		}

		var options  = "width=610, height=840, toolbar=no, status=no, ";
			options += "fullscreen=no, maximize=yes, menubar=no, scrollbars=yes, ";
			options += "resizable=yes, location=no, directories=no, location=no";
			
		var href = "";
		if (typeof event != 'string') {
			if (target.href != null && target.nodeName != "IMG") {
				href = target.href;
			} else {
				href = target.parentNode.href;
			}
		} else {
			href = event;
		}
		
		var noweOkno = window.open(href, 'test', options);
		noweOkno.moveTo(80, 50);
		noweOkno.focus();	
		
		if (event.preventDefault) event.preventDefault();
		return false;
	}
	
	this.popupWindow2 = function (language, objectId, tid) {
		var options  = "width=590, height=840, toolbar=no, status=no, ";
			options += "fullscreen=no, maximize=yes, menubar=no, scrollbars=yes, ";
			options += "resizable=yes, location=no, directories=no, location=no";
		var url;
		if (window.location.href.match(".*\/in\/.*") || 
			window.location.href.match(".*\/inoce\/.*")) {
				
			url  = "http://www.noce.pl/inoce/caly_kal.php?tid=" + tid + "&lang=" + language;
		} else {
			url  = "http://www.noce.pl/inoce/caly_kal.php?tid=" + tid + "&lang=" + language;
		}	
			
		url += "&id=" + objectId;
			
		var noweOkno = window.open(url, '_blank', options);
		noweOkno.moveTo(600, 50);
		noweOkno.focus();	
	};
}

var layout = new Layout();
