function Tooltip(marker, text, padding,id){
	this.marker_ = marker;
	this.text_ = text;
	this.padding_ = padding;
	this.id_ = id;
}
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';
	
	if (this.id_ != '')
	{
	var info = document.createElement("info");
	info.appendChild(document.createTextNode(this.id_));
	info.className = 'markinfo';
	info.style.position = 'absolute';
	info.style.visibility = 'hidden';
	map.getPane(G_MAP_FLOAT_PANE).appendChild(info);
	this.info_ = info;
	}
	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 - this.div_.clientWidth / 2);
	var yPos = markerPos.y - this.div_.clientHeight - 10;
	this.div_.style.top = yPos + 'px';
	this.div_.style.left = xPos + 'px';
	if (this.id_ != '')
	{
	this.info_.style.top = yPos+30 + 'px';
	this.info_.style.left = xPos+30 + '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('p_page').value = 25; 
}
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('+');
}
function ifBound (polygon, latLng){
	var bounds = polygon.getBounds();
	if(bounds != null && !bounds.containsLatLng(latLng)) {
		return false;
	}
	var numPoints = polygon.getVertexCount();
	var inPoly = false;
	var i;
	var j = numPoints-1;
	for(var i=0; i < numPoints; i++) { 
		var vertex1 = polygon.getVertex(i);
		var vertex2 = polygon.getVertex(j);
		if (vertex1.lng() < latLng.lng() && vertex2.lng() >= latLng.lng() || vertex2.lng() < latLng.lng() && vertex1.lng() >= latLng.lng())  {
			if (vertex1.lat() + (latLng.lng() - vertex1.lng()) / (vertex2.lng() - vertex1.lng()) * (vertex2.lat() - vertex1.lat()) < latLng.lat()) {
				inPoly = !inPoly;
			}
		}
		j = i;
	}
	return inPoly;
};

