jQuery.fn.wordcount =  function(min) 
{
//this jQuery function will return a true if there is a specified minimum number of words in the string being examined. If no minimum is specified, the function will return a word count.
var str = this.html();
if (str==null) return true;
var words = new Array();
	if (typeof min=='undefined') 
	{min = 'default';
	words = str.split(" ");
	var y = words.length;
	return y;
	}
	else {words = str.split(" ",min+1);
	var y = words.length;
	if (y>=min) return true;
	else return false;
	}
}
jQuery.fn.findstring = function(regexstring)
{
	var str = this.html();
	if (str==null) return false;
	myregexp = new RegExp(regexstring,"gim");
	var pos = str.search(myregexp);
	if (pos == -1) return false;
	else return true;
}
jQuery.fn.fadeToggle = function(speed, easing, callback) {
   return this.animate({opacity: 'toggle'}, speed, easing, callback);
}
jQuery.fn.highlight = function(id)
//pass the id of the tag you want the number of counted items to return as.
//i.e. $(this').highlight('#count'); will replace the text in the element with an id of 'count'
{
		var num=$(':checked').length;
        $$ = $(this);
        if($$.is(':checked')) {
                $$.parent().addClass("inprogress");
		    }
        else
                {$$.parent().removeClass();}
		if (num>0) $(id).text("Number of attendees: "+num);
		else $(id).text("");
		
}
jQuery.fn.collapse = function()
{
	$(this).each(function(){
						  var str = $(this).text();
							var strlen = str.length;
							var space = strlen*15;
							$(this).css('background-position',space);
						  });
	$(this).mouseover(function(){
		$(this).css({cursor:"pointer"});
		});
	$(this).click(function() {
		$(this).next().toggle("slow");
		$(this).toggleClass('add').toggleClass('minus');
	}).next().hide();
}
jQuery.fn.dayofweek = function()
{
	$(this).each(function() {
	var str=$(this).text();
	var c= Date.parse(str);
	var d= new Date(parseFloat(c));
	var weekday=new Array(7);
	weekday[0]="Sun";
	weekday[1]="Mon";
	weekday[2]="Tue";
	weekday[3]="Wed";
	weekday[4]="Thu";
	weekday[5]="Fri";
	weekday[6]="Sat";
	var datestring = weekday[d.getDay()] + ', '+str;
	$(this).text(datestring);
	});
}
jQuery.fn.fulldayofweek = function()
{
	$(this).each(function() {
	var str=$(this).text();
	var c= Date.parse(str);
	var d= new Date(parseFloat(c));
	var weekday=new Array(7);
	weekday[0]="Sunday";
	weekday[1]="Monday";
	weekday[2]="Tuesday";
	weekday[3]="Wednesday";
	weekday[4]="Thursday";
	weekday[5]="Friday";
	weekday[6]="Saturday";
	var datestring = weekday[d.getDay()] + ', '+str;
	$(this).text(datestring);
	});
}
jQuery.fn.focusNextInputField = function() {
return this.each(function() {
var fields = $(this).parents('form:eq(0),body').find('button,input,textarea,select');
var index = fields.index( this );
if ( index > -1 && ( index + 1 ) < fields.length ) {
fields.eq( index + 1 ).focus();
}
return false;
});
}
jQuery.fn.pointer = function() {
	return $(this).css('cursor','pointer');
}
; 