var tickerTimer;
var tickerRight;
function clickTicker() {
	if (tickerTimer) {
		window.clearInterval(tickerTimer);
	}
	var div=document.getElementById("ticker");
	if (div) {
		var div1=div.firstChild.nextSibling;
		if (div1.offsetWidth>10) {
			tickerTimer=window.setInterval("tickerCollapse()",5);
		}
		else {
			tickerTimer=window.setInterval("tickerExpand()",5);
		}
	}
}
function placeTicker(id,screenWidth) {
	var div=document.getElementById("ticker");
	if (div) {
		var img=div.firstChild;
		var x=document.body.clientWidth-23;
		var y=35;
		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.nextSibling;
	var tbl=container.firstChild;
	var step=(tbl.offsetWidth-container.offsetWidth)/4;
	if (step<1) step=1;
	var w=container.offsetWidth+step;
	if (w>=tbl.offsetWidth) {
		w=tbl.offsetWidth;
		window.clearInterval(tickerTimer);
		tickerTimer=null;
	}
	container.style.width=w+"px";
	div.style.left=(tickerRight-w)+"px";
}
function tickerCollapse() {
	var div=document.getElementById("ticker");
	var container=div.firstChild.nextSibling;
	var tbl=container.firstChild;
	var step=container.offsetWidth/4;
	if (step<1) step=1;
	var w=container.offsetWidth-step;
	if (w<=0) {
		w=0;
		window.clearInterval(tickerTimer);
		tickerTimer=null;
	}
	container.style.width=w+"px";
	div.style.left=(tickerRight-w)+"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();
	}
}
