
/*
Function: chk_invert

	Javascript Function. found in Inverts checkboxes. Call with $(<checkbox identifier>).chk_invert();
	
See Also:

	<chk_toggle_on>, <chk_toggle_off>

*/
jQuery.fn.chk_invert = function()
{
	$(this).each(function(){
		is=$(this).attr("checked")?"":"checked";
		$(this).attr("checked",is);
	});
};

/*
Function: chk_toggle_on

	Sets all identified checkboxes to on. Call with $(<checkbox identifier>).chk_toggle_on();
	
See Also:

	<chk_invert>, <chk_toggle_off>
*/

jQuery.fn.chk_toggle_on = function()
{
	$(this).each(function(){
		$(this).attr("checked","checked");
	});
};

/*
Function: chk_toggle_ff

	Sets all identified checkboxes to off. Call with $(<checkbox identifier>).chk_toggle_ff();
	
See Also:

	<chk_invert>, <chk_toggle_on>
*/

jQuery.fn.chk_toggle_off = function()
{
	$(this).each(function(){
		$(this).removeAttr("checked");
	});
}

/*
Function: toggle_allbut
	
	make all classes of a certain type collapse except the one with id "me"
	
Arguments:
	
	type	-	class of elements to hide
	me		- 	id of element to show.
*/

function toggle_allbut(type,me)
{
	me="#"+me;
	type="."+type;
	$(type).each(function(){
		//alert($(this).attr("id"));
		if("#"+$(this).attr("id") != me)
			$(this).hide("slow");
		else
			$(this).show("slow");
	});
}

/*
Function: isemail

	checks if the element's value matches an email format. !! unverigfied.

*/
jQuery.fn.isemail =function()
{
	val=$(this).val();	
	var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
	return pattern.test(val);
}


/*
Function: dropmenu

	creates a simple generic javascript powered drop menu with a nifty popup effect from an unordered list. Note that the element requires some styling.

*/
jQuery.fn.dropmenu=function()
{
	$(this).children("ul").css({display: "none"}); // Opera Fix
	$(this).children("li").hover(function(){
		$(this).find("ul:first").css({visibility: "visible",display: "none"}).show(268);
	},function(){
		$(this).find("ul:first").css({visibility: "hidden"});
	});
}
