$(document).ready(function() {

//$('#left_header_color').css('width',$(this).parent().css('width')-6);
$('#left_header_color').css('height', $('#left_header_color').parent().height()-9);


$('#geo-select').change(function(){
  $('.geo-banner').hide();
  $('#c'+$(this).val()).show();

//$('#geo-select-down').attr("selectedIndex",$(this).attr("selectedIndex"));
//$('#geo-select-down').change();

  return false;
})

$('#geo-select').change();

	var city_new = {  '28257': [ 'Санкт-Петербург', '105', '2', '78', '1'], '28263':  ['Воронеж', '145', '19', '100', '16'], '28264' : ['Москва', '121', '12', '84', '14'], '28326' : ['Липецк', '141', '17', '97', '17'], '28327' : ['Курск', '145', '8', '100', '11'], 
	'28359' : ['Тамбов', '141', '19', '97', '19'], '28360' : ['Орел', '136', '8', '94', '11'], '28361' : ['Белгород', '149', '11', '103', '13'], '28362' : ['Владивосток', '155', '225', '110', '150'],  '28363' : ['Волгоград', '156', '20', '106', '18'], 
	'28364' : ['Нижний новогород', '115', '27', '76', '30'], '28366' : ['Новосибирск', '135', '110', '75', '92'],  '28381' : ['Новгород', '110', '6', '80', '3'], '28368' : ['Калининград', '121', '1', '84', '1'], '28369' : ['Иркутск', '143', '156', '95', '115'], 
	'28370' : ['Екатеринбург', '121', '60', '85', '45'],  '28385' : ['Казань', '121', '40', '84', '44'], '28393' : ['Омск', '135', '95', '75', '88'], '28395' :  ['Волгоград', '156', '20', '106', '18'],
	'28398' : ['Самара', '135', '42', '84', '14'], '28402' : ['Смоленск', '130', '1', '84', '14'], '28404' : ['Сочи', '156', '20', '84', '14'], '28406' : ['Уфа', '130', '45', '84', '14'], '28408' : ['Челябинск', '130', '55', '84', '14'], 'default' : ['121', '12', '84', '14']};
	
	function switch_map_down(x, y, map_dom) {
	$(map_dom).attr('style', 'top:' + x + 'px; left:' + y + 'px;');
	}
	
	$("#geo-select-down").change(function () {
		var i = $("#geo-select-down option:selected").attr('id');
		if(city_new[i]) {
		switch_map_down(city_new[i][3], city_new[i][4], "#map_mark_down");
		} else { switch_map_down(city_new['default'][2], city_new['default'][3], "#map_mark_down"); }
	}).change(); 
	
	$("#geo-select").change(function () {
		var i = $("#geo-select option:selected").attr('id');
		if(city_new[i]) {
		switch_map_down(city_new[i][1], city_new[i][2], "#map_mark");
		} else { switch_map_down(city_new['default'][0], city_new['default'][1], "#map_mark"); }
	}).change();

	(function() {
		var user_city = document.querySelectorAll('.skinned-select')[0].id;
		for(var key in city_new) {
		var str = city_new[key][0];
		if (user_city.search(str + '') != -1) { if(!$('#'+key).html() && city_new[key]) { break; } switch_map_down(city_new[key][1], city_new[key][2], "#map_mark"); $('.geo-banner').hide(); $('#c'+$('#'+key).val()).show(); $('#right_header_map .select-text').html($('#'+key).html()); break; }
		else continue;
	} })();


$('#geo-select-down').change(function(){
  $('.geo-banner-down').hide();
  $('#d'+$(this).val()).show();

//$('#geo-select').attr("selectedIndex",$(this).attr("selectedIndex"));
//$('#geo-select').change();

  return false;
})

$('#geo-select-down').change();

  $(document).pngFix();




/*   OLD&nbsp;*/

$("#drop_menu_geo").hide(0);
show_drop=0;
$("#triger_drop_m").click(function(e){
e.preventDefault();
if (show_drop==1) 
 { 
  $("#drop_menu_geo").hide(0);
   show_drop=0;
   return;
 }
 if (show_drop==0) 
 { 
  $("#drop_menu_geo").show(0);
   show_drop=1;
 }
});

$("#drop_menu_geo_d").hide(0);
show_drop_d=0;
$("#triger_drop_m_down").click(function(e){
e.preventDefault();
if (show_drop_d==1) 
 { 
  $("#drop_menu_geo_d").hide(0);
  $(this).prev().css("color","#000");
   show_drop_d=0;
   return;
 }
 if (show_drop_d==0) 
 { 
  $("#drop_menu_geo_d").show(0);
   show_drop_d=1;
   $(this).prev().css("color","#000");
 }
});
// для верхнего гео меню
$(".geo_menu").hide(0);
$(".geo_menu_down").hide(0);

$(".geo_menu_it").click(function(e){
e.preventDefault();
geoclass=$(this).attr('alt');
$("#geo_Baner").hide(0);
$(".curent").hide(0);
$("." + geoclass).show(0);
$("." + geoclass).addClass('curent');
//изменение нижнего гео меню
geoclass_d=$(this).attr('alt')+"d";
$("#geo_Baner_down").hide(0);
$(".curent_d").hide(0);
$("." + geoclass_d).show(0);
$("." + geoclass_d).addClass('curent_d');
});
//для нижнего гео меню


$(".geo_menu_it_down").click(function(e){
e.preventDefault();
geoclass_d=$(this).attr('alt');
$("#geo_Baner_down").hide(0);
$(".curent_d").hide(0);
$("." + geoclass_d).show(0);
$("." + geoclass_d).addClass('curent_d');
// изменение верхнего гео меню
geoclass=$(this).attr('alt');
geoclass=geoclass.replace(/d/,'');
$("#geo_Baner").hide(0);
$(".curent").hide(0);
$("." + geoclass).show(0);
$("." + geoclass).addClass('curent');
});
 });
