function checkFieldText(elem, svalidator, smessage) {
  
  if (elem.value.match(svalidator)) return true;
  
  alert(smessage);
  elem.focus();
  return false;
  
}

function fixPNG(element) {
  
  if (/MSIE (5\.5|6).+Win/.test(navigator.userAgent)) {
    
    var src;
    
    if (element.tagName=='IMG') {
    
      if (/\.png$/.test(element.src)) {
        src = element.src;
		  	element.src = "/images/0.gif";
		  }
		
    } else {
        
      src = element.currentStyle.backgroundImage.match(/url\("(.+\.png)"\)/i);
      
      if (src) {
			
        src = src[1];
			
        element.runtimeStyle.backgroundImage="none";
      }
    }
		
    if (src) element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
	}
}  

var srv = {
  f_weather: 0,
  f_exch: 0
};


function showWeather(lang) {
  
  var req = new JsHttpRequest();
  
  req.onreadystatechange = function() {
    
    if (req.readyState == 4) {
      if (req.responseJS) {
          
          $('#r_weather').empty().append(req.responseJS.content);
          srv['f_weather'] = 1;
      }
    }
  }
  req.caching = true;
  req.open('POST', '/rs/get_weather/', true);
  req.send({lang: lang});
  
}

function Exchange() {
  
  var req = new JsHttpRequest();
  
  req.onreadystatechange = function() {
    if (req.readyState == 4) {
      if (req.responseJS) {
        
        $('#r_exch').empty().append(req.responseJS.content);
        
        srv['f_exch'] = 1;
      }
    }
  }
  
  req.caching = true;
  req.open('POST', '/rs/exchange/', true);
  req.send();
}

//{{{ getIcon()
function getIcon() {
  
  var icon = new GIcon();
  
  icon.image = "images/g_home.png";
  
  icon.shadow= "images/g_home_sh.png";
  icon.iconSize = new GSize(42, 32);
  icon.shadowSize = new GSize(42, 32);
  icon.iconAnchor = new GPoint(23, 32);
  icon.infoWindowAnchor = new GPoint(21, 13);
  return icon;
}
//}}}

//{{{ changePlace()
function changePlace(lat, lng, zoom) {
  
  var rs = false;
  
  if (GBrowserIsCompatible()) {
    
    map = new GMap2($('#geo_map').get(0));
    map.enableScrollWheelZoom();
    map.enableDoubleClickZoom();
    map.setCenter(new GLatLng(lat, lng),  zoom);
    map.addControl(new GLargeMapControl3D());
    map.addControl(new GMapTypeControl());
    
    rs = true;
  }
  
  return rs;
}
//}}}

//{{{ showPoint()
function showPoint(lat, lng, txt) {
  
  var point = new GLatLng(lat, lng);
  
  var marker = new GMarker(point, getIcon());
  
  GEvent.addListener(marker, 'click', function() {
    marker.openInfoWindowHtml(txt);
  });
  
  map.addOverlay(marker);
  
  return false;
} 
//}}}

