//This is the main file for all the javascript ajax functions ...

function inSavemode(){
  $('#savestatus').text(' Saving ... ');
}
function reportError(request)
{
  alert('Sorry. There was an error. (Ajax error)');
}
function saveBlockContent(blocktext_id, content){
  if(blocktext_id == "" || content == ""){
    alert("error: we have not all vars");
  }
  var url = '/blocks/savecontent';
  var pars = 'blocktext_id='+blocktext_id+'&content='+content+'';
  var myAjax = new Ajax.Request(
  url,
  {
    method: 'post',
    parameters: pars,
    onComplete: outSavemode
  });
}
function waitAndfade(element, time){
	if(!time){
		time = 3000;
	}
	$(element).delay(time).fadeOut(300);
}
function clearForm(form) {
  // iterate over all of the inputs for the form
  // element that was passed in
  $(':input', form).each(function() {
 var type = this.type;
 var tag = this.tagName.toLowerCase(); // normalize case
 // it's ok to reset the value attr of text inputs,
 // password inputs, and textareas
 if (type == 'text' || type == 'password' || tag == 'textarea')
   this.value = "";
 // checkboxes and radios need to have their checked state cleared
 // but should *not* have their 'value' changed
 else if (type == 'checkbox' || type == 'radio')
   this.checked = false;
 // select elements need to have their 'selectedIndex' property set to -1
 // (this works for both single and multiple select elements)
 else if (tag == 'select')
   this.selectedIndex = -1;
  });
};