	function encodeUrl(url) {
	 	if (url.indexOf("?")>0)
	 	{
			encodedParams = "?";
	 		parts = url.split("?");
	 		params = parts[1].split("&");
	 		for(i = 0; i < params.length; i++)
	 		{
				if (i > 0) {
					encodedParams += "&";
				}
				if (params[i].indexOf("=")>0) {
					p = params[i].split("=");
					encodedParams += (p[0] + "=" + escape(encodeURI(p[1])));
				} else {
					encodedParams += params[i];
				}
			}
			url = parts[0] + encodedParams;
		}
		return url;
	}

	var myPopupWindow = '';

	function openPopupWindowEx(contentType, contentID, retType)
	{
		var url = 'common/csx/ux/csxMicrosite/editms.asp?t='+contentType+'&id='+contentID+'&rt='+retType;
		goPopup(url);
	}

	function goPopup(url, name, width, height)
	{
    name = name.replace(/\/|\-|\./gi, "");
    var whitespace = new RegExp("\\s","g");
    name = name.replace(whitespace,"");

    if (!myPopupWindow.closed && myPopupWindow.location) {
    	myPopupWindow.location.href = encodeUrl(url);
    } else {
      myPopupWindow= window.open(encodeUrl(url),name, "location=no, scrollbars=yes, resizable=no, toolbar=no, menubar=no, width=" + width + ", height=" + height );
      if (!myPopupWindow.opener) myPopupWindow.opener = self;
    }

    if (window.focus) {myPopupWindow.focus()}
	}

	
	function modalDialogShow_IE(url,width,height) { //IE
		return window.showModalDialog(url,window,
		"dialogWidth:"+width+"px;dialogHeight:"+height+"px;edge:Raised;center:Yes;help:No;Resizable:Yes;Maximize:Yes");
	}
	function modalDialogShow_Moz(url,width,height) { //Moz 
		var left = screen.availWidth/2 - width/2;
		var top = screen.availHeight/2 - height/2;
		activeModalWin = window.open(url, "", "width="+width+"px,height="+height+",left="+left+",top="+top);
		window.onfocus = function(){if (activeModalWin.closed == false){activeModalWin.focus();};};
	}
	var sActiveAssetInput;
	function setAssetValue(v) { //required by the asset manager
		document.getElementById(sActiveAssetInput).value = v;
	}
	function openAsset(s) {
		sActiveAssetInput = s
		if(navigator.appName.indexOf('Microsoft')!=-1 && 1 == 0) {
			return modalDialogShow_IE("common/include/lib/editor/Assetmanager/assetmanager.asp?lang=da-DK",640,465); //IE
		} else {
			modalDialogShow_Moz("common/include/lib/editor/Assetmanager/assetmanager.asp?lang=da-DK",700,465); //Moz
		}
	}

	function openPopupWindow(msID, retType, overrideSelOS)
	{
		var url = 'common/csx/ux/csxMicrosite/editms.asp?msid='+msID+'&rt='+retType + (overrideSelOS == 1 ? '&selos=1' : '');
		goPopup(url, 'editms', 900, 600);
	}
	
	var openMSEditorCallback = function(headline, content) { };

	function openMSEditor(options) {
		if (options.micrositeID > 0) {
			if (typeof(options.validateOrg) != 'boolean') options.validateOrg = true;
			if (typeof(options.callback) != 'function') options.callback = function() {};

			openMSEditorCallback = options.callback;

			var url = 'common/csx/ux/csxMicrosite/editms.asp?msid='+options.micrositeID+'&selos='+(options.validateOrg ? '1' : '0');
			goPopup(url, 'editms', 900, 600);
		}
	}

function openPopupWindowEx(contentType, contentID, retType)
	{
		var url = 'common/csx/ux/csxMicrosite/editms.asp?t='+contentType+'&id='+contentID+'&rt='+retType;
		goPopup(url, 'editms', 900, 600);
	}

function fnLoadContent(helpID)
	{
		var url = 'helpShow.asp';
		if (typeof(helpID) != "undefined" ) { url = url + '?id=' + helpID; }
		goPopup(url, 'help', 600, 500);
		return false;
	}


