if (typeof MVD.CMS === 'undefined') {
	MVD.CMS = {};
}

MVD.CMS.ComGet = function () {

	var messages = { view: 'Ver comentarios' };
	var notList = [];

	function update(text) {
		var listcc, cc, el, link;
		eval('listcc = ' + text);
		if (listcc.length == notList.length) {
			for (var i=0; i<notList.length; i++) {
				cc = listcc[i];
                if (cc !== null) {
    				el = document.getElementById('cantCom' + notList[i]);
    				if (el) {
    					link = el.getElementsByTagName('a')[0];
    					if (link) {
    						link.innerHTML = messages.view;
    						el.style.display = 'block';
    					}
    				}
                }
			}
		}
	}

	return {
		add : function (id) {
			notList.push(id);
		},
		get : function () {
			if (notList.length > 0) {
				MVD.Ajax.postGX('angetnotcantcoms', {ucs: notList.join(',') }, update);
			}
		},
		getIds : function () {
			return notList.slice();
		},
		setMessage: function (id, text) {
			messages[id] = text;
			return this;
		}
	};
} ();

// BackCompatibility
function addNot(id) {
	MVD.CMS.ComGet.add(id);
}

function getnotcom() {
	MVD.CMS.ComGet.get();
}

