/*
	Common regexs
*/
var emailAddrEx = /^[\w'']+([\.-]?[\w'']+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
var linkURLEx = /https?:\/\/([-\w\.]+)+(:\d+)?(\/([\w/_\.]*(\?\S+)?)?)?/;

/*
	Common jquery utility custom plugins/functions
*/

/* radio/checkbox check/uncheck/toggle */
$.fn.check = function(mode) {
	var mode = mode || 'on'; // if mode is undefined, use 'on' as default
	return this.each(function() {
		switch(mode) {
			case 'on':
				this.checked = true;
			break;
			
			case 'off':
				this.checked = false;
			break;
			
			case 'toggle':
				this.checked = !this.checked;
			break;
		}
	});
};


/* new window openage */
$.fn.newWindow = function(){

	return this.click(
		function(){
			window.open(this.href);
			return false;
		}
	);
}


/* onclick - hide, show etc..... */
$.fn.clickage = function(elClass, action, speed){
	/*
	 * elClass - the target class
	 * action - the jquery event function to perform
	 * speed - the speed of animation, not required
	 */

	var speed = speed || '';
	
	return this.click(
		function(){
			switch(action) {
				case 'hide':
					$(elClass).hide(speed);
				break;
				
				case 'show':
					$(elClass).show(speed);
				break;
				
				case 'toggle':
					$(elClass).toggle(speed);
				break;
			}
		}
	);
}

/* disable target(s) . */
/*
 * aTarget - the array of target class/id/field names etc
 * bDisabled - boolean that determines disabled or not - true||false
 */
$.fn.setDisabled = function(aTarget, bDisabled){
	
	var bDisabled = bDisabled || false;
	
	for(var i = 0; i < aTarget.length; i++) {
		$(aTarget[i]).attr("disabled", bDisabled);	
	}
	
}
