
/**
 * Cookie plugin
 *
 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */

/**
 * Create a cookie with the given name and value and other optional parameters.
 *
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Set the value of a cookie.
 * @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
 * @desc Create a cookie with all available options.
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Create a session cookie.
 * @example $.cookie('the_cookie', null);
 * @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
 *       used when the cookie was set.
 *
 * @param String name The name of the cookie.
 * @param String value The value of the cookie.
 * @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
 * @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
 *                             If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
 *                             If set to null or omitted, the cookie will be a session cookie and will not be retained
 *                             when the the browser exits.
 * @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
 * @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
 * @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
 *                        require a secure protocol (like HTTPS).
 * @type undefined
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */

/**
 * Get the value of a cookie with the given name.
 *
 * @example $.cookie('the_cookie');
 * @desc Get the value of a cookie.
 *
 * @param String name The name of the cookie.
 * @return The value of the cookie.
 * @type String
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */
jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};
function setActiveStyleSheet(title, reset) {

  if (!W3CDOM){return false};
    var i, a, main;
    for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
		  if (a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
            a.disabled = true;          
            if (a.getAttribute("title") == title) {
                a.disabled = false;
            }
        }
    }
    if (reset == 1) {
        createCookie("wstyle", title, 365);
    }
    

	
    
};

var bugRiddenCrashPronePieceOfJunk = (
    navigator.userAgent.indexOf('MSIE 5') != -1
    &&
    navigator.userAgent.indexOf('Mac') != -1
)

var W3CDOM = (!bugRiddenCrashPronePieceOfJunk &&
               document.getElementsByTagName &&
               document.createElement);


function setStyle() {

    var style = readCookie("wstyle");
    if (style != null) {
        setActiveStyleSheet(style, 0);
    }
};
registerPloneFunction(setStyle);

function registerPloneFunction(func) {
     registerEventListener(window, "load", func);
}


function registerEventListener(elem, event, func) {
    if (elem.addEventListener) {
        elem.addEventListener(event, func, false);
        return true;
    } else if (elem.attachEvent) {
        var result = elem.attachEvent("on"+event, func);
        return result;
    }

    return false;
}


function createCookie(name,value,days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime()+(days*24*60*60*1000));
        var expires = "; expires="+date.toGMTString();
    } else {
        expires = "";
    }
    document.cookie = name+"="+escape(value)+expires+"; path=/;";
};

function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') {
            c = c.substring(1,c.length);
        }
        if (c.indexOf(nameEQ) == 0) {
            return unescape(c.substring(nameEQ.length,c.length));
        }
    }
    return null;
};

/**
* Styleswitch stylesheet switcher built on jQuery
* Under an Attribution, Share Alike License
* By Kelvin Luck ( http://www.kelvinluck.com/ )
**/

(function($)
{
	$(document).ready(function() {
		$('.styleswitch').click(function()
		{
			switchStylestyle(this.getAttribute("rel"));
			return false;
		});
		var c = readCookie('style');
		if (c) switchStylestyle(c);
	});

	function switchStylestyle(styleName)
	{
		$('link[@rel*=style][title]').each(function(i) 
		{
			this.disabled = true;
			if (this.getAttribute('title') == styleName) this.disabled = false;
		});
		createCookie('style', styleName, 365);
	}
})(jQuery);
// cookie functions http://www.quirksmode.org/js/cookies.html
function createCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
function eraseCookie(name)
{
	createCookie(name,"",-1);
}
// /cookie functions

//menu Accordion
//author: Marghoob Suleman
//Date: 05th Aug, 2009
//Version: 1.0
//web: www.giftlelo.com | www.marghoobsuleman.com
;(function($){
	$.fn.msAccordion = function(options) {
		options = $.extend({
					currentDiv:'1',
					previousDiv:'',
					vertical: false,
					defaultid:0,
					currentcounter:0,
					intervalid:0,
					autodelay:0,
					event:"click",
					alldivs_array:new Array()
			}, options);
		$(this).addClass("accordionWrapper");
		$(this).css({overflow:"hidden"});
		//alert(this);
		var elementid = $(this).attr("id");
		var allDivs = this.children();
		if(options.autodelay>0)  {
			$("#"+ elementid +" > div").bind("mouseenter", function(){
														   pause();
														   });
			$("#"+ elementid +" > div").bind("mouseleave", function(){
																  startPlay();
																  });
		}
		//set ids
		allDivs.each(function(current) {
								 var iCurrent = current;
								 var sTitleID = elementid+"_msTitle_"+(iCurrent);
								 var sContentID = sTitleID+"_msContent_"+(iCurrent);
								 var currentDiv = allDivs[iCurrent];
								 var totalChild = currentDiv.childNodes.length;
								 var titleDiv = $(currentDiv).find("div.acc-title");
								 titleDiv.attr("id", sTitleID);
								 var contentDiv = $(currentDiv).find("div.acc-content");
								 contentDiv.attr("id", sContentID);
								 options.alldivs_array.push(sTitleID);
								 //$("#"+sTitleID).click(function(){openMe(sTitleID);});
								 $("#"+sTitleID).bind(options.event, function(){pause();openMe(sTitleID);});
								 });
		
		//make vertical
		if(options.vertical) {makeVertical();};
		//open default
		openMe(elementid+"_msTitle_"+options.defaultid);
		if(options.autodelay>0) {startPlay();};
		//alert(allDivs.length);
		function openMe(id) {
			var sTitleID = id;
			var iCurrent = sTitleID.split("_")[sTitleID.split("_").length-1];
			options.currentcounter = iCurrent;
			var sContentID = id+"_msContent_"+iCurrent;
			if($("#"+sContentID).css("display")=="none") {
				if(options.previousDiv!="") {
					closeMe(options.previousDiv);
				};
				if(options.vertical) {
					$("#"+sContentID).slideDown("slow");
				} else {
					$("#"+sContentID).show("slow");
				}
				options.currentDiv = sContentID;
				options.previousDiv = options.currentDiv;
			};
		};
		function closeMe(div) {
			if(options.vertical) {
				$("#"+div).slideUp("slow");
			} else {
				$("#"+div).hide("slow");
			};
		};	
		function makeVertical() {
			$("#"+elementid +" > div").css({display:"block", float:"none", clear:"both"});
			$("#"+elementid +" > div > div.acc-title").css({display:"block", float:"none", clear:"both"});
			$("#"+elementid +" > div > div.acc-content").css({clear:"both"});
		};
		function startPlay() {
			options.intervalid = window.setInterval(play, options.autodelay*1000);
		};
		function play() {
			var sTitleId = options.alldivs_array[options.currentcounter];
			openMe(sTitleId);
			options.currentcounter++;
			if(options.currentcounter==options.alldivs_array.length) options.currentcounter = 0;
		};
		function pause() {
			window.clearInterval(options.intervalid);
		};
		}
})(jQuery);


/* v1.2.6*/
/*
Script: jEnsure.js

jEnsure library
	A tiny javascript library that provides a handy function "ensure" which allows you to load 
	Javascript, HTML, CSS on-demand and then execute your code. Ensure ensures that relevent 
	Javascript and HTML snippets are already in the browser DOM before executing your code 
	that uses them.

	A great thank you to Omar AL Zabir and his ensure.js, which provided all the inspiration and
	much of the logic!

Credits:
	- Omar AL Zabir - http://msmvps.com/blogs/omar
*/

(function($) {

	// Set up the jQuery-function
	$.ensure = function( data, callback)
	{
        	load( toArray(data.js), toArray(data.css), callback);
	}

	function toArray(value) {
		if (!value) return [];
		else return (value.constructor == Array) ? value : [value];
	}

	function load(scriptList, cssList, callback)
	{
		var scriptsToLoad = 0;

		// Start loading scripts
		$.each(scriptList, function() {
			var url = this;
			if( isUrlLoaded(url) || isTagLoaded('script', 'src', url) )
			{
				log ('Already loaded: ' + url);
			}
			else
			{
				log ('Requesting script: ' + url);
				++scriptsToLoad;
				$.ajax({
					type: "GET",
					url: url,
					success: function() {
						// log ("getScript() success: " + url);
						registerUrl(url);
					},
					error: function() {
						log ("getScript() failed: " + url);
					},
					complete: function() {
						log ("getScript() complete: " + url);
						scriptsToLoad--;
					},
		                        dataType: "script",
					cache: true,
					timeout: 4000
				});
			}
		});

		// Start loading CSS
		$.each(cssList, function() {
			log ('Ensuring css: href=' + this);
			if(!isUrlLoaded(this) && !isTagLoaded('link', 'href', this))
			{            
				var link = document.createElement('link');
				link.setAttribute("href", this);
				link.setAttribute("rel", "Stylesheet");
				link.setAttribute("type", "text/css");
				var head = document.getElementsByTagName("head")[0] || document.documentElement;
				head.appendChild(link);
				registerUrl(this);
			}
        	});

		// wait for scripts
		var timeout=25;
		var i=0;
		var waitForScripts = function () {
		    if (scriptsToLoad <= 0) {
			callback && callback();
		    }
		    else {
			log ("waitForScripts: scriptsToLoad=" + scriptsToLoad + "; i=" + (++i) + "; timeout=" + timeout);
			timeout = Math.min(1000, timeout + 50);
			window.setTimeout(waitForScripts, timeout);
		    }
		}

		waitForScripts();
	}

	function isTagLoaded (tagName, attName, value)
	{
		var sel = tagName + "[" + attName + "=" + value + "]";
		count= $(sel).length;
		log ("isTagLoaded: result=" + (count > 0) + "; selector=" + sel);
		return count > 0;
	}

	// List of URLs loaded through jEnsure
    	var loadedUrls = []

	function isUrlLoaded (url) {
		// log ("isUrlLoaded: result=" + (loadedUrls[url] === true) + "; url=" + url);
       		return loadedUrls[url] === true;
	}

	function registerUrl (url) {
		// log ("Registering url: " + url);
		loadedUrls[url] = true;
	}

	function log (value) {
		if (window.console && console.log) console.log("jEnsure -- " + value)
		else if (window.opera && opera.postError) opera.postError("jEnsure -- " + value);
	}

})(jQuery);

iKnowBase={Version:"@app.version@",locations:{ikbViewer:"/ikbViewer",resource:"/ressurs"},ensures:{facebox:{js:"/ressurs/iknowbase/libs/jquery-plugins/facebox/facebox.js",css:"/ressurs/iknowbase/libs/jquery-plugins/facebox/facebox.css"},ikbPopup:{js:["/ressurs/iknowbase/libs/jquery-plugins/ikbPopup/ikbPopup.js","/ressurs/iknowbase/libs/jquery-plugins/jquery.bgiframe.js"],css:"/ressurs/iknowbase/libs/jquery-plugins/ikbPopup/ikbPopup.css"},form:{js:"/ressurs/iknowbase/libs/jquery-plugins/jquery.form.js"}}};iKnowBase.errorPopup=function(A){jQuery("<div class='ikbErrorPopup' onclick='jQuery(this).slideUp();' />").hide().append(A).prependTo("body").slideDown();iKnowBase.log(A)};iKnowBase.log=function(A){if(window.console&&console.log){console.log(A)}else{if(window.opera&&opera.postError){opera.postError(A)}}};iKnowBase.nvl=function(A,B){if(A!=null){return A}else{return B}};iKnowBase.assert=function(A,B){if(!A){alert("iKnowBase.assert",B)}};iKnowBase.setCookie=function(B,D,A,F,C,E){document.cookie=B+"="+escape(D)+((A)?"; expires="+A.toGMTString():"")+((F)?"; path="+F:"")+((C)?"; domain="+C:"")+((E)?"; secure":"")};iKnowBase.getCookie=function(C){var B=document.cookie;var E=C+"=";var D=B.indexOf("; "+E);if(D==-1){D=B.indexOf(E);if(D!=0){return null}}else{D+=2}var A=document.cookie.indexOf(";",D);if(A==-1){A=B.length}return unescape(B.substring(D+E.length,A))};iKnowBase.deleteCookie=function(A,C,B){if(getCookie(A)){document.cookie=A+"="+((C)?"; path="+C:"")+((B)?"; domain="+B:"")+"; expires=Thu, 01-Jan-70 00:00:01 GMT"}};iKnowBase.toggleClassForClass=function(A,B){var C=document.getElementsByClassName(A);for(i=0;i<C.length;i++){this.toggleClassForElement("toggle",C[i],B)}};iKnowBase.toggleClassForElement=function(D,E,B,A){switch(D){case"toggle":return this.toggleClassForElement("check",E,B)?this.toggleClassForElement("remove",E,B):this.toggleClassForElement("add",E,B);case"swap":E.className=!this.toggleClassForElement("check",E,B)?E.className.replace(A,B):E.className.replace(B,A);break;case"add":if(!this.toggleClassForElement("check",E,B)){E.className+=E.className?" "+B:B}break;case"remove":var C=E.className.match(" "+B)?" "+B:B;E.className=E.className.replace(C,"");break;case"check":return new RegExp("\\b"+B+"\\b").test(E.className)}return E.className!=null?E.className:""};iKnowBase.ensure=function(A,B){jQuery.ensure(A,B)};iKnowBase.withFacebox=function(A){iKnowBase.ensure(iKnowBase.ensures.facebox,A)};iKnowBase.withIkbPopup=function(A){iKnowBase.ensure(iKnowBase.ensures.ikbPopup,A)};iKnowBase.withForm=function(A){iKnowBase.ensure(iKnowBase.ensures.form,A)};iKnowBaseDevelopment={Version:"@app.version@"};iKnowBaseDevelopment.showPortletCacheStatus=function(A,C){var D="ikb.showPortletCacheStatus."+A;var B=iKnowBase.getCookie(D);if(B==null){style="ikbPortletCacheUnknown";status="unknown status"}else{if(B==C){style="ikbPortletCacheCached";status="from cache"}else{style="ikbPortletCacheNotCached";status="not from cache"}}document.write("<div class='"+style+"'>");document.write("<!-- ");document.write("name="+D);document.write("; renderTime="+C);document.write("; cookieTime="+B);document.write(" -->");document.write("Cache");document.write(": delta="+(C-B));document.write("; "+status);document.writeln("</div>");iKnowBase.setCookie(D,C)};jQuery(function(){jQuery(".ikbComponentInformation .ikbHeader").bind("click",function(){jQuery(this).next().toggle()})});(function(){iKnowBase.ContentViewer={};function C(H,E,G){if(H){G=jQuery.extend({_rtarget:H,_ikbController:E,portlet:H},G||{})}var F=(H?location.href.match(/[^\?]*/)[0]:iKnowBase.locations.ikbViewer+E);if(G!=null&&G!="undefined"){F=F+"?"+jQuery.param(G)}return F}function B(H,E,G){var F=C(H,E,G);iKnowBase.log("Request: "+F);iKnowBase.withIkbPopup(function(){jQuery.ikbPopup({post:F})});return false}function D(G,F,E){var H=jQuery("<form method='post'>");H.append("<input type='hidden' name='ikbAction' value='"+G+"' />");H.append("<input type='hidden' name='"+G+".operation' value='"+F+"' />");H.append("<input type='hidden' name='"+G+".arg' value='"+E+"' />");H.appendTo("body").submit();return false}function A(G,F,E){var H=jQuery("<form method='post'>");H.append("<input type='hidden' name='"+G+".operation' value='"+F+"' />");if(F=="startrow"||F=="sortinfo"){H.append("<input type='hidden' name='"+G+".arg' value='"+E+"' />")}else{if(F=="checkin"||F=="checkout"){H.append("<input type='hidden' name='"+G+".document_id' value='"+E+"' />")}}H.appendTo("body").submit();return false}jQuery.extend(iKnowBase.ContentViewer,{getUrl:C,navigatePage:D,navigatePortal:A,deleteDocument:function(F,E,G){return B(G,"/private/document/delete/request",{docid:F,version:(E||0)})},deleteDocumentConfirm:function(F,E,H,G){return B(G,"/private/document/delete/confirm",{docid:F,version:(E||0),mode:H})},changeDocumentType:function(E,F,G){return B(G,"/private/document/changeDocumentType/request",{docid:E,quickLinkGuid:F})},changeDocumentTypeConfirm:function(E,F){return B(portlet,"/private/document/changeDocumentType/confirm",{docid:E,formGuid:F})},copyDocument:function(E,F){return B(portlet,"/private/document/copy/request",{docid:E,quickLinkGuid:F})},copyDocumentConfirm:function(E,F){return B(portlet,"/private/document/copy/confirm",{docid:E,formGuid:F})},selectPersonalAcl:function(G,F,E){return B(G,"/private/personalAcl/popup",{cbFunction:F,cbClosure:E})}})})();iKnowBase.ContentViewer.EditOpenOfficeDocument=function(M,L,C,E,F){if(C==null){C=""}try{var B="";if(M=="INDIRECT"){var D=jQuery.ajax({type:"GET",async:false,url:encodeURI(L),beforeSend:function(N){N.setRequestHeader("x-iknowbase-getcontent-url",L)}});if(D.status!=200){iKnowBase.errorPopup("XMLHTTPError: "+D.status+"="+D.statusText+" (url="+L+")");return }L=D.getResponseHeader("x-iknowbase-content-url");B=D.getResponseHeader("x-iknowbase-content-filename")}var G=new ActiveXObject("com.sun.star.ServiceManager");var A=G.createInstance("com.sun.star.reflection.CoreReflection");var I=G.createInstance("com.sun.star.frame.Desktop");var K=new Array();var H=I.loadComponentFromURL(L,"_blank",0,K)}catch(J){iKnowBase.errorPopup("Error opening document. Error= "+J.name+"; description="+J.message)}};iKnowBase.ContentViewer.EditMSOfficeDocument=function(J,I,B,E,F){if(!window.ActiveXObject){iKnowBase.errorPopup("This function requires support for ActiveXObject (typically Microsoft Internet Explorer)");return }if(B==null){B=""}try{var A="";if(J=="INDIRECT"){var C=jQuery.ajax({type:"GET",async:false,url:encodeURI(I),beforeSend:function(L){L.setRequestHeader("x-iknowbase-getcontent-url",I)}});if(C.status!=200){iKnowBase.errorPopup("XMLHTTPError: "+C.status+"="+C.statusText+" (url="+I+")");return }I=C.getResponseHeader("x-iknowbase-content-url");A=C.getResponseHeader("x-iknowbase-content-filename")}if(this.ikbCustomEditWindowsDocument){var G=ikbCustomEditWindowsDocument("PREOPEN",null,I,B,A,F);if(!G){return }}var D=new ActiveXObject("iKnowBase.RemoteDocument");var K=D.OpenDocument("",I,B,E,A);if(K){if(this.ikbCustomEditWindowsDocument){var G=ikbCustomEditWindowsDocument("POSTOPEN-SUCCESS",K,I,B,A,F);if(!G){return }}}else{if(this.ikbCustomEditWindowsDocument){var G=ikbCustomEditWindowsDocument("POSTOPEN-FAILURE",K,I,B,A,F);if(!G){return }}window.open(I,"_blank")}D=null;K=null}catch(H){iKnowBase.errorPopup("Error opening document. Error= "+H.name+"; description="+H.message)}};function openOODoc(D,B,E,A,C){iKnowBase.ContentViewer.EditOpenOfficeDocument(D,B,E,A,C)}function ikbEditWindowsDocument(D,B,E,A,C){iKnowBase.ContentViewer.EditMSOfficeDocument(D,B,E,A,C)}function ikbOfficeSetProperty(D,A,B){try{D.CustomDocumentProperties(A).Value=B}catch(C){D.CustomDocumentProperties.Add(A,false,4,B)}}

function SetRadioCheck(D,C,B,A){evitaGetElementById("ViewerlinkFileName").value=B;evitaGetElementById("ViewerlinkTitle").value=C;evitaGetElementById("ViewerlinkId").value=D;evitaGetElementById("ViewerlinkType").value=A}function check(B,C,D){var A="p_description";if(A.length!=0){document.getElementById("linkTarget").value=document.getElementById("targetframe").value}document.getElementById("linkFilename").value=B;document.getElementById("linkTitle").value=C;document.getElementById("linkID").value=D}function doInsertIntoEditor(B,K,L,J){var I=evitaGetElementById("ViewerlinkFileName").value;var O=evitaGetElementById("ViewerlinkTitle").value;var F=evitaGetElementById("ViewerlinkId").value;var A=evitaGetElementById("ViewerlinkType").value;var H;if(A==""){alert("Velg et dokument i listen")}else{if(!top.opener.closed){if(evitaGetElementById("targetframe")){var D=evitaGetElementById("targetframe").value}else{var D="_new"}var M=O;if(D=="redirect"){H=" onclick=\"return call_ikb_homeplace("+F+",'TITLE_REDIRECT',"+L+","+J+");\""}else{H=" target=\""+D+"\""}if(A=="FILE"){var E=K;var G=F+"/"+I;var C="<a href='"+E+G+"'"+H+"'>"+M}else{if((I.indexOf("http://")==-1)&&(I.indexOf("https://")==-1)){var C="<a href='http://"+I+"'"+H+"'>"+M}else{var C="<a href='"+I+"'"+H+"'>"+M}}C=C+"</a>";if(B=="p_text"||B=="p_description"){top.opener.eWebEditPro[B].pasteHTML(C);top.close()}else{parent.tinyMCE.execCommand("mceInsertContent",false,C);parent.tinyMCEPopup.close()}}else{alert("Lenken du valgte kan ikke legges inn i dokumentet fordi editeringsvinduet ble lukket.")}}}function listCallback(){var list=evitaGetElementById("selectlist");var list_ids=new Array();var list_labels=new Array();var list_subattribs=new Array();var itemCount=0;var subCount=0;for(i=0;i<list.length;i++){if(list[i].value.length==0){continue}list_ids[itemCount]=list[i].value;list_labels[itemCount]=list[i].text;++itemCount}var cbFunction="storeValues";var cbClosure="";var runThis="parent.opener."+cbFunction+"(parent, cbClosure, list_ids, list_labels, list_subattribs);";eval(runThis)}function AddLink(){var A="p_description";if(A.length!=0){doInsertIntoEditor()}else{AddLinkToList()}}function AddLinkToList(){var D=evitaGetElementById("linkFilename").value;var G=evitaGetElementById("linkTitle").value;var H=evitaGetElementById("linkID").value;var F=evitaGetElementById("linkTarget").value;var E="1";var A=evitaGetElementById("selectlist").length;if(A<E){var B=false;for(var C=0;C<evitaGetElementById("selectlist").length;C++){if(evitaGetElementById("selectlist").options[C].value==H){B=true}}if(B==false){listAddElement(evitaGetElementById("selectlist"),G,H)}else{str="Verdien er allerede i listen!";alert(str)}}else{str="Maks antall verdier for dette attributtet er "+E+".";alert(str)}}function ReturnFromPickList(cbfunction,cbcloseure){var cbs=evitaGetElementById("p_picklist_id");var txt=evitaGetElementById("p_picklist_title");v1=new Array();v2=new Array();if(evitaGetElementById("ViewerlinkId").value!=""){v2[0]=evitaGetElementById("ViewerlinkTitle").value;v1[0]=evitaGetElementById("ViewerlinkId").value}if(parent.window.opener==null){alert("Vinduet som du skal returnere til er lukket.");return false}else{var runThis="parent.opener."+cbfunction+"(parent, cbcloseure,[v1], [v2]);";eval(runThis);parent.opener.focus();self.close()}}function ikbToggleClass(D,E,B,A){switch(D){case"toggle":return ikbToggleClass("check",E,B)?ikbToggleClass("remove",E,B):ikbToggleClass("add",E,B);case"swap":E.className=!ikbToggleClass("check",E,B)?E.className.replace(A,B):E.className.replace(B,A);break;case"add":if(!ikbToggleClass("check",E,B)){E.className+=E.className?" "+B:B}break;case"remove":var C=E.className.match(" "+B)?" "+B:B;E.className=E.className.replace(C,"");break;case"check":return new RegExp("\\b"+B+"\\b").test(E.className);break}return E.className!=null?E.className:""}function evitaGetElementById(A){if(document.getElementById){return document.getElementById(A)}else{return document.all[A]}}function evitaInnerText(A){if(A.innerText){return A.innerText}else{if(A.textContent){return A.textContent}}return text="(evitaInnerText:"+A+")"}function evitaDumpSource(C){var A=window.open("");var B=A.document;B.open();B.write("<html><body>");B.write("<h1>Source</h1><xmp><!CDATA[");B.write(C.innerHTML);B.write("]]></xmp></body></html>");B.close()}function evitaDumpObject(D,B){var A=window.open("");var C=A.document;C.open();C.write("<html><body>");C.write("<h1>"+h+"</h1><xmp>");C.writeln("ID = "+o.id);for(i in o){C.writeln(i+" = "+o[i]+"; ")}C.write("</xmp></body></html>");C.close()}function evitaTextRepositoryClass(){var A=new Array();this.setText=function(B,C){A[B]=C};this.getText=function(B){var C=A[B];if(C==null){C="--- missing value for key= '"+B+"' ---"}return C}}var evitaTextRepository=new evitaTextRepositoryClass();function evitaNvl(A,B){if(A!=null){return A}else{return B}}function evitaArrayCopy(B){var A;if(B==null){return B}else{A=new Array();for(o in B){A[o]=B[o]}return A}}function evitaAssert(A,B){if(!A){alert("evitaAssert",B)}}function evitaRemoveLeadingWhitespace(A){while(true){if(A.substring(0,1)==" "){A=A.substring(1,A.length)}else{break}}return A}function evitaChkNumeric(C,K,M,O,G,L){var D="0123456789"+O+G+L;var J=C.value;var A=true;var I=0;var H="";var B="";for(i=0;i<J.length;i++){ch=J.charAt(i);for(j=0;j<D.length;j++){if(ch==D.charAt(j)){break}}if(j==D.length){A=false;break}if(ch!=","){H+=ch}}if(!A){B="Please enter only these values \"";B=B+D+"\" in the \""+C.name+"\" field.";return(B)}var F=H;var E=parseInt(H);if(F!=""&&!(E>=K&&E<=M)){B="Please enter a value greater than or ";B=B+"equal to \""+K+"\" and less than or ";B=B+"equal to \""+M+"\" in the \""+J.name+"\" field.";return(B)}return(B)}function evitaChkLetter(D,G){var B=D.value;var F=true;var A=0;var C="";var E="";for(i=0;i<B.length;i++){ch=B.charAt(i);for(j=0;j<G.length;j++){if(ch==G.charAt(j)){F=false;break}}if(F==false){break}}if(!F){E="Please do not enter these values \"";E=E+G+"\" in the \""+D.name+"\" field.";return(E)}return(E)}var browserName="";var fullVersion=0;var majorVersion=0;function checkBrowserVersion(){var B=navigator.appVersion;var A=navigator.userAgent;if((verOffset=A.indexOf("MSIE"))!=-1){browserName="Microsoft Internet Explorer";fullVersion=parseFloat(A.substring(verOffset+5));majorVersion=parseInt(""+fullVersion)}else{if((verOffset=A.indexOf("Opera"))!=-1){browserName="Microsoft Internet Explorer";fullVersion=parseFloat(A.substring(verOffset+6));majorVersion=parseInt(""+fullVersion)}else{if((nameOffset=A.lastIndexOf(" ")+1)<(verOffset=A.lastIndexOf("/"))){browserName=A.substring(nameOffset,verOffset);fullVersion=parseFloat(A.substring(verOffset+1));if(!isNaN(fullVersion)){majorVersion=parseInt(""+fullVersion)}else{fullVersion=0;majorVersion=0}}}}if(browserName.toLowerCase()==browserName.toUpperCase()||fullVersion==0||majorVersion==0){browserName=navigator.appName;fullVersion=parseFloat(B);majorVersion=parseInt(B)}}function returnBrowserName(){return browserName}function returnBrowserVersion(){return fullVersion}function evitaGetElementsByClassName(B,F,A){var E=(F=="*"&&B.all)?B.all:B.getElementsByTagName(F);var H=new Array();A=A.replace(/\-/g,"\\-");var G=new RegExp("(^|\\s)"+A+"(\\s|$)");var D;for(var C=0;C<E.length;C++){D=E[C];if(G.test(D.className)){H.push(D)}}return(H)}function do_viewer_command(C,D,B,A,E){order_field=document.forms["g"+C].elements["g"+C+"order"];rowcount_field=document.forms["g"+C].elements["g"+C+"rowcount"];cico_field=document.forms["g"+C].elements["g"+C+"cico_document_id"];operation_field=document.forms["g"+C].elements["g"+C+"operation"];if(D=="checkin"||D=="checkout"){cico_field.value=B}else{if(D=="order"){order_field.value=A;rowcount_field.value=1}else{if(D=="rowcount"){order_field.value=A;rowcount_field.value=E}}}operation_field.value=D;document.forms["g"+C].submit()}function disable_button(A){if(evitaGetElementById(A)){evitaGetElementById(A).disabled=true}}function toggle_image_expand_collapse(B,A){if(document.images){document.images[B].src=A}}function toggle_expand_collapse(E,B,A,C){var F="X"+B+"_docid-"+E;var D=evitaGetElementById(F);ikbToggleClass("toggle",D,"ikbRowHide");if(D.className==""){toggle_image_expand_collapse(("img-"+F),C)}else{toggle_image_expand_collapse(("img-"+F),A)}return false}function checkifSet(B,A){var C=document.forms[B].elements[A];if(typeof (C)!="undefined"){if(document.forms[B].elements[A].value==""){return -1}else{return 0}}else{return -2}}function validatedocbuttons(A,B){myOption=-1;var C=document.forms[A].elements[B];for(i=C.length-1;i>-1;i--){if(C[i].checked){return C[i].value}}return""}function call_metadata_help(B,C,A){vindu=window.open(A+".ikb_portlet_formatting_set.show_in_context?p_guid="+B+"&p_app="+C,"_blank","height=800,top="+(screen.height-800)/2+",width=1050,left="+(screen.width-1050)/2+",scrollbars=yes,resizable=yes,menubar=1,toolbar=yes");vindu.focus();return false}function call_picklist(E,L,Q,J,H,G,D,U,P,O,K,A,F,I){var C="";var R="?";var T=""+D;if(T.indexOf("=")>-1){R="&"}var M="";if(E.length>0){for(S=0;S<E.length;S++){if(M==""){M="topDimensionIDs="+E[S]}else{M+="&topDimensionIDs="+E[S]}}}else{if(typeof (H)!="undefined"){if(H!=""){M="attributeID="+H}}}if(M!=""){navURL=D+R+M+"&p_dim_doc_type="+G+"&mode="}else{navURL=D+R+"p_dim_doc_type="+G+"&mode="}if(L==1){navURL=navURL+"single"}else{navURL=navURL+"multiple"}var B=Q.split(";");if(B.length>0){for(var S=0;S<B.length;S++){if(B[S]!=""){navURL=navURL+"&preSelDim="+escape(B[S])}}}navURL=navURL+"&maxCount="+L+"&cbFunction="+I+"&cbClosure="+J;if(window.showModalDialog){window.open(navURL,U,K)}else{window.open(navURL,U,K+", modal=yes")}}function UpdateSelectListOne(C,E,D,B,A){if(evitaGetElementById(A+"_"+C+B)){var F=document.forms[B].elements[A+"_"+C+B]}else{var F=document.forms[B].elements[A+"_"+C]}if(typeof (F)!="undefined"){F.value=E}return true}function UpdateSelectList(B,L,F,Q,J,E,M,C){if(evitaGetElementById(M+"_"+B+E)){var G=document.forms[E].elements[C+"_"+B+E];var K=evitaGetElementById("divdummy_"+B+E);var O=document.forms[E].elements[M+"_"+B+E]}else{var G=document.forms[E].elements[C+"_"+B];var K=evitaGetElementById("divdummy_"+B);var O=document.forms[E].elements[M+"_"+B]}if(typeof (O)=="undefined"){return true}if(F!=""){var H=O.value;var D=G.value;var A=H.split(";");var P="";if(H==""){P=""}else{P=";"}if(L>A.length){l_found="no";for(var I=0;I<A.length;I++){if(A[I]==F){l_found="yes"}}if(l_found=="no"){G.value=D+P+Q;O.value=H+P+F;oldInnerHtml=K.innerHTML;if(oldInnerHtml==""){K.innerHTML="<a href=\"#\" onclick=\"return DeleteSelectedDocIDs('"+F+"','"+B+"','"+E+"','"+M+"','"+C+"');\"><img alt='Delete' src='/ressurs/evita/iKBDesktop/images/common/del_sel_dim_icon.gif' border='0' /></a> "+Q}else{K.innerHTML=K.innerHTML+"<br><a href=\"#\" onclick=\"return DeleteSelectedDocIDs('"+F+"','"+B+"','"+E+"','"+M+"','"+C+"');\"><img alt='Delete' src='/ressurs/evita/iKBDesktop/images/common/del_sel_dim_icon.gif' border='0' /></a> "+Q}return true}}else{alert(J+" "+L+".")}}}function DeleteSelectedDocIDs(I,B,D,J,C){if(evitaGetElementById(J+"_"+B+D)){var E=document.forms[D].elements[C+"_"+B+D];var H=evitaGetElementById("divdummy_"+B+D);var K=document.forms[D].elements[J+"_"+B+D]}else{var E=document.forms[D].elements[C+"_"+B];var H=evitaGetElementById("divdummy_"+B);var K=document.forms[D].elements[J+"_"+B]}if(typeof (K)=="undefined"){return false}var L=K.value.split(";");var A=E.value.split(";");var O=0;if(L.length==1){K.value="";E.value="";H.innerHTML=""}else{var G=new Array();var M=new Array();for(var F=0;F<L.length;F++){if(L[F]!=I){G[O]=L[F];M[O]=A[F];O++}}rebuild_sel_value_list(G,M,B,D,J,C)}return false}function rebuild_sel_value_list(R,Q,A,D,L,B){if(evitaGetElementById(L+"_"+A+D)){var H=document.forms[D].elements[B+"_"+A+D];var K=evitaGetElementById("divdummy_"+A+D);var P=evitaGetElementById("p_max_value_"+A+D);var O=document.forms[D].elements[L+"_"+A+D];var I=document.forms[D].elements["p_favorite_list_"+A+D]}else{var H=document.forms[D].elements[B+"_"+A];var K=evitaGetElementById("divdummy_"+A);var P=evitaGetElementById("p_max_value_"+A);var O=document.forms[D].elements[L+"_"+A];var I=document.forms[D].elements["p_favorite_list_"+A]}var C="";var F="";var G="";var E=0;var J=0;for(i=0;i<R.length;i++){if(G==""){G=R[i]}else{G+=";"+R[i]}}for(i=0;i<Q.length;i++){if(F==""){F=Q[i];C=" <a href=\"#\" onClick=\"return DeleteSelectedDocIDs('"+R[i]+"','"+A+"','"+D+"','"+L+"','"+B+"');\"><img alt='Delete' src='/ressurs/evita/iKBDesktop/images/common/del_sel_dim_icon.gif' border='0' /></a> "+Q[i]}else{F+=";"+Q[i];C+="<br> <a href=\"#\" onClick=\"return DeleteSelectedDocIDs('"+R[i]+"','"+A+"','"+D+"','"+L+"','"+B+"');\"><img alt='Delete' src='/ressurs/evita/iKBDesktop/images/common/del_sel_dim_icon.gif' border='0' /></a> "+Q[i]}}if(typeof (I)!="undefined"){if(I.type!="hidden"){E=1;var M=I.options.length;for(x=0;x<R.length;x++){l_found=0;for(i=0;i<M;i++){if(I.options[i].value==R[x]){l_found=1;I.options[i].selected=true}}if(l_found==0){I.options[I.options.length]=new Option(Q[x],R[x]);I.options[i].selected=true}}}}H.value=F;O.value=G;if(evitaGetElementById("divdummy_"+A)||evitaGetElementById("divdummy_"+A+D)){if(evitaGetElementById("p_max_value_"+A)||evitaGetElementById("p_max_value_"+A+D)){if(P.innerHTML!="1"||E==0){K.innerHTML=C}else{K.innerHTML=C}}}return false}function rebuild_metadata_list(I,H,A){var E=evitaGetElementById(A);var B="";var D="";var C=0;var F=0;for(i=0;i<I.length;i++){if(D==""){D=I[i]}else{D+=";"+I[i]}}for(i=0;i<H.length;i++){if(B==""){B=H[i]}else{B+=";"+H[i]}}if(typeof (E)!="undefined"){if(E.type!="hidden"){C=1;var G=E.options.length;for(x=0;x<I.length;x++){l_found=0;for(i=0;i<G;i++){if(E.options[i].value==I[x]){l_found=1;E.options[i].selected=true}}if(l_found==0){E.options[E.options.length]=new Option(H[x],I[x]);E.options[i].selected=true}}}}return false}function call_navigators(J,O,C,G,D,H,L,I,M,K){var B="";var A=G.split(";");var F=D.split(";");if(J.length>0){for(E=0;E<J.length;E++){if(B==""){B="topDimensionIDs="+J[E]}else{B+="&topDimensionIDs="+J[E]}}}else{if(typeof (L)!="undefined"){B="attributeID="+L}}navURL=I+"?"+B+"&mode=";if(C==1){navURL=navURL+"single"}else{navURL=navURL+"multiple"}if(C==-1||C==""){C=99}if(G!=""){for(var E=0;E<A.length;E++){navURL=navURL+"&preSelDim="+escape(F[E])}}navURL=navURL+"&maxCount="+C+"&cbFunction="+K+"&cbClosure="+H;window.open(navURL,"DimensionNavigator","width=850, height=600, scrollbars, resizable=yes")}function StoreDocValues(H,A,G,F,B){if(H!=null){H.close()}var E=A.split(":");if(E.length==2){var D=E[0];var C=E[1]}else{var C=A;var D="DocumentForm"}rebuild_sel_value_list(G,F,C,D,"p_attrib_value","p_dummy")}function returnMetadata(E,B,D,C,A){if(E!=null){E.close()}rebuild_metadata_list(D,C,B)}function StoreMasterValue(H,A,G,F,B){if(H!=null){H.close()}var E=A.split(":");if(E.length==2){var D=E[0];var C=E[1]}else{var C=A;var D="DocumentForm"}rebuild_sel_value_list(G,F,C,D,"p_document_id_ref","p_dummy")}function Ce_CalendarSetup(C,A,B){Calendar.setup({inputField:C,ifFormat:B,button:A})}function changeMasterFile(B){var C=document.forms[B];var A=C["p_file"].value;var D=A.split("\\");if(C["p_title"].value==""){C["p_title"].value=D[D.length-1]}}function f_setfocus(B){if(B.elements[0]!=null){var C;var A=B.length;for(C=0;C<A;C++){if(B.elements[C].type!="hidden"&&B.elements[C].type!=""&&!B.elements[C].disabled&&!B.elements[C].readOnly){try{B.elements[C].focus();break}catch(D){break}}}}}function decode(A){for(i=0;i<A.length-4;i++){if(A.substring(i,i+5)=="&amp;"){A=A.substring(0,i)+"&"+A.substring(i+5,A.length)}}for(i=0;i<A.length-3;i++){if(A.substring(i,i+4)=="&lt;"){A=A.substring(0,i)+"<"+A.substring(i+4,A.length)}}for(i=0;i<A.length-3;i++){if(A.substring(i,i+4)=="&gt;"){A=A.substring(0,i)+">"+A.substring(i+4,A.length)}}for(i=0;i<A.length-3;i++){if(A.substring(i,i+4)=="&#39"){A=A.substring(0,i)+"'"+A.substring(i+4,A.length)}}for(i=0;i<A.length-5;i++){if(A.substring(i,i+6)=="&quot;"){A=A.substring(0,i)+"\""+A.substring(i+6,A.length)}}return A}function form_validate_number(D,B,C,A){if(D.value<B||D.value>C||isNaN(Math.abs(D.value))){alert(A);D.focus;D.select;return false}return true}function refreshmainwindow(){if(window.opener&&!window.opener.closed){window.focus();self.close()}else{history.back(-1)}}function clear_parent(){evitaGetElementById("parent_id_text").innerHTML="";document.DocumentForm.p_document_id_ref.value=""}function set_parent_id(A,F,E,C){var B="";var D="";for(i=0;i<E.length;i++){if(D==""){D=E[i]}else{D+=";"+E[i]}}for(i=0;i<C.length;i++){if(B==""){B=C[i]}else{B+=";"+C[i]}}evitaGetElementById("parent_id_text").innerHTML="<a href=\"\" onClick=\"javascript:clear_parent(); return false;\"><img src=\"/ressurs/evita/iKBDesktop/images/common/del_sel_dim_icon.gif\" border=\"0\"></a> "+B;document.DocumentForm.p_document_id_ref.value=D}function openDynamicACLs(B,C,E){var D=document.forms[B];var F=C;var A=D["p_acl_id"].value;if(A==""){A=-1}if(E=="POPUP"){cbFunction="RefreshACLListPopup"}else{cbFunction="RefreshACLList"}F=F+"?cbFunction=RefreshACLList&aclID="+A;vindu=window.open(F,"DynamicACLs","width=850, height=600, scrollbars, resizable=yes");vindu.focus()}function RefreshACLList(B,F,E){var C=document.forms[B];if($("#p_acl_id"+B).is("input")){$("#p_acl_text_"+B).empty();C["p_acl_id"+B].value=F;jQuery("<span align=''left''> "+E+"</span>").appendTo("#p_acl_text_"+B)}else{var A=C["p_acl_id"+B].length-1;var D=0;for(i=A;i>=0;i--){if(C["p_acl_id"+B].options[i].value==F){C["p_acl_id"+B].options[i].selected=true;D=1}}if(D==0){C["p_acl_id"+B].options[C["p_acl_id"+B].options.length]=new Option(E,F);C["p_acl_id"+B].options[C["p_acl_id"+B].options.length-1].selected=true}}}function RefreshACLListPopup(B,A){}function split_long_attributes(E,A){var D;var C;var B;for(x=0;x<A.length;x++){ikbelement=document.forms[E].elements["p_attrib_value_"+A[x]+E];ikbarrayelement=document.forms[E].elements["p_attrib_value_"+A[x]+"_array"+E];ikbelement.disabled="true";ikbarrayelement.disabled="true";inputData=ikbelement.value;totalLength=ikbelement.value.length;if(totalLength>30000){charLeft=totalLength;while(charLeft>0){if(charLeft==totalLength){C=0;B=30000}else{if(charLeft>30000){C+=30000;B=30000}else{C+=30000;B=charLeft}}charLeft-=30000;D=inputData.substr(C,B);jQuery("<input type=\"hidden\" name=\"p_long_text_ids\" value=\""+A[x]+"\">").appendTo("#dynamic_text"+E);jQuery("<input type=\"hidden\" name=\"p_long_text_arrays\">").appendTo("#dynamic_text"+E).val(D)}}else{jQuery("<input type=\"hidden\" name=\"p_long_text_ids\" value=\""+A[x]+"\">").appendTo("#dynamic_text"+E);jQuery("<input type=\"hidden\" name=\"p_long_text_arrays\">").appendTo("#dynamic_text"+E).val(inputData)}}}function split_text_and_description(F,B,A){var E;var D;var C;ikbelement=document.forms[F].elements[B];ikbelement.disabled="true";inputData=ikbelement.value;totalLength=ikbelement.value.length;if(totalLength>30000){charLeft=totalLength;while(charLeft>0){if(charLeft==totalLength){D=0;C=30000}else{if(charLeft>30000){D+=30000;C=30000}else{D+=30000;C=charLeft}}charLeft-=30000;E=inputData.substr(D,C);if(D==0){document.forms[F].elements[A].value=E}else{if(evitaGetElementById("dynamic_text"+F)){jQuery("<input type=\"hidden\" name=\""+A+"\">").appendTo("#dynamic_text"+F).val(E)}else{if(evitaGetElementById("dynamic_text")){jQuery("<input type=\"hidden\" name=\""+A+"\">").appendTo("#dynamic_text").val(E)}else{alert("ERROR: No DIV-field in form to add the chunked value")}}}}}else{document.forms[F].elements[A].value=inputData}}function toggle_block_none(B,A){if(evitaGetElementById(B)){evitaGetElementById(B).style.display=A}}function toggle_formats(B){var A=B;if(A=="file"){evitaGetElementById("p_document_format").value="F";if(checkifSet("p_url")==0){evitaGetElementById("p_url").value=""}toggle_block_none("file","block");toggle_block_none("text","none");toggle_block_none("url","none")}if(A=="url"){evitaGetElementById("p_document_format").value="U";toggle_block_none("file","none");toggle_block_none("text","none");toggle_block_none("url","block")}if(A=="text"){evitaGetElementById("p_document_format").value="T";if(checkifSet("p_url")==0){evitaGetElementById("p_url").value=""}toggle_block_none("file","none");toggle_block_none("text","block");toggle_block_none("url","none")}}function ValidateNumber(B){s=B.value;if(isNaN(Math.abs(B.value))&&(s.charAt(0)!="#")){for(var A=0;(A<=s.length&&s.charAt(A)!=".");){if(((s.charAt(A)>=0)&&(s.charAt(A)<=9))||(s.charAt(A)==","&&A!=0&&A!=s.length-1)||(s.charAt(A)==".")){A++}else{alert("Kun tall er tillatt.");B.focus();B.select();return false}}if(s.charAt(A)=="."){for(A++;A<=s.length;){if(((s.charAt(A)>=0)&&(s.charAt(A)<=9))){A++}else{alert("Kun tall er tillatt.");B.focus();B.select();return false}}}}return true}function ValidateDDMMYYYY(E){var I=new Array(31,28,31,30,31,30,31,31,30,31,30,31);var D=new Array("01","02","03","04","05","06","07","08","09","10","11","12");var H=null;var A=null;var F=null;var G=null;inpDate=E.value;if(inpDate.length==0){return true}F=inpDate.substr(0,2);thisMonth=inpDate.substr(3,2).toUpperCase();H=inpDate.substr(6,4);var B=/^[0-9]{2}.[0-9]{2}.[0-9]{4}$/;if(!B.test(inpDate)){alert("Angi dato p� formatet DD.MM.YYYY (eks. 28.12.2000)");E.focus();E.select();return false}var B=/01|02|03|04|05|06|07|08|09|10|11|12/;if(!B.test(thisMonth)){alert("Angi en gyldig m�ned (01-12) !");E.focus();E.select();return false}N=Number(H);if((N%4==0&&N%100!=0)||(N%400==0)){I[1]=29}for(var C=0;C<=11;C++){if(D[C]==thisMonth){if(F<=I[C]&&F>0){return true}else{alert("Angi en korrekt dag!");E.focus();E.select();return false}}}}function ValidateDatetime(E){var I=new Array(31,28,31,30,31,30,31,31,30,31,30,31);var D=new Array("01","02","03","04","05","06","07","08","09","10","11","12");var H=null;var A=null;var F=null;var G=null;inpDate=E.value;if(inpDate.length==0){return true}F=inpDate.substr(0,2);thisMonth=inpDate.substr(3,2).toUpperCase();H=inpDate.substr(6,4);thisHour=inpDate.substr(11,2);thisMin=inpDate.substr(14,2);var B=/^[0-9]{2}.[0-9]{2}.[0-9]{4} [0-9]{2}:[0-9]{2}$/;if(!B.test(inpDate)){alert("Angi dato p� formatet DD.MM.YYYY HH24:MI (eks. 28.12.2000 12:00)");E.focus();E.select();return false}var B=/01|02|03|04|05|06|07|08|09|10|11|12/;if(!B.test(thisMonth)){alert("Angi en gyldig m�ned (01-12) !");E.focus();E.select();return false}var B=/00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|22|23/;if(!B.test(thisHour)){alert("Angi en gyldig time (00-24) !");E.focus();E.select();return false}var B=/00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59/;if(!B.test(thisMin)){alert("Angi et gyldig minutt (00-59) !");E.focus();E.select();return false}N=Number(H);if((N%4==0&&N%100!=0)||(N%400==0)){I[1]=29}for(var C=0;C<=11;C++){if(D[C]==thisMonth){if(F<=I[C]&&F>0){return true}else{alert("Angi en korrekt dag!");E.focus();E.select();return false}}}}



// Some global instances, this will be filled later
var tinyMCE = null, tinyMCELang = null;


function TinyMCE_Popup() {
};


TinyMCE_Popup.prototype.init = function() {
	var win = window.opener ? window.opener : window.dialogArguments;
	var inst;
	if (!win) {
		// Try parent
		win = parent.parent;

		// Try top
		if (typeof(win.tinyMCE) == "undefined")
			win = top;	
	}

	window.opener = win;
	this.windowOpener = win;
	this.onLoadEval = "";

	// Setup parent references
	tinyMCE = win.tinyMCE;
	tinyMCELang = win.tinyMCELang;

	if (!tinyMCE) {
//		alert("tinyMCE object reference not found from popup.");
		return;
	}

	inst = tinyMCE.selectedInstance;
	this.isWindow = tinyMCE.getWindowArg('mce_inside_iframe', false) == false;
	this.storeSelection = (tinyMCE.isMSIE && !tinyMCE.isOpera) && !this.isWindow && tinyMCE.getWindowArg('mce_store_selection', true);

	if (this.isWindow)
		window.focus();

	// Store selection
	if (this.storeSelection)
		inst.selectionBookmark = inst.selection.getBookmark(true);

	// Setup dir
	if (tinyMCELang['lang_dir'])
		document.dir = tinyMCELang['lang_dir'];

	// Setup title
	var re = new RegExp('{|\\\$|}', 'g');
	var title = document.title.replace(re, "");
	if (typeof tinyMCELang[title] != "undefined") {
		var divElm = document.createElement("div");
		divElm.innerHTML = tinyMCELang[title];
		document.title = divElm.innerHTML;

		if (tinyMCE.setWindowTitle != null)
			tinyMCE.setWindowTitle(window, divElm.innerHTML);
	}

	// Output Popup CSS class
//	document.write('<link href="' + tinyMCE.getParam("popups_css") + '" rel="stylesheet" type="text/css">');

	tinyMCE.addEvent(window, "load", this.onLoad);

};


TinyMCE_Popup.prototype.onLoad = function() {
	var dir, i, elms, body = document.body;

	if (tinyMCE.getWindowArg('mce_replacevariables', true))
		body.innerHTML = tinyMCE.applyTemplate(body.innerHTML, tinyMCE.windowArgs);

	dir = tinyMCE.selectedInstance.settings['directionality'];
	if (dir == "rtl" && document.forms && document.forms.length > 0) {
		elms = document.forms[0].elements;
		for (i=0; i<elms.length; i++) {
			if ((elms[i].type == "text" || elms[i].type == "textarea") && elms[i].getAttribute("dir") != "ltr")
				elms[i].dir = dir;
		}
	}

	if (body.style.display == 'none')
		body.style.display = 'block';

	// Execute real onload (Opera fix)
	if (tinyMCEPopup.onLoadEval != "")
		eval(tinyMCEPopup.onLoadEval);

	// Da er det trygt � kalle ikbOnLoad-funksjonen som m� finnes i applikasjonen
	
	// Kj�re kall til ikbOnload der de finnes, hvis ikke blir kallet ignorert
     	try {
          ikbOnload();
        } catch (e) { 
          // Ignore call
        }	 

};


TinyMCE_Popup.prototype.executeOnLoad = function(str) {
alert("ExecuteonLoad");

	if (tinyMCE.isOpera)
		this.onLoadEval = str;
	else
		eval(str);
alert("After ExecuteonLoad");

};


TinyMCE_Popup.prototype.resizeToInnerSize = function() {
	// Netscape 7.1 workaround
	if (this.isWindow && tinyMCE.isNS71) {
		window.resizeBy(0, 10);
		return;
	}

	if (this.isWindow) {
		var doc = document;
		var body = doc.body;
		var oldMargin, wrapper, iframe, nodes, dx, dy;

		if (body.style.display == 'none')
			body.style.display = 'block';

		// Remove margin
		oldMargin = body.style.margin;
		body.style.margin = '0';

		// Create wrapper
		wrapper = doc.createElement("div");
		wrapper.id = 'mcBodyWrapper';
		wrapper.style.display = 'none';
		wrapper.style.margin = '0';

		// Wrap body elements
		nodes = doc.body.childNodes;
		for (var i=nodes.length-1; i>=0; i--) {
			if (wrapper.hasChildNodes())
				wrapper.insertBefore(nodes[i].cloneNode(true), wrapper.firstChild);
			else
				wrapper.appendChild(nodes[i].cloneNode(true));

			nodes[i].parentNode.removeChild(nodes[i]);
		}

		// Add wrapper
		doc.body.appendChild(wrapper);

		// Create iframe
		iframe = document.createElement("iframe");
		iframe.id = "mcWinIframe";
		iframe.src = document.location.href.toLowerCase().indexOf('https') == -1 ? "about:blank" : tinyMCE.settings['default_document'];
		iframe.width = "100%";
		iframe.height = "100%";
		iframe.style.margin = '0';

		// Add iframe
		doc.body.appendChild(iframe);

		// Measure iframe
		iframe = document.getElementById('mcWinIframe');
		dx = tinyMCE.getWindowArg('mce_width') - iframe.clientWidth;
		dy = tinyMCE.getWindowArg('mce_height') - iframe.clientHeight;

		// Resize window
		// tinyMCE.debug(tinyMCE.getWindowArg('mce_width') + "," + tinyMCE.getWindowArg('mce_height') + " - " + dx + "," + dy);
		window.resizeBy(dx, dy);

		// Hide iframe and show wrapper
		body.style.margin = oldMargin;
		iframe.style.display = 'none';
		wrapper.style.display = 'block';
	}
};


TinyMCE_Popup.prototype.resizeToContent = function() {
	var isMSIE = (navigator.appName == "Microsoft Internet Explorer");
	var isOpera = (navigator.userAgent.indexOf("Opera") != -1);

	if (isOpera)
		return;

	if (isMSIE) {
		try { window.resizeTo(10, 10); } catch (e) {}

		var elm = document.body;
		var width = elm.offsetWidth;
		var height = elm.offsetHeight;
		var dx = (elm.scrollWidth - width) + 4;
		var dy = elm.scrollHeight - height;

		try { window.resizeBy(dx, dy); } catch (e) {}
	} else {
		window.scrollBy(1000, 1000);
		if (window.scrollX > 0 || window.scrollY > 0) {
			window.resizeBy(window.innerWidth * 2, window.innerHeight * 2);
			window.sizeToContent();
			window.scrollTo(0, 0);
			var x = parseInt(screen.width / 2.0) - (window.outerWidth / 2.0);
			var y = parseInt(screen.height / 2.0) - (window.outerHeight / 2.0);
			window.moveTo(x, y);
		}
	}
};


TinyMCE_Popup.prototype.getWindowArg = function(name, default_value) {
	return tinyMCE.getWindowArg(name, default_value);
};


TinyMCE_Popup.prototype.restoreSelection = function() {
	if (this.storeSelection) {
		var inst = tinyMCE.selectedInstance;

		inst.getWin().focus();

		if (inst.selectionBookmark)
			inst.selection.moveToBookmark(inst.selectionBookmark);
	}
};


TinyMCE_Popup.prototype.execCommand = function(command, user_interface, value) {
	var inst = tinyMCE.selectedInstance;

	this.restoreSelection();
	inst.execCommand(command, user_interface, value);

	// Store selection
	if (this.storeSelection)
		inst.selectionBookmark = inst.selection.getBookmark(true);
};


TinyMCE_Popup.prototype.close = function() {
	tinyMCE.closeWindow(window);
};


TinyMCE_Popup.prototype.pickColor = function(e, element_id) {
	tinyMCE.selectedInstance.execCommand('mceColorPicker', true, {
		element_id : element_id,
		document : document,
		window : window,
		store_selection : false
	});
};


TinyMCE_Popup.prototype.openBrowser = function(element_id, type, option) {
	var cb = tinyMCE.getParam(option, tinyMCE.getParam("file_browser_callback"));
	var url = document.getElementById(element_id).value;

	tinyMCE.setWindowArg("window", window);
	tinyMCE.setWindowArg("document", document);

	// Call to external callback
	if (eval('typeof(tinyMCEPopup.windowOpener.' + cb + ')') == "undefined")
		alert("Callback function: " + cb + " could not be found.");
	else
		eval("tinyMCEPopup.windowOpener." + cb + "(element_id, url, type, window);");
};


TinyMCE_Popup.prototype.importClass = function(c) {
	window[c] = function() {};

	for (var n in window.opener[c].prototype)
		window[c].prototype[n] = window.opener[c].prototype[n];

	window[c].constructor = window.opener[c].constructor;
};

// Setup global instance
var tinyMCEPopup = new TinyMCE_Popup();

tinyMCEPopup.init();

