
function storeButtonDisabled(){
               	var nodes = $$('.rich-message-label');
               	var disabled = false;
               	for(var i = 0; i < nodes.length; i++){
               	var node = nodes[i];
               	  if(node.innerHTML != ""){
               	  	disabled = true;
               	  	break;
               	  }
               	}
               	return disabled;
               }
               
function selectAllFiles(f) {
	for (var i = 0; i < filesCount; i++) {
		var b = $('mainform:files:'+i+':file_selected');
		if (b) {
			b.checked = f;
		}
		
	}
}

function onselectFileClick(el) {
	if (!el.checked) {
		$('select_all').checked = false;
	}else {
		var b = true;
		for (var i = 0; i < filesCount; i++) {
		var d = $('mainform:files:'+i+':file_selected');
			if (!d.checked) {
				b = false;
				break;
			}
		}
		if (b) {
			$('select_all').checked = true;
		}
		
	}
}

function SearchPanelShowHide(e, elt) {
	if (Element.visible(elt)) {
		hideSearch();
	}else {
		showSearch();
	}
}

function selectPopularTag(tag, target) {
	if(target){
		var value = target.value;
		if(value && value.indexOf(tag) != -1){
			return;
		}
		if(value && value.length > 0){
			target.value += ', ';
		}
		target.value += tag;
	}
}

function updateUploadProgressBarLabel (progressBar, fileUpload) {
	var c = fileUpload.entries.length;
	var uploaded = 0;
	for (var i=0;i<c;i++) {
		if (fileUpload.entries[i].state == FileUploadEntry.UPLOAD_SUCCESS) {
			uploaded++;
		}
	}

	var value = (c >0) ?  100 * uploaded / c : 0;
	progressBar.setValue(value);
	progressBar.setLabel(uploaded + '/' + c + ' completed');
}