/**
 *  Standard JavaScript functions file
 *
 * @version 1.0 20080309
 * @author Geoffroy Hemery de Goascaradec <geoffroy@goascaradec.fr>
 * @copyright Geoffroy HdG
 * @package CComToo
 * @subpackage JavaScript
 */


/**
 *  JSFunction : Str2Tab (like Explode)
 */
function Str2Tab( ps_str )
{
    var lR_expr   = new RegExp("[ ,;|]+", "g");

    return ps_str.split(lR_expr);
}


/**
 *  JSFunction : Get input value
 */
function getInputValue( ps_id ) {
    return document.getElementById(ps_id).value;
}

/**
 *  JSFunction : Get DIV tag style
 */
function getDivStyle( ps_id ) {
    return document.getElementById(ps_id).style;
}

/**
 *  JSFunction : Get DIV tag display
 */
function getDivDisplay( ps_id ) {
    return getDivStyle(ps_id).display;
}


/**
 *  JSFunction : Set DIV tag style display
 */
function setStyleDisplay( ps_id , ps_value ) {
   getDivStyle(ps_id).display = ps_value;
}


/**
 *  JSFunction : Show DIV
 */
function DivShow( ps_ref ) {
       setStyleDisplay(ps_ref, "");
}

/**
 *  JSFunction : Hide DIV
 */
function DivHide( ps_ref ) {
       setStyleDisplay(ps_ref, "none");
}

/**
 *  JSFunction : Check DIV Hide flag
 */
function DivHideCheck( ps_ref )
{
    if ( getDivDisplay(ps_ref) != "" )
       return true;
    else
       return false;
}

/**
 *  JSFunction : Toggle DIV displaying
 */
function ToggleDiv( ps_ref )
{
    if ( DivHideCheck(ps_ref) )
       DivShow(ps_ref);
    else
       DivHide(ps_ref);
}

/**
 *  JSFunction : Switch DIV displaying
 */
function SwitchDiv( ps_ref_in, ps_ref_out )
{
    if ( DivHideCheck(ps_ref_out) )
    {
       DivShow(ps_ref_out);

        if ( !DivHideCheck(ps_ref_out) )
           DivHide(ps_ref_in);
    }
    else
       DivHide(ps_ref_in);
}

/**
 *  JSFunction : URL opening Confirmation
 */
function confirmer( ps_text, ps_url ) {
    if ( confirm(ps_text) )
       window.location = ps_url;
}

