/* gallerie neu, scripts SK */

function switch_img(url) {
       document.getElementById("gal_img_cont").style.backgroundImage = "url(/bilder/d146/loading.gif)";
       ajax_call('/wn05iframe/page_gallery.php?'+url);
}

var gal_aktiv;
var gal_up = true;
var gal_down = false;
var akt_hoehe;
var gal_speed = 10;

function gal_slide_up(htmlid) {
       if (gal_up) {
          from = document.getElementById(htmlid).offsetHeight;
          to = document.getElementById(htmlid+"_text").offsetHeight+from;
          if (from < to) {
             gal_up = false;
             akt_hoehe = from;
             set_gal_int(htmlid,from,to,"up");
          }
       }
    }

function gal_slide_down(htmlid) {
       if (gal_down) {
          from = document.getElementById(htmlid).offsetHeight;
          to = from-document.getElementById(htmlid+"_text").offsetHeight;
          if (from > to) {
             gal_down = false;
             akt_hoehe = from;
             set_gal_int(htmlid,from,to,"down");
          }
       }
}

function do_gal_slide_up(htmlid,from,to) {
      newhoehe = akt_hoehe+gal_speed;
      newmargin = newhoehe-from;
      if (newhoehe <= to) {
         document.getElementById(htmlid).style.height = newhoehe+"px";
         document.getElementById(htmlid).style.marginTop = "-"+newmargin+"px";
         akt_hoehe = newhoehe;
      }
      else {
         document.getElementById(htmlid).style.height = to+"px";
         endMa = to-from;
         document.getElementById(htmlid).style.marginTop = "-"+endMa+"px";
         clear_gal_int();
         gal_down = true;
      }
}


function do_gal_slide_down(htmlid,from,to) {
      newhoehe = akt_hoehe-gal_speed;
      newmargin = newhoehe-to;
      if (newhoehe >= to) {
          document.getElementById(htmlid).style.height = newhoehe+"px";
          document.getElementById(htmlid).style.marginTop = "-"+newmargin+"px";
          akt_hoehe = newhoehe;
      }
      else {
          document.getElementById(htmlid).style.height = to+"px";
          endMa = to-from;
          document.getElementById(htmlid).style.marginTop = "0px";
          clear_gal_int();
          gal_up = true;
      }
}

function set_gal_int(htmlid,from,to,funct) {
       gal_aktiv = window.setInterval("do_gal_slide_"+funct+"('"+htmlid+"',"+from+","+to+")",40);
}

function clear_gal_int() {
       if(gal_aktiv) { window.clearInterval(gal_aktiv); }
}
