var TXT_VISIBLE_BASE = 80;
var TXT_VISIBLE_START = 0;
var REC_BASE = 20;
var ANIM_TIME = 50;
var WND_NS_WIDTH = 794;
var WND_NS_HEIGHT = 429;

var set_count =  SET_VISIBLE_START + Math.floor(Math.random()*SET_VISIBLE_BASE);


var nItems = 40;

var dots = new Array();
var txts = new Array();
var item_data = new Array();
var act_id = "";



var Xpos = 0;
var Ypos = 0;
var DELTAT = .01;
var SEGLEN = 100;
var SPRINGK = 1;
var MASS = 30;
var GRAVITY = 0;
var RESISTANCE = 10;
var STOPVEL = 0.3;
var STOPACC = 0.1;
var BOUNCE = 0.75;

var Max_Xpos = WND_NS_WIDTH;
var Max_Ypos = WND_NS_HEIGHT;

var Max_height = WND_NS_HEIGHT;
var Max_width = WND_NS_WIDTH;



var SET_VISIBLE_BASE = 100;
var SET_VISIBLE_START = 10;



var act_item;

var item_useable = false;

var TIME_VISIBLE=20;
var TIME_INVISIBLE=120;

var path_start ="./"

var target_str="_self";


// Set Netscape up to run the "captureMousePosition" function whenever
// the mouse is moved. For Internet Explorer and Netscape 6, you can capture
// the movement a little easier.
if (document.layers) { // Netscape
    document.captureEvents(Event.MOUSEMOVE);
    document.onmousemove = captureMousePosition;
} else if (document.all) { // Internet Explorer
    document.onmousemove = captureMousePosition;
} else if (document.getElementById) { // Netcsape 6
    document.onmousemove = captureMousePosition;
}
// Global variables
xMousePos = 0; // Horizontal position of the mouse on the screen
yMousePos = 0; // Vertical position of the mouse on the screen
xMousePosMax = 0; // Width of the page
yMousePosMax = 0; // Height of the page

function captureMousePosition(e) {
    if (document.layers) {
        // When the page scrolls in Netscape, the event's mouse position
        // reflects the absolute position on the screen. innerHight/Width
        // is the position from the top/left of the screen that the user is
        // looking at. pageX/YOffset is the amount that the user has 
        // scrolled into the page. So the values will be in relation to
        // each other as the total offsets into the page, no matter if
        // the user has scrolled or not.
        xMousePos = e.pageX;
        yMousePos = e.pageY;
        xMousePosMax = window.innerWidth+window.pageXOffset;
        yMousePosMax = window.innerHeight+window.pageYOffset;
    } else if (document.all) {
        // When the page scrolls in IE, the event's mouse position 
        // reflects the position from the top/left of the screen the 
        // user is looking at. scrollLeft/Top is the amount the user
        // has scrolled into the page. clientWidth/Height is the height/
        // width of the current page the user is looking at. So, to be
        // consistent with Netscape (above), add the scroll offsets to
        // both so we end up with an absolute value on the page, no 
        // matter if the user has scrolled or not.
        xMousePos = window.event.x+document.body.scrollLeft;
        yMousePos = window.event.y+document.body.scrollTop;
        xMousePosMax = document.body.clientWidth+document.body.scrollLeft;
        yMousePosMax = document.body.clientHeight+document.body.scrollTop;
    } else if (document.getElementById) {
        // Netscape 6 behaves the same as Netscape 4 in this regard 
        xMousePos = e.pageX;
        yMousePos = e.pageY;
        xMousePosMax = window.innerWidth+window.pageXOffset;
        yMousePosMax = window.innerHeight+window.pageYOffset;
    }
}



// BrowserCheck Object
function BrowserCheck() {
	var b = navigator.appName
	if (b=="Netscape") this.b = "ns"
	else if (b=="Microsoft Internet Explorer") this.b = "ie"
	else this.b = b
	this.version = navigator.appVersion
	this.v = parseInt(this.version)
	this.ns = (this.b=="ns" && this.v>=4)
	this.ns4 = (this.b=="ns" && this.v==4)
	this.ns5 = (this.b=="ns" && this.v>=5)
	this.ie = (this.b=="ie" && this.v>=4)
	this.ie4 = (this.version.indexOf('MSIE 4')>0)
	this.ie5 = (this.version.indexOf('MSIE 5')>0)
	this.min = (this.ns||this.ie)
}
is = new BrowserCheck()




function init_dots(path_start_set,str_targ)
{
  var layer_style_obj = null;
  path_start = path_start_set;
  target_str=str_targ;
  if (is.ns) 
  { 
    if (is.ns4) 
    {
      if(parseFloat(navigator.appVersion)>=4.7)
      {
        layer_style_obj = eval("document.test0");
      }
    }
    else
    {
      var elm = document.getElementById("test0");
      layer_style_obj = elm.style;
    }
  }
  else
  {
    layer_style_obj = eval("test0.style");
  }

  if(layer_style_obj != null)
  {
    item_useable = true;
  }

  if(item_useable==true)
  {
    var i = 0;

    nItems = 40;

    dots[0] = new dot(0,40,40);
    dots[1] = new dot(1,40,40);
    dots[2] = new dot(2,40,40);
    dots[3] = new dot(3,66,67);
    dots[4] = new dot(4,47,47);
    dots[5] = new dot(5,47,47);
    dots[6] = new dot(6,47,47);
    dots[7] = new dot(7,47,47);
    dots[8] = new dot(8,47,47);
    dots[9] = new dot(9,47,47);
    dots[10] = new dot(10,43,47);
    dots[11] = new dot(11,43,47);
    dots[12] = new dot(12,47,47);
    dots[13] = new dot(13,47,47);
    dots[14] = new dot(14,40,47);
    dots[15] = new dot(15,43,47);
    dots[16] = new dot(16,43,47);
    dots[17] = new dot(17,43,47);
    dots[18] = new dot(18,44,42);
    dots[19] = new dot(19,42,42);
    dots[20] = new dot(20,43,40);
    dots[21] = new dot(21,43,40);
    dots[22] = new dot(22,43,40);
    dots[23] = new dot(23,43,40);
    dots[24] = new dot(24,43,40);
    dots[25] = new dot(25,43,40);
    dots[26] = new dot(26,43,40);
    dots[27] = new dot(27,43,40);
    dots[28] = new dot(28,43,40);
    dots[29] = new dot(29,43,40);
    dots[30] = new dot(30,43,40);
    dots[31] = new dot(31,43,40);
    dots[32] = new dot(32,43,40);
    dots[33] = new dot(33,43,40);
    dots[34] = new dot(34,43,40);
    dots[35] = new dot(35,43,40);
    dots[36] = new dot(36,40,38);
    dots[37] = new dot(37,43,40);
    dots[38] = new dot(38,43,40);
    dots[39] = new dot(39,43,40);

    txts[0] = new txt(0,117,40);
    txts[1] = new txt(1,117,40);
    txts[2] = new txt(2,117,40);
    txts[3] = new txt(3,88,32);
    txts[4] = new txt(4,135,47);
    txts[5] = new txt(5,193,47);
    txts[6] = new txt(6,84,47);
    txts[7] = new txt(7,130,47);
    txts[8] = new txt(8,150,47);
    txts[9] = new txt(9,303,47);
    txts[10] = new txt(10,215,47);
    txts[11] = new txt(11,77,47);
    txts[12] = new txt(12,296,47);
    txts[13] = new txt(13,296,47);
    txts[14] = new txt(14,260,47);
    txts[15] = new txt(15,267,47);
    txts[16] = new txt(16,137,47);
    txts[17] = new txt(17,140,47);
    txts[18] = new txt(18,250,42);
    txts[19] = new txt(19,250,42);
    txts[20] = new txt(20,150,40);
    txts[21] = new txt(21,204,40);
    txts[22] = new txt(22,175,40);
    txts[23] = new txt(23,70,40);
    txts[24] = new txt(24,105,40);
    txts[25] = new txt(25,60,40);
    txts[26] = new txt(26,100,40);
    txts[27] = new txt(27,180,40);
    txts[28] = new txt(28,160,40);
    txts[29] = new txt(29,40,40);
    txts[30] = new txt(30,225,40);
    txts[31] = new txt(31,95,40);
    txts[32] = new txt(32,115,40);
    txts[33] = new txt(33,175,40);
    txts[34] = new txt(34,160,40);
    txts[35] = new txt(35,95,40);
    txts[36] = new txt(36,178,38);
    txts[37] = new txt(37,110,40);
    txts[38] = new txt(38,140,40);
    txts[39] = new txt(39,110,40);

    //                  ID,           item_width, item_height, margin_left, margin_top, pict_width, pict_height, pict_rightmargin, pict_bottom_margin, nb_of_pict
    item_data[0]=new item("zip1",     453,        246,         12,          34,         300,        200,         2,                0,                  5 );
    item_data[1]=new item("zip2",     453,        246,         12,          34,         300,        200,         2,                0,                  5 );
    item_data[2]=new item("zip3",     453,        246,         12,          34,         300,        200,         2,                0,                  2 );
    item_data[3]=new item("artsmart", 512,        246,         12,          34,         300,        200,         37,               0,                  37);
    item_data[4]=new item("nai",      453,        246,         12,          34,         300,        200,         2,                0,                  4 );
    item_data[5]=new item("chinese",  476,        246,         12,          34,         300,        200,         2,                0,                  9 );
    item_data[6]=new item("tube",     476,        246,         12,          34,         300,        200,         2,                0,                  4 );
    item_data[7]=new item("usa",      476,        246,         12,          34,         300,        200,         2,                0,                  8 );
    item_data[8]=new item("8956",     512,        246,         12,          34,         300,        200,         37,               0,                  4 );
    item_data[9]=new item("2000",     512,        246,         12,          34,         300,        200,         37,               0,                  5 );
    item_data[10]=new item("jeud",    512,        246,         12,          34,         300,        200,         37,               0,                  6 );
    item_data[11]=new item("julia",   512,        246,         12,          34,         300,        200,         37,               0,                  4 );
    item_data[12]=new item("archno",  512,        246,         12,          34,         300,        200,         37,               0,                  18);
    item_data[13]=new item("archpa",  512,        246,         12,          34,         300,        200,         37,               0,                  9 );
    item_data[14]=new item("archst",  512,        246,         12,          34,         300,        200,         37,               0,                  8 );
    item_data[15]=new item("arg",     512,        246,         12,          34,         300,        200,         37,               0,                  3 );
    item_data[16]=new item("asia",    512,        246,         12,          34,         300,        200,         37,               0,                  4 );
    item_data[17]=new item("blue",    512,        246,         12,          34,         300,        200,         37,               0,                  3 );
    item_data[18]=new item("body1",   512,        246,         12,          34,         300,        200,         37,               0,                  3 );
    item_data[19]=new item("body2",   512,        246,         12,          34,         300,        200,         37,               0,                  1 );
    item_data[20]=new item("burg",    512,        246,         12,          34,         300,        200,         37,               0,                  2 );
    item_data[21]=new item("const",   428,        248,         12,          34,         250,        200,         2,                0,                  11 );
    item_data[22]=new item("east",    428,        248,         12,          34,         250,        200,         2,                0,                  15 );
    item_data[23]=new item("exp",     428,        248,         12,          34,         250,        200,         2,                0,                  3 );
    item_data[24]=new item("free",    512,        246,         12,          34,         300,        200,         37,               0,                  4 );
    item_data[25]=new item("ham",     428,        248,         12,          34,         250,        200,         2,                0,                  29 );
    item_data[26]=new item("huly",    512,        246,         12,          34,         300,        200,         37,               0,                  6 );
    item_data[27]=new item("ifa",     512,        246,         12,          34,         300,        200,         37,               0,                  10 );
    item_data[28]=new item("jedep",   512,        246,         12,          34,         300,        200,         37,               0,                  2 );
    item_data[29]=new item("kuba",    512,        246,         12,          34,         300,        200,         37,               0,                  1 );
    item_data[30]=new item("kzk",     512,        246,         12,          34,         300,        200,         37,               0,                  8 );
    item_data[31]=new item("mira",    512,        246,         12,          34,         300,        200,         37,               0,                  10 );
    item_data[32]=new item("nane",    512,        246,         12,          34,         300,        200,         37,               0,                  11 );
    item_data[33]=new item("noki",    428,        248,         12,          34,         250,        200,         2,                0,                  4 );
    item_data[34]=new item("orie",    512,        246,         12,          34,         300,        200,         37,               0,                  2 );
    item_data[35]=new item("posta",   512,        246,         12,          34,         300,        200,         37,               0,                  15 );
    item_data[36]=new item("psyc",    512,        246,         12,          34,         300,        200,         37,               0,                  4 );
    item_data[37]=new item("sads",    512,        246,         12,          34,         300,        200,         37,               0,                  2 );
    item_data[38]=new item("tow",     428,        248,         12,          34,         250,        200,         2,                0,                  9 );
    item_data[39]=new item("work",    512,        246,         12,          34,         300,        200,         37,               0,                  14 );
	

    if (is.ns)
    {
      Max_Xpos = document.body.scrollWidth;
      Max_Ypos = document.body.scrollHeight;
    }
    else
    {
      Max_Xpos = document.body.scrollWidth;
      Max_Ypos = document.body.scrollHeight;
    }

    if (is.ns) 
    {
       Max_height = WND_NS_HEIGHT;
       Max_width = WND_NS_WIDTH;
    }
    else
    { 
      Max_height = document.body.clientHeight + document.body.scrollTop;
      Max_width = document.body.clientWidth + document.body.scrollLeft;
    }

//    alert("x;y="+Max_Xpos+"; "+Max_Ypos+" h;w="+Max_height+"; "+Max_width);


    write_dots();

    for (i = 0; i < nItems; i++) 
    {
      if (is.ns) 
      { 
        if (is.ns4) 
        {
          dots[i].obj = eval("document.dot" + i);
        }
        else
        {
          var elm = document.getElementById("dot" + i);
          dots[i].obj = elm.style;
        }
      }
      else
      {
        dots[i].obj = eval("dot" + i + ".style");
      }
    }

    for (i = 0; i < nItems; i++) 
    {
      if (is.ns) 
      { 
        if (is.ns4) 
        {
          txts[i].obj = eval("document.txt" + i);
        }
        else
        {
          var elm = document.getElementById("txt" + i);
          txts[i].obj = elm.style;
        }
      }
      else
      {
        txts[i].obj = eval("txt" + i + ".style");
      }
    }


    for (i = 0; i < nItems; i++) 
    {
      dots[i].obj.left = Math.floor(dots[i].X);
      dots[i].obj.top = Math.floor(dots[i].Y);
    }

    if (is.ns) 
    {
      startanimate_item();
    }
    else 
    {
      setTimeout("startanimate_item()", 2);
    }
  }
}

function init_items()
{
    write_items();
    for (i = 0; i < nItems; i++) 
    {
      if (is.ns) 
      { 
        if (is.ns4) 
        {
          item_data[i].obj = eval("document.item_page" + i);
        }
        else
        {
          var elm = document.getElementById("item_page" + i);
          item_data[i].obj = elm.style;
        }
      }
      else
      {
        run_str = "item_page"+i+".style";
        item_data[i].obj = eval(run_str);
      }
    }

}

function close_item_page() 
{
  if(item_useable==true)
  {
      if(0<=act_item)
      {
          item_data[act_item].obj.visibility = "hidden";
          act_item = -1;
      }
  }
}


function start_item_page(idx) 
{
  if(item_useable==true)
  {
      var height, width, xPos,yPos;
      xPos = Math.floor(dots[idx].X); 
      yPos = Math.floor(dots[idx].Y); 
      close_item_page();

      if(yPos<yMousePos)
      {
         yPos = yMousePos;
      }

      act_item = idx;
      display_item_pict(item_data[idx].dir_id,0);

      if (is.ns) 
      {
         height = WND_NS_HEIGHT;
         width = WND_NS_WIDTH;
      }
      else
      { 
        height = document.body.clientHeight + document.body.scrollTop;
        width = document.body.clientWidth + document.body.scrollLeft;
      }


      if(width<xPos+item_data[idx].nitemsizew)
      {
        xPos=width-item_data[idx].nitemsizew;
      }
      if(height<yPos+item_data[idx].nitemsizeh)
      {
        yPos=height-item_data[idx].nitemsizeh;
      }


      item_data[act_item].obj.left = xPos; 
      item_data[act_item].obj.top = yPos; 

      if (is.ns) 
      {
        item_data[act_item].obj.visibility = "inherit";
      }
      else
      {
        item_data[act_item].obj.visibility = "visible";
      }
  }
}


// Ez fohja megjeleníteni a képet

function display_item_pict(id,idx)
{
  if(item_useable==true)
  {
     if(0<=act_item)
     {
       act_id = id.toString();
       var url_str = path_start+"sub_"+act_item.toString()+"_"+id.toString();
       url_str+="/";
       url_str+=id.toString()+"_"+idx.toString();
       url_str+=".jpg";

//       alert(url_str);
       var norm=new Image();
       norm.src=url_str;
       document['popup_pict_'+act_item].src = norm.src;

       idx++;
       if(item_data[act_item].pictures_nb<=idx)
       {
          idx=0;
       }
       if(item_data[act_item].pictures_nb!=1)
       {
         var next_pict = "next_item_pict('";
         next_pict+=id.toString();
         next_pict+="',";
         next_pict+=idx.toString();
         next_pict+=")";
//       alert(next_pict);
         window.setTimeout(next_pict, 3000);
       }
     }
  }
}

function next_item_pict(id,idx)
{
  if(item_useable==true)
  {
//     alert("next_item");
     if(0<=act_item && act_id==id)
     {
       var url_str = path_start+"sub_"+act_item.toString()+"_"+id.toString();
       url_str+="/";
       url_str+=id.toString()+"_"+idx.toString();
       url_str+=".jpg";

       var norm=new Image();
       norm.src=url_str;
       document['popup_pict_'+act_item].src = norm.src;
//       alert(url_str);
       idx++;
       if(item_data[act_item].pictures_nb<=idx)
       {
          idx=0;
       }
       var next_pict = "next_item_pict('";
       next_pict+=id.toString();
       next_pict+="',";
       next_pict+=idx.toString();
       next_pict+=")";
//       alert(next_pict);
       window.setTimeout(next_pict, 3000);
     }
  }
}


function dot(i,dot_width,dot_height) 
{
  if(item_useable==true)
  {
    Xpos = Math.floor(Math.random()*(Max_Xpos-dot_width));
    Ypos = Math.floor(Math.random()*(Max_Ypos-dot_height));

    this.X = Xpos;
    this.Y = Ypos;
    this.dx = 0;
    this.dy = 0;
    this.ndotsizew = dot_width;
    this.ndotsizeh = dot_height;
    this.obj=null;
  }
}

function txt(i,txt_width,txt_height) 
{
  if(item_useable==true)
  {
    this.X = Xpos;
    this.Y = Ypos;
    this.dx = 0;
    this.dy = 0;
    this.ntxtsizew = txt_width;
    this.ntxtsizeh = txt_height;
    this.obj=null;
    this.txt_count = TXT_VISIBLE_START + Math.floor(Math.random()*TXT_VISIBLE_BASE);
    this.txt_invisible = true;
  }
}

function item(id,item_width,item_height,margin_left,margin_top, pict_width, pict_height, pict_rightmargin, pict_bottom_margin,nb_of_pict) 
{
  if(item_useable==true)
  {
    this.X = Xpos;
    this.Y = Ypos;
    this.dx = 0;
    this.dy = 0;
    this.dir_id = id;
    this.nitemsizew = item_width;
    this.nitemsizeh = item_height;
    this.leftmargin = margin_left;
    this.topmargin = margin_top;
    this.pictw = pict_width;
    this.picth = pict_height;
    this.rightpictmarg = pict_rightmargin;
    this.bottompictmarg = pict_bottom_margin;
    this.pictures_nb = nb_of_pict;
    this.obj=null;
  }
}


function startanimate_item() 
{ 
  if(item_useable==true)
  {
    setInterval("animate_item()", ANIM_TIME);
  }
}



function vec(X, Y)
{
  if(item_useable==true)
  {
    this.X = Math.floor(X);
    this.Y = Math.floor(Y);
  }
}

function springForce(i, j, spring)
{
  if(item_useable==true)
  {
    var dx = (dots[i].X - dots[j].X);
    var dy = (dots[i].Y - dots[j].Y);
    var len = Math.sqrt(dx*dx + dy*dy);
    if (len > SEGLEN) 
    {
      var springF = SPRINGK * (len - SEGLEN);
      spring.X += (dx / len) * springF;
      spring.Y += (dy / len) * springF;
    }
  }
}

function animate_item() 
{ 
  var start = 0;

  if(item_useable==true)
  {
    set_count--;
    if(set_count<=0)
    {
      set_count =  SET_VISIBLE_START + Math.floor(Math.random()*SET_VISIBLE_BASE);
      Xpos = Math.floor(Math.random()*(Max_Xpos-dots[0].ndotsizew));
      Ypos = Math.floor(Math.random()*(Max_Ypos-dots[0].ndotsizeh));
    }
    dots[0].X = Math.floor(Xpos);
    dots[0].Y = Math.floor(Ypos); 
 
    for (i = 0 ; i < nItems; i++ ) 
    {
      var spring = new vec(0, 0);
      if (i > 0) 
      {
        springForce(i-1, i, spring);
      }
      if (i < (nItems - 1)) 
      {
        springForce(i+1, i, spring);
      }
      var resist = new vec(-dots[i].dx * RESISTANCE, -dots[i].dy * RESISTANCE);
      var accel = new vec((spring.X + resist.X)/ MASS, (spring.Y + resist.Y)/ MASS + GRAVITY);
      dots[i].dx += (DELTAT * accel.X);
      dots[i].dy += (DELTAT * accel.Y);
      if (Math.abs(dots[i].dx) < STOPVEL && Math.abs(dots[i].dy) < STOPVEL && Math.abs(accel.X) < STOPACC && Math.abs(accel.Y) < STOPACC)
      {
        dots[i].dx = 0;
        dots[i].dy = 0;
      }
      dots[i].X += Math.floor(dots[i].dx);
      dots[i].Y += Math.floor(dots[i].dy);

      dots[i].X += (Math.floor(Math.random()*REC_BASE)-Math.floor(REC_BASE/2));
      dots[i].Y += (Math.floor(Math.random()*REC_BASE)-Math.floor(REC_BASE/2));
    
      if (dots[i].Y >= Max_Ypos - dots[i].ndotsizeh - 1) // Max_height
      {
        if (dots[i].dy > 0) 
        {
          dots[i].dy = BOUNCE * -dots[i].dy;
        }
        dots[i].Y = Max_Ypos - dots[i].ndotsizeh - 1;	// Max_height
      }
      if (dots[i].X >= Max_width - dots[i].ndotsizew) 
      {
        if (dots[i].dx > 0) 
        {
           dots[i].dx = BOUNCE * -dots[i].dx;
        }
        dots[i].X = Math.floor(Max_width - dots[i].ndotsizew - 1);
      }

      if (dots[i].X < 0) 
      {
        if (dots[i].dx < 0) 
        {
          dots[i].dx = BOUNCE * -dots[i].dx;
        }
        dots[i].X = 0;
      }
      if (dots[i].Y < 0) 
      {
        if (dots[i].dy < 0) 
        {
          dots[i].dy = BOUNCE * -dots[i].dy;
        }
        dots[i].Y = 0;
      }
      if(Math.floor(dots[i].X)<1 || Math.floor(dots[i].Y)<1)
      {
        dots[i].X = Math.floor(Math.random()*(Max_Xpos-dots[i].ndotsizew));
        dots[i].Y = Math.floor(Math.random()*(Max_Ypos-dots[i].ndotsizeh));
      }

      if((txts[i].txt_invisible == true &&
         Max_width < Math.floor(dots[i].X)+dots[i].ndotsizew+txts[i].ntxtsizew) || txts[i].txt_count==1)
      {
        dots[i].X = Math.floor(Math.random()*(Max_width-(dots[i].ndotsizew+txts[i].ntxtsizew)));
        dots[i].obj.left = dots[i].X;
      }
      else
      {
        dots[i].obj.left = Math.floor(dots[i].X);
      }
      dots[i].obj.top = Math.floor(dots[i].Y); 

      if(txts[i].txt_invisible == true)
      {
          txts[i].obj.left = Math.floor(dots[i].X)+dots[i].ndotsizew;
          txts[i].obj.top = Math.floor(dots[i].Y); 
      }
//      txts[i].obj.left = Math.floor(dots[i].X)+dots[i].ndotsizew;
//      txts[i].obj.top = Math.floor(dots[i].Y); 
    } 

    for (i = 0 ; i < nItems; i++ ) 
    {
      txts[i].txt_count--;

      if(txts[i].txt_count<=0)
      {
        if(txts[i].txt_invisible)
        {
          txts[i].txt_invisible = false;
          txts[i].obj.visibility = "hidden";
          txts[i].txt_count = TIME_INVISIBLE;
          txts[i].obj.left = 0;
          txts[i].obj.top = 0; 
        }
        else
        {
          txts[i].obj.left = Math.floor(dots[i].X)+dots[i].ndotsizew;
          txts[i].obj.top = Math.floor(dots[i].Y); 

          txts[i].txt_invisible = true;
          if (is.ns) 
          {
            txts[i].obj.visibility = "inherit";
          }
          else
          {
            txts[i].obj.visibility = "visible";
          }
          txts[i].txt_count = TIME_VISIBLE;
        }
      }
    }

  }
}


function write_dots()
{

  for (i = 0; i < nItems; i++) 
  {
    var url = path_start+"sub_"+i+"_"+item_data[i].dir_id+"/";

    var out_txt = "";

    out_txt += '<DIV id="dot'+i+'"><a href="javascript:start_item_page('+i+');" target="_self"><img\n';
    out_txt += '       src="'+url+item_data[i].dir_id+'_dot.gif" width="'+dots[i].ndotsizew+'" height="'+dots[i].ndotsizeh+'" border="0"></a></DIV>\n';
    out_txt += '<DIV id="txt'+i+'"><a href="javascript:start_item_page('+i+');" target="_self"><img\n';
    out_txt += '        src="'+url+item_data[i].dir_id+'_txt.gif" width="'+txts[i].ntxtsizew+'" height="'+txts[i].ntxtsizeh+'" border="0" name="ptxt'+i+'"></a></DIV>\n';
    out_txt += '\n';

    document.write(out_txt);

  }
  return;
}

function write_items()
{

  for (i = 0; i < nItems; i++) 
  {
    var url = path_start+"sub_"+i+"_"+item_data[i].dir_id+"/";

    var out_txt = "";

    out_txt += '<DIV id="item_page'+i+'">\n';
    out_txt += '<MAP NAME="map'+i+'">\n';
    out_txt += '<AREA HREF="projects.html" target="'+target_str+'" SHAPE=RECT COORDS="'+((item_data[i].pictw+item_data[i].rightpictmarg)-235)+',5,'+((item_data[i].pictw+item_data[i].rightpictmarg)-70)+',30">\n';
    out_txt += '<AREA HREF="context_frame.html" target="'+target_str+'" SHAPE=RECT COORDS="'+((item_data[i].pictw+item_data[i].rightpictmarg)-70)+',5,'+((item_data[i].pictw+item_data[i].rightpictmarg)-5)+',30">\n';
    out_txt += '</MAP>\n';
    out_txt += '<table width='+item_data[i].nitemsizew+' height='+item_data[i].nitemsizeh+'  border="0" cellspacing="0" cellpadding="0">\n';
    out_txt += '  <TR>\n';
    out_txt += '    <TD width='+item_data[i].nitemsizew+' hight='+item_data[i].nitemsizeh+' background="'+url+item_data[i].dir_id+'_back.gif">\n';
    out_txt += '      <table width='+item_data[i].nitemsizew+' hight='+item_data[i].nitemsizeh+'  border="0" cellspacing="0" cellpadding="0">\n';
    out_txt += '        <TR>\n';
    out_txt += '          <TD align="left" valign="top" width="'+item_data[i].leftmargin+'" rowspan="3"><img\n';
    out_txt += '              src="'+path_start+'design/blank.gif" width="'+item_data[i].leftmargin+'" height="1" border="0"></TD>\n';
    out_txt += '          <TD align="left" valign="top" width="'+(item_data[i].pictw+item_data[i].rightpictmarg)+'"><img\n';
    out_txt += '              src="'+path_start+'design/blank.gif" width="'+(item_data[i].pictw+item_data[i].rightpictmarg)+'" height="'+item_data[i].topmargin+'" border="0" usemap="#map'+i+'"></TD>\n';
    out_txt += '          <TD align="left" valign="top" width="'+(item_data[i].nitemsizew-(item_data[i].pictw+item_data[i].rightpictmarg+item_data[i].leftmargin))+'"><img\n';
    out_txt += '              src="'+path_start+'design/blank.gif" width="'+(item_data[i].nitemsizew-(item_data[i].pictw+item_data[i].rightpictmarg+item_data[i].leftmargin))+'" height="1" border="0"></TD>\n';
    out_txt += '        </TR>\n';
    out_txt += '        <TR>\n';
    out_txt += '          <TD align="right" valign="top"><img\n';
    out_txt += '              src="'+path_start+'design/blank.gif" border="0" name="popup_pict_'+i+'"></TD>\n';
    out_txt += '          <TD align="left" valign="top"><A\n';
    out_txt += '              HREF="javascript:close_item_page();"><img\n';
    out_txt += '              src="'+path_start+'design/blank.gif" width="'+(item_data[i].nitemsizew-(item_data[i].pictw+item_data[i].rightpictmarg+item_data[i].leftmargin))+'" height="'+(item_data[i].picth+item_data[i].bottompictmarg)+'" border="0"></A></TD>\n';
    out_txt += '        </TR>\n';
    out_txt += '        <TR>\n';
    out_txt += '          <TD align="left" valign="top" colspan=2><img\n';
    out_txt += '              src="'+path_start+'design/blank.gif" width="1" height="'+(item_data[i].nitemsizeh-item_data[i].topmargin-(item_data[i].picth+item_data[i].bottompictmarg))+'" border="0"></TD>\n';
    out_txt += '        </TR>\n';
    out_txt += '      </table>\n';
    out_txt += '    </TD>\n';
    out_txt += '  </TR>\n';
    out_txt += '</table>\n';
    out_txt += '</DIV>\n';

//    alert(out_txt);
    document.write(out_txt);

  }

  return;
}

