// remap jQuery to $
(function($){

/*
* jQuery Animate To Class
* Copyright 2008 Igor Frias Vieira
* http://igorvieira.com/blog/animate-to-class/
*
* Released under the MIT and GPL licenses.
*/

(function ($) {
    $.fn.extend({
        animateToClass: function (to, duration, easing, callback) {
            if (!to) { return this; }

            styles = selectStyle(to);

            if (!styles) return this;

            return this.animate(styles, duration, easing, callback);
        }
      });
      jQuery.extend({
        parseQuerystring: function () {
          var nvpair = {};
          var qs = window.location.search.replace('?', '');
          var pairs = qs.split('&');
          $.each(pairs, function (i, v) {
            var pair = v.split('=');
            nvpair[pair[0]] = pair[1];
          });
          return nvpair;
        }
      });

    function selectStyle(sel) {
        if (sel.substr(0, 1) != ".") {
            sel = "." + sel;
        }

        $(document.styleSheets).each(function (i, v) {
            if (attrClassTest = selectAttr(sel, v)) {
                attrClass = attrClassTest;
            }
        });

        if (!attrClass) {
            attrClass = Array();
        }

        objStyle = {}

        if (attrClass == "") {
            return false;
        }

        if (attrClass.match(";")) {
            attrClass = attrClass.split(";");
        }
        else {
            attrClass = [attrClass];
        }

        $(attrClass).each(function (i, v) {
            if (v != "") {
                v = v.split(":");
                v[0] = toCamelCase(v[0]);

                objStyle[v[0]] = $.trim(v[1]);
            }
        });
        return objStyle;
    }

    function selectAttr(sel, v) {
        attrClass = false;

        if ($.browser.msie) {
            if (v.rules.length > 0) {
                $(v.rules).each(function (i2, v2) {
                    if (sel == v2.selectorText) {
                        attrClass = v2.style.cssText;
                    }
                });
            }
            else if (v.imports.length > 0) {
                $(v.imports).each(function (i2, v2) {

                    if (sel == v2.selectorText) {
                        attrClass = v2.style.cssText;
                    }
                    else if (v2 == "[object]" || v2 == "[Object CSSStyleSheet]" || v2 == "[object CSSImportRule]") {
                        return selectAttr(sel, v2);
                    }
                });
            }
        }
        else {
            $(v.cssRules).each(function (i2, v2) {
                if (sel == v2.selectorText) {
                    attrClass = v2.style.cssText;
                }
                else if (v2 == "[object CSSImportRule]") {
                    return selectAttr(sel, v2.styleSheet);
                }
            });
        }

        return attrClass;
    }

    function toCamelCase(str) {
        str = $.trim(str);
        str = str.replace(/-/g, " ");
        str = str.toLowerCase();

        strArr = str.split(" ");

        var nStr = "";
        $(strArr).each(function (i, v) {
            if (i == 0) {
                nStr += v;
            } else {
                /*
                v = v.split("");
                v[0] = v[0].toUpperCase();
                nStr += v.join();
                */

                //There was a bug in older version, this correction was sugested by Simon Shepard.
                nStr += v.substr(0, 1).toUpperCase();
                nStr += v.substr(1, v.length);
            }
        });

        return nStr;
    }
})(jQuery);




})(this.jQuery);



// usage: log('inside coolFunc',this,arguments);
// paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/
window.log = function(){
    log.history = log.history || [];   // store logs to an array for reference
    log.history.push(arguments);
    if(this.console){
        console.log( Array.prototype.slice.call(arguments) );
    }
};



// catch all document.write() calls
(function(doc){
    var write = doc.write;
    doc.write = function(q){
        log('document.write(): ',arguments);
        if (/docwriteregexwhitelist/.test(q)) write.apply(doc,arguments); 
    };
})(document);
