var bg = "#ffffff";
var col = "#000000";
var bg_default = "#ffffff";
var col_default = "#000000";

function InitPriv()
{
	w = (document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth);
	w = w/2-481;
	if (w<0) {w=0;}
	document.getElementById("main").style.marginLeft = w+"px";
	if(document.getElementById("CATEGORY_ID")) {
		if (document.getElementById("CATEGORY_ID").value == 1)
			{document.getElementById("interfaceV_TD").style.display = 'none';
			document.getElementById("interfaceV").value = '';
			document.getElementById("systemV_TD").style.display = 'none';
			document.getElementById("systemV").value = '';
			document.getElementById("Files_TR").style.display = 'none';
			document.getElementById("FILE_0").value = '';}		
		if (document.getElementById("CATEGORY_ID").value == 3)
			{document.getElementById("Files_TR").style.display = 'none';
			document.getElementById("FILE_0").value = '';}
	}

}
function Init()
{
	w = (document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth);
	w = w/2-481;
	if (w<0) {w=0;}
	document.getElementById("main").style.marginLeft = w+"px";
}
function InitMap()
{
	w = (document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth);
	w = w/2-481;
	if (w<0) {w=0;}
	document.getElementById("main").style.marginLeft = w+"px";
//--------------------Яндекс Карта--------------------//
        var map = new YMaps.Map(document.getElementById("YMapsID"));
        map.setCenter(new YMaps.GeoPoint(37.622396,55.687639), 15, YMaps.MapType.MAP);
        map.addControl(new YMaps.Zoom());
        map.addControl(new YMaps.ToolBar());
        map.addControl(new YMaps.TypeControl());        
        var s = new YMaps.Style();
        s.iconStyle = new YMaps.IconStyle();
        s.iconStyle.offset = new YMaps.Point(-13,-40);
        s.iconStyle.href = "http://api-maps.yandex.ru/i/0.3/placemarks/pmrdl.png";
        s.iconStyle.size = new YMaps.Point(36,41);
        YMaps.Styles.add("wizard#rdlPoint", s);

        var placemark1 = new YMaps.Placemark(new YMaps.GeoPoint(37.624543,55.689096), {style: "wizard#rdlPoint", balloonOptions: {maxWidth: 300}});
        map.addOverlay(placemark1);
        placemark1.setBalloonContent("ЗАО &quot;Мотив&quot;");        
//--------------------Яндекс Карта--------------------//
}
function WinResize()
{
	w = (document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth);
	w = w/2-481;
	if (w<0) {w=0;}
	document.getElementById("main").style.marginLeft = w+"px";
}
//__________________________________________
function FormCheck()
	{
		wrong = 1;
		wrong &= field_check('MainForm', 'company', 'company', 'Название компании');
		wrong &= field_check('MainForm', 'town', 'town', 'Город');
		wrong &= field_check('MainForm', 'country', 'country', '0');
		wrong &= check_only_number('staff');
		wrong &= field_check('MainForm', 'fio', 'fio', 'Фамилия, имя, отчество');
		wrong &= check_number('phone');
		wrong &= email_check('email');
		wrong &= select_check('MainForm', 'country', '1', 'countryIn', 'countryIn', 'Страна');

		if (!wrong)
		{
			return false;
		} else {
			city_res = document.MainForm.town.value;
			//if (city_res == "1") city_res = document.MainForm.townIn.value;
			country_res = document.MainForm.country.value;
			if (country_res == "1") country_res = document.MainForm.countryIn.value;
			radiores = document.MainForm.radiotype.value;
			if (radiores == "download") radiores = "Cкачали систему";
			if (radiores == "hosting")
				if (document.MainForm.domain.value == "Имя площадки") {radiores = "Создать площадку, имя не указано"} else {radiores = "Создать площадку "+document.MainForm.domain.value+".motiw.ru";}
			textval = "Компания: " + document.MainForm.company.value + "\n" + "Страна: " + country_res + "\n" + "Город: " + city_res + "\n" + "Численность персонала: " + document.MainForm.staff.value + "\n" + "Ф.И.О.: " + document.MainForm.fio.value + "\n" + "Телефон: " + document.MainForm.phone.value + "\n" + "E-mail: " + document.MainForm.email.value + "\n\n" + radiores + "\n";
			textval2 = "Компания: " + document.MainForm.company.value + "<br>" + "Страна: " + country_res + "<br>" + "Город: " + city_res + "<br>" + "Численность персонала: " + document.MainForm.staff.value + "<br>" + "Ф.И.О.: " + document.MainForm.fio.value + "<br>" + "Телефон: " + document.MainForm.phone.value + "<br>" + "E-mail: " + document.MainForm.email.value + "<br><br>" + radiores + "<br>";
			document.MainForm.city.value = city_res;
			document.MainForm.count.value = country_res;
			document.MainForm.text.value = textval;
			document.MainForm.texthtml.value = textval2;
			document.MainForm.submit();
			return true;
		}
	}
//__________________________________________
function FormCheck2()
	{
		wrong = 1;
		wrong &= field_check('MainForm', 'company', 'company', 'Название компании');
		wrong &= field_check('MainForm', 'fio', 'fio', 'Фамилия, имя, отчество');
		wrong &= email_check('email');
		wrong &= field_check('MainForm', 'txt', 'txt', 'Текст сообщения');

		if (!wrong)
		{
			return false;
		} else {
			document.MainForm.submit();
			return true;
		}
	}
//__________________________________________
function FormCheckSeminar()
	{
		wrong = 1;
		wrong &= field_check('MainForm', 'company', 'company', 'Название компании');
		wrong &= field_check('MainForm', 'fio', 'fio', 'Фамилия, имя, отчество');
		wrong &= email_check('email');

		if (!wrong)
		{
			return false;
		} else {
			document.MainForm.submit();
			return true;
		}
	}
//__________________________________________
function FormCheckBuy()
	{
	var StudyTxt = new Array();
	StudyTxt[1]="Обучение в группе на территории Заказчика или в учебном центре ЗАО МОТИВ";
	StudyTxt[2]="Обучение одного сотрудника в учебном центре ЗАО МОТИВ";
	StudyTxt[3]="Индивидуальное обучение администраторов системы на территории Заказчика";
	StudyTxt[4]="Индивидуальное обучение администраторов документооборота на территории заказчика";
	StudyTxt[5]="Индивидуальное обучение руководителей высшего звена на территории Заказчика";
	StudyTxt[6]="Индивидуальное обучение руководителей среднего звена на территории Заказчика";
	StudyTxt[7]="Индивидуальное обучение сотрудников на территории Заказчика";
	StudyTxt[8]="Проведение деловой игры на территории Заказчика";
		wrong = 1;
		wrong &= field_check('MainForm', 'company', 'company', 'Название компании');
		wrong &= field_check('MainForm', 'town', 'town', 'Город');
		wrong &= field_check('MainForm', 'country', 'country', '0');
		wrong &= check_only_number('staff');
		wrong &= field_check('MainForm', 'fio', 'fio', 'Фамилия, имя, отчество');
		wrong &= check_number('phone');
		wrong &= email_check('email');
		//wrong &= select_check('MainForm', 'town', '1', 'townIn', 'townIn', 'Город');
		wrong &= select_check('MainForm', 'country', '1', 'countryIn', 'countryIn', 'Страна');
		wrong &= field_check('MainForm', 'bank', 'bank', 'Банк');
		wrong &= check_only_number('account');
		wrong &= check_only_number('bik');
		wrong &= check_only_number('account2');
		wrong &= check_only_number('inn');
		wrong &= check_only_number('kpp');

		if (!wrong)
		{
			return false;
		} else {
			city_res = document.MainForm.town.value;
			//if (city_res == "1") city_res = document.MainForm.townIn.value;
			country_res = document.MainForm.country.value;
			if (country_res == "1") country_res = document.MainForm.countryIn.value;

			service = "";
			service2 = "";
			if (document.getElementById('licenses').src == "http://www.motiw.ru/pics/radio-sel.gif") {
				service = service + document.getElementById('lic').value+" лицензий<br />";
				service2 = service2 + document.getElementById('lic').value+" лицензий\n";}
			//if (document.getElementById('hosting').src == "http://www.motiw.ru/pics/radio-sel.gif"){
			//	service = service + "Хостинг для "+document.getElementById('lic').value+" лицензий сроком на "+document.getElementById('years').value+" год(а)<br />"
			//	service2 = service2 + "Хостинг для "+document.getElementById('lic').value+" лицензий сроком на "+document.getElementById('years').value+" год(а)\n";}
			if (document.getElementById('update').src == "http://www.motiw.ru/pics/radio-sel.gif"){
				service = service + "Пакет обновлений для "+document.getElementById('lic').value+" лицензий сроком на "+document.getElementById('years2').value+" год(а)<br />";
				service2 = service2 + "Пакет обновлений для "+document.getElementById('lic').value+" лицензий сроком на "+document.getElementById('years2').value+" год(а)\n";}
			if (document.getElementById('study').src == "http://www.motiw.ru/pics/radio-sel.gif"){
				for (i=1;i<=8;i++)
				{
					id = 'studyType0'+i;
					if (document.getElementById(id).checked) {
						service = service + StudyTxt[i]+"<br />";
						service2 = service2 + StudyTxt[i]+"\n";
					}
				}
			}
			
			textval = "Компания: " + document.MainForm.company.value + "\n" + "Страна: " + country_res + "\n" + "Город: " + city_res + "\n" + "Численность персонала: " + document.MainForm.staff.value + "\n" + "Ф.И.О.: " + document.MainForm.fio.value + "\n" + "Телефон: " + document.MainForm.phone.value + "\n" + "E-mail: " + document.MainForm.email.value + "\n\nПокупка:\n" + service2 + "\n"+"\nОбщая стоимость: " + document.MainForm.totalNum.value + " рублей.\n";
			textval2 = "Компания: " + document.MainForm.company.value + "<br>" + "Страна: " + country_res + "<br>" + "Город: " + city_res + "<br>" + "Численность персонала: " + document.MainForm.staff.value + "<br>" + "Ф.И.О.: " + document.MainForm.fio.value + "<br>" + "Телефон: " + document.MainForm.phone.value + "<br>" + "E-mail: " + document.MainForm.email.value + "<br><br>Покупка:<br>" + service + "<br>Общая стоимость: " + document.MainForm.totalNum.value + " рублей.<br>";

			document.MainForm.city.value = city_res;
			document.MainForm.count.value = country_res;
			document.MainForm.text.value = textval;
			document.MainForm.texthtml.value = textval2;
			document.MainForm.submit();
			return true;
		}
	}
//__________________________________________
var h = screen.availHeight*0.39;
var w = screen.availWidth*0.33;
//__________________________________________
function su()
{
	sub=window.open("/subscribe/from_main.php","sub","width=460,height=230,top=" + h + ",left=" + w + ",titlebar=no,toolbar=no,location=center,status=no,menubar=no,scrollbars=no");
	sub.focus();
}
//__________________________________________
function openDiv(divID, picID)
{
	if (document.getElementById(divID).style.display == "none")
	{
		document.getElementById(divID).style.display = "block";
		if (picID!='') document.getElementById(picID).src = "/pics/minus.gif";
		
	}
	else
	{
		document.getElementById(divID).style.display = "none";
		if (picID!='') document.getElementById(picID).src = "/pics/plus.gif";
	}
}
//__________________________________________
function SupSelCheck(val)
{
	switch (val)
	{
		case "1":
			document.getElementById("MARK_TD").style.display = 'table-row';
			document.getElementById("interfaceV_TD").style.display = 'none';
			document.getElementById("interfaceV").value = '';
			document.getElementById("systemV_TD").style.display = 'none';
			document.getElementById("systemV").value = '';
			document.getElementById("Files_TR").style.display = 'none';
			document.getElementById("FILE_0").value = '';
		break;
		case "2":
			document.getElementById("MARK_TD").style.display = 'table-row';
			document.getElementById("interfaceV_TD").style.display = 'table-row';
			document.getElementById("systemV_TD").style.display = 'table-row';
			document.getElementById("Files_TR").style.display = 'table-row';
		break;
		default:
			document.getElementById("MARK_TD").style.display = 'table-row';
			document.getElementById("interfaceV_TD").style.display = 'table-row';
			document.getElementById("systemV_TD").style.display = 'table-row';
			document.getElementById("Files_TR").style.display = 'none';
			document.getElementById("FILE_0").value = '';
	}
}