			function calc_auto()	{			if ((select_pid = $('#pids').val()) != '-1' 			&& (select_day = parseInt($('#days').val()))			&& (select_day > '1')			&& (select_region = $('#region').val()) != '-1' 			&& (select_limit = $('#limit').val()))		{			summ  = 0;			for (range in costs[select_pid])			{				m = range.split(/-/);					if (m[0] <= select_day && m[1] >= select_day)				{					summ += parseInt(costs[select_pid][range]) * select_day;				}			}						summ += parseInt(select_region);			summ += parseInt(select_limit) * select_day;						$('div#arend span').html(number_format(summ, 0, '.', ' '));						if($('#moskow').val() == '1')			{				if(select_region > 0)					$('div#zalog span').html(number_format(bails_col[select_pid], 0, '.', ' '));				else					$('div#zalog span').html(number_format(bails_nom[select_pid], 0, '.', ' '));							}			else			{				if(select_region > 0)					$('div#zalog span').html(number_format(bails_nom[select_pid], 0, '.', ' '));								else					$('div#zalog span').html(number_format(bails[select_pid], 0, '.', ' '));							}						$('#zakaz_calc').attr('class', 'zakaz_a_selected');		}		else		{			$('div#arend span').html('0');			$('div#zalog span').html('0');			$('#zakaz_calc').attr('class', 'zakaz_a');		}				if((seld = parseInt($('#days').val())) && (seld <= '1'))			alert('Минимальный срок аренды автомобиля -  2 дня');	}	function save_cost(_cst, _zlgn, select_pid, select_region, select_limit)	{		$.get("/main_res/ajax/init.php",			{				module: 'db_pg_shop',				func: 'save_cost_to_globals',				out: 'text',				xcost: _cst,				xzal: _zlgn						},			function (data) {				if (data == 'ok')				{					window.location = '/shop/reserv/' + select_pid + '/' + parseInt(select_region) + '/' + parseInt(select_limit) + '/';				}						}		);	}		function redirect_to_auto()	{		if ((select_pid = $('#pids').val()) != '-1' 			&& (select_day = parseInt($('#days').val())) 			&& (select_region = $('#region').val()) != '-1' 			&& (select_limit = $('#limit').val()))			{				var ar = $('div#arend span').html();				var zl = $('div#zalog span').html();				save_cost(ar, zl, select_pid, select_region, select_limit);			}		else			alert('Не заполнены все поля');	}		function select_auto()	{		if ((select_cost = parseInt($('#cost_s').val())) 			&& (select_region = $('#regionb_s').val()) != '-1' 			&& (kp = parseInt($('#kpp').val())) != '-1')		{			$('#zakaz_select').attr('class', 'zakaz_a_selected');		}		else		{			$('#zakaz_select').attr('class', 'zakaz_a');		}	}		function redirect_to_select()	{		if ((select_cost = parseInt($('#cost_s').val())) 			&& (select_region = $('#regionb_s').val()) != '-1'			&& (kp = parseInt($('#kpp').val())) != '-1')		{			window.location = '/shop/' + select_cost + '/' + select_region + '/' + parseInt($('#limitb_s').val()) + '/' + kp + '/';		}		else		{			alert('Не заполнены все поля');		}	}		function number_format(number, decimals, dec_point, thousands_sep) 	{		//		// +   original by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)		// +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)		// +     bugfix by: Michael White (http://crestidg.com)		var i, j, kw, kd, km;		// input sanitation & defaults		if( isNaN(decimals = Math.abs(decimals)) ){			decimals = 2;		}		if( dec_point == undefined ){			dec_point = ",";		}		if( thousands_sep == undefined ){			thousands_sep = ".";		}		i = parseInt(number = (+number || 0).toFixed(decimals)) + "";		if( (j = i.length) > 3 ){			j = j % 3;		} else{			j = 0;		}		km = (j ? i.substr(0, j) + thousands_sep : "");		kw = i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thousands_sep);		//kd = (decimals ? dec_point + Math.abs(number - i).toFixed(decimals).slice(2) : "");		kd = (decimals ? dec_point + Math.abs(number - i).toFixed(decimals).replace(/-/, 0).slice(2) : "");		return km + kw + kd;	}
