/**
 * ClassManipluation v1.0
 * @author
 * (c) 2008 Adam Schwartz - http://polymath.mit.edu
 *
 * @license
 * Licensed under the MIT Licencse
 * http://www.opensource.org/licenses/mit-license.php
 * This is distributed WITHOUT ANY WARRANTY; without even the implied
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 */

var ClassManipulation = {
	hasClass: function(objElement, strClass) {
		if (objElement.className) {
			var arrList = objElement.className.split(' ');
			var strClassUpper = strClass.toUpperCase();
			for (var i=0; i<arrList.length; i++) {
				if (arrList[i].toUpperCase() == strClassUpper) {
					return true;
				}
			}
		}
		return false;
	},
	addClass: function(objElement, strClass) {
		if (objElement.className) {
			var arrList = objElement.className.split(' ');
			var strClassUpper = strClass.toUpperCase();
			for (var i=0; i<arrList.length; i++) {
	            if (arrList[i].toUpperCase() == strClassUpper) {
					arrList.splice(i, 1);
					i--;
				}
			}
			arrList[arrList.length] = strClass;
			objElement.className = arrList.join(' ');
		} else {
			objElement.className = strClass;
		}
	},
	removeClass: function(objElement, strClass) {
		if (objElement) {
			var arrList = objElement.className.split(' ');
			var strClassUpper = strClass.toUpperCase();
			for (var i=0; i<arrList.length; i++) {
				if (arrList[i].toUpperCase() == strClassUpper) {
					arrList.splice(i, 1);
					i--;
				}
			}
			objElement.className = arrList.join(' ');
		}
	}
}