function updateSel() {
  var i, f = document.forms.mainform; 
  var form = f.Form, omr = f.Omr;

  for (i=0; i<form.length; i++) 
    if (form[i].checked) 
    {
      form = form[i].value; break;
    }
  
  for (i=0; i<omr.length; i++) 
    if (omr[i].checked) 
    {
      omr = omr[i].value; break;
    }
   
  var id, d;
  var divs = document.getElementsByTagName('div'), len = divs.length;

  for (i=0; i<len; i++)
  {
    d = divs[i];
    id = d.id;
    if (id.indexOf('d__')==0)
      d.style.display = id.indexOf(form)>0 && id.indexOf(omr)>0 ? 'block' : 'none';
  } 
} 

function ShowSel(id,disp)
{
  var x = document.getElementsByTagName('div');
  inx = parseInt(x.length);
  
  for (var i=0;i<inx;i++)
  {
    if (x[i].id == id)
      x[i].style.display = disp;
  }
}

function ClearSel()
{
  var x = document.getElementsByTagName('div');
  inx = parseInt(x.length);
  
  for (var i=0;i<inx;i++)
  {
    if (x[i].id.substring(0,3) == 'd__')
      x[i].style.display = 'none';
  }
}

function ExpandSel()
{
  var x = document.getElementsByTagName('div');
  inx = parseInt(x.length);
  
  for (var i=0;i<inx;i++)
  {
      x[i].style.display = 'block';
  }
}


function Tablecolor(color,id)
{
  var x = document.getElementsByTagName('table');
  inx = parseInt(x.length);
 
  if (id = 'all')
  {
    for (var i=0;i<inx;i++)
    {
      if (x[i].id.substring(0,4) == 'tab__')
        x[i].bgcolor = color;    
    }
  }
  else
  {
    for (var i=0;i<inx;i++)
    {
      if (x[i].id == id)
        x[i].bgcolor = color;
    }
  }
}


function XXXToggleVisibility(object)
{
  if (document.getElementById(object).style.visibility != "hidden")
  {
    document.getElementById(object).style.visibility = "hidden";
  }
  else
  {
    document.getElementById(object).style.visibility = "visible";
  } 
}

/**  
*  
*  URL encode / decode  
*  http://www.webtoolkit.info/  
*  
**/  
  
var Url = {   
  
    // public method for url encoding   
    encode : function (string) {   
        return escape(this._utf8_encode(string));   
    },   
  
    // public method for url decoding   
    decode : function (string) {   
        return this._utf8_decode(unescape(string));   
    },   
  
    // private method for UTF-8 encoding   
    _utf8_encode : function (string) {   
        string = string.replace(/\r\n/g,"\n");   
        var utftext = "";   
  
        for (var n = 0; n < string.length; n++) {   
  
            var c = string.charCodeAt(n);   
  
            if (c < 128) {   
                utftext += String.fromCharCode(c);   
            }   
            else if((c > 127) && (c < 2048)) {   
                utftext += String.fromCharCode((c >> 6) | 192);   
                utftext += String.fromCharCode((c & 63) | 128);   
            }   
            else {   
                utftext += String.fromCharCode((c >> 12) | 224);   
                utftext += String.fromCharCode(((c >> 6) & 63) | 128);   
                utftext += String.fromCharCode((c & 63) | 128);   
            }   
  
        }   
  
        return utftext;   
    },   
  
    // private method for UTF-8 decoding   
    _utf8_decode : function (utftext) {   
        var string = "";   
        var i = 0;   
        var c = c1 = c2 = 0;   
  
        while ( i < utftext.length ) {   
  
            c = utftext.charCodeAt(i);   
  
            if (c < 128) {   
                string += String.fromCharCode(c);   
                i++;   
            }   
            else if((c > 191) && (c < 224)) {   
                c2 = utftext.charCodeAt(i+1);   
                string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));   
                i += 2;   
            }   
            else {   
                c2 = utftext.charCodeAt(i+1);   
                c3 = utftext.charCodeAt(i+2);   
                string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));   
                i += 3;   
            }   
  
        }   
  
        return string;   
    }   
  
}  

function print_page(){
         qs = window.location.search.substring(1);
         qs = "?" + qs + "&lg=print";
 	 rp=window.open(qs,"Legend","top=50,left=50,height=600,width=700,menubar=1,scrollbars=1,resizable=1,status=1");
	 rp.focus();
	 return(false);
}

function change_language(language){
         qs = window.location.search.substring(1);
         lqs = qs.indexOf("&sc_lang=");

         switch (language)
         {
           case "da": break;
           case "en": break;                         
           default: language = "en"; 
         }


         if ( lqs >-1 )
         {
            qs = qs.substring(0,lqs) + qs.substring(lqs+11);
         }

         qs = "?" + qs + "&sc_lang=" + language;
         location.href = qs;  
	 return(false);
}

function mailUrl()
{
  var initialsubj="Please, take a look at this"
  var initialmsg="Hi:\n You may want to check out this site: "+window.location

  window.location = "mailto:?subject="+initialsubj+"&body="+initialmsg
}




function post_to_url(path, params, method)
{
  var newwindow;
  var newdocument; 

  method = method || "post"; // Set method to post by default, if not specified.

  newwindow=window.open("");
  newdocument=newwindow.document;

  var form = newdocument.createElement("form");

  form.setAttribute("method", method);
  form.setAttribute("action", path);

  for(var key in params) 
  {
    var hiddenField = newdocument.createElement("input");
    hiddenField.setAttribute("type", "hidden");
    hiddenField.setAttribute("name", key);
    hiddenField.setAttribute("value", params[key]);
    form.appendChild(hiddenField);
  }
  newdocument.body.appendChild(form);    

  form.submit();
  
 // newdocument.close(); 

}

function change_domane()
{
  var url = window.location;
  url = url.toString();
  url = url.replace(/www.risoe.dk/,"domain.dev.domain.com")
  window.location = url;
}

