﻿function selectLayer(id)
{
    if(document.getElementById) elem = document.getElementById(id);      
    else if(document.all) elem = document.all[id];      
    else if(document.layers) elem = document.layers[id];      
    return elem;
}

function toggleLayer(id, visible)
{  
    var elem = selectLayer(id);  
    if(elem) elem.style.display = visible ? 'block' : 'none';          
}

function disableAnchor(id, disable) 
{ 
    var obj = selectLayer(id); 
    if(obj) 
    { 
        if(disable) 
        { 
            var href = obj.getAttribute('href'); 
            var onclick = obj.getAttribute('onclick'); 
            //First we store previous value in a new attribute 
            if(href && href != "") 
            { 
                obj.setAttribute('href.bak', href); 
            } 
            if(onclick) 
            { 
                obj.setAttribute('onclick.bak', onclick); 
                obj.setAttribute('onclick', "void(0);"); 
            } 
            obj.removeAttribute('href'); 
        } 
        else 
        { 
            var hrefBack = obj.getAttribute('href.bak'); 
            var onclickBack = obj.getAttribute('onclick.bak'); 
            if(onclickBack) 
            { 
                obj.setAttribute('onclick', onclickBack); 
                obj.removeAttribute('onclick.bak'); 
            } 
            if(hrefBack) 
            { 
                obj.setAttribute('href', hrefBack); 
                obj.removeAttribute('href.bak'); 
            } 
        } 
    }
}     
function getElementHeight(id)
{
    elem = selectLayer(id);
    return elem.height;
}

function resizeElementHeight(id, newHeight)
{
    elem = selectLayer(id);
    elem.height = newHeight;
}

/* var myUitlegWindow; */

function openPopup(inUrl,inTitle)
{
    var x = window.open(inUrl,inTitle,'width=800,height=700,resizable=1');
    x.focus;
/*
	if (myUitlegWindow)
	{
		myUitlegWindow.close()
	}
	maxWidth = (inWidth > 330 ? inWidth : 330 )
    if (window.screen) 
    {
        maxResX = parseInt(window.screen.availWidth);
        maxResY = parseInt(window.screen.availHeight);
        emptySpace = 50;
        myLeft = maxResX - maxWidth - emptySpace;
        myTop =  emptySpace;        
    }
    else
    {
		maxResY = 600;
    }
    maxHeight = (inHeight < maxResY ? inHeight : maxResY);
    maxWidth = (inWidth < 424 ? inWidth : 424 )
    myUitlegWindow = window.open( inUrl, 
								  inTitle, 
		                          "channelmode=no, directories=no, fullscreen=no," +
                                  "left=" + myLeft + "," + 
                                  "resizable=no, scrollbars=no," + 
                                  "top=" + myTop + "," +
                                  "menubar=no, status=no, titlebar=no, toolbar=no," + 
                                  "height=" + inHeight + ",width=" + maxWidth );                                
	myUitlegWindow.focus();	
*/	
}
