
function 
findObj(theObj, theDoc)
  {
  var p, i, foundObj = null;
  
  if(!theDoc) theDoc = document;
  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
  {
    theDoc = parent.frames[theObj.substring(p+1)].document;
    theObj = theObj.substring(0,p);
  }
  if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
  for (i=0; !foundObj && i < theDoc.forms.length; i++) 
    foundObj = theDoc.forms[i][theObj];
  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
    foundObj = findObj(theObj,theDoc.layers[i].document);
  if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
  
  return foundObj;
  }

function 
MM_findObj(n, d) 
  { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
  }

function 
MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' skal være en e-mail addresse.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' skal være et nummer.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' skal være et nummer mellem '+min+' og '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' skal udfyldes.\n'; }
  } if (errors) alert('Følgende problemer skal rettes :\n\n'+errors);
  document.MM_returnValue = (errors == '');
}

function
AppendBR(InStr)
  {
  SplitStr = InStr.split('\n') ;
  OutStr = "" ;
  
  for (t = 0 ; t < SplitStr.length ; t++)
    OutStr += SplitStr[t]+"<BR>\n" ;
    
  return OutStr ;
  }

function
ConvertToDKPrice(Price)
  {
  var DKPriceStr = "" ;
  var ThousesArr = Array() ;
  var TheSign = false ;

  if (Price < 0.0)
    {
	Price *= -1.0 ;
	TheSign = true ;
	}
  
  FloorPrice = Math.floor(Price) ;
  Frac = Math.round(100.0 * (Price - FloorPrice)) ;
  CurPrice = FloorPrice / 1000.0 ;
  ThousesNo = 0 ;
  while (CurPrice >= 1.0)
    {
    FloorCurPrice1K = 1000.0 * Math.floor(CurPrice) ;
	ThousesArr[ThousesNo] = 1000.0 * CurPrice - FloorCurPrice1K ;

	CurPrice = FloorCurPrice1K / 1000000.0 ;
	ThousesNo += 1 ;
	}
  ThousesArr[ThousesNo] = 1000.0 * CurPrice ;

  if (TheSign == true) DKPriceStr += "-" ;
  for (t = ThousesNo ; t >= 0 ; t--)
    {
	if (t < ThousesNo)
	  {
	  if (ThousesArr[t] < 100.0) DKPriceStr += ("0") ;
	  if (ThousesArr[t] < 10.0) DKPriceStr += ("0") ;
	  }
	DKPriceStr += (""+Math.round(ThousesArr[t])) ;
	if (t > 0) DKPriceStr += "." ;
	}
  
  DKPriceStr += ("," ) ;
  if (Frac < 10.0) DKPriceStr += ("0") ;
  DKPriceStr += (Frac) ;
  
  return DKPriceStr ;
  }

