/**
 * @author acecchin
 */

function msgBg(target, url) {
	document.getElementById(target + '_box').style.backgroundImage = 'url("'+url+'")';	
}

function HasClassName(objElement, strClass) {

	// if there is a class
	if ( objElement.className ) {

		// the classes are just a space separated list, so first get the list
		var arrList = objElement.className.split(' ');

		// get uppercase class for comparison purposes
		var strClassUpper = strClass.toUpperCase();

		// find all instances and remove them
		for ( var i = 0; i < arrList.length; i++ ) {

			// if class found
			if ( arrList[i].toUpperCase() == strClassUpper ) {
				// we found it
				return true;
			}
		}
	}

	// if we got here then the class name is not there
	return false;
}

function AddClassName(objElement, strClass, blnMayAlreadyExist) {

   // if there is a class
   if ( objElement.className ) {
		// the classes are just a space separated list, so first get the list
		var arrList = objElement.className.split(' ');

		// if the new class name may already exist in list
		if ( blnMayAlreadyExist ) {

			// get uppercase class for comparison purposes
			var strClassUpper = strClass.toUpperCase();

			// find all instances and remove them
			for ( var i = 0; i < arrList.length; i++ ) {
				// if class found
				if ( arrList[i].toUpperCase() == strClassUpper ) {
					// remove array item
					arrList.splice(i, 1);

					// decrement loop counter as we have adjusted the array's contents
					i--;
				}
			}
		}

		// add the new class to end of list
		arrList[arrList.length] = strClass;

		// assign modified class name attribute
		objElement.className = arrList.join(' ');
	} else {
		// if there was no class

		// assign modified class name attribute      
		objElement.className = strClass;
   
	}

}


function RemoveClassName(objElement, strClass) {

	// if there is a class
	if ( objElement.className ) {

		// the classes are just a space separated list, so first get the list
		var arrList = objElement.className.split(' ');

		// get uppercase class for comparison purposes
		var strClassUpper = strClass.toUpperCase();

		// find all instances and remove them
		for ( var i = 0; i < arrList.length; i++ ) {

			// if class found
			if ( arrList[i].toUpperCase() == strClassUpper ) {

				// remove array item
				arrList.splice(i, 1);

				// decrement loop counter as we have adjusted the array's contents
				i--;

			}

		}

		// assign modified class name attribute
		objElement.className = arrList.join(' ');

	}
	// if there was no class
	// there is nothing to remove

}
