Docs Home

@File: /surebert/sb.js

@File: /surebert/sb.js

@Author: Paul Visco of http://paul.estrip.org

@Version: 4.601 04/24/04 - 11/21/08

$

@File: /surebert/sb.js

@Description: One of the most important parts of the surebert library. Can reference DOM elements in many way using CSS selectors. The simplest use of it is to reference DOM elements by their id property.


@Param: String Use CSS selectors to return the elements desired
@Example:

e.g.'#myForm' An element id. When passed an element ID it returns a reference to the element with that id'

e.g.'body' An tag name. When passed a tag name it returns an array of all the tags that match that tag name. If the tag is found in sb.singleTags e.g. body, head, title then only one element is returned instead of an array

e.g. '#myDiv' returns node with the id 'myDiv'

e.g. '.myClass' returns all nodes with the class 'myClass', see also [class="myClass"] below

e.g. '*' returns all nodes

e.g. '#myDiv p' returns all the p tags that are decendents of #myDiv

e.g. '#myDiv > p' returns all the p tags that are direct decendents of #myDiv

e.g. 'p + b' returns all the b tags that are direct adjacent siblings of p tags

e.g. 'div ~ p' a p element preceded by an div element

e.g 'p:first-child' returns all the p tags that are the first child of their parent, be careful its not the first child of each p tag

e.g. 'p:last-child' returns all the p tags that are the last child of their parent

e.g. 'p:empty' returns all the p tags that are empty

e.g '#myDiv *:not(p)' returns all nodes that are not p tags within #myDiv

e.g 'input[name"choosen"]' returns all the input nodes with the name 'choosen'

e.g. 'a[href="http://www.surebert.com"] return all the a tags that have the href http://www.surebert.com

e.g. 'a[href$="google.com"] return all the a tags that end in google.com

e.g. 'a[href^="http"] return all the a tags that start with http

e.g. 'a[href*="surebert"] return all the a tags that have the substring "surebert" in them

e.g. a[hreflang|="en"]    returns all a tags whose "hreflang" attribute has a hyphen-separated list of values beginning (from the left) with "en"

e.g. 'p[class~="bob"] returns an array of all p tags whose "class" attribute value is a list of space-separated values, one of which is exactly equal to "bob"

e.g. 'p, b, #wrapper' Commas allow you to make multiple selections at once.This example returns all b nodes, all p nodes and node with the id 'wrapper'

e.g '*:not(p)' LIMITED SUPPORT - returns all nodes that are not p tags

Array.prototype.inArray

@File: /surebert/sb.js

@Description: Checks to see if a value is contained in the array


@Param: Object/String/Number val Method checks to see if val is in the array
@Returns: Boolean True or False
@Example:

var myArray = [1,2,3];
var answer = myArray.inArray(2);
//answer is true

Array.prototype.remove

@File: /surebert/sb.js

@Author: Paul Visco

@Version: 1.1 11/19/07

@Description: Removes a value or a set of values from an array.


@Param: values Array If passed an array of values, all the values in the argument array are removed from the array being manipulated
@Param: value Object/String/Number If a single object, string, number, etc is passed to the function than only that value is removed.
@Returns: Array Returns the array minus the values that were specified for removal.
@Example:

var myArray = [5, 10, 15];
var answer = myArray.remove([10,5]);
//answer =[15];

var answer = myArray.remove(5);
//answer =[10, 15];

Element.prototype.addClassName

@File: /surebert/sb.js

@Description: Adds a className to the sb.element, using this methods sb.element instances can have multiple classNames


@Param: String c The classname to add
@Returns: returns itself
@Example:

myElement.addClassName('redStripe');

Element.prototype.append

@File: /surebert/sb.js

@Description: Appends another DOM element to the element as a child


@Param: Element, String el Another DOM element reference or a string that can be passed through sb.$ to return a DOM node.
@Example:

myElement.append(myOtherElement);

Element.prototype.appendAfter

@File: /surebert/sb.js

@Description: Appends the element after another DOM element as a sibling


@Param: Element, String el Another DOM element reference or a string that can be passed through sb.$ to return a DOM node.
@Example:

//appends myElement to the parent of "#myDiv" as a sibling of "#myDiv" directly after "#myDiv"
myElement.appendAfter('#myDiv');

Element.prototype.appendBefore

@File: /surebert/sb.js

@Description: Appends the element before another DOM element as a sibling


@Param: Element, String el Another DOM element reference or a string that can be passed through sb.$ to return a DOM node.
@Example:

//appends myElement to the parent of "#myDiv" as a sibling of "#myDiv" directly before "#myDiv"
myElement.appendBefore('#myDiv');

Element.prototype.appendTo

@File: /surebert/sb.js

@Description: Appends the element to another DOM element as a child


@Param: Element, String el Another DOM element reference or a string that can be passed through sb.$ to return a DOM node.
@Returns: Element A refernce to the appended node
@Example:

//appends myElement to the page body
myElement.appendTo('body');

//appends myElement to a div with the ID "myDiv"
myElement.appendTo('#myDiv');

Element.prototype.appendToTop

@File: /surebert/sb.js

@Description: Appends the element to the top DOM element as a child


@Param: Element, String el Another DOM element reference or a string that can be passed through sb.$ to return a DOM node.
@Returns: Element A refernce to the appended node
@Example:

//appends myElement to the page body
myElement.appendToTop('body');

//appends myElement to a div with the ID "myDiv"
myElement.appendToTop('#myDiv');

Element.prototype.event

@File: /surebert/sb.js

@Description: Used to set event cross-browser event handlers. For more information see sb.events.


@Param: String evt The event to handle e.g. mouseover, mouseout, mousedown, mouseup, click, dblclick, focus, blurr, scroll, contextmenu, keydown, keyup, keypress
@Param: Function func The function to use as an event handler. It is passed the e from the event in every brower as the first argument. It also references "this" as the object the event is listening on.
@Returns: The event that is added is returned so that you can use the reference to remove it with sb.events.remove or the sb.element instances sb.eventRemove
@Example:


//sets the backgroundColor peroperty to red
myElement.event('click', function(e){
    //alerts the x value of the click
    alert(e.clientX);
    //alerts the innerHTML of myElement
    alert(this.innerHTML);
});

Element.prototype.eventRemove

@File: /surebert/sb.js

@Description: Removes an event created with Element.prototype.event


@Param: String evt An event reference returned from the sb.element instances event method above.
@Example:

//sets the backgroundColor property to red
var myEvt = myElement.event('click', function(e){
    alert(this.innerHTML);
});

myElement.eventRemove(myEvt);

Element.prototype.events

@File: /surebert/sb.js

@Description: Used to assign multiple events at once


@Param: object events
@Example:

var myDiv = $('#myDiv');
myDiv.events({
    click : function(){
        do something
    },
    mouseover : function(){
        //do somthing
    }
});

Element.prototype.eventsAdded

@File: /surebert/sb.js

@Description: Used keep track of events added to a sb.element. All events added with this.event are pushed into this array where they are stored for removal

Element.prototype.eventsRemoveAll

@File: /surebert/sb.js

@Description: Removes all event observers for the sb.element that were added using this.event() or this.events()


@Example:

myElement.eventsRemoveAll();

Element.prototype.getStyle

@File: /surebert/sb.js

@Description: calculates the style of an sb.element based on the current style read from css


@Param: String prop The property to look up
@Returns: returns property value
@Example:

myElement.getStyle('background-color');
//or
myElement.getStyle('backgroundColor').

Element.prototype.getX

@File: /surebert/sb.js

@Description: Calculates the absolute x position of an element


@Returns: Integer the x position of an element
@Example:

myElement.getX();

Element.prototype.getY

@File: /surebert/sb.js

@Description: Calculates the absolute x position of an element


@Returns: Integer the y position of an element
@Example:

myElement.getY();

Element.prototype.hasClassName

@File: /surebert/sb.js

@Description: Checks to see if the element has the className specified. Elements can have more than one className.


@Param: String c The className to check for
@Returns: Boolean True if the element contains the className and False if it doesn't
@Example:

myElement.hasClassName('redStripe');

Element.prototype.lastEventAdded

@File: /surebert/sb.js

@Description: Used keep track of the last event added to a sb.element.

Element.prototype.prototype.getStyle

@File: /surebert/sb.js

@Description: Sets the style of an sb.element


@Param: String prop The property to assign a value to
@Param: String val The value to assign to the property specified
@Returns: returns property value
@Example:

myElement.setStyle('backgroundColor', blue);
//or
myElement.setStyle('opacity', 0.5);

Element.prototype.remove

@File: /surebert/sb.js

@Description: Removes an element from the DOM


@Returns: returns itself
@Example:

myElement.remove();

Element.prototype.removeClassName

@File: /surebert/sb.js

@Description: Removes a className from the elements className array. Elements can have more than one className


@Param: String c Specified the className to remove from the element
@Returns: returns itself
@Example:

myElement.removeClassName('redStripe');

Element.prototype.replace

@File: /surebert/sb.js

@Description: Replaces an element with another element in the DOM


@Param: Object/String A reference to another DOM node, either as a string which is passed to the sb.$ function or as an element reference
@Returns: returns itself
@Example:

myElement.replace('#myOtherElement');

Element.prototype.styles

@File: /surebert/sb.js

@Description: Sets multiple style properties for an sb.element


@Param: Object params An object with css style/value pairs that are applied to the object
@Returns: returns itself
@Example:

myElement.styles({
    backgroundColor : '#000000',
    fontSize : '18px',
    border : '1px solid #FF0000'
});

String.prototype.toCamel

@File: /surebert/sb.js

@Description: Converts all dashes to camelStyle


@Returns: String The original string with dashes converted to camel - useful when switching between CSS and javascript style properties
@Example:

var str = 'background-color';

var newString = str.toCamel();
//newString = 'backgroundColor'

sb.ajax

@File: /surebert/sb.js

@Description: sb.ajax is a constructor that can be used to instanitate objects which communicate in real time from the client to the server without refreshing the page, all properties can be passed as the only object argument


@Returns: Object A new ajax communication object
@Example:

var myAjax = new sb.ajax({
    //optional 'get' is the default
    method : 'post',
    
    //optional 'text' is the default
    format : 'text',
    
    //optional no data needs to be sent to the server side script
    data : 'name=paul&friend=tim&day=monday',
    
    // the server side script to call
    url : 'process.php',
    
    //the handler function receives all data returned from the server side script, depending on the format specified, result has different properties, by default it is a text string
    onResponse : function(result){
        //alerts the text returned from the server side script
        alert(result);
    }
});

sb.ajax.defaultFormat

@File: /surebert/sb.js

@Description: The default way the ajax instances handles the data retreived from the scripts. This sets the default format for all sb.ajax instances that do not already specify a format. It is text by default but you can override this in your script. The options are;


@Example:

sb.ajax.defaultFormat = 'json';

sb.ajax.defaultMethod

@File: /surebert/sb.js

@Description: The default transport method used for communicating with server side scripts. If this is changed, all insatnces with non specified transport methods will use this one. It is 'get' by default. Another option is 'post'.

sb.ajax.defaultURL

@File: /surebert/sb.js

@Description: The default url the ajax instances semd data to. This sets the url for all sb.ajax instances that do not already specify a url.


@Example:

sb.ajax.defaultURL = 'process.php';

sb.ajax.prototype.abort

@File: /surebert/sb.js

@Description: You can use this to abort an ajax function that is fetching. In addition, if you have defined an onabort() method for your sb.ajax instance it will fire whenever the fetch is canceled.


@Example:

    var myAjax = new sb.ajax({
        url : 'process.php'
    });
    myAjax.fetch();
    
    //aborts a fetch already in progress, you could attach this event to a cancel button
    myAjax.abort();
    

sb.ajax.prototype.abort

@File: /surebert/sb.js

@Description: You can use this to abort an ajax function that is fetching. In addition, if you have defined an onabort() method for your sb.ajax instance it will fire whenever the fetch is canceled.


@Example:

    var myAjax = new sb.ajax({
        url : 'process.php',
        onAbort : function(){
            alert('ajax call aborted');
        }
    });
    
    //aborts a fetch already in progress, you could attach this event to a cancel button, also used by timeout
    myAjax.abort();
    

sb.ajax.prototype.async

@File: /surebert/sb.js

@Type: Boolean false performs synchronous and pauses, true performs asynchronously which is the default allowing other processes to continue

@Description: Determines if the script is paused while the data is loaded.


@Example:

    var myAjax = new sb.ajax({
        url : 'process.php',
        async : 1
    });
    
    //or added afterwards with
    myAjax.async = 1;
    

sb.ajax.prototype.completed

@File: /surebert/sb.js

@Type: Boolean

@Description: Is set to 0 when if the ajax call is not complete or set to 1 if it is compelete. Used to check for complete state when using synchronous calls in safari. Each instances completed status is reset on each fetch() call so that asynchronous calls can still be fetched more than once.

sb.ajax.prototype.data

@File: /surebert/sb.js

@Type: String

@Description: The data sent to the server side script specified in the url property. The values are passed as key value pairs e.g. x=1&y=2&name=joe. You should always escape or URIencode data that includes anything other than alphanumeric data.


@Example:

    var myAjax = new sb.ajax({
        url : 'process.php',
        data : 'name=paul&day=monday&value='+escape($('myInput').value)
    });
    
    //or added afterwards with
    myAjax.data = 'name=paul&day=monday&value='+escape($('myInput').value);
    

sb.ajax.prototype.debug

@File: /surebert/sb.js

@Type: Boolean

@Description: Determines if the data sent and received is debugged to the to surebert debug consol which. This only works if you include sb.developer.js This makes debuggin much easier.


@Example:

    var myAjax = new sb.ajax({
        url : 'process.php',
        debug : 1
    });
    
    //or added afterwards with
    myAjax.debug =1;
    

sb.ajax.prototype.fetch

@File: /surebert/sb.js

@Description: Sends any data specified to the external server side file specified in your instances .url property and returns the data recieved to the instance's onResponse method


@Example:

    var myAjax = new sb.ajax({
        url : 'process.php'
    });
    
    //fetches the data from the url specified
    myAjax.fetch();
    

sb.ajax.prototype.format

@File: /surebert/sb.js

@Type: Boolean

@Description: The format the data is retreived in. Can be json, text, xml, head, js, send - s. This value overides any sb.ajax.defaultFormat value set or if the content type of the server page matches a specific format.


@Example:

    var myAjax = new sb.ajax({
        url : 'process.php',
        format : 'json'
    });
    
    //or added afterwards with
    myAjax.format = 'json';
    

sb.ajax.prototype.local

@File: /surebert/sb.js

@Type: Boolean

@Description: Allows ajax object instances to fetch data from a local file instead of from a server. Normally, the instance checks for the HTTP server response - e.g. 200, 404, 500, etc and if you grab a klocal file this does not exist. If you are serving your pages from a web server you should never need to use this.


@Example:

    var myAjax = new sb.ajax({
        url : 'process.php',
        local : 1
    });
    

sb.ajax.prototype.onHeaders

@File: /surebert/sb.js

@Description: Fires when the ajax request gets it headers back


@Example:

    var myAjax = new sb.ajax({
        url : 'process.php',
        onHeaders : function(status, statusText){
            //alert 400 if file not found
            alert(status);
            //you also have access to other headers
            alert(this.getResponseHeader('Content-type');
        }
    });

    

sb.ajax.prototype.onHeaders

@File: /surebert/sb.js

@Description: Fires when the ajax request gets it headers back


@Example:

    var myAjax = new sb.ajax({
        url : 'process.php',
        timeout : 500,
        onTimeout : function(status, statusText){
            //alert 400 if file not found
            alert(status);
            //you also have access to other headers
            alert(this.getResponseHeader('Content-type');
        }
    });
    
    

sb.ajax.prototype.onResponse

@File: /surebert/sb.js

@Description: Fires when the ajax request gets its response back from the server.


@Param: response String, json, or XML depending on ajax instance .format property
@Example:

    var myAjax = new sb.ajax({
        url : 'process.php',
        onResponse : function(response){
            alert(response);
        }
    });
    

sb.ajax.prototype.timeout

@File: /surebert/sb.js

@Description: The amount of time in milliseconds the ajax request will wait before it aborts. This is optional


@Example:

    var myAjax.timeout = 1000;
    
    //fetches the data from the url specified
    myAjax.fetch();
    

sb.browser

@File: /surebert/sb.js

@Description: Find out what browser we are using and gets the query string and screen data

sb.browser.ie6

@File: /surebert/sb.js

@Type: boolean

@Description: Is teh page being displayed with ie 6. Normally you would access this information through sb.browser.agent and sb.browser.version but I added this for convenience with ie6

sb.browser.measure

@File: /surebert/sb.js

@Description: Measures the inside view area of the window


@Example:

    var pos = sb.browser.measure();
    //pos = [800, 642]
    

sb.colors

@File: /surebert/sb.js

@Description: Methods used to calculate and manipulate color values, see also /colors direcory

sb.createIfNotExists

@File: /surebert/sb.js

@Description: Sets up global alias for a variable if one does not already exist.


@Example:

    //checks to see if global jump function exists and creates it if it does not
    sb.createIfNotExists('jump', function(){alert('jump');});
    
    

sb.dom.onReady

@File: /surebert/sb.js

@Description: Used to run a function when a DOM element becomes available


@Param: object o An object of parameters
@Example:


    //In this example the onloaded function fires when the node with the id #navigation is available the onloaded function, receives a this which is essentialy the element passed through sb.$
    sb.dom.onReady({
        id : '#navigation',
        onReady : function(){
            alert(this.innerHTML);
        },
        interval : 100,
        tries : 10,
        ontimeout function(el){
            alert(el+' not found');
        },
        args : ['one', 'two']
    });
    
    

sb.element

@File: /surebert/sb.js

@Description: Used to create DOM nodes. If a string is passed to the fuction it simply return document.createElement(str);


@Param: Object o An object of properties which are used to contruct the DOM object, all properites are appending as properties to the dom object. sb.elements have many methods whcih are all listed in the Element.prototype object below
@Param: String o If passed a nodeName as a string it simply returns document.createElement(nodeName);
@Param: Object sb.element If passed an sb.element it uses that element as a template and clones it
@Returns: Element A DOM element hat can be inserted into the DOM or further manipulated
@Example:
 
var myDiv = new sb.element({
    tag : 'div',
    className : 'redStripe',
    innerHTML : 'I am a redstriped div',
    events : {
        click : function(){
            alert(this.innerHTML);
        },
        mouseover : function(){
            this.style.backgroundColor='red';
        }
    },
    styles : {
        backgroundColor : 'blue',
        fontSize : '18px'
    },
    addAttributes : function{
        friend : 'xxx'
    }
});

myDiv.appendTo('body');

//OR just pass the nodeType
var myDiv = new sb.element('div');

myDiv.appendChild(myOtherDiv);

sb.element.protoype

@File: /surebert/sb.js

@Description: Methods of sb.element instances. Assume that myElement is an sb.element instance in all examples of Element.prototype

sb.events

@File: /surebert/sb.js

@Description: Cross browser event handling that references the proper "this" and passes the event to the handler method. Using sb.events, multiple events can be added to a single DOM node for the same event. e.g. multiple onclick handlers

sb.events.add

@File: /surebert/sb.js

@Description: Add an event listener to a DOM element, re-write of surebert events based on tips from http://www.digital-web.com/articles/seven_javascript_techniques/


@Param: Element/String el A reference to a DOM element or a string that can be passed through sb.$ to return a dom el e.g. '#myList'
@Param: String event The event to listen for without the on e.g. 'click'
@Param: Function handler The function that is run when the event occurs. The this reference of the function is the element itself and the funciton is also passed an event object which holds data about the event e.g. clientX, clientY, target, etc The funciton can be either an anonymous inline function or a function reference
@Example:

    var myEvent = sb.events.add('#myList', 'click', function(e){
        alert(this.innerHTML);
    });
    

sb.events.preventDefault

@File: /surebert/sb.js

@Description: Used to prevent default actions from occurring on an event e.g. links that are clicked would do whatever is in the event handler but not the ordinary default event of goign to the page specified by the href attribute.


@Param: Object event An event reference as passed to a handler function as e
@Example:

    var myEvent = sb.events.add('#myList', 'click', function(e){
        sb.events.preventDefault(e);
    });
    
    

sb.events.relatedTarget

@File: /surebert/sb.js

@Description: Related targets are specified for events that have related targets. e.g. mouseover and mouseout. when the event is mouseout the relatedTarget refers to the element the mouse is moving to. When the event is mouseover, the relatedTarget refers to the element that the mouse is moving from.


@Param: Object event An event reference as passed to a handler function as e
@Returns: Element The related target DOM node as explained in the description
@Example:

    var myEvent = sb.events.add('#myList', 'click', function(e){
        var target = sb.events.relatedTarget(e);
        alert(target.nodeName);
    });
    

sb.events.remove

@File: /surebert/sb.js

@Description: Removes an event listener


@Param: Object event An event listener reference as returned from sb.events.add
@Example:

    var myEvent = sb.events.add('#myList', 'click', function(e){
        alert(this.innerHTML);
    });
    
    sb.events.remove(myEvent);
    

sb.events.removeAll

@File: /surebert/sb.js

@Description: Removes all event listeners added with sb.events.add or sb.elements or $'s event method


@Example:

    sb.events.removeAll();
    

sb.events.stopAndPrevent

@File: /surebert/sb.js

@Description: Used to stop event bubbling e.g. when a ordered list is clicked the event bubbles to its children.


@Param: Object event An event reference as passed to a handler function as e
@Example:

    var myEvent = sb.events.add('#myList', 'click', function(e){
        sb.events.stopPropagation(e);
    });
    
    

sb.events.stopAndPrevent

@File: /surebert/sb.js

@Description: used to stop event bubbling and prevent default actions for an event


@Param: Object event An event reference as passed to a handler function as e
@Example:

    var myEvent = sb.events.add('#myList', 'click', function(e){
        sb.events.stopAndPrevent(e);
        
    });
    
    

sb.events.target

@File: /surebert/sb.js

@Description: Determines the target of the event, becaus eof event bubbling, this is not necessarily the this of the event. e.g when an orderlist is clicked, the target might have been one of the child list items, however, it's click event fires because teh chidlren are within it. By referencing the target you can see which child was clicked.


@Param: Object event An event reference as passed to a handler function as e
@Returns: Element The target DOM node as explained in the description
@Example:

    var myEvent = sb.events.add('#myList', 'click', function(e){
        var target = sb.events.target(e);
        alert(target.innerHTML);
    });
    
    

sb.include

@File: /surebert/sb.js

@Description: Includes another surebert module. Make sure you surebert files are in /surebert or that you have set sb.base before using this.


@Example:

    sb.include('String.prototype.nl2br');
    

sb.included

@File: /surebert/sb.js

@Description: An array of all modules that are included, updated live and can be used for debugging and making compressed libraries before putting into production


@Example:

    alert(sb.included);
    

sb.load

@File: /surebert/sb.js

@Description: Used to load external javascript from the same server synchronously and on demand.


@Returns: Returns 0 upon eval success or 1 if not
@Example:
 
    sb.load('/surebert/surebert.effects.js');
    
    if(sb.load('../js/myJavascript.js')){
    
        //run function from myJavascript.js

    }
    

sb.nodeList

@File: /surebert/sb.js

@Description: Used to create sb.nodeLists which are groups of sb.elements that have many of the same methods as sb.element but which act on all sb.elements in the sb.nodeList. It also has all the properties of an sb.array. These are returned by sb.s$

sb.nodeList.prototype.add

@File: /surebert/sb.js

@Description: Adds more nodes to the nodeList nodes array and assigns sb_ids or adds super element properties if required


@Param: An array of other nodes to add
@Example:
 
    var nodes = $('ol li');
    //adds element with id 'wrapper' to the node list
    nodes.add($('#wrapper'));
    
    

sb.nodeList.prototype.create_super_elements

@File: /surebert/sb.js

@Description: Determines if superElements should be created

sb.nodeList.prototype.drop

@File: /surebert/sb.js

@Description: drop dom nodes, either array o single node from a sb.nodeList


@Example:
 
    var nodes = $('ol li');
    //adds element with id 'wrapper' to the node list
    nodes.drop('#wrapper');
    //add all the links to the sb.nodeList
    nodes.drop('a');
    

sb.nodeList.prototype.empty

@File: /surebert/sb.js

@Description: Empties the nodes array

sb.nodeList.prototype.empty

@File: /surebert/sb.js

@Description: Empties the nodes array

sb.nodeList.prototype.length()

@File: /surebert/sb.js

@Description: Return the length of the this.nodes array which represents how many nodes the nodeList instance is holding

sb.nodeList.prototype.selector

@File: /surebert/sb.js

@Description: The CSS selector used to find the nodes

sb.objects.copy

@File: /surebert/sb.js

@Description: Makes a copy of an object and it's properties


@Param: Object o the object to copy
@Returns: Object a copy of the object
@Example:

        var o = {name : 'paul, language : 'javascript'};
        var f = sb.objects.copy(o);
    

sb.objects.dump

@File: /surebert/sb.js

@Description: Returns the properties of the object and their values for an object


@Param: Object o the object to return the properties of
@Param: Number pre If this parameter is set to 1 than, the data is returned in a pre tag to maitain formatting
@Returns: String The properties of the object
@Example:

        var o = {name : 'paul, language : 'javascript'};
        sb.objects.dump({o});
    

sb.objects.infuse

@File: /surebert/sb.js

@Description: Used to add properties from one object to another. If you have globals enabled you can just call infuse on any object or constructor and pass teh object to copy the properties from.


@Example:

    var boy = {
        name : 'paul'
    };
    
    var otherBoy : {
        eats : function(){
            alert('yum');
        }
    }
    //copies eat function to boy object
    sb.objects.infuse(otherBoy, boy);
    //or with globals enabled
    boy.infuse(otherBoy);
    

sb.objects.serialize

@File: /surebert/sb.js

@Description: Serializes all the properties of an object into a post data style key value string


@Param: Object o An object with properties
@Returns: String e.g. key=value&key=value

sb.onbodyload

@File: /surebert/sb.js

@Description: an array of functions that run once the DOM loads, they are fired in order, funcitons can be function references or inline anonymous functions


@Example:

    sb.onbodyload.push({myFunction});
    

sb.onleavepage

@File: /surebert/sb.js

@Description: an array of functions that run once when leaving the page, they are fired in order


@Example:

    sb.onleavepage.push({myFunction});
    

sb.styles

@File: /surebert/sb.js

@Description: Methods used to manipulate CSS and javascript styles

sb.toArray

@File: /surebert/sb.js

@Description: converts other types of iterable objects into an array e.g. an arguments list or an element sb.nodeList returned from getElementsByTagName.


@Param: Object Iterable non-array
@Returns: Array A normal iteratable array with all the properties of an array and the values of the iterable object it was passed.
@Example:
 
    var images = document.getElementsByTagName('img');
    images = sb.toArray(images);
    images.forEach(function(image,key,arr){
        alert(image.src);
    });
    

sb.typeOf

@File: /surebert/sb.js

@Description: returns the type of the object it is passed


@Param: object o Any type of javascript object, string, array, function, number, etc
@Returns: String 'function', 'array', 'string', 'object', 'textnode', 'element', 'boolean', 'float', 'number', or returns value of object's custom typeOf() if it exists, 'null'
@Example:

        var obj = {name : 'joe'}
        sb.typeOf(obj); //return 'object'
    

sb.uniqueID

@File: /surebert/sb.js

@Description: produces a unique id, ideal for DOM element which are created on the fly but require unique ids


@Returns: String a unique id string for a dom elements id string e.g. 'uid_5'
@Example:

    var myUniqueId = sb.uniqueID();
    //myUniqueId = 'uid_5' //<--just an example return would be unique each time it is called on a page
    

sb.unixTime

@File: /surebert/sb.js

@Description: calculates the current time as a unix timestamp


@Returns: Number A unix timestamp
@Example:

    var unixtime = sb.unixTime();
    //unixtime = 1170091311//<- just a possible example - would return current time