function FaneBladAction(FaneBladAreal,FType,linkAreal,faneLink) {

  var Klass = "detailTxt1";
  var Streg = "http://" + document.domain + "/images/blank_black.jpg";

  AntalFaner = FaneBladAreal.length;
  
  var FaneBladName = new Array(AntalFaner);

  j=0
  for (i = 0; i < FaneBladAreal.length; i=i+1){
    FaneBladName[j] = FaneBladAreal[i];
    j++;
    document.writeln("<div id='faneLink" + j +  "' value='"+ FaneBladAreal[i] +"'></div>");
  }

  var lineBilled  = tjekStyleFane(FType,"lBil"); 

  
  document.writeln("<div id='antalF' value='"+ AntalFaner +"'></div>");
  document.writeln("<div id='FType' value='"+ FType +"'></div>");
  document.writeln("<div id='faneLink' value='"+ faneLink +"'></div>");
  document.writeln("<table border='0' cellspacing='0' cellpadding='0' width='100%' id='BG5'>");
  document.writeln(" <tr>");
  document.writeln("  <td>");
  document.writeln("<table border='0' cellspacing='0' cellpadding='0' width='*'>");
  document.writeln(" <tr>");
  document.writeln("  <td valign='bottom'><img src='" + lineBilled + "' id='startLine' width='6' height='1'></td>");

  for (i = 1; i <= AntalFaner; i++){
    document.writeln("<td width='*' align='left'>");
    document.writeln(" <table id='Fane" + i + "' value='" + linkAreal[i-1] + "' width='*' border='0' cellspacing='0' cellpadding='0'>");
    document.writeln("  <tr> ");
    document.writeln(" 	 <td colspan='2' width='3' rowspan='2'><img name='VB" + i + "' width='3' height='15'></td>");
    document.writeln(" 	 <td colspan='3' id='FaneMidt" + i + "'></td>");
    document.writeln("	 <td colspan='2' width='3' rowspan='2'><img name='HB" + i + "' width='3' height='15'></td>");
    document.writeln("	 <td width='3' rowspan='2'></td>");
    document.writeln("	</tr>");
    document.writeln("	<tr> ");
    document.writeln("	 <td width='7' id='BG1" + i + "'></td> ");
    document.writeln("	 <td width='*' id='BG2" + i + "' align='center' class='" + Klass + "'><a href=Javascript:showLayerAction(" + i + ",'submit');>" + FaneBladName[i-1] + "</a></td>");
    document.writeln("	 <td width='7' id='BG3" + i + "'></td> ");
    document.writeln("	</tr>");
    document.writeln("	<tr> ");
    document.writeln("   <td width='1'   id=BB21" + i + "></td>");
    document.writeln("   <td colspan='5' id=BB1" + i + "></td>");
    document.writeln("   <td width='1'   id=BB22" + i + "></td>");
    document.writeln("   <td width='3'   id=BB3"  + i + "></td>");
    document.writeln("	</tr>");
    document.writeln(" </table>");
    document.writeln("</td>");
  }
  document.writeln(" <td id='Streg' valign='bottom'></td>");
  document.writeln(" </tr>");
  document.writeln("</table>");
  document.writeln(" <td></td>");
  document.writeln(" </tr>");
  document.writeln("</table>");

}

function AfslutFaneAction(){

  var FaneBlad;
  var Bredde1F;
  var BreddeFaner = 0;
  var FaneAllBredde = document.getElementById("BG5").offsetWidth;
  var startLine     = document.getElementById("startLine").offsetWidth;

  var AntalFaner    = document.getElementById("antalF").value;
  var FType         = document.getElementById("FType").value;
  var lineBilled    = tjekStyleFane(FType,"lBil"); 
  for (i = 1; i <= AntalFaner; i++){
    FaneBlad    = document.getElementById("Fane" + i);
    Bredde1F    = FaneBlad.offsetWidth;
    BreddeFaner = BreddeFaner + Bredde1F;
  }
  BreddeSidst = FaneAllBredde - BreddeFaner - startLine - 1;
  document.getElementById("Streg").innerHTML = "<img src='" + lineBilled + "' width='" + BreddeSidst + "' height='1'>";
}

function showLayerAction(valgteFane,derKaldes,valgteFaneID) {

	var FType      = document.getElementById("FType").value;
  var AntalFaner = document.getElementById("antalF").value;
  var faneLink   = document.getElementById("faneLink").value;
  
  venstre        = tjekStyleFane(FType,"VB");
  hojre          = tjekStyleFane(FType,"HB");
  midtBG	       = tjekStyleFane(FType,"mBG");
  lineBG	       = tjekStyleFane(FType,"lBG"); 

  venstreValgt   = tjekStyleFane(FType,"VBV");
  hojreValgt     = tjekStyleFane(FType,"HBV");
  midtBGValgt	   = tjekStyleFane(FType,"mBGV");  
  lineBGValgt	   = tjekStyleFane(FType,"lBGV");  
  lineColor	     = tjekStyleFane(FType,"lColor");  

  var FaneID = new Array(AntalFaner);

	//alert(valgteFaneID);
	//alert(valgteFane);

  for(i=1;i<=AntalFaner;i++) { 
    FaneID[i] = document.getElementById("Fane" + i).value;
		//alert(FaneID[i]);
		//alert(i);
    if (i==valgteFane || FaneID[i]==valgteFaneID) {
      document["VB"+i].src        = venstreValgt;
      document["HB"+i].src        = hojreValgt;
      document.all["BB1"+i].style.backgroundColor = lineBGValgt;
      document.all["BB21"+i].style.backgroundColor = lineColor;
      document.all["BB22"+i].style.backgroundColor = lineColor;
      document.all["BB3"+i].style.backgroundColor  = lineColor;
      document.all["BG1"+i].style.backgroundColor = midtBGValgt;
      document.all["BG2"+i].style.backgroundColor = midtBGValgt;
      document.all["BG3"+i].style.backgroundColor = midtBGValgt;
      document.all["FaneMidt"+i].style.backgroundColor = lineColor;
      valgteFaneID = FaneID[i];
      valgteFane   = i
    } 
    else {
      document["VB"+i].src        = venstre;
      document["HB"+i].src        = hojre;
      document.all["BB1"+i].style.backgroundColor = lineBG;
      document.all["BB21"+i].style.backgroundColor = lineColor;
      document.all["BB22"+i].style.backgroundColor = lineColor;
      document.all["BB3"+i].style.backgroundColor  = lineColor;
      document.all["BG1"+i].style.backgroundColor = midtBG;
      document.all["BG2"+i].style.backgroundColor = midtBG;
      document.all["BG3"+i].style.backgroundColor = midtBG;
      document.all["FaneMidt"+i].style.backgroundColor = lineColor;
    }
  }

  if (derKaldes == 'submit'){
    var x=document.all.form;
    
    if (faneLink.indexOf("?") == -1) {
      x.action=faneLink + "?fb=" + valgteFane + "&fane_id=" + valgteFaneID;
    }
    else {
      x.action=faneLink + "&fb=" + valgteFane + "&fane_id=" + valgteFaneID;
    }
    document.form.submit();
  }  
}


