var VIEW = VIEW || {};

VIEW.msgsts = VIEW.msgsts ||
(function () {
	return {
		removeCookie: function (name, val) {
			if (name) {
				var str = name + "=" + (val || "");
				var data = document.cookie;
				if (0 <= data.indexOf(str)) {
					var date = new Date();
					date.setHours(date.getHours() - 10);
					document.cookie = str + ";expires=" + date.toUTCString();
					return true;
				}
			}
			return false;
		},
		setTopMessage: function (msg, sts) {
			$("#topMessage").html(msg).addClass(sts);
		},
		setItemMessage: function (name, msg, sts, loc, val) {
			var setMsgSts = function(itm, msg, sts) {
				$(itm).attr("title", msg);
				$(itm).addClass(sts);
			};

			var elem = document.getElementsByName(name);
			if (elem) {
				if (val) {
					for (var i = 0, len = elem.length; i < len; i += 1) {
						if (elem.item(i).value === val) {
							setMsgSts(elem.item(i), msg, sts, i);
							break;
						}
					}
				} else if (loc && !isNaN(loc)) {
					if (loc < elem.length) {
						setMsgSts(elem.item(loc), msg, sts, loc);
					}
				} else {
					for (var j = 0, ln = elem.length; j < ln; j += 1) {
						setMsgSts(elem.item(j), msg, sts, j);
					}
				}
			}
		}
	};
}());
