﻿var ns4=document.layers?1:0;
var ie4=document.all;
var ns6=document.getElementById&&!document.all?1:0;

var themenu = null;
var toptboundary=112;
var currentLayer = null;

function pull(id)
{
    themenu = document.getElementById(id);
    themenu.style.position = "relative";
    
    if(currentLayer != null)
    {
        if (currentLayer.id != themenu.id)
        {
            currentLayer.style.height = "12px";
            currentLayer.style.marginTop = "0px";
        }
    }

    if (themenu != null)
    {
        if (window.drawit) clearInterval(drawit);
    
        pullit = setInterval("pullengine()",10);
    }
    currentLayer = themenu;
}

function draw(id)
{
    themenu = document.getElementById(id);
    themenu.style.position = "static";
    
    if (themenu != null)
    {
        clearInterval(pullit)
        drawit=setInterval("drawengine()",10)
    }
}

function pullengine(){
    var height = parseInt(themenu.style.height);
    var marginTop = parseInt(themenu.style.marginTop);

    if ((ie4||ns6)&& height < toptboundary)
    {
        themenu.style.height = height + 10 + "px";
        themenu.style.marginTop = marginTop -10 + "px";
    }
    else if(ns4&&themenu.left < toptboundary)
    {
        themenu.style.height += 10 + "px";
        themenu.style.marginTop = marginTop -10 + "px";
    }
    else if (window.pullit)
    {
    
        themenu.style.height = toptboundary;
        themenu.style.marginTop = marginTop;
        clearInterval(pullit);
    }
}

function drawengine()
{
    var height = parseInt(themenu.style.height);
    var marginTop = parseInt(themenu.style.marginTop);
    
    if ( (ie4||ns6) && height > toptboundary)
    {
        themenu.style.height = height - 10 + "px";
        themenu.style.marginTop = marginTop + 10 + "px";
    }   
    else if(ns4 && height > toptboundary)
    {
        themenu.style.height -= 10 + "px";
        themenu.style.marginTop = marginTop + 10 + "px";
    }
    else if (window.drawit)
    {
        themenu.style.height = "12px";
        //themenu.style.height = height -10 + "px";
        themenu.style.marginTop = 0 +  "px";
        clearInterval(drawit)
    }    
}

function init()
{
    themenu = document.getElementById("menu2");
}