var EasyCMS_jsLibVersion = 199;
// To cover IE 5.0's lack of the push method
if(typeof Array.prototype.push != "function"){
    Array.prototype.push = ArrayPush;
    function ArrayPush(value){
        this[this.length] = value;
    }
}
// ---
/*
	ELO - Encapsulated Load Object, by Robert Nyman, http://www.robertnyman.com
	Inspired and influenced by Dean Edwards, Matthias Miller, and John Resig: http://dean.edwards.name/weblog/2006/06/again/
*/
var ELO = {
	loaded : false,
	timer : null,
	functionsToCallOnload : [], // Type in functions as strings here. e.g. "myFunction()"
	init : function (){
		if(ELO.loaded) return;
		ELO.loaded = true;
		ELO.load();
	},
	
	load : function (){
		if(this.timer){
			clearInterval(this.timer);
		}
		for(var i=0; i<this.functionsToCallOnload.length; i++){
			try{
				eval(this.functionsToCallOnload[i]);
			}
			catch(e){
				// Handle error here
			}
		}
	}
};
// ---
/* Internet Explorer */
/*@cc_on @*/
/*@if (@_win32)
	if(document.getElementById){
		document.write("<script id=\"ieScriptLoad\" defer src=\"//:\"><\/script>");
	    document.getElementById("ieScriptLoad").onreadystatechange = function() {
	        if (this.readyState == "complete") {
	            ELO.init();
	        }
	    };
	}
/*@end @*/
// ---
/* Mozilla/Opera 9 */
if (document.addEventListener) {
	document.addEventListener("DOMContentLoaded", ELO.init, false);
}
// ---
/* Safari */
if(navigator.userAgent.search(/WebKit/i) != -1){
    ELO.timer = setInterval(function (){
		if(document.readyState.search(/loaded|complete/i) != -1) {
			ELO.init();
		}
	}, 10);
}
// ---
/* Other web browsers */
window.onload = ELO.init;
// ---
if(typeof Array.prototype.inArray != "function"){
  Array.prototype.inArray = function (value) {
    var i;
    for (i=0; i < this.length; i++) {
      if (this[i] === value) {
        return true;
      }
    }
    return false;
  }
}

function addEvent( obj, type, fn ) {
	if (obj.addEventListener) {
		obj.addEventListener( type, fn, false );
		EventCache.add(obj, type, fn);
	}
	else if (obj.attachEvent) {
		obj["e"+type+fn] = fn;
		obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
		obj.attachEvent( "on"+type, obj[type+fn] );
		EventCache.add(obj, type, fn);
	}
	else {
		obj["on"+type] = obj["e"+type+fn];
	}
}
	
var EventCache = function(){
	var listEvents = [];
	return {
		listEvents : listEvents,
		add : function(node, sEventName, fHandler){
			listEvents.push(arguments);
		},
		flush : function(){
			var i, item;
			for(i = listEvents.length - 1; i >= 0; i = i - 1){
				item = listEvents[i];
				if(item[0].removeEventListener){
					item[0].removeEventListener(item[1], item[2], item[3]);
				};
				if(item[1].substring(0, 2) != "on"){
					item[1] = "on" + item[1];
				};
				if(item[0].detachEvent){
					item[0].detachEvent(item[1], item[2]);
				};
				item[0][item[1]] = null;
			};
		}
	};
}();
addEvent(window,'unload',EventCache.flush);function $(o) {
  if (typeof(o) == "string")
    return document.getElementById(o)
    else
    return o;
};
  // TODO:
  // http://www.quirksmode.org/bugreports/archives/2005/03/setAttribute_does_not_work_in_IE_when_used_with_th.html
  // el.className = 'Class name';   // This works in all browsers!
  // el.style.cssText = 'key:val;'; // This works in all browsers!
  function applyStyleString(el,str){
    if(document.all && !window.opera) {
      el.style.cssText = str;
      el.setAttribute("cssText",str);
    } else {
      el.setAttribute("style",str);
    }
  };
  function swFieldsFocus(el){
    var hoverColor = arguments[1] ? arguments[1] : "#ffff99";
    var fields = new Array("input","textarea","select");

    for (var i = 0; i < fields.length; i++) {
      var inps = el.getElementsByTagName(fields[i]);
      for (var j = 0; j < inps.length; j++) {

        if(inps[j].getAttribute('readonly') != true){
          inps[j].onfocus = function(){
            this.style.backgroundColor = hoverColor;
          }
          inps[j].onblur = function(){
            this.style.backgroundColor = "";
          }
        } else {
          // readonly
        }
      }
    }
  };
/* Function : getElementsByClassName Deluxe Edition
   Author    : http://muffinresearch.co.uk/archives/2006/04/29/getelementsbyclassname-deluxe-edition/ 
   */
function getElementsByClassName(strClass, strTag, objContElm) {
  strTag = strTag || "*";
  objContElm = objContElm || document;
  var objColl = (strTag == '*' && document.all) ? document.all : objContElm.getElementsByTagName(strTag);
  var arr = new Array();
  var delim = strClass.indexOf('|') != -1  ? '|' : ' ';
  var arrClass = strClass.split(delim);
  for (i = 0, j = objColl.length; i < j; i++) {
    var arrObjClass = objColl[i].className.split(' ');
    if (delim == ' ' && arrClass.length > arrObjClass.length) continue;
    var c = 0;
    comparisonLoop:
    for (k = 0, l = arrObjClass.length; k < l; k++) {
      for (m = 0, n = arrClass.length; m < n; m++) {
        if (arrClass[m] == arrObjClass[k]) c++;
        if (( delim == '|' && c == 1) || (delim == ' ' && c == arrClass.length)) {
          arr.push(objColl[i]);
          break comparisonLoop;
        }
      }
    }
  }
  return arr;
}



  function swFieldsFocus(el){
    var hoverColor = arguments[1] ? arguments[1] : "#ffff99";
    var fields = new Array("input","textarea","select");

    for (var i = 0; i < fields.length; i++) {
      var inps = el.getElementsByTagName(fields[i]);
      for (var j = 0; j < inps.length; j++) {

        if(inps[j].getAttribute('readonly') != true){
          inps[j].onfocus = function(){
            this.style.backgroundColor = hoverColor;
          }
          inps[j].onblur = function(){
            this.style.backgroundColor = "";
          }
        } else {
          // readonly
        }
      }
    }
  };
function hideLayer(whichLayer) {
  if (document.getElementById) {
    // this is the way the standards work
    document.getElementById(whichLayer).style.display = "none";
  } else if (document.all) {
    // this is the way old msie versions work
    document.all[whichlayer].style.display = "none";
  } else if (document.layers) {
    // this is the way nn4 works
    document.layers[whichLayer].display = "none";
  }
};
function showLayer(whichLayer) {
  if (document.getElementById) {
    document.getElementById(whichLayer).style.display = "block";
  } else if (document.all) {
    document.all[whichlayer].style.display = "block";
  } else if (document.layers) {
    document.layers[whichLayer].display = "block";
  }
};
function sw_add (id) {
  thenumber = document.setting[id].value;
  thenumber = thenumber*(-1);
  thenumber = thenumber-1;
  thenumber = thenumber*(-1);
  document.setting[id].value = thenumber;
}
function sw_sub (id) {
  thenumber = document.setting[id].value;
  if(validateLOW(id,1)){
    thenumber = thenumber-1;
    document.setting[id].value = thenumber;
  }
};
function chkData() {
  if(document.sw.usr.value <= 0){
    alert("Skriv inn ditt brukernavn");
    document.sw.usr.value = '';
    document.sw.usr.focus();
    return false;
  }
  if(document.sw.pas.value <= 0){
    alert("Skriv inn ditt passord");
    document.sw.pas.value = '';
    document.sw.pas.focus();
    return false;
  }
};
function chkUpload() {
  box = document.form_upload.bildegruppe;
  temp = box.options[box.selectedIndex].value;
  if (temp) {
    if(document.form_upload.bildegruppeny.value){
      alert("Du kan ikke både velge bilde kategori å lage ny bilde kategori, velg en av dem.");
      return false;
    }
  } else {
    if(!document.form_upload.bildegruppeny.value)
    document.form_upload.bildegruppeny.value = 'mine bilder'
  }
  if(document.form_upload.file1.value <= 0){
    alert("Du må velge en bildefil før du kan fortsette.");
    document.form_upload.file1.value = '';
    //document.form_upload.file1.value.focus();
    return false;
  }
};
function chkFileUpload() {
  box = document.myXUploadForm.filgruppe;
  temp = box.options[box.selectedIndex].value;
  if (temp) {
    if(document.myXUploadForm.filgruppeny.value){
      alert("Du kan ikke både velge fil kategori å lage ny fil kategori, velg en av dem.");
      return false;
    }
  } else {
    if(!document.myXUploadForm.filgruppeny.value)
    document.myXUploadForm.filgruppeny.value = 'mine filer'
  }
  if(document.myXUploadForm.file1.value <= 0){
    alert("Du må velge en fil før du kan fortsette.");
    document.myXUploadForm.file1.value = '';
    //document.myXUploadForm.file1.value.focus();
    return false;
  }
};
function validateig(){
	if(validate(document.setting.pimgsize_mainX.value,'Auto resize max large (L) dimensjon'))
	return false;
	if(document.setting.pimgsize_mainX.value > 1280){
		alert("    --- BILDE OPPLASTNING ---\n\nDu får ikke lov å ha stort bilde bredere en 1280px.\n\nVerdien stilles ned til 1280px.");
		document.setting.pimgsize_mainX.focus();
		document.setting.pimgsize_mainX.value = '1280';
		return false;
 	}
	if(validate(document.setting.pimgsize_mainY.value,'Auto resize max large (L) dimensjon'))
	return false
	if(document.setting.pimgsize_mainY.value > 1280){
		alert("    --- BILDE OPPLASTNING ---\n\nDu får ikke lov å ha stort bilde høyere en 1280px.\n\nVerdien stilles ned til 1280px.");
		document.setting.pimgsize_mainY.value = '1280';
		document.setting.pimgsize_mainY.focus();
		return false;
 	}
	if(document.setting.pimgsize_mainX.value < 200){
		alert("    --- BILDE OPPLASTNING ---\n\nDu får ikke lov å ha stort bilde mindre en 200px i bredden.\n\nVerdien stilles opp til 200px.");
		document.setting.pimgsize_mainX.focus();
		document.setting.pimgsize_mainX.value = '200';
		return false;
 	}
	if(document.setting.pimgsize_mainY.value < 200){
		alert("    --- BILDE OPPLASTNING ---\n\nDu får ikke lov å stort bilde mindre en 200px i høyden.\n\nVerdien stilles opp til 200px.");
		document.setting.pimgsize_mainY.value = '200';
		document.setting.pimgsize_mainY.focus();
		return false;
 	}
	if(validate(document.setting.pimgsize_thumbX.value,'Auto-resize max medium (M) dimensjon'))
	return false
	if(document.setting.pimgsize_thumbX.value > 500){
		alert("    --- BILDE OPPLASTNING ---\n\nDu får ikke lov å ha medium bildene bredere en 500px.\n\nVerdien stilles opp til 500px.");
		document.setting.pimgsize_thumbX.focus();
		document.setting.pimgsize_thumbX.value = '500';
		return false;
 	}
	if(validate(document.setting.pimgsize_thumbY.value,'Auto-resize max medium (M) dimensjon'))
	return false
	if(document.setting.pimgsize_thumbY.value > 500){
		alert("    --- BILDE OPPLASTNING ---\n\nDu får ikke lov å ha medium bildene høyere en 500px.\n\nVerdien stilles opp til 500px.");
		document.setting.pimgsize_thumbY.value = '500';
		document.setting.pimgsize_thumbY.focus();
		return false;
 	}
	if(document.setting.pimgsize_thumbX.value < 75){
		alert("    --- BILDE OPPLASTNING ---\n\nDu får ikke lov å ha medium bildene mindre en 75px i bredden.\n\nVerdien stilles opp til 75px.");
		document.setting.pimgsize_thumbX.focus();
		document.setting.pimgsize_thumbX.value = '75';
		return false;
 	}
	if(document.setting.pimgsize_thumbY.value < 75){
		alert("    --- BILDE OPPLASTNING ---\n\nDu får ikke lov å ha medium bildene mindre en 75px i høyden.\n\nVerdien stilles opp til 75px.");
		document.setting.pimgsize_thumbY.value = '75';
		document.setting.pimgsize_thumbY.focus();
		return false;
 	}
	if(validate(document.setting.pimgsize_systemX.value,'Auto-resize max small (S) dimensjon'))
	return false
	if(document.setting.pimgsize_systemX.value > 200){
		alert("    --- BILDE OPPLASTNING ---\n\nDu får ikke lov å ha de minste bildene bredere en 200px.\n\nVerdien stilles ned til 200px.");
		document.setting.pimgsize_systemX.focus();
		document.setting.pimgsize_systemX.value = '200';
		return false;
 	}
	if(validate(document.setting.pimgsize_systemY.value,'Auto-resize max small (S) dimensjon'))
	return false
	if(document.setting.pimgsize_systemY.value > 200){
		alert("    --- BILDE OPPLASTNING ---\n\nDu får ikke lov å ha de minste bildene høyere en 200px.\n\nVerdien stilles ned til 200px.");
		document.setting.pimgsize_systemY.value = '200';
		document.setting.pimgsize_systemY.focus();
		return false;
 	}
	if(document.setting.pimgsize_systemX.value < 25){
		alert("    --- BILDE OPPLASTNING ---\n\nDu får ikke lov å ha de minste bildene mindre en 25px i bredden.\n\nVerdien stilles opp til 25px.");
		document.setting.pimgsize_systemX.focus();
		document.setting.pimgsize_systemX.value = '25';
		return false;
 	}
	if(document.setting.pimgsize_systemY.value < 25){
		alert("    --- BILDE OPPLASTNING ---\n\nDu får ikke lov å ha de minste bildene mindre en 25px i høyden.\n\nVerdien stilles opp til 25px.");
		document.setting.pimgsize_systemY.value = '25';
		document.setting.pimgsize_systemY.focus();
		return false;
 	}
	if(validate(document.setting.richsize_defaultX.value,'Standard bredde artikkel full'))
	return false
	if(document.setting.richsize_defaultX.value > 1024){
		alert("    --- ARTIKKEL OG SIDE EDITOR ---\n\nDu får ikke lov å ha arbeidsfeltet bredere en 1024px.\n\nFeltet stilles ned til 1024px.");
		document.setting.richsize_defaultX.value = '1024';
		document.setting.richsize_defaultX.focus();
		return false;
 	}
	if(document.setting.richsize_defaultX.value < 300){
		alert("    --- ARTIKKEL OG SIDE EDITOR ---\n\nDu får ikke lov å ha arbeidsfeltet smalere en 300px.\n\nFeltet stilles ned til 300px.");
		document.setting.richsize_defaultX.value = '300';
		document.setting.richsize_defaultX.focus();
		return false;
 	}
	if(validate(document.setting.richsize_defaultY.value,'Standard høyde artikkel full'))
	return false
	if(document.setting.richsize_defaultY.value > 750){
		alert("    --- ARTIKKEL OG SIDE EDITOR ---\n\nDu får ikke lov å ha artikkel full feltet høyere en 750px.\n\nFeltet stilles ned til 750px.");
		document.setting.richsize_defaultY.value = '750';
		document.setting.richsize_defaultY.focus();
		return false;
 	}
	if(document.setting.richsize_defaultY.value < 100){
		alert("    --- ARTIKKEL OG SIDE EDITOR ---\n\nDu får ikke lov å ha artikkel full feltet lavere en 100px.\n\nFeltet stilles ned til 100px.");
		document.setting.richsize_defaultY.value = '100';
		document.setting.richsize_defaultY.focus();
		return false;
 	}
	if(validate(document.setting.richsize_ingress.value,'Standard høyde ingress'))
	return false
	if(document.setting.richsize_ingress.value > 400){
		alert("    --- ARTIKKEL OG SIDE EDITOR ---\n\nDu får ikke lov å ha ingress feltet høyere en 400px.\n\nFeltet stilles ned til 400px.");
		document.setting.richsize_ingress.value = '400';
		document.setting.richsize_ingress.focus();
		return false;
 	}
	if(document.setting.richsize_ingress.value < 25){
		alert("    --- ARTIKKEL OG SIDE EDITOR ---\n\nDu får ikke lov å ha ingress feltet lavere en 25px.\n\nFeltet stilles ned til 25px.");
		document.setting.richsize_ingress.value = '25';
		document.setting.richsize_ingress.focus();
		return false;
 	}
	if(validate(document.setting.richsize_extraX.value,'Utvidet bredde artikkel full'))
	return false
	if(document.setting.richsize_extraX.value > 1024){
		alert("    --- ARTIKKEL OG SIDE EDITOR ---\n\nDu får ikke lov å ha det ekstra arbeidsfeltet bredere en 1024px.\n\nFeltet stilles ned til 1024px.");
		document.setting.richsize_extraX.value = '1024';
		document.setting.richsize_extraX.focus();
		return false;
 	}
	if(document.setting.richsize_extraX.value < 300){
		alert("    --- ARTIKKEL OG SIDE EDITOR ---\n\nDu får ikke lov å ha det ekstra arbeidsfeltet smalere en 300px.\n\nFeltet stilles ned til 300px.");
		document.setting.richsize_extraX.value = '300';
		document.setting.richsize_extraX.focus();
		return false;
 	}
	if(validate(document.setting.richsize_extraY.value,'Utvidet høyde artikkel full'))
	return false
	if(document.setting.richsize_extraY.value > 750){
		alert("    --- ARTIKKEL OG SIDE EDITOR ---\n\nDu får ikke lov å ha det ekstra artikkel full feltet høyere en 750px.\n\nFeltet stilles ned til 750px.");
		document.setting.richsize_extraY.value = '750';
		document.setting.richsize_extraY.focus();
		return false;
 	}
	if(document.setting.richsize_extraY.value < 100){
		alert("    --- ARTIKKEL OG SIDE EDITOR ---\n\nDu får ikke lov å ha det ekstra artikkel full feltet lavere en 100px.\n\nFeltet stilles ned til 100px.");
		document.setting.richsize_extraY.value = '100';
		document.setting.richsize_extraY.focus();
		return false;
 	}
};
function InstGenArt(mode){
  if(mode){
    document.setting.richsize_defaultX.value = '620';
    document.setting.richsize_ingress.value  = '120';
    document.setting.richsize_defaultY.value = '300';
    document.setting.richsize_extraX.value   = '750';
    document.setting.richsize_extraY.value   = '500';
  } else {
    document.setting.pimgsize_mainX.value    = '500';	
    document.setting.pimgsize_mainY.value    = '500';	
    document.setting.pimgsize_thumbX.value   = '200';	
    document.setting.pimgsize_thumbY.value   = '200';	
    document.setting.pimgsize_systemX.value  = '75';	
    document.setting.pimgsize_systemY.value  = '75';	
  }
};
function swPOP(url,Xvalue,Yvalue,scroll) {
  var w = 480, h = 340;if (document.all || document.layers) { w = screen.availWidth;h = screen.availHeight; }
  var popW = Xvalue, popH = Yvalue;var leftPos = (w-popW)/2, topPos = (h-popH)/2;
  if (scroll) { i = open(url, "displayWindow","top="+topPos+",left="+leftPos+",width="+Xvalue+",height="+Yvalue+",status=no,toolbar=1,menubar=no,resize=no,dependent=yes,scrollbars=yes");} else { i = open(url, "displayWindow","top="+topPos+",left="+leftPos+",width="+Xvalue+",height="+Yvalue+",status=1,toolbar=1,menubar=0,resize=no,dependent=yes,scrollbars=no");}
};
function zoom(header,alt,url,Xvalue,Yvalue,scroll) {
  Xvalue = Number(Xvalue) + 25;
  Yvalue = Number(Yvalue) + 60;
  if (scroll) {
    i = open("", "EUindow","top=50,left=50,width="+Xvalue+",height="+Yvalue+",status=no,toolbar=no,menubar=no,resize=yes,dependent=yes,scrollbars=yes");
  } else {
    i = open("", "EUindow","top=50,left=50,width="+Xvalue+",height="+Yvalue+",status=no,toolbar=no,menubar=no,resize=no,dependent=yes,scrollbars=no");
  }
  i.focus();
  i.document.open();
  i.document.write('<html>\n')
  i.document.write('<head>\n')
  i.document.write('<title>EasyCMS bilde forhåndsvisning</title>\n')
  i.document.write('<style><!--\n')
  i.document.write('body { \n')
  i.document.write('margin : 0px 0px 0px 0px;\n')
  i.document.write('}\n')
  i.document.write('--></style>\n')
  i.document.write('<\head>\n')
  i.document.write('<body bgcolor="#ffffff" text="#000000">\n')
  i.document.write('<center>\n')
  i.document.write('<div style="font-size:14px; font-weight:bold; font-family:verdana,arial,sans-serif,helvetica;">',header,'</div><a href="javascript:window.close();"><img src="',url,'" border="2" style="border:2px solid white;" alt="',alt,'"></a>\n')
  i.document.write('<div style="font-size:10px;font-family:verdana;color:#808080;">&copy; Easy CMS (c) Steinhaug AS</div></center>\n')
  i.document.write('</body>\n')
  i.document.write('</html>\n');
  i.document.close();
};

function validate(string,felt) {
  var valid="1234567890";
    for (var i=0; i<string.length; i++) {
      if (valid.indexOf(string.charAt(i)) < 0) {
        alert(felt+' inneholder ugyldige tegn!');
      return true;
      }
    }
  return false;
};
function _pullAndReplaceIt(theUrl,replacement){
  var req = new XMLHttpRequest();
  if (req) {
    req.onreadystatechange = function() {
      if (req.readyState == 4 && req.status == 200) {
        document.getElementById(replacement).innerHTML = req.responseText;
      }
    };
    req.open('GET', theUrl);
    req.send(null);
  }
};

/* -------------------------------------------------- */
/* Følgende funksjoner kan slettes, men legger inn en */
/* backfall i tilfelle man trenger dem er ibruk       */
/* -------------------------------------------------- */

function validateNR(theform,felt) {
  alert('Easy Webshop function');
  return false;
} 
function validateNRd(theform,felt) {
  alert('Easy Webshop function');
  return false;
} 
function validateLOW (id,range){
  alert('Easy Webshop function');
  return false;
}
function search(keyword, where){
  alert('Easy Webshop function');
  return false;
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *  XMLHttpRequestHeartBeat v1.0                                     *
 *  Simple system for giving a steady heartbeat to the webserver     *
 *  to avoid session timeout and loosing work on pages a user might  *
 *  spend a long time working on                                     *
 *                                                                   *
 *  Revised : 19 August 2005                                         *
 *  Author  : kim@steinhaug.com                                      *
 *                                                                   *
 *  Start :                                                          *
 *  XMLHttpRequestHeartBeatInit([int seconds]);                      *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
function XMLHttpRequestHeartBeat(replacement,heartbeatUrl) {
  var currentTime = new Date();
  var req = new XMLHttpRequest();
  if (req) {
    req.onreadystatechange = function() {
      if (req.readyState == 4 && req.status == 200) {
         // To debug remove and add <div id="heartbeat"></div> somewhere on the page
         // document.getElementById(replacement).innerHTML = req.responseText;
      };
    };
    req.open('GET', heartbeatUrl + '?' + currentTime.getDay() + currentTime.getHours() + currentTime.getMinutes() + currentTime.getSeconds());
    req.send(null);
  }
}


function XMLHttpRequestHeartBeatInit(seconds){

  var heartbeatUrl = 'heartbeat.php';
  seconds = seconds * 1000;
  //sw_heartbeat_alert = setTimeout('alert("Serverpuls ble ikke aktivert, du må derfor lagre arbeidet innen 20 minutter for å unngå å bli logget ut automatisk.")',15000);
  sw_heartbeat_alert = setTimeout('alert("SERVERPULS BLE IKKE AKTIVERT\\n\\nDet har nå gått 15 minutter og du vil snart (typisk om ca. 5-10 minutter) automatisk bli logget ut av serveren,\\nvi anbefaler deg lagre arbeidet ditt så langt å så velge å redigere siden på nytt.\\nDa har du en ny periode innen du automatisk blir logget ut.\\n\\nVi gjør også oppmerksom på at denne feilmeldingen dukker opp ettersom serverPuls ikke ble aktivert,\\nnoe som tyder på en feil med din installasjon av Easy CMS.\\n\\nTa kontakt med support for å løse dette problemet, så slipper du også denne meldingen.")',900000);
  var currentTime = new Date();
  var req = new XMLHttpRequest();
  if (req) {
    req.onreadystatechange = function() {
      if (req.readyState == 4 && req.status == 200) {
        if(req.responseText=='ready'){
          clearTimeout(sw_heartbeat_alert);
          sw_heartbeat = setInterval('XMLHttpRequestHeartBeat("heartbeat","' + heartbeatUrl + '")',seconds);
        };
      };
    };
    req.open('GET', heartbeatUrl + '?status=initialize&' + currentTime.getDay() + currentTime.getHours() + currentTime.getMinutes() + currentTime.getSeconds());
    req.send(null);
  }
}

/* TAGG : content_cms.php */
function UpdateGroupAssignments(){
  if (document.CMS.boxchecked.value == 0){
    alert('Vennligst velg hvilke elementer du vil endre gruppetilhørighet på');
  } else {
    document.CMS.action.value = "UpdateGroupAssignments";
    document.CMS.unit.value = $('groupid').value;
    document.CMS.submit();
  }
}
function UpdateGroupAssignments_intranet(){
  if (document.CMS.boxchecked.value == 0){
    alert('Vennligst velg hvilke elementer du vil endre intranett gruppetilhørighet på');
  } else {
    document.CMS.action.value = "UpdateGroupAssignments_intranet";
    document.CMS.unit.value = $('groupid_intranet').value;
    document.CMS.submit();
  }
}
function publishItems(){
  if (document.CMS.boxchecked.value == 0){
    alert('Vennligst velg hvilke elementer du vil publisere');
  } else {
    document.CMS.action.value="publish";
    document.CMS.submit();
  }
}
function unpublishItems(){
  if (document.CMS.boxchecked.value == 0){
    alert('Vennligst velg hvilke elementer du vil deaktivere');
  } else {
    document.CMS.action.value="unpublish";
    document.CMS.submit();
  }
}
function publishItem(unit){
  document.CMS.action.value="publish_single";
  document.CMS.unit.value=unit;
  document.CMS.submit();
}
function unpublishItem(unit){
  document.CMS.action.value="unpublish_single";
  document.CMS.unit.value=unit;
  document.CMS.submit();
}

function deleteItems(){
  if (document.CMS.boxchecked.value == 0){
    alert('Vennligst velg hva du vil slette');
  } else if (confirm('Er du sikker på at du vil slette de valgte elementene? ')){
    document.CMS.action.value="delete";
    document.CMS.submit();
  }
}
function ElementalChaos(ShaZaM,KabloM){
  if (document.getElementById) {
    document.getElementById(ShaZaM).src = 'images/' + KabloM;
  }
}
function isChecked(isitchecked){
  if (isitchecked == true){
    document.CMS.boxchecked.value++;
  } else {
    document.CMS.boxchecked.value--;
  }
}
function moveUp(unit){
  document.CMS.action.value="reorder";
  document.CMS.direction.value="up";
  document.CMS.unit.value=unit;
  document.CMS.submit();
}
function moveDown(unit){
  document.CMS.action.value="reorder";
  document.CMS.direction.value="down";
  document.CMS.unit.value=unit;
  document.CMS.submit();
}
function moveUpSub(unit,category){
  document.CMS.action.value="reorder";
  document.CMS.direction.value="up";
  document.CMS.category.value=category;
  document.CMS.unit.value=unit;
  document.CMS.submit();
}
function moveDownSub(unit,category){
  document.CMS.action.value="reorder";
  document.CMS.direction.value="down";
  document.CMS.category.value=category;
  document.CMS.unit.value=unit;
  document.CMS.submit();
}
function moveUpSubSub(me,daddy,grandaddy){
  document.CMS.action.value="reorder";
  document.CMS.direction.value="up";
  document.CMS.subcategory.value=daddy;
  document.CMS.category.value=grandaddy;
  document.CMS.unit.value=me;
  document.CMS.submit();
}
function moveDownSubSub(me,daddy,grandaddy){
  document.CMS.action.value="reorder";
  document.CMS.direction.value="down";
  document.CMS.subcategory.value=daddy;
  document.CMS.category.value=grandaddy;
  document.CMS.unit.value=me;
  document.CMS.submit();
}

/* Autoresize textarea while typing */
function autoResize(el, lines){
  var row = (el.value + "a").split(/\n/).length;
  applyStyleString(el,'height: ' + (15 * ((row < lines) ? lines : row + 1)) + 'px');
}

function checkAll(n) {
  var f = document.CMS;
  var c = f.toggle.checked;
  var n2 = 0;
  for (i=0; i < n; i++) {
    cb = eval( 'f.cb' + i );
    if (cb) {
      cb.checked = c;
      n2++;
    }
  }
  if (c) {
    document.CMS.boxchecked.value = n2;
  } else {
    document.CMS.boxchecked.value = 0;
  }
}

  function confirm_cms_convert(cid,ctype){
    if(ctype==1){
      if(confirm('Er du sikker på du vil konvertere siden?' + "\n" + 'Vær oppmerksom at denne konverteringen sletter siden, du kan ikke få siden tilbake!')){
        window.location.href = 'content_cms.php?convert=' + cid + '&type=' + ctype;
      }
    } else {
      if(confirm('Er du sikker på du vil konvertere siden')){
        window.location.href = 'content_cms.php?convert=' + cid + '&type=' + ctype;
      }
    }
  }
  var cookieNames = new Array();
  function Get_Cookie(name) { 
    var start = document.cookie.indexOf(name+"="); 
    var len = start+name.length+1; 
    if ((!start) && (name != document.cookie.substring(0,name.length))) return null; 
    if (start == -1) return null; 
    var end = document.cookie.indexOf(";",len); 
    if (end == -1) end = document.cookie.length; 
    return unescape(document.cookie.substring(len,end)); 
  } 
  function Set_Cookie(name,value,expires,path,domain,secure) { 
    expires = expires * 60*60*24*1000;
    var today = new Date();
    var expires_date = new Date( today.getTime() + (expires) );
    var cookieString = name + "=" +escape(value) + 
      ( (expires) ? ";expires=" + expires_date.toGMTString() : "") + 
      ( (path) ? ";path=" + path : "") + 
      ( (domain) ? ";domain=" + domain : "") + 
      ( (secure) ? ";secure" : ""); 
    document.cookie = cookieString; 
  }
  function init_size(id){
    cookieValue = Get_Cookie(id);
    el = document.getElementById(id);
    if(parseInt(cookieValue)){
      el.height = parseInt(cookieValue);
    }
  }
  function size_it(id,direction){
    var step = 50;
    el = document.getElementById(id);
    var currentY = parseInt(el.style.height);
    if(direction=='down'){
      if(currentY>75){
        el.style.height = (parseInt(currentY) - parseInt(step)) + "px";
      } else {
        el.style.height = 50;
      }
    } else {
      el.style.height = (parseInt(currentY) + parseInt(step)) + "px";
    }
      Set_Cookie(id,el.style.height,100000);
  }

function confirmDelete(title,uri){
  if (confirm('Er du sikker på at du vil slette ' + title + '?')){
    location.href=uri;
  }
}

/* TAGG : content_cms.php */




/* Quick IE version */
function CheckTabIE(el){
  // Run only in IE
  // and if tab key is pressed
  // and if the control key is pressed
//  if ((document.all) && (9==event.keyCode) && (event.ctrlKey)) {
  if ((document.all) && (9==event.keyCode)) {
  // Cache the selection
  el.selection=document.selection.createRange(); 
  setTimeout("ProcessTabIE('" + el.id + "')",0);
  }
}
function ProcessTabIE(id){
  // Insert tab character in place of cached selection
  document.all[id].selection.text=String.fromCharCode(9);
  // Set the focus
  document.all[id].focus();
}
/* Other version */
        
        // Set desired tab- defaults to four space softtab
        var tab = "    ";
        
        function checkTab(evt) {
            var t = evt.target;
            var ss = t.selectionStart;
            var se = t.selectionEnd;

            // Tab key - insert tab expansion
            if (evt.keyCode == 9) {
                evt.preventDefault();
                
                // Special case of multi line selection
                if (ss != se && t.value.slice(ss,se).indexOf("\n") != -1) {
                    // In case selection was not of entire lines (e.g. selection begins in the middle of a line)
                    // we ought to tab at the beginning as well as at the start of every following line.
                    var pre = t.value.slice(0,ss);
                    var sel = t.value.slice(ss,se).replace(/\n/g,"\n"+tab);
                    var post = t.value.slice(se,t.value.length);
                    t.value = pre.concat(tab).concat(sel).concat(post);
                    
                    t.selectionStart = ss + tab.length;
                    t.selectionEnd = se + tab.length;
                }
                
                // "Normal" case (no selection or selection on one line only)
                else {
                    t.value = t.value.slice(0,ss).concat(tab).concat(t.value.slice(ss,t.value.length));
                    if (ss == se) {
                        t.selectionStart = t.selectionEnd = ss + tab.length;
                    }
                    else {
                        t.selectionStart = ss + tab.length;
                        t.selectionEnd = se + tab.length;
                    }
                }
            }
            
            // Backspace key - delete preceding tab expansion, if exists
            else if (evt.keyCode==8 && t.value.slice(ss - 4,ss) == tab) {
                evt.preventDefault();
                
                t.value = t.value.slice(0,ss - 4).concat(t.value.slice(ss,t.value.length));
                t.selectionStart = t.selectionEnd = ss - tab.length;
            }
            
            // Delete key - delete following tab expansion, if exists
            else if (evt.keyCode==46 && t.value.slice(se,se + 4) == tab) {
                evt.preventDefault();
                
                t.value = t.value.slice(0,ss).concat(t.value.slice(ss + 4,t.value.length));
                t.selectionStart = t.selectionEnd = ss;
            }
            
            // Left/right arrow keys - move across the tab in one go
            else if (evt.keyCode == 37 && t.value.slice(ss - 4,ss) == tab) {
                evt.preventDefault();
                t.selectionStart = t.selectionEnd = ss - 4;
            }
            else if (evt.keyCode == 39 && t.value.slice(ss,ss + 4) == tab) {
                evt.preventDefault();
                t.selectionStart = t.selectionEnd = ss + 4;
            }
            
        }

// Constructor
function MCContextMenu() {
	this.isMSIE = navigator.appName == "Microsoft Internet Explorer";
	this.isGecko = navigator.userAgent.indexOf('Gecko') != -1;
	this.isSafari = navigator.userAgent.indexOf('Safari') != -1;
	this.isOpera = navigator.userAgent.indexOf("Opera") != -1;
	this.doc = document;
	this.win = window;
	this.items = new Array();
	this.settings = new Array();
	this.menuDiv = null;
	this.menuGenerated = false;
	this.counter = 0;
	this.oldItems = null;

    this.temp_x  = 0;
    this.temp_y  = 0;
    this.temp_dx = 0;
    this.temp_dy = 0;
}

// Methods
MCContextMenu.prototype = {
	init : function(settings) {
		this.settings = typeof(settings) == "undefined" ? new Array() : settings;

		this.defParam("contain_within_body", true);
		this.defParam("handle_iframe_events", true);
		this.defParam("add_before_attrib", "contextmenuaddbefore");
		this.defParam("add_after_attrib", "contextmenuaddafter");
		this.defParam("contextmenu_attrib", "contextmenu");
		this.defParam("ajax_attrib", "acm");
		this.defParam("replace_browser_menu", true);

//		this.addEvent(window, "load", MCContextMenu.prototype.onLoad);
        ELO.functionsToCallOnload.push("MCContextMenu.prototype.onLoad()");
	},

	onLoad : function() {
		mcContextMenu.registerEventListeners(document);

		if (mcContextMenu.getParam('handle_iframe_events')) {
			for (var i=0; i<window.frames.length; i++) {
				try {
					var doc = window.frames[i].document;
					doc.body.mcContextMenuBodyID = "mc" + mcContextMenu.counter++;
					mcContextMenu.registerEventListeners(doc);
				} catch (ex) {
					// May throw security exception
				}
			}
		}
	},

	registerEventListeners : function(doc) {
		this.addEvent(doc, "contextmenu", mcContextMenu.showEvent);
		this.addEvent(doc, "click", mcContextMenu.hideEvent);
		this.addEvent(doc, "keypress", mcContextMenu.hideEvent);
	},

	showEvent : function(e) {
		e = typeof(e) == "undefined" ? window.event : e;
		var elm = e.srcElement ? e.srcElement : e.target;
		var body = mcContextMenu.getBody(elm);
		var lnk = mcContextMenu.getParentElement(elm, 'A');
        if(!lnk){
          var lnk = mcContextMenu.getParentElement(elm, 'IMG');
        }
		var x, y, dx = 0, dy = 0;
		var modified = false;

		// Restore default menu
		if (mcContextMenu.oldItems) {
			mcContextMenu.menuGenerated = false;
			mcContextMenu.items = mcContextMenu.cloneArray(mcContextMenu.oldItems);
			mcContextMenu.oldItems = null;
		}

		if (lnk) {
			var before = lnk.getAttribute(mcContextMenu.getParam('add_before_attrib'));
			var after = lnk.getAttribute(mcContextMenu.getParam('add_after_attrib'));
			var replace = lnk.getAttribute(mcContextMenu.getParam('contextmenu_attrib'));

            var acm = lnk.getAttribute(mcContextMenu.getParam('ajax_attrib'));  // Pick the new system
            if (acm && acm != "") {                                             // If we infact have any data
              mcContextMenu.showEventAjaxMode(e);                               // we cancel this and execute the
              return true;                                                      // new Ajax-system.
            }

			mcContextMenu.oldItems = mcContextMenu.cloneArray(mcContextMenu.items);

			if (after && after != "") {
				var ar = mcContextMenu.explode(';', mcContextMenu.escapeCM(after));

				for (var i=0; i<ar.length; i++)
					mcContextMenu.addItem(ar[i]);

				modified = true;
			}

			if (before && before != "") {
				var ar = mcContextMenu.explode(';', mcContextMenu.escapeCM(before));

				for (var i=ar.length-1; i>=0; i--)
					mcContextMenu.addItemAtBeginning(ar[i]);

				modified = true;
			}

			if (replace && replace != "") {
				mcContextMenu.clear();

				var ar = mcContextMenu.explode(';', mcContextMenu.escapeCM(replace));

				for (var i=0; i<ar.length; i++)
					mcContextMenu.addItem(ar[i]);

				modified = true;
			}
		}

		if (!mcContextMenu.getParam("replace_browser_menu") && !modified) {
			mcContextMenu.hide();
			return true;
		}

		if (mcContextMenu.isMSIE) {
			dx = body.scrollLeft;
			dy = body.scrollTop;
		}

		if (body.mcContextMenuBodyID) {
			var iframe = mcContextMenu.getIFrameElement(body.mcContextMenuBodyID);
			var pos = mcContextMenu.getAbsPosition(iframe);
			dx = pos.absLeft;
			dy = pos.absTop;

			if (!mcContextMenu.isMSIE) {
				dx -= body.scrollLeft;
				dy -= body.scrollTop;
			}
		}

		if (mcContextMenu.isMSIE) {
			x = e.clientX;
			y = e.clientY;
		} else {
			x = e.pageX;
			y = e.pageY;
		}

		x += dx;
		y += dy;

		// Range check
		x = x < 0 ? 0 : x;
		y = y < 0 ? 0 : y;

		// Show menu
		if (mcContextMenu.getParam("replace_browser_menu") || mcContextMenu.items.length > 0) {
			mcContextMenu.show(x, y);
			mcContextMenu.cancelEvent(e);
			return false;
		} else
			mcContextMenu.hide();

		return true;
	},

	showEventAjaxMode : function(e) {
		e = typeof(e) == "undefined" ? window.event : e;
		var elm = e.srcElement ? e.srcElement : e.target;
		var body = mcContextMenu.getBody(elm);
		var lnk = mcContextMenu.getParentElement(elm, 'A');
        if(!lnk){
          var lnk = mcContextMenu.getParentElement(elm, 'IMG');
        }
		var x, y, dx = 0, dy = 0;
		var modified = false;

		// Restore default menu
		if (mcContextMenu.oldItems) {
			mcContextMenu.menuGenerated = false;
			mcContextMenu.items = mcContextMenu.cloneArray(mcContextMenu.oldItems);
			mcContextMenu.oldItems = null;
		}
		if (lnk) {
            var acm = lnk.getAttribute(mcContextMenu.getParam('ajax_attrib'));              // Pick the new system
            mcContextMenu.oldItems = mcContextMenu.cloneArray(mcContextMenu.items);
			if (acm && acm != "") {
				mcContextMenu.clear();
                var ar = mcContextMenu.escapeCM(acm);
                var req = new XMLHttpRequest(); 
                if (req) { 
                  req.onreadystatechange = function() {
                    if (req.readyState == 4 && req.status == 200) { 
                      if (req.status && req.status != "" && req.status != 'no data!') {
                        mcContextMenu.showEventAjaxModeShow(e,req.responseText);
                      }
                    } 
                  }
                  var currentTime = new Date();
                  if (ar && ar != "") {
                    var modified = true;
                    mcContextMenu.cancelEvent(e);  // Cancel the real context menu
                  }
                  if (!mcContextMenu.getParam("replace_browser_menu") && !modified) {
                    mcContextMenu.hide();
                    return true;
                  }
                  if (mcContextMenu.isMSIE) {
                    dx = body.scrollLeft;
                    dy = body.scrollTop;
                  }
                  if (body.mcContextMenuBodyID) {
                    var iframe = mcContextMenu.getIFrameElement(body.mcContextMenuBodyID);
                    var pos = mcContextMenu.getAbsPosition(iframe);
                    dx = pos.absLeft;
                    dy = pos.absTop;
                    if (!mcContextMenu.isMSIE) {
                      dx -= body.scrollLeft;
                      dy -= body.scrollTop;
                    }
                  }
                  if (mcContextMenu.isMSIE) {
                    x = e.clientX;
                    y = e.clientY;
                  } else {
                    x = e.pageX;
                    y = e.pageY;
                  }
                  x += dx;
                  y += dy;
                  // Range check
                  x = x < 0 ? 0 : x;
                  y = y < 0 ? 0 : y;
                  mcContextMenu.ajax_x  = x;  // Store data
                  mcContextMenu.ajax_y  = y;  // Store data
                  mcContextMenu.ajax_dx = dx; // Store data
                  mcContextMenu.ajax_dy = dy; // Store data
                  req.open('GET', 'func.context-menu.php?data=' + ar + '&' + currentTime.getDay() + currentTime.getHours() + currentTime.getMinutes() + currentTime.getSeconds()); 
                  req.send(null);
                } else {
                  // Error, output dummy menu
                  // Trigger contextmenu without nothing
                }
			}
		} // if lnk end
	},
	showEventAjaxModeShow : function(e,val) {
// Debug 
//document.forms.test.trigger.value = val;

		e = typeof(e) == "undefined" ? window.event : e;
		var elm = e.srcElement ? e.srcElement : e.target;
		var body = mcContextMenu.getBody(elm);

        var x = mcContextMenu.ajax_x;
        var y = mcContextMenu.ajax_y;
        var dx = mcContextMenu.ajax_dx;
        var dy = mcContextMenu.ajax_dy;

        var modified = true;
		var ar = mcContextMenu.explode(';', mcContextMenu.escapeCM(val));
		for (var i=0; i<ar.length; i++)
    		mcContextMenu.addItem(ar[i]);

		// Show menu
		if (mcContextMenu.getParam("replace_browser_menu") || mcContextMenu.items.length > 0) {
			mcContextMenu.show(x, y);
			return false;
		} else
			mcContextMenu.hide();

		return true;
	},

	hideEvent : function(e) {
		mcContextMenu.hide();
		return true;
	},

	show : function(x, y) {
        // Latest Dustin Diaz Sweet Tiles
    	var sweetTitles = document.getElementById('toolTip');
		if ( sweetTitles ) {
          sweetTitles.style.visibility = 'hidden';
        }
		// Create menu div
		if (this.menuDiv == null) {
			// Add iframe
			if (this.isMSIE) {
				this.iframe = this.doc.createElement("iframe");
				this.iframe.src = "javascript:void(0);";
				this.iframe.className = "mcContextMenuIFrame";
				this.iframe.frameBorder = "0";
				this.iframe.style.display = "none";
				this.doc.body.appendChild(this.iframe);
			}

			this.menuDiv = this.doc.createElement("div");
			this.menuDiv.className = "mcContextMenuContainer";
			this.doc.body.appendChild(this.menuDiv);
		}

		// Fill menu with items
		if (!this.menuGenerated) {
			var html = "";
			var anyIcons = false;

            // Sprite is counted as Icon aswell
			for (var i=0; i<this.items.length; i++) {
				if (this.items[i].icon)
					anyIcons = true;
				if (this.items[i].sprite)
					anyIcons = true;
			}

            html += '<div class="mcContextMenuInnerContainer">';
			html += '<table border="0" cellpadding="0" cellspacing="0" class="mcContextMenu ' + (anyIcons ? '' : 'NoImagePadding') + '">';

			for (var i=0; i<this.items.length; i++) {
				var item = this.items[i];
				var cls = "";

				cls += " " + (item.class_name ? item.class_name : "");
				cls += " " + (item.disabled ? "mcContextMenuItemDisabled" : "");

				html += '<tr';

				if (item.title == '--') {
					html += '><td class="mcContextMenuSeparator" nowrap="nowrap"' + (anyIcons ? 'colspan="2"' : '') + ' align="center"><div></div></td>';

                    if(item.header){
                      html += '</tr>';
                      html += '<tr><td colspan="2" class="mcContextMenu-header">' + item.header + '</td>';
                    }

				} else {
					html += ' onmouseover="mcContextMenu.addCSSClass(this,\'mcContextMenuItemOver\');"';
					html += ' onmouseout="mcContextMenu.removeCSSClass(this,\'mcContextMenuItemOver\');">';

					if (anyIcons) {
						html += '<td class="mcContextMenuItem' + cls + '" nowrap="nowrap"';
/* Added Kim */
					if (item.url && !item.disabled)
						html += ' onmouseup="document.location=\'' + this.jsEncode(item.url) + '\';"';

						html += '>';

						if (item.sprite)
							html += '<div class="cmCSS cm' + item.sprite + '"></div>';
						else if (item.icon)
							html += '<img src="' + item.icon + '" width="16" height="16" class="mcContextMenuImage" />';
						else
							html += '&nbsp;';

						html += '</td>';
					}

					if (item.disabled){
						html += '<td class="mcContextMenuItem' + cls + '" nowrap="nowrap"';
						html += ' onmouseover="mcContextMenu.addCSSClass(this,\'mcContextMenuItemOverDisabled\');"';
						html += ' onmouseout="mcContextMenu.removeCSSClass(this,\'mcContextMenuItemOverDisabled\');"';
					} else {
/*
						html += '<td class="mcContextMenuItem' + cls + '" nowrap="nowrap"';
						html += ' onmouseover="mcContextMenu.addCSSClass(this,\'mcContextMenuItemOver\');"';
						html += ' onmouseout="mcContextMenu.removeCSSClass(this,\'mcContextMenuItemOver\');"';
*/
						html += '<td ';
					}

// Fires extra event in IE and indeed launches the URL twice which is bad 
					if (item.url && !item.disabled)
						html += ' onmouseup="document.location=\'' + this.jsEncode(item.url) + '\';"';
					if (item.js && !item.disabled)
						html += ' onmouseup="' + item.js + '"';




					html += '>';

					if (item.disabled)
						html += '<span class="mcContextMenuItemText">' + this.xmlEncode(item.title) + '<span>' + this.xmlEncode(item.title) + '</span></span>';
					else
						html += '<span class="mcContextMenuItemText">' + this.xmlEncode(item.title) + '</span>';

//						html += '<a class="mcContextMenuItemText" href="' + this.xmlEncode(item.url) + '" onclick="return false;" onmousedown="return false;">' + this.xmlEncode(item.title) + '</a>';

					html += '</td>';
				}

				html += '</tr>';
            }

            html += "</table>";
            html += "</div>";
            
			this.menuDiv.innerHTML = html;
// Debug 
// document.forms.test.html.value = html;

			this.menuGenerated = true;
        }

        // Measure it
        this.menuDiv.style.left = "-1000px";
        this.menuDiv.style.top = "-1000px";
        this.menuDiv.style.display = 'block';
        width = this.menuDiv.offsetWidth;
        height = this.menuDiv.offsetHeight;

        // Get max x, y
        if (this.getParam("contain_within_body")) {
            var x2 = this.doc.body.scrollLeft + this.doc.body.clientWidth;
            var y2 = this.doc.body.scrollTop + this.doc.body.clientHeight;

            // Move it inside view port
            x = x + width > x2 ? x2 - width : x;
            y = y + height > y2 ? y2 - height : y;

          // Kim HACK to fix IE when window is scrolled
          if (this.isMSIE){
            var y2 = this.doc.body.clientHeight;
            if (document.documentElement && !document.documentElement.scrollTop)
              topoffset = document.documentElement.scrollTop;
              else if (document.documentElement && document.documentElement.scrollTop)
              topoffset = document.documentElement.scrollTop;
              else if (document.body && document.body.scrollTop)
              topoffset = document.body.scrollTop
            var y2 = this.doc.body.clientHeight;
			y = y + height > y2 ? y2 - height : y;
            y = y + topoffset;
          }

        }

        // Range check
        x = x < 0 ? 0 : x;
        y = y < 0 ? 0 : y;

        // Make it visible
        this.menuDiv.style.left = x + "px";
        this.menuDiv.style.top = y + "px";

        if (this.isMSIE) {
            this.iframe.style.left = x + "px";
            this.iframe.style.top = y + "px";
            this.iframe.style.width = width + "px";
            this.iframe.style.height = height + "px";
            this.iframe.style.display = "block";
        }
	},

	hide : function() {
		if (this.menuDiv != null)
			this.menuDiv.style.display = 'none';

		if (this.iframe != null)
			this.iframe.style.display = 'none';
	},

	clear : function() {
		this.items = new Array();
		this.menuGenerated = false;
	},

	addItemAtBeginning : function(s) {
		this.addItem(s, true);
	},

	addItem : function(s, infront) {
		if (infront)
			this.items.unshift(this.parseItem(s));
		else
			this.items[this.items.length] = this.parseItem(s);

		this.menuGenerated = false;
	},

	addSeparator : function() {
		this.addItem('--:--');
		this.menuGenerated = false;
	},

	getParam : function(name, default_value, type) {
		var value = typeof(this.settings[name]) == "undefined" ? default_value : this.settings[name];
		var type = typeof(type) == "undefined" ? "string" : type;

		if (value == "true" || value == "false")
			return value == "true";

		return value;
	},

	defParam : function(k, v) {
		this.settings[k] = this.getParam(k, v);
	},

	addEvent : function(obj, name, handler) {
		if (typeof(obj.attachEvent) != "undefined")
			obj.attachEvent("on" + name, handler);
		else
			obj.addEventListener(name, handler, false);
	},

	cancelEvent : function(e) {
		if (typeof(e.preventDefault) != "undefined") {
			e.preventDefault();
			return;
		}

		e.returnValue = false;
		e.cancelBubble = true;
	},

	getAbsPosition : function(node) {
		var p = {absLeft : 0, absTop : 0};
		var pn = node;

		while (pn) {
			p.absLeft += pn.offsetLeft;
			p.absTop += pn.offsetTop;
			pn = pn.offsetParent;
		}

		return p;
	},

	trim : function(s) {
		return s.replace(/^\s*|\s*$/g, "");
	},

	xmlEncode : function(s) {
		s = s.replace(/&/g, '&amp;');
		s = s.replace(/\"/g, '&quot;');
		s = s.replace(/</g, '&lt;');
		s = s.replace(/>/g, '&gr;');
		return s;
	},

	jsEncode : function(s) {
		s = s.replace(new RegExp('"', 'g'), '\\"');
		s = s.replace(new RegExp("'", 'g'), "\\'");
		return s;
	},

	getBody : function(e) {
		if (e == null)
			return null;

		if (e.nodeName == "HTML")
			return e.getElementsByTagName("BODY")[0];

		return this.getParentElement(e, "BODY");
	},

	getParentElement : function(e, name) {
		var p = e;
		do {
			if (p.nodeName == name)
				return p;
		} while (p = p.parentNode);

		return null;
	},

	getIFrameElement : function(id) {
		var n = document.getElementsByTagName("iframe");
		for (var i=0; i<n.length; i++) {
			if (n[i].contentWindow.document.body.mcContextMenuBodyID == id)
				return n[i];
		}

		return null;
	},

	addCSSClass : function(elm, cls) {
		this.removeCSSClass(elm, cls);
		var ar = this.explode(' ', elm.className);
		ar[ar.length] = cls;
		elm.className = ar.join(' ');
	},

	removeCSSClass : function(elm, cls) {
		var ar = this.explode(' ', elm.className);

		for (var i=0; i<ar.length; i++) {
			if (ar[i] == cls)
				ar[i] = '';
		}

		elm.className = ar.join(' ');
	},

    validateSpacer : function(s) {
      /* Added by Kim Steinhaug
         Extends the devider    */
      if(s.search(new RegExp("^--:","gi"))>=0)
        return true;
      else if(s == '--'){
        return true;
      } else {
        return false;
      }
    },

	parseItem : function(s) {
		s = this.escapeCM(s);
        if (!this.validateSpacer(this.trim(s))) {
            var ar = new RegExp('^\\s*?(.*?)\\s*?:', 'gi').exec(s);  // Corrected after email from Johan 
			// var ar = new RegExp('^\s*?(.*?)\s*?:', 'gi').exec(s); // Gives error 
			var title = ar != null && ar.length == 2 ? ar[1] : "";
		} else {
			title = '--';
        }

		var otitle = this.parseOption(s, 'title');

		return {
			title : otitle == "" ? title : otitle,
			url : this.parseOption(s, 'url'),
			js : this.parseOption(s, 'js'),
			header : this.parseOption(s, 'header'), // New one!
			icon : this.parseOption(s, 'icon'),
            sprite : this.parseOption(s, 'sprite'),
			class_name : this.parseOption(s, 'class'),
			disabled : s.indexOf('disabled') != -1
		};
	},

	parseOption : function(s, n) {
		var ar = new RegExp(n + '\\(\'(.*?)\'\\)', 'gi').exec(s);
		return ar != null && ar.length == 2 ? this.unescapeCM(ar[1]) : '';
	},

	escapeCM : function(s) {
		s = s.replace(new RegExp("''", 'gi'), '<<dquot>>');
		s = s.replace(new RegExp(";;", 'gi'), '<<scolon>>');

		return s;
	},

	unescapeCM : function(s) {
		s = s.replace(/<<dquot>>/gi, "'");
		s = s.replace(/<<scolon>>/gi, ";");

		return s;
	},

	explode : function(d, s) {
		var ar = s.split(d);
		var oar = new Array();

		for (var i = 0; i<ar.length; i++) {
			if (ar[i] != "")
				oar[oar.length] = ar[i];
		}

		return oar;
	},

	cleanArray : function(ar) {
		for (var k in ar)
			ar[k] = null;
	},

	cloneArray : function(ar) {
		var oar = new Array();

		this.cleanArray(oar);

		for (var k in ar)
			oar[k] = ar[k];

		for (var i=0; i<ar.length; i++)
			oar[i] = ar[i];

		return oar;
	}
};
// Setup context menu
mcContextMenu = new MCContextMenu();
mcContextMenu.init({
	replace_browser_menu : false
});

// Setup default menu
mcContextMenu.addItem("Switch menu:url('http://www.somesite.com');");
mcContextMenu.addSeparator();
mcContextMenu.addItem("Cut:url('javascript:alert(''Cut'');') icon('images/cut.gif')");
mcContextMenu.addItem("Copy:url('http://www.somesite.com') icon('images/copy.gif");
mcContextMenu.addItem("Paste:url('http://www.somesite.com') icon('images/paste.gif') disabled");
/*
Sweet Titles (c) Creative Commons 2005
http://creativecommons.org/licenses/by-sa/2.5/
Author: Dustin Diaz | http://www.dustindiaz.com
*/
var sweetTitles = { 
	xCord : 0,								// @Number: x pixel value of current cursor position
	yCord : 0,								// @Number: y pixel value of current cursor position
	tipElements : ['a','img'],                    // @Array: Allowable elements that can have the toolTip, default : 'a','abbr','acronym'
	obj : Object,							// @Element: That of which you're hovering over
	tip : Object,							// @Element: The actual toolTip itself
	active : 0,								// @Number: 0: Not Active || 1: Active
    fadespeed : 40,                         // default : 10, amount of opacity increase
	init : function() {
		if ( !document.getElementById ||
			!document.createElement ||
			!document.getElementsByTagName ) {
			return;
		}
		var i,j;
		this.tip = document.createElement('div');
		this.tip.id = 'toolTip';
		document.getElementsByTagName('body')[0].appendChild(this.tip);
		this.tip.style.top = '0';
		this.tip.style.visibility = 'hidden';
		var tipLen = this.tipElements.length;
		for ( i=0; i<tipLen; i++ ) {
			var current = document.getElementsByTagName(this.tipElements[i]);
			var curLen = current.length;
			for ( j=0; j<curLen; j++ ) {

              // Only attach tooltips on A with IMG inside
              if(current[j].firstChild != null){
                var img = current[j].firstChild;
                if(img.nodeName=='IMG'){
                  if(img.alt){
                    addEvent(current[j],'mouseover',this.tipOver);
                    addEvent(current[j],'mouseout',this.tipOut);
//                    current[j].setAttribute('tip',current[j].title);
//                    current[j].removeAttribute('title');
                    current[j].setAttribute('tip',img.alt);
                    img.removeAttribute('alt');
                    current[j].removeAttribute('title');
                  }
                }
              // Add support for single images if enabled!
              } else if( (current[j].nodeName=='IMG') && this.tipElements.inArray('img') ){
                  if(current[j].alt){
                    addEvent(current[j],'mouseover',this.tipOver);
                    addEvent(current[j],'mouseout',this.tipOut);
                    current[j].setAttribute('tip',current[j].alt);
                    current[j].removeAttribute('alt');
                    current[j].removeAttribute('title');
                  }
              }

			}
		}
	},
	updateXY : function(e) {
		if ( document.captureEvents ) {
			sweetTitles.xCord = e.pageX;
			sweetTitles.yCord = e.pageY;
		} else if ( window.event.clientX ) {
            xoffset = -20;
            yoffset = 0;
			sweetTitles.xCord = window.event.clientX+document.documentElement.scrollLeft + xoffset;
			sweetTitles.yCord = window.event.clientY+document.documentElement.scrollTop + yoffset;
		}
	},
	tipOut: function() {
		if ( window.tID ) {
			clearTimeout(tID);
		}
		if ( window.opacityID ) {
			clearTimeout(opacityID);
		}
		sweetTitles.tip.style.visibility = 'hidden';
	},
	checkNode : function() {
		var trueObj = this.obj;
		if ( this.tipElements.inArray(trueObj.nodeName.toLowerCase()) ) {
			return trueObj;
		} else {
			return trueObj.parentNode;
		}
	},
	tipOver : function(e) {
		sweetTitles.obj = this;
		tID = window.setTimeout("sweetTitles.tipShow()",500);
		sweetTitles.updateXY(e);
	},
	tipShow : function() {		
		var scrX = Number(this.xCord);
		var scrY = Number(this.yCord);
		var tp = parseInt(scrY+15);
		var lt = parseInt(scrX+10);
		var anch = this.checkNode();
//		var addy = '';
//		var access = '';
//		if ( anch.nodeName.toLowerCase() == 'a' ) {
//			addy = (anch.href.length > 25 ? anch.href.toString().substring(0,25)+"..." : anch.href);
//			var access = ( anch.accessKey ? ' <span>['+anch.accessKey+']</span> ' : '' );
//		} else {
//			addy = anch.firstChild.nodeValue;
//		}
//		this.tip.innerHTML = "<p>"+anch.getAttribute('tip')+"<em>"+access+addy+"</em></p>";

// Trimm down http://mysite.no/this to /this
//if ( anch.nodeName.toLowerCase() == 'a' ) {
//	var host = location.hostname.toString();
//	var pattern = new RegExp("(http://?)"+host,"gi");
//	var fullPath = anch.href.toString();
//	var path = fullPath.replace(pattern,'');
//	addy = (path.length > 25 ? path.toString().substring(0,25)+"..." : path);
//	var access = ( anch.accessKey ? " ["+anch.accessKey+"]" : "" );
//}

		this.tip.innerHTML = "<p>"+anch.getAttribute('tip')+"</p>";
		if ( parseInt(document.documentElement.clientWidth+document.documentElement.scrollLeft) < parseInt(this.tip.offsetWidth+lt) ) {
			this.tip.style.left = parseInt(lt-(this.tip.offsetWidth+10))+'px';
		} else {
			this.tip.style.left = lt+'px';
		}
		if ( parseInt(document.documentElement.clientHeight+document.documentElement.scrollTop) < parseInt(this.tip.offsetHeight+tp) ) {
			this.tip.style.top = parseInt(tp-(this.tip.offsetHeight+10))+'px';
		} else {
			this.tip.style.top = tp+'px';
		}
		this.tip.style.visibility = 'visible';
		this.tip.style.opacity = '.1';
		this.tipFade(10);
	},
	tipFade: function(opac) {
		var passed = parseInt(opac);
		var newOpac = parseInt(passed+this.fadespeed);
		if ( newOpac < 80 ) {
			this.tip.style.opacity = '.'+newOpac;
			this.tip.style.filter = "alpha(opacity:"+newOpac+")";
			opacityID = window.setTimeout("sweetTitles.tipFade('"+newOpac+"')",20);
		}
		else { 
			this.tip.style.opacity = '.80';
			this.tip.style.filter = "alpha(opacity:80)";
		}
	}
};
ELO.functionsToCallOnload.push("sweetTitles.init()");
/*

Cross-Browser XMLHttpRequest v1.2
=================================

Emulate Gecko 'XMLHttpRequest()' functionality in IE and Opera. Opera requires
the Sun Java Runtime Environment <http://www.java.com/>.

by Andrew Gregory
http://www.scss.com.au/family/andrew/webdesign/xmlhttprequest/

This work is licensed under the Creative Commons Attribution License. To view a
copy of this license, visit http://creativecommons.org/licenses/by/1.0/ or send
a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305,
USA.

Not Supported in Opera
----------------------
* user/password authentication
* responseXML data member

Not Fully Supported in Opera
----------------------------
* async requests
* abort()
* getAllResponseHeaders(), getAllResponseHeader(header)

*/
// IE support
if (window.ActiveXObject && !window.XMLHttpRequest) {
  window.XMLHttpRequest = function() {
    var msxmls = new Array(
      'Msxml2.XMLHTTP.5.0',
      'Msxml2.XMLHTTP.4.0',
      'Msxml2.XMLHTTP.3.0',
      'Msxml2.XMLHTTP',
      'Microsoft.XMLHTTP');
    for (var i = 0; i < msxmls.length; i++) {
      try {
        return new ActiveXObject(msxmls[i]);
      } catch (e) {
      }
    }
    return null;
  };
}
// Gecko support
/* ;-) */
// Opera support
if (window.opera && !window.XMLHttpRequest) {
  window.XMLHttpRequest = function() {
    this.readyState = 0; // 0=uninitialized,1=loading,2=loaded,3=interactive,4=complete
    this.status = 0; // HTTP status codes
    this.statusText = '';
    this._headers = [];
    this._aborted = false;
    this._async = true;
    this._defaultCharset = 'ISO-8859-1';
    this._getCharset = function() {
      var charset = _defaultCharset;
      var contentType = this.getResponseHeader('Content-type').toUpperCase();
      val = contentType.indexOf('CHARSET=');
      if (val != -1) {
        charset = contentType.substring(val);
      }
      val = charset.indexOf(';');
      if (val != -1) {
        charset = charset.substring(0, val);
      }
      val = charset.indexOf(',');
      if (val != -1) {
        charset = charset.substring(0, val);
      }
      return charset;
    };
    this.abort = function() {
      this._aborted = true;
    };
    this.getAllResponseHeaders = function() {
      return this.getAllResponseHeader('*');
    };
    this.getAllResponseHeader = function(header) {
      var ret = '';
      for (var i = 0; i < this._headers.length; i++) {
        if (header == '*' || this._headers[i].h == header) {
          ret += this._headers[i].h + ': ' + this._headers[i].v + '\n';
        }
      }
      return ret;
    };
    this.getResponseHeader = function(header) {
      var ret = getAllResponseHeader(header);
      var i = ret.indexOf('\n');
      if (i != -1) {
        ret = ret.substring(0, i);
      }
      return ret;
    };
    this.setRequestHeader = function(header, value) {
      this._headers[this._headers.length] = {h:header, v:value};
    };
    this.open = function(method, url, async, user, password) {
      this.method = method;
      this.url = url;
      this._async = true;
      this._aborted = false;
      this._headers = [];
      if (arguments.length >= 3) {
        this._async = async;
      }
      if (arguments.length > 3) {
        opera.postError('XMLHttpRequest.open() - user/password not supported');
      }
      this.readyState = 1;
      if (this.onreadystatechange) {
        this.onreadystatechange();
      }
    };
    this.send = function(data) {
      if (!navigator.javaEnabled()) {
        alert("XMLHttpRequest.send() - Java must be installed and enabled.");
        return;
      }
      if (this._async) {
        setTimeout(this._sendasync, 0, this, data);
        // this is not really asynchronous and won't execute until the current
        // execution context ends
      } else {
        this._sendsync(data);
      }
    }
    this._sendasync = function(req, data) {
      if (!req._aborted) {
        req._sendsync(data);
      }
    };
    this._sendsync = function(data) {
      this.readyState = 2;
      if (this.onreadystatechange) {
        this.onreadystatechange();
      }
      // open connection
      var url = new java.net.URL(new java.net.URL(window.location.href), this.url);
      var conn = url.openConnection();
      for (var i = 0; i < this._headers.length; i++) {
        conn.setRequestProperty(this._headers[i].h, this._headers[i].v);
      }
      this._headers = [];
      if (this.method == 'POST') {
        // POST data
        conn.setDoOutput(true);
        var wr = new java.io.OutputStreamWriter(conn.getOutputStream(), this._getCharset());
        wr.write(data);
        wr.flush();
        wr.close();
      }
      // read response headers
      // NOTE: the getHeaderField() methods always return nulls for me :(
      var gotContentEncoding = false;
      var gotContentLength = false;
      var gotContentType = false;
      var gotDate = false;
      var gotExpiration = false;
      var gotLastModified = false;
      for (var i = 0; ; i++) {
        var hdrName = conn.getHeaderFieldKey(i);
        var hdrValue = conn.getHeaderField(i);
        if (hdrName == null && hdrValue == null) {
          break;
        }
        if (hdrName != null) {
          this._headers[this._headers.length] = {h:hdrName, v:hdrValue};
          switch (hdrName.toLowerCase()) {
            case 'content-encoding': gotContentEncoding = true; break;
            case 'content-length'  : gotContentLength   = true; break;
            case 'content-type'    : gotContentType     = true; break;
            case 'date'            : gotDate            = true; break;
            case 'expires'         : gotExpiration      = true; break;
            case 'last-modified'   : gotLastModified    = true; break;
          }
        }
      }
      // try to fill in any missing header information
      var val;
      val = conn.getContentEncoding();
      if (val != null && !gotContentEncoding) this._headers[this._headers.length] = {h:'Content-encoding', v:val};
      val = conn.getContentLength();
      if (val != -1 && !gotContentLength) this._headers[this._headers.length] = {h:'Content-length', v:val};
      val = conn.getContentType();
      if (val != null && !gotContentType) this._headers[this._headers.length] = {h:'Content-type', v:val};
      val = conn.getDate();
      if (val != 0 && !gotDate) this._headers[this._headers.length] = {h:'Date', v:(new Date(val)).toUTCString()};
      val = conn.getExpiration();
      if (val != 0 && !gotExpiration) this._headers[this._headers.length] = {h:'Expires', v:(new Date(val)).toUTCString()};
      val = conn.getLastModified();
      if (val != 0 && !gotLastModified) this._headers[this._headers.length] = {h:'Last-modified', v:(new Date(val)).toUTCString()};
      // read response data
      var reqdata = '';
      var stream = conn.getInputStream();
      java.lang.System.err.println(stream);
      if (stream) {
        var reader = new java.io.BufferedReader(new java.io.InputStreamReader(stream, this._getCharset()));
        var line;
        while ((line = reader.readLine()) != null) {
          if (this.readyState == 2) {
            this.readyState = 3;
            if (this.onreadystatechange) {
              this.onreadystatechange();
            }
          }
          reqdata += line + '\n';
        }
        reader.close();
        this.status = 200;
        this.statusText = 'OK';
        this.responseText = reqdata;
        this.readyState = 4;
        if (this.onreadystatechange) {
          this.onreadystatechange();
        }
        if (this.onload) {
          this.onload();
        }
      } else {
        // error
        this.status = 404;
        this.statusText = 'Not Found';
        this.responseText = '';
        this.readyState = 4;
        if (this.onreadystatechange) {
          this.onreadystatechange();
        }
        if (this.onerror) {
          this.onerror();
        }
      }
    };
  };
}
// ActiveXObject emulation
if (!window.ActiveXObject && window.XMLHttpRequest) {
  window.ActiveXObject = function(type) {
    switch (type.toLowerCase()) {
      case 'microsoft.xmlhttp':
      case 'msxml2.xmlhttp':
      case 'msxml2.xmlhttp.3.0':
      case 'msxml2.xmlhttp.4.0':
      case 'msxml2.xmlhttp.5.0':
        return new XMLHttpRequest();
    }
    return null;
  };
}/*
(C) www.dhtmlgoodies.com, September 2005

Version 1.2, November 8th - 2005 - Added <iframe> background in IE
Version 1.3, November 12th - 2005 - Fixed top bar position in Opera 7

This is a script from www.dhtmlgoodies.com. You will find this and a lot of other scripts at our website.	

Terms of use:
You are free to use this script as long as the copyright message is kept intact. However, you may not
redistribute, sell or repost it without our permission.

Thank you!

www.dhtmlgoodies.com
Alf Magne Kalleland

*/
var languageCode = 'no';	// Possible values: 	en,ge,no 	
							// en = english, ge = german, no = norwegian

var calendar_offsetTop = 0;		// Offset - calendar placement - You probably have to modify this value if you're not using a strict doctype
var calendar_offsetLeft = 0;	// Offset - calendar placement - You probably have to modify this value if you're not using a strict doctype
var calendarDiv = false;

var MSIE = false;
var Opera = false;
if(navigator.userAgent.indexOf('MSIE')>=0 && navigator.userAgent.indexOf('Opera')<0)MSIE=true;
if(navigator.userAgent.indexOf('Opera')>=0)Opera=true;


switch(languageCode){
	case "en":
		var monthArray = ['January','February','March','April','May','June','July','August','September','October','November','December'];
		var monthArrayShort = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
		var dayArray = ['Mon','Tue','Wed','Thu','Fri','Sat','Sun'];
		var weekString = 'Week';
		var todayString = 'Today is';
		break;
	case "ge":
		var monthArray = ['Jänner','Februar','März','April','Mai','Juni','Juli','August','September','Oktober','November','Dezember'];
		var monthArrayShort = ['Jan','Feb','Mar','Apr','Mai','Jun','Jul','Aug','Sep','Okt','Nov','Dez'];
		var dayArray = ['Mon','Die','Mit','Don','Fre','Sam','Son'];	
		var weekString = 'Woche';
		var todayString = 'Heute';
		
		break;
	case "no":
		var monthArray = ['Januar','Februar','Mars','April','Mai','Juni','Juli','August','September','Oktober','November','Desember'];
		var monthArrayShort = ['Jan','Feb','Mar','Apr','Mai','Jun','Jul','Aug','Sep','Okt','Nov','Des'];
		var dayArray = ['Man','Tir','Ons','Tor','Fre','L&oslash;r','S&oslash;n'];	
		var weekString = 'Uke';
		var todayString = 'Dagen i dag er';
		break;	
}



var daysInMonthArray = [31,28,31,30,31,30,31,31,30,31,30,31];
var currentMonth;
var currentYear;
var calendarContentDiv;
var returnDateTo;
var returnFormat;
var activeSelectBoxMonth;
var activeSelectBoxYear;
var iframeObj = false;

var returnDateToYear;
var returnDateToMonth;
var returnDateToDay;

var inputYear;
var inputMonth;
var inputDay;


var selectBoxHighlightColor = '#D60808'; // Highlight color of select boxes
var selectBoxRolloverBgColor = '#E2EBED'; // Background color on drop down lists(rollover)
function cancelCalendarEvent()
{
	return false;
}
function isLeapYear(inputYear)
{
	if(inputYear%4==0)return true;
	if(inputYear%100==0)return true;
	if(inputYear%400==0)return true;
	return false;	
	
}
var activeSelectBoxMonth = false;

function highlightMonthYear()
{
	if(activeSelectBoxMonth)activeSelectBoxMonth.className='';
	
	if(this.className=='monthYearActive'){
		this.className='';	
	}else{
		this.className = 'monthYearActive';
		activeSelectBoxMonth = this;
	}
}

function showMonthDropDown()
{
	if(document.getElementById('monthDropDown').style.display=='block'){
		document.getElementById('monthDropDown').style.display='none';	
	}else{
		document.getElementById('monthDropDown').style.display='block';		
		document.getElementById('yearDropDown').style.display='none';
	}
}

function showYearDropDown()
{
	if(document.getElementById('yearDropDown').style.display=='block'){
		document.getElementById('yearDropDown').style.display='none';	
	}else{
		document.getElementById('yearDropDown').style.display='block';		
		document.getElementById('monthDropDown').style.display='none';	
	}		

}

function selectMonth()
{
	document.getElementById('calendar_month_txt').innerHTML = this.innerHTML
	currentMonth = this.id.replace(/[^\d]/g,'');

	document.getElementById('monthDropDown').style.display='none';
	for(var no=0;no<monthArray.length;no++){
		document.getElementById('monthDiv_'+no).style.color='';	
	}
	this.style.color = selectBoxHighlightColor;
	activeSelectBoxMonth = this;
	writeCalendarContent();
	
}

function selectYear()
{
	document.getElementById('calendar_year_txt').innerHTML = this.innerHTML
	currentYear = this.innerHTML.replace(/[^\d]/g,'');
	document.getElementById('yearDropDown').style.display='none';
	if(activeSelectBoxYear){
		activeSelectBoxYear.style.color='';
	}
	activeSelectBoxYear=this;
	this.style.color = selectBoxHighlightColor;
	writeCalendarContent();
	
}

function switchMonth()
{
	if(this.src.indexOf('left')>=0){
		currentMonth=currentMonth-1;;
		if(currentMonth<0){
			currentMonth=11;
			currentYear=currentYear-1;
		}
	}else{
		currentMonth=currentMonth+1;;
		if(currentMonth>11){
			currentMonth=0;
			currentYear=currentYear/1+1;
		}	
	}	
	
	writeCalendarContent();	
	
	
}

function createMonthDiv(){
	var div = document.createElement('DIV');
	div.className='monthYearPicker';
	div.id = 'monthPicker';
	
	for(var no=0;no<monthArray.length;no++){
		var subDiv = document.createElement('DIV');
		subDiv.innerHTML = monthArray[no];
		subDiv.onmouseover = highlightMonthYear;
		subDiv.onmouseout = highlightMonthYear;
		subDiv.onclick = selectMonth;
		subDiv.id = 'monthDiv_' + no;
		subDiv.style.width = '56px';
		subDiv.onselectstart = cancelCalendarEvent;		
		div.appendChild(subDiv);
		if(currentMonth && currentMonth==no){
			subDiv.style.color = selectBoxHighlightColor;
			activeSelectBoxMonth = subDiv;
		}				
		
	}	
	return div;
	
}

function changeSelectBoxYear()
{

	var yearItems = this.parentNode.getElementsByTagName('DIV');
	if(this.innerHTML.indexOf('-')>=0){
		var startYear = yearItems[1].innerHTML/1 -1;
		if(activeSelectBoxYear){
			activeSelectBoxYear.style.color='';
		}
	}else{
		var startYear = yearItems[1].innerHTML/1 +1;
		if(activeSelectBoxYear){
			activeSelectBoxYear.style.color='';

		}			
	}

	for(var no=1;no<yearItems.length-1;no++){
		yearItems[no].innerHTML = startYear+no-1;	
		yearItems[no].id = 'yearDiv' + (startYear/1+no/1-1);	
		
	}		
	if(activeSelectBoxYear){
		activeSelectBoxYear.style.color='';
		if(document.getElementById('yearDiv'+currentYear)){
			activeSelectBoxYear = document.getElementById('yearDiv'+currentYear);
			activeSelectBoxYear.style.color=selectBoxHighlightColor;;
		}
	}
}

function updateYearDiv()
{
	var div = document.getElementById('yearDropDown');
	var yearItems = div.getElementsByTagName('DIV');
	for(var no=1;no<yearItems.length-1;no++){
		yearItems[no].innerHTML = currentYear/1 -6 + no;	
		if(currentYear==(currentYear/1 -6 + no)){
			yearItems[no].style.color = selectBoxHighlightColor;
			activeSelectBoxYear = yearItems[no];				
		}else{
			yearItems[no].style.color = '';
		}
	}		
}

function updateMonthDiv()
{
	for(no=0;no<12;no++){
		document.getElementById('monthDiv_' + no).style.color = '';
	}		
	document.getElementById('monthDiv_' + currentMonth).style.color = selectBoxHighlightColor;
	activeSelectBoxMonth = 	document.getElementById('monthDiv_' + currentMonth);
}

function createYearDiv()
{

	if(!document.getElementById('yearDropDown')){
		var div = document.createElement('DIV');
		div.className='monthYearPicker';
	}else{
		var div = document.getElementById('yearDropDown');
		var subDivs = div.getElementsByTagName('DIV');
		for(var no=0;no<subDivs.length;no++){
			subDivs[no].parentNode.removeChild(subDivs[no]);	
		}	
	}	
	
	
	var d = new Date();
	if(currentYear){
		d.setFullYear(currentYear);	
	}

	var startYear = d.getFullYear()/1 - 5;

	
	var subDiv = document.createElement('DIV');
	subDiv.innerHTML = '&nbsp;&nbsp;- ';
	subDiv.onclick = changeSelectBoxYear;
	subDiv.onmouseover = highlightMonthYear;
	subDiv.onmouseout = highlightMonthYear;	
	subDiv.onselectstart = cancelCalendarEvent;			
	div.appendChild(subDiv);
	
	for(var no=startYear;no<(startYear+10);no++){
		var subDiv = document.createElement('DIV');
		subDiv.innerHTML = no;
		subDiv.onmouseover = highlightMonthYear;
		subDiv.onmouseout = highlightMonthYear;		
		subDiv.onclick = selectYear;		
		subDiv.id = 'yearDiv' + no;	
		subDiv.onselectstart = cancelCalendarEvent;	
		div.appendChild(subDiv);
		if(currentYear && currentYear==no){
			subDiv.style.color = selectBoxHighlightColor;
			activeSelectBoxYear = subDiv;
		}			
	}
	var subDiv = document.createElement('DIV');
	subDiv.innerHTML = '&nbsp;&nbsp;+ ';
	subDiv.onclick = changeSelectBoxYear;
	subDiv.onmouseover = highlightMonthYear;
	subDiv.onmouseout = highlightMonthYear;		
	subDiv.onselectstart = cancelCalendarEvent;			
	div.appendChild(subDiv);		

	
	return div;
}

function highlightSelect()
{
	if(this.className=='selectBox'){
		this.className = 'selectBoxOver';	
		this.getElementsByTagName('IMG')[0].src = 'images/jscal-down_over.gif';
	}else{
		this.className = 'selectBox';	
		this.getElementsByTagName('IMG')[0].src = 'images/jscal-down.gif';			
	}
	
}

function highlightArrow()
{
	if(this.src.indexOf('over')>=0){
		if(this.src.indexOf('left')>=0)this.src = 'images/jscal-left.gif';	
		if(this.src.indexOf('right')>=0)this.src = 'images/jscal-right.gif';				
	}else{
		if(this.src.indexOf('left')>=0)this.src = 'images/jscal-left_over.gif';	
		if(this.src.indexOf('right')>=0)this.src = 'images/jscal-right_over.gif';	
	}
}

function highlightClose()
{
	if(this.src.indexOf('over')>=0){
		this.src = 'images/jscal-close.gif';
	}else{
		this.src = 'images/jscal-close_over.gif';	
	}	

}

function closeCalendar(){

	document.getElementById('yearDropDown').style.display='none';
	document.getElementById('monthDropDown').style.display='none';
		
	calendarDiv.style.display='none';
	if(iframeObj)iframeObj.style.display='none';
	if(activeSelectBoxMonth)activeSelectBoxMonth.className='';
	if(activeSelectBoxYear)activeSelectBoxYear.className='';
	

}

function writeTopBar()
{

	var topBar = document.createElement('DIV');
	topBar.className = 'topBar';
	topBar.id = 'topBar';
	calendarDiv.appendChild(topBar);
	
	// Left arrow
	var leftDiv = document.createElement('DIV');
	leftDiv.style.marginRight = '1px';
	var img = document.createElement('IMG');
	img.src = 'images/jscal-left.gif';
	img.onmouseover = highlightArrow;
	img.onclick = switchMonth;
	img.onmouseout = highlightArrow;
	leftDiv.appendChild(img);
	topBar.appendChild(leftDiv);
	if(Opera)leftDiv.style.width = '16px';
	
	// Right arrow
	var rightDiv = document.createElement('DIV');
	rightDiv.style.marginRight = '1px';
	var img = document.createElement('IMG');
	img.src = 'images/jscal-right.gif';
	img.onclick = switchMonth;
	img.onmouseover = highlightArrow;
	img.onmouseout = highlightArrow;
	rightDiv.appendChild(img);
	if(Opera)rightDiv.style.width = '16px';
	topBar.appendChild(rightDiv);		

			
	// Month selector
	var monthDiv = document.createElement('DIV');
	monthDiv.id = 'monthSelect';
	monthDiv.onmouseover = highlightSelect;
	monthDiv.onmouseout = highlightSelect;
	monthDiv.onclick = showMonthDropDown;
	var span = document.createElement('SPAN');		
	span.innerHTML = monthArray[currentMonth];
	span.id = 'calendar_month_txt';
	monthDiv.appendChild(span);

	var img = document.createElement('IMG');
	img.src = 'images/jscal-down.gif';
	img.style.position = 'absolute';
	img.style.right = '0px';
	monthDiv.appendChild(img);
	monthDiv.className = 'selectBox';
	if(Opera){
		img.style.cssText = 'float:right;position:relative';
		img.style.position = 'relative';
		img.style.styleFloat = 'right';
	}
	topBar.appendChild(monthDiv);

	var monthPicker = createMonthDiv();
	monthPicker.style.left = '37px';
	monthPicker.style.top = monthDiv.offsetTop + monthDiv.offsetHeight + 1 + 'px';
	monthPicker.style.width ='60px';
	monthPicker.id = 'monthDropDown';
	
	calendarDiv.appendChild(monthPicker);
			
	// Year selector
	var yearDiv = document.createElement('DIV');
	yearDiv.onmouseover = highlightSelect;
	yearDiv.onmouseout = highlightSelect;
	yearDiv.onclick = showYearDropDown;
	var span = document.createElement('SPAN');		
	span.innerHTML = currentYear;
	span.id = 'calendar_year_txt';
	yearDiv.appendChild(span);
	topBar.appendChild(yearDiv);
	
	var img = document.createElement('IMG');
	img.src = 'images/jscal-down.gif';
	yearDiv.appendChild(img);
	yearDiv.className = 'selectBox';
	
	if(Opera){
		yearDiv.style.width = '50px';
		img.style.cssText = 'float:right';
		img.style.position = 'relative';
		img.style.styleFloat = 'right';
	}	
	
	var yearPicker = createYearDiv();
	yearPicker.style.left = '113px';
	yearPicker.style.top = monthDiv.offsetTop + monthDiv.offsetHeight + 1 + 'px';
	yearPicker.style.width = '35px';
	yearPicker.id = 'yearDropDown';
	calendarDiv.appendChild(yearPicker);
	
		
	var img = document.createElement('IMG');
	img.src = 'images/jscal-close.gif';
	img.style.styleFloat = 'right';
	img.onmouseover = highlightClose;
	img.onmouseout = highlightClose;
	img.onclick = closeCalendar;
	topBar.appendChild(img);
	if(!document.all){
		img.style.position = 'absolute';
		img.style.right = '2px';
	}
	
	

}

function writeCalendarContent()
{
	if(!calendarContentDiv){
		calendarContentDiv = document.createElement('DIV');
		calendarDiv.appendChild(calendarContentDiv);



	}
	
	var d = new Date();		
	d.setMonth(currentMonth);
	d.setFullYear(currentYear);		
	d.setDate(0);		


	document.getElementById('calendar_year_txt').innerHTML = currentYear;
	document.getElementById('calendar_month_txt').innerHTML = monthArray[currentMonth];
	
	var existingTable = calendarContentDiv.getElementsByTagName('TABLE');
	if(existingTable.length>0){
		calendarContentDiv.removeChild(existingTable[0]);
	}
	
	var calTable = document.createElement('TABLE');
	calTable.cellSpacing = '0';
	calendarContentDiv.appendChild(calTable);
	var calTBody = document.createElement('TBODY');
	calTable.appendChild(calTBody);
	var row = calTBody.insertRow(-1);
	var cell = row.insertCell(-1);
	cell.innerHTML = weekString;
	cell.style.backgroundColor = selectBoxRolloverBgColor;
	
	for(var no=0;no<dayArray.length;no++){
		var cell = row.insertCell(-1);
		cell.innerHTML = dayArray[no]; 
	}
	
	var row = calTBody.insertRow(-1);
	var cell = row.insertCell(-1);
	cell.style.backgroundColor = selectBoxRolloverBgColor;
	var week = getWeek(currentYear,currentMonth,1);
	cell.innerHTML = week;		// Week
	for(var no=0;no<d.getDay();no++){
		var cell = row.insertCell(-1);
		cell.innerHTML = '&nbsp;';
	}

	var colCounter = d.getDay();
	var daysInMonth = daysInMonthArray[currentMonth];
	if(daysInMonth==28){
		if(isLeapYear(currentYear))daysInMonth=29;
	}
	
	for(var no=1;no<=daysInMonth;no++){
		d.setDate(no-1);
		if(colCounter>0 && colCounter%7==0){
			var row = calTBody.insertRow(-1);
			var cell = row.insertCell(-1);
			var week = getWeek(currentYear,currentMonth,no);
			cell.innerHTML = week;		// Week	
			cell.style.backgroundColor = selectBoxRolloverBgColor;			
		}
		var cell = row.insertCell(-1);
		if(currentYear==inputYear && currentMonth == inputMonth && no==inputDay){
			cell.style.color = '#FF0000';	
		}
		cell.innerHTML = no;
		cell.onclick = pickDate;
		colCounter++;
	}
	
	
	if(!document.all){
		if(calendarContentDiv.offsetHeight)
			document.getElementById('topBar').style.top = calendarContentDiv.offsetHeight + document.getElementById('topBar').offsetHeight -1 + 'px';
		else{
			document.getElementById('topBar').style.top = '';
			document.getElementById('topBar').style.bottom = '0px';
		}
			
	}
	
	if(iframeObj){
		setTimeout('resizeIframe()',50);
	}
		
	
}

function resizeIframe()
{
	iframeObj.style.width = calendarDiv.offsetWidth + 'px';
	iframeObj.style.height = calendarDiv.offsetHeight + 'px' ;	
	
	
}

function pickDate()
{
	var month = currentMonth/1 +1;
	if(month<10)month = '0' + month;
	var day = this.innerHTML;
	if(day/1<10)day = '0' + day;
	if(returnFormat){
		returnFormat = returnFormat.replace('dd',day);
		returnFormat = returnFormat.replace('mm',month);
		returnFormat = returnFormat.replace('yyyy',currentYear);
		returnDateTo.value = returnFormat;
	}else{
		for(var no=0;no<returnDateToYear.options.length;no++){
			if(returnDateToYear.options[no].value==currentYear){
				returnDateToYear.selectedIndex=no;
				break;
			}				
		}
		for(var no=0;no<returnDateToMonth.options.length;no++){
			if(returnDateToMonth.options[no].value==month){
				returnDateToMonth.selectedIndex=no;
				break;
			}				
		}
		for(var no=0;no<returnDateToDay.options.length;no++){
			if(returnDateToDay.options[no].value==day){
				returnDateToDay.selectedIndex=no;
				break;
			}				
		}
		
		
	}
	closeCalendar();
	
}

// This function is from http://www.codeproject.com/csharp/gregorianwknum.asp
// Only changed the month add
function getWeek(year,month,day){
	day = day/1;
	year = year /1;
    month = month/1 + 1; //use 1-12
    var a = Math.floor((14-(month))/12);
    var y = year+4800-a;
    var m = (month)+(12*a)-3;
    var jd = day + Math.floor(((153*m)+2)/5) + 
                 (365*y) + Math.floor(y/4) - Math.floor(y/100) + 
                 Math.floor(y/400) - 32045;      // (gregorian calendar)
    var d4 = (jd+31741-(jd%7))%146097%36524%1461;
    var L = Math.floor(d4/1460);
    var d1 = ((d4-L)%365)+L;
    NumberOfWeek = Math.floor(d1/7) + 1;
    return NumberOfWeek;        
}

function writeBottomBar()
{
	var d = new Date();
	var topBar = document.createElement('DIV');
	topBar.id = 'topBar';
	topBar.className = 'todaysDate';
	topBar.innerHTML = todayString + ': ' + d.getDate() + '.' + monthArrayShort[d.getMonth()] + '. ' +  d.getFullYear() ;
	calendarDiv.appendChild(topBar);	
	
	
		
}
function getTopPos(inputObj)
{
	
  var returnValue = inputObj.offsetTop + inputObj.offsetHeight;
  while((inputObj = inputObj.offsetParent) != null)returnValue += inputObj.offsetTop;
  return returnValue + calendar_offsetTop;
}

function getleftPos(inputObj)
{
  var returnValue = inputObj.offsetLeft;
  while((inputObj = inputObj.offsetParent) != null)returnValue += inputObj.offsetLeft;
  return returnValue + calendar_offsetLeft;
}

function positionCalendar(inputObj)
{
	calendarDiv.style.left = getleftPos(inputObj) + 'px';
	calendarDiv.style.top = getTopPos(inputObj) + 'px';
	if(iframeObj){
		iframeObj.style.left = calendarDiv.style.left;
		iframeObj.style.top =  calendarDiv.style.top;
	}
		
}
	
function initCalendar()
{
	if(MSIE){
		iframeObj = document.createElement('IFRAME');
		iframeObj.style.position = 'absolute';
		iframeObj.border='0px';
		iframeObj.style.border = '0px';
		iframeObj.style.backgroundColor = '#FF0000';
		document.body.appendChild(iframeObj);
	}
		
	calendarDiv = document.createElement('DIV');	
	calendarDiv.id = 'calendarDiv';
	calendarDiv.style.zIndex = 1000;
	
	document.body.appendChild(calendarDiv);
	writeBottomBar();
	writeTopBar();
	
	

	if(!currentYear){
		var d = new Date();
		currentMonth = d.getMonth();
		currentYear = d.getFullYear();
	}
	writeCalendarContent();	



}


function displayCalendar(inputField,format,buttonObj)
{
    if(buttonObj == null)
      buttonObj = inputField;

	if(inputField.value.length==format.length){
		var monthPos = format.indexOf('mm');
		currentMonth = inputField.value.substr(monthPos,2)/1 -1;	
		var yearPos = format.indexOf('yyyy');
		currentYear = inputField.value.substr(yearPos,4);		
		var dayPos = format.indexOf('dd');
		tmpDay = inputField.value.substr(dayPos,2);	
	}else{
		var d = new Date();
		currentMonth = d.getMonth();
		currentYear = d.getFullYear();
		tmpDay = 1;
	}
	
	inputYear = currentYear;
	inputMonth = currentMonth;
	inputDay = tmpDay/1;
	
	if(!calendarDiv){
		initCalendar();			
	}else{
		writeCalendarContent();
	}			
	returnFormat = format;
	returnDateTo = inputField;
	positionCalendar(buttonObj);
	calendarDiv.style.visibility = 'visible';	
	calendarDiv.style.display = 'block';	
	if(iframeObj){
		iframeObj.style.display = '';
		iframeObj.style.height = calendarDiv.offsetHeight + 'px';
		iframeObj.style.width = calendarDiv.offsetWidth + 'px';
	}
	updateYearDiv();
	updateMonthDiv();

}

function displayCalendarSelectBox(yearInput,monthInput,dayInput,buttonObj)
{
	currentMonth = monthInput.options[monthInput.selectedIndex].value/1-1;
	currentYear = yearInput.options[yearInput.selectedIndex].value;

	inputYear = yearInput.options[yearInput.selectedIndex].value;
	inputMonth = monthInput.options[monthInput.selectedIndex].value/1 - 1;
	inputDay = dayInput.options[dayInput.selectedIndex].value/1;
			
	if(!calendarDiv){
		initCalendar();			
	}else{
		writeCalendarContent();
	}		

	returnDateToYear = yearInput;
	returnDateToMonth = monthInput;
	returnDateToDay = dayInput;
	

	

	
	returnFormat = false;
	returnDateTo = false;
	positionCalendar(buttonObj);
	calendarDiv.style.visibility = 'visible';	
	calendarDiv.style.display = 'block';
	if(iframeObj){
		iframeObj.style.display = '';
		iframeObj.style.height = calendarDiv.offsetHeight + 'px';
		iframeObj.style.width = calendarDiv.offsetWidth + 'px';	
	}
	updateYearDiv();
	updateMonthDiv();
		
}
	/************************************************************************************************************
	(C) www.dhtmlgoodies.com, September 2005
	
	This is a script from www.dhtmlgoodies.com. You will find this and a lot of other scripts at our website.	
	
	Terms of use:
	You are free to use this script as long as the copyright message is kept intact. However, you may not
	redistribute, sell or repost it without our permission.
	
	Thank you!
	
	www.dhtmlgoodies.com
	Alf Magne Kalleland
	
	************************************************************************************************************/
	function BubbleTip(e,text){
		if(document.all)e = event;
		
		var obj = document.getElementById('bubble_tooltip');
		var obj2 = document.getElementById('bubble_tooltip_content');
		obj2.innerHTML = text;
		obj.style.display = 'block';
		var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
		var leftPos = e.clientX - 500;
		if(leftPos<0)leftPos = 0;
		obj.style.left = leftPos + 'px';
		obj.style.top = e.clientY - obj.offsetHeight -1 + st + 'px';
	}	
	
	function hideBubbleTip() {
		document.getElementById('bubble_tooltip').style.display = 'none';
	}

bubble_url   = 'Navnet på lenken som skrives inn i nettleser for å få opp siden. En lenke kan bare bestå av bokstaver fra a-z, tall 0-9 og bindestrek. Søkemotorer legger stor vekt på navnet på lenken så pass på å ha nøkkelord med i lenkens navn. Om ikke du oppgir noen navn vil URL automatisk genereres utifra artikkeloverskrift.<br><br>Merk at om du allerede har laget en url er det ikke lurt å endre denne, ettersom foll allerede har tatt den ibruk. Om du endrer en eksisterende lenke betyr dette at alle som lenker til deg må oppdatere sin lenke';
bubble_title = 'Tittelen på siden som vises oppe i venstre hjørne i nettleseren. Søkemotorer legger stor vekt på tittelen på siden så pass på å ha en god tittel. Om ikke du oppgir noen navn vil URL automatisk genereres utifra artikkeloverskrift.';

bubble_meta_description_max    = 'Du kan selv bestemme lengden på beskrivelsen ved å definere antall bokstaver (chars eller c) eller antall ord (words eller w). <br><br>Eks på maks 10 ord: &quot;<strong>10 words</strong>&quot; eller &quot;<strong>10w</strong>&quot;. <br>Eks på maks 10 bokstaver: &quot;<strong>10 chars</strong>&quot; eller &quot;<strong>10c</strong>&quot; eller &quot;<strong>10</strong>&quot;.';
bubble_meta_description_prefix = 'Teksten blir prefikset meta beskrivelsen.';
bubble_meta_description        = 'Du kan selv skrive meta beskrivelsen av siden. Ved å skrive noe i dette feltet overstyrer du det automatiserte systemet som genererer meta beskrivelsen, som da ikke blir benyttet i det hele tatt. Når dette feltet er tomt vil Easy CMS automatisk generere meta beskrivelsen for deg.';
bubble_meta_keywords_max       = 'Du kan selv bestemme lengden på nøkkelordene ved å definere antall bokstaver (chars eller c) eller antall ord (words eller w). <br><br>Eks på maks 10 ord: &quot;<strong>10 words</strong>&quot; eller &quot;<strong>10w</strong>&quot;. <br>Eks på maks 10 bokstaver: &quot;<strong>10 chars</strong>&quot; eller &quot;<strong>10c</strong>&quot; eller &quot;<strong>10</strong>&quot;.';
bubble_meta_keywords_prefix    = 'Teksten blir prefikset meta nøkkelordene.';
bubble_meta_keywords           = 'Du kan selv skrive meta nøkkelord for siden. Ved å skrive noe i dette feltet overstyrer du det automatiserte systemet som genererer meta nøkkelordene, som da ikke blir benyttet i det hele tatt. Når dette feltet er tomt vil Easy CMS automatisk generere meta nøkkelord for deg.';
bubble_seo_alt_overrides       = 'Bilder på siden med tomme alt=&quot;&quot; tagger blir populert med frasene du skriver her. Du kan skille fraser med | tegnet. (Tegnet er tasten til venstre for 1 tallet på tastaturet).<br><br>Eksempel: <strong>Nøkkelord|En viktig frase|Nøkkelord</strong>';

/* Simple AJAX Code-Kit (SACK) */
/* ©2005 Gregory Wild-Smith */
/* www.twilightuniverse.com */
/* Software licenced under a modified X11 licence, see documentation or authors website for more details */

function sack(file){
	this.AjaxFailedAlert = "Your browser does not support the enhanced functionality of this website, and therefore you will have an experience that differs from the intended one.\n";
	this.requestFile = file;
	this.method = "POST";
	this.URLString = "";
	this.encodeURIString = true;
	this.execute = false;

	this.onLoading = function() { };
	this.onLoaded = function() { };
	this.onInteractive = function() { };
	this.onCompletion = function() { };

	this.createAJAX = function() {
		try {
			this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (err) {
				this.xmlhttp = null;
			}
		}
		if(!this.xmlhttp && typeof XMLHttpRequest != "undefined")
			this.xmlhttp = new XMLHttpRequest();
		if (!this.xmlhttp){
			this.failed = true; 
		}
	};
	
	this.setVar = function(name, value){
		if (this.URLString.length < 3){
			this.URLString = name + "=" + value;
		} else {
			this.URLString += "&" + name + "=" + value;
		}
	}
	
	this.encVar = function(name, value){
		var varString = encodeURIComponent(name) + "=" + encodeURIComponent(value);
	return varString;
	}
	
	this.encodeURLString = function(string){
		varArray = string.split('&');
		for (i = 0; i < varArray.length; i++){
			urlVars = varArray[i].split('=');
			if (urlVars[0].indexOf('amp;') != -1){
				urlVars[0] = urlVars[0].substring(4);
			}
			varArray[i] = this.encVar(urlVars[0],urlVars[1]);
		}
	return varArray.join('&');
	}
	
	this.runResponse = function(){
		eval(this.response);
	}
	
	this.runAJAX = function(urlstring){
		this.responseStatus = new Array(2);
		if(this.failed && this.AjaxFailedAlert){ 
			alert(this.AjaxFailedAlert); 
		} else {
			if (urlstring){ 
				if (this.URLString.length){
					this.URLString = this.URLString + "&" + urlstring; 
				} else {
					this.URLString = urlstring; 
				}
			}
			if (this.encodeURIString){
				var timeval = new Date().getTime(); 
				this.URLString = this.encodeURLString(this.URLString);
				this.setVar("rndval", timeval);
			}
			if (this.element) { this.elementObj = document.getElementById(this.element); }
			if (this.xmlhttp) {
				var self = this;
				if (this.method == "GET") {
					var totalurlstring = this.requestFile + "?" + this.URLString;
					this.xmlhttp.open(this.method, totalurlstring, true);
				} else {
					this.xmlhttp.open(this.method, this.requestFile, true);
				}
				if (this.method == "POST"){
  					try {
						this.xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded')  
					} catch (e) {}
				}

				this.xmlhttp.send(this.URLString);
				this.xmlhttp.onreadystatechange = function() {
					switch (self.xmlhttp.readyState){
						case 1:
							self.onLoading();
						break;
						case 2:
							self.onLoaded();
						break;
						case 3:
							self.onInteractive();
						break;
						case 4:
							self.response = self.xmlhttp.responseText;
							self.responseXML = self.xmlhttp.responseXML;
							self.responseStatus[0] = self.xmlhttp.status;
							self.responseStatus[1] = self.xmlhttp.statusText;
							self.onCompletion();
							if(self.execute){ self.runResponse(); }
							if (self.elementObj) {
								var elemNodeName = self.elementObj.nodeName;
								elemNodeName.toLowerCase();
								if (elemNodeName == "input" || elemNodeName == "select" || elemNodeName == "option" || elemNodeName == "textarea"){
									self.elementObj.value = self.response;
								} else {
									self.elementObj.innerHTML = self.response;
								}
							}
							self.URLString = "";
						break;
					}
				};
			}
		}
	};
this.createAJAX();
}	/************************************************************************************************************
	(C) www.dhtmlgoodies.com, October 2005
	
	This is a script from www.dhtmlgoodies.com. You will find this and a lot of other scripts at our website.	
	
	Terms of use:
	You are free to use this script as long as the copyright message is kept intact. However, you may not
	redistribute, sell or repost it without our permission.
	
	Updated:
		
		March, 14th, 2006 - Create new tabs dynamically
		March, 15th, 2006 - Dynamically delete a tab
		
	Thank you!
	
	www.dhtmlgoodies.com
	Alf Magne Kalleland
	
	************************************************************************************************************/		
	var textPadding = 3; // Padding at the left of tab text - bigger value gives you wider tabs
	var strictDocType = true; 
	var tabView_maxNumberOfTabs = 6;	// Maximum number of tabs
	
	/* Don't change anything below here */
	var dhtmlgoodies_tabObj = new Array();
	var activeTabIndex = new Array();
	var MSIE = navigator.userAgent.indexOf('MSIE')>=0?true:false;
	
	var regExp = new RegExp(".*MSIE ([0-9]\.[0-9]).*","g");
	var navigatorVersion = navigator.userAgent.replace(regExp,'$1');
	
	var ajaxObjects = new Array();
	var tabView_countTabs = new Array();
	var tabViewHeight = new Array();
	var tabDivCounter = 0;
	var closeImageHeight = 8;	// Pixel height of close buttons
	var closeImageWidth = 8;	// Pixel height of close buttons
	
	
	function setPadding(obj,padding){
		var span = obj.getElementsByTagName('SPAN')[0];
		span.style.paddingLeft = padding + 'px';	
		span.style.paddingRight = padding + 'px';	
	}
	function showTab(parentId,tabIndex)
	{
		var parentId_div = parentId + "_";
		if(!document.getElementById('tabView' + parentId_div + tabIndex)){
			return;
		}
		if(activeTabIndex[parentId]>=0){
			if(activeTabIndex[parentId]==tabIndex){
				return;
			}
	
			var obj = document.getElementById('tabTab'+parentId_div + activeTabIndex[parentId]);
			
			obj.className='tabInactive';
			var img = obj.getElementsByTagName('IMG')[0];
			if(img.src.indexOf('tab_')==-1)img = obj.getElementsByTagName('IMG')[1];
			img.src = './images/js/tab-view/tab_right_inactive.gif';
			document.getElementById('tabView' + parentId_div + activeTabIndex[parentId]).style.display='none';
		}
		
		var thisObj = document.getElementById('tabTab'+ parentId_div +tabIndex);	
			
		thisObj.className='tabActive';
		var img = thisObj.getElementsByTagName('IMG')[0];
		if(img.src.indexOf('tab_')==-1)img = thisObj.getElementsByTagName('IMG')[1];
		img.src = './images/js/tab-view/tab_right_active.gif';
		
		document.getElementById('tabView' + parentId_div + tabIndex).style.display='block';
		activeTabIndex[parentId] = tabIndex;
		

		var parentObj = thisObj.parentNode;
		var aTab = parentObj.getElementsByTagName('DIV')[0];
		countObjects = 0;
		var startPos = 2;
		var previousObjectActive = false;
		while(aTab){
			if(aTab.tagName=='DIV'){
				if(previousObjectActive){
					previousObjectActive = false;
					startPos-=2;
				}
				if(aTab==thisObj){
					startPos-=2;
					previousObjectActive=true;
					setPadding(aTab,textPadding+1);
				}else{
					setPadding(aTab,textPadding);
				}
				
				aTab.style.left = startPos + 'px';
				countObjects++;
				startPos+=2;
			}			
			aTab = aTab.nextSibling;
		}
		
		return;
	}
	
	function tabClick()
	{
		var idArray = this.id.split('_');		
		showTab(this.parentNode.parentNode.id,idArray[idArray.length-1].replace(/[^0-9]/gi,''));
		
	}
	
	function rolloverTab()
	{
		if(this.className.indexOf('tabInactive')>=0){
			this.className='inactiveTabOver';
			var img = this.getElementsByTagName('IMG')[0];
			if(img.src.indexOf('tab_')<=0)img = this.getElementsByTagName('IMG')[1];
			img.src = './images/js/tab-view/tab_right_over.gif';
		}
		
	}
	function rolloutTab()
	{
		if(this.className ==  'inactiveTabOver'){
			this.className='tabInactive';
			var img = this.getElementsByTagName('IMG')[0];
			if(img.src.indexOf('tab_')<=0)img = this.getElementsByTagName('IMG')[1];
			img.src = './images/js/tab-view/tab_right_inactive.gif';
		}
		
	}
	
	function hoverTabViewCloseButton()
	{
		this.src = this.src.replace('close.gif','close_over.gif');
	}
	
	function stopHoverTabViewCloseButton()
	{
		this.src = this.src.replace('close_over.gif','close.gif');
	}
	
	function initTabs(mainContainerID,tabTitles,activeTab,width,height,closeButtonArray,additionalTab)
	{
		if(!closeButtonArray)closeButtonArray = new Array();
		
		if(!additionalTab || additionalTab=='undefined'){			
			dhtmlgoodies_tabObj[mainContainerID] = document.getElementById(mainContainerID);
			width = width + '';
			if(width.indexOf('%')<0)width= width + 'px';
			dhtmlgoodies_tabObj[mainContainerID].style.width = width;
						
			height = height + '';
			if(height.length>0){
				if(height.indexOf('%')<0)height= height + 'px';
				dhtmlgoodies_tabObj[mainContainerID].style.height = height;
			}
			

			tabViewHeight[mainContainerID] = height;
			
			var tabDiv = document.createElement('DIV');		
			var firstDiv = dhtmlgoodies_tabObj[mainContainerID].getElementsByTagName('DIV')[0];	
			
			dhtmlgoodies_tabObj[mainContainerID].insertBefore(tabDiv,firstDiv);	
			tabDiv.className = 'dhtmlgoodies_tabPane';			
			tabView_countTabs[mainContainerID] = 0;

		}else{
			var tabDiv = dhtmlgoodies_tabObj[mainContainerID].getElementsByTagName('DIV')[0];
			var firstDiv = dhtmlgoodies_tabObj[mainContainerID].getElementsByTagName('DIV')[1];
			height = tabViewHeight[mainContainerID];
			activeTab = tabView_countTabs[mainContainerID];		
	
			
		}
		
		
		
		for(var no=0;no<tabTitles.length;no++){
			var aTab = document.createElement('DIV');
			aTab.id = 'tabTab' + mainContainerID + "_" +  (no + tabView_countTabs[mainContainerID]);
			aTab.onmouseover = rolloverTab;
			aTab.onmouseout = rolloutTab;
			aTab.onclick = tabClick;
			aTab.className='tabInactive';
			tabDiv.appendChild(aTab);
			var span = document.createElement('SPAN');
			span.innerHTML = tabTitles[no];
			span.style.position = 'relative';
			aTab.appendChild(span);
			
			if(closeButtonArray[no]){
				var closeButton = document.createElement('IMG');
				closeButton.src = 'images/close.gif';
				closeButton.height = closeImageHeight + 'px';
				closeButton.width = closeImageHeight + 'px';
				closeButton.setAttribute('height',closeImageHeight);
				closeButton.setAttribute('width',closeImageHeight);
				closeButton.style.position='absolute';
				closeButton.style.top = '6px';
				closeButton.style.right = '0px';
				closeButton.onmouseover = hoverTabViewCloseButton;
				closeButton.onmouseout = stopHoverTabViewCloseButton;
				
				span.innerHTML = span.innerHTML + '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';	
				
				var deleteTxt = span.innerHTML+'';

				closeButton.onclick = function(){ deleteTab(this.parentNode.innerHTML) };
				span.appendChild(closeButton);
			}
			
			var img = document.createElement('IMG');
			img.valign = 'bottom';
			img.src = './images/js/tab-view/tab_right_inactive.gif';
			// IE5.X FIX
			if((navigatorVersion && navigatorVersion<6) || (MSIE && !strictDocType)){
				img.style.styleFloat = 'none';
				img.style.position = 'relative';	
				img.style.top = '4px'
				span.style.paddingTop = '4px';
				aTab.style.cursor = 'hand';
			}	// End IE5.x FIX
			aTab.appendChild(img);
		}

		var tabs = dhtmlgoodies_tabObj[mainContainerID].getElementsByTagName('DIV');
		var divCounter = 0;
		for(var no=0;no<tabs.length;no++){
			if(tabs[no].className=='dgTab' && tabs[no].parentNode.id == mainContainerID){
				if(height.length>0)tabs[no].style.height = height;
				tabs[no].style.display='none';
				tabs[no].id = 'tabView' + mainContainerID + "_" + divCounter;
				divCounter++;
			}			
		}	
		tabView_countTabs[mainContainerID] = tabView_countTabs[mainContainerID] + tabTitles.length;	
		showTab(mainContainerID,activeTab);

		return activeTab;
	}	
	
	function showAjaxTabContent(ajaxIndex,parentId,tabId)
	{
		var obj = document.getElementById('tabView'+parentId + '_' + tabId);
		obj.innerHTML = ajaxObjects[ajaxIndex].response;		
	}
	
	function resetTabIds(parentId)
	{
		var tabTitleCounter = 0;
		var tabContentCounter = 0;
		
		
		var divs = dhtmlgoodies_tabObj[parentId].getElementsByTagName('DIV');

		
		for(var no=0;no<divs.length;no++){
			if(divs[no].className=='dgTab'){
				divs[no].id = 'tabView' + parentId + '_' + tabTitleCounter;
				tabTitleCounter++;
			}
			if(divs[no].id.indexOf('tabTab')>=0){
				divs[no].id = 'tabTab' + parentId + '_' + tabContentCounter;	
				tabContentCounter++;
			}	
			
				
		}
	
		tabView_countTabs[parentId] = tabContentCounter;
	}
	
	
	function createNewTab(parentId,tabTitle,tabContent,tabContentUrl,closeButton)
	{
		if(tabView_countTabs[parentId]>=tabView_maxNumberOfTabs)return;	// Maximum number of tabs reached - return
		var div = document.createElement('DIV');
		div.className = 'dgTab';
		dhtmlgoodies_tabObj[parentId].appendChild(div);		

		var tabId = initTabs(parentId,Array(tabTitle),0,'','',Array(closeButton),true);
		if(tabContent)div.innerHTML = tabContent;
		if(tabContentUrl){
			var ajaxIndex = ajaxObjects.length;
			ajaxObjects[ajaxIndex] = new sack();
			ajaxObjects[ajaxIndex].requestFile = tabContentUrl;	// Specifying which file to get

			ajaxObjects[ajaxIndex].onCompletion = function(){ showAjaxTabContent(ajaxIndex,parentId,tabId); };	// Specify function that will be executed after file has been found
			ajaxObjects[ajaxIndex].runAJAX();		// Execute AJAX function	

            /* New Protoype object
             var opt = {
              method: 'post',
              postBody: '',
              onSuccess: function(t) {
                div.innerHTML = t.responseText;
              },
              on404: function(t) {
                alert('Error 404: location "' + t.statusText + '" was not found.');
              },
              onFailure: function(t) {
                alert('Error ' + t.status + ' -- ' + t.statusText);
              }
            }
            new Ajax.Request(tabContentUrl, opt);
            */

		}
				
	}
	
	function getTabIndexByTitle(tabTitle)
	{
		var regExp = new RegExp("(.*?)&nbsp.*$","gi");
		tabTitle = tabTitle.replace(regExp,'$1');
		for(var prop in dhtmlgoodies_tabObj){
			var divs = dhtmlgoodies_tabObj[prop].getElementsByTagName('DIV');
			for(var no=0;no<divs.length;no++){
				if(divs[no].id.indexOf('tabTab')>=0){
					var span = divs[no].getElementsByTagName('SPAN')[0];
					var regExp2 = new RegExp("(.*?)&nbsp.*$","gi");
					var spanTitle = span.innerHTML.replace(regExp2,'$1');
					
					if(spanTitle == tabTitle){
						
						var tmpId = divs[no].id.split('_');						
						return Array(prop,tmpId[tmpId.length-1].replace(/[^0-9]/g,'')/1);
					}		
				}
			}
		}
		
		return -1;
		
	}
	
	/* Call this function if you want to display some content from external file in one of the tabs 
	Arguments: Title of tab and relative path to external file */
	
	function addAjaxContentToTab(tabTitle,tabContentUrl)
	{
		var index = getTabIndexByTitle(tabTitle);
		if(index!=-1){
			var ajaxIndex = ajaxObjects.length;
			
			tabId = index[1];
			parentId = index[0];
			
			
			ajaxObjects[ajaxIndex] = new sack();
			ajaxObjects[ajaxIndex].requestFile = tabContentUrl;	// Specifying which file to get

			ajaxObjects[ajaxIndex].onCompletion = function(){ showAjaxTabContent(ajaxIndex,parentId,tabId); };	// Specify function that will be executed after file has been found
			ajaxObjects[ajaxIndex].runAJAX();		// Execute AJAX function				
			
		}	
	}

	
	
	function deleteTab(tabLabel,tabIndex,parentId)
	{

		if(tabLabel){
			var index = getTabIndexByTitle(tabLabel);
			if(index!=-1){
				deleteTab(false,index[1],index[0]);
			}
			
		}else if(tabIndex>=0){
			if(document.getElementById('tabTab' + parentId + '_' + tabIndex)){
				var obj = document.getElementById('tabTab' + parentId + '_' + tabIndex);
				var id = obj.parentNode.parentNode.id;
				obj.parentNode.removeChild(obj);
				var obj2 = document.getElementById('tabView' + parentId + '_' + tabIndex);
				obj2.parentNode.removeChild(obj2);
				resetTabIds(parentId);
				activeTabIndex[parentId]=-1;
				showTab(parentId,'0');
			}			
		}
		

			
		
		
	}
	
	/************************************************************************************************************
(C) www.dhtmlgoodies.com, September 2005

This is a script from www.dhtmlgoodies.com. You will find this and a lot of other scripts at our website.	

Terms of use:
You are free to use this script as long as the copyright message is kept intact. However, you may not
redistribute, sell or repost it without our permission.

Thank you!

www.dhtmlgoodies.com
Alf Magne Kalleland

************************************************************************************************************/

var form_widget_amount_slider_handle = './images/js/form_widget_amount_slider/slider_handle.gif';
var slider_handle_image_obj = false;
var sliderObjectArray = new Array();
var slider_counter = 0;
var slideInProgress = false;
var handle_start_x;
var event_start_x;
var currentSliderIndex;
var sliderHandleWidth = 9;

function form_widget_cancel_event()
{
	return false;		
}

function getImageSliderHeight(){
	if(!slider_handle_image_obj){
		slider_handle_image_obj = new Image();
		slider_handle_image_obj.src = form_widget_amount_slider_handle;
	}
	if(slider_handle_image_obj.width>0){
		return;
	}else{
		setTimeout('getImageSliderHeight()',50);
	}
}


function positionSliderImage(e,theIndex)
{
	
	if(!theIndex)theIndex = this.getAttribute('sliderIndex');
	var theValue = sliderObjectArray[theIndex]['formTarget'].value;
	if(!theValue.match(/^[0-9]*$/g))theValue=sliderObjectArray[theIndex]['min'] +'';
	if(theValue/1>sliderObjectArray[theIndex]['max'])theValue = sliderObjectArray[theIndex]['max'];
	if(theValue/1<sliderObjectArray[theIndex]['min'])theValue = sliderObjectArray[theIndex]['min'];
	sliderObjectArray[theIndex]['formTarget'].value = theValue;
	var handleImg = document.getElementById('slider_handle' + theIndex);
	var ratio = sliderObjectArray[theIndex]['width'] / (sliderObjectArray[theIndex]['max']-sliderObjectArray[theIndex]['min']);
	var currentValue = sliderObjectArray[theIndex]['formTarget'].value-sliderObjectArray[theIndex]['min'];		
	handleImg.style.left = Math.round(currentValue * ratio) + 'px';	
}



function adjustFormValue(theIndex)
{
	var handleImg = document.getElementById('slider_handle' + theIndex);	
	var ratio = sliderObjectArray[theIndex]['width'] / (sliderObjectArray[theIndex]['max']-sliderObjectArray[theIndex]['min']);
	var currentPos = handleImg.style.left.replace('px','');
	sliderObjectArray[theIndex]['formTarget'].value = Math.round(currentPos / ratio) + sliderObjectArray[theIndex]['min'];
	
}
	
function initMoveSlider(e)
{

	if(document.all)e = event;	
	slideInProgress = true;
	event_start_x = e.clientX;
	handle_start_x = this.style.left.replace('px','');
	currentSliderIndex = this.id.replace(/[^\d]/g,'');
	return false;
}

function startMoveSlider(e)
{
	if(document.all)e = event;	
	if(!slideInProgress)return;	
	var leftPos = handle_start_x/1 + e.clientX/1 - event_start_x;
	if(leftPos<0)leftPos = 0;
	if(leftPos/1>sliderObjectArray[currentSliderIndex]['width'])leftPos = sliderObjectArray[currentSliderIndex]['width'];
	document.getElementById('slider_handle' + currentSliderIndex).style.left = leftPos + 'px';
	adjustFormValue(currentSliderIndex);
	if(sliderObjectArray[currentSliderIndex]['onchangeAction']){
		eval(sliderObjectArray[currentSliderIndex]['onchangeAction']);
	}
}

function stopMoveSlider()
{
	slideInProgress = false;
}

function form_widget_amount_slider(targetElId,formTarget,width,min,max,onchangeAction)
{
	if(!slider_handle_image_obj){
		getImageSliderHeight();		
	}
			
	slider_counter = slider_counter +1;
	sliderObjectArray[slider_counter] = new Array();
	sliderObjectArray[slider_counter] = {"width":width - sliderHandleWidth,"min":min,"max":max,"formTarget":formTarget,"onchangeAction":onchangeAction};
	
	formTarget.setAttribute('sliderIndex',slider_counter);
	formTarget.onchange = positionSliderImage;
	var parentObj = document.createElement('DIV');

	
	parentObj.style.height = '12px';	// The height of the image
	parentObj.style.position = 'relative';
	parentObj.id = 'slider_container' + slider_counter;
	document.getElementById(targetElId).appendChild(parentObj);
	
	var obj = document.createElement('DIV');
	obj.className = 'form_widget_amount_slider';
	obj.innerHTML = '<span></span>';
	obj.style.width = width + 'px';
	obj.id = 'slider_slider' + slider_counter;
	obj.style.position = 'absolute';
	obj.style.bottom = '0px';
	parentObj.appendChild(obj);
	
	var handleImg = document.createElement('IMG');
	handleImg.style.position = 'absolute';
	handleImg.style.left = '0px';
	handleImg.style.zIndex = 5;
	handleImg.src = slider_handle_image_obj.src;
	handleImg.id = 'slider_handle' + slider_counter;
	handleImg.onmousedown = initMoveSlider;
	
	parentObj.style.width = obj.offsetWidth + 'px';
	
	if(document.body.onmouseup){
		if(document.body.onmouseup.toString().indexOf('stopMoveSlider')==-1){
			alert('You allready have an onmouseup event assigned to the body tag');
		}
	}else{
		document.body.onmouseup = stopMoveSlider;	
		document.body.onmousemove = startMoveSlider;	
	}
	handleImg.ondragstart = form_widget_cancel_event;
	parentObj.appendChild(handleImg);
	positionSliderImage(false,slider_counter);
	
	
}
