var tickerTimer;
var tickerRight;
function clickTicker() {
	if (tickerTimer) {
		window.clearInterval(tickerTimer);
	}
	var div=document.getElementById("ticker");
	if (div) {
		var div1=div.firstChild;
		if (div1.offsetHeight>10) {
			tickerTimer=window.setInterval("tickerCollapse()",5);
		}
		else {
			tickerTimer=window.setInterval("tickerExpand()",5);
		}
	}
}
function placeTicker(id,screenWidth) {
	var div=document.getElementById("ticker");
	var div1=document.getElementById(id);
	if (div && div1) {
		var img=div1.firstChild.firstChild;
		var x=img.offsetWidth+60;
		var parent=img;
		while (parent) {
			x+=parent.offsetLeft;
			parent=parent.offsetParent;
		}
		var y=0;
		div.style.left=x+"px";
		div.style.top=y+"px";
		div.style.display="";
		tickerRight=x;
	}
}
function tickerExpand() {
	var div=document.getElementById("ticker");
	var container=div.firstChild;
	var tbl=container.firstChild;
	var step=(tbl.offsetHeight-container.offsetHeight)/4;
	if (step<1) step=1;
	var h=container.offsetHeight+step;
	if (h>=tbl.offsetHeight) {
		h=tbl.offsetHeight;
		window.clearInterval(tickerTimer);
		tickerTimer=null;
	}
	container.style.height=h+"px";
}
function tickerCollapse() {
	var div=document.getElementById("ticker");
	var container=div.firstChild;
	var tbl=container.firstChild;
	var step=container.offsetHeight/4;
	if (step<1) step=1;
	var h=container.offsetHeight-step;
	if (h<=0) {
		h=0;
		window.clearInterval(tickerTimer);
		tickerTimer=null;
	}
	container.style.height=h+"px";
}
function closeTicker() {
	if (tickerTimer) {
		window.clearInterval(tickerTimer);
	}
	tickerTimer=window.setInterval("tickerCollapse()",5);
}
function onSubmitTicker() {
	if (!document.tickerForm.question.value) {
		document.tickerForm.question.focus();
		alert("Введите текст вопроса");
		return false;
	}
	if (!document.tickerForm.phone.value) {
		document.tickerForm.phone.focus();
		alert("Введите телефон или адрес email");
		return false;
	}
	return true;
}
function submitTicker() {
	if (onSubmitTicker()) {
		document.tickerForm.submit();
	}
}
