﻿// Обработчик переключения страниц на главной странице
function ico_view(id) {
	var constId = "text";
	var icoT = "ico";
	var i = 1;
	var stat = true;
	do
	{
		var newId = constId + i;
		var iconId = icoT + i;
		if( document.getElementById( newId ) )
			{
				document.getElementById( newId ).style.display  = (i == id) ? 'block' : 'none';
				document.getElementById( iconId ).src  = (i == id) ? 'img/icon_'+i+'_ru_s.gif' : 'img/icon_'+i+'_ru.gif';
				i++;
			} else {
				stat = false;
			}
	}
	while (stat);
}

// Проверка заполнения полей в форме подключения к услуге
function check_new() {
    texts = "";
    if (document.forms["new"].select.value == "") {
		texts += "- Срок подписки \n"
    }
    if (document.forms["new"].name.value == "") {
		texts += "- Имя \n"
    }
    if (document.forms["new"].mail.value == "") {
        texts += "- Адрес электронной почты \n"
    }
	if (document.forms["new"].tariff.value == "") {
		texts += "- Тарифный пакет \n"
	}
    if (texts != "") {
        alert("Необходимо заполнить следующие поля: \n" + texts); 
        return false;
    }
	//alert("Услуга временно недоступна.");
    document.forms["new"].submit();
}

// Проверка заполнения полей в форме продления подписки
function check_old() {
	texts = "";
    if (document.forms["old"].select.value == "") {
        texts += "- Срок продления подписки \n"
    }
    if (document.forms["old"].mail.value == "") {
        texts += "- Адрес электронной почты \n"
    }
    if (document.forms["old"].code.value == "") {
        texts += "- Код \n"
    }
    if (texts != "") {
        alert("Необходимо заполнить следующие поля: \n" + texts); 
        return false;
    }
	//alert("Услуга временно недоступна.");
    document.forms["old"].submit();
}

// Проверка ввода кода при получении информации о клиенте
function check_info() {
	texts = "";
    if (document.forms["info"].code.value == "") {
        texts += "- Код \n"
    }
    if (texts != "") {
        alert("Необходимо заполнить следующие поля: \n" + texts); 
		return false;
    }
    document.forms["info"].submit();
}
