function mouse_over(what) {
  what.className += '_hover';
}

function mouse_out(what) {
  if(what.className.indexOf('_hover') > 0)
    what.className = what.className.substr(0,what.className.indexOf('_hover'));
}

function mouse_show(link_id,elem_id) {
  elem = document.getElementById(elem_id);
  link = document.getElementById(link_id);
  
  if(link.className.indexOf('_closed') > 0) {
    link.className = link.className.substr(0,link.className.indexOf('_closed')) + '_open';
    elem.className = elem.className.substr(0,elem.className.indexOf('_closed')) + '_open';
  }
  else {
    link.className = link.className.substr(0,link.className.indexOf('_open')) + '_closed';
    elem.className = elem.className.substr(0,elem.className.indexOf('_open')) + '_closed';
  }
}

function checkbox_enable(checkbox,element_id) {
  elem = document.getElementById(element_id);
  
  if(checkbox.checked) {
    elem.disabled = false;
    elem.style.display = "inline";
  }
  else {
    elem.disabled = true;
    elem.style.display = "none";
  }
}

function do_nothing() {
}

/******************************************************************************/

function show_modal(id,href) {
  if(window.showModalDialog) {
    new_win = window.showModalDialog(href,"text_edit","dialogWidth:750px;dialogHeight:500px");
    document.getElementById("sendform"+id).submit();
  } 
  else {
    new_win = window.open(href,'text_edit','height=500,width=750,toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,modal=yes');
  }
}

function open_image(href) {
  if(href != null)
    new_window = window.open("foto_view.php?img="+href,"","width=400,height=400,resizable,scrollbars=no,status=0");
}

function fit_image() {
  if(window.innerWidth) {
    iWidth = window.innerWidth;
    iHeight = window.innerHeight;
  }
  else {
    iWidth = document.body.clientWidth;
    iHeight =document.body.clientHeight;
  }
  iWidth = document.images[0].width - iWidth;
  iHeight = document.images[0].height - iHeight;
  window.resizeBy(iWidth, iHeight);
};

/******************************************************************************/

function savetext(formid) {
  window.open('','smallwin','height=50,width=200,toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,modal=1');
  document.getElementById(formid).target="smallwin";
  document.getElementById(formid).submit();
}

function saveform_onload(id) {
  window.close();
  window.opener.close();
  window.opener.window.opener.document.getElementById("sendform"+id).submit();
}

function ask(message,href) {
  if(confirm(message))
    location.href=href;
}
