/*
Script: dbug.js
Wrapper for the firebug console.log() function.

Dependancies:
     no dependencies
    
Author:
    Aaron Newton, <aaron [dot] newton [at] cnet [dot] com>

Class: dbug
        dbug is a wrapper for the firebug console plugin for
        firefox. The syntax for logging is the same as documented
        at http://getfirebug.com, though only the .log() command
        is supported.
        
        You can leave dbug.log() statements in your code and 
        they will not be echoed out to the screen in any way. 

        To display the dbug statements, you have two options:
        include *"jsdebug=true"* in the query string of the page
        and all your dbug statements will be printed as they
        occur OR *type into the firebug console dbug.enable()*
        and the debug statements that have occurred up until
        that point will be echoed, and all others from that
        point will be printed as they occur. You can also
        *put dbug.enable() in your javascript* to turn it on.
        
        dbug.disable() will turn it back off.

Arguments:
    args - collection of things to log to the console.
    
Examples:
    (start code)
    dbug.log("message");
    > message
    dbug.log("my var is %s", myVar)
    > my var is x
    dbug.log($('myelement'));
    > <div id="myelement"></div>
    dbug.log("myelement: %s, some value: %s", $('myelement'), somevalue);
    > myelement: <div id="myelement"></div>, some value: blah
    (end)
    
    more at <http://getfirebug.com>
    */
dbug = {
/*  Property: logged

        Array with any messages logged that have not been sent to the console; 
        happens when dbug is not enabled. when you enable it again,
        these messages will be dumped to the console.
    */
    logged: [], 
    timers: {},
    loadtimers: {},
    loadtimerlogged: [],
    
/*  property: debug
        boolean; whether or not the debugger is enabled.
    */  
    firebug: false, 
    debug: false, 

/*  property: log

        sends a message to the console if dbug is enabled, otherwise
        it stores this info until dbug is enabled.
        
        Parameters:
            message - the message to log, includes various substition options, see <http://www.getFirebug.com>

        Syntax: 
        > dbug.log("message");
        > > message
        > dbug.log("my var is %s", myVar)
        > > my var is x

        for more examples, see <http://www.getFirebug.com>
    */
    log: function() {
        this.logged.push(arguments);
    },
    nolog: function(msg) {
        this.logged.push(arguments);
    },
/*  Property: time
        Starts a console timer with the given name if dbug is enabled.
        See <http://www.getFirebug.com> for details.
    */
    time: function(name){
        this.timers[name] = new Date().getTime();
    },
    loadtime: function(name){
        this.loadtimers[name] = new Date().getTime();
    },
/*  Property: timeEnd
        Ends a console timer with the given name if dbug is enabled.
        See <http://www.getFirebug.com> for details.
    */
    timeEnd: function(name){
        if (this.timers[name] > 0) {
            var end = new Date().getTime() - this.timers[name];
            this.log('%s: %s', name, end);
            this.timers[name] = false;
        } else this.log('no such timer: %s', name);
    },
    loadtimeEnd: function(name){
        if (this.loadtimers[name] > 0) {
            var end = new Date().getTime() - this.loadtimers[name];
            this.loadtimerlogged.push(['%s: %s', name, end]);
            this.loadtimers[name] = false;
        } else this.log('no such load timer: %s', name);
    },
/*  Property: enable

        turns on the dbug functionality so that messages will show up
        in the firebug console. any messages sent to dbug.log() 
        previously will be displayed in the console immediately and
        all future logging statements will echo to the console.

        See also: 
        <dbug.log>, <dbug.disable>
        
        Example:
        >dbug.enable()
        > > enabling dbug
        
    */  
    enable: function() { 
        if(this.firebug) {
            this.debug = true;
            this.log = console.debug;
            this.time = console.time;
            this.timeEnd = console.timeEnd;
            this.log('enabling dbug');
            for(i=0;i<this.logged.length;i++){ this.log.apply(console, this.logged[i]); }
            this.logged=[];
        }
    },
    
    showLoadTimers: function(){
        if(!this.debug) this.enable();
        for(i=0;i<this.loadtimerlogged.length;i++){ this.log.apply(console, this.loadtimerlogged[i]); }
    },
    
/*  Property: disable

        turns the dbug functionality off. all future logging calls
        will be stored in the logged array until dbug is enabled again.
        
        See also: 
        <dbug.log>, <dbug.enable>, <dbug.logged>
        
        Example:
        >dbug.disable()
    */
    disable: function(){ 
        if(this.firebug) this.debug = false;
        this.log = this.nolog;
        this.time = function(){};
        this.timeEnd = function(){};
    }
};
if (typeof console != "undefined") { // safari, firebug
    if (typeof console.debug != "undefined") { // firebug
        dbug.firebug = true; 
        if(window.location.href.indexOf("jsdebug=true")>0) dbug.enable();
    }
}
/* do not edit below this line */   
/* Section: Change Log 

$Source: /cvs/webapps/www-rb-api/resources/js/cnet.framework.dasher.js,v $
$Log: not supported by cvs2svn $
Revision 1.2  2007/01/30 02:24:22  grahamb
commented out console.log calls since they were failing in IE7

Revision 1.1  2006/12/20 01:48:03  grahamb
initial check-in

Revision 1.6  2006/12/06 20:14:59  newtona
carousel - improved performance, changed some syntax, actually deployed into usage and tested
cnet.nav.accordion - improved css selectors for time
multiple accordion - fixed a typo
dbug.js - added load timers
element.cnet.js - changed syntax to utilize mootools more effectively
function.cnet.js - equated $set to $pick in preparation for mootools v1

Revision 1.5  2006/12/06 17:52:50  newtona
making this file have no dependencies

Revision 1.4  2006/11/22 00:21:01  newtona
docs update

Revision 1.3  2006/11/21 23:56:08  newtona
added dbug.time and debug.timeEnd

Revision 1.2  2006/11/02 21:26:42  newtona
checking in commerce release version of global framework.

notable changes here:
cnet.functions.js is the only file really modified, the rest are just getting cvs footers (again).

cnet.functions adds numerous new classes:

$type.isNumber
$type.isSet
$set

*/


dbug.loadtime('redball global framework'); 
/*
Script: Moo.js
    My Object Oriented javascript.
    
Dependancies:
     Has no dependancies.
    
Author:
    Valerio Proietti, <http://mad4milk.net>

License:
    MIT-style license.

Credits:
    - Class is slightly based on Base.js  <http://dean.edwards.name/weblog/2006/03/base/> (c) 2006 Dean Edwards, License <http://creativecommons.org/licenses/LGPL/2.1/>
    - Some functions are based on those found in prototype.js <http://prototype.conio.net/> (c) 2005 Sam Stephenson sam [at] conio [dot] net, MIT-style license
    - Documentation by Aaron Newton (aaron.newton [at] cnet [dot] com) and Valerio Proietti.
*/

/*
Class: Class
    The base class object of the <http://mootools.net> framework.
    
Arguments:
    properties - the collection of properties that apply to the class. Creates a new class, its initialize method will fire upon class instantiation.
    
Example:
    >var Cat = new Class({
    >   initialize: function(name){
    >       this.name = name;
    >   }
    >});
    >var myCat = new Cat('Micia');
    >alert myCat.name; //alerts 'Micia'
*/

var Class = function(properties){
    var klass = function(){
        for (var p in this){
            if (this[p]) this[p]._proto_ = this;
        }
        if (arguments[0] != 'noinit' && this.initialize) return this.initialize.apply(this, arguments);
    };
    klass.extend = this.extend;
    klass.implement = this.implement;
    klass.prototype = properties;
    return klass;
};

/*
Property: empty
    Returns an empty function
*/

Class.empty = function(){};

/*
Property: create
    same as new Class. see <Class>
*/

Class.create = function(properties){
    return new Class(properties);
};

Class.prototype = {

    /*
    Property: extend
        Returns the copy of the Class extended with the passed in properties.
        
    Arguments:
        properties - the properties to add to the base class in this new Class.
        
    Example:
        >var Animal = new Class({
        >   initialize: function(age){
        >       this.age = age;
        >   }
        >});
        >var Cat = Animal.extend({
        >   initialize: function(name, age){
        >       this.parent(age); //will call the previous initialize;
        >       this.name = name;
        >   }
        >});
        >var myCat = new Cat('Micia', 20);
        >alert myCat.name; //alerts 'Micia'
        >alert myCat.age; //alerts 20
    */

    extend: function(properties){
        var pr0t0typ3 = new this('noinit');
        for (var property in properties){
            var previous = pr0t0typ3[property];
            var current = properties[property];
            if (previous && previous != current) current = previous.parentize(current) || current;
            pr0t0typ3[property] = current;
        }
        return new Class(pr0t0typ3);
    },
    
    /*  
    Property: implement
        Implements the passed in properties to the base Class prototypes, altering the base class, unlike <Class.extend>.

    Arguments:
        properties - the properties to add to the base class.
        
    Example:
        >var Animal = new Class({
        >   initialize: function(age){
        >       this.age = age;
        >   }
        >});
        >Animal.implement({
        >   setName: function(name){
        >       this.name = name
        >   }
        >});
        >var myAnimal = new Animal(20);
        >myAnimal.setName('Micia');
        >alert(myAnimal.name); //alerts 'Micia'
    */
    
    implement: function(properties){
        for (var property in properties) this.prototype[property] = properties[property];
    }

};

/* Section: Object related Functions  */

/*
Function: Object.extend
    Copies all the properties from the second passed object to the first passed Object.
    If you do myWhatever.extend = Object.extend the first parameter will become myWhatever, and your extend function will only need one parameter.
        
Example:
    >var firstOb = {
    >   'name': 'John',
    >   'lastName': 'Doe'
    >};
    >var secondOb = {
    >   'age': '20',
    >   'sex': 'male',
    >   'lastName': 'Dorian'
    >};
    >Object.extend(firstOb, secondOb);
    >//firstOb will become: 
    >{
    >   'name': 'John',
    >   'lastName': 'Dorian',
    >   'age': '20',
    >   'sex': 'male'
    >};
    
Returns:
    The first object, extended.
*/

Object.extend = function(){
    var args = arguments;
    if (args[1]) args = [args[0], args[1]];
    else args = [this, args[0]];
    for (var property in args[1]) args[0][property] = args[1][property];
    return args[0];
};

/*
Function: Object.Native
    Will add a .extend method to the objects passed as a parameter, equivalent to <Class.implement>

Arguments:
    a number of classes/native javascript objects

*/

Object.Native = function(){
    for (var i = 0; i < arguments.length; i++) arguments[i].extend = Class.prototype.implement;
};

new Object.Native(Function, Array, String, Number);

Function.extend({

    parentize: function(current){
        var previous = this;
        return function(){
            this.parent = previous;
            return current.apply(this, arguments);
        };
    }

});/*
Script: Array.js
    Contains Array prototypes and the function <$A>;

Dependencies:
    <Moo.js>
    
Author:
    Valerio Proietti, <http://mad4milk.net>

License:
    MIT-style license.
*/

/*
Class: Array
    A collection of The Array Object prototype methods.
*/

if (!Array.prototype.forEach){
    
    /*  
    Mehod: forEach
        Iterates through an array; note: <Array.each> is the preferred syntax for this funciton.
        
    Arguments:
        fn - the function to execute with each item in the array
        bind - optional, the object that the "this" of the function will refer to.
        
    Example:
        >var Animals = ['Cat', 'Dog', 'Coala'];
        >Animals.forEach(function(animal){
        >   document.write(animal)
        >});

    See also:
        <Function.bind>
        <Array.each>
    */
    
    Array.prototype.forEach = function(fn, bind){
        for(var i = 0; i < this.length ; i++) fn.call(bind, this[i], i);
    };
}

Array.extend({
    
    /*
    Property: each
        Same as <Array.each>.
    */
    
    each: Array.prototype.forEach,
    
    /*  
    Property: copy
        Copy the array and returns it.
    
    Returns:
        an Array
            
    Example:
        >var letters = ["a","b","c"];
        >var copy = ["a","b","c"].copy();
    */
    
    copy: function(){
        var newArray = [];
        for (var i = 0; i < this.length; i++) newArray.push(this[i]);
        return newArray;
    },
    
    /*  
    Property: remove
        Removes an item from the array.
        
    Arguments:
        item - the item to remove
        
    Returns:
        the Array without the item removed.
        
    Example:
        >["1","2","3"].remove("2") // ["1","3"];
    */
    
    remove: function(item){
        for (var i = 0; i < this.length; i++){
            if (this[i] == item) this.splice(i, 1);
        }
        return this;
    },
    
    /*  
    Property: test
        Tests an array for the presence of an item.
        
    Arguments:
        item - the item to search for in the array.
        
    Returns:
        true - the item was found
        false - it wasn't
        
    Example:
        >["a","b","c"].test("a"); // true
        >["a","b","c"].test("d"); // false
    */
    
    test: function(item){
        for (var i = 0; i < this.length; i++){
            if (this[i] == item) return true;
        };
        return false;
    },
    
    /*  
    Property: extend
        Extends an array with another
        
    Arguments:
        newArray - the array to extend ours with
        
    Example:
        >var Animals = ['Cat', 'Dog', 'Coala'];
        >Animals.extend(['Lizard']);
        >//Animals is now: ['Cat', 'Dog', 'Coala', 'Lizard'];
    */
    
    extend: function(newArray){

        for (var i = 0; i < newArray.length; i++) {
            this.push(newArray[i]);
        }
        return this;
    },
    
    /*  
    Property: associate
        Creates an associative array based on the array of keywords passed in.
        
    Arguments:
        keys - the array of keywords.
        
    Example:
        (sart code)
        var Animals = ['Cat', 'Dog', 'Coala', 'Lizard'];
        var Speech = ['Miao', 'Bau', 'Fruuu', 'Mute'];
        var Speeches = Animals.associate(speech);
        //Speeches['Miao'] is now Cat.
        //Speeches['Bau'] is now Dog.
        //...
        (end)
    */
    
    associate: function(keys){
        var newArray = [];
        for (var i =0; i < this.length; i++) newArray[keys[i]] = this[i];
        return newArray;
    }

});

/* Section: Utility Functions  */

/*
Function: $A()
    Same as <Array.copy>, but as function. 
    Useful to apply Array prototypes to iterable objects, as a collection of DOM elements or the arguments object.
    
Example:
    >function myFunction(){
    >   $A(arguments).each(argument, function(){
    >       alert(argument);
    >   });
    >};
    >//the above will alert all the arguments passed to the function myFunction.
*/

function $A(array){
    return Array.prototype.copy.call(array);
};/* 
Script: Function.js
    Contains Function prototypes, utility functions and Chain.

Dependencies: 
    <Moo.js>

Author:
    Valerio Proietti, <http://mad4milk.net>

License:
    MIT-style license.

Credits:
    - Some functions are inspired by those found in prototype.js <http://prototype.conio.net/> (c) 2005 Sam Stephenson sam [at] conio [dot] net, MIT-style license
*/

/*
Class: Function
    A collection of The Function Object prototype methods.
*/

Function.extend({
    
    /*
    Property: pass
        Shortcut to create closures with arguments and bind.
    
    Returns:
        a function.
    
    Arguments:
        args - the arguments to pass to that function (array or single variable)
        bind - optional, the object that the "this" of the function will refer to.
    
    Example:
        >myFunction.pass([arg1, arg2], myElement);
    */
    
    pass: function(args, bind){
        var fn = this;
        if ($type(args) != 'array') args = [args];
        return function(){
            return fn.apply(bind || fn._proto_ || fn, args);
        };
    },
    
    /*
    Property: bind
        method to easily create closures with "this" altered.
    
    Arguments:
        bind - optional, the object that the "this" of the function will refer to.
    
    Returns:
        a function.
    
    Example:
        >function myFunction(){
        >   this.setStyle('color', 'red');
        >   // note that 'this' here refers to myFunction, not an element
        >   // we'll need to bind this function to the element we want to alter
        >};
        >var myBoundFunction = myFunction.bind(myElement);
        >myBoundFunction(); // this will make the element myElement red.
    */
    
    bind: function(bind){
        var fn = this;
        return function(){
            return fn.apply(bind, arguments);
        };
    },
    
    /*
    Property: bindAsEventListener
        cross browser method to pass event firer
    
    Arguments:
        bind - optional, the object that the "this" of the function will refer to.
    
    Returns:
        a function with the parameter bind as its "this" and as a pre-passed argument event or window.event, depending on the browser.
    
    Example:
        >function myFunction(event){
        >   alert(event.clientx) //returns the coordinates of the mouse..
        >};
        >myElement.onclick = myFunction.bindAsEventListener(myElement);
    */
        
    bindAsEventListener: function(bind){
        var fn = this;
        return function(event){
            fn.call(bind, event || window.event);
            return false;
        };
    },
    
    /*
    Property: delay
        Delays the execution of a function by a specified duration.
    
    Arguments:
        ms - the duration to wait in milliseconds
        bind - optional, the object that the "this" of the function will refer to.
    
    Example:
        >myFunction.delay(50, myElement) //wait 50 milliseconds, then call myFunction and bind myElement to it
        >(function(){alert('one second later...')}).delay(1000); //wait a second and alert
    */
    
    delay: function(ms, bind){
        return setTimeout(this.bind(bind || this._proto_ || this), ms);
    },
    
    /*
    Property: periodical
        Executes a function in the specified intervals of time
        
    Arguments:
        ms - the duration of the intervals between executions.
        bind - optional, the object that the "this" of the function will refer to.
    */
    
    periodical: function(ms, bind){
        return setInterval(this.bind(bind || this._proto_ || this), ms);
    }

});

/* Section: Utility Functions  */

/*
Function: $clear
    clears a timeout or an Interval.

Returns:
    null

Arguments:
    timer - the setInterval or setTimeout to clear.

Example:
    >var myTimer = myFunction.delay(5000); //wait 5 seconds and execute my function.
    >myTimer = $clear(myTimer); //nevermind

See also:
    <Function.delay>, <Function.periodical>
*/

function $clear(timer){
    clearTimeout(timer);
    clearInterval(timer);
    return null;
};

/*
Function: $type
    Returns the type of object that matches the element passed in.

Arguments:
    obj - the object to inspect.

Example:
    >var myString = 'hello';
    >$type(myString); //returns "string"

Returns:
    'function' - if obj is a function
    'textnode' - if obj is a node but not an element
    'element' - if obj is a DOM element
    'array' - if obj is an array
    'object' - if obj is an object
    'string' - if obj is a string
    'number' - if obj is a number
    false - (boolean) if the object is not defined or none of the above, or if it's an empty string.
*/
    
function $type(obj){
    if (!obj) return false;
    var type = false;
    if (obj instanceof Function) type = 'function';
    else if (obj.nodeName){
        if (obj.nodeType == 3 && !/\S/.test(obj.nodeValue)) type = 'textnode';
        else if (obj.nodeType == 1) type = 'element';
    }
    else if (obj instanceof Array) type = 'array';
    else if (typeof obj == 'object') type = 'object';
    else if (typeof obj == 'string') type = 'string';
    else if (typeof obj == 'number' && isFinite(obj)) type = 'number';
    return type;
};

/*Class: Chain*/

var Chain = new Class({
    
    /*
    Property: chain
        adds a function to the Chain instance stack.
        
    Arguments:
        fn - the function to append.
    
    Returns:
        the instance of the <Chain> class.
    
    Example:
        >var myChain = new Chain();
        >myChain.chain(myFunction).chain(myFunction2);
    */
    
    chain: function(fn){
        this.chains = this.chains || [];
        this.chains.push(fn);
        return this;
    },
    
    /*
    Property: callChain
        Executes the first function of the Chain instance stack, then removes it. The first function will then become the second.

    Example:
        >myChain.callChain(); //executes myFunction
        >myChain.callChain(); //executes myFunction2
    */
    
    callChain: function(){
        if (this.chains && this.chains.length) this.chains.splice(0, 1)[0].delay(10, this);
    },

    /*
    Property: clearChain
        Clears the stack of a Chain instance.
    */
    
    clearChain: function(){
        this.chains = [];
    }

});/*
Script: String.js
    Contains String prototypes and Number prototypes.

Dependencies:
    <Moo.js>
    
Author:
    Valerio Proietti, <http://mad4milk.net>

License:
    MIT-style license.
*/

/*
Class: String
    A collection of The String Object prototype methods.
*/

String.extend({
    
    /*  
    Property: test
        Tests a string with a regular expression.
        
    Arguments:
        regex - the regular expression you want to match the string with
        params - optional, any parameters you want to pass to the regex
        
    Returns:
        an array with the instances of the value searched for or empty array.
        
    Example:
        >"I like cookies".test("cookie"); // returns ["I like cookies", "cookie"]
        >"I like cookies".test("COOKIE", "i") //ignore case
        >"I like cookies because cookies are good".test("COOKIE", "ig"); //ignore case, find all instances.
        >"I like cookies".test("cake"); //returns empty array
    */
    
    test: function(regex, params){
        return this.match(new RegExp(regex, params));
    },
    
    /*  
    Property: toInt
        parses a string to an integer.
        
        Returns:
            either an int or "NaN" if the string is not a number.
        
        Example:
            >var value = "10px".toInt(); // value is 10
    */
    toInt: function(){
        return parseInt(this);
    },
    
    /*  
    Property: camelCase
        Converts a hiphenated string to a camelcase string.
        
    Example:
        >"I-like-cookies".camelCase(); //"ILikeCookies"
        
    Returns:
        the camel cased string
    */
    
    camelCase: function(){
        return this.replace(/-\D/gi, function(match){
            return match.charAt(match.length - 1).toUpperCase();
        });
    },
    
    /*  
    Property: capitalize
        Converts the first letter in each word of a string to Uppercase.
        
    Example:
        >"i like cookies".capitalize(); //"I Like Cookies"
        
    Returns:
        the capitalized string
    */
    capitalize: function(){
        return this.toLowerCase().replace(/\b[a-z]/g, function(match){
            return match.toUpperCase();
        });
    },
    
    /*  
    Property: trim
        Trims the leading and trailing spaces off a string.
        
    Example:
        >"    i like cookies     ".trim() //"i like cookies"
        
    Returns:
        the trimmed string
    */
    
    trim: function(){
        return this.replace(/^\s*|\s*$/g, '');
    },
    
    /*  
    Property: clean
        trims (<String.trim>) a string AND removes all the double spaces in a string.
        
    Returns:
        the cleaned string
        
    Example:
        >" i      like     cookies      \n\n".clean() //"i like cookies"
    */

    clean: function(){
        return this.replace(/\s\s/g, ' ').trim();
    },

    /*  
    Property: rgbToHex
        Converts an RGB value to hexidecimal. The string must be in the format of "rgb(255, 255, 255)" or "rgba(255, 255, 255, 1)";
        
    Arguments:
        array - boolean value, defaults to false. Use true if you want the array ['FF', '33', '00'] as output instead of #FF3300
        
    Returns:
        hex string or array. returns transparent if the fourth value of rgba in input string is 0,
        
    Example:
        >"rgb(17,34,51)".rgbToHex(); //"#112233"
        >"rgba(17,34,51,0)".rgbToHex(); //"transparent"
        >"rgb(17,34,51)".rgbToHex(true); //[11,22,33]
    */
    
    rgbToHex: function(array){
        var rgb = this.test('([\\d]{1,3})', 'g');
        if (rgb[3] == 0) return 'transparent';
        var hex = [];
        for (var i = 0; i < 3; i++){
            var bit = (rgb[i]-0).toString(16);
            hex.push(bit.length == 1 ? '0'+bit : bit);
        }
        var hexText = '#'+hex.join('');
        if (array) return hex;
        else return hexText;
    },
    
    /*  
    Property: hexToRgb
        Converts a hexidecimal color value to RGB. Input string must be the hex color value (with or without the hash). Also accepts triplets ('333');
        
    Arguments:
        array - boolean value, defaults to false. Use true if you want the array ['255', '255', '255'] as output instead of "rgb(255,255,255)";
        
    Returns:
        rgb string or array.
        
    Example:
        >"#112233".hexToRgb(); //"rgb(17,34,51)"
        >"#112233".hexToRgb(true); //[17,34,51]
    */
    
    hexToRgb: function(array){
        var hex = this.test('^[#]{0,1}([\\w]{1,2})([\\w]{1,2})([\\w]{1,2})$');
        var rgb = [];
        for (var i = 1; i < hex.length; i++){
            if (hex[i].length == 1) hex[i] += hex[i];
            rgb.push(parseInt(hex[i], 16));
        }
        var rgbText = 'rgb('+rgb.join(',')+')';
        if (array) return rgb;
        else return rgbText;
    }

});

/*
Class: Number
    contains the internal method toInt.
*/

Number.extend({

    /*
    Property: toInt
        Returns this number; useful because toInt must work on both Strings and Numbers.
    */

    toInt: function(){
        return this;
    }

});/*
Script: Element.js
    Contains useful Element prototypes, to be used with the dollar function <$>.
    
Dependencies:
    <Moo.js>, <Function.js>, <Array.js>, <String.js>

Author:
    Valerio Proietti, <http://mad4milk.net>
    
License:
    MIT-style license.
    
Credits:
    - Some functions are inspired by those found in prototype.js <http://prototype.conio.net/> (c) 2005 Sam Stephenson sam [at] conio [dot] net, MIT-style license
*/

/*
Class: Element
    Custom class to allow all of its methods to be used with any DOM element via the dollar function <$>.
*/

var Element = new Class({

    /*
    Property: initialize
        Creates a new element of the type passed in.
            
    Arguments:
        el - the tag name for the element you wish to create.
            
    Example:
        >var div = new Element('div');
    */

    initialize: function(el){
        if ($type(el) == 'string') el = document.createElement(el);
        return $(el);
    },

    inject: function(el, where){
        el = $(el) || new Element(el);
        switch(where){
            case "before": $(el.parentNode).insertBefore(this, el); break;
            case "after": {
                    if (!el.getNext()) $(el.parentNode).appendChild(this);
                    else $(el.parentNode).insertBefore(this, el.getNext());
            } break;
            case "inside": el.appendChild(this); break;
        }
        return this;
    },
    
    /*
    Property: injectBefore
        Inserts the Element before the passed element.
            
    Parameteres:
        el - a string representing the element to be injected in (myElementId, or div), or an element reference.
        If you pass div or another tag, the element will be created.
            
    Example:
        >html: 
        ><div id="myElement"></div>
        ><div id="mySecondElement"></div>
        >js:
        >$('mySecondElement').injectBefore('myElement');
        >resulting html
        ><div id="myElement"></div>
        ><div id="mySecondElement"></div>

    */
    
    injectBefore: function(el){
        return this.inject(el, 'before');
    },
    
    /*  
    Property: injectAfter
        Same as <Element.injectBefore>, but inserts the element after.
    */
    
    injectAfter: function(el){
        return this.inject(el, 'after');
    },

    /*  
    Property: injectInside
        Same as <Element.injectBefore>, but inserts the element inside.
    */
    
    injectInside: function(el){
        return this.inject(el, 'inside');
    },

    /*  
    Property: adopt
        Inserts the passed element inside the Element. Works as <Element.injectInside> but in reverse.
            
    Parameteres:
        el - a string representing the element to be injected in (myElementId, or div), or an element reference.
        If you pass div or another tag, the element will be created.
    */
    
    adopt: function(el){
        this.appendChild($(el) || new Element(el));
        return this;
    },
    
    /*  
    Property: remove
        Removes the Element from the DOM.
            
    Example:
        >$('myElement').remove() //bye bye
    */
    
    remove: function(){
        this.parentNode.removeChild(this);
    },
    
    /*  
    Property: clone
        Clones the Element and returns the cloned one.
        
    Returns: 
        the cloned element
        
    Example:
        >var clone = $('myElement').clone().injectAfter('myElement');
        >//clones the Element and append the clone after the Element.
    */
    
    clone: function(contents){
        return $(this.cloneNode(contents || true));
    },

    /*  
    Property: replaceWith
        Replaces the Element with an element passed.
            
    Parameteres:
        el - a string representing the element to be injected in (myElementId, or div), or an element reference.
        If you pass div or another tag, the element will be created.
        
    Returns:
        the passed in element
            
    Example:
        >$('myOldElement').replaceWith($('myNewElement')); //$('myOldElement') is gone, and $('myNewElement') is in its place.
    */
    
    replaceWith: function(el){
        var el = $(el) || new Element(el);
        this.parentNode.replaceChild(el, this);
        return el;
    },
    
    /*  
    Property: appendText
        Appends text node to a DOM element.

    Arguments:
        text - the text to append.
        
    Example:
        ><div id="myElement">hey</div>
        >$('myElement').appendText(' howdy'); //myElement innerHTML is now "hey howdy"
    */

    appendText: function(text){
        if (this.getTag() == 'style' && window.ActiveXObject) this.styleSheet.cssText = text;
        else this.appendChild(document.createTextNode(text));
        return this;
    },
    
    /*
    Property: hasClass
        Tests the Element to see if it has the passed in className.
        
    Returns:
        true - the Element has the class
        false - it doesn't
     
    Arguments:
        className - the class name to test.
     
    Example:
        ><div id="myElement" class="testClass"></div>
        >$('myElement').hasClass('testClass'); //returns true
    */

    hasClass: function(className){
        return !!this.className.test("\\b"+className+"\\b");
    },

    /*  
    Property: addClass
        Adds the passed in class to the Element, if the element doesnt already have it.
        
    Arguments:
        className - the class name to add
        
    Example: 
        ><div id="myElement" class="testClass"></div>
        >$('myElement').addClass('newClass'); //<div id="myElement" class="testClass newClass"></div>
    */
    
    addClass: function(className){
        if (!this.hasClass(className)) this.className = (this.className+' '+className.trim()).clean();
        return this;
    },
    
    /*  
    Property: removeClass
        works like <Element.addClass>, but removes the class from the element.
    */

    removeClass: function(className){
        if (this.hasClass(className)) this.className = this.className.replace(className.trim(), '').clean();
        return this;
    },

    /*  
    Property: toggleClass
        Adds or removes the passed in class name to the element, depending on if it's present or not.
        
    Arguments:
        className - the class to add or remove
        
    Example:
        ><div id="myElement" class="myClass"></div>
        >$('myElement').toggleClass('myClass');
        ><div id="myElement" class=""></div>
        >$('myElement').toggleClass('myClass');
        ><div id="myElement" class="myClass"></div>
    */
    
    toggleClass: function(className){
        if (this.hasClass(className)) return this.removeClass(className);
        else return this.addClass(className);
    },
    
    /*
    Property: setStyle  
        Sets a css property to the Element.
        
        Arguments:
            property - the property to set
            value - the value to which to set it
        
        Example:
            >$('myElement').setStyle('width', '300px'); //the width is now 300px
    */
    
    setStyle: function(property, value){
        if (property == 'opacity') this.setOpacity(parseFloat(value));
        else this.style[property.camelCase()] = value;
        return this;
    },

    /*
    Property: setStyles
        Applies a collection of styles to the Element.
        
    Arguments:
        source - an object or string containing all the styles to apply
        
    Examples:
        >$('myElement').setStyles({
        >   border: '1px solid #000',
        >   width: '300px',
        >   height: '400px'
        >});

        OR
        
        >$('myElement').setStyle('border: 1px solid #000; width: 300px; height: 400px;');
    */
    
    setStyles: function(source){
        if ($type(source) == 'object') {
            for (var property in source) this.setStyle(property, source[property]);
        } else if ($type(source) == 'string') {
            if (window.ActiveXObject) this.cssText = source;
            else this.setAttribute('style', source);
        }
        return this;
    },
    
    /*  
    Property: setOpacity
        Sets the opacity of the Element, and sets also visibility == "hidden" if opacity == 0, and visibility = "visible" if opacity == 1.
        
    Arguments:
        opacity - Accepts numbers from 0 to 1.
        
    Example:
        >$('myElement').setOpacity(0.5) //make it 50% transparent
    */
    
    setOpacity: function(opacity){
        if (opacity == 0){
            if(this.style.visibility != "hidden") this.style.visibility = "hidden";
        } else {
            if(this.style.visibility != "visible") this.style.visibility = "visible";
        }
        if (window.ActiveXObject) this.style.filter = "alpha(opacity=" + opacity*100 + ")";
        this.style.opacity = opacity;
        return this;
    },
    
    /*  
    Property: getStyle
        Returns the style of the Element given the property passed in.
        
    Arguments:
        property - the css style property you want to retrieve
        
    Example:
        >$('myElement').getStyle('width'); //returns "400px"
        >//but you can also use
        >$('myElement').getStyle('width').toInt(); //returns "400"
        
    Returns:
        the style as a string
    */
    
    getStyle: function(property){
        var proPerty = property.camelCase();
        var style = this.style[proPerty] || false;
        if (!style) {
            if (document.defaultView) style = document.defaultView.getComputedStyle(this,null).getPropertyValue(property);
            else if (this.currentStyle) style = this.currentStyle[proPerty];
        }
        if (style && ['color', 'backgroundColor', 'borderColor'].test(proPerty) && style.test('rgb')) style = style.rgbToHex();
        return style;
    },

    /*  
    Property: addEvent
        Attaches an event listener to a DOM element.
        
    Arguments:
        action - the event to monitor ('click', 'load', etc)
        fn - the function to execute
        
    Example:
        >$('myElement').addEvent('click', function(){alert('clicked!')});
    */

    addEvent: function(action, fn){
        this[action+fn] = fn.bind(this);
        if (this.addEventListener) this.addEventListener(action, fn, false);
        else this.attachEvent('on'+action, this[action+fn]);
        var el = this;
        if (this != window) Unload.functions.push(function(){
            try {
                el.removeEvent(action, fn);
            }
            catch(e) {
                dbug.log("Couldn't remove event: " + e.message);
            }
            el[action+fn] = null;
        });
        return this;
    },
    
    /*  
    Property: removeEvent
        Works as Element.addEvent, but instead removes the previously added event listener.
    */
    
    removeEvent: function(action, fn){
        if (this.removeEventListener) this.removeEventListener(action, fn, false);
        else this.detachEvent('on'+action, this[action+fn]);
        return this;
    },

    getBrother: function(what){
        var el = this[what+'Sibling'];
        while ($type(el) == 'textnode') el = el[what+'Sibling'];
        return $(el);
    },
    
    /*
    Property: getPrevious
        Returns the previousSibling of the Element, excluding text nodes.
        
    Example:
        >$('myElement').getPrevious(); //get the previous DOM element from myElement
        
    Returns:
        the sibling element or undefined if none found.
    */
    
    getPrevious: function(){
        return this.getBrother('previous');
    },
    
    /*
    Property: getNext
        Works as Element.getPrevious, but tries to find the nextSibling.
    */
    
    getNext: function(){
        return this.getBrother('next');
    },
    
    /*
    Property: getNext
        Works as <Element.getPrevious>, but tries to find the firstChild.
    */

    getFirst: function(){
        var el = this.firstChild;
        while ($type(el) == 'textnode') el = el.nextSibling;
        return $(el);
    },

    /*
    Property: getLast
        Works as <Element.getPrevious>, but tries to find the lastChild.
    */

    getLast: function(){
        var el = this.lastChild;
        while ($type(el) == 'textnode')
        el = el.previousSibling;
        return $(el);
    },

    /*  
    Property: setProperty
        Sets an attribute for the Element.
        
    Arguments:
        property - the property to assign the value passed in
        value - the value to assign to the property passed in
        
    Example:
        >$('myImage').setProperty('src', 'whatever.gif'); //myImage now points to whatever.gif for its source
    */

    setProperty: function(property, value){
        var el = false;
        switch(property){
            case 'class': this.className = value; break;
            case 'style': this.setStyles(value); break;
            case 'name': if (window.ActiveXObject && this.getTag() == 'input'){
                el = $(document.createElement('<input name="'+value+'" />'));
                $A(this.attributes).each(function(attribute){
                    if (attribute.name != 'name') el.setProperty(attribute.name, attribute.value);
                    
                });
                if (this.parentNode) this.replaceWith(el);
            };
            default: this.setAttribute(property, value);
        }
        return el || this;
    },
    
    /*  
    Property: setProperties
        Sets numerous attributes for the Element.
        
    Arguments:
        source - an object with key/value pairs.
        
    Example:
        >$('myElement').setProperties({
        >   src: 'whatever.gif',
        >   alt: 'whatever dude'
        >});
        ><img src="whatever.gif" alt="whatever dude">
    */
    
    setProperties: function(source){
        for (var property in source) this.setProperty(property, source[property]);
        return this;
    },
    
    /*
    Property: setHTML
        Sets the innerHTML of the Element.
        
    Arguments:
        html - the new innerHTML for the element.
        
    Example:
        >$('myElement').setHTML(newHTML) //the innerHTML of myElement is now = newHTML
    */
    
    setHTML: function(html){
        this.innerHTML = html;
        return this;
    },
    
    /*  
    Property: getProperty
        Gets the an attribute of the Element.
        
    Arguments:
        property - the attribute to retrieve
        
    Example:
        >$('myImage').getProperty('src') // returns whatever.gif
        
    Returns:
        the value, or an empty string
    */
    
    getProperty: function(property){
        return this.getAttribute(property);
    },
    
    /*
    Property: getTag
        Returns the tagName of the element in lower case.
        
    Example:
        >$('myImage').getTag() // returns 'img'
        
    Returns:
        The tag name in lower case
    */
    
    getTag: function(){
        return this.tagName.toLowerCase();
    },
    
    getOffset: function(what){
        what = what.capitalize();
        var el = this;
        var offset = 0;
        do {
            offset += el['offset'+what] || 0;
            el = el.offsetParent;
        } while (el);
        return offset;
    },

    /*  
    Property: getTop
        Returns the distance from the top of the window to the Element.
    */
    
    getTop: function(){
        return this.getOffset('top');
    },
    
    /*  
    Property: getLeft
        Returns the distance from the left of the window to the Element.
    */
    
    getLeft: function(){
        return this.getOffset('left');
    },
    
    /*  
    Property: getValue
        Returns the value of the Element, if its tag is textarea, select or input.
    */
    
    getValue: function(){
        var value = false;
        switch(this.getTag()){
            case 'select': value = this.getElementsByTagName('option')[this.selectedIndex].value; break;
            case 'input': if ( (this.checked && ['checkbox', 'radio'].test(this.type)) || (['hidden', 'text', 'password'].test(this.type)) ) 
                value = this.value; break;
            case 'textarea': value = this.value;
        }
        return value;
    }

});

new Object.Native(Element);

Element.extend({
    hasClassName: Element.prototype.hasClass,
    addClassName: Element.prototype.addClass,
    removeClassName: Element.prototype.removeClass,
    toggleClassName: Element.prototype.toggleClass
});

/* Section: Utility Functions  */

/*
Function: $Element
    Applies a method with the passed in args to the passed in element. Useful if you dont want to extend the element
        
    Arguments:
        el - the element
        method - a string representing the Element Class method to execute on that element
        args - an array representing the arguments to pass to that method
        
    Example:
        >$Element(el, 'hasClass', className) //true or false
*/

function $Element(el, method, args){
    if ($type(args) != 'array') args = [args];
    return Element.prototype[method].apply(el, args);
};

/*
Function: $()
    returns the element passed in with all the Element prototypes applied.
    
Arguments:
    el - a reference to an actual element or a string representing the id of an element
        
Example:
    >$('myElement') // gets a DOM element by id with all the Element prototypes applied.
    >var div = document.getElementById('myElement');
    >$(div) //returns an Element also with all the mootools extentions applied.
        
    You'll use this when you aren't sure if a variable is an actual element or an id, as
    well as just shorthand for document.getElementById().
        
Returns:
    a DOM element or false (if no id was found)
        
Note:
    you need to call $ on an element only once to get all the prototypes.
    But its no harm to call it multiple times, as it will detect if it has been already extended.
*/

function $(el){
    if ($type(el) == 'string') el = document.getElementById(el);
    if ($type(el) == 'element'){
        if (!el.extend){
            Unload.elements.push(el);
            el.extend = Object.extend;
            el.extend(Element.prototype);
        }
        return el;
    } else return false;
};

window.addEvent = document.addEvent = Element.prototype.addEvent;
window.removeEvent = document.removeEvent = Element.prototype.removeEvent;

var Unload = {

    elements: [], functions: [], vars: [],

    unload: function(){
        Unload.functions.each(function(fn){
            fn();
        });
        
        window.removeEvent('unload', window.removeFunction);
        
        Unload.elements.each(function(el){
            for(var p in Element.prototype){
                window[p] = null;
                document[p] = null;
                el[p] = null;
            }
            el.extend = null;
        });
    }
    
};

window.removeFunction = Unload.unload;
window.addEvent('unload', window.removeFunction);/*
Script: Ajax.js
    Contains the ajax class. Also contains methods to generate querystings from forms and Objects.
        
Dependencies:
    <Moo.js>, <Function.js>, <Array.js>, <String.js>, <Element.js>

Author:
    Valerio Proietti, <http://mad4milk.net>

License:
    MIT-style license.
*/

/*
Class: Ajax
    For all your asynchronous needs. Note: this class implements <Chain>

Arguments:
    url - the url pointing to the server-side script.
    options - optional, an object containing options.

Options:
    method - 'post' or 'get' - the prototcol for the request; optional, defaults to 'post'.
    postBody - if method is post, you can write parameters here. Can be a querystring, an object or a Form element.
    async - boolean: asynchronous option; true uses asynchronous requests. Defaults to true.
    onComplete - function to execute when the ajax request completes.
    onStateChange - function to execute when the state of the XMLHttpRequest changes.
    update - $(element) to insert the response text of the XHR into, upon completion of the request.
    evalScripts - boolean; default is false. Execute scripts in the response text onComplete.

Example:
    >var myAjax = new Ajax(url, {method: 'get'}).request();                             
*/
    
var Ajax = ajax = new Class({

    setOptions: function(options){
        this.options = {
            method: 'post',
            postBody: null,
            async: true,
            onComplete: Class.empty,
            onStateChange: Class.empty,
            update: null,
            evalScripts: false
        };
        Object.extend(this.options, options || {});
    },
    
    initialize: function(url, options){
        this.setOptions(options);
        this.url = url;
        this.transport = this.getTransport();
    },
    
    /*
    Property: request
        Executes the ajax request.
            
    Example:
        >var myAjax = new Ajax(url, {method: 'get'});
        >myAjax.request();
        
        OR
        
        >new Ajax(url, {method: 'get'}).request();
    */
    
    request: function(){
        this.transport.open(this.options.method, this.url, this.options.async);
        this.transport.onreadystatechange = this.onStateChange.bind(this);
        if (this.options.method == 'post'){
            this.transport.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
            if (this.transport.overrideMimeType) this.transport.setRequestHeader('Connection', 'close');
        }
        switch($type(this.options.postBody)){
            case 'element': this.options.postBody = $(this.options.postBody).toQueryString(); break;
            case 'object': this.options.postBody = Object.toQueryString(this.options.postBody);
        }
        if($type(this.options.postBody) == 'string') this.transport.send(this.options.postBody);
        else this.transport.send(null);
        return this;
    },

    onStateChange: function(){
        this.options.onStateChange.delay(10, this);
        if (this.transport.readyState == 4 && this.transport.status == 200){
            if (this.options.update) $(this.options.update).setHTML(this.transport.responseText);
            this.options.onComplete.pass([this.transport.responseText, this.transport.responseXML], this).delay(20);
            if (this.options.evalScripts) this.evalScripts.delay(30, this);
            this.transport.onreadystatechange = Class.empty;
            this.callChain();
        }
    },
    
    /*  
    Property: evalScripts
        Executes scripts in the response text
    */
    
    evalScripts: function(){
        if(scripts = this.transport.responseText.match(/<script[^>]*?>[\S\s]*?<\/script>/g)){
            scripts.each(function(script){
                eval(script.replace(/^<script[^>]*?>/, '').replace(/<\/script>$/, ''));
            });
        }
    },

    getTransport: function(){
        if (window.XMLHttpRequest) return new XMLHttpRequest();
        else if (window.ActiveXObject) return new ActiveXObject('Microsoft.XMLHTTP');
    }

});

Ajax.implement(new Chain);

/* Section: Object related Functions  */

/*  
Function: Object.toQuerySTring
    Generates a querysting from a key/pair values in an object
            
Arguments:
    source - the object to generate the querystring from.

Returns:
    the query string.
            
Example:
    >Object.toQueryString({apple: "red", lemon: "yellow"}); //returns "apple=red&lemon=yellow"
*/

Object.toQueryString = function(source){
    var queryString = [];
    for (var property in source) queryString.push(encodeURIComponent(property)+'='+encodeURIComponent(source[property]));
    return queryString.join('&');
};

/*
Class: Element
    Custom class to allow all of its methods to be used with any DOM element via the dollar function <$>.
*/

Element.extend({
    
    /*
    Property: send
        Sends a form with an ajax post request
            
    Arguments:
        options - option collection for ajax request. See <Ajax.initialize> for option list.
    
    Returns:
        The Ajax Class Instance
            
    Example:
        (start code)
        <form id="myForm" action="submit.php">
        <input name="email" value="bob@bob.com">
        <input name="zipCode" value="90210">
        </form>
        <script>
        $('myForm').send()
        </script>
        (end)
    */
    
    send: function(options){
        options = Object.extend(options, {postBody: this.toQueryString(), method: 'post'});
        return new Ajax(this.getProperty('action'), options).request();
    },
    
    /*
    Property: toQueryString
        Reads the children inputs of the Element and generates a  query string, based on their values. Used internally in <Ajax>
            
    Example:
        (start code)
        <form id="myForm" action="submit.php">
        <input name="email" value="bob@bob.com">
        <input name="zipCode" value="90210">
        </form>

        <script>
         $('myForm').toQueryString()
        </script>
        (end)

        Returns:
            email=bob@bob.com&zipCode=90210
    */
    
    toQueryString: function(){
        var queryString = [];
        $A(this.getElementsByTagName('*')).each(function(el){
            var name = $(el).name;
            var value = el.getValue();
            if (value && name) queryString.push(encodeURIComponent(name)+'='+encodeURIComponent(value));
        });
        return queryString.join('&');
    }

});/*
Script: Dom.js
    Css Query related function and <Element> extensions

Dependencies:
    <Moo.js>, <Function.js>, <Array.js>, <String.js>, <Element.js>

Author:
    Valerio Proietti, <http://mad4milk.net>

License:
    MIT-style license.
*/

/* Section: Utility Functions */

/*
Function: $S()
    Selects DOM elements based on css selector(s). Extends the elements upon matching.
    
Arguments:
    any number of css selectors
    
Example:
    >$S('a') //an array of all anchor tags on the page
    >$S('a', 'b') //an array of all anchor and bold tags on the page
    >$S('#myElement') //array containing only the element with id = myElement
    >$S('#myElement a.myClass') //an array of all anchor tags with the class "myClass" within the DOM element with id "myElement"

Returns:
    array - array of all the dom elements matched
*/

function $S(){
    var els = [];
    $A(arguments).each(function(sel){
        if ($type(sel) == 'string') els.extend(document.getElementsBySelector(sel));
        else if ($type(sel) == 'element') els.push($(sel));
    });
    return $Elements(els);
};


/*
Function: $$
    Same as <$S>
*/

var $$ = $S;

/* 
Function: $E 
    Selects a single (i.e. the first found) Element based on the selector passed in and an optional filter element.
    
Arguments:
    selector - the css selector to match
    filter - optional; a DOM element to limit the scope of the selector match; defaults to document.
    
Example:
>$E('a', 'myElement') //find the first anchor tag inside the DOM element with id 'myElement'
    
Returns:
    a DOM element - the first element that matches the selector
*/

function $E(selector, filter){
    return ($(filter) || document).getElement(selector);
};

/*
Function: $ES
    Returns a collection of Elements that match the selector passed in limited to the scope of the optional filter.
    See Also: <Element.getElements> for an alternate syntax.

Retunrs:
    array - an array of dom elements that match the selector within the filter
        
Arguments:
    selector - css selector to match
    filter - optional; a DOM element to limit the scope of the selector match; defaults to document.

Examples:
    >$ES("a") //gets all the anchor tags; synonymous with $S("a")
    >$ES('a','myElement') //get all the anchor tags within $('myElement')
*/

function $ES(selector, filter){
    return ($(filter) || document).getElementsBySelector(selector);
};

function $Elements(elements){
    return Object.extend(elements, new Elements);
};

/*
Class: Element
    Custom class to allow all of its methods to be used with any DOM element via the dollar function <$>.
*/

Element.extend({

    /*
    Property: getElements 
        Gets all the elements within an element that match the given (single) selector.
    
    Arguments:
        selector - the css selector to match
    
    Example:
        >$('myElement').getElements('a'); // get all anchors within myElement

    Credits:
        Say thanks to Christophe Beyls <http://digitalia.be> for the new regular expression that rules getElements, a big step forward in terms of speed.
    */

    getElements: function(selector){
        var filters = [];
        selector.clean().split(' ').each(function(sel, i){
            var bits = sel.test('^(\\w*|\\*)(?:#([\\w_-]+)|\\.([\\w_-]+))?(?:\\[["\']?(\\w+)["\']?(?:([\\*\\^\\$]?=)["\']?(\\w*)["\']?)?\\])?$');
            if (!bits) return;
            if (!bits[1]) bits[1] = '*';
            var param = bits.remove(bits[0]).associate(['tag', 'id', 'class', 'attribute', 'operator', 'value']);
            if (i == 0){
                if (param['id']){
                    var el = this.getElementById(param['id']);
                    if (!el || ((param['tag'] != '*') && ($Element(el, 'getTag') != param['tag']))) return;
                    filters = [el];
                } else {
                    filters = $A(this.getElementsByTagName(param['tag']));
                }
            } else {
                filters = $Elements(filters).filterByTagName(param['tag']);
                if (param['id']) filters = $Elements(filters).filterById(param['id']);
            }
            if (param['class']) filters = $Elements(filters).filterByClassName(param['class']);
            if (param['attribute']) filters = $Elements(filters).filterByAttribute(param['attribute'], param['value'], param['operator']);

        }, this);
        filters.each(function(el){
            $(el);
        });
        return $Elements(filters);
    },
    
    /*
    Property: getElementById
        Targets an element with the specified id found inside the Element. Does not overwrite document.getElementById.

    Arguments:
        id - the id of the element to find.
    */
    
    getElementById: function(id){
        var el = document.getElementById(id);
        if (!el) return false;
        for(var parent = el.parentNode; parent != this; parent = parent.parentNode){
            if (!parent) return false;
        }
        return el;
    },

    /*
    Property: getElement
        Same as <Element.getElements>, but returns only the first. Alternate syntax for <$E>, where filter is the Element.

    */

    getElement: function(selector){
        return this.getElementsBySelector(selector)[0];
    },

    /*
    Property: getElement
        Same as <Element.getElements>, but allows for comma separated selectors, as in css. Alternate syntax for <$S>, where filter is the Element.

    */

    getElementsBySelector: function(selector){
        var els = [];
        selector.split(',').each(function(sel){
            els.extend(this.getElements(sel));
        }, this);
        return $Elements(els);
    }

});

document.extend = Object.extend;

/* Section: document related functions */

document.extend({
    /*
    Function: document.getElementsByClassName 
        Returns all the elements that match a specific class name. 
        Here for compatibility purposes. can also be written: document.getElements('.className'), or $S('.className')
    */

    getElementsByClassName: function(className){
        return document.getElements('.'+className);
    },
    getElement: Element.prototype.getElement,
    getElements: Element.prototype.getElements,
    getElementsBySelector: Element.prototype.getElementsBySelector

});

/*
Class: Elements
    Methods for dom queries arrays, as <$S>.
*/

var Elements = new Class({

    /*
    Property: action
        Applies the supplied actions collection to each Element in the collection.
    
    Arguments:
        actions - an Object with key/value pairs for the actions to apply. 
        The initialize key is executed immediatly.
        Keys beginning with on will add a simple event (onclick for example).
        Keys ending with event will add an event with <Element.addEvent>.
        Other keys are useless.

    Example:
        >$S('a').action({
        >   initialize: function() {
        >       this.addClassName("anchor");
        >   },
        >   onclick: function(){
        >       alert('clicked!');
        >   },
        >   mouseoverevent: function(){
        >       alert('mouseovered!');
        >   }
        >});
    */

    action: function(actions){
        this.each(function(el){
            el = $(el);
            if (actions.initialize) actions.initialize.apply(el);
            for(var action in actions){
                var evt = false;
                if (action.test('^on[\\w]{1,}')) el[action] = actions[action];
                else if (evt = action.test('([\\w-]{1,})event$')) el.addEvent(evt[1], actions[action]);
            }
        });
    },

    //internal methods

    filterById: function(id){
        var found = [];
        this.each(function(el){
            if (el.id == id) found.push(el);
        });
        return found;
    },

    filterByClassName: function(className){
        var found = [];
        this.each(function(el){
            if ($Element(el, 'hasClass', className)) found.push(el);
        });
        return found;
    },

    filterByTagName: function(tagName){
        var found = [];
        this.each(function(el){
            found.extend($A(el.getElementsByTagName(tagName)));
        });
        return found;
    },

    filterByAttribute: function(name, value, operator){
        var found = [];
        this.each(function(el){
            var att = el.getAttribute(name);
            if(!att) return;
            if (!operator) return found.push(el);
    
            switch(operator){
                case '*=': if (att.test(value)) found.push(el); break;
                case '=': if (att == value) found.push(el); break;
                case '^=': if (att.test('^'+value)) found.push(el); break;
                case '$=': if (att.test(value+'$')) found.push(el);
            }

        });
        return found;
    }

});

new Object.Native(Elements);/*
Script: Fx.js
    Applies visual transitions to any element. Contains Fx.Base, Fx.Style and Fx.Styles

Dependencies:
    <Moo.js>, <Function.js>, <Array.js>, <String.js>, <Element.js>

Author:
    Valerio Proietti, <http://mad4milk.net>

License:
    MIT-style license.
*/

var Fx = fx = {};

/*
Class: Fx.Base
    Base class for the Mootools fx library.
    
Options:
    onStart - the function to execute as the effect begins; nothing (<Class.empty>) by default.
    onComplete - the function to execute after the effect has processed; nothing (<Class.empty>) by default.
    transition - the equation to use for the effect see <Fx.Transitions>; default is <Fx.Transitions.sineInOut>
    duration - the duration of the effect in ms; 500 is the default.
    unit - the unit is 'px' by default (other values include things like 'em' for fonts or '%').
    wait - boolean: to wait or not to wait for a current transition to end before running another of the same instance. defaults to true.
    fps - the frames per second for the transition; default is 30
*/

Fx.Base = new Class({

    setOptions: function(options){
        this.options = Object.extend({
            onStart: Class.empty,
            onComplete: Class.empty,
            transition: Fx.Transitions.sineInOut,
            duration: 500,
            unit: 'px',
            wait: true,
            fps: 50
        }, options || {});
    },

    step: function(){
        var time = new Date().getTime();
        if (time < this.time + this.options.duration){
            this.cTime = time - this.time;
            this.setNow();
        } else {
            this.options.onComplete.pass(this.element, this).delay(10);
            this.clearTimer();
            this.callChain();
            this.now = this.to;
        }
        this.increase();
    },
    
    /*  
    Property: set
        Immediately sets the value with no transition.
    
    Arguments:
        to - the point to jump to
    
    Example:
        >var myFx = new Fx.Style('myElement', 'opacity').set(0); //will make it immediately transparent
    */
    
    set: function(to){
        this.now = to;
        this.increase();
        return this;
    },
    
    setNow: function(){
        this.now = this.compute(this.from, this.to);
    },

    compute: function(from, to){
        return this.options.transition(this.cTime, from, (to - from), this.options.duration);
    },
    
    /*
    Property: custom
        Executes an effect from one position to the other.
    
    Arguments:
        from - integer:  staring value
        to - integer: the ending value
    
    Examples:
        >var myFx = new Fx.Style('myElement', 'opacity').custom(0,1); //display a transition from transparent to opaque.
    */
    
    custom: function(from, to){
        if (!this.options.wait) this.clearTimer();
        if (this.timer) return;
        this.options.onStart.pass(this.element, this).delay(10);
        this.from = from;
        this.to = to;
        this.time = new Date().getTime();
        this.timer = this.step.periodical(Math.round(1000/this.options.fps), this);
        return this;
    },
    
    /*
    Property: clearTimer
        Stops processing the transition.
    */
    clearTimer: function(){
        this.timer = $clear(this.timer);
        return this;
    },
    
    setStyle: function(element, property, value){
        element.setStyle(property, value + this.options.unit);
    }

});

Fx.Base.implement(new Chain);

/*  
Class: Fx.Style
    The Style effect; Extends <Fx.Base>, inherits all its properties. Used to transition any css property from one value to another.

Arguments:
    el - the $(element) to apply the style transition to
    property - the property to transition
    options - the Fx.Base options (see: <Fx.Base>)
    
Example:
    >var marginChange = new fx.Style('myElement', 'margin-top', {duration:500});
    >marginChange.custom(10, 100);
*/

Fx.Style = Fx.Base.extend({

    initialize: function(el, property, options){
        this.element = $(el);
        this.setOptions(options);
        this.property = property.camelCase();
    },
    
    /*  
    Property: hide
        Same as <Fx.Base.set>(0)
    */
    
    hide: function(){
        return this.set(0);
    },

    /*  
    Property: goTo
        will apply <Fx.Base.custom>, setting the starting point to the current position.
        
    Arguments:
        val - the ending value
    */

    goTo: function(val){
        return this.custom(this.now || 0, val);
    },

    increase: function(){
        this.setStyle(this.element, this.property, this.now);
    }

});

/*
Class: Fx.Styles
    Allows you to animate multiple css properties at once; Extends <Fx.Base>, inherits all its properties.
    
Arguments:
    el - the $(element) to apply the styles transition to
    options - the fx options (see: <Fx.Base>)

Example:
    >var myEffects = new fx.Styles('myElement', {duration: 1000, transition: fx.linear});
    >myEffects.custom({
    >   'height': [10, 100],
    >   'width': [900, 300]
    >});
*/

Fx.Styles = Fx.Base.extend({

    initialize: function(el, options){
        this.element = $(el);
        this.setOptions(options);
        this.now = {};
    },

    setNow: function(){
        for (var p in this.from) this.now[p] = this.compute(this.from[p], this.to[p]);
    },
    
    /*
    Property:   custom
        The function you'll actually use to execute a transition.
    
    Arguments:
        an object
        
    Example:
        see <Fx.Styles>
    */

    custom: function(objFromTo){
        if (this.timer && this.options.wait) return;
        var from = {};
        var to = {};
        for (var p in objFromTo){
            from[p] = objFromTo[p][0];
            to[p] = objFromTo[p][1];
        }
        return this.parent(from, to);
    },

    increase: function(){
        for (var p in this.now) this.setStyle(this.element, p, this.now[p]);
    }

});

/*
Class: Element
    Custom class to allow all of its methods to be used with any DOM element via the dollar function <$>.
*/

Element.extend({

    /*
    Property: effect
        Applies an <Fx.Style> to the Element; This a shortcut for <Fx.Style>.

    Example:
        >var myEffect = $('myElement').effect('height', {duration: 1000, transition: Fx.Transitions.linear});
        >myEffect.custom(10, 100);
    */
    
    effect: function(property, options){
        return new Fx.Style(this, property, options);
    },
    
    /*  
    Property: effects
        Applies an <Fx.Styles> to the Element; This a shortcut for <Fx.Styles>.
        
    Example:
        >var myEffects = $(myElement).effects({duration: 1000, transition: Fx.Transitions.sineInOut});
        >myEffects.custom({'height': [10, 100], 'width': [900, 300]});
    */

    effects: function(options){
        return new Fx.Styles(this, options);
    }

});

/*
Class: Fx.Transitions
    A collection of transition equations for use with the <Fx> Class.
        
See Also:
    <Fxtransitions.js> for a whole bunch of transitions.
        
Credits:
    Easing Equations, (c) 2003 Robert Penner (http://www.robertpenner.com/easing/), Open Source BSD License.
*/

Fx.Transitions = {
    
    /* Property: linear */
    linear: function(t, b, c, d){
        return c*t/d + b;
    },
    
    /* Property: sineInOut */
    sineInOut: function(t, b, c, d){
        return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
    }

};/*    
Script: Cookie.js
    A cookie reader/creator

Credits: 
    based on the functions by Peter-Paul Koch (http://quirksmode.org)
    
Dependencies:
    <Moo.js>, <String.js>
*/

/*
Class: Cookie
    Class for creating, getting, and removing cookies.
*/

var Cookie = {
    
    /*  
    Property: set
        Sets a cookie in the browser.
        
    Arguments:
        key - the key (name) for the cookie
        value - the value to set
        duration - optional, how long the cookie should remain (in days); defaults to 1 year.
        
    Example:
        >Cookie.set("username", "Aaron", 1) //save this for a day
        
    */

    set: function(key, value, duration){
        var date = new Date();
        date.setTime(date.getTime()+((duration || 365)*86400000));
        document.cookie = key+"="+value+"; expires="+date.toGMTString()+"; path=/";
    },
    
    /*  
    Property: get
        Gets the value of a cookie.
        
    Arguments:
        key - the name of the cookie you wish to retrieve.
        
    Example:
        >Cookie.get("username") //returns Aaron
    */
    
    get: function(key){
        var myValue, myVal;
        document.cookie.split(';').each(function(cookie){
            if(myVal = cookie.trim().test(key+'=(.*)')) myValue = myVal[1];
        });
        return myValue;
    },

    /*
    Property: remove
        Removes a cookie from the browser.
        
    Arguments:
        key - the name of the cookie to remove
        
    Examples:
        >Cookie.remove("username") //bye-bye Aaron
    */

    remove: function(key){
        this.set(key, '', -1);
    }

};/*
Script: Json.js
    Simple Json parser and Stringyfier, See: <http://www.json.org/>
        
Dependencies:
    <Moo.js>, <Function.js>, <Array.js>, <String.js>, <Element.js>

Author:
    Valerio Proietti, <http://mad4milk.net>

License:
    MIT-style license.
*/

/*
Class: Json
    Simple Json parser and Stringyfier, See: <http://www.json.org/>
*/

var Json = {

    /*
    Property: toString
        Converts an object to a string, to be passed in server-side scripts as a parameter. Although its not normal usage for this class, this method can also be used to convert functions and arrays to strings.
        
    Arguments:
        obj - the object to convert to string
        
    Returns:
        A json string
        
    Example:
        (start code)
        Json.toString({apple: 'red', lemon: 'yellow'}); "{"apple":"red","lemon":"yellow"}" //don't get hung up on the quotes; it's just a string.
        (end)
    */

    toString: function(obj){
        var string = [];
        
        var isArray = function(array){
            var string = [];
            array.each(function(ar){
                string.push(Json.toString(ar));
            });
            return string.join(',');
        };
        
        var isObject = function(object){
            var string = [];
            for (var property in object) string.push('"'+property+'":'+Json.toString(object[property]));
            return string.join(',');
        };
        
        switch($type(obj)){
            case 'number': string.push(obj); break;
            case 'string': string.push('"'+obj+'"'); break;
            case 'function': string.push(obj); break;
            case 'object': string.push('{'+isObject(obj)+'}'); break;
            case 'array': string.push('['+isArray(obj)+']');
        }
        
        return string.join(',');
    },
    
    /*  
    Function: evaluate
        converts a json string to an object.
        
    Arguments:
        str - the string to evaluate.
        
    Example:
        >var myObject = Json.evaluate('{"apple":"red","lemon":"yellow"}');
        >//myObject will become {apple: 'red', lemon: 'yellow'}
    */

    evaluate: function(str){
        return eval('(' + str + ')');
    }

};/*
Script: Window.js
    Window methods, as those to get the size or a better onload.
        
Dependencies:
    <Moo.js>, <Function.js>, <String.js>

Author:
    Valerio Proietti, <http://mad4milk.net>

License:
    MIT-style license.
*/

/*
Class: Window
    Cross browser methods to get the window size, onDomReady method.
*/

var Window = {
    
    /*  
    Property: disableImageCache
        Disables background image chache for internex explorer, to prevent flickering. 
        To be called if you have effects with background images, and they flicker.
        
    Example:
        Window.disableImageCache();
    */
    
    disableImageCache: function(){
        if (window.ActiveXObject) document.execCommand("BackgroundImageCache", false, true);
    },

    extend: Object.extend,
    
    /*  
    Property: getWidth
        Returns an integer representing the width of the browser.
    */

    getWidth: function(){
        return window.innerWidth || document.documentElement.clientWidth || 0;
    },
    
    /*
    Property: getHeight
        Returns an integer representing the height of the browser.
    */

    getHeight: function(){
        return window.innerHeight || document.documentElement.clientHeight || 0;
    },

    /*
    Property: getScrollHeight
        Returns an integer representing the scrollHeight of the window.

    See Also:
        <http://developer.mozilla.org/en/docs/DOM:element.scrollHeight>
    */

    getScrollHeight: function(){
        return document.documentElement.scrollHeight;
    },

    /*
    Property: getScrollWidth
        Returns an integer representing the scrollWidth of the window.
        
    See Also:
        <http://developer.mozilla.org/en/docs/DOM:element.scrollWidth>
    */

    getScrollWidth: function(){
        return document.documentElement.scrollWidth;
    },

    /*  
    Property: getScrollTop
        Returns an integer representing the scrollTop of the window (the number of pixels the window has scrolled from the top).
        
    See Also:
        <http://developer.mozilla.org/en/docs/DOM:element.scrollTop>
    */

    getScrollTop: function(){
        return document.documentElement.scrollTop || window.pageYOffset || 0;
    },

    /*
    Property: getScrollLeft
        Returns an integer representing the scrollLeft of the window (the number of pixels the window has scrolled from the left).
        
    See Also:
        <http://developer.mozilla.org/en/docs/DOM:element.scrollLeft>
    */
    
    getScrollLeft: function(){
        return document.documentElement.scrollLeft || window.pageXOffset || 0;
    },
    
    /*
    Property: onDomReady
        Executes the passed in function when the DOM is ready (when the document tree has loaded, not waiting for images).
        
    Credits:
        (c) Dean Edwards/Matthias Miller/John Resig, remastered for mootools. Later touched up by Christophe Beyls <http://digitalia.be>.
        
    Arguments:
        init - the function to execute when the DOM is ready
        
    Example:
        > Window.onDomReady(function(){alert('the dom is ready');});
    */
    
    onDomReady: function(init){
        var state = document.readyState;
        if (state && document.childNodes && !document.all && !navigator.taintEnabled){ //khtml
            if (state.test(/loaded|complete/)) return init();
            else return Window.onDomReady.pass(init).delay(100);
        } else if (state && window.ActiveXObject){ //ie
            var script = $('_ie_ready_');
            if (!script) document.write("<script id='_ie_ready_' defer='true' src='://'></script>");
            $('_ie_ready_').addEvent('readystatechange', function(){
                if (this.readyState == 'complete') init();
            });
            return;
        } else { //others
            var myInit = function() {
                if (arguments.callee.done) return;
                arguments.callee.done = true;
                init();
            };
            window.addEvent("load", myInit);
            document.addEvent("DOMContentLoaded", myInit);
        }
    }

};/*    
Script: Accordion.js
    Fx.Elements and Accordion.
        
Dependencies:
    <Moo.js>, <Function.js>, <Array.js>, <String.js>, <Element.js>, <Fx.js>

Author:
    Valerio Proietti, <http://mad4milk.net>

License:
    MIT-style license.
*/

/*
Class: Fx.Elements
    Fx.Elements allows you to apply any number of styles trantisions to a selection of elements. Wonky syntax but very powerful. Used internally by the accordion.

Arguments:
    elements - a collection of elements the effects will be applied to.
    options - same as <Fx.Base> options.
*/

Fx.Elements = Fx.Base.extend({

    initialize: function(elements, options){
        this.elements = [];
        elements.each(function(el){
            this.elements.push($(el));
        }, this);
        this.setOptions(options);
        this.now = {};
    },

    setNow: function(){
        for (var i in this.from){
            var iFrom = this.from[i];
            var iTo = this.to[i];
            var iNow = this.now[i] = {};
            for (var p in iFrom) iNow[p] = this.compute(iFrom[p], iTo[p]);
        }
    },

    /*
    Property: custom
        Applies the passed in style transitions to each object named (see example). Each item in the collection is refered to as a numerical string ("1" for instance). The first item is "0", the second "1", etc.
        
    Example:
        (start code)
        var myElementsEffects = new Fx.Elements($$('a'));
        myElementsEffects.custom({
            '0': { //let's change the first element's opacity and width
                'opacity': [0,1],
                'width': [100,200]
            },
            '1': { //and the second one's opacity
                'opacity': [0.2, 0.5]
            }
        });
        (end)
    */

    custom: function(objObjs){
        if (this.timer && this.options.wait) return;
        var from = {};
        var to = {};
        for (var i in objObjs){
            var iProps = objObjs[i];
            var iFrom = from[i] = {};
            var iTo = to[i] = {};
            for (var prop in iProps){
                iFrom[prop] = iProps[prop][0];
                iTo[prop] = iProps[prop][1];
            }
        }
        return this.parent(from, to);
    },

    increase: function(){
        for (var i in this.now){
            var iNow = this.now[i];
            for (var p in iNow) this.setStyle(this.elements[i.toInt()], p, iNow[p]);
        }
    }

});

/*
Class: Fx.Accordion
    The Fx.Accordion function creates a group of elements that are toggled when their handles are clicked. When one elements toggles in, the others toggles back.

Arguments:
    elements - required, a collection of elements the transitions will be applied to.
    togglers - required, a collection of elements, the elements handlers.
    options - optional, see options below, and <Fx.Base> options.

Options:
    start - either 'open-first' or 'first-open'. 'open-first' will slide that element open, while 'first-open' will just show that element as open immediately with no transition.
    fixedHeight - integer, if you want your accordion to have a fixed height. defaults to false.
    fixedWidth - integer, if you want your accordion to have a fixed width. defaults to false.
    alwaysHide - boolean, if you want the ability to close your only-open item. defaults to false.
    wait - boolean. means that open and close transitions can cancel current ones (so if you click
     on items before the previous finishes transitioning, the clicked transition will fire canceling the previous). true means that if one element is sliding open or closed, clicking on another will have no effect. for Accordion defaults to false.
    onActive - function to execute when an element starts to show
    onBackground - function to execute when an element starts to hide
    height - boolean, will add a height transition to the accordion if true. defaults to true.
    opacity - boolean, will add an opacity transition to the accordion if true. defaults to true.
    width - boolean, will add a width transition to the accordion if true. defaults to false, css mastery is required to make this work!
*/

Fx.Accordion = Fx.Elements.extend({

    extendOptions: function(options){
        Object.extend(this.options, Object.extend({
            start: 'open-first',
            fixedHeight: false,
            fixedWidth: false,
            alwaysHide: false,
            wait: false,
            onActive: Class.empty,
            onBackground: Class.empty,
            height: true,
            opacity: true,
            width: false
        }, options || {}));
    },

    initialize: function(togglers, elements, options){
        this.parent(elements, options);
        this.extendOptions(options);
        this.previousClick = 'nan';
        togglers.each(function(tog, i){
            $(tog).addEvent('click', function(){this.showThisHideOpen(i)}.bind(this));
        }, this);
        this.togglers = togglers;
        this.h = {}; this.w = {}; this.o = {};
        this.elements.each(function(el, i){
            this.now[i] = {};
            $(el).setStyles({'height': 0, 'overflow': 'hidden'});
        }, this);
        switch(this.options.start){
            case 'first-open': this.elements[0].setStyle('height', this.elements[0].scrollHeight+this.options.unit); break;
            case 'open-first': this.showThisHideOpen(0); break;
        }
    },

    hideThis: function(i){
        if (this.options.height) this.h = {'height': [this.elements[i].offsetHeight, 0]};
        if (this.options.width) this.w = {'width': [this.elements[i].offsetWidth, 0]};
        if (this.options.opacity) this.o = {'opacity': [this.now[i]['opacity'] || 1, 0]};
    },

    showThis: function(i){
        if (this.options.height) this.h = {'height': [this.elements[i].offsetHeight, this.options.fixedHeight || this.elements[i].scrollHeight]};
        if (this.options.width) this.w = {'width': [this.elements[i].offsetWidth, this.options.fixedWidth || this.elements[i].scrollWidth]};
        if (this.options.opacity) this.o = {'opacity': [this.now[i]['opacity'] || 0, 1]};
    },

    /*
    Property: showThisHideOpen
        Shows a specific item and hides all others. Useful when triggering an accordion from outside.
        
    Arguments:
        iToShow - the index of the item to show.
    */

    showThisHideOpen: function(iToShow){
        if (iToShow != this.previousClick || this.options.alwaysHide){
            this.previousClick = iToShow;
            var objObjs = {};
            var err = false;
            var madeInactive = false;
            this.elements.each(function(el, i){
                this.now[i] = this.now[i] || {};
                if (i != iToShow){
                    this.hideThis(i);
                } else if (this.options.alwaysHide){
                    if (el.offsetHeight == el.scrollHeight){
                        this.hideThis(i);
                        madeInactive = true;
                    } else if (el.offsetHeight == 0){
                        this.showThis(i);
                    } else {
                        err = true;
                    }
                } else if (this.options.wait && this.timer){
                    this.previousClick = 'nan';
                    err = true;
                } else {
                    this.showThis(i);
                }
                objObjs[i] = Object.extend(this.h, Object.extend(this.o, this.w));
            }, this);
            if (err) return;
            if (!madeInactive) this.options.onActive.call(this, this.togglers[iToShow], iToShow);
            this.togglers.each(function(tog, i){
                if (i != iToShow || madeInactive) this.options.onBackground.call(this, tog, i);
            }, this);
            return this.custom(objObjs);
        }
    }

});/*   Script: prototype.compatability.js
        This library extends the <http://mootools.net> framework on which the cnet.global.framework is based.


Dependancies:
     mootools - <Moo.js>, <String.js>, <Array.js>, <Function.js>, <Element.js>, <Dom.js>, <Ajax.js>
     cnet libraries - <array.cnet.js>, <element.cnet.js>, <string.cnet.js>
    
Author:
    Aaron Newton, <aaron [dot] newton [at] cnet [dot] com>

Description:
        This script specifically extends Mootools to add functions to make the framework backwards
        compatable with Prototype lite, originally authored by the team at mad4milk.net, and then altered by
        CNET.com to include a few other things, like the Event object.
    */

/*  Prototype JavaScript (lite version from CNET via mad4milk.net) framework, modified to work on top of MooTools
 *  (c) 2005 Sam Stephenson <sam@conio.net>
 *  Prototype is freely distributable under the terms of an MIT-style license.
 *  For details, see the Prototype web site: http://prototype.conio.net/
/*--------------------------------------------------------------------------*/

/*  Class: Prototype    
        This is the "lite" version of Prototype, originally authored by the mad4milk team.
*/
var Prototype = {
    Version: 'CNET Prototype Lite, MooTools edition ver. 1.0',
    ScriptFragment: '(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)',
    emptyFunction: function() {},
    K: function(x) {return x}
};
/*  Class: String
        This extends the <String> prototype.
    */
Object.extend(String.prototype, {
/*  Property: camelize
        returns the string in camelCase function.
        
        Example:
        >"this is a string".camelize()
        > > thisIsAString
    */
    camelize: function() {
        var oStringList = this.split('-');
        if (oStringList.length == 1) return oStringList[0];

        var camelizedString = this.indexOf('-') == 0
            ? oStringList[0].charAt(0).toUpperCase() + oStringList[0].substring(1)
            : oStringList[0];

        for (var i = 1, len = oStringList.length; i < len; i++) {
            var s = oStringList[i];
            camelizedString += s.charAt(0).toUpperCase() + s.substring(1);
        }

        return camelizedString;
    }
});
/*  Class: Position(deprecated)
        Deprecated class to get the position of a DOM element.
    */

var Position = {
/*  
        Property: cumulativeOffset
        Returns the offset top and left values for an element. This is deprecated. You should 
        instead use <Element.getOffset> in the mootools library.
        
        Arguments:
        element - the DOM element to get the left and top values
        
        Returns:
        Array: [left, top]
        
        Example:
        >Position.cumulativeOffset(myElement);
        > > [100, 100]
    */
    cumulativeOffset: function(element) {
        return [Element.getTop(), Element.getLeft()];
    }
};
/*  Class: Event(deprecated)
        Part of the Prototype library; deprecated. You should
        instead use <Element.addEvent> from the mootools library.
    */
if (!window.Event) { var Event = new Object(); }
Object.extend(Event, {
/*  Property: element
        Deprecated, returns the target of the event (i.e. the clicked (or whatever) DOM element.
        You should instead use <Element.addEvent> from the mootools library.
        
        Parameter: 
        event - the event that fired
        
        Example:
        >Event.element(eventObject)
        > > clickedElement
    */
    element: function(event) {return event.target || event.srcElement;},
/*  Property: stop
        Stops an event monitor; deprecated. You should
        instead use <Element.addEvent> from the mootools library.
        
        Parameter:
        event - the event you wish to stop monitoring
        
        Example:
        >Event.stop(eventObject);
    */
    stop: function(event) {
        if (event.preventDefault) {event.preventDefault();event.stopPropagation();
        } else {event.returnValue = false;event.cancelBubble = true;}
    },
/*  Property: findElement
        Finds the first node with the given tagName starting from the
        node the event was triggered on; traverses the DOM upwards; deprecated.
        You should instead use <Element.getBrother>, <Element.getPrevious>, 
        <Element.getNext>, or <Element.getFirst> from the mootools library.
        
        Arguments:
        event - the event object that fired.
        tagName - the html tag name (a, div, etc.) that you want to find
    */
    findElement: function(event, tagName) {
        var element = Event.element(event);
        while (element.parentNode && (!element.tagName || (element.tagName.toUpperCase() != tagName.toUpperCase())))
            element = element.parentNode; return element;
    },
/*  Property: observe
        Observes an element for an event and then executes the passed in function, deprecated.
        You should instead use <Element.addEvent> from the mootools library.
        
        Arguments:
        element - the element you wish to monitor
        name - the event you wish to capture ("click", "load", "mouseover", etc.)
        observer - the function you wish to execute when the event fires
        useCapture - if true, handles the event in the capture phase and if false in the bubbling phase.
    */
    observe: function(element, name, observer, useCapture) {
        if (name == 'keypress' && (navigator.appVersion.match(/Konqueror|Safari|KHTML/) || element.attachEvent))
            name = 'keydown';
        if(element == window) window.addEvent(name, observer);
        else if($(element)) $(element).addEvent(name, observer);
    },
/*  Property: stopObserving
        Removes an event handler from the event, deprecated.
        You should instead use <Element.removeEvent> from the mootools library.
        
        Arguments:
        element - object or id
        name - event name (like 'click')
        observer - function that is handling the event
        useCapture - if true handles the event in the capture phase and if false in the bubbling phase.
    */
    stopObserving: function(element, name, observer, useCapture) {
        if (name == 'keypress' && (navigator.appVersion.match(/Konqueror|Safari|KHTML/) || element.detachEvent))
            name = 'keydown';
        $(element).removeEvent(name, observer);
    },
/*  Property: onDOMReady
        Executes a function when the DOM is ready; deprecated. You should use <Window.onDomReady> instad
        
        Arguments:
        function - the function you wish to execute when the DOM is ready
        
        Examples:
        >Event.onDOMReady(myFunction)
        >
        >Event.onDOMReady(function(){
        > alert('the DOM is ready');
        >});    */
    onDOMReady : function(f) {
        Window.onDomReady(f);
    }
});

/*  Class: Element(deprecated)
        These extentions are deprecated and are here for Prototype.lite backwards compatibility.
    */
Object.extend(Element, {
/*  Property: getDimensions
        Gets the width and height of the element; deprecated.
        You should instead use <Element.getDimensions> (as in $(id).getDimensions) or <Element.getStyle>.
        
        Returns:
        object - {width: #, height: #}
        
        Arguments:
        element - the element to get the dimensions.
        
        Example:
        Element.getDimensions(myDOMElement | myDOMElementId)
            */
    getDimensions: function(element) {
        return $(element).getDimensions();
    },
/*  Property: visible
        Returns true (the element is visible) or false (it is not), deprecated.
        You should instead use <Element.visible> as in $(id).visible();
        
        Returns:
        boolean - true: visible, false: hidden
        
        Arguments:
        element - the element to inspect
        
        Example:
        Element.visible(myDOMElement | myDOMElementId)
    */
    visible: function(element) {
        return $(element).visible();
    },
/*  Property: toggle
        hides/unhides an element, deprecated.
        You should instead use <Element.toggle> (as in $(id).toggle())
        
        Arguments:
        element - the element to hide/show
        
        Example:
        Element.toggle(myDOMElement | myDOMElementId)
    */
    toggle: function(element) {
        return $(element).toggle();
    },
/*  Property: hide
        hides an element; deprecated.
        You should instead use <Element.hide> (as in $(id).hide())
        
        Arguments:
        element - the element to hide
        
        Example:
        Element.hide(myDOMElement | myDOMElementId)
    */
    hide: function(element) {
        return $(element).hide();
    },
/*  Property: show
        shows an element; deprecated.
        You should instead use <Element.show> (as in $(id).show())
        
        Arguments:
        element - the element to show
        
        Example:
        Element.show(myDOMElement | myDOMElementId)
    */
    show: function(element) {
        return $(element).show();
    },
/*  Property: cleanWhitespace
        Removes all empty nodes from an element and its children, deprecated.
        You should instead use <Element.cleanWhitespace> as in ($(id).cleanWhitespace()).
        
        Arguments:
        element - the element to clean
        
        Example:
        >Element.cleanWhitespace(myDOMElement | myDOMElementId)
    */
    cleanWhitespace: function(element) {
        return $(element).cleanWhitespace();
    },
/*  Property: find
        Returns an element from the node's array (such as parentNode), deprecated.
        
        Arguments:
        element - the element you wish to find from.
        what - the value you wish to find (such as 'parentNode')
    */
    find: function(element, what) {
        return $(element).find(what);
    },
/*  Property: replace
        Replaces the element with the html you pass in, deprecated.
        You should instead use <Element.replace> (as in $(id).replace(html)).
        
        Parameters - 
        element - the element you want to replace
        html - the html you want to replace it with.
        
        Example:
        >Element.replace(myDOMElement | myDOMElementId, htmlToReplaceMyElement)
    */
    replace: function(element, html) {
        $(element).replace(html);
    },
    /*  Property: empty
            Returns a boolean; true = the node is empty, deprecated.
            You should instead use <Element.empty> (as in $(id).empty()).
            
            Arguments: 
            element - the element you wish inspect
            
            Example:
            >Element.empty(myDOMElement | myDOMElementId)
                */
    empty: function(element) {
        return $(element).empty();
    },
    /*  Property: hasClassName
            Returns a boolean; true = the node has the class name, deprecated.
            You should use <Element.hasClassName> (as in $(id).hasClassName(class)).
            
            Arguments:
            element - the element or element id you wish to inspect
            className - the class name to check for
            
            Example:
            >Element.hasClassName('myElement', 'selected') //does my element have the 'selected' class?
        */
    hasClassName: function(element, className){
        return $(element).hasClassName(className);
    }
});

/*  Class: Ajax.Request (deprecated)
        This a compatability syntax for Prototype.js Ajax requests; you should use <Ajax> in Mootools.
    */
Ajax.Request = new Class({
  initialize: function(url, options) {
        if(options.parameters) url += "?"+options.parameters;
        dbug.log('using legacy Ajax.Request object\n options: %1.o', options);
        if(options.onComplete){
            this.onCompleteFunction = options.onComplete;
            options.onComplete = this.onComplete.bind(this);
        }
        if(options.onFailure){
            this.onFailureFunction = options.onComplete;
            options.onFailure = this.onFailure.bind(this);
        }
        this.ajax = new ajax(url,options);
    this.transport = (ajax).transport;
  },
    
    onComplete: function() {
        if(this.onCompleteFunction && this.ajax.responseIsSuccess())
            this.onCompleteFunction(this.ajax.transport);
    },
    onFailure: function() {
        if(this.onFailureFunction && this.ajax.responseIsFailure())
            this.onFailureFunction(this.ajax.transport);
    },

  request: function(url) {
    this.ajax.request(url);
  },

  header: function(name) {
    try {
      return this.ajax.transport.getResponseHeader(name);
    } catch (e) {}
  },

  evalJSON: function() {
    try {
      return Json.evaluate(this.ajax.header('X-JSON'));
    } catch (e) {}
  },

  evalResponse: function() {
    try {
      return Json.evaluate(this.ajax.transport.responseText);
    } catch (e) {
      this.dispatchException(e);
    }
  },

  dispatchException: function(exception) {
    (this.options.onException || Prototype.emptyFunction)(this, exception);
    Ajax.Responders.dispatch('onException', this, exception);
  }
});
/*  Class: Ajax.Updater (deprecated)
        This a compatability syntax for Prototype.js Ajax requests; you should use <Ajax> in Mootools.
    */
Ajax.Updater = Ajax.Request.extend({
  initialize: function(container, url, options) {
        if(options.parameters) url += "?"+options.parameters;
        dbug.log('using legacy Ajax.Updater object\n options: %1.o', options);
        this.options = options;
    this.onComplete = options.onComplete || Class.empty;
    this.options.onComplete = (function(transport, object) {
      this.updateContent();
      this.onComplete(transport, object);
    }).bind(this);
    this.containers = {
      success: container.success ? $(container.success) : $(container),
      failure: container.failure ? $(container.failure) :
        (container.success ? null : $(container))
    };
        this.options.fireNow = false;
        this.ajax = new ajax(url,options);
    this.transport = this.ajax.transport;
        this.ajax.request();
  },

  updateContent: function() {
    var receiver = this.ajax.responseIsSuccess() ?
      this.containers.success : this.containers.failure;
    var response = this.transport.responseText;

    if (!this.options.evalScripts)
      response = response.stripScripts();

    if (receiver) {
      $(receiver).setHTML(response);
    }
  }
});

/* do not edit below this line */   
/* Section: Change Log 

$Source: /cvs/webapps/www-rb-api/resources/js/cnet.framework.dasher.js,v $
$Log: not supported by cvs2svn $
Revision 1.2  2007/01/30 02:24:22  grahamb
commented out console.log calls since they were failing in IE7

Revision 1.1  2006/12/20 01:48:03  grahamb
initial check-in

Revision 1.6  2006/11/21 23:56:57  newtona
bug fixes for onComplete functionality

Revision 1.5  2006/11/17 19:58:18  newtona
syntax fixes

Revision 1.4  2006/11/17 19:41:49  newtona
updating prototype compatability; switching onDOMReady to use Mootools, adding ajax compatability

Revision 1.3  2006/11/17 19:39:33  newtona
updating prototype compatability; switching onDOMReady to use Mootools, adding ajax compatability

Revision 1.2  2006/11/02 21:34:40  newtona
added cvs footer


*/
/*  Script: function.cnet.js
        Extends functionality in Mootools <Function.js>
        
        Dependencies:
        <Moo.js>, <Function.js>
        
        Author:
        Aaron Newton - aaron [dot] newton [at] cnet [dot] com

        Function: $type
        Extends the <$type> function in <Function.js>

        Property: isNumber
        Determines if a value is a number. If the value is a string, if the string will parse
        to a number, returns true.
        
        Arguments:
        val - the object to asses.
        
        Example:
        >$type.isNumber(myValue) //if it's a number, returns true
    */
        $type.isNumber = function(val) {
            if((typeof val != "undefined" && typeof val == "number") ||
            (typeof val != "boolean" && (typeof val != "string" || val.length >0) && isFinite(new Number(val)))) return true;
            return false;
        };

/*  Property: isSet
        Determines if a value is defined.
        
        Arguments:
        val - the object to asses
        
        Example:
        >$type.isSet(myValue) //if it's not undefined or null, returns true
    */      
        $type.isSet = function(val){
            return (typeof val != "undefined" && val != null);
        };
/*  Function:   $set
        returns a value if it's defined, otherwise sets it to a default and returns it.
        
        Arguments:
        val - the value to test
        defaultVal - the default value to set val to, if it's undefined
        
        Examples:
        (start code)
if($set(myVal, false)) .... 
    // if myVal is defined, evaluate it and then execute my code or 
    //don't, otherwise set it to false and evaluate that.
        (end)
*/
        function $set(val, defaultVal){
            return $type.isSet(val)?val:defaultVal;
        };
        $pick = $set;
        
/* do not edit below this line */   
/* Section: Change Log 

$Source: /cvs/webapps/www-rb-api/resources/js/cnet.framework.dasher.js,v $
$Log: not supported by cvs2svn $
Revision 1.2  2007/01/30 02:24:22  grahamb
commented out console.log calls since they were failing in IE7

Revision 1.1  2006/12/20 01:48:03  grahamb
initial check-in

Revision 1.6  2006/12/06 20:14:59  newtona
carousel - improved performance, changed some syntax, actually deployed into usage and tested
cnet.nav.accordion - improved css selectors for time
multiple accordion - fixed a typo
dbug.js - added load timers
element.cnet.js - changed syntax to utilize mootools more effectively
function.cnet.js - equated $set to $pick in preparation for mootools v1

Revision 1.5  2006/12/04 18:36:52  newtona
syntax error in the docs

Revision 1.4  2006/11/15 01:18:45  newtona
updated docs

Revision 1.3  2006/11/13 22:56:01  newtona
added function $set

Revision 1.2  2006/11/02 21:34:00  newtona
Added cvs footer


*/
/*  Script: array.cnet.js
Extends the array prototype.

Dependancies:
     no dependencies.
    
Author:
    Aaron Newton, <aaron [dot] newton [at] cnet [dot] com>
    


Class: Array
        This extends the <Array> class.
    */

Array.extend({
/*  Property: indexOf
        Returns the index of an item in an array.
        
        Parameters:
        item - the item you wish to find in the array.
        from - (optional) index to start your search (defaults to zero)
        
        Credits:
        Props to Chris on Mootools form: http://forum.mootools.net/profile.php?id=14
        
        Example:
        >myArray.indexOf(x)
        > -1 (the item is not in the array) | # (the index of the item)
    */
    indexOf: function(item, from) {
    from = from || 0;
    if (from < 0) {
        from = this.length + from;
        if(from < 0) from = 0;
    }
    while (from < this.length){
        if(this[from] === item) return from;
        from++;
    }
    return -1;
    }
});
/* do not edit below this line */   
/* Section: Change Log 

$Source: /cvs/webapps/www-rb-api/resources/js/cnet.framework.dasher.js,v $
$Log: not supported by cvs2svn $
Revision 1.2  2007/01/30 02:24:22  grahamb
commented out console.log calls since they were failing in IE7

Revision 1.1  2006/12/20 01:48:03  grahamb
initial check-in

Revision 1.3  2006/11/22 02:07:09  newtona
better array.indexOf

Revision 1.2  2006/11/02 21:34:00  newtona
Added cvs footer


*/
/*  Script: window.cnet.js
Extends the Mootools <Window> class.

Class: Window
        This extends the <Window> class from the <http://mootools.net> library.
    */
Window.extend({
/*  property: isLoaded
        The loaded state of the DOM; true (it's loaded) or false.
        
        Example:
        >if (Window.isLoaded) ...
    */
    isLoaded: false,
/*  Property: getHost   
        Returns the domain of the window or the passed in url.
        
        Arguments:
        url (optional) - the url you wish to get the host for (otherwise Window.getHost
                            returns the host of the current window location).
*/
    getHost:function(url){
        url = $set(url, window.location.href);
        var host = url;
        if(url.indexOf('http://') >= 0){
            url = url.substring(url.indexOf('http://')+7,url.length);
            if(url.indexOf(':')) url = url.substring(0, url.indexOf(":"));
            if(url.indexOf('/'))
                return url.substring(0,url.indexOf('/'));
            return url;
        }
        return false;
    },
/*  Property: getQueryStringValue
        Returns a specific query string value from the window location.
        
        Arguments:
        key - the key to search for in the query string
        
        Example:
(start code)
//window.location is http://www.example.com/?this=that&something=else
var something = Window.getQueryStringValue("something");
> something = "else"
(end)
    */
    getQueryStringValue: function(key) {
        var qs = window.location.search; //get the query string
        if(qs == "") return null; //if there isn't one, return null
        if(qs.indexOf("?") == 0)qs = qs.substring(1, qs.length); //remove the question mark
        return qs.parseQuery()[key];
    },
    
/*  Property: getPort
        Returns the port number of the window location.
        
        Arguments
        url - (optional) the url to test for a port; defaults to the window location.
        
        Example:
        (start code)
//window.location.href is http://www.example.com:8001/blah.html
Window.getPort()
> 8001
        (end)
    */
    getPort: function(url) {
        url = $set(url, window.location.href);
        var re = new RegExp(':([0-9]{4})');
        var m = re.exec(url);
      if (m == null) return false;
      else {
            var port = false;
            m.each(function(val){
                if($type.isNumber(val)) port = val;
            });
      }
        return port;
    },
    /*  
        Property: disableIEBgCache
        IE has a bug where DOM elements with backgrounds that are modified
    such as changing the opacity or floating something over them will
        cause the background to flicker. To get around this, you have to
        turn the background cache off. This is a page-wide function. The
        downside is that if you try and dynamically change the background
        of a css class (such as with the hover state:
        div:hover {background:...changes}
        it won't happen in IE. This means you have to do this kind of thing
        with javascript by changing an element's class from one to another.
        
        This is an extention to the <http://mootools.net> <Window> class.
        
        See also: mootools: element.addClassName(class) & .removeClassName(class)
        
        You can turn this back on at any point by calling
        >Window.disableIEBgCache(false);
        
        Arguments:
        boolean - true: turn the cache on, false: disable the cache
        
        See also: <Window>
    */
    disableIEBgCache:function(disable){
        try {   
            document.execCommand('BackgroundImageCache', false, disable);
        } catch(e) {}
    }
});
//set up Window.isLoaded - a boolean
try {
    Event.onDOMReady(function() { Window.isLoaded = true });
} catch (e) {
    Event.observe(window, "load", function() { Window.isLoaded = true });
}
Window.disableIEBgCache(true);


/*  Class: Window.popup
This class opens a popup window with the passed in values.
        
Arguments
    url - the destination for the popup
    options - an object containing key/value options
    
Options:
    width - (integer) the width of the window; defaults to 500
    height - (integer) the height of the window; defaults to 300
    x - (integer) the offest from the left of the screen; defaults to 50
    y - (integer) the offset from the top of the screen; defaults to 50
    toolbar - (integer) show the browser toolbar in the window; 
            0 (zero) does not show it, 1 (one) does; defaults to 0 (zero)
    location - (integer) show the location in the browser;
            0 does not show it; defautls to 0
    directories - (integer) show the directories in the browser;
            0 does not show it; defautls to 0
    status - (integer) show the status bar in teh browser;
            0 does not show it; defautls to 0
    scrollbars - (string) 'auto' shows the scroll bars if they are required,
            'no' shows none, 'yes' shows them all the time
    resizeable - (integer) lets the user resize the window;
            1 allows resizeing; defaults to 1
    name - (string) the name of the popup; defaults to "popup"
    
    Examples:
    (start code)
var myPopup = new Window.popup('http://www.example.com'); //opens with default parameters

var myPopup = new Window.popup('http://www.example.com', {
    width: 300,
    height: 800,
    x: 500,
    toolbar: 1
}); //launch a window with custom properties
    (end)

    Property: window
    The window object itself (the popup). The class Window.popup opens a new browser window. The pointer to this
    window can be reached like so:
    (start code)
    var myPopup = new Window.popup('http://www.example.com');
    myPopup.window // this is the reference to the popup itself.
    (end)
    
    Note that if you call this class with the same name (the default name is 'popup') as an already open window
    you won't open a new popup window, but instead will send your url to the existing window. You should probably
    give it something unique so you can have more than one if you need. 

    Example:
    (start code)
    var myPopup = new Window.popup('http://www.example.com'); //default name for the popup is "popup"
    var anotherPopup = new Window.popup('http://www.example2.com'); //you just refreshed the "popup" window with this new url
    (end)
    
    This actually represents a way to keep refering to the same window that's already open. So long as the window
    calling it is the same window that opened the popup to begin with (even if the user goes to another page), the
    above code will always re-acquire the already open popup.
    
    Example:
    (start code)
    //page loads
    var myPopup = new Window.popup('http://www.example.com'); //default name for the popup is "popup"
    
    //user goes to another page, and, when that page loads, this happens again
    var myPopup = new Window.popup('http://www.example.com'); //default name for the popup is "popup"
    (end)
    
    The result is you just refreshed the already open window with the same url. There are ways to do this
    without refreshing, but not with this class (yet).
    */
Window.popup = new Class({
    setOptions: function(options) {
        this.options = Object.extend({
            width: 500,
            height: 300,
            x: 50,
            y: 50,
            toolbar: 0,
            location: 0,
            directories: 0,
            status: 0,
            scrollbars: 'auto',
            resizeable: 1,
            name: 'popup'
        }, options || {});
    },
    initialize: function(url, options){
        this.url = url || false;
        this.setOptions(options);
        if(this.url) this.openWin();
    },
    openWin: function(url){
        url = url || this.url;
        this.window = window.open(url,
            this.options.name,
            'toolbar='+this.options.toolbar+
            ',location='+this.options.location+
            ',directories='+this.options.directories+
            ',status='+this.options.status+
            ',scrollbars='+this.options.scrollbars+
            ',resizable='+this.options.resizeable+
            ',width='+this.options.width+
            ',height='+this.options.height+
            ',top='+this.options.y+
            ',left='+this.options.x);
        this.focus();
        return this.window;
    },
/*  Property: focus
        Focus the window related to the Window.popup object.
        
        Example:
        (start code)
var myPopup = new Window.popup('http://www.example.com'); //opens with default parameters
myPopup.focus(); //bring it to the front
        (end)
        
        Note:
        When you create a new popup it calls .focus() on itself immediately by default.
    */
    focus: function(){
        this.window.focus();
    },
/*  Property: close
        Closes the popup window related to the Window.popup object.

        Example:
        (start code)
var myPopup = new Window.popup('http://www.example.com'); //opens with default parameters
myPopup.close(); //close the window
        (end)

    */
    close: function(){
        this.window.close();
    }
});
/*  Class: legacyPopup
        A legacy instance of <Window.popup> that defaults to a specific width and height; not intended for use. */
var legacyPopup = Window.popup.extend({
    setOptions: function(){
        this.parent();
        this.options = Object.extend({
            width: 516, 
            height: 350
        }, this.options);
    }
});

/*  Function: openPop
        An instance of <legacyPopup>; not intended for actual use.
    */
function openPop(url){
    return new legacyPopup(url);
}

/*  Function: GetValue
        Legacy syntax for Window.getQueryStringValue; deprecated.
    */
var GetValue = Window.getQueryStringValue;
    
/* do not edit below this line */   
/* Section: Change Log 

$Source: /cvs/webapps/www-rb-api/resources/js/cnet.framework.dasher.js,v $
$Log: not supported by cvs2svn $
Revision 1.2  2007/01/30 02:24:22  grahamb
commented out console.log calls since they were failing in IE7

Revision 1.1  2006/12/20 01:48:03  grahamb
initial check-in

Revision 1.9  2006/11/27 19:34:32  newtona
changed the line about firefox bugs; this comment was misleading. no functional changes.

Revision 1.8  2006/11/26 00:28:19  newtona
forgot about ports in getHost... fixed

Revision 1.7  2006/11/26 00:26:35  newtona
ok. actually *fixed* the bug with getHost

Revision 1.6  2006/11/26 00:16:48  newtona
fixed conditional bug in Window.getHost

Revision 1.5  2006/11/16 18:50:40  newtona
fixed a syntax error in getQueryStringValue

Revision 1.4  2006/11/15 01:19:49  newtona
added Window.getQueryStringValue

Revision 1.3  2006/11/04 00:54:35  newtona
added Widnow.getPort()

Revision 1.2  2006/11/02 21:34:00  newtona
Added cvs footer


*/
/*  Script: string.cnet.js
        These are mootools authored extensions designed to allow prototype.lite libraries run in this environment.

Dependancies:
     mootools - <Moo.js>, <String.js>, <Array.js>, <Function.js>, <Element.js>, <Dom.js>

Author:
    Aaron Newton, <aaron [dot] newton [at] cnet [dot] com>
    

        Class: String
        This extends the <String> prototype.
    */
String.extend({
/*  Property: stripTags
        Remove all html tags from a string. */
    stripTags: function() {
    return this.replace(/<\/?[^>]+>/gi, '');
  },
/*  Property: stripScripts
        Removes all script tags from an HTML string.
    */
    stripScripts: function() {
        return this.replace(new RegExp(Prototype.ScriptFragment, 'img'), '');
    },
/*  Property: evalScripts
        Executes scripts included in an HTML string.
    */
    evalScripts: function() {
        if(scripts = this.match(/<script[^>]*?>.*?<\/script>/g)){
            scripts.each(function(script){
                eval(script.replace(/^<script[^>]*?>/, '').replace(/<\/script>$/, ''));
            });
        }
    },
/*  Property: replaceAll
        Replaces all instances of a string with the specified value.
        
        Arguments:
        searchValue - the string you want to replace
        replaceValue - the string you want to insert in the searchValue's place
        
        Example:
        >"I like cheese".replaceAll("cheese", "cookies");
        > > I like cookies  */
    replaceAll: function(searchValue, replaceValue) {
        var replaceRegex = new RegExp(searchValue,"g");
        var parsed = this.replace(replaceRegex, replaceValue);
        return parsed;
    },
/*  Property: urlEncode
        urlEncodes a string (if it is not already).
        
        Example:
        > "Mondays aren't that fun".urlEncode()
        > > Mondays%20aren%27t%20that%20fun
    */
    urlEncode: function() {
        if (this.indexOf('%') > -1) return this;
        else return escape(this);
    },
/*  Property: parseQuery
        Turns a query string into an associative array of key/value pairs.
        
        Example:
(start code)
"this=that&what=something".parseQuery()
> { this: "that", what: "something" }

var values = "this=that&what=something".parseQuery();
> values.this > "that"
(end)
    */
    parseQuery: function() {
    var pairs = this.match(/^\??(.*)$/)[1].split('&');
        var params = {};
        pairs.each(function(pair) {
      pair = pair.split('=');
      params[pair[0]] = pair[1];
    });
        return params;
    }
});
/* do not edit below this line */   
/* Section: Change Log 

$Source: /cvs/webapps/www-rb-api/resources/js/cnet.framework.dasher.js,v $
$Log: not supported by cvs2svn $
Revision 1.2  2007/01/30 02:24:22  grahamb
commented out console.log calls since they were failing in IE7

Revision 1.1  2006/12/20 01:48:03  grahamb
initial check-in

Revision 1.3  2006/11/15 01:19:19  newtona
added String.parseQuery

Revision 1.2  2006/11/02 21:34:00  newtona
Added cvs footer


*/
/*  Script: element.cnet.js
Extends the <Element> object.

Dependancies:
     mootools - <Moo.js>, <String.js>, <Array.js>, <Function.js>, <Element.js>, <Dom.js>

Author:
    Aaron Newton, <aaron [dot] newton [at] cnet [dot] com>
    
Class: Element
        This extends the <Element> prototype.
    */
Element.extend({
/*  Property: getDimensions
        Returns width and height for element; if element is not visible the element is
        cloned off screen, shown, measured, and then removed.
        
        Returns:
        An object with .width and .height defined as integers.
        
        Example:
        >$(id).getDimensions()
        > > {width: #, height: #}
    */
    getDimensions: function() {
        var w = this.getStyle('width', true);
        var h = this.getStyle('height', true);
        if((w == 0 || $type(w) != 'number')||(h == 0 || !$type(h) != 'number')){
            var holder = new Element('div').setStyles({
                'position':'absolute',
                'top':'-1000px',
                'left':'-1000px'
            }).injectAfter(this);
            var clone = this.clone().injectInside(holder).show();
            w = clone.offsetWidth;
            h = clone.offsetHeight;
            holder.remove();
        }
        return {width: w, height: h};
    },
/*  Property: visible
        Returns a boolean; true = visible, false = not visible.
        
        Example:
        >$(id).visible()
        > > true | false    */
    visible: function() {
        return this.getStyle('display') != 'none';
    },
/*  Property: toggle
        Toggles the state of an element from hidden (display = none) to 
        visible (display = what it was previously or else display = block)
        
        Example:
        > $(id).toggle()
    */
    toggle: function() {
        return this[this.visible() ? 'hide' : 'show']();
    },
/*  Property: hide
        Hides an element (display = none)
        
        Example:
        > $(id).hide()
        */
    hide: function() {
        this.originalDisplay = this.getStyle('display'); 
        this.setStyle('display','none');
        return this;
    },
/*  Property: show
        Shows an element (display = what it was previously or else display = block)
        
        Example:
        >$(id).show() */
    show: function(display) {
        this.setStyle('display',(display || this.originalDisplay || 'block'));
        return this;
    },
/*  Property: cleanWhitespace
        Removes all empty text nodes from an element and its children
        
        Example:
        > $(id).cleanWhitespace()   */
    cleanWhitespace: function() {
        $A(this.childNodes).each(function(node){
            if (node.nodeType == 3 && !/\S/.test(node.nodeValue)) node.parentNode.removeChild(node);
        });
        return this;
    },
/*  Property: find
        Returns an element from the node's array (such as parentNode), deprecated (left over from Prototype.lite).
        
        Arguments:
        what - the value you wish to find (such as 'parentNode')

        Example:
        > $(id).find(parentNode)
    */
    find: function(what) {
        var element = this[what];
        while (element.nodeType != 1) element = element[what];
        return element;
    },
/*  Property: replace
        Replaces an html element with the html passed in.
        
        Arguments:
        html - the html with which to replace the node.
        
        Example:
        >$(id).replace(myHTML) */
    replace: function(html) {
        if (this.outerHTML) {
            this.outerHTML = html.stripScripts();
        } else {
            var range = this.ownerDocument.createRange();
            range.selectNodeContents(this);
            this.parentNode.replaceChild(
                range.createContextualFragment(html.stripScripts()), this);
        }
        html.evalScripts.delay(10);
    },
/*  Property: empty
        Returns a boolean: true = the Node is empty, false, it isn't.
        
        Example:
        > $(id).empty
        > true (the node is empty) | false (the node is not empty)
    */
    empty: function() {
        return !!this.innerHTML.match(/^\s*$/);
    },
    /*  Property: getOffsetHeight
            Returns the offset height of an element, deprecated.
            You should instead use <Element.getStyle>('height')
            or just Element.offsetHeight.
            
            Example:
            > $(id).getOffsetHeight()
        */
    getOffsetHeight: function(){ return this.offsetWidth; },
    /*  Property: getOffsetWidth
            Returns the offset width of an element, deprecated.
            You should instead use <Element.getStyle>('width')
            or just Element.offsetWidth.
            
            Example:
            > $(id).getOffsetWidth()
        */
    getOffsetWidth: function(){ return this.offsetWidth; }
});
/* do not edit below this line */   
/* Section: Change Log 

$Source: /cvs/webapps/www-rb-api/resources/js/cnet.framework.dasher.js,v $
$Log: not supported by cvs2svn $
Revision 1.2  2007/01/30 02:24:22  grahamb
commented out console.log calls since they were failing in IE7

Revision 1.1  2006/12/20 01:48:03  grahamb
initial check-in

Revision 1.4  2006/12/06 20:14:59  newtona
carousel - improved performance, changed some syntax, actually deployed into usage and tested
cnet.nav.accordion - improved css selectors for time
multiple accordion - fixed a typo
dbug.js - added load timers
element.cnet.js - changed syntax to utilize mootools more effectively
function.cnet.js - equated $set to $pick in preparation for mootools v1

Revision 1.3  2006/11/27 17:59:32  newtona
small change to replace and the way it uses timeouts

Revision 1.2  2006/11/02 21:34:00  newtona
Added cvs footer


*/
/*  Script: cookie.cnet.js
        This is an extension to the <http://mootools.net> 
        library, specifically, the <Cookie> class.
        
Dependancies:
     mootools - <Moo.js>, <String.js>
     cnet libraries - <dbug.js>
    
Author:
    Aaron Newton, <aaron [dot] newton [at] cnet [dot] com>

    
Class: Cookie
This class implements the <Cookie> class from Mootools.
*/
Cookie = Object.extend(Cookie, {
/*  
Property: set
        CNET Cookie creator function; allows for domain setting in 
        the cookie (optional). 
        
        Syntax:
        same as mootools, but you can pass in an optional
        fourth value, the domain for the cookie you are setting.
        
        Example:
        > Cookie.set('mySetting', 'myValue', 1, 'cnet.com')
        result:
        if you set this at reviews.cnet.com, other subdomains
             will be able to access it.
        
        See also: <Cookie.js>
    */
    set: function(key,value,duration,domain) {
        var date = new Date();
        date.setTime(date.getTime()+((duration || 365)*86400000));
        this.value = key+"="+value+"; expires="+date.toGMTString()+"; path=";
        this.value += domain || "/";
        document.cookie = this.value;
    },
    remove: function(key, domain){
        this.set(key, '', -1, domain);
    }
});
//setCookie and getCookie are functions we used to use with the same
//syntax, so this just makes those calls compatible.
var setCookie = Cookie.set;
var getCookie = Cookie.get;
var writeCookie = Cookie.set;
var rbSetCookie = Cookie.set;
//rbGetCookie and rbSetCookie are just legacy namespaces
function rbGetCookie(key) {
     var val = Cookie.get(key);
     if($type(val)) return unescape(val);
     else return false;
}
/* do not edit below this line */   
/* Section: Change Log 

$Source: /cvs/webapps/www-rb-api/resources/js/cnet.framework.dasher.js,v $
$Log: not supported by cvs2svn $
Revision 1.2  2007/01/30 02:24:22  grahamb
commented out console.log calls since they were failing in IE7

Revision 1.1  2006/12/20 01:48:03  grahamb
initial check-in

Revision 1.4  2006/11/14 02:07:02  newtona
rewrote Cookie.set; fixed a bug and made it tidier

Revision 1.3  2006/11/13 23:54:58  newtona
fixed a bug (referred to "days" instead of "duration")

Revision 1.2  2006/11/02 21:34:00  newtona
Added cvs footer


*/
/*  
Script: ajax.cnet.js
This is an extension to the Ajax class in the <http://mootools.net> library.

Dependancies:
     mootools - <Moo.js>, <String.js>, <Array.js>, <Function.js>, <Element.js>
     cnet libraries - <dbug.js>
    
Author:
    Aaron Newton, <aaron [dot] newton [at] cnet [dot] com>

        Additional Options: 
        onFailure - This extention adds the ability to pass in an _onFailure_ function
        that will fire if the ajax call fails. Additionally, it will check
        the response to see if the page failed. it will look for the
        presence of "COMPONENT_RESPONSE_CODE" in the returned document
        and if presence, look for "COMPONENT_RESPONSE_CODE=200". This will
        allow you to detect when our server returns our page not found
        document, as our server doesn't post a 404 header with it. Finally, it will
        check for the strings "<title>Page Not Found" and "errorPageSearchForm"
        in the source returned, as 404 pages on CNET and Download.com don't seem
        to identify themselves in any other way...
        
        fireNow - Finally, an additional option can be passed in: fireNow: true/false
        if true, the request will fire automatically. This is really a legacy
        thing. Instead you should do this:

        > var myAjax = new Ajax(url, {options}).request();
        
        to fire automatically. You do not have to assign the object (var myAjax)
        but you'll need it if you want to query the status of it later.
        
        Example instantiation:
        >new Ajax(myurl, {onComplete: myFunction, onFailure: myErrorHandler, method: 'get'});
        
        See Also: <Ajax>
*/
Ajax.implement({
    initialize: function(url, options){
        this.setOptions(options);
        this.options.postBody = $set(this.options.postBody, 'postBody is empty; this string added due to a FF bug; ignored');
        this.url = url;
        this.transport = this.getTransport();
        this.options.fireNow = $set(this.options.fireNow, true);
        this.tried = 0;
        if(this.options.fireNow) this.autoRequest.delay(200, this);
    },
    autoRequest: function(){
        if(this.tried < 10 && this.responseIsFailure()){
            this.tried++;
            (function(){
                try{
                    this.request();
                }catch(e){
                    dbug.log("error; auto fire trying again momentarily. error: %s", e);
                    this.autoRequest();
                }
            }).delay(50, this);
        } else
            dbug.log('unable to fire ajax automatically');
    },
    responseIsSuccess: function(status){
        try {
            if(this.transport.readyState != 4 || 
                 this.transport.status == "undefined" || 
                (this.transport.status < 200 || this.transport.status >= 300)) 
                    return false;

            //console.log('error search form: %s', !!this.transport.responseText.test('errorPageSearchForm'));
            if((!this.transport.responseText.test("COMPONENT_RESPONSE_CODE") ||
                     this.transport.responseText.test("COMPONENT_RESPONSE_CODE=200")) &&
                     !this.transport.responseText.test("<title>Page Not Found") && 
                     !this.transport.responseText.test('errorPageSearchForm')) {
                    dbug.log('ajax request successful');
                    return true;
            }
            dbug.log('ajax request failed');
            return false;
        } catch(e) {
            return false;
        }
    },
    responseIsFailure: function(){
        return !this.responseIsSuccess();       
    },
    onStateChange: function(){
        if (this.transport.readyState == 4 && this.responseIsSuccess()){
            if (this.options.update) $(this.options.update).setHTML(this.transport.responseText);
            this.options.onComplete.pass([this.transport.responseText, this.transport.responseXML], this).delay(20);
            if (this.options.evalScripts) this.evalScripts.delay(30, this);
            this.transport.onreadystatechange = Class.empty;
            this.callChain();
        } else if(this.transport.readyState == 4 && this.responseIsFailure()) {
            //console.log('on failure: %s', this.options.onFailure);
            if($type(this.options.onFailure)=='function') this.options.onFailure.pass(this.transport, this).delay(20);
        }
    }
});
/* do not edit below this line */   
/* Section: Change Log 

$Source: /cvs/webapps/www-rb-api/resources/js/cnet.framework.dasher.js,v $
$Log: not supported by cvs2svn $
Revision 1.2  2007/01/30 02:24:22  grahamb
commented out console.log calls since they were failing in IE7

Revision 1.1  2006/12/20 01:48:03  grahamb
initial check-in

Revision 1.4  2006/11/27 19:34:32  newtona
changed the line about firefox bugs; this comment was misleading. no functional changes.

Revision 1.3  2006/11/17 02:49:14  newtona
modified cnet.ajax to handle automatic firing a little more gracefully
modified dom.js to fix a bug with css selectors

Revision 1.2  2006/11/02 21:34:00  newtona
Added cvs footer


*/
/*
Script: fixpng.js

Dependancies:
     mootools - <Moo.js>, <String.js>, <Array.js>, <Function.js>, <Element.js>, <Dom.js>
    
Author:
    Aaron Newton, <aaron [dot] newton [at] cnet [dot] com>

        Function: fixPNG
        this will make transparent pngs show up correctly in IE. This function 
        is based almost entirely on the function found here: 
        <http://homepage.ntlworld.com/bobosola/pnginfo.htm>
        
        Arguments:
        myImage - the image element or id to fix
        
        Note: 
        there is an instances of this already set to fire onDOMReady that
        will fix any png files with the class "fixPNG". This means any producer
        can just give the class "fixPNG" to any img tag and they are set BUT, the
        ping will look wrong until the DOM loads, which may or may not be noticeable.
        
        The alternative is to embed the call right after the image like so:
        
        ><img src="png1.png" width="50" height="50" id="png1">
        ><img src="png2.png" width="50" height="50" id="png2">
        ><script>
        >   $S('#png1', '#png2').each(function(png) {fixPNG(png);});
        >   //OR
        >   fixPNG('png1');
        >   fixPNG('png2');
        ></script>
*/

function fixPNG(myImage) 
{
    try {
        var arVersion = navigator.appVersion.split("MSIE");
        var version = parseFloat(arVersion[1]);
        if ((version >= 5.5) && (version < 7) && (document.body.filters)){
            myImage = $(myImage);
            var vis = myImage.visible();
            if(!vis) myImage.show();
            var width = $(myImage).offsetWidth;
            var height = $(myImage).offsetHeight;
            if(!vis) myImage.hide();
            var imgID = (myImage.id) ? "id='" + myImage.id + "' " : "";
            var imgClass = (myImage.className) ? "class='" + myImage.className + "' " : "";
            var imgTitle = (myImage.title) ? "title='" + myImage.title  + "' " : "title='" + myImage.alt + "' ";
            var imgStyle = "display:inline-block;" + myImage.style.cssText;
            var strNewHTML = "<span " + imgID + imgClass + imgTitle
                                    + " style=\"" + "width:" + width 
                                    + "px; height:" + height 
                                    + "px;" + imgStyle + ";"
                                    + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
                                    + "(src=\'" + myImage.src + "\', sizingMethod='scale');\"></span>";
            myImage.outerHTML = strNewHTML;
        }
    } catch(e) {}
};
Event.onDOMReady(function(){$S('img.fixPNG').each(function(png){fixPNG(png)});});
/* do not edit below this line */   
/* Section: Change Log 

$Source: /cvs/webapps/www-rb-api/resources/js/cnet.framework.dasher.js,v $
$Log: not supported by cvs2svn $
Revision 1.2  2007/01/30 02:24:22  grahamb
commented out console.log calls since they were failing in IE7

Revision 1.1  2006/12/20 01:48:03  grahamb
initial check-in

Revision 1.2  2006/11/02 21:26:42  newtona
checking in commerce release version of global framework.

notable changes here:
cnet.functions.js is the only file really modified, the rest are just getting cvs footers (again).

cnet.functions adds numerous new classes:

$type.isNumber
$type.isSet
$set

*//*
Script: iframeshim.js
Iframe shim class for hiding elements below a floating DOM element.

Dependancies:
     mootools - <Moo.js>, <String.js>, <Array.js>, <Function.js>, <Element.js>, <Dom.js>

Author:
    Aaron Newton, <aaron [dot] newton [at] cnet [dot] com>


Class: iframeShim
        There are two types of elements that (sometimes) prohibit you from 
        positioning a DOM element over them: some form elements and some
        flash elements. The two options you have are:
            - to hide these elements when your dom is going to be over them; 
            this works if you know your DOM element is going to completely
            obscure that element
            
            - an iframe shim - where you put an iframe below your element but
            ABOVE the form/flash element. more details here:
            http://www.macridesweb.com/oltest/IframeShim.html
            
        The iframeShim class handles a lot of the dirty work for you.
Arguments:
            element -  the element you want to put this shim under
            display -  turn it on by default?
            name -  the id you want to give the new DOM element of the iframe shim
            zindex -  the index of the shim; optional, default is 1 less than the element
            margin -  make the iframe smaller than the element to give a buffer (for 
                            things like shadows)
            offset -  {top:#, left:#} - move the iframe up/down, left/right relative to 
                            the element
        
        then, when you make your floating DOM show up you just execute .hide() or .show()
        to make the shim do it's magic. You can also call .position() if the element the
        shim is supposed to be under happens to move.
        
        example:
        
        > <div id="myFloatingDiv">stuff</div>
        > <script>
        >   var myFloatingDivShim = new iframeShim({
        >       element: 'myFloatingDiv',
        >       display: false,
        >       name: 'myFloatingDivShimId'
        >   });
        >   function showMyFloatingDiv(){
        >       $('myFloatingDiv').show();
        >       myFloatingDivShim.show();
        >   }
        > </script>
        
        See also <hide>, <show>, <position>
    */
    
var iframeShim = new Class({
    initialize: function (options){
        this.options = options;
        el = options.element;
        var shim = new Element('iframe');
        this.id = options.name + "_shim";
        shim.id = this.id;
        try{
            if(!$(el).getStyle('z-Index'))
                $(el).setStyle('z-Index',0);
        }catch(e){
            $(el).setStyle('z-Index',0);
        }
        shim.setStyles({
            'position': 'absolute',
            'zIndex': $(el).getStyle('z-Index')-1,
            'border': 'none',
            'filter': 'progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)'
        });
        shim.setAttribute('src', 'javascript:void(0);');
        shim.setAttribute('frameborder', '0');
        shim.setAttribute('scrolling', 'no');
        shim.inject(el,'after');
        if(options.display) this.show();
        else this.hide();
        shim = null;
    },

/*  
        Property: position
        This will reposition the iframe element. Call this when you move or resize
        the iframe element.
    */
    position: function(shim){
        shim = shim || this.id;
        var el = this.options.element;
        var wasVis = $(el).visible();
        if(! wasVis) $(el).show();
        this.left = $(el).getLeft();
        this.top = $(el).getTop();
        this.width = $(el).offsetWidth;
        this.height = $(el).offsetHeight;
        if(! wasVis) $(el).hide();
        if($type(this.options.margin)){
            this.width = this.width-(this.options.margin*2);
            this.height = this.height-(this.options.margin*2);
            this.left = this.left + this.options.margin;
            this.top = this.top + this.options.margin;
        }
        if($type(this.options.offset)){
            this.left = this.left-this.options.offset.left;
            this.top = this.top-this.options.offset.top;
        }
        $(shim).setStyles({
            'left': this.left + 'px',
            'width': this.width + 'px',
            'height': this.height + 'px',
            'top': this.top + 'px'
        });
    },
/*  
        Property: hide
        This will hide the iframeshim object. If you don't call this when you
        hide the element that's over the flash or select list, then that thing
        will still be hidden.
    */
    hide: function(){
        $(this.id).hide();
    },

/*  
        Property: show
        This will obscure any form elements or flash elements below the iframe
        shim element. Call this when you show your floating element.
    */
    show: function(){
        $(this.id).show();
        this.position();
    },
/*  
        Property: remove
        This will remove the iframe from the DOM.
    */
    remove: function(){
        $(this.id).remove();
    }
});
/* do not edit below this line */   
/* Section: Change Log 

$Source: /cvs/webapps/www-rb-api/resources/js/cnet.framework.dasher.js,v $
$Log: not supported by cvs2svn $
Revision 1.2  2007/01/30 02:24:22  grahamb
commented out console.log calls since they were failing in IE7

Revision 1.1  2006/12/20 01:48:03  grahamb
initial check-in

Revision 1.2  2006/11/02 21:26:42  newtona
checking in commerce release version of global framework.

notable changes here:
cnet.functions.js is the only file really modified, the rest are just getting cvs footers (again).

cnet.functions adds numerous new classes:

$type.isNumber
$type.isSet
$set

*//*
Script: mouseovers.js
Collection of mouseover behaviours (images, class toggles, etc.).
These functions handle standard mouseover behaviour.
        
Dependancies:
     mootools - <Moo.js>, <String.js>, <Array.js>, <Function.js>, <Element.js>, <Dom.js>
    
Author:
    Aaron Newton, <aaron [dot] newton [at] cnet [dot] com>


Function: imgMouseOverEvents
        handles hover states for images. Producers simply author all their 
        images to have an on version and an off version with same naming 
        conventions, then call this function with those conventions and 
        a css selector. All images that match that selector will get the 
        mouseover behavior applied to them automatically.

Example:
        (start code)
        <img src="myimg_off.gif" class="autoMouseOver">
        assuming that my hover image is the same path with _off
           substituted with _on; so: myimg_on.gif is the hover version
        <script>
            imgMouseOverEvents('_off', '_on', 'img.autoMouseOver');
        </script>
        (end)
        You can call this function as soon as the DOM is ready.
        
        Note:
        The default instance of this function is included in this library.
        If producers name their on/off state files with "_on" and "_off"
        in the file names and give their images the class "autoMouseOver"
        then they don't have to write any javascript. This also works for
        inputs.
        
        Arguments:
        outString - the string to substitute for the on string when the user mouses out
        overString - the string to substitute for the out string when the users mouses over
        selector - css selector to apply this behaviour
        
        See Also: <tabMouseOvers>
    */
function imgMouseOverEvents(outString, overString, selector) {
    $S(selector).each(function(image) {
        image = $(image);
        if ($type(image.src)) {
            if (image.src.indexOf(outString) > 0) {
                image.addEvent('mouseover',function(){ 
                    image.src = image.src.replace(outString, overString);
                }).addEvent('mouseout', function(){ 
                    image.src = image.src.replace(overString, outString);
                });
            }
        }
    });
};
Event.onDOMReady(function(){imgMouseOverEvents('_off', '_over', 'img.autoMouseOverOff');});
Event.onDOMReady(function(){imgMouseOverEvents('_off', '_on', 'img.autoMouseOver');});
Event.onDOMReady(function(){imgMouseOverEvents('_off', '_on', 'input.autoMouseOver');});

/*  
Function: tabMouseOvers
        tabMouseOvers are almost identical to <imgMouseOverEvents>.
        this function will swap out one css class for another when the
        user mouses over a dom element (doesn't have to be a tab layout)
        You also have the option of having the class of the DOM element
        change when the user mouses over a child of the DOM element that's
        supposed to toggle (for instance, if your tab has a link in it,
        you can have the tab change when the user mouses over the anchor
        instead of the whole tab).
        
        pass in the css class for the 'on' and 'off states, a swell as 
        the css selector for the DOM element, and, optionally, the selector
        for the sub elements for the mouseover action.
        
        you can also optionally set applyToBoth to set the mouseover to both
        the selector and the subselector if you like
        
        Arguments:
        cssOn - the "on" state for the tab; this css class will be added 
                        when the user mouses over the element.
        cssOff - the "off" state for the tab
        selector - the selector for all the tabs
        subselector - the selector for any sub elements that you wish to attach
                        the mouseover behavior to
        applyToBoth - a boolean; if you want to apply the mouseover behavior
                        to both the selector and the subselector; false = just the
                        subselector
        
        example:
        ><ul id="myTabs">
        >   <li><a href="1">one</a></li>
        >   <li><a href="2">two</a></li>
        >   <li><a href="3">three</a></li>
        ></ul>
        ><script>
        >   tabMouseOvers('on', 'off', '#myTabs li", "a", false);
        ></script>
        
        now, when the user mouses over the anchor tags, the parent li object
        will get the class "on" added to it.
        
        note that those last two, the subselector and the applyToBoth are optional
*/
function tabMouseOvers(cssOn, cssOff, selector, subselector, applyToBoth){
    $S(selector).action({
        initialize: function(){
            this.applyToBoth = applyToBoth || false;
            if(! $test(subselector))
                this.addClassName(cssOff).removeClassName(cssOn);
            else {
                $A(this.getElementsBySelector(subselector)).each(function(el){
                    el.addClassName(cssOff).removeClassName(cssOn);
                });
            }
        },
        onmouseover: function(){
            if(this.applyToBoth || ! $test(subselector))
                this.addClassName(cssOn).removeClassName(cssOff);
            else {
                $A(this.getElementsBySelector(subselector)).each(function(el){
                    el.addClassName(cssOn).removeClassName(cssOff);
                });
            }
        },
        onmouseout: function(){
            if(this.applyToBoth || ! $test(subselector))
                this.addClassName(cssOff).removeClassName(cssOn);
            else {
                $A(this.getElementsBySelector(subselector)).each(function(el){
                    el.addClassName(cssOff).removeClassName(cssOn);
                });
            }
        }
    });
};
/* do not edit below this line */   
/* Section: Change Log 

$Source: /cvs/webapps/www-rb-api/resources/js/cnet.framework.dasher.js,v $
$Log: not supported by cvs2svn $
Revision 1.2  2007/01/30 02:24:22  grahamb
commented out console.log calls since they were failing in IE7

Revision 1.1  2006/12/20 01:48:03  grahamb
initial check-in

Revision 1.3  2006/11/03 18:45:36  newtona
found conflict on tips page
http://help.dldev2.cnet.com:8006/9611-12576_39-0.html?tag=button1&nodeId=6501&jsdebug=true

in imgMouseOverEvents

added this line:

image = $(image);

To apply Mootools Element properties to each image as I apply them

Revision 1.2  2006/11/02 21:26:42  newtona
checking in commerce release version of global framework.

notable changes here:
cnet.functions.js is the only file really modified, the rest are just getting cvs footers (again).

cnet.functions adds numerous new classes:

$type.isNumber
$type.isSet
$set

*//*
Script: tabswapper.js
Handles the scripting for a common UI layout; the tabbed box.


Class: tabSwapper
        Handles the scripting for a common UI layout; the tabbed box.
        If you have a set of dom elements that are going to toggle visibility based
        on the related tabs above them (they don't have to be above, but usually are)
        you can instantiate a tabSwapper and it's handled for you.
        
        Example:
        
        ><ul id="myTabs">
        >   <li><a href="1">one</a></li>
        >   <li><a href="2">two</a></li>
        >   <li><a href="3">three</a></li>
        ></ul>
        ><div id="myContent">
        >   <div>content 1</div>
        >   <div>content 2</div>
        >   <div>content 3</div>
        ></div>
        ><script>
        >   var myTabSwapper = new tabSwapper({
        >       selectedClass: "on",
        >       deselectedClass: "off",
        >       mouseoverClass: "over",
        >       mouseoutClass: "out",
        >       tabSelector: "#myTabs li",
        >       clickSelector: "#myTabs li a",
        >       sectionSelector: "#myContent div",
        >       name: "myTabSwapper",
        >       smooth: true,
        >       cookieName: "rememberMe"
        >   });
        ></script>
        
        Notes:
         - you don't have to specify the classes for mouseover/out
         - you don't have to specify a click selector; it'll just
           use the tab DOM elements if you don't give it the click
             selector
         - the click selector is NOT a subselector of the tabs; be sure
           to specify a full css selector for these
         - smooth: is off by default; adds some nice transitional effects
         - cookieName: will store the users's last selected tab in a cookie
           and restore this tab when they next visit
             
Arguments:
    options - optional, an object containing options.

Options:
            selectedClass - the class for the tab when it is selected
            deselectedClass - the class for the tab when it isn't selected
            mouseoverClass - the class for the tab when the user mouses over
            mouseoutClass - the class for the tab when the user mouses out
            tabSelector - the css selector to find all the tabs
            clickSelector - the css selector for all the elements the user clicks
                                            optional; if not defined, will use tabSelector
            sectionSelector - the css selector for the content the tabs display
            name - the name of the instance you create of this class
            initPanel - the panel to show on init; 0 is default (optional)
            smooth - use effects to smooth transitions; false is default (optional)
            cookieName - if defined, the browser will remember their previous selection
                        using a cookie (optional)
            cookieDays - how many days to remember this? default is 999, but it's
                        ignored if cookieName isn't set (optional)
    */

var tabSwapper = new Class({
    initialize: function(options){
        this.options = Object.extend({
            name: null, 
            initPanel: 0, 
            smooth: false, 
            cookieName: null, 
            cookieDays: 999 
        }, options || {});
        this.sectionOpacities = [];
        if(! $type(this.options.clickSelector)) this.options.clickSelector = this.options.tabSelector;
        this.setup();
        if(this.options.cookieName && parseInt(this.recall())) this.swap(parseInt(this.recall()));
        else this.swap(this.options.initPanel);
    },
    setup: function(){
        var swapper = this;
        var opt = this.options;
        $S(opt.clickSelector).each(function(lnk, idx){
            lnk.addEvent('click', function(){swapper.swap(idx)});
        });
        if($type(opt.mouseoverClass) && $type(opt.mouseoutClass))
            tabMouseOvers(opt.mouseoverClass, opt.mouseoutClass, opt.tabSelector);
        this.tabs = $S(opt.tabSelector);
        this.sections = $S(opt.sectionSelector);
    },
    swap: function(swapIdx){
        var opt = this.options;
        var swapper = this;
        this.tabs.each(function(tab, idx){
            if(swapIdx == idx) tab.addClassName(opt.selectedClass).removeClassName(opt.deselectedClass);
            else tab.addClassName(opt.deselectedClass).removeClassName(opt.selectedClass);
        });
        this.sections.each(function(sect, idx){
            if(swapIdx == idx) swapper.showSection(idx);
            else swapper.hideSection(idx);
        });
        if(opt.cookieName) this.save(swapIdx);
    },
    save: function(index){
        Cookie.set(this.options.cookieName, index, this.options.cookieDays);
    },
    recall: function(){
        return Cookie.get(this.options.cookieName);
    },
    hideSection: function(idx) {
        var sect = this.sections[idx];
        if(sect.visible()) {
            /* -- if(!sect.o) sect.o = sect.effect('opacity', {duration: 500});
            sect.o.custom(1,0); -- */
            sect.hide();
        }
        sect = null;
    },
    showSection: function(idx) {
        var sect = this.sections[idx];
        var opacityFx = this.sectionOpacities[idx];
        if(!sect.visible()) {
            if(this.options.smooth) {
                if (!opacityFx) opacityFx = this.sections[idx].effect('opacity', {duration: 500});
                opacityFx.set(0);
            }
            sect.show();
            if(this.options.smooth) opacityFx.custom(0,1);
        }
        sect = null;
        opacityFx = null;
    }
});
/* do not edit below this line */   
/* Section: Change Log 

$Source: /cvs/webapps/www-rb-api/resources/js/cnet.framework.dasher.js,v $
$Log: not supported by cvs2svn $
Revision 1.2  2007/01/30 02:24:22  grahamb
commented out console.log calls since they were failing in IE7

Revision 1.1  2006/12/20 01:48:03  grahamb
initial check-in

Revision 1.3  2006/11/21 23:55:56  newtona
optimization update

Revision 1.2  2006/11/02 21:26:42  newtona
checking in commerce release version of global framework.

notable changes here:
cnet.functions.js is the only file really modified, the rest are just getting cvs footers (again).

cnet.functions adds numerous new classes:

$type.isNumber
$type.isSet
$set

*//*
Script: browser.sniffer.js
This is a very, very simple browser sniffer.    

Dependancies:
     no dependencies.
    
Constant: agt
 = navigator.userAgent.toLowerCase()
*/
// convert all characters to lowercase to simplify testing
var agt=navigator.userAgent.toLowerCase();
// *** BROWSER VERSION ***
// Note: On IE5, these return 4, so use is_ie5up to detect IE5.
/*  
Constant: is_major
Integer value of the browser version (so 6.01 will be just 6).
    */
var is_major = parseInt(navigator.appVersion);
/*  
Constant: is_minor
Float value of the browser version (6.00 or 6.01, etc.).    */

var is_minor = parseFloat(navigator.appVersion);
/*  
Constant: is_nav    
Is mozilla browser.
*/
var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
                     && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
                     && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
/*
Constant: is_nav6
Is mozilla 6.
    */
var is_nav6 = (is_nav && (is_major == 5));
/*  
Constant: is_nav6up
Is mozilla version > 5  */
var is_nav6up = (is_nav && (is_major >= 5));
/*  
Constant: is_gecko
Is gecko browser    */
var is_gecko = (agt.indexOf('gecko') != -1);
/*  
Constant: is_opera
Is the opera browser    */
var is_opera = (agt.indexOf("opera") != -1);
/*  
Constant: is_fx 
Is firefox
*/
var is_fx = ((agt.indexOf('mozilla/5')!=-1) && (agt.indexOf('spoofer')==-1) &&
                         (agt.indexOf('compatible')==-1) && (agt.indexOf('opera')==-1)  &&
                         (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1)      &&
                         (is_gecko) && ((navigator.vendor=="Firefox")||(agt.indexOf('firefox')!=-1)));
/*  
Constant: is_ffox   
Is firefox (see <is_fx>)
*/
var is_ffox = is_fx;
/*  
Constant: is_ie
Is Internet Explorer.   */
var is_ie       = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
/*
Constant: is_ie6
Is IE 6 */
var is_ie6   = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) );
/*  
Constant: is_ie7
Is IE 7 */
var is_ie7   = (is_ie && is_major == 7);
/*  
Constant: is_ie7up
Is IE 7 and up */
var is_ie7up = (is_ie && is_minor >= 7);
/*  
Constant: is_mac
Agent is on the mac os. */
var is_mac   = (agt.indexOf("mac")!=-1);
/*  
Constant: is_safari
Is Safari browser.
    */
var is_safari = ((agt.indexOf('safari')!=-1)&&(agt.indexOf('mac')!=-1))?true:false;
/*  
Constant: is_Flash
Agent has flash installed   */
var is_Flash    = false;
/*  
Constant: is_FlashVersion
Version of flash installed  */
var is_FlashVersion = 0;

if ((is_nav||is_opera||is_fx)||
        (is_mac&&is_ie5up)) {
     var plugin = (navigator.mimeTypes && 
                                 navigator.mimeTypes["application/x-shockwave-flash"] &&
                                 navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin) ?
                                 navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
     if (plugin&&plugin.description) {
            is_Flash = true;
            is_FlashVersion = parseInt(plugin.description.substring(plugin.description.indexOf(".")-1));
     }
}
/* do not edit below this line */   
/* Section: Change Log 

$Source: /cvs/webapps/www-rb-api/resources/js/cnet.framework.dasher.js,v $
$Log: not supported by cvs2svn $
Revision 1.2  2007/01/30 02:24:22  grahamb
commented out console.log calls since they were failing in IE7

Revision 1.1  2006/12/20 01:48:03  grahamb
initial check-in

Revision 1.8  2006/11/02 21:26:42  newtona
checking in commerce release version of global framework.

notable changes here:
cnet.functions.js is the only file really modified, the rest are just getting cvs footers (again).

cnet.functions adds numerous new classes:

$type.isNumber
$type.isSet
$set

Revision 1.6  2006/10/27 21:49:19  pamelad
hmmm


*/
/*
Script: cnet.functions.js
    Collected functions and objects for the CNET "Redball" family of sites.
    
Dependancies:
     mootools - <Moo.js>, <String.js>, <Array.js>, <Function.js>, <Element.js>, <Dom.js>
     cnet libraries - <dbug.js>, <iframeshim.js>, <mouseovers.js>
    
Author:
    Aaron Newton, <aaron [dot] newton [at] cnet [dot] com>

    Object: LocalVars
        LocalVars is a collection of page specific data that represents the 
        state of a page on our network and should be used to enact various 
        functions based on the data stored in this object.
        
        The following code is very specific to cnet.com, news.com, and download.com

        LocalVars is a collection of two chunks of data: <UserVars> and <PageVars>. 
        Each page on the redball network will instantiate a new LocalVars element, example:
        (start code)
UserVars = new LocalVars.UserVars({
    loggedIn: '<!--#echo var="CNET-Logged-In" -->',
    userName: '<!--#echo var="CNET-URS-DISPNAME" -->',
    ursRegId: '<!--#echo var="CNET-URS-USER-ID" -->',
    rememberMe: '<!--#echo var="CNET-URS-REMEMBERME" -->'
});
PageVars = new LocalVars.PageVars({
    pageType: <!--#echo var="CNET-PAGE-TYPE-ID"-->,
    nodeId: <!--#echo var="CNET-ONTOLOGY-NODE-ID" -->,
    channelId: <!--#echo var="CNET-CHANNEL" -->,
    siteId: <!--#echo var="CNET-SITE-ID" -->,
    assetId: <!--#echo var="CNET-ASSET-ID"-->,
    editionId: <!--#echo var="CNET-EDITION-ID"-->
});
        (end)
    */
var rbCookies = []; //legacy namespace for PageVars.cookies
var LocalVars = { 
/*  Class: UserVars
        Part of the <LocalVars> object that contains data about the user.
        
        Example:
        (start code)
UserVars = new LocalVars.UserVars({
    loggedIn: '<!--#echo var="CNET-Logged-In" -->',
    userName: '<!--#echo var="CNET-URS-DISPNAME" -->',
    ursRegId: '<!--#echo var="CNET-URS-USER-ID" -->',
    rememberMe: '<!--#echo var="CNET-URS-REMEMBERME" -->'
});
        (end)
        
    */
    UserVars: new Class({ 
        initialize: function(specs) { 
            specs = specs || {}; 
            this.sentSpecs = specs; 
/*  Property: userName
        UserVars.userName is the value for the user's username returned from the Apache vars.
    */
            this.userName = (specs.userName && specs.userName.trim() != '') ? specs.userName.trim() : false;
/*  Property: userNameDisplay
        UserVars.userNameDisplay is the display value for the user's username returned from the Apache vars.
    */
            this.userNameDisplay = (this.userName) ? unescape(this.userName.replaceAll('\\\+',' ')) : false;
/*  Property: ursRegId
        UserVars.ursRegId is the value for the user's registration id (from the urs application) returned from the Apache vars.
    */
            this.ursRegId = specs.ursRegId || false;
/*  Property: loggedIn
        UserVars.loggedIn the user's login state returned from the Apache vars.
        It is either an integer or the boolean false.
        Regardless of which it is, it should be something you can put in a conditional.

        Example:
        >if(UserVars.loggedIn) ....do something....
    */
            this.loggedIn = parseInt(specs.loggedIn) || false;
/*  Property: rememberMe
        UserVars.rememberMe is the value for the user's preference to store their
        login (returned from the Apache vars) so as not to prompt them to login
        again when they come back to the site.
    */
            this.rememberMe = parseInt(specs.rememberMe) || false;
            this.getAllCookies();
        },
/*  Property: getAllCookies
        *Deprecated*; Retrieves all the cookies for the user and stores them in the PageVars.cookies object.

        Example:
        >if (UserVars.cookies['cookieKey'] == "the value I'm checking for") ...

        It's actually way better to just use <Cookie.get> whenever you want to retrieve a cookie value.
        There isn't a cost to using this function.
    */
        getAllCookies: function(){
            this.cookies = [];
            if (document.cookie) {
                var cks = document.cookie.split("; ");
                cks.each(function(ck) {
                 var cook = ck.split("=");
                 rbCookies[cook[0]] = cook[1];
                });
            }
            rbCookies = this.cookies; //rbCookies is a legacy namespace of the cookies for a user on a page
        }
    }),
/*  Class: PageVars
        Part of the <LocalVars> object that contains data about the page.

        Arguments:
        specs - an object containing the specs for the page.

        Options:
        pageType - (integer) the pageType number
        nodeId - (integer) the node Id for the page
        channelId - (integer) the channel Id for the page
        siteId - (integer) the site Id of the page
        assetId - (integer) the asset Id of the page
        editionId - (integer) the edition Id of the page

        Example:
        (start code)
PageVars = new LocalVars.PageVars({
    pageType: <!--#echo var="CNET-PAGE-TYPE-ID"-->,
    nodeId: <!--#echo var="CNET-ONTOLOGY-NODE-ID" -->,
    channelId: <!--#echo var="CNET-CHANNEL" -->,
    siteId: <!--#echo var="CNET-SITE-ID" -->,
    assetId: <!--#echo var="CNET-ASSET-ID"-->,
    editionId: <!--#echo var="CNET-EDITION-ID"-->
});
        (end)
    */
    PageVars: new Class({
        initialize: function(specs) {
            specs = specs || {};
            this.sentSpecs = specs;
    /*  Property: pageType
            PageVars.pageType is an integer for the the page type.
    */
            this.pageType = ($type.isNumber(specs.pageType))?new Number(specs.pageType):false;
    /*  Property: nodeId
            PageVars.nodeId is an integer of the node Id of the page.
    */
            this.nodeId = ($type.isNumber(specs.nodeId))?new Number(specs.nodeId):false;
    /*  Property: channelId
            PageVars.channelId is an integer of the channel Id of the page.
    */
            this.channelId = ($type.isNumber(specs.channelId))?new Number(specs.channelId):false;
    /*  Property: siteId
            PageVars.siteId is an integer of the site Id for the page.
    */
            this.siteId = ($type.isNumber(specs.siteId))?new Number(specs.siteId):false;
    /*  Property: assetId
            PageVars.assetId is an integer of the asset's id.
    */
            this.assetId = ($type.isNumber(specs.assetId))?new Number(specs.assetId):false;
    /*  Property: editionId
            PageVars.editionId is an integer of the edition id for the page.
    */
            this.editionId = ($type.isNumber(specs.editionId))?new Number(specs.editionId):false;
            this.setOid();
        },
        setOid: function(){
    /*  Property: oid
            PageVars.oid is a string or boolean for the full oid of the page.
            - it is the boolean *false* if the pageType, nodeId, siteId, and assetId aren't all set
            - it is the string <pageType>-<nodeId>_<siteId>-<assetId>
    */
            this.oid = ($type.isNumber(this.pageType) && $type.isNumber(this.nodeId) &&
                                    $type.isNumber(this.siteId) && $type.isNumber(this.assetId))?
                                    this.pageType+"-"+this.nodeId+"_"+this.siteId+"-"+this.assetId:
                                    false;
        }
    })
};

var UserVars = {};
var PageVars = {};

/*  Class: LoginStatus
        The Login Status class is used by Redball sites to set up the display of the page
        based on their login state. The code contains various settings that are determined
        by the user's cookie and session. The internal functions of this class are not
        meant to be executed independently; the only thing needed is to instantiate the class
        when the DOM is loaded.

        Example:
        (start code)
Event.onDOMReady(function(){
    new LoginStatus; //you don't need to store the instance for any reason
});
        (end)
    */
var LoginStatus = new Class({
    ssaIDs: [1,7,9,39,92], //site ids for commerce (ssa)
    initialize: function() {
        this.retPath = escape(window.location.href);
        if (UserVars.loggedIn || UserVars.rememberMe) { //if the user is logged in
            this.writeUserName(); //display their user name
            if (this.isSSA()) this.genSSAProfileURL(); //if this is an ssa site, setup the profile url
            $('uloginIn').show(); //show the login
        } else {
            if (this.isSSA()) this.primeApache(); //if this is ssa, but the user isn't logged in
            $('uloginOut').show();//show the logged out state (the link to login which shows the login form)
            //setup an iframe shim for the login form to obscure the select list under it
            //see <iframeShim> in the global.utils directory
            var loginShim = new iframeShim({
                element:'uloginForm',
                name:'uloginForm',
                display: false
            });
            //setup an event watcher for hitting the etner button in the password field
            try {
                Event.observe('uloginPass', 'keypress', function(e) {
                    if(e.keyCode == 13) $('uloginForm').submit();
                });
            } catch(e) {}
        }
        this.writePathArgs(); //write the path arguments
        //assign the toggle to the login iframe
        this.assignToggle('rb_login_cancel',loginShim);
        this.assignToggle('openLogIn',loginShim);
    },
    isSSA: function() {
        return this.ssaIDs.test(PageVars.siteId); //returns true if the site is an ssa site
    },
    writeUserName: function() { //generates the user's welcome message with their username
        if (UserVars.userName) {
            var profileLink = new Element('A');
            profileLink.appendText(UserVars.userNameDisplay).setProperties({
                id:'uniloginProfileName',
                href: $('uniloginProfile').href
            });
            $('welcomeString').appendText(', ').adopt(profileLink);
        }
    },
    genSSAProfileURL: function() { //generates the profile link for ssa pages
        var profileURL = (UserVars.userName)
            ? "http://my.cnet.com/community/"+UserVars.userName.replaceAll(' ', '+')+"/?tag=unilog"
            : "#";
        $('uniloginProfile').href = profileURL;
        try { $('uniloginProfileName').href = profileURL; }
        catch(e) { dbug.log(e); }
    },
    primeApache: function() { //!HACK! primes apache, which for some reason needs the login form submitted twice.
        document.uloginForm.onsubmit = function() {
            new ajax(document.uloginForm.action, {
                postBody: $(document.uloginForm).toQueryString(),
                async: false
            });
        }
    },
    writePathArgs: function() { //writes the return path to all the links and the form in the login element
        $S('#hd_unilogin a').each(function(anA) {
            var sep = (anA.href.test(/\?/)) ? "&" : "?";
            if (anA.href.test(/\/13\d{2}\-/))
                anA.href+=sep+"path="+this.retPath;
            },this);
        try {
            var sep = ($('uloginForm').action.test(/\?/)) ? "&" : "?";
            $('uloginForm').action += sep+"path="+this.retPath;
        } catch(e) {dbug.log("Attempting to add path to form action: %s",e);}
    },
    //assignes toggles to the links and associates them with the iframeshim.toggle() function which must also fire
    assignToggle: function(aLink,shim) {
        if($(aLink)) {
            $(aLink).href = "javascript:void(0)";
            $(aLink).onclick = function() {
                if ($('uloginForm').visible())
                    document.uloginForm.reset();
                $('uloginForm').toggle();
                if ($(shim.id).visible()) shim.hide();
                else shim.show();
            };
        }
    }
});


/*  Section: Redball Functions
        These functions are specific to the redball network and its pages.

        Function: toggleLoginForm
        toggleLoginForm is a function used in the head of Redball network sites
        to show or hide the form that users interact with to log in.

        Example:
        > toggleLoginForm(); //hides or shows the form
    */
function toggleLoginForm() {
    if ($('uloginForm').visible())
        document.uloginForm.reset();
    $('uloginForm').toggle();
    if ($('uloginForm_shim')) $('uloginForm_shim').toggle();
    return false;
};


/*  Function: rbSearch
        Executes a search on a redball site, passing that search through DW for tracking.

        Arguments:
        host - http....com, defaults to the host of the current page, (optional)
        searchURL - the url, relative to the host or a fully qualified domain
                                name to the application that will handle the search
        formId - the form that has the values that must be submitted to the searchURL
        searchDropDownId - the DOM id of the dropdown element for the search (optional)
        oid - the oid for DW tracking, defaults to LocalVars.PageVars.oid, (optional)
        siteid - the site id for DW tracking, defaults to LocalVars.PageVars.site, (optional)
        userAction - the DW search action id, defaults to 37, (optional)
*/
function rbSearch(options) {
    try {
        //set default actions
        this.options = Object.extend({
            host: Window.getHost(),
            oId: PageVars.oid,
            siteId: PageVars.siteId,
            userAction: 37
        }, options || {});
        //get the inputs and set ids for them if they aren't set already
        $(this.options.formId).getElements('input').each(function(input){
            if(!$type(input.id)) input.id = options.formId+'_'+input.name;
        });
        //same for selects
        $(this.options.formId).getElements('select').each(function(input){
            if(!$type(input.id)) input.id = options.formId+'_'+input.name;
        });
        //set the search action based on the environment
        this.setSearchAction = function(){
            //get the search type from the select list
            this.searchType = $(this.options.searchDropDownId)[$(this.options.searchDropDownId).selectedIndex].value;
            //if the search type is 'nw' (meaning redball network) or the search type is equal to the network search
            if (this.searchType == 'nw' ||
                this.searchType == 'http://cnet.search.com/search?chkpt=astg.cnet.fd.search.cnet') 
                    //set the user action to 'all cnet' search
                    this.options.userAction = 98;
            //if the search type is 'wb' (meaning the web) or the url is set for the web
            if (this.searchType == 'wb' ||
                this.searchType == 'http://www.search.com/search?chkpt=astg.cnet.fd.search.web') 
                //set the user action for a web search
                this.options.userAction = 97; 
            // special handling for tips & tricksdbug.log(this.options.siteId
            if (this.options.siteId == '39') {
                        //set new action since this is set to javascript:void
                        this.options.searchURL = 'http://www.search.com/redirect';
                        //append q as kw onto target url
                        this.searchType += 'kw=' + escape($(this.options.formId).q.value);
            }
            // special handling for downloads music
            if (this.options.siteId == '32') {
          //set new action since this is set to javascript:void
          this.options.searchURL = '/3607-5_32-0.html';
                //if the search type is for songs, use a different action
                if (this.searchType == '3608')
                    this.options.searchURL = '/3608-5_32-0.html';
                //if the search type is for downloads, games, network, or thew eb, use this url...
                if (this.searchType == 'dl-20' || this.searchType == 'dl-2012' ||
                    this.searchType == 'nw' || this.searchType == 'wb' )
                    this.options.searchURL = '/3120-20_4-0.html';
            }
            // special handling for shopper
            if (this.options.siteId == '9') {
                if (this.searchType == 'sh')
                    this.options.searchUrl = '/4144-5_9-0.html';
                if (this.searchType == 'nw' || this.searchType == 'wb')
                    this.options.searchUrl = 'http://www.search.com/redirect';
            }
            //return the search option and values
            return $(this.options.searchDropDownId).name + "=" + this.searchType + "&";
        };
        //get the input values
        this.getFormValues = function(){
            var qs = '';
            //loop through input children and construct query string
            $(this.options.formId).getElements("input").each(function(input){
            if(input.type == "text" || input.type == "hidden")
                qs += input.name+"="+input.value+"&";
            });
            //if we're on shopper, add some additoinal info
            if(this.options.siteId == '9') {
                if (this.searchType == 'nw')
                    qs += "target=http://cnet.search.com/search?chkpt=astg.cnet.fd.search.cnet&";
                if (this.searchType == 'wb')
                    qs += "target=http://www.search.com/search?chkpt=astg.cnet.fd.search.web&";
            }
            //send everything back minus the last ampersand
            return qs.substring(0, qs.length-1);
        };
        this.makeSearchURL = function() {
            //set the search action
            this.setSearchAction();
            //set the action for the form to this url:
            this.action = this.options.searchURL.indexOf("http:") < 0 ? this.options.host + this.options.searchURL : this.options.searchURL;
            var seperator = "?";
            if (this.action.indexOf("?") > 0) seperator = "&";
            //construct the complete search url
            this.destURL = this.action + seperator + escape(this.setSearchAction()) + escape(this.getFormValues());
            //wrap it in a redirect
            this.redirURL = 'http://dw.com.com/redir?usraction=' + this.options.userAction;
            //add the oid if it's available
            if(this.options.oId) this.redirURL += '&oId=' + this.options.oId;
            //add the site id if it's available
            if($type.isNumber(this.options.siteId))
                this.redirURL += '&siteId=' + this.options.siteId;
            //then the destination url (escaped)
            this.redirURL += '&destUrl=' + this.destURL;
            //log the search url to the console
            dbug.log('search url: ' + this.redirURL);
            return this.redirURL;
        };
        var rbs = this;
        this.execute = function() {
            if(window.location.href.indexOf('jsdebugsearch=true')<0)
                window.location.href = rbs.makeSearchURL();
            else rbs.makeSearchURL();
        };
        this.execute();
    } catch(e){
        dbug.log('rbsearch error: %s', e);
    }
};
/*  function: sendSearchRedirect2
        deprecated syntax for <rbSearch>
    */
function sendSearchRedirect2(host, action, formId, searchTypeId, oId, siteId) {
    rbSearch({
        host: host,
        searchURL: action,
        formId: formId,
        searchDropDownId: searchTypeId,
        oid: oId,
        siteid: siteId
    });
};
/* do not edit below this line */
/* Section: Change Log

$Source: /cvs/webapps/www-rb-api/resources/js/cnet.framework.dasher.js,v $
$Log: not supported by cvs2svn $
Revision 1.2  2007/01/30 02:24:22  grahamb
commented out console.log calls since they were failing in IE7

Revision 1.1  2006/12/20 01:48:03  grahamb
initial check-in

Revision 1.7  2006/11/27 19:33:33  newtona
added shopper logic to rbsearch

Revision 1.6  2006/11/08 18:57:46  pamelad
added channelId to page vars

Revision 1.5  2006/11/06 20:18:15  newtona
fixed replaceAll syntax error

Revision 1.4  2006/11/02 21:26:42  newtona
checking in commerce release version of global framework.

notable changes here:
cnet.functions.js is the only file really modified, the rest are just getting cvs footers (again).

cnet.functions adds numerous new classes:

$type.isNumber
$type.isSet
$set

Revision 1.2  2006/10/27 22:10:21  pamelad
removed revision tags at the top of the page

*/
dbug.loadtimeEnd('redball global framework'); 
/*
Script: Drag.js
    Contains Classes Drag.Base, Drag.Move and a couple of element methods to drag and resize your elements.
        
Dependencies:
    <Moo.js>, <Function.js>, <Array.js>, <String.js>, <Element.js>

Author:
    Valerio Proietti, <http://mad4milk.net>

License:
    MIT-style license.
*/

var Drag = {};

/*
Class: Drag.Base
    Modify two css properties of an element based on the position of the mouse.

Arguments:
    el - the $(element) to apply the transformations to.
    xModifier - required. The css property to modify, based to the position on the X axis of the mouse. defaults to none.
    yModifier - required. The css property to modify, based to the position on the Y axis of the mouse pointer. defaults to none.
    options - optional. The options object.

Options:
    handle - the $(element) to act as the handle for the draggable element. defaults to the $(element) itself.
    onStart - function to execute when the user starts to drag (on mousedown); optional.
    onComplete - optional, function to execute when the user completes the drag.
    onDrag - optional, function to execute at every step of the dragged $(element).
    xMax - optional, the maximum value for the x property of the dragged $(element).
    xMin - optional, the minium value for the x property of the dragged $(element).
    yMax - optional, the maximum value for the y property of the dragged $(element).
    yMin - optional, the minium value for the y property of the dragged $(element).
*/

Drag.Base = new Class({

    setOptions: function(options){
        this.options = Object.extend({
            handle: false,
            unit: 'px', 
            onStart: Class.empty, 
            onComplete: Class.empty, 
            onDrag: Class.empty,
            xMax: false,
            xMin: false,
            yMax: false,
            yMin: false
        }, options || {});
    },

    initialize: function(el, xModifier, yModifier, options){
        this.setOptions(options);
        this.element = $(el);
        this.handle = $(this.options.handle) || this.element;
        if (xModifier) this.xp = xModifier.camelCase();
        if (yModifier) this.yp = yModifier.camelCase();
        this.handle.onmousedown = this.start.bind(this);
    },

    start: function(evt){
        evt = evt || window.event;
        this.startX = evt.clientX;
        this.startY = evt.clientY;
        
        this.handleX = this.startX - this.handle.getLeft();
        this.handleY = this.startY - this.handle.getTop();
        
        this.set(evt);
        this.options.onStart.pass(this.element, this).delay(10);
        document.onmousemove = this.drag.bind(this);
        document.onmouseup = this.end.bind(this);
        return false;
    },

    addStyles: function(x, y){
        if (this.xp){
            var stylex = this.element.getStyle(this.xp).toInt();
        
            var movex = function(val){
                this.element.setStyle(this.xp, val+this.options.unit);
            }.bind(this);
        
            if (this.options.xMax && stylex >= this.options.xMax){
                if (this.clientX <= this.handleX+this.handle.getLeft()) movex(stylex+x);
                if (stylex > this.options.xMax) movex(this.options.xMax);
            } else if(this.options.xMin && stylex <= this.options.xMin){
                if (this.clientX >= this.handleX+this.handle.getLeft()) movex(stylex+x);
                if (stylex < this.options.xMin) movex(this.options.xMin);
            } else movex(stylex+x);
        }
        if (this.yp){
            var styley = this.element.getStyle(this.yp).toInt();

            var movey = function(val){
                this.element.setStyle(this.yp, val+this.options.unit);
            }.bind(this);

            if (this.options.yMax && styley >= this.options.yMax){
                if (this.clientY <= this.handleY+this.handle.getTop()) movey(styley+y);
                if (styley > this.options.yMax) movey(this.options.yMax);
            } else if(this.options.yMin && styley <= this.options.yMin){
                if (this.clientY >= this.handleY+this.handle.getTop()) movey(styley+y);
                if (styley < this.options.yMin) movey(this.options.yMin);
            } else movey(styley+y);
        }
    },

    drag: function(evt){
        evt = evt || window.event;
        this.clientX = evt.clientX;
        this.clientY = evt.clientY;
        this.options.onDrag.pass(this.element, this).delay(5);
        this.addStyles((this.clientX-this.lastMouseX), (this.clientY-this.lastMouseY));
        this.set(evt);
        return false;
    },

    set: function(evt){
        this.lastMouseX = evt.clientX;
        this.lastMouseY = evt.clientY;
        return false;
    },

    end: function(){
        document.onmousemove = null;
        document.onmouseup = null;
        this.options.onComplete.pass(this.element, this).delay(10);
    }

});

/*
Class: Drag.Move
    Extends <Drag.Base>, has additional functionality for dragging an element (modifying its left and top values).

Arguments:
    el - the $(element) to apply the transformations to.
    options - optional. The options object.
    
Options:
    all the drag.Base options, plus:
    snap - if true the element will start dragging after a certain distance has been reached from the mousedown. defaults to true.
    snapDistance - integer representing the snapping distance. Default is 8.
    onSnap - function to execute when the element has been dragged the snapDistance.
    xModifier - the modifier to handle left and right dragging; defaults to left.
    yModifier - the modifier to handle up and down dragging; defaults to top.
    container - if set to an element will fill automatically xMin/xMax/yMin/yMax based on the $(element) size and position. defaults to false.
*/

Drag.Move = Drag.Base.extend({

    extendOptions: function(options){
        this.options = Object.extend(this.options || {}, Object.extend({
            onSnap: Class.empty,
            droppables: [],
            snapDistance: 8,
            snap: true,
            xModifier: 'left',
            yModifier: 'top',
            container: false
        }, options || {}));
    },

    initialize: function(el, options){
        this.extendOptions(options);
        this.container = $(this.options.container);
        this.parent(el, this.options.xModifier, this.options.yModifier, this.options);
    },

    start: function(evt){
        if (this.options.container) {
            var cont = $(this.options.container).getPosition();
            Object.extend(this.options, {
                xMax: cont.right-this.element.offsetWidth,
                xMin: cont.left,
                yMax: cont.bottom-this.element.offsetHeight,
                yMin: cont.top
            });
        }
        this.parent(evt);
        if (this.options.snap) document.onmousemove = this.checkAndDrag.bind(this);
        return false;
    },

    drag: function(evt){
        this.parent(evt);
        this.options.droppables.each(function(drop){
            if (this.checkAgainst(drop)){
                if (drop.onOver && !drop.dropping) drop.onOver.pass([this.element, this], drop).delay(10);
                drop.dropping = true;
            } else {
                if (drop.onLeave && drop.dropping) drop.onLeave.pass([this.element, this], drop).delay(10);
                drop.dropping = false;
            }
        }, this);
        return false;
    },

    checkAndDrag: function(evt){
        evt = evt || window.event;
        var distance = Math.round(Math.sqrt(Math.pow(evt.clientX - this.startX, 2)+Math.pow(evt.clientY - this.startY, 2)));
        if (distance > this.options.snapDistance){
            this.set(evt);
            this.options.onSnap.pass(this.element, this).delay(10);
            document.onmousemove = this.drag.bind(this);
            this.addStyles(-(this.startX-evt.clientX), -(this.startY-evt.clientY));
        }
        return false;
    },

    checkAgainst: function(el){
        x = this.clientX+Window.getScrollLeft();
        y = this.clientY+Window.getScrollTop();
        var el = $(el).getPosition();
        return (x > el.left && x < el.right && y < el.bottom && y > el.top);
    },

    end: function(){
        this.parent();
        this.options.droppables.each(function(drop){
            if (drop.onDrop && this.checkAgainst(drop)) drop.onDrop.pass([this.element, this], drop).delay(10);
        }, this);
    }

});

/*
Class: Element
    Custom class to allow all of its methods to be used with any DOM element via the dollar function <$>.
*/

Element.extend({
    
    /*
    Property: makeDraggable
        Makes an element draggable with the supplied options.
        
    Arguments:
        options - see <Drag.Move> and <Drag.Base> for acceptable options.
    */
    
    makeDraggable: function(options){
        return new Drag.Move(this, options);
    },
    
    /*
    Property: makeResizable
        Makes an element resizable (by dragging) with the supplied options.

    Arguments:
        options - see <Drag.Base> for acceptable options.
    */
    
    makeResizable: function(options){
        return new Drag.Base(this, 'width', 'height', options);
    },
    
    /*  
    Property: getPosition
        Returns an object with width, height, left, right, top, and bottom, representing the values of the Element
        
    Example:
        >var myValues = $('myElement').getPosition();
        >//myValues will be..
        >{
        >   width: 200,
        >   height: 300,
        >   left: 100,
        >   top: 50,
        >   right: 300,
        >   bottom: 350
        >}
    */

    getPosition: function(){
        var obj = {};
        obj.width = this.offsetWidth;
        obj.height = this.offsetHeight;
        obj.left = this.getLeft();
        obj.top = this.getTop();
        obj.right = obj.left + obj.width;
        obj.bottom = obj.top + obj.height;
        return obj;
    }

});/*
Script: Fxpack.js
    More Specific Effects.

Author:
    Valerio Proietti, <http://mad4milk.net>

License:
    MIT-style license.
        
Dependencies:
    <Moo.js>, <Function.js>, <Array.js>, <String.js>, <Element.js>, <Fx.js>

*/

/*      
Class: Fx.Scroll
    The scroller effect; scrolls an element or the window to a location. Extends <Fx.Base>, inherits all its properties.

Arguments:
    el - the $(element) to apply the style transition to
    options - the Fx.Base options (see: <Fx.Base>)
*/

Fx.Scroll = Fx.Base.extend({

    initialize: function(el, options) {
        this.element = $(el);
        this.setOptions(options);
    },
    
    /*  
    Property: down
        Scrolls an element down to the bottom of its scroll height.
    */

    down: function(){
        return this.custom(this.element.scrollTop, this.element.scrollHeight-this.element.offsetHeight);
    },
    
    /*
    Property: up
        Scrolls an element up to the top of its scroll height.
    */

    up: function(){
        return this.custom(this.element.scrollTop, 0);
    },

    increase: function(){
        this.element.scrollTop = this.now;
    }
});

/*
Class: Fx.Slide
    The slide effect; slides an element in horizontally or vertically, the contents will fold inside. Extends <Fx.Base>, inherits all its properties.
    
Note:
    This effect works on any block element, but the element *cannot be positioned*; no margins or absolute positions. To position the element, put it inside another element (a wrapper div, for instance) and position that instead.
    
Options:
    mode - set it to vertical or horizontal. Defaults to vertical.
    and all the <Fx.Base> options

Example:
    (start code)
    var mySlider = new Fx.Slide('myElement', {duration: 500});
    mySlider.toggle() //toggle the slider up and down.
    (end)
*/

Fx.Slide = Fx.Base.extend({

    initialize: function(el, options){
        this.element = $(el);
        this.wrapper = new Element('div').injectAfter(this.element).setStyle('overflow', 'hidden').adopt(this.element);
        this.setOptions(options);
        if (!this.options.mode) this.options.mode = 'vertical';
        this.now = [];
    },

    setNow: function(){
        [0,1].each(function(i){
            this.now[i] = this.compute(this.from[i], this.to[i]);
        }, this);
    },

    vertical: function(){
        this.margin = 'top';
        this.layout = 'height';
        this.startPosition = [this.element.scrollHeight, '0'];
        this.endPosition = ['0', -this.element.scrollHeight];
        return this;
    },

    horizontal: function(){
        this.margin = 'left';
        this.layout = 'width';
        this.startPosition = [this.element.scrollWidth, '0'];
        this.endPosition = ['0', -this.element.scrollWidth];
        return this;
    },
    
    /*
    Property: hide
        Hides the element without a transition.
    */

    hide: function(){
        this[this.options.mode]();
        this.wrapper.setStyle(this.layout, '0');
        this.element.setStyle('margin-'+this.margin, -this.element['scroll'+this.layout.capitalize()]+this.options.unit);
        return this;
    },
    
    /*
    Property: show
        Shows the element without a transition.
    */

    show: function(){
        this[this.options.mode]();
        this.wrapper.setStyle(this.layout, this.element['scroll'+this.layout.capitalize()]+this.options.unit);
        this.element.setStyle('margin-'+this.margin, '0');
        return this;
    },
    
    /*
    Property: toggle
        Hides or shows a slide element, depending on its state;
    */

    toggle: function(mode){
        this[this.options.mode]();
        if (this.wrapper['offset'+this.layout.capitalize()] > 0) return this.custom(this.startPosition, this.endPosition);
        else return this.custom(this.endPosition, this.startPosition);
    },

    increase: function(){       
        this.wrapper.setStyle(this.layout, this.now[0]+this.options.unit);
        this.element.setStyle('margin-'+this.margin, this.now[1]+this.options.unit);
    }
    
});

/*
Class: Fx.Color
    Smoothly transitions the color of an element; Extends <Fx.Base>, inherits all its properties.
    
Credits:
    fx.Color, originally by Tom Jensen (http://neuemusic.com) MIT-style LICENSE.
    
Arguments:
    same arguments as <Fx.Style>, only accepts color based properties.
    
Example:
    (start code)
    var myColorFx = new Fx.Color('myElement', 'color', {duration: 500});
    myColorFx.custom('000000', 'FF0000') //fade from black to red
    (end)
*/

Fx.Color = Fx.Base.extend({

    initialize: function(el, property, options){
        this.element = $(el);
        this.setOptions(options);
        this.property = property;
        this.now = [];
    },

    /*  
    Property: custom
        Transitions one color of the element specified in class creation smoothly from one color to the next.
        
    Arguments:
        from - the starting color
        to - the ending color
        
    Note:
        Both values can be any of the following formats:
        '#333' - css shorthand with the hash
        '333' - or without the hash
        '#333333' - css longhand with the hash
        '333333' - without the hash
    */

    custom: function(from, to){
        return this.parent(from.hexToRgb(true), to.hexToRgb(true));
    },

    setNow: function(){
        [0,1,2].each(function(i){
            this.now[i] = Math.round(this.compute(this.from[i], this.to[i]));
        }, this);
    },

    increase: function(){
        this.element.setStyle(this.property, "rgb("+this.now[0]+","+this.now[1]+","+this.now[2]+")");
    },
    
    /*  
    Property: fromColor
        Transitions from the color passed in to the current color of the element.
        
    Arguments:
        color - the color to transition *from* to the current color of the element.
        
    Example:
        >myColorFx.fromColor('F00') //transition from red to whatever color the element is currently
    */

    fromColor: function(color){
        return this.custom(color, this.element.getStyle(this.property));
    },
    
    /*  
    Property: toColor
        Transitions to the color passed in from the current color of the element.
        
    Arguments:
        color - the color to transition *to* from the current color of the element.
        
    Example:
        >myColorFx.toColor('F00') //transition from whatever color the element is currently to red
    */
    
    toColor: function(color){
        return this.custom(this.element.getStyle(this.property), color);
    }

});/*
Script: Fxtransitions.js
    Cool transitions,  to be used with <Fx.Js>
    
Dependencies:
    <Fx.js>

Author:
    Robert Penner, <http://www.robertpenner.com/easing/>, modified to be used with mootools.
        
License:
    Easing Equations v1.5, (c) 2003 Robert Penner, all rights reserved. Open Source BSD License.
*/

/*
Class: Fx.Transitions
    A collection of tweaning transitions for use with the <Fx.Base> classes.
*/

Fx.Transitions = {

    /* Property: linear */
    linear: function(t, b, c, d){
        return c*t/d + b;
    },
    
    /* Property: quadIn */
    quadIn: function(t, b, c, d){
        return c*(t/=d)*t + b;
    },

    /* Property: quatOut */
    quadOut: function(t, b, c, d){
        return -c *(t/=d)*(t-2) + b;
    },

    /* Property: quadInOut */
    quadInOut: function(t, b, c, d){
        if ((t/=d/2) < 1) return c/2*t*t + b;
        return -c/2 * ((--t)*(t-2) - 1) + b;
    },

    /* Property: cubicIn */
    cubicIn: function(t, b, c, d){
        return c*(t/=d)*t*t + b;
    },

    /* Property: cubicOut */
    cubicOut: function(t, b, c, d){
        return c*((t=t/d-1)*t*t + 1) + b;
    },

    /* Property: cubicInOut */
    cubicInOut: function(t, b, c, d){
        if ((t/=d/2) < 1) return c/2*t*t*t + b;
        return c/2*((t-=2)*t*t + 2) + b;
    },

    /* Property: quartIn */
    quartIn: function(t, b, c, d){
        return c*(t/=d)*t*t*t + b;
    },

    /* Property: quartOut */
    quartOut: function(t, b, c, d){
        return -c * ((t=t/d-1)*t*t*t - 1) + b;
    },

    /* Property: quartInOut */
    quartInOut: function(t, b, c, d){
        if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
        return -c/2 * ((t-=2)*t*t*t - 2) + b;
    },

    /* Property: quintIn */
    quintIn: function(t, b, c, d){
        return c*(t/=d)*t*t*t*t + b;
    },

    /* Property: quintOut */
    quintOut: function(t, b, c, d){
        return c*((t=t/d-1)*t*t*t*t + 1) + b;
    },

    /* Property: quintInOut */
    quintInOut: function(t, b, c, d){
        if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
        return c/2*((t-=2)*t*t*t*t + 2) + b;
    },

    /* Property: sineIn */
    sineIn: function(t, b, c, d){
        return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
    },

    /* Property: sineOut */
    sineOut: function(t, b, c, d){
        return c * Math.sin(t/d * (Math.PI/2)) + b;
    },

    /* Property: sineInOut */
    sineInOut: function(t, b, c, d){
        return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
    },

    /* Property: expoIn */
    expoIn: function(t, b, c, d){
        return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
    },

    /* Property: expoOut */
    expoOut: function(t, b, c, d){
        return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
    },

    /* Property: expoInOut */
    expoInOut: function(t, b, c, d){
        if (t==0) return b;
        if (t==d) return b+c;
        if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
        return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
    },

    /* Property: circIn */
    circIn: function(t, b, c, d){
        return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
    },

    /* Property: circOut */
    circOut: function(t, b, c, d){
        return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
    },

    /* Property: circInOut */
    circInOut: function(t, b, c, d){
        if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
        return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
    },

    /* Property: elasticIn */
    elasticIn: function(t, b, c, d, a, p){
        if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3; if (!a) a = 1;
        if (a < Math.abs(c)){ a=c; var s=p/4; }
        else var s = p/(2*Math.PI) * Math.asin(c/a);
        return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
    },

    /* Property: elasticOut */
    elasticOut: function(t, b, c, d, a, p){
        if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3; if (!a) a = 1;
        if (a < Math.abs(c)){ a=c; var s=p/4; }
        else var s = p/(2*Math.PI) * Math.asin(c/a);
        return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
    },

    /* Property: elasticInOut */
    elasticInOut: function(t, b, c, d, a, p){
        if (t==0) return b;  if ((t/=d/2)==2) return b+c;  if (!p) p=d*(.3*1.5); if (!a) a = 1;
        if (a < Math.abs(c)){ a=c; var s=p/4; }
        else var s = p/(2*Math.PI) * Math.asin(c/a);
        if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
        return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
    },

    /* Property: backIn */
    backIn: function(t, b, c, d, s){
        if (!s) s = 1.70158;
        return c*(t/=d)*t*((s+1)*t - s) + b;
    },

    /* Property: backOut */
    backOut: function(t, b, c, d, s){
        if (!s) s = 1.70158;
        return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
    },

    /* Property: backInOut */
    backInOut: function(t, b, c, d, s){
        if (!s) s = 1.70158;
        if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
        return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
    },

    /* Property: bounceIn */
    bounceIn: function(t, b, c, d){
        return c - Fx.Transitions.bounceOut (d-t, 0, c, d) + b;
    },

    /* Property: bounceOut */
    bounceOut: function(t, b, c, d){
        if ((t/=d) < (1/2.75)){
            return c*(7.5625*t*t) + b;
        } else if (t < (2/2.75)){
            return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
        } else if (t < (2.5/2.75)){
            return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
        } else {
            return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
        }
    },

    /* Property: bounceInOut */
    bounceInOut: function(t, b, c, d){
        if (t < d/2) return Fx.Transitions.bounceIn(t*2, 0, c, d) * .5 + b;
        return Fx.Transitions.bounceOut(t*2-d, 0, c, d) * .5 + c*.5 + b;
    }   

};/*    
Script: Fxutils.js
        Contains Fx.Height, Fx.Width, Fx.Opacity. Only useful if you really, really need to toggle those values, and toggling only works in STRICT DOCTYPE.
        See <Fx.Style> for a better alternative.

Dependencies:
    <Moo.js>, <Function.js>, <Array.js>, <String.js>, <Element.js>, <Fx.js>
    
Author:
    Valerio Proietti, <http://mad4milk.net>

License:
    MIT-style license.
*/

/*
Class: Fx.Height
    Alters the height of an element. Extends <Fx.Style> (and consequentially <Fx.Base>), and inherits all its methods.

Arguments:
    el - the $(element) to apply the style transition to
    options - the Fx.Base options (see: <Fx.Base>)
    
Example:
    >var myEffect = new Fx.Height('myElementId', {duration: 500});
    >myEffect.toggle(); //will close the element if open, and vice-versa.
*/

Fx.Height = Fx.Style.extend({

    initialize: function(el, options){
        this.parent(el, 'height', options);
        this.element.setStyle('overflow', 'hidden');
    },
    
    /*
    Property: toggle
        Toggles the height of an element from zero to it's scrollHeight, and vice-versa.
    */

    toggle: function(){
        if (this.element.offsetHeight > 0) return this.custom(this.element.offsetHeight, 0);
        else return this.custom(0, this.element.scrollHeight);
    },

    /*
    Property: show
        Size the element to its full scrollHeight immediatly, without applying a transition.
    */

    show: function(){
        return this.set(this.element.scrollHeight);
    }

});

/*
Class: Fx.Width
    Same as Fx.Height, but uses Width. It always toggles from its initial width to zero, and vice versa.
*/

Fx.Width = Fx.Style.extend({

    initialize: function(el, options){
        this.parent(el, 'width', options);
        this.element.setStyle('overflow', 'hidden');
        this.iniWidth = this.element.offsetWidth;
    },

    toggle: function(){
        if (this.element.offsetWidth > 0) return this.custom(this.element.offsetWidth, 0);
        else return this.custom(0, this.iniWidth);
    },

    show: function(){
        return this.set(this.iniWidth);
    }

});

/*
Class: Fx.Opacity
    Same as Fx.Height, but uses Opacity. It always toggles from opaque to transparent, and vice versa.
*/

Fx.Opacity = Fx.Style.extend({

    initialize: function(el, options){
        this.parent(el, 'opacity', options);
        this.now = 1;
    },

    toggle: function(){
        if (this.now > 0) return this.custom(1, 0);
        else return this.custom(0, 1);
    },

    show: function(){
        return this.set(1);
    }

});/*
Script: Sortables.js
    Contains <Sortables> Class.
    
Dependencies:
    <Moo.js>, <Function.js>, <Array.js>, <String.js>, <Element.js>, <Fx.js>, <Drag.js>
    
Author:
    Valerio Proietti, <http://mad4milk.net>

License:
    MIT-style license.
*/

/*
Class: Sortables
    Creates an interface for <Drag> and drop, resorting of a list.

Arguments:
    elements - requires,  the collection of elements that will become sortables.
    options - an Object, see options below.

Options:
    handles - a collection of elements to be used for drag handles. defaults to the elements.
    fxDuration - the duration in ms of the effects applied to the dragged element and its clone. defaults to 250 ms.
    fxTransition - the transition for the effects (see also: <Fx.Transitions>).
    maxOpacity - the opacity for the dragged clone
    onStart - function executed when the item starts dragging
    onComplete - function executed when the item ends dragging
    contain - boolean, true keeps the dragged item constrained to it's parent element, defaults to false.
*/
    
var Sortables = new Class({

    setOptions: function(options) {
        this.options = {
            handles: false,
            fxDuration: 250,
            fxTransition: Fx.Transitions.sineInOut,
            maxOpacity: 0.5,
            onComplete: Class.empty,
            onStart: Class.empty,
            contain: false
        };
        Object.extend(this.options, options || {});
    },

    initialize: function(elements, options){
        this.setOptions(options);
        this.options.handles = this.options.handles || elements;
        var trash = new Element('div').injectInside($(document.body));
        $A(elements).each(function(el, i){
            var copy = $(el).clone().setStyles({
                'position': 'absolute',
                'opacity': '0',
                'display': 'none'
            }).injectInside(trash);
            var elEffect = el.effect('opacity', {
                duration: this.options.fxDuration,
                wait: false,
                transition: this.options.fxTransition
            }).set(1);
            var copyEffects = copy.effects({
                duration: this.options.fxDuration,
                wait: false,
                transition: this.options.fxTransition,
                onComplete: function(){
                    copy.setStyle('display', 'none');
                }
            });
            var yMax = false;
            var yMin = false;
            if (this.options.contain){
                yMax = $(el.parentNode).getTop()+el.parentNode.offsetHeight-el.offsetHeight;
                yMin = el.parentNode.getTop();
            }
            var dragger = new Drag.Move(copy, {
                handle: this.options.handles[i],
                yMax: yMax,
                yMin: yMin,
                xModifier: false,
                onStart: function(){
                    this.options.onStart.bind(this).delay(10);
                    copy.setHTML(el.innerHTML).setStyles({
                        'display': 'block',
                        'opacity': this.options.maxOpacity,
                        'top': el.getTop()+'px',
                        'left': el.getLeft()+'px'
                    });
                    elEffect.custom(elEffect.now, this.options.maxOpacity);
                }.bind(this),
                onComplete: function(){
                    this.options.onComplete.bind(this).delay(10);
                    copyEffects.custom({
                        'opacity': [this.options.maxOpacity, 0],
                        'top': [copy.getTop(), el.getTop()]
                    });
                    elEffect.custom(elEffect.now, 1);
                }.bind(this),
                onDrag: function(){
                    if (el.getPrevious() && copy.getTop() < (el.getPrevious().getTop())) el.injectBefore(el.getPrevious());
                    else if (el.getNext() && copy.getTop() > (el.getNext().getTop())) el.injectAfter(el.getNext());
                }
            });
        }, this);
    }

});/*   
Script: Tips.js
    Tooltips, BubbleTips, whatever they are, they will appear on mouseover
    
Dependencies:
    <Moo.js>, <Function.js>, <Array.js>, <String.js>, <Element.js>, <Fx.js>
    
Author:
    Valerio Proietti, <http://mad4milk.net>

License:
    MIT-style license.
    
Credits:
    Tips.js is based on Bubble Tooltips (<http://web-graphics.com/mtarchive/001717.php>) by Alessandro Fulcitiniti <http://web-graphics.com>
*/

/*
Class: Tips
    Display a tip on any element with a title and/or href.

Arguments: 
    elements - a collection of elements to apply the tooltips to on mouseover.
    options - an object. See options Below.

Options: 
    transitionStart - the transition effect used to show the tip (see <Fx.Transitions>).
    transitionEnd - the transition effect used to hide the tip (see <Fx.Transitions>).
    maxTitleChars - the maximum number of characters to display in the title of the tip. defaults to 30.
    fxDuration - the duration (in ms) for the transition effect when the tip to appears and disappears. defaults to 150.
    maxOpacity - how opaque to make the tooltip (0 = 0% opaque, 1= 100% opaque). defaults to 1.
    timeOut - the delay to wait to show the tip (how long the user must hover to have the tooltip appear). defaults to 100.
    className - the class name to apply to the tooltip

Example:
    (start code)
    <img src="/images/i.png" title="The body of the tooltip is stored in the title" tooltitle="The Title of the Tooltip" class="toolTipImg"/>
    <script>
        var myTips = new Tips($S('.toolTipImg'), {
            maxTitleChars: 50, //I like my captions a little long
            maxOpacity: .9, //let's leave a little transparancy in there
        });
    </script>
    (end)
*/

var Tips = new Class({

    setOptions: function(options){
        this.options = {
            transitionStart: Fx.Transitions.sineInOut,
            transitionEnd: Fx.Transitions.sineInOut,
            maxTitleChars: 30,
            fxDuration: 150,
            maxOpacity: 1,
            timeOut: 100,
            className: 'tooltip'
        }
        Object.extend(this.options, options || {});
    },

    initialize: function(elements, options){
        this.elements = elements;
        this.setOptions(options);
        this.toolTip = new Element('div').addClassName(this.options.className).setStyle('position', 'absolute').injectInside(document.body);
        this.toolTitle = new Element('H4').injectInside(this.toolTip);
        this.toolText = new Element('p').injectInside(this.toolTip);
        this.fx = new fx.Style(this.toolTip, 'opacity', {duration: this.options.fxDuration, wait: false}).hide();
        $A(elements).each(function(el){
            $(el).myText = el.title || false;
            if (el.myText) el.removeAttribute('title');
            if (el.href){
                if (el.href.test('http://')) el.myTitle = el.href.replace('http://', '');
                if (el.href.length > this.options.maxTitleChars) el.myTitle = el.href.substr(0,this.options.maxTitleChars-3)+"...";
            }
            if (el.myText && el.myText.test('::')){
                var dual = el.myText.split('::');
                el.myTitle = dual[0].trim();
                el.myText = dual[1].trim();
            } 
            el.onmouseover = function(){
                this.show(el);
                return false;
            }.bind(this);
            el.onmousemove = this.locate.bindAsEventListener(this);
            el.onmouseout = function(){
                this.timer = $clear(this.timer);
                this.disappear();
            }.bind(this);
        }, this);
    },

    show: function(el){
        this.toolTitle.innerHTML = el.myTitle;
        this.toolText.innerHTML = el.myText;
        this.timer = $clear(this.timer);
        this.fx.options.transition = this.options.transitionStart;
        this.timer = this.appear.delay(this.options.timeOut, this);
    },

    appear: function(){
        this.fx.custom(this.fx.now, this.options.maxOpacity);
    },

    locate: function(evt){
        var doc = document.documentElement;
        this.toolTip.setStyles({'top': evt.clientY + doc.scrollTop + 15 + 'px', 'left': evt.clientX + doc.scrollLeft - 30 + 'px'});
    },

    disappear: function(){
        this.fx.options.transition = this.options.transitionEnd;
        this.fx.custom(this.fx.now, 0);
    }

});//adds functionality to a class to block out the page with a semi-transparent layer
var modalizer = new Class({
    modalOptions: {
            color: '#333',
            zIndex: 5000,
            opacity: .8,
            elementsToHide: 'select', //comma seperated string of selectors: 'select, input, img.someClass'
            onModalHide: Class.empty,
            onModalShow: Class.empty
    },
    modalShow: function(){
        if(!$('modalOverlay')) {
            var overlay = new Element('div').setProperty('id','modalOverlay').injectInside(document.body).setStyles({
                    'display':'block',
                    'position':'fixed',
                    'top':'0px',
                    'left':'0px',   
                    'width':'100%',
                    'height':'100%',
                    'z-index':this.modalOptions.zIndex,
                    'background-color':this.modalOptions.color,
                    'opacity':this.modalOptions.opacity
            });
            if(is_ie6) overlay.setStyle('position','absolute');
            $('modalOverlay').addEvent('click', function(){
                this.modalHide();
            }.bind(this));
        }
        this.modalOptions.onModalShow();
        $('modalOverlay').show('block');
    },
    modalHide: function(){
        this.togglePopThroughElements(1);
        this.modalOptions.onModalHide();
        if($('modalOverlay'))$('modalOverlay').hide();
    },
    togglePopThroughElements: function(opacity){
        document.getElementsBySelector(this.modalOptions.elementsToHide).each(function(sel){
            sel.setStyle('opacity', opacity);
        });
    }
});//creates a div with your content on the page at the location relative to the element you specify
var stickyWin = new Class({
    initialize: function(options){
            this.options = this.setOptions(this.defaultOptions, options);
            this.makeWindow();
            if(this.options.content) this.setContent(this.options.content);
            if(this.options.showNow) this.show();
    },
    defaultOptions: {
            onStart: Class.empty,
            onDisplay: Class.empty,
            onClose: Class.empty,
            closeClassName: 'closeSticky',
            content: '',
            zIndex: 10000,
            id: 'stickyWin',
            className: '',
            position: 'center', //center, corner
            offsetTop: 0,
            offsetLeft: 0,
            relativeTo: document.body, 
            width: false,
            height: false,
            timeout: -1,
            allowMultipleByClass: false,
            allowMultiple: true,
            showNow: true,
            useIframeShim: true
    },
    setOptions: function(defaults, options){
        return Object.extend(defaults, options || {});
    },
    makeWindow: function(){
        this.destroyOthers();
        this.win = new Element('div').setProperty('id',
            this.options.id).addClass(this.options.className).addClass('stickyWinInstance').addClass('clearfix').setStyles({
                'display':'none',
                'position':'absolute',
                'zIndex':this.options.zIndex
            }).injectInside(document.body);
        if($type.isNumber(this.options.width)) this.win.setStyle('width', this.options.width.toInt() + 'px');
        if($type.isNumber(this.options.height)) this.win.setStyle('height', this.options.height.toInt() + 'px');
        return this;
    },
    show: function(){
        this.position();
        this.showWin();
        if(this.options.useIframeShim) this.showIframeShim();
        this.visible = true;
        return this;
    },
    showWin: function(){
        this.win.show();
    },
    hide: function(){
        this.hideWin();
        if(this.options.useIframeShim) this.hideIframeShim();
        this.visible = false;
        return this;
    },
    hideWin: function(){
        this.win.hide();
    },
    destroyOthers: function() {
        if(!this.options.allowMultipleByClass || !this.options.allowMultiple) {
            $$('div.stickyWinInstance').each(function(sw) {
                if(!this.options.allowMultiple || (!this.options.allowMultipleByClass && sw.hasClass(this.options.className))) 
                    sw.remove();
            }, this);
        }
        if($(this.options.id)) $(this.options.id).remove();
    },
    setContent: function(html) {
        this.win.setHTML(html);
        this.win.getElements('.'+this.options.closeClassName).each(function(el){
            dbug.log('setting up close click for %o', el);
            el.addEvent('click', this.hide.bind(this));
        }, this);
        return this;
    },
    position: function(){
        var rel = $(this.options.relativeTo) || document.body;
        if (!$(this.options.relativeTo)) this.options.position = 'center';
        var top = (rel == document.body)?Window.getScrollTop():rel.getTop();
        if (top < 0) top = 0;
        var left = (rel == document.body)?Window.getScrollLeft():rel.getLeft();
        if (left < 0) left = 0;
        
        var dim = this.win.getDimensions();
        switch(this.options.position) {
            case 'center':              
                var relTop = ((rel == document.body)?Window.getHeight():rel.offsetHeight)/2;
                var relLeft = ((rel == document.body)?Window.getWidth():rel.offsetWidth)/2;
                var finalTop = top + relTop - (dim.height/2);
                var finalLeft = left + relLeft - (dim.width/2);
                if(finalTop < 0) finalTop = 0;
                if(finalLeft < 0) finalLeft = 0;
                this.win.setStyles({
                    'top': finalTop + 'px',
                    'left': finalLeft + 'px'
                });
                break;
            case 'corner':
                this.win.setStyles({
                    'top':top + 'px',
                    'left':left + 'px'
                });
                break;
        }
        if(this.shim) this.shim.position();
        return this;
    },
    makeIframeShim: function(){
        if(!this.shim){
            this.shim = new iframeShim({
                element: $('stickyWinOverlay') || this.win,
                display: false,
                name: 'stickyWinShim'
            });
        }
    },
    showIframeShim: function(){
        this.makeIframeShim();
        this.shim.show();           
    },
    hideIframeShim: function(){
        this.shim.hide();
    },
    destroy: function(){
        this.win.remove();
        this.shim.remove();
        $('stickyWinOverlay').remove();
    }
});

//creates a stickyWin that can fade in and out, can be dragged, and can be resized
var stickyWinFx = stickyWin.extend({
    initialize: function(options){
        this.defaultOptions = this.setOptions(this.defaultOptions, {
            fade: true,
            fadeDuration: 150,
            fadeTransition: Fx.Transitions.sineInOut,
            draggable: false,
            dragOptions: {},
            dragHandleSelector: '',
            resizable: false,
            resizeOptions: {},
            resizeHandleSelector: ''
        });
        this.parent(options);
        if(this.options.draggable) this.makeDraggable();
        if(this.options.resizable) this.makeResizable();
    },
    hideWin: function(){
        if(this.options.fade) this.fade(1,0);
        else this.win.hide();
    },
    showWin: function(){
        if(this.options.fade) this.fade(0,1);
        else this.win.show();
    },
    fade: function(from,to){
        if(!this.fadeFx) {
            this.win.setStyles({
                'opacity':'0',
                'display':'block'
            });
            this.fadeFx = this.win.effect('opacity', {
                duration: this.options.fadeDuration,
                transition: this.options.fadeTransition
            });
        }
        this.fadeFx.custom(from,to);
        return this;
    },
    makeDraggable: function(){
        if(this.options.useIframeShim) {
            this.makeIframeShim();
            var dragComplete = this.options.dragOptions.onComplete || Class.empty;
            this.options.dragOptions.onComplete = function(){
                dragComplete();
                this.shim.position();
            }.bind(this);
        }
        if(this.options.dragHandleSelector) this.options.dragOptions.handle = this.win.getElement(this.options.dragHandleSelector);
        this.win.makeDraggable(this.options.dragOptions);
    }, 
    makeResizable: function(){
        if(this.options.useIframeShim) {
            this.makeIframeShim();
            var resizeComplete = this.options.resizeOptions.onComplete || Class.empty;
            this.options.resizeOptions.onComplete = function(){
                resizeComplete();
                this.shim.position();
            }.bind(this);
        }
        if(this.options.resizeHandleSelector) this.options.resizeOptions.handle = this.win.getElement(this.options.resizeHandleSelector);
        this.win.makeResizable(this.options.resizeOptions);
    }
});

var modalWinBase = {
    initialize: function(options){
        this.parent(options);
        this.modalOptions.onModalHide = this.hideWin.pass(false);
        this.modalOptions = this.setOptions(this.modalOptions, options);
    },
    showWin: function(showModal){
        if($pick(showModal, true))this.modalShow();
        this.parent();
    },
    hideWin: function(hideModal){
        if($pick(hideModal, true))this.modalHide();
        this.parent();
    }
};

//makes a modal stickyWin
var stickyWinModal = stickyWin.extend(modalWinBase);
stickyWinModal.implement(new modalizer);

//makes a modal stickyWin that can fade, drag, and resize
var stickyWinFxModal = stickyWinFx.extend(modalWinBase);
stickyWinFxModal.implement(new modalizer);
var simpleErrorPopup = function(msghdr, msg) {
    var body =  '<style>' +
        '#simpleErrorBox { width: 225px; font-family: verdana; font-size: 11px; color: #5d5b4a; text-align: left;}' +
        '#simpleErrorBox .boxtop {background:url(http://www.download.com/i/dl/watchlist/error_boxtop.gif) no-repeat; height: 22px; padding: 6px 8px 0px 12px; margin: 0px; font-size: 10px; color: #5d5b4a; font-weight: bold; }' +
        '#simpleErrorBox .boxbody { background:url(http://www.download.com/i/dl/watchlist/error_boxback.gif); padding: 1px; margin: 0px; }' +
        '#simpleErrorBox img { vertical-align: middle; position: relative; top: -1px; padding: 0px 2px 0px 2px; }' +
        '#simpleErrorBox img.closebtn { float: right; padding: 3px 8px 0px 0px; border: 0px;}' +
        '#simpleErrorBox p { padding: 0px 14px 0px 14px; margin: 6px 0px 6px 0px; }' +
        '#simpleErrorBox p.errorMsg { color: #990000; font-weight: bold; }' +
        '#simpleErrorBox p.errorMsg a { color: #990000; text-decoration: underline; }' +
        '#simpleErrorBox p.errorMsg img.bang { float: left; width: 30px; height: 30px; margin: 3px 5px 5px 0px; }' +
        '#simpleErrorBox hr { width: 200px; margin: 0px 14px 5px 11px; background: url(http://i.d.com.com/i/dl/global/dotted_div_hor.gif) repeat-x; border: 0px; padding: 0px; height: 1px; }' +
        '#simpleErrorBox .boxbottom { background:url(http://www.download.com/i/dl/watchlist/error_boxbottom.gif) no-repeat; height: 11px; padding: 0px; margin: 0px; }' +
        '</style>' +
        '<div id="simpleErrorBox">' +
        '<div class="boxtop clearfix">' +
        '<a href="javascript:void(0);" class="closeSticky"><img src="http://i.d.com.com/i/dl/watchlist/closebtn.gif" width="13" height="13" onmouseover="this.src=\'http://i.d.com.com/i/dl/watchlist/closebtn_over.gif\'" onmouseout="this.src=\'http://i.d.com.com/i/dl/watchlist/closebtn.gif\'" class="closebtn"></a>' +
        msghdr +
        '</div>' +
        '<div class="boxbody clearfix">' +
        '<p class="errorMsg clearfix">' +
        '<img src="http://i.d.com.com/i/dl/products/icon_problems_sm.gif" class="bang clearfix">' +
        msg +
        '</p>' +
        '</div>' +
        '<div class="boxbottom">' +
        '</div>' +
        '</div>';
    return new stickyWinModal({
        content: body,
        position: 'center', //center, corner
        allowMultiple: false
    });
};
