// initialise Superfish 
$(document).ready(function(){

  if ($("ul#dynmenu").length > 0) {
     $("ul#dynmenu").superfish({ 
         animation: {width:'show'},    // slide-down effect without fade-in 
         delay:     80,               // 1.2 second delay on mouseout 
         dropShadows: false,
         oldJquery       : false, /* set to true if using jQuery version  below 1.2 */
         disableHI       : false /* set to true to disable hoverIntent detection */
      });
  }

  if ($("label.autopopulate").length > 0) {  
     jQuery.each($("label.autopopulate"), function(){
        //console.log($(this).next("input[type='text']"));
        $(this).next("input[type='text']").attr("value", $(this).html());
        $(this).next("input[type='text']").attr("title", $(this).html());
        $(this).hide();
        //REMOVE populated label on a focus
        $(this).next("input[type='text']").focus(function () {
           // If value and title are equal on focus, clear value
   			if (this.value == this.title) {
   				this.value = '';
   				this.select(); // Make input caret visible in IE
   			}
        });
        //ADDED it back if field is empty
        $(this).next("input[type='text']").blur(function () {
           if (!this.value.length) { this.value = this.title; }
        });
     });
  }//end if
}); 