var totTidsteg;
var statPlace = false;

  /*
   * Write an script tag into the document that will make the forecast table for the current place available.
   */
function writeStatImporter()
{
   var placeId = nodeArray[selectedNodeNum].placeId;
   //alert("src='"+ dataPath +"stat_" + String(placeId).substring(0, 4) + ".js'");
   if (showingHasRegions())
   {
      document.write("<script language=javascript src='"+ dataPath +"vstat_" + placeId + ".js'><\/script>");
      //document.write("<script language=javascript src='https://xout.smhi.se/natvader/gateway/getmodule.php?user_id="+ mainUserId +"&module_request=vstatdiagram&komId=" + placeId + "'><\/script>");
      //document.write("<script language=javascript src='https://xout.smhi.se/natvader/gateway/getmodule.php?user_id="+ mainUserId +"&module_request=statistik2&komId=" + placeId + "'><\/script>");
      document.write("<script language=javascript src='"+ dataPath +"stat_" + String(placeId).substring(0, 4) + ".js'><\/script>");
   }
}

  /*
   * Write an script tag into the document that will make the sun time table for the current place available.
   */
function writeSunTimeTableImporter()
{
 if (isLeafNode(selectedNodeNum))
 {
   var placeId = nodeArray[selectedNodeNum].placeId;
	if (String(placeId).substring(0, 4) == '1001' || String(placeId).substring(0, 4) == '1002' || String(placeId).substring(0, 4) == '1003')
   {
      //document.write("<script language=javascript src='https://xout.smhi.se/natvader/gateway/getmodule.php?user_id="+ mainUserId +"&module_request=soltid_sverige&komId=" + placeId + "'><\/script>");
      //alert(""+ dataPath +"suntime_" + placeId + ".js");
      document.write("<script language=javascript src='"+ dataPath +"suntime_" + placeId + ".js'><\/script>");
      //document.write("<script language=javascript src='https://xout.smhi.se/natvader/gateway/getmodule.php?user_id="+ mainUserId +"&module_request=soltid2&komId=" + placeId + "'><\/script>");
   }
 }
}


function printStatTable()
{
   document.write('<table border="0" cellpadding="0" cellspacing="0" width="100%">');
   //if ((String(placeId).length>10) && ((String(placeId).substring(0, 4) == "1001") || (String(placeId).substring(0, 4) == "1003")))
   if(showingHasRegions())
   {
      if((smhivstatimages['tempsmall'][0] !== undefined) && (smhivstatimages['temp'][0] !== undefined))
      {
        document.write("<tr><td><div class='stat' style='margin-top: 5px; margin-left: 10px;'>");
        document.write("<table><tr><td class='ntv_smaller'><a href=# class='stat' onMouseOver=\"this.style.textDecoration='underline';\" onMouseOut=\"this.style.textDecoration='none';\" onclick=\"javascript:window.open('ntv_stat.html?url='+smhivstatimages['temp'][0], 'none', 'width=400,height=300');\">"+phraseArray[8]+"</a></td></tr><tr><td><a href=# onclick=\"javascript:window.open('ntv_stat.html?url='+smhivstatimages['temp'][0], 'none', 'width=400,height=300');\"><img src='"+smhivstatimages['tempsmall'][0]+"' width='105' height='85' border='0'></a></td></tr></table>");
        document.write("</div></td></tr>");
        /*
        document.write("<div class='ntv_smaller' style='margin-top: 10px;'><a href=# class='stat' onMouseOver=\"this.style.textDecoration='underline';\" onMouseOut=\"this.style.textDecoration='none';\" onclick=\"javascript:window.open('ntv_stat.html?url='+smhivstatimages['temp'][0], 'none', 'width=400,height=300');\">"+phraseArray[8]+"</a></div>");
        //document.write("<div class=\"stat\" style='margin-top: 10px; margin-left: 25px;'><a href=# onclick=\"javascript:window.open('ntv_stat.html?url='+smhivstatimages['temp'][0], 'none', 'width=400,height=300');\"><img src='symb/Tempar.png' style='border: 0px solid black;'></a></div>");
        document.write("<div class=\"stat\" style='margin-top: 5px; margin-left: 10px;'><a href=# onclick=\"javascript:window.open('ntv_stat.html?url='+smhivstatimages['temp'][0], 'none', 'width=400,height=300');\"><img src='"+smhivstatimages['tempsmall'][0]+"' width='105' height='85' border='0'></a></div>");
        */
      }
      if((smhivstatimages['nbd'][0] !== undefined)&& (smhivstatimages['nbdsmall'][0] !== undefined))
      {
        document.write("<tr><td><div class='stat' style='margin-top: 5px; margin-left: 10px;'>");
        document.write("<table><tr><td class='ntv_smaller'><a href=# class='stat' onMouseOver=\"this.style.textDecoration='underline';\" onMouseOut=\"this.style.textDecoration='none';\" onclick=\"javascript:window.open('ntv_stat.html?url='+smhivstatimages['nbd'][0], 'none', 'width=400,height=300');\">"+phraseArray[9]+"</a></td></tr><tr><td><a href=# onclick=\"javascript:window.open('ntv_stat.html?url='+smhivstatimages['nbd'][0], 'none', 'width=400,height=300');\"><img src='"+smhivstatimages['nbdsmall'][0]+"' width='105' height='85' border='0'></a></td></tr></table>");
        document.write("</div></td></tr>");
        /*
        document.write("<div class='ntv_smaller' style='margin-top: 10px;'><a href=# class='stat' onMouseOver=\"this.style.textDecoration='underline';\" onMouseOut=\"this.style.textDecoration='none';\" onclick=\"javascript:window.open('ntv_stat.html?url='+smhivstatimages['nbd'][0], 'none', 'width=400,height=300');\">"+phraseArray[9]+"</a></div>");
        //document.write("<div style='margin-top: 10px; margin-left: 25px;'><a href=# onclick=\"javascript:window.open('ntv_stat.html?url='+smhivstatimages['nbd'][0], 'none', 'width=400,height=300');\"><img src='symb/nederbord.png' style='border: 0px solid black;'></a></div>");
        document.write("<div style='margin-top: 5px; margin-left: 10px;'><a href=# onclick=\"javascript:window.open('ntv_stat.html?url='+smhivstatimages['nbd'][0], 'none', 'width=400,height=300');\"><img src='"+smhivstatimages['nbdsmall'][0]+"' width='105' height='85' border='0'></a></div>");
        */
      }
   }
   else 
   {
		document.write('<tr height=\"204\"><td bgcolor=\"#FFFFFF\"><img src=\"img/trans.gif\" height=\"204\" width=\"105\"></td></tr>');
   }
   document.write('</table><!-- /right content -->');
}


  /*
   * Write the imported sun time table into the document.
   */

function printSunTimesTable()
{
   document.write("<div style='margin-top: 8px;'>");
   document.write('<table border="0" cellpadding="0" cellspacing="0" width="100%">');
   if (soltidArray.length > 0)
   {
      document.write("<tr><td>");
      document.write("<table bgcolor=white cellspacing=0 cellpadding=0 width=100% border=0>");
      document.write("<tr>");
      document.write("  <td width='2%' rowspan='2'><img src='img/trans.gif' height='38' width='1'></td>");
      //document.write("  <td width='98%' align='middle' colspan=2><img src='symb/Solens-upp-och-nedgång.png'></td>");
      document.write("  <td width='98%' align='middle' colspan=2><img src='symb/Sol-upp-och-ned.png'></td>");
      //document.write("  <td width='49%' align='middle'><img src='symb/solned.gif'></td>");
      document.write('  <td class="ntv_legend_padding2_question" rowspan="2"><a href="javascript:void(0);" onclick="window.open(\'beskrivning_stat.html\', \'Nederbörd\', \'location=no, menubar=no, Height=280, width=200, status=no, resizable=no, scrollbar=no \')"><img src="'+ntvInfoPath+'" border=0></a></td>');
      document.write("</tr>");
      document.write("<tr>");
     	document.write("  <td align='middle' class='ntv_smaller'>"+soltidArray[0][2]+"</td>");
     	document.write("  <td align='middle' class='ntv_smaller'>"+soltidArray[0][3]+"</td>");      
      document.write("</tr>");
      document.write("</table>");
      document.write('</td></tr>');
   }
   else
   {
   	document.write("<tr height=\"100%\"><td valign=\"top\" bgcolor=\"#FFFFFF\">");
   	document.write("<table bgcolor=white cellspacing=0 cellpadding=0 width=100%>");
   	document.write("<tr><td><img src='img/trans.gif' width='100' height='36'></td></tr>");
   	document.write("</table>");
   	document.write('</td></tr>');
   }
   document.write('</table><!-- /right content -->');
   document.write("</div>");
}

function printStatSwe(divString)
{
   var test=typeof divString;
   if(test == 'undefined')
   {
      var divString = "<div id=\"ntv_stat\" style='border:1px solid black;'>";
   }
   //doPrintStat = doPrintStatTable();
	//doPrintStatNor = doPrintStatNorway();
   document.write(divString);
   document.write('<h1 class=\"ntv_h1\">'+phraseArray[7]+'</h1>');
   printStatTable();
   printSunTimesTable();
	document.write('</div>');
}
/*
function printStatNor(divString)
{
   var test=typeof divString;
   if(test == 'undefined')
   {
      var divString = "<div id=\"ntv_stat\" style='border:1px solid black;'>";
   }
   doPrintStat = doPrintStatTable();
	doPrintStatNor = doPrintStatNorway();
   document.write(divString);
   document.write('<h1 class=\"ntv_h1\">'+phraseArray[7]+'</h1>');
   printStatNorway();
   printSunTimesTable();
	document.write('</div>');
}
*/

