// -----------------------------------------------------------
// Browser detection
// -----------------------------------------------------------
InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;

  isNS6 = false;
  if (navigator.appName == "Netscape" && parseInt(navigator.appVersion) >= 5) {
    isNS6 = true;
  }

  isMacIE = false;
  if ((navigator.appVersion.indexOf("Mac") != -1) && (navigator.userAgent.indexOf("MSIE") != -1)) {
    isMacIE = true;
  }

// -----------------------------------------------------------
// Layer funktioner
// -----------------------------------------------------------

function MM_findObj(n, d) 
{
  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 && document.getElementById) 
		x=document.getElementById(n); 
	return x;
}

function MM_showHideLayers() 
{
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
	if ((obj=MM_findObj(args[i]))!=null) 
	{ 
		v=args[i+2];
    		if (obj.style) 
		{ 
			obj=obj.style; 
			v=(v=='show')?'visible':(v='hide')?'hidden':v; 
		}
    		obj.visibility=v; 
	}
}


// -----------------------------------------------------------
// Open new windows commands
// -----------------------------------------------------------
function MM_openBrWindow(theURL,winName,features) 
{ //v2.0
  window.open(theURL,winName,features);
}

function launchCenteredWin(url, name, width, height, otherfeatures)
{
  var str = "height=" + height + ",innerHeight=" + height;
  str += ",width=" + width + ",innerWidth=" + width;
  if (window.screen) {
    var ah = screen.availHeight - 30;
    var aw = screen.availWidth - 10;

    var xc = (aw - width) / 2;
    var yc = (ah - height) / 2;

    str += ",left=" + xc + ",screenX=" + xc;
    str += ",top=" + yc + ",screenY=" + yc;
  }
  newwin = window.open(url, name, str + ',' + otherfeatures);

}

function launchWin(url, name, width, height,x_pos,y_pos, otherfeatures)
{
  var str = "" 
  
  str = "height=" + height + ",innerHeight=" + height;
  str += ",width=" + width + ",innerWidth=" + width;

  if (window.screen) {
    var ah = screen.availHeight - 30;
    var aw = screen.availWidth - 10;

    var xc = (aw - width) / 2;
    var yc = (ah - height) / 2;

    str += ",left=" + x_pos + ",screenX=" + x_pos;
    str += ",top=" + y_pos + ",screenY=" + y_pos;

  }
  newwin = window.open(url, name, str + ',' + otherfeatures);


}

function LaunchLogoutScript()
{
	launchWin('./Logout.asp?C=1','_blank',25,25,0,0,'scrollbars=no,resizable=no');
}
// -----------------------------------------------------------
//  LOKE funktions
// -----------------------------------------------------------
function Relocated( url)
{
	top.mframe.sideframe.location.href=url
}
function RelocatedMenu( url)
{
	top.mframe.MenuFrame.location.href=url
}

function RelocatedUpdate( url)
{
	top.Update.location.href=url
}
function Relocated_MF( url)
{
	top.mframe.MenuFrame.location.href=url
}
function ChanceMenu(menu)
{

	  navMovie = InternetExplorer ? top.mframe.MenuFrame.navMovie : top.mframe.MenuFrame.document.navMovie;
	  //navMovie = InternetExplorer ? top.mframe.linksframe.navMovie : top.mframe.linksframe.navMovie;
          //navMovie.SetVariable("_root.section",pageID);
          //navMovie.TGotoLabel("_level0", "changesection");
          //navMovie.TPlay("_level0");
	  navMovie.SetVariable("_root.ControlMovie.Menu", menu);
	  navMovie.SetVariable("_root.ControlMovie.ChanceM", 1);

}

function textCounter(field,maxlimit) 
{
	if (field.value.length > maxlimit) 
		field.value = field.value.substring(0, maxlimit);
}

// ------------------------------------------------
// Text counter
// ------------------------------------------------
function textCounter2(field, field2, maxlimit) 
{
	if (field.value.length > maxlimit) 
		field.value = field.value.substring(0, maxlimit);

	Count =  maxlimit - field.value.length;

	if(Count < 500)
	{
		field2.value ="(" + Count  + " tegn tilbage )"
	}
	else
	{
		field2.value =""
	}

}

function textCounter(field, field2, maxlimit) 
{
	if (field.value.length > maxlimit) 
		field.value = field.value.substring(0, maxlimit);

	Count =  maxlimit - field.value.length;

	if(Count < 500)
	{
		if(field2!=null)
		{
			field2.value ="(" + Count  + " tegn tilbage )"
		}
	}
	else
	{
		if(field2!=null)
		{
			field2.value =""
		}
	}

}

function numeric_onkeypress(event) 
{
	var c;

	if ( document.all ) 
		c = event.keyCode;
	else
		c = event.charCode;

	keyvalid = ( ((c>47) && (c<58)) || (c==0) );
	
	if ( !keyvalid )
	{
		event.returnValue = false;

		if ( document.all )
			return false;

		event.preventDefault ();
		return false;
	}

	return true;
}

// -----------------------------------------------
// Lag
// -----------------------------------------------


function ShowLag(LAG)
{
	if(InternetExplorer == true)
	{
		document.all[""+LAG].style.visibility = "Visible"
		
	}
	
	else
	{
		document.getElementById(""+LAG).style.visibility = "Visible"
	}

}
function HideLag(LAG)
{

	if(InternetExplorer == true)
	{
		document.all[""+LAG].style.visibility = "Hidden"
	}

	else
	{
		document.getElementById(""+LAG).style.visibility = "Hidden"
		
	
	
	}


}
function ShowLag2(LAG)
{
	if(InternetExplorer == true)
	{
		document.all[""+LAG].style.visibility = "Visible"
		document.all[""+LAG].style.Display = "BLOCK"
		
	}
	
	else
	{
		document.getElementById(""+LAG).style.visibility = "Visible"
		document.getElementById(""+LAG).style.Display = "BLOCK"
	}

}
function HideLag2(LAG)
{

	if(InternetExplorer == true)
	{
		document.all[""+LAG].style.visibility = "Hidden"
		document.all[""+LAG].style.Display = "NONE"
	}

	else
	{
		document.getElementById(""+LAG).style.visibility = "Hidden"
		document.getElementById(""+LAG).style.Display = "NONE"		
	
	
	}


}

function ShowBlock(LAG)
{
		

	if(InternetExplorer == true)
	{
		//document.all[""+LAG].style.visibility = "visible"
		document.all[""+LAG].style.display = "BLOCK"
	}	
	else
	{
		document.getElementById(""+LAG).style.top = 0
		document.getElementById(""+LAG).style.visibility = 'visible'
		document.getElementById(""+LAG).style.display = 'Block'	

	}

}
function HideBlock(LAG)
{

	if(InternetExplorer == true)
	{
		//document.all[""+LAG].style.visibility= "hidden"
		document.all[""+LAG].style.display = "NONE"

	}

	else
	{
		document.getElementById(""+LAG).style.visibility = 'hidden'
		document.getElementById(""+LAG).style.display = 'none'		

	}


}

function FindDivStyle(LAG)
{
	if(InternetExplorer == true)
	{		
		return document.all[""+LAG]
	}

	else
	{
		return document.getElementById(""+LAG)
	}
}

function SetDivBgColor(Lag, color)
{
	if(InternetExplorer == true)
	{
		l = FindDivStyle(Lag)
		l.style.background = color
	}
	else

	{
		l = FindDivStyle(Lag)	
		l.style.background = "#" + color	
	}

}
// -----------------------------------------------
// Billed func
// -----------------------------------------------

// billede swap
function ChangePic(name, pic)
{

		eval("document." + name + ".src = '" + pic + "'")

}

function ChangePic_hw(name, pic, w, h)
{
		eval("document." + name + ".src = '" + pic + "'")
		eval("document." + name + ".width = '" + w + "'")
		eval("document." + name + ".height = '" + h + "'")

	

}



// billede preload
var myimages=new Array()
function preloadimages()
{
	for (i=0;i<preloadimages.arguments.length;i++)
	{
		myimages[i]=new Image()
		myimages[i].src=preloadimages.arguments[i]
	}
}

// ---------------------------------------------
// 
// ---------------------------------------------

function RelocatedUrl(url)
{
	top.location.href=url
}

function RelocatedMenuUrl(url)
{
	top.Menu.location.href=url
}
function RelocatedTFrameUrl(url)
{
	top.TFrame.location.href=url
}

function RelocatedFrameUrl(frame,url)
{

	if(InternetExplorer == true)
	{		
		alert(" " + frame +".location.href = '" + url + "'")
		eval(" " + frame +".location.href = " + url)
	}

	else
	{
		top.getElementById(""+frame).location.href=url
	}
}

// ---------------------------------------------
// 
// ---------------------------------------------

function Resize()
{

   i = document.getElementById('TF');
	
   var H = i.offsetHeight
   var F = parent.document.getElementById('TargetFrame');
   F.style.height = H +'px';

   
   if(F != null && H != null)
   {
   		F.height = H
   }
}
