/**
 * Manejo de ventanas
 */

/*=============================================================================*/
function popup( )
/*=============================================================================*/
{
    var windowTargetName = '_blank';
    var arguments  = "";
        arguments += "width       = 800, ";
        arguments += "height      = 600, ";
        arguments += "top         = 100, ";
        arguments += "left        = 100, ";
        arguments += "scrollbars  = YES, ";
        arguments += "resizable   = YES, ";
        arguments += "directories =  NO, ";
        arguments += "location    =  NO, ";
        arguments += "menubar     =  NO, ";
        arguments += "status      =  NO, ";
        arguments += "titlebar    =  NO, ";
        arguments += "toolbar     =  NO";

    var popupWindow = window.open( this.href, windowTargetName, arguments );
    popupWindow.focus( );

    return false;
}

/*=============================================================================*/
function popdown( )
/*=============================================================================*/
{
    window.close( );
}

/*=============================================================================*/
function startBlank( )
/*=============================================================================*/
{
    var windowTargetName = '_blank';

    var blankPage = window.open( this.href, windowTargetName );
    blankPage.focus( );

    return false;
}

/*=============================================================================*/
function handleExternalLinks( )
/*=============================================================================*/
{
    var anchorCollection = document.getElementsByTagName( 'a' );
    var distinguishClass = 'external_link';

    for ( var i = 0; i < anchorCollection.length; i++ )
    {
        if ( anchorCollection[ i ].className == distinguishClass )
        {
            anchorCollection[ i ].onclick = startBlank;
        }
    }
}

// Attach error handler to page on load
if ( window.addEventListener )
{
    window.addEventListener( "load", handleExternalLinks, false );
}
else
{
    if ( window.attachEvent )
    {
        window.attachEvent( "onload", handleExternalLinks );
    }
}
