/*
* Dependencies:
*	jquery-1.4.js
*/
 
// =============== GENERAL METHODS =============== //
/*
 * @author: Shaun Johnson
 * @method: setClass
 * @description: Adds a Class then Removes a Class based on elements id
 *
 * @element: element to be modified
 * @classAdd: class for on state
 * @classRemove: class to be remove
 *
 */
function setClass(element, classAdd, classRemove)
{
	element.addClass(classAdd);
	element.removeClass(classRemove);
}

/*
 * @author: Shaun Johnson
 * @method: swapClass
 * @description: Adds a Class then Removes a Class based on objects
 *
 * @obj: name of element to swap class on
 * @classOn: class for on state
 * @classOff: class for off state
 *
 */
function swapClass(targetName, classOn, classOff)
{
	if ($("a[name='"+targetName+"']").hasClass(classOn)) {
		$("a[name='"+targetName+"']").addClass(classOff);
		$("a[name='"+targetName+"']").removeClass(classOn);
	} else {
		$("a[name='"+targetName+"']").addClass(classOn);
		$("a[name='"+targetName+"']").removeClass(classOff);
	}
}
/*
 * @author: Shaun Johnson
 * @method: addDialog
 * @description: Uses jQuery UI Dialog
 *
 * @dTitle:
 * @dMsg:
 *
 */
function addDialog(dTitle, dMsg)
{
	var $dialog = $('<div></div>')
	.html(dMsg)
	.dialog({
		title: dTitle,
		autoOpen: true,
		resizable: false,
		draggable: false,
		closeOnEscape: false,
		modal: true,
		buttons: {
			Ok: function() {
				$(this).dialog('close');
			}
		}
	});
}
/*
 * @author: Shaun Johnson
 * @method: doMessage
 * @description:
 *
 * @$obj:
 * @type:
 * @msg:
 *
 */
function doMessage($obj,type,msg)
{
	$obj.removeClass()
	switch(type)
	{
		case "loading":
			msgClassType = 'cws-pc-status-loading';
		break;
		case "passed":
			msgClassType = 'cws-pc-status-passed';
		break;
		case "warning":
			msgClassType = 'cws-pc-status-warning';
		break;
		case "error":
			msgClassType = 'cws-pc-status-error';
		break;
	}
	$obj.addClass(msgClassType);	
	$obj.html(msg);
	$obj.show();
}
/*
 * @author: John Resig - http://ejohn.org/blog/javascript-array-remove/
 * @description: Used to remove node in Json file
 *	
 */
Array.prototype.remove = function(from, to) {
    var rest = this.slice((to || from) + 1 || this.length);
    this.length = from < 0 ? this.length + from : from;
    return this.push.apply(this, rest);
};
