// NHP Common JS Lib.

// Specialized DOM manipulations
function nhpDomManipulator() {
	return {
	
		showHideMultiple: function(hideElements, showElements, hideSpeed, showSpeed) {
			$(hideElements).each(function() {
				$(this).hide(hideSpeed);
			});
			$(showElements).each(function() {
				$(this).show(showSpeed);
			});
		}
	};
}
var nhpManipulateDom = new nhpDomManipulator();

// Input box default text plugin
$.fn.nhpInputDefaultText = function() {
	this.focus(function() {
		if( this.value == this.defaultValue ) {
			this.value = "";
	}});
	this.blur(function() {
		if( !this.value.length ) {
			this.value = this.defaultValue;
		}
	});
};

// Randomizes DOM order of a container of elements
$.fn.randomizeElementCollection = function(childElem) {
	return this.each(function() {
		var $this = $(this);
		var elems = $this.children(childElem);
		elems.sort(function() {
			return (Math.round(Math.random()) - 0.5);
		});
		$this.remove(childElem);  
		for (var i = 0, limit = elems.length; i < limit; i++) {
			$this.append(elems[i]);
		}
	});    
};


