var TimeOut         = 200;
var currentLayer    = null;
var currentitem     = null;
var currentLayerNum = 0;
var noClose         = 0;
var closeTimer      = null;

// Open Hidden Layer
function opentime(n)
{

 screenW = screen.width;
 screenH = screen.height;
 movepos = 0;

     if (screenW < 1024)
        movepos = -150;
     if (screenW == 1024)
          movepos = -60;
    if (screenW == 1152)
          movepos = 0;
    if (screenW > 1152)
          movepos = 70;

 if (screenW > 1500)
          movepos = 200;

 if (screenW > 1800)
          movepos = 350;



    var l  = document.getElementById("menu"+n);
    var mm = document.getElementById("mmenu"+n);
	
    if(l)
    {

       if (n == 1)
       {
       l.style.top  = 145 + 'px';
       l.style.left = movepos + 175 + 'px';
       }

      if (n == 2)
      {
       l.style.top  = 145 + 'px';
       l.style.left = movepos + 320 + 'px';
      }

      if (n == 3)
      {
       l.style.top  = 145 + 'px';
       l.style.left = movepos + 810 + 'px';
      }

      if (n == 4)
      {
       l.style.top  = 145 + 'px';
       l.style.left = movepos + 640 + 'px';
      }

      if (n == 5)
      {
       l.style.top  = 145 + 'px';
       l.style.left = movepos + 480 + 'px';
      }


      if (n == 6)
      {
       l.style.top  = 165 + 'px';
       l.style.left = movepos + 320 + 'px';
      }



        closingtime();
        l.style.visibility='visible';

        if(currentLayer && (currentLayerNum != n))
            currentLayer.style.visibility='hidden';

        currentLayer = l;
        currentitem = mm;
        currentLayerNum = n;			
    }
    else if(currentLayer)
    {
        currentLayer.style.visibility='hidden';
        currentLayerNum = 0;
        currentitem = null;
        currentLayer = null;
	}



}

// Turn On Close Timer
function dispclosingtime()
{
    closeTimer = window.setTimeout(mclose, TimeOut);
}

// Cancel Close Timer
function closingtime()
{
    if(closeTimer)
    {
        window.clearTimeout(closeTimer);
        closeTimer = null;
    }
}

// Close Showed Layer
function mclose()
{
    if(currentLayer && noClose!=1)
    {
        currentLayer.style.visibility='hidden';
        currentLayerNum = 0;
        currentLayer = null;
        currentitem = null;
    }
    else
    {
        noClose = 0;
    }

    currentLayer = null;
    currentitem = null;
}

// Close Layer Then Click-out
document.onclick = mclose; 