// remap jQuery to $
(function($){

	/**
	 * HoverAccordion - jQuery plugin for intuitively opening accordions and menus
	 * 
	 * http://berndmatzner.de/jquery/hoveraccordion/
	 * 
	 * Copyright (c) 2008-2010 Bernd Matzner
	 * 
	 * Dual licensed under the MIT and GPL licenses:
	 * http://www.opensource.org/licenses/mit-license.php
	 * http://www.gnu.org/licenses/gpl.html
	 * 
	 * Version: 0.9.0
	 * 
	 * Requires jQuery 1.4.4 or higher
	 */
	(function(h){h.fn.hoverAccordion=function(a){function m(d,f,b){var e=h(o).find("."+a.classOpen).closest("li").find("ul:first");if(false===e.is(":animated")){if(a.keepHeight==true)b=k;if(f.hasClass(a.classOpen)==false){d.children().show();d.animate({height:b},{step:function(c){d.height(b-c)},duration:a.speed});e.animate({height:0},{step:function(c){d.height(b-c)},duration:a.speed}).children().hide();f.addClass(a.classOpen).removeClass(a.classClosed);e.closest("li").removeClass(a.classActive).find("a:first").addClass(a.classClosed).removeClass(a.classOpen)}}} a=jQuery.extend({speed:"fast",activateItem:true,keepHeight:false,onClickOnly:false,classActive:"active",classHeader:"header",classHover:"hover",classOpen:"opened",classClosed:"closed"},a);var o=this,g=window.location.href,l=0,n=0,k=0;h(this).children("li").each(function(){var d=h(this),f=false;n++;var b=d.find("a:first").addClass(a.classHeader);if(b.length>0){b.hover(function(){b.addClass(a.classHover)},function(){b.removeClass(a.classHover)});var e=b.attr("href");if(e=="#")b.click(function(){this.blur(); return false});else if(a.activateItem==true&&g.indexOf(e)>0&&g.length-g.lastIndexOf(e)==e.length){f=true;d.addClass(a.classActive);b.removeClass(a.classClosed).addClass(a.classOpen)}}var c=d.find("ul:first");if(c.length>0){var i=c.height();if(k<i)k=i;a.onClickOnly==true?b.click(function(){m(c,b,i)}):b.hover(function(){l=setInterval(function(){m(c,b,i);clearInterval(l)},400)},function(){clearInterval(l)});if(a.activateItem==true)c.children("li").each(function(){var j=h(this).find("a").attr("href"); if(j)if(g.indexOf(j)>0&&g.length-g.lastIndexOf(j)==j.length){f=true;d.addClass(a.classActive);b.removeClass(a.classClosed).addClass(a.classOpen)}});else if(parseInt(a.activateItem,10)==n){f=true;d.addClass(a.classActive);b.removeClass(a.classClosed).addClass(a.classOpen)}}if(!f){b.removeClass(a.classOpen);if(c.length>0){c.children().hide();b.addClass(a.classClosed)}}});return this}})(jQuery);
	
	
	//	See link for more options.
	//	http://www.kryogenix.org/code/browser/labelify/

	/**
	 * jQuery.labelify - Display in-textbox hints
	 * Stuart Langridge, http://www.kryogenix.org/
	 * Released into the public domain
	 * Date: 25th June 2008
	 * @author Stuart Langridge
	 * @version 1.3
	 *
	 *
	 * Basic calling syntax: $("input").labelify();
	 * Defaults to taking the in-field label from the field's title attribute
	 *
	 * You can also pass an options object with the following keys:
	 *   text
	 *     "title" to get the in-field label from the field's title attribute 
	 *      (this is the default)
	 *     "label" to get the in-field label from the inner text of the field's label
	 *      (note that the label must be attached to the field with for="fieldid")
	 *     a function which takes one parameter, the input field, and returns
	 *      whatever text it likes
	 *
	 *   labelledClass
	 *     a class that will be applied to the input field when it contains the
	 *      label and removed when it contains user input. Defaults to blank.
	 *  
	 */
	jQuery.fn.labelify = function(settings) {
	  settings = jQuery.extend({
	    text: "title",
	    labelledClass: ""
	  }, settings);
	  var lookups = {
	    title: function(input) {
	      return $(input).attr("title");
	    },
	    label: function(input) {
	      return $("label[for=" + input.id +"]").text();
	    }
	  };
	  var lookup;
	  var jQuery_labellified_elements = $(this);
	  return $(this).each(function() {
	    if (typeof settings.text === "string") {
	      lookup = lookups[settings.text]; // what if not there?
	    } else {
	      lookup = settings.text; // what if not a fn?
	    };
	    // bail if lookup isn't a function or if it returns undefined
	    if (typeof lookup !== "function") { return; }
	    var lookupval = lookup(this);
	    if (!lookupval) { return; }

	    // need to strip newlines because the browser strips them
	    // if you set textbox.value to a string containing them    
	    $(this).data("label",lookup(this).replace(/\n/g,''));
	    $(this).focus(function() {
	      if (this.value === $(this).data("label")) {
	        this.value = this.defaultValue;
	        $(this).removeClass(settings.labelledClass);
	      }
	    }).blur(function(){
	      if (this.value === this.defaultValue) {
	        this.value = $(this).data("label");
	        $(this).addClass(settings.labelledClass);
	      }
	    });

	    var removeValuesOnExit = function() {
	      jQuery_labellified_elements.each(function(){
	        if (this.value === $(this).data("label")) {
	          this.value = this.defaultValue;
	          $(this).removeClass(settings.labelledClass);
	        }
	      })
	    };

	    $(this).parents("form").submit(removeValuesOnExit);
	    $(window).unload(removeValuesOnExit);

	    if (this.value !== this.defaultValue) {
	      // user already started typing; don't overwrite their work!
	      return;
	    }
	    // actually set the value
	    this.value = $(this).data("label");
	    $(this).addClass(settings.labelledClass);

	  });
	};






 



})(window.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) );
  }
};



