$(document).ready(function() {
						   
	// widget expand/collapse functionality
	$(".collapsible .widget-header").each(function(i){
		$(this).click(function(){
			if ($(this).next().is(":hidden")) {
				$(this).next().show();
				$(this).addClass("active");
				$.cookie("widgetState"+i, "collapsed");
				return false;
			} else {
				$(this).next().hide();
				$(this).removeClass("active");
				$.cookie("widgetState"+i, "expanded");
				return false;
			}
		});
	
		// cookies for saving state of widgets
		var widgetState = $.cookie("widgetState"+i);
		if (!widgetState || widgetState == "collapsed") {
			$(this).next().show();
			$(this).addClass("active");
		} else {
			$(this).next().hide();
			$(this).removeClass("active");
		}
	});
	
	// create round corners for ads
	$(".adspace.rounded").each(function() {
		$(this).append("<div class='tl'></div>")
		$(this).append("<div class='tr'></div>")
		$(this).append("<div class='bl'></div>")
		$(this).append("<div class='br'></div>")
	});
	
	// accordion plugin for the #find-stories widget
	$("#find-stories").accordion({
		collapsible: true,
		autoHeight: false
	});
	
	//uses title attribute form example text (modified to work with value)
     $('.search, .textfield, .textarea, .TextboxField, .TextAreaField').each(function() {
      if (myval != "" || myval == 'undefined') {
       var myval = $(this).val();
      }
      $(this).val('');
      $(this).example(function() {
       return myval;
       // class .grey for default value
      }, {className: 'grey'});
     });
	
	$("#article-browser").tabs();
	
	// auto column plugin for A-Z browsing
	$('.browse-index').addClass("dontsplit");  
	$('.columnize').columnize({ columns:4, lastNeverTallest:true });  

});

