//акция для евросети

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('st2_in').innerHTML = data[2];

	document.getElementById('st2_out').innerHTML = data[3];

	document.getElementById('mts_in').innerHTML = data[4];

	document.getElementById('mts_out').innerHTML = data[5];

	document.getElementById('mf_in').innerHTML = data[6];

	document.getElementById('mf_out').innerHTML = data[7];

	document.getElementById('bl_in').innerHTML = data[8];

	document.getElementById('bl_out').innerHTML = data[9];

}









function select_gprs(obj) {

	var html = '<table class="price"><tr><td colspan="2" class="price_td">Цена (у.е./100 Kb)</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() {

	form = document.getElementById('placeform'); //а если много форм? 

	formid = 'placeform';

	c_id = document.getElementById(formid).city_select.value; 	

	//alert('123');

	//c_id = form.city_select.value; 	

	
if(document.getElementById('aboutdostavka')) {
    if(c_id==18 || c_id==19)
    {
        document.getElementById('aboutdostavka').style.display='block';
    }
    else     {
        document.getElementById('aboutdostavka').style.display='none';
    }
}

	

	

	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]);

	}

	

	if (districts_data[c_id].length == 1) {

		document.getElementById('districtSlect').style.display = 'none';

	} else {

		document.getElementById('districtSlect').style.display = '';

	}

	

	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];

					//выделяем из массива чаcть с альтом = до || и часть с хрефом - после ||

					var fullstr = citys_data[logo_id];

					var pos = fullstr.indexOf("||");

					var alt = fullstr.substring(0, pos);

					pos2= pos + 2;

					var href = fullstr.substring(pos2);
//alert(logo_id);
							if (href) {html += '<td><noindex><a rel="nofollow" href="' + href + '"><img src="/img/shop_logos/' + logo_id + '.gif" alt="" width="114" height="46"></a></noindex><p class="podpis">' + alt + '</p></td>';}

							else {html += '<td><img src="/img/shop_logos/' + logo_id + '.gif" alt="" width="114" height="46"><p class="podpis">' + alt + '</p></td>';}

						

				} else {

					html += '<td>&nbsp;</td>';

				}

				i++;

			}

			html += '</tr>';

		}

		html += '</table>';

	}

	document.getElementById('cityLogosPlace').innerHTML = html;

	



}



function update_district() {

	points_place = document.getElementById('points_list');

	form = document.getElementById('placeform');

	small = form.smallform.value;

	if(small != '1') small = '0';



	points_place.innerHTML = '<p>Загрузка</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 = 'small=' + small + '&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 = document.getElementById('points_list');

	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;

	}

}





//////////////////

function chsim() {

	if (document.getElementById('sim2').style.display == 'none') {

		document.getElementById('sim1').style.display = 'none';

		document.getElementById('sim2').style.display = 'block';

	} else {

		document.getElementById('sim1').style.display = 'block';

		document.getElementById('sim2').style.display = 'none';

	}

}
