lastid = 0;

function muudanimi( base, id, page, update_id )
{

  if ( lastid != id )
  {
    lastid = id;
    link = base + 'fn_ajax.php?muudapiltinfo='+id+'&page='+page;

    document.getElementById( update_id ).style.display = "table-cell";

    new Ajax.Updater( update_id, link, {
      method: 'get'
    });
  }
  else {
    document.getElementById( update_id ).style.display = "none";
    lastid = 0;
  }

//  document.forms.muuda_nimi.nimi.focus();
//  document.forms.muuda_nimi.nimi.select();
}

function change(href) { window.location.href = href; }

function popup_size(w,h)
{
  window.resizeTo(w,h);
  var x = (screen.width - w) / 2
  var y = (screen.height - h) / 2
  window.moveTo(x,y);
}

function img_r_vasak( base, pilt_id ) {
 var teeme = confirm('Желаете повернуть картинку налево?');;
 if (teeme == true) {
    xmlhttpPost( base + "fn_ajax.php?img_r_vasak=" + pilt_id, "src", "pilt_" + pilt_id ); } }

function img_r_parem( base, pilt_id ) {
 var teeme = confirm('Желаете повернуть картинку направо?');;
 if (teeme == true) {
     xmlhttpPost( base + "fn_ajax.php?img_r_parem=" + pilt_id, "src", "pilt_" + pilt_id ); } }

function xmlhttpPost(strURL, type, element) {
  var http = false;

  if(navigator.appName == "Microsoft Internet Explorer") {
    http = new ActiveXObject("Microsoft.XMLHTTP");
  } else {
    http = new XMLHttpRequest("Ajax");
  }

  http.open("GET", strURL, true);
  http.onreadystatechange=function()
  {
    if(http.readyState == 4) {
      var now = new Date();

      if ( type=='src' )
        updatepage_src ( element, http.responseText + '#' + now.getTime() );
      else if ( type == 'html' )
        updatepage_html ( element, http.responseText );
    }
  }
  http.send(null);
}

function updatepage_html(element, str){
    document.getElementById( element ).innerHTML = str; }

function updatepage_src(element, str){
    document.getElementById( element ).src = str; }


function wazaa( base )
{
  xmlhttpPost( base + "fn_ajax.php?wazaa", "html", "wazaa" );
}
