//<!--

/* there is no onchange for form-tag, and its a liiitle complicated to add the onchange to the upload-field in this window.js, so work around */
function loadGroupsUploadOnChange()
{
  $('uploadForm').onchange = function()
	{
		jsUpload(this);
		return false;
	}
}


/* opens UploadDialog */
function openUpload( labelCancel, errorMessage )
{
  Dialog.alert( $('groupsUpload').innerHTML, 
                { 
                  className:"alphacube", width:600, okLabel: labelCancel
                }
  );
}


/* This function is called when user selects file in file dialog, it disabled the fields and shows a progressbar */
function jsUpload(upload_field)
{
  $('uploadForm').submit();
  document.getElementById('uploadStatus').style.visibility = 'visible';
  upload_field.disabled = true;

  return true;
}


/* close UploadDialog */
function closeUpload()
{
  top.$$('.overlay_alphacube').invoke('hide'); 
  top.$$('.dialog, .overlay_alphacube').invoke('remove'); 
}

/* changes DefaultPictures to uploaded */
function changeAvatarPic(pic, avatar_id)
{
  top.$('avatar_img').src         = pic;
  top.$('upload_avatar_id').value = avatar_id;
  top.document.getElementById('uploadButton').style.display = 'none';
  top.document.getElementById('deleteButton').style.display = 'block';
}

/* delete uploaded pictures and reset hiddenField avatar_id */
function deleteAvatarPic(pic)
{
  $('avatar_img').src         = pic;
  $('upload_avatar_id').value = '';
  document.getElementById('uploadButton').style.display = 'block';
  document.getElementById('deleteButton').style.display = 'none';
}



function confirmGroupDelete( okLabel, cancelLabel, url )
{
  Dialog.confirm( $('groupsDelete').innerHTML, 
                  { 
                    className:"alphacube", width:600, okLabel: okLabel, cancelLabel: cancelLabel, ok: function(win) 
                                                                                                      {
                                                                                                        top.location = url;
                                                                                                        return true;
                                                                                                      }
                  }
  );
}


function checkGroupMemberBoxes()
{
  $$('#groupsMemberList input').each(function(o){o.checked = $('mark').checked;}); 
}
//-->