/* $Id: module.js 573 2007-09-08 19:14:26Z zapotek $ */
/* __________________________________________________________________ */

var Obj = new Array();

/**
 * Shows/hides the quick help body
 */
function toggleQuickHelp( e ) {
    el = Event.getTarget(e);
    if( Dom.getStyle( 'quickHelp', 'display' ) == 'none' ) {
        el.innerHTML = '<?=$modStrings["close"]?>';
        Dom.setStyle( 'quickHelp', 'display', 'block' );
    } else {
        el.innerHTML = '<?=$modStrings["open"]?>';
        Dom.setStyle( 'quickHelp', 'display', 'none' );
    }
}

/**
 * Outputs a message/warning/error
 */
function showMessage( msg, container_id ) {
    if( !container_id )
      container_id = 'customMessage';
      
    container = $(container_id);
    if( !container ) return;
    
    var html = '<div class="'+ msg['class'] +'">'+ msg['text'] +'</div>';
    container.innerHTML = html;

     // turn opacity back on
    YAHOO.util.Dom.setStyle( container_id, 'display', 'block' );
    // turn opacity back on
    YAHOO.util.Dom.setStyle( container_id, 'opacity', 100 );
    // animate
    YAHOO.example.init( container_id );
}

function highlight( el ) {
    if( !el ) {
        // hightlight the globally saved line
        Dom.addClass( $(gbl.currentHighlight), 'selected' );
    } else {
        // remove the class from a previously highlited line
        Dom.removeClass( gbl.currentHighlight, 'selected' );
        
        if( typeof el != 'object' ) {
            // hightlight a line by ID
            Dom.addClass( $('mngTableLine_'+ el), 'selected' );
            // save its id
            gbl.currentHighlight = el;
        } else {
            // hightlight the line
            Dom.addClass( el, 'selected' );
            // save its id
            gbl.currentHighlight = el.id;
        }
    } // end if( !el ) ...
} // end highlight( )

function toggleElementDisplay( id ){

    if( $(id).style.display == 'none' || 
        $(id).style.display == '' )
    {
        $(id).style.display    = 'block';
   		createCookie( "hide_" + id, '0' );
        sign = '[-]';
    } else {
        $(id).style.display    = 'none';
   		createCookie( "hide_" + id, '1' );
        sign = '[+]';
    }
    
    if( $(id + '_sign') ){
            $(id + '_sign').innerHTML = sign;
    }
    
//    alert( document.cookie );
}

/** 
 * make an element disappear
 * 
 * @param   string  the div ID
 * @return  void
 *
 **/
function hideElement( id ){
    $(id).style.display    = 'none';
}

/** 
 * make an element re-appear
 * 
 * @param   string  the div ID
 * @return  void
 **/
function showElement( id ){
    $(id).style.display    = 'block';
}


/** 
 * get an element's position
 * 
 * @param   string  the div ID
 * @return  array   X,Y
 **/
getXY = function( pID ) {
    var curleft = curtop = 0;
    var obj = $( pID );
    
    if( obj.offsetParent ) {
        curleft = obj.offsetLeft;
        curtop = obj.offsetTop;
        while( obj = obj.offsetParent ) {
          curleft += obj.offsetLeft;
          curtop += obj.offsetTop;
        }
    }
    
    return [curleft,curtop];
} // end of getXY()