// ==============================================================================
// NMMenu
// ==============================================================================

function NMMenu () 
{

    this.menuItem = [];

};


NMMenu.prototype.init = function (sCurrentMenuId) 
{

    this.pointerElem = document.getElementById ('pointer');
    
    this.currentMenuItem = this.getMenuItem (sCurrentMenuId);
    
    if (this.currentMenuItem)
    {
        this.pointerElem.style.top = this.currentMenuItem.getVerticalPosition () + 'px';
        this.pointerElem.style.display = 'block';
    }
    else
    {
        
        this.pointerElem.style.display = 'none';
        
    };

};


NMMenu.prototype.addMenuItem = function (sId)
{
    
    this.menuItem.push (new NMMenuItem (sId));
    
};


NMMenu.prototype.getMenuItem = function (sId)
{
    
    for (var i = 0; i < this.menuItem.length; i++)
    {
        
        if (sId === this.menuItem[i].id)
            return this.menuItem[i];
        
    };
    
};

// ---------------------------------------
// NMMenuItem
// ---------------------------------------

function NMMenuItem (sId)
{

    this.id = sId;

};


NMMenuItem.prototype.getVerticalPosition = function ()
{
    
    this.elem = document.getElementById ('menuItem' + this.id);
    
    return this.findPosY (this.elem) + 3;
    
};


NMMenuItem.prototype.findPosY = function (obj)
{

	var curtop = 0;
	if(obj.offsetParent)
		while(1)
		{
		  curtop += obj.offsetTop;
		  if(!obj.offsetParent)
			break;
		  obj = obj.offsetParent;
		}
	else if(obj.y)
		curtop += obj.y;
	return curtop;
	
};


// ==============================================================================
// Overig
// ==============================================================================

function writeEmail (sDomain, sAlias, sDisplayText) {
    
    if (!sDomain)
        sDomain = 'studiobraaf.nl';

    if (!sDisplayText)
        sDisplayText = sAlias + '\u0040' + sDomain;
	
	document.write ('<a href="mailto:' + sAlias + '\u0040' + sDomain + '">' + sDisplayText + '</a>');
	
};