


var max_height = 0;
var last_height = 0;

var last = 0;

function change(id) {
	var duration_open = 500;
	var duration_close = 500;
	
    var div = "#" + id + "_long";
    var more = "#" + id + "_more";
    var arrow = document.getElementById(id + "_arrow").style;
    
    var last_div = "#" + last + "_long";
    var last_more = "#" + last + "_more";
    var last_arrow =  document.getElementById(last + "_arrow").style;
    
   if (jQuery(div).is(":hidden")) {
	   	
        jQuery(div).slideDown(duration_open);
        arrow.backgroundPosition = "top";
        jQuery(more).hide();
        setTimeout("setMax()", duration_open)
        setBottom(0);
        if(last != id) {
        	jQuery(last_div).slideUp(duration_close);
        	last_arrow.backgroundPosition = "bottom";
        	jQuery(last_more).show();
        }
        last = id;
      } else {
        jQuery(div).slideUp(duration_close);
        arrow.backgroundPosition = "bottom";
        jQuery(more).show();
       /* setBottom(1);*/
      }
   
}


function change_id(id) {
	var duration_open = 1000;
	var duration_close = 1000;
	
    var div = "#" + id;
    var arrow = document.getElementById(id + "_arrow").style;
    
    var last_div = "#" + last;
    var last_arrow = document.getElementById(last + "_arrow").style;
    
   if (jQuery(div).is(":hidden")) {
	   
        jQuery(div).slideDown(duration_open);
        arrow.backgroundPosition = "top";
        setTimeout("setMax()", duration_open)
        setBottom(0);
        
        if(last != id) {
            jQuery(last_div).slideUp(duration_close);
            last_arrow.backgroundPosition = "bottom";
            
        }
        last = id;
      } else {
        jQuery(div).slideUp(duration_close);
        arrow.backgroundPosition = "bottom";
       /* setBottom(1);*/
      }
   
}


function setBottom(mode) {
	var bottom = document.getElementById("bottom");
	var height = bottom.offsetHeight;

	if(mode == 0) {
		height = last_height + 100;
		if(max_height < height) {
			bottom.style.height = "";
		}
	}
	if(mode == 1) {
		
		bottom.style.height = height + "px"
	}
}

function setMax() {
	var bottom = document.getElementById("bottom");
	var height = bottom.offsetHeight;
	
	if(height > max_height) {
		max_height = height;
		/*alert(max_height);*/
	}
	var last_height = parseInt(bottom.style.height);
	
}
