// JavaScript Document

var spacing		= 15;
var timerStart	= 1;
var timerEnd	= 30;
var maxHeight	= 200;
var minHeight	= 0;
var allow		= 1;

function show_search(id1, id2, height){
	if(allow == 0) return;
	spacing		= 15;
	timerStart	= 10;
	timerEnd		= 30;
	maxHeight	= height;
	minHeight	= 1;
	ob1			= document.getElementById(id1);
	ob2			= document.getElementById(id1);
	if(ob1.className == "close_search"){
		open_search(id2);
		ob1.className = "open_search";
	}
	else{
		close_search(id2)
		ob1.className = "close_search";
	}
}

function open_search(id){
	allow		= 0;
	ob			= document.getElementById(id);
	height	= parseInt(ob.style.height) + spacing;
	
	timer		= timerEnd;
	if(height > (maxHeight - 10))			spacing = 1;
	else if(height > (maxHeight - 15))	spacing = 2;
	else if(height > (maxHeight - 25))	spacing = 3;
	else if(height > (maxHeight - 50))	spacing = 5;
	else timer	= timerStart;
	
	ob.style.height = height + "px";
	if(height >= maxHeight){
		allow	= 1;
		ob.style.overflow = "auto";
		return;
	}
	
	command	= 'open_search("' + id + '")';
	setTimeout(command, timer);
}

function close_search(id){
	allow		= 0;
	ob			= document.getElementById(id);
	ob.style.overflow = "hidden";
	height	= parseInt(ob.style.height) - spacing;
	
	timer		= timerEnd;
	if(height < (minHeight + 10))			spacing = 1;
	else if(height < (minHeight + 25))	spacing = 3;
	else if(height < (minHeight + 50))	spacing = 5;
	else timer	= timerStart;
	
	ob.style.height = height + "px";
	if(height <= minHeight){
		allow	= 1;
		return;
	}
	
	command	= 'close_search("' + id + '")';
	setTimeout(command, timer);
}
