
initWcmPortalFrameworkNamespace = function(pubOriginalServletUrl, pvtOriginalServletUrl, pubContentPageUrl, pvtContentPageUrl, wcmPathParamName, siteAliases) {

	console.debug("initWcmPortalFrameworkNamespace begin..");
	if (typeof geminisystems == "undefined") {

		geminisystems = {
			consts: {
				// constants to be set by first rendered WCM portlet
				HOMEPAGE_UID: null,
				BREADCRUMB_DELIMITER: null,
				WCM_PATH_ROOT: null,
				WCM_PATH_PARAM: null,
				WCM_SERVLET_URL: null,
				WCM_ORIGINAL_SERVLET_URL: null,
				WCM_CONTENT_PAGE: null,
				WAIT_IMG_URL: null,
				WAIT_TITLE_TEXT: null,
				WCM_TITLE_IDPREFIX: 'portletWcmTitle_' ,
				WCM_CONTENT_IDPREFIX: 'portletWcmContent_' ,
				CLASS_USE_SAME_CONTENT_PLACE: 'wcmUseSameContentPlace',
				CLASS_WCM_ORIGINAL_LINK: 'wcmOriginalLink',
				CLASS_NONWCM_ORIGINAL_LINK: 'nonwcmOriginalLink',
				THIS_SITE_ALIASES: null
			}, param: {
				wcmPath: null,
				wcmTags: null
			},
			func: {},
			handler: {
				wcmFrameworkReady: null,
				mainContentLoaded: null
			}
		};
	}

	if (pubContentPageUrl && pvtContentPageUrl && null == geminisystems.consts.WCM_CONTENT_PAGE) {
		if (window.location.pathname.include('/myportal')) {
			geminisystems.consts.WCM_ORIGINAL_SERVLET_URL = pvtOriginalServletUrl;
			geminisystems.consts.WCM_CONTENT_PAGE = pvtContentPageUrl;
		} else {
			geminisystems.consts.WCM_ORIGINAL_SERVLET_URL = pubOriginalServletUrl;
			geminisystems.consts.WCM_CONTENT_PAGE = pubContentPageUrl;
		}
	}

	if (wcmPathParamName && null == geminisystems.consts.WCM_PATH_PARAM) {
		geminisystems.consts.WCM_PATH_PARAM = wcmPathParamName;
	}

	if (siteAliases) {
		geminisystems.consts.THIS_SITE_ALIASES = siteAliases;
	}

	geminisystems.handler.wcmFrameworkReady = function(url) {}
	geminisystems.handler.mainContentLoaded = function(container) {}

	geminisystems.func.isDynamicPage = function(url) {
		// make URL relative to the site, but an absolute path
		url = url.replace(/^http:\/\/[^\/]+/, '');
		var isDynamic = (url.startsWith(geminisystems.consts.WCM_CONTENT_PAGE));
		//console.debug('=== it is ' + (isDynamic ? 'DYNAMIC'  : 'STATIC') + ' PAGE ===');
		//console.debug('=== content page URL: ' + geminisystems.consts.WCM_CONTENT_PAGE);
		//console.debug('===    this page URL: ' + url);
		return isDynamic;
	}

	geminisystems.func.isAnotherSite = function(url) {
		// strip everything besides protocol, site and port
		url = url.gsub(/(^http:\/\/[^\/]+\/).*/, '#{1}');
		var aliases = $A(geminisystems.consts.THIS_SITE_ALIASES);
		aliases.push(document.URL);

		var isAnother = true;
		for (var i=0; i<aliases.size(); i++) {
			if (aliases[i].startsWith(url)) {
				//console.debug('isAnotherSite: ..BINGO!!! site is: ' + aliases[i]);
				isAnother = false;
				break;
			}
		}
		//var isAnother = !document.URL.startsWith(url);
		if (isAnother) {
			console.debug("=== it's ANOTHER SITE URL = " + url);
			console.debug('===      new  URL: ' + url);
			console.debug('=== this page URL: ' + document.URL);
		}
		return isAnother;
		//return false;
	}

	geminisystems.func.reorderWcmParams = function(paramStr) {
	    if (-1 == paramStr.indexOf('&')) return paramStr;

	    var params = paramStr.substring(1).split('&');
	    for (var i=0; i< params.length; i++) {
	        if (0 == params[0].indexOf(geminisystems.consts.WCM_PATH_PARAM)) {
	            break;
	        }
	        var param = params.shift();
	        params.push(param);
	    }
	    return '?'+params.join('&');
	}
	
	geminisystems.func.putWcmContentToPortlet = function(portletNs, wcmPath, titlePrefix, preprocess, postprocess) {
		console.debug("putWcmContentTo: wcmPath = " + wcmPath);
		//console.debug("geminisystems.consts.WCM_SERVLET_URL = " + geminisystems.consts.WCM_SERVLET_URL);

		if (geminisystems.consts.WAIT_IMG_URL) {
			//console.debug("put WAIT_IMG_URL '" + geminisystems.consts.WAIT_IMG_URL + "' to portletNs '" + portletNs + "'");
			geminisystems.func.setPortletContent(portletNs, '<img src="' + geminisystems.consts.WAIT_IMG_URL + '">');
		}
		if (null != geminisystems.consts.WAIT_TITLE_TEXT) {
			//console.debug("put WAIT_TITLE_TEXT '" + geminisystems.consts.WAIT_TITLE_TEXT + "' to portletNs '" + portletNs + "'");
			geminisystems.func.setPortletTitle(portletNs, geminisystems.consts.WAIT_TITLE_TEXT);
		}
		if (preprocess) preprocess();

		wcmPath = geminisystems.func.fixWcmParamDelimiters(wcmPath);

		//if (wcmPath.include('&')) {
		//	wcmPath = wcmPath.substring(0, wcmPath.indexOf('&'));
		//}

		if (!titlePrefix) titlePrefix = "";

		// get metadata
		new Ajax.Request(geminisystems.consts.WCM_SERVLET_URL + '?'
				+ geminisystems.consts.WCM_PATH_PARAM + '='
				+ wcmPath, {
				method: 'get',
				onSuccess: function(transport) {
					// get JSON response
					var response = transport.responseText.evalJSON();
					// setup portlet content
					if(response.error) {
						console.debug('CONTENT LOADING ERROR: ' + response.error);
						geminisystems.func.setPortletContent(portletNs, '<pre>' + response.error + '</pre>');
						return;
					}
					geminisystems.func.setPortletContent(portletNs, response.content);
					// setup portlet title
					if (0 < $A(response.pathNodes).size()) {
						geminisystems.func.setPortletTitle(portletNs,
							geminisystems.func.buildTitle(titlePrefix, $A(response.pathNodes).last().title)
						);
					}
try {
//console.debug('=== begin DoJo REPARSE!!!');
					dojo.parser.parse();
//console.debug('=== ..end DoJo REPARSE!!!');
} catch(e) {
	console.debug('=== DoJo REPARSE EXCEPTION: ' + e);
}
					if (postprocess) postprocess(response);
					geminisystems.handler.mainContentLoaded(
						geminisystems.func.portletContainerByNs(portletNs).content
					);
				},
				onFailure: function(transport) {
					console.debug('content loading failure');
				}
			});

	}

	geminisystems.func.buildTitle = function(prefix, title) {
		var str = null;
		if (prefix.match(/[:-]\s*$/))
			str = prefix + title;
		else if (prefix)
			str = prefix;
		else
			str = title;
		//console.debug('buildTitle result: ' + str);
		return str;
	}

	geminisystems.func.portletContainerByNs = function(portletNs) {
		var portletId = portletNs.substring('PC_'.length, portletNs.length-'_'.length);
		//console.debug("portletContainerByNs: portletNs = '" + portletNs + "', portletId = '" + portletId + "'");
		var portlet = {
			title: $(geminisystems.consts.WCM_TITLE_IDPREFIX + portletId),
			content: $(geminisystems.consts.WCM_CONTENT_IDPREFIX + portletNs)
		};
		//console.debug("portletContainerByNs: portlet.titleElm = " + portlet.title + ", portlet.contentElm = " + portlet.content);
		return portlet;
	}

	geminisystems.func.setPortletTitle = function(portletNs, title) {
		//console.debug("setPortletTitle BEGIN");
		geminisystems.func.setElmText(
			geminisystems.func.portletContainerByNs(portletNs).title,
			title);
		//console.debug("setPortletTitle END");
	}

	geminisystems.func.setPortletContent = function(portletNs, content) {
		//console.debug("setPortletContent BEGIN");
		//console.debug('content: ' + content);
		//window.setTimeout(function(){
			try {
				var plt = geminisystems.func.portletContainerByNs(portletNs);
				var parent = plt.content.parentNode;
				var detached = plt.content.remove();
				plt.content.innerHTML = content;
				parent.appendChild(detached);
			} catch(e) {
				throw e;
				console.debug('setPortletContent EXCEPTION: ' + e);
			}
		//},1);
		//console.debug("setPortletContent END");
	}

	geminisystems.func.resetNavigation = function() {
		console.debug('reset navigation: BEGIN');
		if (geminisystems.func.isDynamicPage(document.URL)) {
			var bCrumbs = $$('div.breadcrumbNav')[0];
			// leave top-level breadcrumb as it is, from portal
			var rootHref = bCrumbs.childElements().first().remove();
			bCrumbs.innerHTML = '';
			bCrumbs.appendChild(rootHref);
		}
		console.debug('reset navigation: END');
	}


	// ==============================================================================================
	// Firefox/MSIE incompatibility fix, look there for comments:
	// http://whoisron.blogspot.com/2008/06/javascript-textcontent-vs-innertext.html
	// ----------------------------------------------------------------------------------------------
	geminisystems.func.getElmText = function(elm) {
		var hasInnerText =
			(document.getElementsByTagName("body")[0].innerText != undefined) ? true : false;

		if (!hasInnerText){
			return $(elm).textContent;
		} else{
			return $(elm).innerText;
		}
	}
	geminisystems.func.setElmText = function(elm, text) {
		var hasInnerText =
			(document.getElementsByTagName("body")[0].innerText != undefined) ? true : false;

		if (!hasInnerText){
			$(elm).textContent = text;
		} else{
			$(elm).innerText = text;
		}
	}
	// ==============================================================================================


	geminisystems.func.setNavigation = function(urlBase, response) {
		console.debug('setNavigation: BEGIN');

		var getParentNavItem = function(navItem, parentLevel) {
			var item = $(navItem);
			while (item) {
				// indeed, there should be the only parent
				var parents = item.select('.wpsNavLevel' + parentLevel);
				if (0 < parents.size()) {
					return parents[0];
				}
				item = $(item.parentNode);
			}
			return null;
		}
		
		var syncMenuWithBreadcrumbs = function(response) {
			console.debug('========== syncMenuWithBreadcrumbs: BEGIN');
			var nodes = $(response.pathNodes);
			//nodes.each(function(node){
			//	console.debug('========== syncMenuWithBreadcrumbs: got nodes: "' + node.title + '"');
			//});

			// deselect all nodes, just for any case
			$$('.wpsNavItem.selected').each(function(elm){
				elm.removeClassName('selected');
			});

			// process breadcrumbs levels from top to 2nd level
			var found = false;
			//try {
			for (level=2; level>=1; level--) {
				//console.debug('syncMenuWithBreadcrumbs: ..level ' + level);

				var navItems = $$('a.wpsNavItem.wpsNavLevel'+level);
				var bcrumbs = $$('a.wcmFramework.breadcrumbLevel'+level);

				navItems.each(function(navItem){
					/*
					// ..here is just debug output, see for logic below
					console.debug("syncMenuWithBreadcrumbs: ..test this node: '"+ geminisystems.func.getElmText(navItem).strip() +"'");
					if (nodes[level]
						&& geminisystems.func.getElmText(navItem).strip() == nodes[level].title) {
						if (1 < level) {
							console.debug("syncMenuWithBreadcrumbs: this node found! ..check parent node: '"+ geminisystems.func.getElmText(getParentNavItem(navItem, level-1)).strip() +"' =? '"+ nodes[level-1].title +"'");
							if (geminisystems.func.getElmText(getParentNavItem(navItem, level-1)).strip() == nodes[level-1].title) {
								console.debug('syncMenuWithBreadcrumbs: parent OK, breadcrumb found!');
							} else {
								console.debug('syncMenuWithBreadcrumbs: parent FAILURE!');
							}
						} else {
							console.debug("syncMenuWithBreadcrumbs: 1-st level node found!");
						}
					}
					*/
					if (nodes[level]
							&& geminisystems.func.getElmText(navItem).strip() == nodes[level].title
							&& (1 < level
								? (geminisystems.func.getElmText(getParentNavItem(navItem, level-1)).strip() == nodes[level-1].title)
								: true
							   )
							) {
						if (!found) {
							//console.debug('syncMenuWithBreadcrumbs: found!');
							navItem.addClassName('selected');
							$(navItem.parentNode).addClassName('selected');
							found = true;
						}
						//move URL from menu to breadcrumb
						var url = navItem.getAttribute('href');
						bcrumbs[0].setAttribute('href', url);
					}
				});
			}
			console.debug('========== syncMenuWithBreadcrumbs: END');
		}

		var constructLevelLink = function(urlBase, response, level) {
			var nodes = $(response.pathNodes);
			//console.debug('construct level ' + level + ' link for: ' + nodes[level].name);

			var url = urlBase + '?'	+ geminisystems.consts.WCM_PATH_PARAM +
					'=' + geminisystems.consts.WCM_PATH_ROOT;

			for (var i=0; i<nodes.size() && i<=level; i++) {
				//console.debug('breadcrumb URL1: ' + url);
				var node = nodes[i];
				url = url + '/' + node.name.gsub(/\s+/, '+');
			}
			
			//var a = new Element('a', {'class': '', href: '#'}).update(node.title);
       			var a = $(document.createElement(0 < level ? 'a' : 'span'));
       			if (0 < level) {
				// 
				a.addClassName('wcmFramework');
				a.addClassName('breadcrumbLevel' + level);
				//a.setAttribute('href', 2 < level ? url : '/ACTUAL_URL_VALUE_TO_BE_SET_BY_JAVASCRIPT');
				a.setAttribute('href', url);
				//console.debug('breadcrumb URL2: ' + url);
			}
       			a.appendChild(document.createTextNode(node.title));
			return a;
		}

		var appendWcmPathToBreadcrumbs = function(urlBase, response) {
			console.debug('append WCM path to breadcrumbs');

			var bCrumbs = $$('div.breadcrumbNav')[0];
			bCrumbs.appendChild(new Element('span').update(geminisystems.consts.BREADCRUMB_DELIMITER));

			var nodes = $(response.pathNodes);

			var level = 0;
			nodes.each(function(node){
				// leave top-level breadcrumb as it is, from portal
				// limit breadcrumbs to 3 top levels
				if (0 < level && level <= 2) {
					$(bCrumbs).appendChild(constructLevelLink(urlBase, response, level));
					bCrumbs.appendChild(new Element('span').update(geminisystems.consts.BREADCRUMB_DELIMITER));
				}
				level++;
			});
		}

		if (geminisystems.func.isDynamicPage(document.URL)) {
			appendWcmPathToBreadcrumbs(urlBase, response);
			syncMenuWithBreadcrumbs(response);
		}
		console.debug('setNavigation: END');
	}

	geminisystems.func.fixWcmParamDelimiters = function(path) {
		try {
	       		//console.debug('fixWcmParamDelimiters: FROM ' + path);
			if (path) path = path.replace(/\?/g, '&');
	       		//console.debug('fixWcmParamDelimiters:   TO ' + path);
		} catch(e) {
			console.debug('fixWcmParamDelimiters EXCEPTION: ' + e);
		}
		return path;
	}

	geminisystems.func.fixedWcmImageUrl = function(url, currentWcmPath, doUseOriginalLink) {
		//console.debug('fixedWcmImageUrl: <== ' + url);
		//console.debug('fixedWcmImageUrl: currentWcmPath = ' + currentWcmPath);
		//console.debug('fixedWcmImageUrl: doUseOriginalLink = ' + doUseOriginalLink);

		if (url.include(geminisystems.consts.WCM_SERVLET_URL)) {
			url = url.replace(''+geminisystems.consts.WCM_SERVLET_URL, '/wps/wcm/connect');
		}


		//console.debug('fixedWcmImageUrl: ==> ' + url);
		return url;
	}

	geminisystems.func.fixedWcmUrl = function(url, currentWcmPath, isWcmOriginalLink) {

		url = url.gsub(/\%2[fF]/, '/');
		currentWcmPath = currentWcmPath.gsub(/\%2[fF]/, '/');

		console.debug('fixedWcmUrl: <== ' + url);
		//console.debug('fixedWcmUrl: currentWcmPath = ' + currentWcmPath);
		//console.debug('fixedWcmUrl: isWcmOriginalLink = ' + isWcmOriginalLink);

		// fix back the poor WSPS link..
		// Example: complex WSPS current page URL and href="abc", so resulted URL
		//          will be definitely wrong on "static" pages
		var fixImproperUrl = function(url, wcmPagePrefix) {

			var thisLoc = window.location;
			var thisHref = thisLoc.href;
			var thisPath = thisLoc.pathname;
			var thisPathUrl = thisHref.substring(0, thisHref.indexOf(thisPath) + thisPath.length);
			var thisSitePort = thisPathUrl.substring(0, thisPathUrl.indexOf(thisPath));

			// if it isn't parameter-only href, then skip everything after last '/'
			if ('?' != url.charAt(thisPathUrl.length)) {
				thisPathUrl = thisPathUrl.substring(0, thisPathUrl.lastIndexOf('/'));
			}

			//console.debug('fixedWcmUrl: fixImproperUrl: url0 = ' + url);
			//console.debug('fixedWcmUrl: fixImproperUrl: thisPathUrl = ' + url);
			//console.debug('fixedWcmUrl: fixImproperUrl: wcmPagePrefix = ' + wcmPagePrefix);
			if (0==url.indexOf(thisPathUrl) && 0!=url.indexOf(thisSitePort+wcmPagePrefix)) {
				//console.debug('fixedWcmUrl: fixImproperUrl: url1 = ' + url);
				url = thisSitePort + '/wps/wcm/connect' + currentWcmPath + url.substring(thisPathUrl.length);
				//console.debug('fixedWcmUrl: fixImproperUrl: url2 = ' + url);
			}

			//console.debug('fixedWcmUrl: fixImproperUrl: url = ' + url);
			return url;
		}

		var findWcmPathIndex = function(url) {
			// supposed prefixes
			var possiblePrefixes = new Array(
				geminisystems.consts.WCM_SERVLET_URL,
				'/wcm/connect',
				'/wcm/myconnect'
			);

			for (var i=0; i<possiblePrefixes.size(); i++)  {
				var index = url.toUpperCase().indexOf(possiblePrefixes[i].toUpperCase());
				if (0<=index) {
				//console.debug('findWcmPathIndex: index = ' + index);
				//console.debug('findWcmPathIndex: possiblePrefixes[i].length = ' + possiblePrefixes[i].length);
				//console.debug('findWcmPathIndex: wcmPath = ' + url.substring(index+possiblePrefixes[i].length));
					return index + possiblePrefixes[i].length;
				}
			}
			
			return -1;
		}

		//console.debug('fixedWcmUrl: local site url = ' + url);
		var wcmPagePrefix = geminisystems.consts.WCM_CONTENT_PAGE + '?'
			+ geminisystems.consts.WCM_PATH_PARAM + '=';

		//console.debug('fixedWcmUrl: url1 =  ' + url);

		if (geminisystems.func.isAnotherSite(url)) {
			console.debug('fixedWcmUrl: ==> ' + url);
			return url;
		}

		//console.debug('fixedWcmUrl: url2 =  ' + url);

		// fix back the poor link..
		url = fixImproperUrl(url, wcmPagePrefix);

		//console.debug('fixedWcmUrl: url3 =  ' + url);

		var wcmPathIndex = findWcmPathIndex(url);
		if (isWcmOriginalLink) {
			if (0 <= wcmPathIndex) {
				url = geminisystems.consts.WCM_ORIGINAL_SERVLET_URL + url.substring(wcmPathIndex);
			}
			console.debug('fixedWcmUrl: ==> ' + url);
			return url;
		}

		//console.debug('fixedWcmUrl: url4 =  ' + url);

		var servletUrl = geminisystems.consts.WCM_SERVLET_URL;

		//console.debug('fixedWcmUrl: patternValue = servletUrl = ' + servletUrl);
		//console.debug('fixedWcmUrl: wcmPathIndex = ' + wcmPathIndex);


		if (0 <= wcmPathIndex) {
			// if it is absolute WCM link, then replace pattern with proper prefix

       			// extract WCM path from href
       			var wcmPath = geminisystems.func.fixWcmParamDelimiters(url.substring(wcmPathIndex));
       
       			// return fixed link
       			url = wcmPagePrefix + wcmPath;
       		} else {
       		// it is relative WCM link, then prepend pattern with proper prefix
       			var wcmPath = geminisystems.func.fixWcmParamDelimiters(currentWcmPath);

       			if('string' == typeof wcmPath && wcmPath.startsWith('/')) {
       				// reconstruct absolute URL
 				var contentPage = geminisystems.consts.WCM_CONTENT_PAGE;
				if (0 <= url.indexOf(contentPage)) {
	       				url = url.substring(url.indexOf(contentPage) + contentPage.length);
				}
				if (url.match(/^[\#\?\&].*/)) {
	       				wcmPath = wcmPath + geminisystems.func.fixWcmParamDelimiters(url);
				} else {
	       				// ensure it ends with '/'
	       				wcmPath = wcmPath + (wcmPath.endsWith('/') ? '' : '/');
	       				wcmPath = wcmPath + url.substring(url.lastIndexOf('/')+1, url.length);
				}
       				url = wcmPagePrefix + wcmPath;
       			} else {
       				console.debug("current WCM path is unknown, so have no mention about correct absolute URL - link to nowhere..");
       				url = "javascript:alert('link fixup broken, seems predefined WCM path was wrong: " +
       					currentWcmPath + "');";
       			}
       		}

		console.debug('fixedWcmUrl: ==> ' + url);
		return url;
       	}

	geminisystems.func.fixWcmLinks = function(portletNs, currentWcmPath, titlePrefix) {

		var setWcmLinkHandler = function(portletNs, elm, currentWcmPath) {
			//$(elm).addClassName(geminisystems.consts.CLASS_USE_SAME_CONTENT_PLACE);
			var inTheSamePortlet = $(elm).hasClassName(geminisystems.consts.CLASS_USE_SAME_CONTENT_PLACE);

			console.debug('setWcmLinkHandler: portletNs = ' + portletNs +
				' elm = ' + elm +
				' inTheSamePortlet = ' + inTheSamePortlet
				);

       			var wcmPagePrefix = geminisystems.consts.WCM_CONTENT_PAGE + '?'
       				+ geminisystems.consts.WCM_PATH_PARAM + '=';

			var handler = function(evt) {
       				var url = geminisystems.func.fixedWcmUrl(evt.target["href"], currentWcmPath,
					evt.target.hasClassName(geminisystems.consts.CLASS_WCM_ORIGINAL_LINK));
       				var wcmPath = url.substring(wcmPagePrefix.length, url.length);

				//console.debug('wcmLinkHandler: url = "' + url + '"');
				//console.debug('wcmLinkHandler: wcmPagePrefix = "' + wcmPagePrefix + '"');
				//console.debug('wcmLinkHandler: wcmPath = "' + wcmPath + '"');

				if (!inTheSamePortlet) {
					//console.debug('wcmLinkHandler: handler forwards browser on new location');
					//alert('handler: redirect to ' + url);

					window.location = url;

					evt.stop();
				} else {
					//console.debug('wcmLinkHandler: handler loads content inside of the same portlet');
					//alert('handler: load ' + url + ' in portlet ' + portletNs);

					geminisystems.func.putWcmContentToPortlet(portletNs, wcmPath, null,
						//preprocess
						null,
					
						//postprocess
				        	function(response) {
							// setup title
							if (!titlePrefix) titlePrefix = "";
							var title = $A(response.pathNodes).last().title;

							geminisystems.func.setPortletTitle(portletNs,
								geminisystems.func.buildTitle(titlePrefix, title)
							);

							// fix links
							geminisystems.func.fixWcmLinks(portletNs, currentWcmPath, titlePrefix);
						});

					evt.stop();
				}
			};

			$(elm).observe('click', handler);
		}


		console.debug('fixWcmLinks begin..');
		// sanitize current WCM path: strip parameters from it
		if (0<=currentWcmPath.indexOf('?')) currentWcmPath = currentWcmPath.substring(0, currentWcmPath.indexOf('?'));
		console.debug('fixWcmLinks: currentWcmPath = ' + currentWcmPath);

		if (!geminisystems.consts.WCM_SERVLET_URL
			|| !geminisystems.consts.WCM_CONTENT_PAGE
			|| !geminisystems.consts.WCM_PATH_PARAM) {
				console.debug("geminisystems.consts.WCM_SERVLET_URL = '"  + geminisystems.consts.WCM_SERVLET_URL + "'");
				console.debug("geminisystems.consts.WCM_CONTENT_PAGE = '" + geminisystems.consts.WCM_CONTENT_PAGE + "'");
				console.debug("geminisystems.consts.WCM_PATH_PARAM = '"   + geminisystems.consts.WCM_PATH_PARAM + "'");
				console.debug('fixWcmLinks: some gemini parameters are incorrect, returns..');
				return;
		}

		var contentDiv = geminisystems.func.portletContainerByNs(portletNs).content;
		$$('#' + $(contentDiv)['id'] + ' img[src]').each(function(elm){
			if (!elm.hasClassName(geminisystems.consts.CLASS_NONWCM_ORIGINAL_LINK)) {
				var newSrc = geminisystems.func.fixedWcmImageUrl(elm["src"], currentWcmPath,
					elm.hasClassName(geminisystems.consts.CLASS_WCM_ORIGINAL_LINK));
				elm.setAttribute("src", newSrc);
			}
		});
		$$('#' + $(contentDiv)['id'] + ' a[href]').each(function(elm){
			if (!elm.hasClassName(geminisystems.consts.CLASS_NONWCM_ORIGINAL_LINK)) {
				elm["href"] = geminisystems.func.fixedWcmUrl(elm["href"], currentWcmPath,
					elm.hasClassName(geminisystems.consts.CLASS_WCM_ORIGINAL_LINK));
				//setWcmLinkHandler(portletNs, $(elm), currentWcmPath);
			}
		});
		console.debug('fixWcmLinks end..');
	}

	console.debug("initWcmPortalFrameworkNamespace end..");
}

