	var newWindow;
	var helpWindow;
	var generalHelpWindow;
	var searchFieldWindow;
	
	function openWindow(url, width, height, name, scrollbars, isGeneralHelp)
	{
		var x = Math.round((screen.availWidth - width) / 2);
		var y = Math.round((screen.availHeight - height) / 2);
		var featureString = 'left=' + x + ',top=' + y + ',width=' + width + ',height=' + height + ',resizable=yes,scrollbars=' + scrollbars;

		if (name=='searchField') {
		   if(!window.searchFieldWindow)
				searchFieldWindow = window.open(url, name, featureString);
			else if (searchFieldWindow.closed)
				searchFieldWindow = window.open(url, name, featureString);
			else {
				searchFieldWindow.close();
				searchFieldWindow = window.open(url, name, featureString);
			}				
			if (window.focus) 
				searchFieldWindow.focus();
		   return false;
		}
		
		
		if (isGeneralHelp) {
			if(!window.generalHelpWindow)
				generalHelpWindow = window.open(url, name, featureString);
			else if (generalHelpWindow.closed)
				generalHelpWindow = window.open(url, name, featureString);
				
			if (window.focus) 
				generalHelpWindow.focus();
		}
		else if (url.match("/relHelp/")!= null) {
			if(!window.helpWindow)
				helpWindow = window.open(url, name, featureString);
			else if (helpWindow.closed)
				helpWindow = window.open(url, name, featureString);
				
			if (window.focus) 
				helpWindow.focus();
		}
		else {	
			if(!window.newWindow)
				newWindow = window.open(url, name, featureString);
			else if (newWindow.closed)
				newWindow = window.open(url, name, featureString);
				
			if (window.focus) 
				newWindow.focus();
		}
		return false;
	}
	
	function openObjSearch(url, width, height, name, scrollbars, isGeneralHelp)
	{
		var filtrai = "";
		for (var i = 0; i < 20; i++)
		{
			var filter = document.getElementsByName('filter.area.c' + i);
			if (filter.length > 0)		// filtras egzistuoja
				if (filter[0].checked)
					filtrai += 'C' + i + ',';
		}
		if (filtrai != "")
			url +=  '&filter=' + filtrai.substring(0, filtrai.length-1);
		openWindow(url, width, height, name, scrollbars, isGeneralHelp);
	}