function OpenPopUp(sURL,w,h)  {
	window.open(sURL, "", "toolbar=0, location=0, status=0, scroll=no, scrollbars=no, menubar=0, resizable=no, width="+w+", height="+h+"")
}

function AltClck(mystring,re){
	//alert(mystring);
	origstr=document.Form1.txtAdvancedSearch.value;
	origstr=origstr.replace(/ $/,"")+' ';
	if(origstr.search(re)==-1){
		origstr+=mystring+' ';
	} 
	else {
		origstr=origstr.replace(re," ");
	}
	document.Form1.txtAdvancedSearch.value=origstr;
}

var NS4 = (document.layers) ? true : false;
function checkEnter(event)
{     
    var code = 0;
    
    if (NS4)
        code = event.which;
    else
        code = event.keyCode;
   
    return (code==13)
    //    __doPostBack('Menu$SearchButton','');
}


// ------------------ Clientside Errorhandling block ------------------ //
// Note : That each template also includes errorhandling script.
var iframe_counter = 0;
function openInIFrame(url) {
	var myiframe;
	var name = 'client_error_logging' + iframe_counter;
	
	myiframe = document.createElement('iframe');
	myiframe.id = name;
	myiframe.src = url;
	myiframe.width = 0;
	myiframe.height = 0;
	document.body.appendChild(myiframe);
	
	iframe_counter = iframe_counter + 1;
}

function URLEncode(plaintext)
{
	// The Javascript escape and unescape functions do not correspond
	// with what browsers actually do...
	var SAFECHARS = "0123456789" +					// Numeric
					"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetic
					"abcdefghijklmnopqrstuvwxyz" +
					"-_.!~*'()";					// RFC2396 Mark characters
	var HEX = "0123456789ABCDEF";

	var encoded = "";
	for (var i = 0; i < plaintext.length; i++ ) {
		var ch = plaintext.charAt(i);
	    if (ch == " ") {
		    encoded += "+";
		} else if (SAFECHARS.indexOf(ch) != -1) {
		    encoded += ch;
		} else {
		    var charCode = ch.charCodeAt(0);
			if (charCode > 255) {
			    encoded += "+";
			} else {
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt(charCode & 0xF);
			}
		}
	} 

	return encoded;
}


/*	--- Fixes for problematic browser behavior ---
*/

/* Width must be specified for float elements in Opera: */
if (navigator.userAgent.toLowerCase().indexOf('opera') != -1) {
	window.attachEvent('onload', function() {
		var li, w = 0, m = document.getElementById('MainMenu');
		for (var i = 0; (li = m.getElementsByTagName('li')[i]); i++) {
			w += li.offsetWidth;
		}
		m.style.width = w + 'px';
	});
}


/*--- Start Ejendome Functions --- */
function showSizeFields(divID, cbID)
{
 if(document.getElementById(cbID).checked)
 {
  document.getElementById(divID).style.display='block';
  
 }
 else
 {
  document.getElementById(divID).style.display='none';
 }
 
}

function enableTerminals(nordA, nordB, nordC, nordCargo, nordID)
{
  if(document.getElementById(nordID).checked)
  {
  document.getElementById(nordA).disabled=false;
  document.getElementById(nordB).disabled=false;
  document.getElementById(nordC).disabled=false;
  document.getElementById(nordCargo).disabled=false;
  }
  else
  {
  document.getElementById(nordA).disabled=true;
  document.getElementById(nordB).disabled=true;
  document.getElementById(nordC).disabled=true;
  document.getElementById(nordCargo).disabled=true;
  }
}

function SetType(ddlLoc, ddlType)
{
     document.getElementById(ddlType.id).disabled=false;
     if ( ddlLoc.value == 'Roskilde (grund)') 
        { 
         for (var index = 0, roof = ddlType.options.length; index < roof; index++) 
            {
                if ('Grunde' == ddlType.options[index].value) {
                    ddlType.options[index].selected = true;
                    ddlType.disabled = true;
                    break;
                    }
             }
         }
}


/*--- End Ejendome Functions --- */

