/* $Id: df-common.js 1575 2010-02-23 09:05:14Z jamesf $ */
/*
 * ** Copyright and license information                      **
 * **                                                        **
 * -- THIS TEXT MUST REMAIN VISIBLE AND IN TACT IN ALL CASES --
 *
 * DF Scroll - Javascript for custom scroll bars
 *
 * Copyright (c) 2010 Dalton Firth Limited, some rights reserved
 *
 * http://www.daltonfirth.co.uk/opensource software is licensed as open source for free reuse according to the
 * terms of the Gnu Affero General Public License (AGPL)
 *
 * For the full text of the license, see http://www.gnu.org/licenses/agpl.txt
 *
 * You are free to modify and redistribute this software within the terms 
 * described in the above specified license.  Send any modifications, updates
 * and derivatives of this software via email to:
 *
 *     opensource-notify@daltonfirth.co.uk
 *
 * Under the terms of the AGPL you are obliged to make available the source,
 * including this notice,e to all users of this software, even when the user
 * accesses services over a network.
 *
 * This software comes with ABSOLUTELY NO WARRANTY WHATSOEVER.
 *
 * ^^ THE ABOVE TEXT MUST REMAIN UNMODIFIED IN ALL CASES     ^^ 
 */


function df_attach_event(elem, event, func)
{
    if(elem.addEventListener)
    { // Mozilla, Netscape, Firefox
	elem.addEventListener(event, func, false);
    }
    else 
    { 
        // IE
	elem.attachEvent('on'+event, func);
    }
}

function df_attach_event_cap(elem, event, func)
{
    if(elem.addEventListener)
    { // Mozilla, Netscape, Firefox
	elem.addEventListener(event, func, true);
    }
    else 
    { 
        // IE
	elem.attachEvent('on'+event, func);
    }
}


function df_add_load_event(func) 
{
    var oldonload = window.onload;
  
    if (typeof window.onload != 'function') 
    {
        window.onload = func;
    }
    else 
    {
        window.onload = function() 
            {
                if (oldonload) 
                {
                    oldonload();
                }
                func();
            }
    }
}

function df_get_current_style(elem, property)
{
    if (window.getComputedStyle)
    {
        return window.getComputedStyle(elem, null).getPropertyValue(property);
    }
    else
    {
        return elem.currentStyle[property];
    }    
}

function df_clear_once(event)
{
    var targ_elem; 

    if (!event)
    {
        event = window.event;
    }

    if (event.target)
    {
        targ_elem = event.target;
    }
    else
    {
        targ_elem = event.srcElement;
    }
    
    if (!targ_elem.dfClickedOnce)
    {    
        targ_elem.value = '';
        targ_elem.dfClickedOnce = true;
    }
    
}




