// JavaScript Document

var content_drag = "<div class=\"drag\">drag</div>";
var content_id = 0;

var content = new Array(100);
  
function save_content(event){
  max_zindex += 10;
  var id = "cm_" + content_id;
  var id_con = "con_" + content_id; 
  if(content[content_id] != content_drag){
    content[content_id] = $(id).innerHTML; 
  } 
  $(id).innerHTML = content_drag;
  $(id_con).style.backgroundColor = "transparent";
  $(id_con).style.zIndex = max_zindex;
}

function give_content(){
  var id_con = "con_" + content_id;
  var id = "cm_" + content_id;
  $(id).style.display = "none";
  $(id_con).style.backgroundColor = "#ffffff";
  setTimeout("give_content_real()",400);
}

function give_content_real(){
  var id = "cm_" + content_id;
  $(id).innerHTML = content[content_id];
  new Effect.Appear(id,{duration:.8});
}

function setze(){
    var versatz = 4;
    var rand = $('all').offsetLeft;
    //ie6 ?  rand = $('all').offsetLeft : rand = 0;
    var regler_pos_1 = $('regler3').offsetLeft;
    var regler_pos_2 = $('regler4').offsetLeft;
    var breite_all = $('all').offsetWidth;
    
    var x1 = regler_pos_1 - rand;
    var x3 = $('box_3').offsetWidth;
    
    if ((regler_pos_2 - regler_pos_1) < 180){
      x1 = regler_pos_2 - 180;
    }
    x1 < 180 ? x1 = 180 : true;
    
    var all_pro = 98;
    ie6 ? all_pro = 98 : true;
    
    var x1_pro = x1 * 100 / breite_all;
    var x3_pro = x3 * 100 / breite_all;
    var x2_pro = all_pro - x1_pro - x3_pro;
    
    var x1_pro_p = x1_pro + "%";
    var x2_pro_p = x2_pro + "%";
    
    
    $('box_1').style.width = x1_pro_p;
    $('box_2').style.width = x2_pro_p;
    $('regler3').style.left = "0px";
    
    rsx();
    
    pro_1 = x1_pro;
    pro_2 = x2_pro;
    pro_3 = x3_pro;
  }
  
  function setze2(){
    var versatz = 4;
    var rand = $('all').offsetLeft;
    var regler_pos_1 = $('regler3').offsetLeft;
    var regler_pos_2 = $('regler4').offsetLeft;
    var breite_all = $('all').offsetWidth;
    
    var x1 = $('box_1').offsetWidth;
    var x2 = regler_pos_2 - regler_pos_1 - versatz;
    
    if ((regler_pos_2 - regler_pos_1) < 180){
      x2 = 180;
    }
    regler_pos_2 > breite_all - 180 ? x2 = breite_all - 180 - x1: true;
    
    var all_pro = 98;
    ie6 ? all_pro = 98 : true;
    
    var x1_pro = x1 * 100 / breite_all;
    var x2_pro = x2 * 100 / breite_all;
    var x3_pro = all_pro - x1_pro - x2_pro;
    
    var x2_pro_p = x2_pro + "%";
    var x3_pro_p = x3_pro + "%";
    
    $('box_2').style.width = x2_pro_p;
    $('box_3').style.width = x3_pro_p;
    $('regler4').style.left = "0px";
    //$('regler4').style.position = "static"; 
    rsx(); 
    
    pro_1 = x1_pro;
    pro_2 = x2_pro;
    pro_3 = x3_pro;   
  }
  
  function speicher(){
    max_zindex++;
    $('regler3').style.zIndex = max_zindex;
    pos_1 = $('box_1').offsetWidth;
    //$('regler3').style.position = "relative";
  }
  
  function speicher2(){
    max_zindex++;
    $('regler4').style.zIndex = max_zindex;
    pos_2 = $('box_1').offsetWidth + $('box_2').offsetWidth;
    //$('regler4').style.position = "relative";
  }
  
  function rss(){
    max_zindex++;
    var id = "rs_" + this.id_nr;
    var id_con = "con_" + this.id_nr;
    $(id).style.position = "relative";
    $(id_con).style.zIndex = max_zindex;
  }
  
  function rs(){
    var id_c = "c_" + this.id_nr;
    var id_rs = "rs_" + this.id_nr;
    var id_oc = "oc_" + this.id_nr;
    var pos_e = $(id_c).offsetTop;
    var pos_rs = $(id_rs).offsetTop;
    var h = pos_rs - pos_e - 1;
    var h_px = h + "px";
    if(h >30){
      $(id_c).style.height = h_px;
    }
    else{
      $(id_c).style.height = "30px";
    }
    $(id_rs).style.position = "static";
    $(id_oc).style.backgroundImage = "url(" + root_dir + "v6/grafiken/open.gif)";
    
    rsx();
    
    //explorer-bug -------------------------------
    /*var id_con = "con_" + this.id_nr;
    var breite_con = $(id_con).offsetWidth - 2;
    var breite_con_px = breite_con + "px";
    $(id_c).style.width = breite_con_px;
    $(id_c).style.width = "100%";*/ 
  }

  function is_empty(){
    max_zindex++;
    $('box_1').style.zIndex = max_zindex;
    //$('zeige').innerHTML = pro_1;
    
    if ($('box_1').offsetHeight < 10){
      var breite = pro_1 + "%";
      $('box_1').style.width = breite;
      $('box_1').style.height = "20px";
    }
    else{
      $('box_1').style.height = "";
    }
  }
  
  function is_empty2(){
    max_zindex++;
    $('box_2').style.zIndex = max_zindex;
    
    if ($('box_2').offsetHeight < 10){
      var breite = pro_2 + "%";
      $('box_2').style.width = breite;
      $('box_2').style.height = "20px";
    }
    else{
      $('box_2').style.height = "";
    }
  }
  
  function is_empty3(){
    max_zindex++;
    $('box_3').style.zIndex = max_zindex;
    if ($('box_3').offsetHeight < 10){
      var breite = pro_3 + "%";
      $('box_3').style.width = breite;
      $('box_3').style.height = "20px";
    }
    else{
      $('box_3').style.height = "";
    }
  }

function rsx(){
  var h1 = $('box_1').offsetHeight;
  var h2 = $('box_2').offsetHeight;
  var h3 = $('box_3').offsetHeight;
  var h1_px = h1 + "px";
  var h2_px = h2 + "px";
  var h3_px = h3 + "px";
  
  h1 > h2 ? $('regler3').style.height = h1_px : $('regler3').style.height = h2_px;
  h2 > h3 ? $('regler4').style.height = h2_px : $('regler4').style.height = h3_px;
  
  
}
 
function max_win(nr){
  var cm_id = "cm_" + nr;
  var c_id = "c_" + nr;
  var hoehe = $(cm_id).offsetHeight + 5;
  var hoehe_px = hoehe + "px";
  $(c_id).style.height = hoehe_px;
  
  var oc_id = "oc_" + nr;
  $(oc_id).style.backgroundImage = "url(" + root_dir + "v6/grafiken/open.gif)";
  rsx();
}

function max_win_bn(nr){
  var cm_id = "cm_" + nr;
  var c_id = "c_" + nr;
  var hoehe = 120 + $('Göttinger Wald').offsetHeight + $('Harz').offsetHeight + $('Vorharz').offsetHeight + $('Weser-Leine').offsetHeight;
  var hoehe_px = hoehe + "px";
  $(c_id).style.height = hoehe_px;
  
  var oc_id = "oc_" + nr;
  $(oc_id).style.backgroundImage = "url(" + root_dir + "v6/grafiken/open.gif)";
  rsx();
}

function inc_win(nr){
  var id = "c_" + nr;
  var hoehe = $(id).offsetHeight + 50;
  var hoehe_px = hoehe + "px";
  $(id).style.height = hoehe_px;
  
  var id_oc = "oc_" + nr;
  $(id_oc).style.backgroundImage = "url(" + root_dir + "v6/grafiken/open.gif)";
  rsx();
}

function dec_win(nr){
  var id = "c_" + nr;
  var hoehe = $(id).offsetHeight;
  if(hoehe > 60){
    hoehe -= 50;
    var hoehe_px = hoehe + "px";
    $(id).style.height = hoehe_px;
    rsx();
  }
}

function hide_(obj,win){
  var id = "c_" + win; 
  var hide_object = $(id);
  if(hide_object.offsetHeight == 3){
    switch(win){
      case 1:hide_object.style.height = alt_height_1 + "px"; break;
      case 2:hide_object.style.height = alt_height_2 + "px"; break;
      case 3:hide_object.style.height = alt_height_3 + "px"; break;
      case 4:hide_object.style.height = alt_height_4 + "px"; break;
      case 5:hide_object.style.height = alt_height_5 + "px"; break;
      case 6:hide_object.style.height = alt_height_6 + "px"; break;
      case 7:hide_object.style.height = alt_height_7 + "px"; break;
      case 8:hide_object.style.height = alt_height_8 + "px"; break;
  }
  obj.style.backgroundImage = "url(" + root_dir + "v6/grafiken/open.gif)";
  //hide_object.style.overflow = "auto";
  }
  else{
    switch(win){
      case 1:alt_height_1 = hide_object.offsetHeight; break;
      case 2:alt_height_2 = hide_object.offsetHeight; break;
      case 3:alt_height_3 = hide_object.offsetHeight; break;
      case 4:alt_height_4 = hide_object.offsetHeight; break;
      case 5:alt_height_5 = hide_object.offsetHeight; break;
      case 6:alt_height_6 = hide_object.offsetHeight; break;
      case 7:alt_height_7 = hide_object.offsetHeight; break;
      case 8:alt_height_8 = hide_object.offsetHeight; break;
    }
   hide_object.style.height = "3px";
   obj.style.backgroundImage = "url(" + root_dir + "v6/grafiken/close.gif)";
      //hide_object.style.overflow = "hidden";
  }
  rsx();
}

function win_collapse(){
  hoehe_win = hoehe_win - 1;
  if(hoehe_win > 3){
    alert(hoehe_win);
    //$(id).style.height = "3px";
    setTimeout("win_collapse()", 1000);
  } 
}

var hoehe_win = 10;











