var popUpWindow;

function PopUp(url,width,height)  {
 
  var div = document.getElementById('page');
  if (div==null)  {
    return;
  }
  if (popUpWindow != null) {
    try { 
        popUpWindow.close();
    } 
    catch(err) { 
        alert(err.description);
    }
  }
  
  popUpWindow = window.open('','Popup','height='+height+',width='+width);
  popUpWindow.document.write('<html><head><title>Popup</title>');
  popUpWindow.document.write('<style>body{margin:0;padding:0}</style></head><body>');
  popUpWindow.document.write('<a href="javascript:window.close()" title="Klik for at lukke vindue">');
  popUpWindow.document.write('<img src="'+url+'" width="'+width+'" height="'+height+'" border="0"></a>');
  popUpWindow.document.write('</body><html>');
  popUpWindow.focus();
}



// Trim string left + right
function trimAll(sString) {
	while (sString.substring(0,1) == ' ') {
		sString = sString.substring(1, sString.length);
	}
	while (sString.substring(sString.length-1, sString.length) == ' ') {
		sString = sString.substring(0,sString.length-1);
	}
	return sString;
}	

// Test Search value before submitting
function validateSearch() 
{
	document.form.Search.value=trimAll(document.form.Search.value); 
	if(document.form.Search.value != 'S&oslash;geord' && document.form.Search.value != '') {
		document.form.submit(); 
	}			
	return false;
}

function validateEmail(str) {
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
	   return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
	    return false
	}

	 if (str.indexOf(at,(lat+1))!=-1){
	    return false
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
	    return false
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
	    return false
	 }
	
	 if (str.indexOf(" ")!=-1){
	    return false
	 }
		 return true					
}


