

function getObj(id) {
	var item = null;
	if (document.getElementById) {
        item = document.getElementById(id);
    }
	else if (document.all) {
		item = document.all[id];
	}
	else if (document.layers) {
		item = document.layers[id];
	}
	return item;
}
var element;
//var elementImage;
var elementHeight;
var elementTextHeight;
var timer;
var step=1;
var waittimer;
var newElement;
var newElementImage;

function ShowHide(id) {
    var item = null;
    if (document.getElementById) {
		item = document.getElementById(id);
    }
    else if (document.all) {
		item = document.all[id];
    }
    else if (document.layers) {
        item = document.layers[id];
    }
    
    element=getObj(id);
    
    if (!item) {
    }
    
	if (item.clientHeight < 2) {
	    ShowElement();
	}
	else {
	    HideElement();
	}
}


function ShowElement() {
	elementHeight=element.clientHeight;
	elementTextHeight=element.firstChild.offsetHeight;
	step=2;
	step=(elementTextHeight/2);
	
	move();
}
function HideElement() {
	elementHeight=element.clientHeight;
	elementTextHeight=element.firstChild.offsetHeight;
	step=2;

	moveClose();
}
function move() {
	if (elementHeight <= elementTextHeight) {
		elementHeight=elementHeight+step;
		//step++;step++;step++;
		if ( step > 2 ) { step=step-step/2; } else { step=2 }
		if ( elementHeight > elementTextHeight ) { element.style.height=elementTextHeight+"px"; elementHeight=elementTextHeight+1; } else { element.style.height=elementHeight+"px"; }
		element.style.height=elementHeight+"px";
		timer=setTimeout("move()",50);
	}
	else { element.style.height=elementTextHeight+"px"; elementHight=elementTextHeight; clearTimeout(timer); }
}
function moveClose() {
	if (elementHeight > 1) {
		elementHeight=elementHeight-step;
		//step++;step++;step++;
		step=step+step;
		if (elementHeight <= 1 ) { element.style.height="1px"; } else { element.style.height=elementHeight+"px"; }
		timer=setTimeout("moveClose()",50);
	}
	else { 
		element.style.height="1px"; 
		elementHeight=1; 
		clearTimeout(timer); 
		/*if ( (element!=newElement) && (newElement) ) { 
			element=newElement;
			//elementImage=newElementImage;
			//elementImage.className="krevedko";
			ShowElement();
		}*/
	}
}