function pageLoad($) {
	$('.decorate ul li, .decorate td, .decorate tr, hr').decorate();
	

	
	// changes the search label on click
	(function searchlabel() {
		var searchb = $('#CAT_Search');
		var defaultText = "search";
		searchb.onblur = function () { 
			if (this.value == '') { this.value = defaultText; }
		}
		searchb.onfocus = function () {
			if (this.value == defaultText) { this.value = ''; }
		}
		if (searchb.value == "") {
			searchb.value = defaultText;
		}
	}) ();
	

	truncateBlogPost($);
	
	if (window.pageClass) {
		document.body.className += " " + window.pageClass;
	}
}

function truncateBlogPost($) {
 $(".truncate").each(function () {
  el = $(this);
  if (el.height() > 50) {
   var words = el.text().split(" ");
      while (el.height() > 50) {
    words.pop();
       this.innerHTML = words.join(" ") + "...";
      }
  }
 });
}

function imageResizer() {
	var ns = $("textarea[class*=imgresize]");
	ns.each(function () {
		var nshtml = this.value
		var attrs = this.className.replace(/.*imgresize\[([^\]]*)\].*/g, "$1").replace(/ /g,"&amp;");
		var imghtml = nshtml.replace(/(.*)<img.*src=\"([^\"]+)\"[^\/]*\/>(.*)/, '$1<img src="/Utilities/ShowThumbnail.aspx?USM=1'+attrs+'&amp;R=1&amp;Img=$2" />$3');
		this.parentNode.innerHTML = imghtml;	  
	});
	
	var ns = $("img[class*=imgresize]");
	ns.each(function () {
		var attrs = "&amp;W="+this.width+"&amp;H="+this.height;
		this.src = '/Utilities/ShowThumbnail.aspx?USM=1'+attrs+'&amp;R=1&amp;Img=$2'
	});
}



