
function calc1() {
	var p=0;
	var num=0;
	var is_ergo=1;
	// calc style
	p+=parseFloat($("input[name='style']:checked").val());
	// site type
	var p_site=parseFloat($("input[name='type']:checked").val());
	p+=p_site;
	// cms type
	var cms_p=parseInt($("input[name='cms']:checked").val());
	if (cms_p) {
		// ergo		
	 	p+=cms_p;
	} else {
		// bitrix
		is_ergo=0;
		// portal or shop or catalog selected
		if ($("input[id='st_2']:checked").length || $("input[id='st_3']:checked").length || $("input[id='fn_8']:checked").length) p+=720; 
		else p+=620;
	}
	// flash
	p+=calc_price_2('flash_1', true);
	p+=calc_price_2('flash_2', true);
	// store price and calc only options price (used in language versions)
	var p_old=p;
	p=0;
	// forms
	p+=calc_price_1(1, 37.5, 18.75);
	// news
	p+=calc_price_1(2, 80, 40);
	// articles
	p+=calc_price_1(3, 80, 40);
	// poll
	p+=calc_price_2(4);
	// search
	if (parseInt($("input[name='fn_5']:checked").val())) {
		if (is_ergo) p+=86; else p+=80;
	}
	// subscription
	p+=calc_price_2(6);
	// secured zone
	p+=calc_price_2(7);
	// catalog options
	var has_catalog=0;
	if ($("input[id='fn_8']:checked").length) has_catalog=1;
	if (has_catalog) {
		// catalog
		p+=calc_price_2(8);
		// many levels
		p+=calc_price_2(9);
		// 1C
		p+=calc_price_2(10);
		// import/export
		p+=calc_price_2(11);
		// comments
		p+=calc_price_2(12);
		// order
		p+=calc_price_2(13);
		// number of positions
		catalog_amount=parseInt($("#fn_13_num").val());
	}
	// ishop
	var has_ishop=0;
	if ($("input[id='fn_14']:checked").length) has_ishop=1;
	if (has_ishop) {
		// ishop
		p+=calc_price_2(14);
		// relative
		p+=calc_price_2(15);
		// many levels
		p+=calc_price_2(16);
		// leaders
		p+=calc_price_2(17);
		// history
		p+=calc_price_2(18);
		// ratings
		p+=calc_price_2(19);
		// import/export
		p+=calc_price_2(20);
		// order
		p+=calc_price_2(21);
		// 1C
		p+=calc_price_2(22);
	}
	// gallery
	p+=calc_price_2(23);
	// forum
	p+=calc_price_2(24);
	// plans
	p+=calc_price_1(25, 377.5, 188.75);
	// map
	p+=calc_price_2(26);
	// restore and sum price
	var p_options=p;
	p+=p_old;
	// catalog content (only active if catalog selected)
	var do_content_catalog=0;
	if (parseInt($("input[name='fn_27']:checked").val()) && has_catalog) do_content_catalog=1;
	if (do_content_catalog) {
		// for each catalog item
		p+=5.35*catalog_amount;
		// simple 
		p+=calc_price_2(28)*catalog_amount;
		//complex
		p+=calc_price_2(29)*catalog_amount;
	}
	// rus text
	p+=calc_price_3(31, 11.5);
	// en text
	p+=calc_price_3(32, 14);
	// processing simple
	p+=calc_price_1(33, 1.8, 1.8);
	// processing complex
	p+=calc_price_1(34, 18.7, 18.7);
	// buy photos
	p+=calc_price_1(35, 4, 4);
	// 3d
	p+=calc_price_1(36, 449.5, 449.5);
	// collage
	p+=calc_price_1(37, 597, 597);
	// painiting
	p+=calc_price_1(38, 598.4, 598.4);
	// languages
	var lang_num=$("#fn_39_num").val();
	if (!lang_num) lang_num=1;
	p+=(lang_num-1)*(p_site + p_options)/2;
	$("#result_price").val(p);
				 
}

// price depends on amount (forms, articles etc)
function calc_price_1(input_id, price1, price2) {
	var p=0;
	if ($("input[name='fn_" + input_id + "']:checked").val()) {
		num=parseInt($("#fn_" + input_id + "_num").val());
		if (num) p+=1*price1 + (num-1)*price2;
	}
	return p;
}

// get price for checkbox field
function calc_price_2(input_id, is_full_name) {
	var p=0;
	if (is_full_name) p=parseFloat($("input[name='" + input_id + "']:checked").val());
	else p=parseFloat($("input[name='fn_" + input_id + "']:checked").val());
	if (!p) p=0;
	return p;
}

// price depends on amount (language x 1000)
function calc_price_3(input_id, price) {
	var p=0;
	if ($("input[name='fn_" + input_id + "']:checked").val()) {
		num=parseInt($("#fn_" + input_id + "_num").val());
		if (num) p+=(num/1000)*price;
	}
	return p;
}
