function Tooltip(marker, text, padding){
	this.marker_ = marker;
	this.text_ = text;
	this.padding_ = padding;
}
Tooltip.prototype.initialize = function(map){
	var div = document.createElement("div");
	div.appendChild(document.createTextNode(this.text_));
	div.className = 'tooltip';
	div.style.position = 'absolute';
	div.style.visibility = 'hidden';
	
	map.getPane(G_MAP_FLOAT_PANE).appendChild(div);
	this.map_ = map;
	this.div_ = div;

}
Tooltip.prototype.remove = function(){
	this.div_.parentNode.removeChild(this.div_);
}
Tooltip.prototype.copy = function(){
	return new Tooltip(this.marker_,this.text_,this.padding_);
}
Tooltip.prototype.redraw = function(force){
	if (!force) return;
	var markerPos = this.map_.fromLatLngToDivPixel(this.marker_.getPoint());
	var iconAnchor = this.marker_.getIcon().iconAnchor;
	var xPos = Math.round(markerPos.x+5);
	var yPos = markerPos.y;
	this.div_.style.top = yPos + 'px';
	this.div_.style.left = xPos + 'px';
}
Tooltip.prototype.show = function(){
	this.div_.style.visibility = 'visible';
	this.div_.style.opacity = 1;
}
Tooltip.prototype.popup = function(){
	this.info_.style.visibility = 'visible';
	this.info_.style.opacity = 1;
}
Tooltip.prototype.hide = function(){
	this.div_.style.visibility = 'hidden';
}
function pass(field,val){
if (field == 'p_city'){ 
document.getElementById('p_p').value = 1; 
}
document.getElementById(field).value = val;

Next();
}
function isnum(elem) {
var str = elem.value;
var re = /^[-]?\d*\.?\d*$/;
str = str.toString();
if (!str.match(re)) { return false; }
return true;
}
function valid(){
if(!isnum(document.getElementById('mnprice'))) {
document.getElementById('mnprice').value = '';
}
else if(!isnum(document.getElementById('mxprice'))) {
document.getElementById('mxprice').value = '';
}
else if(parseInt(document.getElementById('mnprice').value) >= parseInt(document.getElementById('mxprice').value)) {
document.getElementById('mnprice').value = '';
}
else if(parseInt(document.getElementById('mxprice').value) <= parseInt(document.getElementById('mnprice').value)) {
document.getElementById('mxprice').value = '';
}
else
{
document.getElementById('p_pfrom').value = document.getElementById('mnprice').value;
document.getElementById('p_pto').value = document.getElementById('mxprice').value;
Next();
}
}
function check(field,field2)
{
  if(document.getElementById(field).checked == true)
  document.getElementById(field2).value = '1';
  else
  document.getElementById(field2).value = '0';
  Next();
}
function file (url) {
    var req = this.window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
    if (!req) {throw new Error('XMLHttpRequest not supported');}
    req.open("GET", url, false);
    req.send(null);
    return req.responseText.split('\n');
}
function str_replace (search, replace, subject, count) {
    var i = 0, j = 0, temp = '', repl = '', sl = 0, fl = 0,
            f = [].concat(search),
            r = [].concat(replace),
            s = subject,
            ra = r instanceof Array, sa = s instanceof Array;
    s = [].concat(s);
    if (count) {
        this.window[count] = 0;
    }

    for (i=0, sl=s.length; i < sl; i++) {
        if (s[i] === '') {
            continue;
        }
        for (j=0, fl=f.length; j < fl; j++) {
            temp = s[i]+'';
            repl = ra ? (r[j] !== undefined ? r[j] : '') : r[0];
            s[i] = (temp).split(f[j]).join(repl);
            if (count && s[i] !== temp) {
                this.window[count] += (temp.length-s[i].length)/f[j].length;}
        }
    }
    return sa ? s : s[0];
}
