//акция для евросети
function show_action() {
	document.getElementById('actiontext').style.display = 'block';
}
function hide_action() {
	document.getElementById('actiontext').style.display = 'none';
}

function chTable() {
	if (document.getElementById('boxGPRS').style.display == 'block') {
		document.getElementById('boxGPRS').style.display = 'none';
		document.getElementById('boxPrice').style.display = 'block';
	} else {
		document.getElementById('boxGPRS').style.display = 'block';
		document.getElementById('boxPrice').style.display = 'none';
	}
}

function select_tariff(obj) {
	var data = tariff_data[obj.value];

	document.getElementById('st_in').innerHTML = '<strong>' + data[0] + '</strong>';
	document.getElementById('st_out').innerHTML = data[1];
	document.getElementById('mts_in').innerHTML = data[2];
	document.getElementById('mts_out').innerHTML = data[3];
	document.getElementById('mf_in').innerHTML = data[4];
	document.getElementById('mf_out').innerHTML = data[5];
	document.getElementById('bl_in').innerHTML = data[6];
	document.getElementById('bl_out').innerHTML = data[7];
}

function select_gprs(obj) {
	var html = '<table class="price"><tr><td colspan="2" class="price_td">Price (1 $/1 Мb)</td></tr>';
	for (i = 0; i < gprs_data[obj.value].length; i++) {
		html += '<tr><td class="comp"><strong>' + gprs_data[obj.value][i][0] + '</strong></td><td class="inn">' + gprs_data[obj.value][i][1] + '</td></tr><tr class="hr"><td colspan="2"></td></tr>';
	}
	html += '</table>'
	document.getElementById('gprs_place').innerHTML = html;
}

function open_map(id) {
	var w = 310;
	var h = 330;
	window.open('/buy/point/' + id + '/', '_blank', 'top=' + ((screen.availHeight / 2) - (h / 2)) + 'px, left=' + ((screen.availWidth / 2) - (w / 2)) + 'px, width=' + w + ', height=' + h + ', directories=no, location=no, menubar=no, resizable=no, scrollbars=no, status=no, toolbar=no');
}

function update_region() {
	r_id = form.regions_select.value;
	if (form.city_select.length > 0) {
		while (form.city_select.length > 0) {
			form.city_select.options[0] = null;
		}
	}
	for (i = 0; i < citys_data[r_id].length; i++) {
		form.city_select.options[i] = new Option(citys_data[r_id][i][1], citys_data[r_id][i][0]);
	}
	update_city();
}

function update_city() {
	c_id = form.city_select.value;
	if (c_id == 19) {
		document.getElementById('district_text').innerHTML = 'Choose closest subway station:';
	} else {
		document.getElementById('district_text').innerHTML = 'Select district:';
	}
	// разные валюты для городов
	if (c_id == 18) {
		document.getElementById('ten').innerHTML = '<img src="/img/icon/ten.gif" /><label> - SIMTRAVEL with deposit  10 $ (890 RUB)</label>	';
		document.getElementById('fifty').innerHTML = '<img src="/img/icon/icon_fifty.gif" /><label> - SIMTRAVEL with deposit  50 $ (2100 RUB)</label>';
	}
	if (c_id == 19) {
		document.getElementById('ten').innerHTML = '<img src="/img/icon/ten.gif" /><label> - SIMTRAVEL with deposit  10 $ (890 RUB)</label>	';
		document.getElementById('fifty').innerHTML = '<img src="/img/icon/icon_fifty.gif" /><label> - SIMTRAVEL with deposit  50 $ (2100 RUB)</label>';
	}
	if (c_id == 432) {
		document.getElementById('ten').innerHTML = '<img src="/img/icon/ten.gif" /><label> - SIMTRAVEL with deposit  10 $ (200 GRN)</label>	';
		document.getElementById('fifty').innerHTML = '';
	}
	if (c_id == 433) {
		document.getElementById('ten').innerHTML = '<img src="/img/icon/ten.gif" /><label> - SIMTRAVEL with deposit  10 $ (16 LVL)</label>	';
		document.getElementById('fifty').innerHTML = '<img src="/img/icon/one.gif" /><label> - SIMTRAVEL with deposit  1$ (11 LVL)</label>';
	}
	
	if (c_id == 434) {
		document.getElementById('ten').innerHTML = '<img src="/img/icon/ten.gif" /><label> - SIMTRAVEL with deposit  10 $ (29 USD)</label>	';
		document.getElementById('fifty').innerHTML = '';
	}
	
	//	
	
	if (form.district_select.length > 0) {
		while (form.district_select.length > 0) {
			form.district_select.options[0] = null;
		}
	}
	
	for (i = 0; i < districts_data[c_id].length; i++) {
		form.district_select.options[i] = new Option(districts_data[c_id][i][1], districts_data[c_id][i][0]);
	}
	
	update_district();

	var html = '';
	if (shops_data[c_id]) {
		html += '<table width="100%" border="0" cellspacing="0" cellpadding="0" class="logo_table">';
		for (i = 0; i < shops_data[c_id].length; false) {
			html += '<tr>';
			for (u = 0; u < 3; u++) {
				if (shops_data[c_id][i]) {
					var logo_id = shops_data[c_id][i];
						
						html += '<td><img src="/img/shop_logos/' + logo_id + '.gif" alt="' + citys_data[logo_id] + '" width="104" height="26"></td>';
				} else {
					html += '<td>&nbsp;</td>';
				}
				i++;
			}
			html += '</tr>';
		}
		html += '</table>';
	}
	document.getElementById('cityLogosPlace').innerHTML = html;
	
	
	
	if (districts_data[c_id].length == 1) {
		document.getElementById('districtSlect').style.display = 'none';
	} else {
		document.getElementById('districtSlect').style.display = '';
	}
	//var html2 = '';
	//document.getElementById('icon').innerHTML = html2;
}

function update_district() {
	points_place.innerHTML = '<p>Wait...</p>';
	
	// map_point.style.display = 'none';

	r_id = form.regions_select.value;
	c_id = form.city_select.value;
	d_id = form.district_select.value;
	var url = '/js/ajax_answer.php';
	var pars = 'op=get_points&regions_id=' + r_id + '&city_id=' + c_id + '&district_id=' + d_id;
	var myAjax = new Ajax.Request(url, {method: 'get', parameters: pars, onComplete: update_district_result});

}
function update_district_result(originalRequest) {
	points_place.innerHTML = originalRequest.responseText;
}

function update_map(src, href) {
	if (src == '' || href == '') {
		// alert('Карта к данной точке продаж отсутствует.');
		map_point.style.display = 'none';
	} else {
		var html = '<iframe width="290" height="300" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="' + src + '"></iframe><br /><small><a href="' + href + '" style="color:#0000FF;text-align:left">Просмотреть увеличенную карту</a></small>';
		map_point.style.display = '';
		map_point.innerHTML = html;
	}
}
