$.fn.clearForm = function() {
  return this.each(function() {
 var type = this.type, tag = this.tagName.toLowerCase();
 if (tag == 'form')
   return $(':input',this).clearForm();
 if (type == 'text' || type == 'password' || tag == 'textarea')
   this.value = '';
 else if (type == 'checkbox' || type == 'radio')
   this.checked = false;
 else if (tag == 'select')
   this.selectedIndex = -1;
  });
};

function urlize(s) {
	ns = s.toLowerCase();
	ns = ns.replace(/^\s+|\s+$/g,"");
	ns = ns.replace(/ /g, "_")
	return ns;
}

/*
function setThumb(obj, imagefile, thumbfile) {
	if (obj && thumbfile) {
		obj.html('<img class="clickable" src="/'+thumbfile+'">');
	}
	div = $('<div id="'+imagefile+'"><img src="/'+imagefile+'"></div>');
	$('img', obj).click(function() {
		div.dialog('open');
	});
	obj.after(div);
	div.dialog({modal:true, autoOpen:false, resizable:false, width: 'auto'});
		
}
*/

function setThumb(obj, imagefile, thumbfile) {
	if (obj && thumbfile) {
		obj.html('<a href="/'+imagefile+'"><img class="clickable" src="/'+thumbfile+'"></a>');
	}
	div = $('<div style="display:none"><div id="'+imagefile+'"><img src="/'+imagefile+'"></div></div>');
	//obj.after(div);
	$('a', obj).colorbox();
		
}
