function gogo(select)
{
	if(select.options[select.selectedIndex].value !== '')
	{
		location = select.options[select.selectedIndex].value;
	}
}

function clearSearchInput(input)
{
	if (input.value == 'Поиск')
	{
		input.value = '';
	}
	else if (input.value == '')
	{
		input.value = 'Поиск';
	}
}

function fixIeHover(id)
{
	if (window.navigator.appName == "Microsoft Internet Explorer" /*&& !window.navigator.appVersion.match(/MSIE 7/)*/)
	{
		var nodes = document.getElementById(id).getElementsByTagName("li");
		for (var i = 0; i < nodes.length; i++)
		{
			nodes[i].onmouseover = function()
			{
				this.className += " over";
			}
			nodes[i].onmouseout = function()
			{
				this.className = this.className.replace(new RegExp(" over\\b"), "")
			}
		}
	}
}

// стандартный отступ
var PADDING = 5;
// высота низа: 57 изображение + 3 отступ от границы окна
var FOOTER_HEIGHT = 67;
// минимальная высота главной страницы: 5 отступ от границы окна + 80 верхний баннер + 43 верхние кнопки + 5 отступ правого баннера + 420 правый баннер + 60 низ - 21 поправка на прилегание баннера к низу
var HOME_MIN_HEIGHT = 592;
// минимальная ширина: 222 левая часть (логотип) + 600 средняя часть (верхний баннер) + 181 правая часть (инфоблок)
var MIN_WIDTH = 1003;
// часть сайта - главная или подсайты
var MAIN = window.location.hostname == 'airs.ru' || window.location.hostname == 'www.airs.ru' || window.location.hostname == 'airs' || window.location.hostname == '192.168.0.11';

if (MAIN)
{
	var HEADER_HEIGHT = 127;
}
else
{
	var HEADER_HEIGHT = 162;
}

function setMain()
{
	if (document.body.offsetHeight > HOME_MIN_HEIGHT)
	{
		var body_height = document.body.offsetHeight;
	}
	else
	{
		var body_height = HOME_MIN_HEIGHT;
	}

	var news_and_articles_height = body_height - 480 - 15; // 128 (верх) + 60 (низ) + 282 (модели 94 * 3) + 10 (верхний и нижний отступ моделей) =
	var height_space = news_and_articles_height - 60; //старое значение - 27; 22 это высота заголовка блока статьи или новости - 5 оступ от низа блока

	// если пространства мало, удаляем 1 строку из таблицы обзора оборудования
	document.getElementById("news0").style.display = document.getElementById("news1").style.display = "block";
	if (height_space < (document.getElementById("news0").offsetHeight + document.getElementById("news1").offsetHeight))
	{
		height_space += 94; // 94 высота 1 строки таблицы обзора оборудования
		news_and_articles_height += 94;
		document.getElementById("systemair").style.display = document.getElementById("purifierDaikin").style.display = "none";
	}
	else
	{
		document.getElementById("systemair").style.display = document.getElementById("purifierDaikin").style.display = "block";
	}
	var height_news = height_space - 15 + 25; // 15 ссылка все новости

	// так как свойство display: none высоту равняет к нулю, восстанавливаем значение
	document.getElementById("news").style.height = document.getElementById("articles").style.height = news_and_articles_height + "px";
	document.getElementById("modelsList").style.top = news_and_articles_height + PADDING + 25 + "px";

	for (var i = 0, max_news_height = 0, max_article_height = 0, news, article; i < 9; i++)
	{
		news = document.getElementById("news" + i);
		article = document.getElementById("article" + i);

		if (news.offsetHeight == 0)
		{
			news.style.display = "block";
		}
		if (article.offsetHeight == 0)
		{
			article.style.display = "block";
		}

		max_news_height += news.offsetHeight;
		max_article_height += article.offsetHeight;

		if (max_news_height > height_news)
		{
			news.style.display = "none";
		}
		if (max_article_height > (height_space - 150))
		{
			article.style.display = "none";
		}
	}
}

function setFooter()
{
	if (MAIN)
	{
		if (window.location.pathname == "/")
		{
			if (document.body.offsetHeight > HOME_MIN_HEIGHT)
			{
				height = document.body.offsetHeight - FOOTER_HEIGHT;
			}
			else
			{
				// 128 верх + 420 баннер + 5 отступ баннера = 552
				height = 553;
			}
		}
		else
		{
			var height = Math.max(document.getElementById("menuNavigation").offsetHeight + 88 /* левый баннер */, document.getElementById("content").offsetHeight + 3 /* отступ хлебных крошек  от верха */) + PADDING;
			if ((height + 187) < document.body.offsetHeight) // 127 (верхняя часть) + 60 (нижняя часть) = 187
			{
				height = document.body.offsetHeight - FOOTER_HEIGHT;
			}
			else
			{
				height = height + HEADER_HEIGHT;
			}
		}
	}
	else
	{
		var height = document.getElementById("content").offsetHeight + PADDING;
		if ((height + 200) < document.body.offsetHeight) // 140 (верхняя часть) + 60 (нижняя часть) = 200
		{
			height = document.body.offsetHeight - FOOTER_HEIGHT;
		}
		else
		{
			height = (document.getElementById("menuNavigation").offsetHeight + height) - HEADER_HEIGHT/3;
		}
	}
	document.getElementById("footer").style.display = 'block';
	document.getElementById("footer").style.top = height + "px";
}

function setStyle()
{
	if (MAIN && window.location.pathname == "/")
	{
		setMain();
	}
	setFooter();
}

function setGuide()
{
	var articles_height = Math.max(document.body.offsetHeight - 162 - 65, document.getElementById("content").offsetHeight); // 140 (верх) + 60 (низ)
	var height_space = articles_height - 22 - 5; // 22 это высота заголовка блока статьи или новости - 5 оступ от низа блока

	document.getElementById("articles").style.height = articles_height + "px";

	for (var i = 0, max_article_height = 0, article; i < 9; i++)
	{
		article = document.getElementById("article" + i);

		if (article.offsetHeight == 0)
		{
			article.style.display = "block";
		}

		max_article_height += article.offsetHeight;

		if (max_article_height > height_space)
		{
			article.style.display = "none";
		}
	}
}

function openFullImage(image_path)
{
	var image_window = window.open('', 'full_image', 'scrollbars=1,resizable=1,status=no,toolbar=no,menubar=no');
	image_window.document.write('<img src="' + image_path + '" alt="" />');
}

function viewDetails(url){window.open(url,'','scrollbars=1,resizable=1,width=800,height=700,status=no,toolbar=no,menubar=no');}
function animClipDown(ref,counter){var cP=Math.pow(Math.sin(Math.PI*counter/200),0.75);ref.style.clip=(counter==100?((window.opera||navigator.userAgent.indexOf('KHTML')>-1)?'':'rect(auto, auto, auto, auto)'):'rect(0, '+ref.offsetWidth+'px, '+(ref.offsetHeight*cP)+'px, 0)')};function animFade(ref,counter){var f=ref.filters,done=(counter==100);if(f){if(!done&&ref.style.filter.indexOf("alpha")==-1)ref.style.filter+=' alpha(opacity='+counter+')';else if(f.length&&f.alpha)with(f.alpha){if(done)enabled=false;else{opacity=counter;enabled=true}}}else ref.style.opacity=ref.style.MozOpacity=counter/100.1};