//<!--

/* 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 loadProfileUploadOnChange()
{
  $('uploadForm').onchange = function()
	{
		jsUpload(this);
		return false;
	}
}


/* opens UploadDialog */
function openUserUpload( labelCancel, errorMessage )
{
  Dialog.alert( $('profileUpload').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';
  $('uploadStatus').show();
  upload_field.disabled = true;

  return true;
}


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

/* changes DefaultPictures to uploaded */
function changeUserPic(pic)
{
  $('user_img').src = pic;
  document.getElementById('changeAvatar').style.display = 'none';
  document.getElementById('deleteAvatar').style.display = 'block';
}



/* changes avatar to defaultPic */
function deleteUserPic(pic)
{
  $('user_img').src = pic;
  document.getElementById('changeAvatar').style.display = 'block';
  document.getElementById('deleteAvatar').style.display = 'none';
}

/* filles form and shows uploaded picture */
function changeBackgroundPic(pic,pic_id)
{
  top.$('user_img').src    = pic;
  top.$('upload_id').value = pic_id;
  document.getElementById('userImg').style.display          = 'block';
  document.getElementById('changeBackground').style.display = 'none';
  document.getElementById('deleteBackground').style.display = 'block';
}

//just switching the layer, we dont need a dummy-pic, but we need the new id
function deleteBackgroundPic()
{
  top.$('upload_id').value = '';
  document.getElementById('userImg').style.display          = 'none';
  document.getElementById('changeBackground').style.display = 'block';
  document.getElementById('deleteBackground').style.display = 'none';
}

function confirmAccountDeletion(labelCancel) {
  Dialog.alert( $('deleteAccountContainer').innerHTML, 
                { 
                  className:"alphacube", width:600, okLabel: labelCancel
                }
  );

  // hide ok-button, he is just closing the window and at this moment useless.
  $$('.alphacube_buttons').invoke( 'hide' );
}

//-->
