﻿var n_house_type=9; //10
var n_plan_type=3; //6
var n_compl=7; //6
var kompl_name=['Профиль','Стеклопакет','Фурнитура','Подоконник','Откосы','Ручка','Уплотнитель'];
var n_access=12; //12
var dop_aks_name=['Чесма Baby STOP!','Чесма Термо +','Чесма Анти шум','Чесма Анти дождь','Чесма Анти пыль','Чесма Анти солнце','Чесма тон','Чесма защита','Чесма Анти комар','Чесма Анти комар+','Чесма колор','Чесма декор'];
var price_dop_aks=[ '1593','1210','811','1131', '1100','3130','3207','10610', '1178','4483','3781','3672' ];
var n_options=1; //2
var uslugi1_name=['СТАНДАРТ', 'ЛЮКС'];
var n_service=1; //4
var uslugi2_name=['Вывоз мусора', 'доставка', 'окна в кредит', 'мобильный офис'];
var n_discount=4; //6
var discount_name=['СКИДКА ПО ДИСКОНТНОЙ КАРТЕ','СКИДКА 3%','СКИДКА ЗА ОБЪЕМ','СКИДКА 5%'];
var n_price=5; //6


function insertprice() {
	s1=s2=document.getElementById('order_discount').value=0;
	kolvo_okon=parseInt(document.getElementById('kolvo_okon').value);
	document.getElementById('price_inp3').value=document.getElementById('price_inp1').value;
	
	for (i=1; i<=n_access; i++) {
		itm_1 = document.getElementById('dop_aks'+i);
		if ((itm_1.style.backgroundColor=="rgb(187, 225, 202)") || (itm_1.style.backgroundColor=="#bbe1ca")) {
			if ((i>=1 && i<=5) || i==9 || i==10) s1+=price_dop_aks[i-1]*kolvo_okon;
			else s2+=price_dop_aks[i-1]*kolvo_okon;
		} //alert(kolvo_okon+'-'+price_dop_aks[i-1]);
	}
	
	sum_usluga=( kolvo_okon * document.getElementById('order_usluga').value ).toFixed(2);
	sum_usluga=parseFloat(sum_usluga);
	
	for (i=1; i<=n_discount; i++) {
		discount=0;
		itm1='discount_checkb'+i;
		itm_1 = document.getElementById(itm1);
		if (!itm_1.style.backgroundPosition) itm_1.style.backgroundPosition="0px 0px";
		if (itm_1.style.backgroundPosition=="0px -19px") {
			switch (i) {
				case 1: discount=parseInt(document.getElementById(itm1+'n').value); break;
				case 2: discount=3; break;
				case 3: n=parseInt(document.getElementById(itm1+'n').value); if (!n) n=0;
				switch (n) {
					case 0: discount=0; break;
					case 1: discount=3; break;
					case 2: discount=5; break;
					default: discount=7; break;
				} break;
				case 4: discount=5; break;
			}
			document.getElementById('order_discount').value=parseInt(document.getElementById('order_discount').value)+discount;
		}
	}
	discount=parseInt(document.getElementById('order_discount').value);
	document.getElementById('discount_all').innerHTML=discount;
	
	s1+=parseFloat(document.getElementById('price_inp3').value);
	document.getElementById('price_inp3').value=( s1+s2 ).toFixed(2)+' руб.';

	document.getElementById('price_inp4').value=s1+s2+sum_usluga+' руб.';

	if (discount) s1=s1*((100-discount)/100);
	document.getElementById('price_inp2').value=( s1+s2+sum_usluga ).toFixed(2)+' руб.';
	//alert(s1);
}


function step3_dop_aks(id) {
	if (document.getElementById) {
		itm_1 = document.getElementById('dop_aks'+id);
		itm_2 = document.getElementById('dop_aks_div_'+id);
		itm_3 = document.getElementById('div_title2_'+id);
	}
	if (itm_1.style.backgroundColor=="rgb(187, 225, 202)" || itm_1.style.backgroundColor=="#bbe1ca") {
		itm_1.style.backgroundColor = "#f0f4fe";
		itm_2.style.backgroundColor = "#0bb33a";
		itm_1.style.color = "#707070";
		itm_2.style.color = "#ffffff";
		itm_3.style.display = "none";
	} else {
		itm_1.style.backgroundColor = "#bbe1ca";
		itm_2.style.backgroundColor = "#1063a5";
		itm_1.style.color = "#111111";
		itm_2.style.color = "#ffffff";
		itm_3.style.display = "inline";
	}
insertprice();
}


function opc_change(id2){
	for (id=1; id<=n_options; id++) {
		if (document.getElementById) {
			itm_1 = document.getElementById('opc'+id);
			itm_2 = document.getElementById('opc_div_title'+id+'_2');
			itm_3 = document.getElementById('opc'+id+'_title2');
		}
		if (!itm_1.style.backgroundPosition) itm_1.style.backgroundPosition="0px 0px";
		if (id==id2) {
			if (itm_1.style.backgroundPosition=="0px 0px") {
				itm_1.style.backgroundPosition = "0px -155px";
				itm_2.style.display = "inline-block";
				itm_3.style.color = "#ff0000";
			} else {
				itm_1.style.backgroundPosition = "0px 0px";
				itm_2.style.display = "";
				itm_3.style.color = "#1063a5";
			}
		} else {
			itm_1.style.backgroundPosition = "0px 0px";
			itm_2.style.display = "";
			itm_3.style.color = "#1063a5";
		}
	}
}


function usluga_checkb(id, usluga2_count) {
	if (document.getElementById) itm_1 = document.getElementById('usluga_'+id);
	if (!itm_1.style.backgroundPosition) itm_1.style.backgroundPosition="0px 0px";
	if (itm_1.style.backgroundPosition=="0px 0px") {
		itm_1.style.backgroundPosition = "0px -19px";
		document.getElementById('order_usluga').value=usluga2_count;
	} else {
		itm_1.style.backgroundPosition = "0px 0px";
		document.getElementById('order_usluga').value='';
	}
insertprice();
}


function discount_checkb(id, discount_count) {
	if (document.getElementById) itm_1 = document.getElementById('discount_checkb'+id);
	if (!itm_1.style.backgroundPosition) itm_1.style.backgroundPosition="0px 0px";
	if (itm_1.style.backgroundPosition=="0px 0px") {
		itm_1.style.backgroundPosition = "0px -19px";
	} else {
		itm_1.style.backgroundPosition = "0px 0px";
	}
insertprice();
}


function getRadioGroupValue(radioGroupObj) {
	for (var i=0; i < radioGroupObj.length; i++) if (radioGroupObj[i].checked) return parseInt(radioGroupObj[i].value);
	return null;
}


function kompl_change(cur_choice) { 
	c1=getRadioGroupValue(document.shop.step2_teplo);
	c2=getRadioGroupValue(document.shop.step2_tishina);
	c3=getRadioGroupValue(document.shop.step2_krasota);
	kompl_var=c1+c2*3+c3*9;
	document.getElementById('c3').value=kompl_var+1;

	for (i=1; i<=n_compl; i++) {
		document.getElementById('kompl_'+i).innerHTML='<p>'+komplektaciya[kompl_var][3+i]+'</p><div class="tooltip"><span class="tooltip_title">'+komplektaciya[kompl_var][3+i]+'</span><br />'+komplektaciya[kompl_var][3+i+n_compl]+'</div>'; 
	}

	ajaxLoad('price_inp', '/mgr_ajax.php?c1='+document.getElementById('c1').value+'&c2='+document.getElementById('c2').value+'&c3='+document.getElementById('c3').value, '','','');
	
	if (document.getElementById('price_inp0').value!=" руб." && document.getElementById('price_inp0').value!="0 руб." && document.getElementById('price_inp0').value!="" && document.getElementById('price_inp0').value!=" ") {
		for (ip=0; ip<n_price; ip++) document.getElementById('price_div'+ip).style.display="block";
	} else {
		for (ip=0; ip<n_price; ip++) document.getElementById('price_div'+ip).style.display="none";
	}
}


function printorder() {
	c1=getRadioGroupValue(document.shop.step2_teplo);
	c2=getRadioGroupValue(document.shop.step2_tishina);
	c3=getRadioGroupValue(document.shop.step2_krasota);
	kompl_var=c1+c2*3+c3*9;

	text1='';
	for (i=1; i<=n_compl; i++) text1+='<br />'+kompl_name[i-1]+': '+komplektaciya[kompl_var][3+i];

	text2='<br />Дополнительные аксессуары: ';
	for (id=1; id<=n_access; id++) {
		if (document.getElementById) itm_1 = document.getElementById('dop_aks'+id);
		if (itm_1.style.backgroundColor=="rgb(187, 225, 202)" || itm_1.style.backgroundColor=="#bbe1ca")
			text2+='<br />'+dop_aks_name[id-1];
	}
	
	text3='';
	for (id=1; id<=n_options; id++) {
		if (document.getElementById) itm_1 = document.getElementById('opc'+id);
		if (itm_1.style.backgroundPosition=="0px -155px")
			text3+='<br />Услуга 1: '+uslugi1_name[id-1];
	}
	
	text4='';
	for (id=1; id<=n_service; id++) {
		if (document.getElementById) itm_1 = document.getElementById('usluga_'+id);
		if (itm_1.style.backgroundPosition=="0px -19px")
			text4+='<br />Услуга 2: '+uslugi2_name[id-1];
	}

	text5='';
	for (id=1; id<=n_discount; id++ ){
		if (document.getElementById) itm_1 = document.getElementById('discount_checkb'+id);
		if (itm_1.style.backgroundPosition=="0px -19px")
			text5+='<br />Скидка: '+discount_name[id-1];
	}
	
	var c11=c22=c33='';
	++c1; ++c2; ++c3;
	if (c1==1) c11='не важно'; else if (c1==2) c11='важно'; else if (c1==3) c11='очень важно';
	if (c2==1) c22='не важно'; else if (c2==2) c22='важно'; else if (c2==3) c22='очень важно';
	if (c3==1) c33='не важно'; else if (c3==2) c33='важно'; else if (c3==3) c33='очень важно';
	
	text='<strong>Коммерческое предложение от Окна ЧЕСМЫ</strong><br />'+'<strong>Ваш уникальный ID № '+document.getElementById('id_order').value+'</strong><br />'+'<br />Серия дома: ' + document.getElementById('step1_info11').innerHTML +
	'<br />Кол-во комнат: ' + document.getElementById('step1_info12').innerHTML +
	'<br />Тепло: ' + c11 + 
	'<br />Тишина: ' + c22 + 
	'<br />Красота: ' + c33 + '<br />' + text1 + text2 + text3 + text4 + text5
	+'<br /><br /><a href="#" onclick="javascript: window.print();">Печать</a>';
	new_window=window.open('http://www.oknachesma.ru/mgr_print_order.php','','_blank, width=600, height=600');
	new_window.document.writeln(text);
}


function check_forms(a) {
	if(a==1){
		if	((document.getElementById('user_name').value=='') ||
			(document.getElementById('user_telephone').value=='') ||
			(document.getElementById('user_message').value=='') ||
			!(/^(\+?[1-9][0-9]{0,2}(\s|-)?((\(|\s)?[1-9][0-9]{0,4}(\)|\s)?))?(\s|-)?([1-9][0-9]{2}(\s|-)?[0-9]{2}(\s|-)?[0-9]{0,2})$/).test(document.getElementById('user_telephone').value)) {
				alert('Введите корректные данные у обязательных полей, помеченных звездочкой "*"'); return false;
			} else return true;
	}
	else if(a==2){
		if	((document.getElementById('user_name').value=='') ||
			(document.getElementById('user_telephone').value=='') ||
			(document.getElementById('user_message').value=='') ||
			(document.getElementById('user_adress').value=='') ||
			(document.getElementById('user_time').value=='') ||
			!(/^(\+?[1-9][0-9]{0,2}(\s|-)?((\(|\s)?[1-9][0-9]{0,4}(\)|\s)?))?(\s|-)?([1-9][0-9]{2}(\s|-)?[0-9]{2}(\s|-)?[0-9]{0,2})$/).test(document.getElementById('user_telephone').value)) {
				alert('Введите корректные данные у обязательных полей, помеченных звездочкой "*"'); return false;
			} else return true;
	}
	else if(a==3){
		if	((document.getElementById('user_name').value=='') ||
			(document.getElementById('user_telephone').value=='') ||
			(document.getElementById('user_message').value=='') ||
			!(/^(\+?[1-9][0-9]{0,2}(\s|-)?((\(|\s)?[1-9][0-9]{0,4}(\)|\s)?))?(\s|-)?([1-9][0-9]{2}(\s|-)?[0-9]{2}(\s|-)?[0-9]{0,2})$/).test(document.getElementById('user_telephone').value)) {
				alert('НВведите корректные данные у обязательных полей, помеченных звездочкой "*"'); return false;
			} else return true;
	}
	else if(a==4){
		document.getElementById('seria_doma').value = document.getElementById('step1_info11').innerHTML;
		document.getElementById('kolvo_kvar').value = document.getElementById('step1_info12').innerHTML;
		document.getElementById('order_price').value = document.getElementById('price_inp2').value;
		document.getElementById('commerch_content_input').value = document.getElementById('commerch_content').innerHTML;

		if (document.getElementById('user_email').value.length > 0){
			if ( !isValidEmail(document.getElementById('user_email').value, true) ||
			(document.getElementById('user_email').value.length < 6) ) {
				alert ('Введите корректный e-mail!'); return false;
			}
		}

	document.getElementById('dop_aksess').value='';
	for (id=1; id<=n_access; id++) {
		if (document.getElementById) itm_1 = document.getElementById('dop_aks'+id); 
		if (itm_1.style.backgroundColor=="rgb(187, 225, 202)" || itm_1.style.backgroundColor=="#bbe1ca") document.getElementById('dop_aksess').value+=id+",";
	}
	document.getElementById('uslugi1').value='';
	for (id=1; id<=n_options; id++) {
		if (document.getElementById) itm_1 = document.getElementById('opc'+id);
		if (itm_1.style.backgroundPosition=="0px -155px") document.getElementById('uslugi1').value+=id+",";
	}
	document.getElementById('uslugi2').value='';
	for (id=1; id<=n_service; id++) {
		if (document.getElementById) itm_1 = document.getElementById('usluga_'+id);
		if (itm_1.style.backgroundPosition=="0px -19px") document.getElementById('uslugi2').value+=id+",";
	}
	document.getElementById('discount').value='';
	for (id=1; id<=n_discount; id++) {
		if (document.getElementById) itm_1 = document.getElementById('discount_checkb'+id);
		if (itm_1.style.backgroundPosition=="0px -19px") document.getElementById('discount').value+=id+",";
	}
	
	if (document.getElementById('seria_doma').value=="" || document.getElementById('kolvo_kvar').value==""){
		alert('Не выбрана серия дома или кол-во квартир. Проверьте данные на 1-ом шаге магазина готовых решений!');
		hide_order_form();
		gotostep(1);
		return false;
	}
	
	if ( 
		(document.getElementById('user_name').value=='') ||
		(document.getElementById('user_telephone').value=='') ||
		(document.getElementById('user_name').value.length<2) ||
		(document.getElementById('user_telephone').value.length<7) 
	) {
		if (
		(document.getElementById('user_name').value=='') ||
		(document.getElementById('user_name').value.length<2)
		)
			document.getElementById('user_name').style.backgroundColor='#f66';
		if (
		(document.getElementById('user_telephone').value=='') ||
		(document.getElementById('user_telephone').value.length<7) ||
		!(/^(\+?[1-9][0-9]{0,2}(\s|-)?((\(|\s)?[1-9][0-9]{0,4}(\)|\s)?))?(\s|-)?([1-9][0-9]{2}(\s|-)?[0-9]{2}(\s|-)?[0-9]{0,2})$/).test(document.getElementById('user_telephone').value)
		)
			document.getElementById('user_telephone').style.backgroundColor='#f66';
		
		alert('Введите корректные данные у обязательных полей, помеченных звездочкой "*"');
		return false;
	}
	else {
		if (document.getElementById('print_mode').value==1) printorder();
		return true;
	}

	}
}

function isValidEmail (email, strict) {
	if ( !strict ) email = email.replace(/^\s+|\s+$/g, '');
	return (/^([a-z0-9_\-]+\.)*[a-z0-9_\-]+@([a-z0-9][a-z0-9\-]*[a-z0-9]\.)+[a-z]{2,4}$/i).test(email);
}

function show_order_form(pm) {
	document.getElementById('order_form').style.visibility='visible';
	document.getElementById('print_mode').value=pm;
	document.getElementById('id_strong').innerHTML='Уникальный ID Вашего решения: <strong>'+document.getElementById('id_order').value+'</strong>';
}
function hide_order_form() {
	document.getElementById('order_form').style.visibility='hidden';
	document.getElementById('print_mode').value=0;
}


function gotostep(id1) { if (id1 != '') expMenu(id1); }
function expMenu(id2) {
	var itm1 = itm2 = itm3 = itm_1 = itm_2 = itm_3 = null;
	itm1='step_title';
	itm2='step';
	itm3='step3_1';
	itm4='step3_2';
	itm5='step3_3';
	itm6='step3_4';
	Scroll.to(window,{'x':0,'y':240},500);

	if (document.getElementById('price_inp0').value!=" руб." && document.getElementById('price_inp0').value!="0 руб." && document.getElementById('price_inp0').value!="" && document.getElementById('price_inp0').value!=" ") {
		for (ip=0; ip<n_price; ip++) document.getElementById('price_div'+ip).style.display="block";
	} else {
		for (ip=0; ip<n_price; ip++) document.getElementById('price_div'+ip).style.display="none";
	}
	
	switch(id2){
		case 1:
			itm_1 = document.getElementById(itm1+1);
			itm_1.style.backgroundPosition = "0 0";
			itm_1 = document.getElementById(itm1+2);
			itm_1.style.backgroundPosition = "0 0";
			itm_1 = document.getElementById(itm1+3);
			itm_1.style.backgroundPosition = "0 0";
		 	document.getElementById('step2_info13').innerHTML='';//XX окна
		 	document.getElementById('left_block_picture').style.backgroundImage='url(/template/images/step1_left_block_bg.jpg)';
		break;
		case 2:
			itm_1 = document.getElementById(itm1+1);
			itm_1.style.backgroundPosition = "0 -32px";
			itm_1 = document.getElementById(itm1+2);
			itm_1.style.backgroundPosition = "0 -32px";
			itm_1 = document.getElementById(itm1+3);
			itm_1.style.backgroundPosition = "0 -32px";
		 	document.getElementById('step2_info13').innerHTML='';//XX окна
		 	document.getElementById('left_block_picture').style.backgroundImage='url(/template/images/step2_left_block_bg.jpg)';
			kompl_change(0);
			ajaxLoad2('id_order', '/mgr_ajax2.php?c1='+document.getElementById('c1').value+'&c2='+document.getElementById('c2').value+'&c3='+document.getElementById('c3').value+'&id_order='+document.getElementById('id_order').value, '','','');
		break;
		case 3:
			itm_1 = document.getElementById(itm1+1);
			itm_1.style.backgroundPosition = "0 -64px";
			itm_1 = document.getElementById(itm1+2);
			itm_1.style.backgroundPosition = "0 -64px";
			itm_1 = document.getElementById(itm1+3);
			itm_1.style.backgroundPosition = "0 -64px";
		 	document.getElementById('step2_info13').innerHTML='';//XX окна
		 	document.getElementById('left_block_picture').style.backgroundImage='url(/template/images/step3_left_block_bg.jpg)';
			ajaxLoad('price_inp', '/mgr_ajax.php?c1='+document.getElementById('c1').value+'&c2='+document.getElementById('c2').value+'&c3='+document.getElementById('c3').value, '','','');
			ajaxLoad2('id_order', '/mgr_ajax2.php?c1='+document.getElementById('c1').value+'&c2='+document.getElementById('c2').value+'&c3='+document.getElementById('c3').value+'&id_order='+document.getElementById('id_order').value, '','','');

			c1=getRadioGroupValue(document.shop.step2_teplo);
			c2=getRadioGroupValue(document.shop.step2_tishina);
			c3=getRadioGroupValue(document.shop.step2_krasota);
			kompl_var=c1+c2*3+c3*9;
		
			text='';
			for (i=1; i<=7; i++) text+='<br />'+kompl_name[i-1]+': '+komplektaciya[kompl_var][3+i]; 
			
			var c11=c22=c33='';
			++c1; ++c2; ++c3;
			if (c1==1) c11='не важно'; else if (c1==2) c11='важно'; else if (c1==3) c11='очень важно';
			if (c2==1) c22='не важно'; else if (c2==2) c22='важно'; else if (c2==3) c22='очень важно';
			if (c3==1) c33='не важно'; else if (c3==2) c33='важно'; else if (c3==3) c33='очень важно';
			
			document.getElementById('commerch_content').innerHTML='<strong>Коммерческое предложение от Окна ЧЕСМЫ</strong><br />'+'<strong>Ваш уникальный ID № '+document.getElementById('id_order').value+'</strong><br />';
			document.getElementById('commerch_content').innerHTML+=
			'<br />Серия дома: ' + document.getElementById('step1_info11').innerHTML +
			'<br />Кол-во комнат: ' + document.getElementById('step1_info12').innerHTML +
			'<br />Тепло: ' + c11 + 
			'<br />Тишина: ' + c22 + 
			'<br />Красота: ' + c33 + '<br />' + text ;
		break;
	}

	for (i=1; i<=3; i++){
		if (document.getElementById) itm_2 = document.getElementById(itm2+i);
		if (i==id2) itm_2.style.display = ""; 
		else itm_2.style.display = "none";
	}

	if (document.getElementById) {
		itm_3 = document.getElementById(itm3);
		itm_4 = document.getElementById(itm4);
		itm_5 = document.getElementById(itm5);
		itm_6 = document.getElementById(itm6);
	}
	if (id2==3) { itm_3.style.display = ""; }
	else { itm_3.style.display = "none"; }
	if (id2==3) { itm_4.style.display = ""; }
	else { itm_4.style.display = "none"; }
	if (id2==3) { itm_5.style.display = ""; }
	else { itm_5.style.display = "none"; }
	if (id2==3) { itm_6.style.display = ""; }
	else { itm_6.style.display = "none"; }
}


function td_green_blue(id){
	document.getElementById('c1').value=id-1;
	ajaxLoad('price_inp', '/mgr_ajax.php?c1='+document.getElementById('c1').value+'&c2='+document.getElementById('c2').value+'&c3='+document.getElementById('c3').value, '','','');
	
	document.getElementById('td_dom_seria_okno').innerHTML='&nbsp;';
	document.getElementById('kolvo_okon').value=0;
	if (document.getElementById('c1').value!="" && document.getElementById('c2').value!="") {
		t1=parseInt(document.getElementById('c1').value);
		t2=parseInt(document.getElementById('c2').value);
		for (i=2; i<=7; i++)
			for (j=1; j<=dom_seria_okno[t1*6+t2][i]; j++) {
				document.getElementById('td_dom_seria_okno').innerHTML+='<img src="/template/images/window_type_'+(i-1)+'.jpg" />&nbsp;';
				document.getElementById('kolvo_okon').value=parseInt(document.getElementById('kolvo_okon').value)+1;
			}
	}
	
	var id_td = null;
	switch(id){
		case 1: document.getElementById('step1_info11').innerHTML=document.getElementById('step1_info21').innerHTML=document.getElementById('step2_info11').innerHTML='137 серия'; break;
		case 2: document.getElementById('step1_info11').innerHTML=document.getElementById('step1_info21').innerHTML=document.getElementById('step2_info11').innerHTML='504 серия'; break;
		case 3: document.getElementById('step1_info11').innerHTML=document.getElementById('step1_info21').innerHTML=document.getElementById('step2_info11').innerHTML='504 (Д) 505серия'; break;
		case 4: document.getElementById('step1_info11').innerHTML=document.getElementById('step1_info21').innerHTML=document.getElementById('step2_info11').innerHTML='606 серия'; break;
		case 5: document.getElementById('step1_info11').innerHTML=document.getElementById('step1_info21').innerHTML=document.getElementById('step2_info11').innerHTML='Хрущевки (панель)'; break;
		case 6: document.getElementById('step1_info11').innerHTML=document.getElementById('step1_info21').innerHTML=document.getElementById('step2_info11').innerHTML='Хрущевки (кирпич)'; break;
		case 7: document.getElementById('step1_info11').innerHTML=document.getElementById('step1_info21').innerHTML=document.getElementById('step2_info11').innerHTML='Корабли 1600 ЛГ (600)'; break;
		case 8: document.getElementById('step1_info11').innerHTML=document.getElementById('step1_info21').innerHTML=document.getElementById('step2_info11').innerHTML='Корабли (Г-обр)'; break;
		case 9: document.getElementById('step1_info11').innerHTML=document.getElementById('step1_info21').innerHTML=document.getElementById('step2_info11').innerHTML='Кирпичные дома'; break;
		case 10:document.getElementById('step1_info11').innerHTML=document.getElementById('step1_info21').innerHTML=document.getElementById('step2_info11').innerHTML='Старый фонд'; break;
	}

	if (document.getElementById) {
		for (i=1; i<=n_house_type; i++) {
			id_td = document.getElementById('td_green_blue_'+i);
			if (i==id) id_td.style.backgroundColor='#1063a5';
			else id_td.style.backgroundColor='#0bb33a';
		}
	}
	return true;
}


function kv_type(id){
	document.getElementById('c2').value=id-1;
	ajaxLoad('price_inp', '/mgr_ajax.php?c1='+document.getElementById('c1').value+'&c2='+document.getElementById('c2').value+'&c3='+document.getElementById('c3').value, '','','');
	
	document.getElementById('td_dom_seria_okno').innerHTML='&nbsp;';
	document.getElementById('kolvo_okon').value=0;
	if (document.getElementById('c1').value!="" && document.getElementById('c2').value!="") {
		t1=parseInt(document.getElementById('c1').value);
		t2=parseInt(document.getElementById('c2').value);
		for (i=2; i<7; i++)
			for (j=1; j<=dom_seria_okno[t1*6+t2][i]; j++){
				document.getElementById('td_dom_seria_okno').innerHTML+='<img src="/template/images/window_type_'+(i-1)+'.jpg" />&nbsp;';
				if (i==5 || i==6) document.getElementById('kolvo_okon').value=parseInt(document.getElementById('kolvo_okon').value)+2;
				else document.getElementById('kolvo_okon').value=parseInt(document.getElementById('kolvo_okon').value)+1;
			}
	}
	
	var id_kv = null;
	switch(id){
		case 1: document.getElementById('step1_info12').innerHTML=document.getElementById('step1_info22').innerHTML=document.getElementById('step2_info12').innerHTML='1-комнатная квартира'; break;
		case 2: document.getElementById('step1_info12').innerHTML=document.getElementById('step1_info22').innerHTML=document.getElementById('step2_info12').innerHTML='2-комнатная квартира'; break;
		case 3: document.getElementById('step1_info12').innerHTML=document.getElementById('step1_info22').innerHTML=document.getElementById('step2_info12').innerHTML='3-комнатная квартира'; break;
		case 4: document.getElementById('step1_info12').innerHTML=document.getElementById('step1_info22').innerHTML=document.getElementById('step2_info12').innerHTML='4-комнатная квартира'; break;
		case 5: document.getElementById('step1_info12').innerHTML=document.getElementById('step1_info22').innerHTML=document.getElementById('step2_info12').innerHTML='5-комнатная квартира'; break;
		case 6: document.getElementById('step1_info12').innerHTML=document.getElementById('step1_info22').innerHTML=document.getElementById('step2_info12').innerHTML='6-комнатная квартира'; break;
	}

	if (document.getElementById) {
		for (i=1; i<=n_plan_type; i++){
			id_kv = document.getElementById('kv_'+i);
			if (i==id) id_kv.style.fontWeight='bold';
			else id_kv.style.fontWeight='normal';
		}
	}
	return true;
}


function replace_string(txt,cut_str,paste_str){
	var f=0; var ht='';
	ht = ht + txt;
	f=ht.indexOf(cut_str);
	while (f!=-1){
		f=ht.indexOf(cut_str);
		if (f>0){
			ht = ht.substr(0,f) + paste_str + ht.substr(f+cut_str.length);
		};
	};
	return ht;
};
