function showhide(id){
	document.getElementById(id).style.display=(document.getElementById(id).style.display=='none')?'block':'none';
//	document.getElementById('ShowDivOff'+id).style.display=(document.getElementById(id).style.display=='none')?'block':'none';
//	document.getElementById('ShowDivOn'+id).style.display=(document.getElementById('ShowDid).style.display=='none')?'block':'none';
}
function ShowAmt(id)
{
if (id == 99999)
	{
	window.open('http://www.kommunikationogsprog.dk/auklub');
	}
	else
	{
	window.location=('/?Id='+id);
	}
}

function hidebox(){
if (ie4||ns6)
crossobj.style.visibility="hidden"
else if (ns4)
document.showimage.visibility="hide"
}

function DispKreds(place) 
	{
	var location = document.kredse.kreds.options[place].value
		window.location=(location)
	}
	
var ns4=document.layers
var ie4=document.all
var ns6=document.getElementById&&!document.all

//drag drop function for NS 4////
/////////////////////////////////

var dragswitch=0
var nsx
var nsy
var nstemp

function drag_dropns(name){
if (!ns4)
return
temp=eval(name)
temp.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP)
temp.onmousedown=gons
temp.onmousemove=dragns
temp.onmouseup=stopns
}

function gons(e){
temp.captureEvents(Event.MOUSEMOVE)
nsx=e.x
nsy=e.y
}
function dragns(e){
if (dragswitch==1){
temp.moveBy(e.x-nsx,e.y-nsy)
return false
}
}

function stopns(){
temp.releaseEvents(Event.MOUSEMOVE)
}

//drag drop function for ie4+ and NS6////
/////////////////////////////////


function drag_drop(e){
if (ie4&&dragapproved){
crossobj.style.left=tempx+event.clientX-offsetx
crossobj.style.top=tempy+event.clientY-offsety
return false
}
else if (ns6&&dragapproved){
crossobj.style.left=tempx+e.clientX-offsetx
crossobj.style.top=tempy+e.clientY-offsety
return false
}
}

function initializedrag(e){
crossobj=ns6? document.getElementById("showimage") : document.all.showimage

var firedobj=ns6? e.target : event.srcElement
var topelement=ns6? "HTML" : "BODY"

while (firedobj.tagName!=topelement&&firedobj.id!="dragbar"){
firedobj=ns6? firedobj.parentNode : firedobj.parentElement
}

if (firedobj.id=="dragbar"){
offsetx=ie4? event.clientX : e.clientX
offsety=ie4? event.clientY : e.clientY

tempx=parseInt(crossobj.style.left)
tempy=parseInt(crossobj.style.top)

dragapproved=true
document.onmousemove=drag_drop
}
}
document.onmousedown=initializedrag
document.onmouseup=new Function("dragapproved=false")

////drag drop functions end here//////

function resizeDivs()
{
	document.getElementById('divContent').style.height = (document.body.clientHeight-460)+' px';
	
}
function ShowSatsList(id)
{
	window.location=('/index.asp?Id='+id);
}
function OpenPrint(strPage) 
{
	window.open(strPage,'Print','height=450,width=600,location=no,scrollbars=yes,menubars=no,toolbars=no,resizable=no,top='+(screen.height-450)/2+',left='+(screen.width-600)/2);
}
function ScreenPrint()
{
	window.print();
	window.close();
}

function ShowPublicationList(id)
{
	window.location=('/moduler/publications/frontend/index.asp?PublicationCategory='+id);
}
function ShowKursusList(id)
{
	window.location=(id);
}
function ShowNews(id)
{
	window.location=('/index.asp?NyhedsId='+id);
}

function NumberOk(str)
{
  for (var i = 0; i < str.length; ++i)
    if (str.charAt(i) < '0' || str.charAt(i) > '9') return false;
  return true;
}

function Trim(str)
{
  var tmp = "";
  var n = str.length;
  var i = 0;
  var j = n;
  while (str.charAt(i) == ' ' && i < n) ++i;
  while (str.charAt(j) == ' ' && j > 0) --j;
  if (i < j) tmp = str.substring(i, j);
  return tmp;
}

function ToAMD(dato)
{
  if (dato.length == 0) return "";
  var dag = dato.substring(0, 2);
  var mdr = dato.substring(3, 5);
  var aar = dato.substring(6);
  return aar + "-" + mdr + "-" + dag;
}

function ToDMA(dato)
{
  if (dato.length == 0) return "";
  var aar = dato.substring(0, 4);
  var mdr = dato.substring(5, 7);
  var dag = dato.substring(8);
  return dag + "-" + mdr + "-" + aar;
}

function y2k(number)
{
	return (number < 1000) ? number + 1900 : number;
}

function padout(number)
{
	return (number < 10) ? '0' + number : number;
}

var today = new Date();
var day = today.getDate();
var month = today.getMonth();
var year = y2k(today.getYear());
var whichOne = 0;

function restart()
{
	document.editor.elements['date' + whichOne].value = '' + padout(day) + '-' + padout(month - 0 + 1) + '-' + year;
	mywindow.close();
	document.editor.elements['date' + whichOne].focus();
}

function newWindow(number)
{
	whichOne = number;
	day = today.getDate(), month = today.getMonth(), year = y2k(today.getYear());
	mywindow=open('../lib/cal.htm','vindue','resizable=no,width=300,height=190');
	mywindow.location.href = '../lib/cal.htm';
	if (mywindow.opener == null) mywindow.opener = self;
}

function found(box, id, kode)
{
  var item = id + ":" + kode;
	for (var i = 0; i < box.options.length; i++)
	{
		if (box.options[i].value == item) return true;
	}
	return false;
}

function moveTo(fbox, tbox, kode)
{
	for (var i = 0; i < fbox.options.length; i++)
	{
		if (fbox.options[i].selected && fbox.options[i].value != "")
		{
			if (!found(tbox, fbox.options[i].value, kode))
			{
				var no = new Option();
				no.value = fbox.options[i].value + ":" + kode;
				no.text = "[" + kode + "] " + fbox.options[i].text;
				tbox.options[tbox.options.length] = no;
			}
		}
	}
}

function removeFrom(box)
{
  for (var i = 0; i < box.options.length; i++)
  {
    if (box.options[i].selected && box.options[i].value != "")
    {
      box.options[i].value = "";
      box.options[i].text = "";
    }
  }
  BumpUp(box);
}

function BumpUp(box)
{
	for (var i = 0; i < box.options.length; i++)
	{
		if (box.options[i].value == "")
		{
			for (var j = i; j < box.options.length-1; j++)
			{
				box.options[j].value = box.options[j+1].value;
				box.options[j].text = box.options[j+1].text;
			}
			var ln = i;
			break;
		}
	}
	if (ln < box.options.length)
	{
		box.options.length -= 1;
		BumpUp(box);
	}
}
