(function($) {
    $.fn.disposable = function(cln) {
        return this.each(function() {
            var el = this;
            if (!el.dispose) {
                el.dispose = cleanup;
                $(window).bind("unload", cleanup);
            }
            function cleanup() {
                if (!el) return;
                $(el).unbind();
                $(window).unbind("unload", cleanup);
                el.dispose = null;
                el = null;
            };
        });
    };
})(jQuery);

$(document).ready(function(){
/*						   
	$('#edit-realname').val('Name');
	
	$('#edit-realname').focus(function(){
		$('#edit-realname').val('');
	});
	
	$('#edit-realname').blur(function() {
		if($('#edit-realname').val() == '') {
			$('#edit-realname').val('Name');
		}
	});
*/	

	$('#edit-mail').val('Email');
	
	$('#edit-mail').focus(function(){
		$('#edit-mail').val('');
	});
	
	$('#edit-mail').blur(function() {
		if($('#edit-mail').val() == '') {
			$('#edit-mail').val('Email');
		}
	});

	/* the following is custom button code*/
	// add the following line for each form that we want fancy buttons
//	if(!$.browser.msie){	
/*	$('#civicrm-subscribe-form .form-submit').addClass('btn');
	
	
    $('.btn').each(function(){
	   var b = $(this);
	   var uu = b.attr('href');
	   var tt = b.text() || b.val();
	   if ($(':submit,:button',this)) {
	     b = $('<a>').insertAfter(this).addClass(this.className).attr({'id': this.id,'href': uu});
	     $(this).remove();
	   }
	   b.text('').css({cursor:'pointer'}).prepend('<i></i>').append($('<span>').
	   text(tt).append('<i></i><span></span>'));
	   });
	 
	   $(".form-submit").click(function(){
	     var form = $(this).parents('form:first');
	     form.submit();
	   });
	 
	   $("input").keypress(function(e){
	     if (e.which == 13) {
	        	var form = $(this).parents('form:first');
	 	    form.submit();
	   }
//	  } //end msie check

	 });
	*/
 /* end of button code*/

/*----- need to expand footer menu submenus ---- */
    //$('#footer_menu .start-collapsed').removeClass('collapsed');
	//$('#footer_menu .start-collapsed').addClass('expanded');
	
	$('#footer_menu .start-collapsed.collapsed a').click();
  $('#block-search-0 .form-submit').attr('style', 'display:hidden');

	$("form#civicrm-subscribe-form input")
		.bind("focus.labelFx", function(){
			$(this).siblings("label").hide();
		})
		.bind("blur.labelFx", function(){
			$(this).siblings("label")[!this.value ? "show" : "hide"]();
		})
		.trigger("blur.labelFx");

		if ($.browser.msie && $.browser.version < 9) $('#edit-term-node-tid-depth')
		    .bind('focus mouseover', function() { $(this).addClass('expand').removeClass('clicked'); })
		    .bind('click', function() { $(this).toggleClass('clicked'); })
		    .bind('mouseout', function() { if (!$(this).hasClass('clicked')) { $(this).removeClass('expand'); }})
		    .bind('blur', function() { $(this).removeClass('expand clicked'); });


});


