var layerList = new Array();

function createLayer(name, left, top, width, height, visible, content) {

  var z = layerList.length;
  var layer;

  layerList[z] = name;

  if (document.layers) {
    document.writeln('<layer name="' + name + '" left=' + left + ' top=' + top + ' width=' + width + ' height=' + height + ' visibility=' + (visible ? '"show"' : '"hide"') + ' z-index=' + z + '>');
    document.writeln(content);
    document.writeln('</layer>');
    layer = getLayer(name);
    layer.width = width;
    layer.height = height;
  }

  if (document.all || document.getElementById) {
    document.writeln('<div id="' + name + '" style="position:absolute; overflow:none; left:' + left + 'px; top:' + top + 'px; width:' + width + 'px; height:' + height + 'px;' + ' visibility:' + (visible ? 'visible;' : 'hidden;') + ' z-index=' + z + '">');
    document.writeln(content);
    document.writeln('</div>');
  }
}

function getLayer(name) {

  // Returns a handle to the named layer.

  if (document.layers)
    return(document.layers[name]);
  else if (document.all) {
    layer = eval('document.all.' + name + '.style');
    return(layer);
  }
  else if (document.getElementById) {
    layer = eval('document.getElementById("' + name + '").style');
    return(layer);
  }
  else
    return(null);
}

function hideLayer(name) {

  var layer = getLayer(name);

  if (document.layers)
    layer.visibility = "hide";
  if (document.all || document.getElementById)
    layer.visibility = "hidden";
}

function showLayer(name) {

  var layer = getLayer(name);

  if (document.layers)
    layer.visibility = "show";
  if (document.all || document.getElementById)
    layer.visibility = "visible";
}

function moveLayer(name, x, y) {

  var layer = getLayer(name);

  if (document.layers)
    layer.moveToAbsolute(x, y);
    //layer.moveTo(x, y);
  if (document.all || document.getElementById) {
    layer.left = x;
    layer.top  = y;
  }
}

function getzIndex(name) {

  var layer = getLayer(name);

  if (document.layers)
    return(layer.zIndex);
  else if (document.all)
    return(layer.zIndex);
  else
    return(null);
}

function setzIndex(name, z) {

  var layer = getLayer(name);

  if (document.layers)
    layer.zIndex = z;
  if (document.all)
    layer.zIndex = z;
}

function sortzIndex(a, b) {

  return(getzIndex(a) - getzIndex(b));
}

function bringToFront(name) {

  var i, temp;

  layerList.sort(sortzIndex);

  i = layerList.length - 1;
  temp = getzIndex(layerList[i]);
  while (i > 0 && layerList[i] != name) {
    setzIndex(layerList[i], getzIndex(layerList[i - 1]));
    i--;
  }
  setzIndex(name, temp);
}

function changebgcolor(element){
  if (navigator.appName != "Netscape") {
	 element.style.background="#FFFDC6";
  }
}

function changeback(element){
  if (navigator.appName != "Netscape") {
	 element.style.background="#ffffff";
  }
}


function ShowHieraki(ind_id,ind_type,cvr,name,status,idx){
	//alert('jtreetable/chieraki.asp?ind_id=' + ind_id + '&ind_type=' + ind_type + '&cvr=' + cvr + '&name=' + escape(name) + '&status=' + status + '&idx=' + idx);
	window.open('jtreetable/chieraki.asp?ind_id=' + ind_id + '&ind_type=' + ind_type + '&cvr=' + cvr + '&name=' + escape(name) + '&status=' + status + '&idx=' + idx, "compwnd", "toolbar=0,scrollbars=yes,location=0,status=0,menubar=0,resizable=yes,width=635,height=480,left=150,top=150");
}

function ShowHelp(h_id){
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open('help.asp?id=" + h_id + "', 'hlpwnd', 'toolbar=1,scrollbars=yes,location=0,status=0,menubar=0,resizable=yes,width=520,height=520,left=150,top=150');");
}

function ShowFieldHelp(h_field){
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open('help.asp?field=" + h_field + "', 'hlpwnd', 'toolbar=1,scrollbars=yes,location=0,status=0,menubar=0,resizable=yes,width=520,height=520,left=150,top=150');");
}

function openwnd(wndname){
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open('" + wndname + "', 'tmpwnd', 'toolbar=0,scrollbars=yes,location=0,status=0,menubar=0,resizable=no,width=585,height=465,left=150,top=150');");
}

function SetShowDialog(p_name) {
	wOpenWindow(p_name, "nnndwnd", 520,550)
}

function SetShowDialogNNX(p_name) {
	wOpenWindow(p_name, "nnxnwnd", 520,520)
}

function OpenWindow(theURL, target, winwidth, winheight) { //v2.0
	var xposi = 0, yposi = 0;				// default values
	//var winwidth = 350, winheight= 250;		// default values
	if (document.all) var xMax = screen.width, yMax = screen.height;
	else if (document.layers) var xMax = window.outerWidth, yMax = window.outerHeight;
	xposi = xMax/2 - (winwidth/2)
	yposi = yMax/2 - (winheight/2)
	window.open(theURL,'','screenX='+xposi+',screenY='+yposi+',top='+yposi+',left='+xposi+',width='+winwidth+',height='+winheight+',location=no,scrolling=yes, scrollbars=yes,status=no, resizable');
}

function wOpenWindow(theURL, target, winwidth, winheight) { //v2.0
	var xposi = 0, yposi = 0;				// default values
	//var winwidth = 350, winheight= 250;		// default values
	if (document.all) var xMax = screen.width, yMax = screen.height;
	else if (document.layers) var xMax = window.outerWidth, yMax = window.outerHeight;
	xposi = xMax/2 - (winwidth/2)
	yposi = yMax/2 - (winheight/2)
	window.open(theURL,'','screenX='+xposi+',screenY='+yposi+',top='+yposi+',left='+xposi+',width='+winwidth+',height='+winheight+',toolbar=yes,location=no,scrolling=no, scrollbars=no,status=no');
}

function changetab(tabno){
	if(tabno==1){
		document.forms[0].logintab.value = "login";
	}
	if(tabno==2){
		document.forms[0].logintab.value = "produktinfo";
	}
	if(tabno==3){
		document.forms[0].logintab.value = "dataindhold";
	}
	if(tabno==4){
		document.forms[0].logintab.value = "demo";
	}
	if(tabno==5){
		document.forms[0].logintab.value = "bestilling";
	}
	if(tabno==6){
		document.forms[0].logintab.value = "rettigheder";
	}
	document.forms[0].submit()
}

function firstFocusLogin(){
	if (document.forms[0].logintab.value == "login"){
		document.forms["logintab1"].username.focus();
	}
	//alert(document.forms[0].logintab.value);	
}

function resetLogin(){
	var f;
	
	f = document.forms[0];
	
	f.username.value = "";
	f.password.value = "";
	firstFocusLogin();
}

function firstFocus(){
	document.forms[0].name.focus();
}

function ResetTab1(prtype){
	var f;
	f = document.forms[0];

	f.name.value = "";
	f.truncatename.value = "0";
	f.chktruncname.checked = false;
	f.phone.value = "";
	f.street.value = "";
	f.truncatestreet.value = "0";
	f.chktruncstreet.checked = false;
	f.houseno.value = "";
	f.zipcode.value = "";
	f.district.value = "";
	f.cvrno.value = "";
	f.tdcid.value = "";
	
	if (prtype == 1) {
		f.categorycodes.value = "";
		f.catsearchwords.value = "";
	}

	f.trade.value = "";
	f.decisionmaker.value = "";
	f.email.value = "";
	f.homepage.value = "";
	f.showadswithphone.checked = false;
	f.chklegalentity.checked = false;
	f.chkadswithphone.value = "";
	f.IsLegalEntity.value = "";
	//f.shownitemsval.value = "";
}

function ResetTab3(){
	var f;
	f = document.forms[0];
	
	f.name.value = "";
	f.truncatename.value = "0";
	f.chktruncname.checked = false;
	f.phone.value = "";
	f.zipcode.value = "";
	f.district.value = "";
	f.category.value = "";
	f.trade.value = "";
	f.cvrno.value = "";
	f.tdcid.value = "";
	//f.intervalselect.selectedIndex = "2";
	f.IsLegalEntity.value = "";
	//f.shownitemsval.value = "";
}

function ResetTab4(){
	var f;
	
	f = document.forms[0];
	
	f.name.value = "";
	f.truncatename.value = "0";
	f.chktruncname.checked = false;
	f.phone.value = "";
	f.street.value = "";
	f.truncatestreet.value = "0";
	f.chktruncstreet.checked = false;
	f.houseno.value = "";
	f.zipcode.value = "";
	f.district.value = "";
	f.cvrno.value = "";
	f.tdcid.value = "";
	f.revisor.value = "";
	//f.intervalselect.selectedIndex = "2";
	//f.shownitemsval.value = "";
}

function ResetTab5(){
	var f;
	
	f = document.forms[0];
	
	f.name.value = "";
	f.truncatename.value = "0";
	f.chktruncname.checked = false;
	f.phone.value = "";
	f.street.value = "";
	f.truncatestreet.value = "0";
	f.chktruncstreet.checked = false;
	f.houseno.value = "";
	f.zipext.value = "";
	f.district.value = "";
	//f.intervalselect.selectedIndex = "2";
	//f.shownitemsval.value = "";
}


